void spawn_splash(void self, char water_splash_name, char splash_sound_name, int frame, int map) {
void splash;
float base = gep(self,"base");
if ( map == NULL() ) map = 0;
splash = spawnsubentity_relative(water_splash_name,RIPPLE_XSHIFT,1,NULL(),self);
changeentityproperty(splash,"position",NULL(),NULL(),base+RIPPLE_ASHIFT+get_water_height()-WATER_H_FIX);
changeentityproperty(splash,"parent",self);
changeentityproperty(splash,"map",map);
if ( frame != NULL() ) {
changeentityproperty(splash,"animpos",frame);
playsample(loadsample(splash_sound_name));
}
return splash;
}
// return 0 if it doesn't exists
int check_splash_pos(void self, void splash, char model_name) {
if ( gep(splash,"exists") ) {
int anim_pos = gep(splash,"animpos");
if ( !is_name(splash,"defaultmodel",model_name) || !is_for(splash,self) ) return 0;
if ( anim_pos <= SPLASH_DOWN_START_FRAME ) {
float x = gep(self,"x");
float z = gep(self,"z");
float a = gep(self,"a");
float base = gep(self,"base");
int dir = gep(self,"direction");
float ex = gep(splash,"x");
float xshift = RIPPLE_XSHIFT;
if ( !dir ) xshift *= -1;
if ( ex != x+xshift ) {
cep(splash,"position",x+xshift,z+1,base+RIPPLE_ASHIFT+get_water_height()-WATER_H_FIX);
}
} // fine if animpos
return 1;
} else return 0; // fine if exists
}