Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help So many errors
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#8
RE: So many errors

(02-11-2013, 07:52 PM)Kiandra Wrote: I want the music to play every time, the wind effect to play the first time only, then the timers to be triggered every time the player enters the area (reset if they exit) until the event is triggered. Once the event has occurred, I don't want the player to be able to trigger it again.

I'm starting to get the feeling that this script is way over my head :S

You'll get there, if you take the time to break down the problems and code them bit by bit.
However, since you want to actually re-set the timers if they leave the area (rather than just make them invalid when they expire), we should do things slightly differently.


void OnStart()
{
AddEntityCollideCallback("Player", "Area_VisionTrigger", "Script_VisionTrigger", false, 0);
SetLocalVarInt("HasWindPlayed", 0) // setup for use in Script_VisionTrigger
}


void Script_VisionTrigger (string &in asParent, string &in asChild, int alState)
{

if(alState == 1)
{
PlayMusic("vision_music", true, 1, 6, 7, false); // this is to happen every time

if (GetLocalVarInt("HasWindPlayed") == 0) // wind stuff happens first time only
{

CreateParticleSystemAtEntity("Area_VisionWind", "ps_dust_whirl.ps", "Area_VisionWind", false);
SetLampLit("candlestick_floor_1", false, true);
SetLampLit("candle_floor_small_1", false, true);
PlaySoundAtEntity("blow", "general_wind_whirl", "Player", 0.0f, false);
SetLocalVarInt("HasWindPlayed", 1);
}

AddTimer("fadescreen", 18.1f, "timer_fade");
AddTimer("visionstarter", 19.2f, "timer_vision_start");
AddTimer("visionender", 203.53f, "timer_vision_end");
SetLocalVarInt("IsPlayerInArea", 1); // where 1 is yes and 0 is no
}
if(alState == -1)
{
StopMusic(3, 7);
RemoveTimer("fadescreen");
RemoveTimer("visionstarter");
RemoveTimer("visionender");

SetLocalVarInt("IsPlayerInArea", 0); // where 1 is yes and 0 is no
}
}

void Potential_Timer_Function(string &in strTimer)
{
if (GetLocalVarInt("IsPlayerInArea") == 1)
{
// do the stuff
SetEntityActive("Area_VisionTrigger", false); // this will deactivate the trigger area
}
}

Decided to keep the variables for checking if you are in / out of the area, despite the fact that with the RemoveTimers they are not so important, but a nice extra layer of security never hurt

EDIT: Ninja'd, but still useful i hope

(This post was last modified: 02-11-2013, 08:59 PM by Adrianis.)
02-11-2013, 08:55 PM
Find


Messages In This Thread
So many errors - by CarnivorousJelly - 02-10-2013, 10:43 PM
RE: So many errors - by FlawlessHappiness - 02-10-2013, 11:13 PM
RE: So many errors - by CarnivorousJelly - 02-11-2013, 12:54 AM
RE: So many errors - by FlawlessHappiness - 02-11-2013, 07:48 AM
RE: So many errors - by CarnivorousJelly - 02-11-2013, 07:52 PM
RE: So many errors - by Adrianis - 02-11-2013, 08:55 PM
RE: So many errors - by CarnivorousJelly - 02-12-2013, 06:45 AM
RE: So many errors - by Adrianis - 02-11-2013, 11:22 AM
RE: So many errors - by FlawlessHappiness - 02-11-2013, 08:36 PM
RE: So many errors - by Adrianis - 02-12-2013, 06:14 PM
RE: So many errors - by CarnivorousJelly - 02-13-2013, 12:54 AM
RE: So many errors - by CarnivorousJelly - 02-14-2013, 05:23 AM
RE: So many errors - by TheGreatCthulhu - 02-14-2013, 01:23 PM



Users browsing this thread: 1 Guest(s)