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
Conditional function activation?
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#2
RE: Conditional function activation?

First off, you'll want to change true to false in your AddEntityCollideCallback line. The true signifies that the callback will be removed once triggered, meaning your function will run only once. Changing it to false lets the callback run each time the collision happens, so that once the player returns to the hallway with the hammer, the function will run again.

Secondly, this semantics bug is likely stemming from a map cache issue. I see nothing wrong syntactically nor semantically in your code. Try adding some debug messages to see (visually) the value of HasItem("stone_hammer_1"). Do something like AddDebugMessage("does player have hammer: "+HasItem("stone_hammer_1"), false);

Thirdly, if you want to do this a different way, you can leave true as is, and simply add the collision callback after the player picks up the hammer. This is a simple way to bypass the conditional and at the same time take advantage of the auto-remove feature of collision callbacks, so you don't have to remove it manually.

To do this, create a function called HammerPick or something similar. Next, select your hammer item in the level editor. Go to the second tab, and in the PlayerInteractCallback field write HammerPick. The function takes one parameter, a string. Then just stick the AddEntityCollideCallback line in that function, and you can totally disregard your if statement in CollideActivateLiveGrunt function.

PHP Code: (Select All)
void HammerPick(string &in hammerRef)
{
//just an example to show you the parameter


Off to MW3~!

(This post was last modified: 03-14-2012, 04:39 AM by palistov.)
03-14-2012, 04:36 AM
Find


Messages In This Thread
Conditional function activation? - by Damascus - 03-14-2012, 03:58 AM
RE: Conditional function activation? - by palistov - 03-14-2012, 04:36 AM



Users browsing this thread: 1 Guest(s)