Scripted Gameplay Flow Control

Miscellaneous Forums/General Discussion/Scripted Gameplay Flow Control

An approach I used and worked really good was to copy the ai coding approach from fps creator. They had a scripting approach worked as followed.

:state=0:turnLeft,state=1;
:state=1,enemySighted:moveFore;
:state=1,enemyNotSighted:state=0;

You would attach this script to an agent. It's default state value is 0. The first part of the first statement inbetween the ":" is the condition, the second is the action. So in line one, the condition is, "does state = 0". If true then execute the action afterword. In this case turnLeft, and then set the state value to 1. Then the next line checks to see if the state value is 1, and if the enemy is in sight. If so it executes the moveFore function. The script is executed once a cycle and the state value static between cycles. State would be field value attached to the entity.

It's a pretty simple AI scripting system, but it work quite good.