Page 1 of 1

AI code. A basic code for a shooting game...

PostPosted: Thu Feb 15, 2007 12:52 am
by Sgt. Sparky
Code: Select all
//Have the monster not receive events when out of vision.

//Monster -> Draw Actor

 y  += 5;
 if(xscreen > player.xscreen + 50)go = 0;
 if(xscreen < player.xscreen - 50)go = 1;
 if(go == 1)
{
  x += 5;
  if(AnimFinish == 1)ChangeAnimatio("EventActor", "GoRight",FORWARD);
}
if(go == 0)
{
   x -= 5;
   if(AnimFinish == 1)ChangeAnimation("EventActor", "GoLeft",FORWARD);
}
if(distance(xscreen, yscreen, Player.xscreen, Player.yscreen) < 50)
{
    if(AnimFinish == 1 && xscreen > Player.xscreen)
    {
        ChangeAnimation("Event Actor", "HitLeft", FORWARD);
        AnimFinish = 1;
        Whack = 1;
    }
    if(AnimFinish == 1 && xscreen < Player.xscreen)
    {
        ChangeAnimation("Event Actor", "HitRight", FORWARD);
        AnimFinish = 0;
        Whack = 1;
}
if(distance(xscreen, yscreen, Player.xscreen, Player.yscreen) > 250)//orwhateveryouwant
{
     CreateActor("Bullet", "BulletAnimation", "(none)", "(none)", 0, 0, false);
}

//Monster -> animation finish

AnimFinish = 1;
CreateTimer("Event Actor", "12", 12);

//Monster -> Key upLeftOrRight)

AnimFinish = 1;

//Have the monster have a physical response when it collides with the ground.

//Monster -> collision on any side of player

if(Whack == 1)
{
    SendActivationEvent("Player");
}

//Player -> Activation event from any actor

//(this is where you do all your damage calculations)

//Bullet -> create actor

angle = direction(xscreen, yscreen, Player.xscreen, Player.yscreen);
directional_velocity = 15;
PlaySound2("data/GunShot", 1.000000, 1, 0.000000);

//Monster -> Timer(12)

whack = 0;

//Player -> collision on any side of bullet

(more damage calculation)


This Should cover most of the script.

if you want more AI stuff for difent events just let me know.
if any of you want I can post somwe AI from CommandoMan.
http://game-editor.com/forum/tp-3034--D ... 1-354.html
or from Knight Archer
http://game-editor.com/forum/viewtopic. ... 6175#16175
:D
I hope it helps!

Woah. Nice.

PostPosted: Tue Apr 03, 2007 12:00 am
by Hblade
Woah. Nice. I like this code allot.

PostPosted: Tue Apr 03, 2007 2:05 am
by UltimatHedgehog
Hblade!! You've returned from beyond the grave! :D YAY!!

p.s. if youre confused read what i said on lets all team up

PostPosted: Tue Apr 03, 2007 2:57 am
by Sgt. Sparky
erm... what are we teaming up on?... :|
I know we are teaming up... just on what :?: :|

Some time.

PostPosted: Wed Apr 04, 2007 8:46 pm
by Hblade
Some time. After I finish My Game, Hblade, Ten, We might team up, But intill ten, what with everything going on, I will just work on my game Hblade.