Controlling the
Archer
This
is the Control Loop for the archer. It dictates behaviors and actions of the archer.
if (timeout){ |
Since all the actions of the baddy are controlled through a timeout loop, this with have to be started in the Initialize() function. The first thing the loop does is handles the modes of the NPC. If this.mode is equal to 0, then the Movement() function is to be called. This of course moves the archer as well locates its target and tests for instances to call the other modes. So if it has said that this.mode is equal to 1, then instead of moving, the archer will be calling the function ShootBow(), meaning the archer is in the process of shooting. But if this.mode is 2, then SwordAttack() has been called and the archers target has gotten to close to the NPC for a bow attack. The next if statement tests to see if the NPC is still alive. If so, then the Control Loop needs to loop again, so the timeout is set back to .05. Otherwise the baddy just died and the SpinMove() function should be called. The last else statement is incase a glitch or two happens when toying with the NPCs targets. |
This is the nerve system of the completed
archer NPC. This is a stand-alone loop that only needs to be initiated in order
to run amok.
Previous Topic
Home