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
Any way to loop a AddEntityCollideCallback?
theabcs Offline
Junior Member

Posts: 5
Threads: 2
Joined: Apr 2012
Reputation: 0
#1
Any way to loop a AddEntityCollideCallback?

Here is my script:

void scare(string &in asParent, string &in asChild, int alState) {
AddLocalVarInt("arm", 1);
if(GetLocalVarInt("arm") == 10){

PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_scare", "Player", 0, false);

GiveSanityDamage(10.0f, true);
SetSwingDoorClosed("door2", true, true);
SetEntityActive("grunt2", true);

AddEnemyPatrolNode("grunt2", "PathNodeArea_17", 0, "idle");
AddEnemyPatrolNode("grunt2", "PathNodeArea_18", 0, "idle");
AddEnemyPatrolNode("grunt2", "PathNodeArea_19", 0, "idle");
AddEnemyPatrolNode("grunt2", "PathNodeArea_20", 0, "idle");
AddEnemyPatrolNode("grunt2", "PathNodeArea_21", 0, "idle");
AddEnemyPatrolNode("grunt2", "PathNodeArea_22", 0, "idle");
AddTimer("monster1", 30.0f, "gleave");
}
}


Is there any way to loop the script so that even if the script has been used, it can be reset/reused? The script works fine in game, however it is a one time deal and I would like it to be reusable multiple times.
(This post was last modified: 04-04-2012, 10:55 PM by theabcs.)
04-04-2012, 10:29 PM
Find
stonecutter Offline
Member

Posts: 140
Threads: 17
Joined: Feb 2011
Reputation: 4
#2
RE: Any way to loop a AddEntityCollideCallback?

check out !

AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates);


It has nothing to do with your script yor callback gets deleted after one use ! Take a look at your "OnStart" and check you set the red market thing to false !

We Shall Arise - Death / Grind from Bavaria
Musicvideo : http://goo.gl/HzxvLK
Facebook : http://goo.gl/9YfYCV
Free Album : http://goo.gl/sEBW2X
(This post was last modified: 04-04-2012, 10:36 PM by stonecutter.)
04-04-2012, 10:35 PM
Find
theabcs Offline
Junior Member

Posts: 5
Threads: 2
Joined: Apr 2012
Reputation: 0
#3
RE: Any way to loop a AddEntityCollideCallback?

(04-04-2012, 10:35 PM)stonecutter Wrote: check out !

AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates);


It has nothing to do with your script yor callback gets deleted after one use ! Take a look at your "OnStart" and check you set the red market thing to false !

Well in my script i have a local variable that has to be added until it reaches a limit. Because of this, the script is already on false. Here is my parent function:

AddEntityCollideCallback("Player", "ScriptArea_5", "scare", false, 0);

So, my script works fine, until it is 100% activated and it is then unresponsive.

04-04-2012, 10:43 PM
Find
stonecutter Offline
Member

Posts: 140
Threads: 17
Joined: Feb 2011
Reputation: 4
#4
RE: Any way to loop a AddEntityCollideCallback?

is this right ?
AddLocalVarInt("arm", 1);

you set it to 1 but in the next if statement it has to be 10 ?

where is the function to increase the variable "arm" ?
maybe it has something to do that you have to set the variable again to 1.
can you post the whole script ?

We Shall Arise - Death / Grind from Bavaria
Musicvideo : http://goo.gl/HzxvLK
Facebook : http://goo.gl/9YfYCV
Free Album : http://goo.gl/sEBW2X
04-04-2012, 10:59 PM
Find
theabcs Offline
Junior Member

Posts: 5
Threads: 2
Joined: Apr 2012
Reputation: 0
#5
RE: Any way to loop a AddEntityCollideCallback?

(04-04-2012, 10:59 PM)stonecutter Wrote: is this right ?
AddLocalVarInt("arm", 1);

you set it to 1 but in the next if statement it has to be 10 ?

where is the function to increase the variable "arm" ?
maybe it has something to do that you have to set the variable again to 1.
can you post the whole script ?
I cannot post the whole script because it is over 400 lines. Firstly, AddLocalVarInt("arm", 1); means that you are adding a value of 1 to "arm". So this script says when the player collides with a certain script function so many times (10), then to activate the following. I also figure out the answer to my problem so no need to worry.


04-05-2012, 04:31 AM
Find
stonecutter Offline
Member

Posts: 140
Threads: 17
Joined: Feb 2011
Reputation: 4
#6
RE: Any way to loop a AddEntityCollideCallback?

so i think you added a Counter reset ? set "arm" = 0 after you reach 10, so that you will count again ?

We Shall Arise - Death / Grind from Bavaria
Musicvideo : http://goo.gl/HzxvLK
Facebook : http://goo.gl/9YfYCV
Free Album : http://goo.gl/sEBW2X
04-05-2012, 10:07 AM
Find
theabcs Offline
Junior Member

Posts: 5
Threads: 2
Joined: Apr 2012
Reputation: 0
#7
RE: Any way to loop a AddEntityCollideCallback?

(04-05-2012, 10:07 AM)stonecutter Wrote: so i think you added a Counter reset ? set "arm" = 0 after you reach 10, so that you will count again ?
Yes i did exactly that by forcing the script to add a negative value to the variable.
04-13-2012, 01:45 AM
Find




Users browsing this thread: 1 Guest(s)