07-07-2012, 09:09 PM
Hello,
So I was working on my custom story when I decided upon making a function. In the script I have a callback for when the player enters an area (ScriptArea_1) and the function is called to make the player look at an object (hatch_ceiling_1) and it then calls multiple timers. However, all the timers are malfunctioning in that they make the sounds and particle effects loop. Here's an example:
Here is the scripting:
void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "Look_splash", true, 1);
}
//Watermonster introduction
void Look_splash(string &in asParent, string &in asChild, int alState)
{
StartPlayerLookAt("hatch_ceiling_1", 5, 5, "SplashTimers");
}
void SplashTimers()
{
AddTimer("", 0.5, "Splash_1");
AddTimer("", 5, "Splash_2");
AddTimer("", 10, "Splash_3");
}
void Splash_1(string &in asTimer)
{
CreateParticleSystemAtEntity("", "ps_impact_water_low.ps", "ScriptArea_splash", false);
CreateParticleSystemAtEntity("", "ptest_dust_falling.ps", "ScriptArea_splash", false);
PlaySoundAtEntity("", "react_pant.snt", "ScriptArea_splash", 0.5, false);
PlaySoundAtEntity("", "impact_water_med.snt", "ScriptArea_splash", 0.5, false);
AddTimer("", 5, "Splash_2");
}
void Splash_2(string &in asTimer)
{
CreateParticleSystemAtEntity("", "ps_impact_water_low.ps", "ScriptArea_splash", false);
CreateParticleSystemAtEntity("", "ptest_dust_falling.ps", "ScriptArea_splash", false);
PlaySoundAtEntity("", "water_lurker_attack_rev.snt", "ScriptArea_splash", 0.5, false);
PlaySoundAtEntity("", "impact_water_high.snt", "ScriptArea_splash", 0.5, false);
AddTimer("", 5, "Splash_3");
}
void Splash_3(string &in asTimer)
{
PlaySoundAtEntity("", "water_lurker_eat_rev.snt", "ScriptArea_splash", 0.5, false);
PlaySoundAtEntity("", "water_lurker_idle_rev.snt", "ScriptArea_splash", 0.5, false);
StopPlayerLookAt();
}
I'd appreciate any advice or solutions anyone has to offer. Thanks.
PS: If anyone requires pictures of the areas in the Level Editor, I'd be happy to post them.
EDIT: Fixed script (didn't have full script).
So I was working on my custom story when I decided upon making a function. In the script I have a callback for when the player enters an area (ScriptArea_1) and the function is called to make the player look at an object (hatch_ceiling_1) and it then calls multiple timers. However, all the timers are malfunctioning in that they make the sounds and particle effects loop. Here's an example:
Here is the scripting:
void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "Look_splash", true, 1);
}
//Watermonster introduction
void Look_splash(string &in asParent, string &in asChild, int alState)
{
StartPlayerLookAt("hatch_ceiling_1", 5, 5, "SplashTimers");
}
void SplashTimers()
{
AddTimer("", 0.5, "Splash_1");
AddTimer("", 5, "Splash_2");
AddTimer("", 10, "Splash_3");
}
void Splash_1(string &in asTimer)
{
CreateParticleSystemAtEntity("", "ps_impact_water_low.ps", "ScriptArea_splash", false);
CreateParticleSystemAtEntity("", "ptest_dust_falling.ps", "ScriptArea_splash", false);
PlaySoundAtEntity("", "react_pant.snt", "ScriptArea_splash", 0.5, false);
PlaySoundAtEntity("", "impact_water_med.snt", "ScriptArea_splash", 0.5, false);
AddTimer("", 5, "Splash_2");
}
void Splash_2(string &in asTimer)
{
CreateParticleSystemAtEntity("", "ps_impact_water_low.ps", "ScriptArea_splash", false);
CreateParticleSystemAtEntity("", "ptest_dust_falling.ps", "ScriptArea_splash", false);
PlaySoundAtEntity("", "water_lurker_attack_rev.snt", "ScriptArea_splash", 0.5, false);
PlaySoundAtEntity("", "impact_water_high.snt", "ScriptArea_splash", 0.5, false);
AddTimer("", 5, "Splash_3");
}
void Splash_3(string &in asTimer)
{
PlaySoundAtEntity("", "water_lurker_eat_rev.snt", "ScriptArea_splash", 0.5, false);
PlaySoundAtEntity("", "water_lurker_idle_rev.snt", "ScriptArea_splash", 0.5, false);
StopPlayerLookAt();
}
I'd appreciate any advice or solutions anyone has to offer. Thanks.
PS: If anyone requires pictures of the areas in the Level Editor, I'd be happy to post them.
EDIT: Fixed script (didn't have full script).