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
Secret Idea (dun dun DUN) + Help Needed
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#13
RE: Secret Idea (dun dun DUN) + Help Needed

(04-08-2011, 08:18 AM)Simpanra Wrote: I have looked at palistov's script and I am slightly confused, it looks like it may do what I want but I can't find the place in which I would place my collide callback function for when I collide with the first area. Also, as far as my limited knowledge goes, it looks like the restore sanity function would simply happen straight after the drain sanity function?

Sorry if i am completely mistaken but thank you all for the help so far =)


You add the collide callback under your OnStart()

And no, the drain will end once the player leaves the area (when alState == -1), and the restoration of sanity will also only occur on exiting the script area. I had some strange idea with the local vars which match alState...I'm starting to think that they aren't even needed.

the entire script file containing only your drain event will look like this:

void OnStart()
{
AddEntityCollideCallback("Player", "DrainArea", "SanityDrain", false, 0);
}

void SanityDrain(string &in asParent, string &in asChild, int alState)
{
if(alState == 1) {
SetLocalVarInt("areacheck", 1);
SetLocalVarFloat("defaultsanity", GetPlayerSanity());
}
if(alState == -1) {
Set LocalVarInt("areacheck", -1);
RemoveEntityCollideCallback("Player", "DrainArea"); // this will make the even not occur twice.
}
SetLocalVarInt("damage", 0);
if(GetLocalVarInt("areacheck") == 1) {
for(int s=1;s<100;s++) AddTimer("drain"+s, 1.0, "SanityDrain"); // drain will happen 99 times
}
if(GetLocalVarInt("areacheck") == -1) RestoreDrainedSanity();
}

void SanityDrain(string &in asTimer)
{
GiveSanityDamage(5, false);
AddLocalVarInt("damage", 5); //I suggest not using effects. This may turn out to be very annoying
}

void RestoreDrainedSanity()
{
SetPlayerSanity(GetPlayerSanity() + GetLocalVarFloat("defaultsanity"))
for(int s=1;s<100;s++) RemoveTimer("drain"+s);
}


EDIT:
This current script can be gimmicked by the player; they can simply step in then step backwards. Using two areas would actually provide the intended effect. Anxt was right Big Grin

(This post was last modified: 04-08-2011, 05:45 PM by palistov.)
04-08-2011, 05:39 PM
Find


Messages In This Thread
RE: Secret Idea (dun dun DUN) + Help Needed - by palistov - 04-08-2011, 05:39 PM



Users browsing this thread: 1 Guest(s)