In C-Script, I usually have a single wait() function at the end of the entire state blending (it's where I have one, two, or multiple states processed depending on conditions). This will reduce frame rate but the entity would have done everything in a single frame, instead of spread out over multiple frames.

I'm used to writing things in C/C++ where *everything* possible is done in a single frame >_<

For C-Script, I separate the animations from the code like this:

 Code:
// All three of these have a while(my != NULL){... wait(1);} loop in them
// And any sort of 'cleanup' would be done right after the loop
// And any sort of 'init' would be done before the loop
function attach_animate(){...} // Will animate based on variables
function attach_path(){...} // Will decide to move based on variables
function attach_mind(){...} // Will decide to take actions based on variables

// Entity
action ai_ent
{
   // Stuff
   ...
   // Attach processes
   attach_animate();
   attach_path();
   attach_mind();
   // Stuff
   ...
}


Sorting crap into multiple looping functions will actually have the effect of doing everything at once in a single frame as long as each individual loop has just one wait(); in it.

If ya sort it correctly you can call the different functions and leave some out, or add others to quickly blend many different ai methods.

For example, you can separate each mind into different components so it's easy for multiple things to be blended together:
 Code:
function attach_distance_attacker(){...} // If the entity has a gun, then it will keep the distance from the closest target while firing if it decides to attack using a gun
function attach_close_attacker(){...} // If the entity has a sword or close weapon, then it will get in close to the target to attack
function attach_evasive_move_pattern(){...} // When fighting, the entity will focus on being hard to hit and will find ways to be hard to hit
function attach_aggressive_move_pattern(){...} // When fighting, the entity will charge at the target, trying to overwhelm the target preventing escape
function attach_item_search(){...} // The entity will search for items if needed
function attach_target_search(){...} // The entity will really want to find stuff to kill, as opposed to wandering around in exploration


For example, you can combine the charging with the gun, so the entity still keeps a distance, yet it chases after the player with a mechanical rage firing wildly, and the gun combined with the evasive one would have the entity keep distance and hide behind things here and there.

It may be obvious in the melee case to have the entity charge, but you could combine the evasive method to have the entity jump around and try to ambush the player, and run off.

This can be achieved by having the patterns know how much distance the entity wants to keep, and act differently by how close or how far the entity wants to be.

There's lots of ways to get these to work together, but I hope you get the idea.

Last edited by WolfCoder; 04/24/08 16:42.