you guys have been waiting,
its still in development but im releasing
some code so you guys could see what im including
in this new ecxiting NEW AI.

The Script im releasing is a little sample
of the Ally Script

A friendly entity who helps you out in battle

Since This is a little demo from the ally script
which is currently being worked on

1. The ally will not follow you
2. May have problems with engine crashes
3. Does not have all the features in the ai

the script works perfectly.
all you have to do is assign the action to your
ally. If you want your ally to attack, Make shure
the flag1 is checked in your enemy action and insert a number in the
skill 9 section.

remember! if you dont check the flag1 and insert
a value in skill 9 in your Enemy Action
actor_walk_fight or anything like that, your
ally wont attack it!

plus+ if you shoot your own ally, it will fire
at you
Enjoy!!!

code:
 
//allyscript
//written by Chris Le//
entity* ally_target;

//Dying Function
//You could modify this to do other several things like:
//when ally dies, you could add functions so that your ally
//could scream in pain

function allystate_die()
{
my._animdist = 0; // reset entity's animation time to zero
while (my._animdist < 100)
{
ent_frame("death",my._animdist); // set the frame from the percentage
my._animdist += 5 * time; // calculate next percentage for death in 1.25 secs
wait(1);
}
my.enable_scan = off; // becomes insensible
my.enable_shoot = off;
my.event = null; // does not react anymore
}

// event function that recieves hits
function myfight_event()
{
if (((event_type == event_scan) && (indicator == _explode)))
|| ((event_type == event_shoot) && (indicator == _gunfire))
{
my._signal = 1;
if (my._armor <= 0) { my._health -= damage; }
else { my._armor -= damage; }
}
if ((event_type == event_detect) && (you != player) && (you.flag1 >0) && (you.skill9 > 0) ) {
my._signal = 1; }
ally_target = you;
wait(1);
}


//wait function. Ally stands
function allystate_wait()
{


while (1) {
if (my._health <= 0) { allystate_die(); return; }
if (my._health < 30) { allystate_escape(); return;}

// scan for the enemy
temp.pan = 180;
temp.tilt = 180;
temp.z = 1000;
indicator = _watch;
scan_entity(my.x,temp);
if (my._signal == 1) { allystate_attack(); return; }
waitt(8);
}
}


//attack state, my favorite!!!
// here is where you could modify what type on bullets it will shoot
// and how much damage it causes

function allystate_attack()
{
if (ally_target==null || ally_target.skill9<0)
{
allystate_wait();
ally_Target=null;
}
my._animdist = 0;
while (1) {

if (my._health <= 0) { allystate_die(); return; }
if (my._health < 30) { allystate_escape(); return; }

//turns towards enemy
temp.x = ally_target.x - my.x;
temp.y = ally_target.y - my.y;
temp.z = ally_target.z - my.z;
vec_to_angle(my_angle,temp);
force = 4;
actor_turn();
ent_cycle("attack", my._animdist);
my._animdist += 5 * time;
if (my._animdist > 100) {
my._animdist -= 100;
shot_speed.x = 100;
shot_speed.y = 0;
shot_speed.z = 0;
my_angle.pan = my.pan;
vec_rotate(shot_speed, my_angle);
damage = 3;
fire_mode = 302.2;
create(fireball, my.x, bullet_shot);
wait(1);
create(fireball, my.x, bullet_shot);
wait(1);
create(fireball, my.x, bullet_shot);
wait(1);
create(fireball, my.x, bullet_shot);
wait(1);
create(fireball, my.x, bullet_shot);
wait(1);
create(fireball, my.x, bullet_shot);
wait(1);
create(fireball, my.x, bullet_shot);
wait(1);
create(fireball, my.x, bullet_shot);
wait(1);
create(fireball, my.x, bullet_shot);
wait(1);
create(fireball, my.x, bullet_shot);
wait(1);
create(fireball, my.x, bullet_shot);
wait(1);
create(fireball, my.x, bullet_shot);
wait(1);
}
wait(1);
}
}

//escape state. makes the ally a chicken and runoff
function allystate_escape()
{
while(1) {
if (my._health <= 0) { allystate_die(); return; }
temp.x = my.x - player.x;
temp.y = my.y - player.y;
temp.z = my.z - player.z;
vec_to_angle(my_angle,temp);
force = 4;
actor_turn();
//walks away like a chicken
actor_move();
wait(1);
}
}

action b_ally_ai_v1
{
my._walkframes = 1;
my._entforce = 0.7;
my._armor = 100;
my._health = 100;
my._signal = 0;

my.enable_scan = on;
my.enable_shoot = on;
my.enable_detect = on;
my.event = myfight_event;

allystate_wait();

}




.,.,.,., SiGh,