Game Development Community

Using Call()

by Bryce · in General Discussion · 06/14/2009 (7:02 pm) · 3 replies

Hello Everyone,

I've come across a confusing situation that I need a bit of help with.

I've got a path marker with a field called "event." The idea is that I can put in this field a function name, such as SetActionThread("Scan"), and when an NPC runs over that marker, they call whatever function is saved in the Event field.

I have everything figured out, except for getting the function to run. I've heard about using the Call() function, but I can't seem to figure out the best way to make this happen.

I'm not sure how else to explain it, but hopefully someone understands? Help is greatly appreciated!

Thanks,
Bryce

#1
06/14/2009 (8:07 pm)
Have you tried doing an eval(%ctrl.event), where event = "setActionThread(\"scan\");"?
#2
06/14/2009 (8:19 pm)
Wouldn't you need to put in a function to the AIplayer which hooks in the getnode/location/thing (like when it checks for the next node on a path) and then check if that node has an event value (via a console style call/function which you'd have to write) and then get the player again and make him play that event. I might have confused myself there...

eg:
get aiPlayer
assign aiplayer node
getnode
if(node has event) event=thisevent
get aiplayer targetting node
aiplayer.thisevent
#3
06/14/2009 (9:04 pm)
Yes! Eval() works, I got it working! Thanks so much!

@Steve: It's all handled in the state machine. Every think tick, the AI Player checks to see if he's within 1 meter of his target node. There, he checks to see if the marker has a stopTime specified (and will wait there for that long, or move to the next marker). If the node has an event value, eval() runs it.

Time for some level scripting, I want to release another blog...