Man, I've seriously been embarrassing myself in my latest scripting attempts.
Okay. This one is tested and worked in my test quest.
As soon as Link gets into the water, the splash sound plays, and then repeats every 10 (configurable) frames. When Link stops walking or leaves the water, the timer resets so it plays again when he next moves.
After I wrack my brain for possible improvements I might even submit this to the DB.
CODE
import "std.zh"
const int splashFreq = 10; //Number of frames between splash SFX
global script waterSplash{
void run(){
int splashTimer = splashFreq;
while(true){
if( Screen->ComboT[ComboAt(Link->X+7,Link->Y+15)] == CT_SHALLOWWATER
&& Link->Action==LA_WALKING
){
if( splashTimer >= splashFreq ){
Game->PlaySound(SFX_SPLASH);
splashTimer = 0;
}
splashTimer++;
}
else splashTimer = splashFreq;
Waitframe();
}
}
}
By the way, the last version checked if Link's position changed to run the sound effect, as I wasn't thinking of Link->Action at the time.
Edited by MoscowModder, 25 January 2012 - 06:23 PM.