Game Development Community

Schedule

by Temasek Polytechnic · in Torque Game Engine · 05/31/2006 (7:44 pm) · 2 replies

I want to add shedule to the do the following for an AIPlayer, but i dont know how.

In the AIPlayer::create function, i created the AIPlayer. This AIPlayer will then either run(controlled by a doRun function) or look around(control by a doLook function) after 5 seconds.

There is a chooseAction function that generates a random number between 0 and 1. If the number is 0, then it will execute the doRun function, else it will execute the doLook function.

Once the doRun or doLook function has completed executing, it will call the chooseAction function again after 5 seconds.

This means that every 5 seconds, the AIPlayer will either run to a location or look around.

How do i use the schedule for the above?

#1
05/31/2006 (7:55 pm)
You create a central function for it's "thinking" process like AIPlayer::think(%aiplayer), then include a reference inside the function like %aiplayer.schedule(5000, "think") to make it loop, and finally when you create the ai, just call %ai.think() on it. You can make all your decisions about what to do inside the think or chooseAction, or whatever you call it function.
#2
05/31/2006 (8:19 pm)
Thank you Paul! I'll try it out!