3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1]

Author Topic: zombie animation changer. Scripters to the rescue !!  (Read 633 times)

« on: March 08, 2012, 06:15:54 PM »
I'm trying to make this script work for my zombie game, I need to make it so when the dieing animation stops after a time has elapsed, lets say after 2 seconds.
I'v try'ed many ways to try an get it to work. do any one here know?? ??? here's the script.
oh and idk why the Idle one dosnt work either.  :-\
Code: [Select]
Vector3 PlayerLoc, ZombieLoc;
float Distance, Health;
int cAnimation, nAnimation;

///                                                         
int Walking = 2; //Animation set for walking.
int Attacking = 4; //Animation set for attacking.
int Dying = 5; //Aniamtion set for dying
int Idle = 1;
float Range = 2.5; //The attack range in meters.
///                                                         

void Main()
{
   iObjectLocation(OBJ_88,ZombieLoc);
   iObjectLocation(OBJ_110,PlayerLoc);
   Distance = iVectorLength(ZombieLoc-PlayerLoc);

   Health = IN_154;
   if (Distance <=  20.0 && Health > 0) nAnimation = Idle; ///If the distance between u and zombie is 20 meters than Idle animation plays
   if (Distance >  Range && Health > 0) nAnimation = Walking;
   if (Distance <= Range && Health > 0) nAnimation = Attacking;
   if (Health <= 0)                     nAnimation = Dying;

   if (cAnimation != nAnimation) {cAnimation = nAnimation; OUT_24 = nAnimation;} //If the current animation is not the same as the new animation, the current animation is set to the new one.

}

Can any one fix it???????????? ??? ??? ??? ???
« Last Edit: March 08, 2012, 08:00:25 PM by Har88 »
Yeah.. I'm back, momentarily... been busy with the minecraft business over at http://www.harsworld.com/
« Reply #1 on: March 08, 2012, 09:22:53 PM »
Code: [Select]
Vector3 PlayerLoc, ZombieLoc;
float Distance, Health, timevar = 0;
int cAnimation, nAnimation;
bool dead = false;

///                                                         
int Walking = 2; //Animation set for walking.
int Attacking = 4; //Animation set for attacking.
int Dying = 5; //Aniamtion set for dying
int Idle = 1;
float Range = 2.5; //The attack range in meters.
///                                                         

void Main()
{
   iObjectLocation(OBJ_88,ZombieLoc);
   iObjectLocation(OBJ_110,PlayerLoc);
   Distance = iVectorLength(ZombieLoc-PlayerLoc);

   Health = IN_154;
   if (Distance >=  20.0 && Health > 0) {nAnimation = Idle;} ///If the distance between u and zombie is 20 meters than Idle animation plays
   if (Distance >  Range && Health > 0) {nAnimation = Walking;}
   if (Distance <= Range && Health > 0) {nAnimation = Attacking;}
   if (Health <= 0 && dead==false)                     
      {
         nAnimation = Dying;
         timevar = (timevar + (1/60));
         if (timevar>=2)
         {
            dead = true;
            timevar = 0;
            //stop the animation
         }
      }

   if (cAnimation != nAnimation) {cAnimation = nAnimation; OUT_24 = nAnimation;} //If the current animation is not the same as the new animation, the current animation is set to the new one.

}
I modified it a bit to what I think will work.
also for the first distance for animation idle, shouldn't that be >= 20?

