Game Development Community

aiplayer.cs - Where should handleWaypointsAndChase be called?

by Ben Ward · in Torque Game Engine · 10/20/2002 (6:11 am) · 3 replies

First of all, thanks to Stefan for the great resource on bots at
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2505.

Where should handleWaypointsAndChase be called in aiplayer.cs?

I hope this isn't a stupid question. My bots are in and chasing me in an outdoor enviroment without waypoints. However they only adjust their aim and direction at onReachDestination. What this looks like is the bot running a line to where I *was* before correcting itself and doing the same process over again.

function AIPlayer::onReachDestination(%this) {
echo( "onReachDestination" );
if(%this.player.hasInventory($weaponammo) == 0)
{
%this.getstuff($weaponammo);
}
%this.handleWaypointsAndChase(%this);
}

What I am looking for is a way to update the position more frequently than one every onReachDestination.
Any one have any pointers?

Thanks,
Ben

About the author

Recent Threads


#1
10/20/2002 (9:20 am)
Can you schedule a function to be called that will schedule itself and have that function update positions ?
#2
10/20/2002 (10:01 am)
Robert,

Thanks for your help!

I am only aware of onMove and onReachDestination inside of aiplayer.cs. If I was to create a new function, where should it exist? In the engine code? How can I schedule it? It only needs to run every 1 or 2 seconds.

Thanks,
Ben
#3
10/20/2002 (1:10 pm)
Might I suggest using the method you use to get them to chase you ...
at that time schedule a function (maybe a recursive one)
that will Update the target information.

I notice your scripts refers to AI as %this.player
this must be an Old script or old Code ?
not using the latest release?
here is one I have placed in my spawn for ai
%this.schedule(100 * 10, "handleObjective", %this);

this will start my Objective Handling code.
.. something Ive added which is great for Objective Handlers as now each ai can hold a List of objectives
and this I handle in the scripts (setting, getting, adding,...using, updating)