Using callbacks instead of schedules
by Nmuta Jones · in Torque Game Engine · 10/20/2008 (8:06 pm) · 5 replies
I have a bunch of bots that follow my player, using a method similar to the "getClosestHuman" method made popular by 3DGPAI1 books. (Ken Finney).
At any rate, I have noticed that using schedules to dictate player behavior can be problematic, especially since it can create a situation where the game attempts to call or access objects that no longer exist after a player has been killed.
I have tried using the "cancel" method onDeath to cancel the schedule for such players but sometimes this still does not seem to work. Sometimes it does, sometimes it does not, and when it does not, it creates a memory leak of sorts and eventually crashes the game when the game is continually looking for an increasing number of objects that don't exist.
I remember hearing that CALLBACKS are preferable to schedules when dealing with players or NPCs. But I am very unsure about how to use callbacks this way. I know about onDeath, onEnterLiquid, etc., but how do make callbacks to trigger "onReachDestination" or things of that nature, when a bot has reached its destination and needs to receive new marching orders?
Any help or point in the right direction would be appreciated.
Thanks.
At any rate, I have noticed that using schedules to dictate player behavior can be problematic, especially since it can create a situation where the game attempts to call or access objects that no longer exist after a player has been killed.
I have tried using the "cancel" method onDeath to cancel the schedule for such players but sometimes this still does not seem to work. Sometimes it does, sometimes it does not, and when it does not, it creates a memory leak of sorts and eventually crashes the game when the game is continually looking for an increasing number of objects that don't exist.
I remember hearing that CALLBACKS are preferable to schedules when dealing with players or NPCs. But I am very unsure about how to use callbacks this way. I know about onDeath, onEnterLiquid, etc., but how do make callbacks to trigger "onReachDestination" or things of that nature, when a bot has reached its destination and needs to receive new marching orders?
Any help or point in the right direction would be appreciated.
Thanks.
About the author
Lead Developer for MediaBreeze Multimedia
#2
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5939
10/21/2008 (6:23 am)
Ok, this may be the resource you are speaking of: it looks very good.http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5939
#3
10/21/2008 (6:45 am)
If you set schedule up correctly on the owner object (ie. second parameter is an object id, not 0) then you should have no problem deleting the object, because that would cancel the schedule afaik.
#4
Aha! I think this is it, and it actually mentions the link you posted in it's comments sections.
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=13632
Anyhow, compare that and the other link, I haven't actually looked into either of them.
10/21/2008 (9:14 am)
Nmuta, no that's not it. The one I'm thinking of was posted earlier this year. I usually bookmark these things for future reference but don't seem to have it......Aha! I think this is it, and it actually mentions the link you posted in it's comments sections.
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=13632
Anyhow, compare that and the other link, I haven't actually looked into either of them.
#5
10/21/2008 (9:40 am)
Ok, thanks!
Associate Steve Acaster
[YorkshireRifles]
if(!isObject(%targetplayer)) { return; //do nothing or some other code }There is a resource somewhere for implementing a subscription system of messaging events based on the way Unreal does it.