Currently using 7.22
« Reply #2 on: March 08, 2012, 10:26:10 PM »
That was a good try dart. didnt work, i try'ed to fix it but didnt work neither  :'(
« Last Edit: March 08, 2012, 10:27:44 PM by Har88 »
Yeah.. I'm back, momentarily... been busy with the minecraft business over at http://www.harsworld.com/
« Reply #3 on: March 09, 2012, 03:11:32 AM »
You need to make something like this.

float Timer = -1;
void Main()
{
   if (State == Dead && Timer == -1) Timer = 0;
   If (Timer > -1) Timer += 0.01666667;
   if (Timer >= 2.0) OUT_AnimationSpeed = 0;
   if (State != Dead)
  {
      OUT_AnimationSpeed = 1;
      Timer = -1;
   }
}

In my script I always work with timers. They're great!  ;D
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #4 on: March 09, 2012, 04:03:43 AM »
THX RobertooMolvadoo i mended it into my script  :-*  :-* :-* :-* :-* :-* :-*
now only one problem left the Idle animation wont start once your 20meters away from zombie  :-\v ??? ??? ???

Here's the orginal script but with fixed death animation anyway
Code: [Select]
Vector3 PlayerLoc, ZombieLoc;
float Distance, Health, timevar = 0;
int cAnimation, nAnimation;

///                                                         
int Walking = 2; //Animation set for walking.
int Attacking = 4; //Animation set for attacking.
int Dying = 5; //Aniamtion set for dying
int Idle = 1;
float Range = 2.5; //The attack range in meters.
float Dead = -1;
float State = -1;
float Timer = -1;
///                                                         

void Main()
{
   iObjectLocation(OBJ_88,ZombieLoc);
   iObjectLocation(OBJ_110,PlayerLoc);
   Distance = iVectorLength(ZombieLoc-PlayerLoc);

   Health = IN_154;
   if (Distance >=  20.0 && Health > 0) {nAnimation = Idle;} ///If the distance between u and zombie is 20 meters than Idle animation plays
   if (Distance >  Range && Health > 0) {nAnimation = Walking;}
   if (Distance <= Range && Health > 0) {nAnimation = Attacking;}
   if (Health <= 0)                     
      {
         nAnimation = Dying;
         if (State == Dead && Timer == -1) Timer = 0;
         if (Timer > -1); Timer += 0.01666667;
         if (Timer >= 1.79) OUT_23 = 0;
         if (State != Dead)
         {
         OUT_23 = 1;
         Timer = -1;
      }
     }
   if (cAnimation != nAnimation) {cAnimation = nAnimation; OUT_24 = nAnimation;} //If the current animation is not the same as the new animation, the current animation is set to the new one.

}
« Last Edit: March 09, 2012, 04:39:02 PM by Har88 »
Yeah.. I'm back, momentarily... been busy with the minecraft business over at http://www.harsworld.com/
« Reply #5 on: March 09, 2012, 10:29:59 AM »
That's an easy one.

Just for you to know, you get an answer because of my kindness. Not because of big fonts.

Let's take a look at this:
   if (Distance >=  20.0 && Health > 0) {nAnimation = Idle;} ///If the distance between u and zombie is 20 meters than Idle animation plays
   if (Distance >  Range && Health > 0) {nAnimation = Walking;}
   if (Distance <= Range && Health > 0) {nAnimation = Attacking;}

Let's replace it with numbers:
   if (Distance >=  20.0 && Health > 0) {nAnimation = Idle;} ///If the distance between u and zombie is 20 meters than Idle animation plays
   if (Distance > 2.5 && Health > 0) {nAnimation = Walking;}
   if (Distance <= 2.5 && Health > 0) {nAnimation = Attacking;}

You see? Two if-statements are 'overlapping'.
It should be:
   if (Distance >=  20.0 && Health > 0) {nAnimation = Idle;} ///If the distance between u and zombie is 20 meters than Idle animation plays
   if (Distance >  Range && Distance < 20 && Health > 0) {nAnimation = Walking;}
   if (Distance <= Range && Health > 0) {nAnimation = Attacking;}
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #6 on: March 09, 2012, 08:35:21 PM »
Thanks so much RobertooMolvadoo u have helped me alot. I really appreciate it man  :)
Yeah.. I'm back, momentarily... been busy with the minecraft business over at http://www.harsworld.com/
Pages: [1]