HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.
Pages: [1] 2

Author Topic: Base Animation Script Files  (Read 7141 times)

keeperofstars

  • General Accounts
  • *
  • Posts: 998
    • View Profile
    • StarKeeper Online
Base Animation Script Files
« on: Aug 22, 13, 10:13:56 PM »

So as I was working through testing various characters. I noticed all the basic movements the character controller tries to preform on a character, and I tried to make a default character Animation Script file that I could apply to all characters.

I also created a default  animationset.dat file as well. I also created a full set of .asq files that have it all linked. I will post the .AAS file here and the .dat here and then try zipping up and attaching the full set.

Here is the .AAS file

Code: [Select]
! biped control
!
!this is a super basic template to start with
!add more stuff and make it do something neat!!


channels
{
  AnimAllBody
}

inputs
{
// Basic Inputs
  BaseMode = Normal, Combat
  variable BasePosture = Idle, Turning, Moving, Dead, Prone, Alive, Stunned, Paralyzed
  variable OverridePosture = None, Falling, Landing, Jumping, Knockback, Dead, Knockdown
  variable IdleType = Normal, Dead, Paralyzed, Stunned, Ranger, Knockdown
 
// General Movement Input
variable CurrentMotion = CombatMove, Idle, TurningLeft, TurningRight, Forward, Backingup
  variable MoveType = Normal, Swim
  MoveDirection = Forward, Backward, SideStepLeft, SideStepRight
  TurnDirection = None, Right, Left
  TurnAmount = None, T45Degrees, T90Degrees, T135Degrees, T180Degrees
  variable AlreadyTurning = True, False
 
// Combat Inputs
  variable Attacking = None, Ranger2x4, RangerBlossom, RangerKneelFire, RangerMelee, RangerQuadstorm, RangerSlasher, RangerTorque, RangerUppercut, SpellMelee, SpellUppercut,  SpellSlasher, SpellBladeSpinner, SpellBlast, SpellBlastStaff, SpellTorque, SpellRaiser, SpellStaff360Slam, SwordMelee, Sword5thDegree, SwordCombo, SwordFlipSlash, SwordJuggleSlash, SwordStinger, SwordUppercut
  variable ImpactHit = None, Blam, Dodge, Block, Parry
  WeaponHand = Closed, Opened
  variable WeaponType = None, Sword, Bow
 
// Special Inputs to play a specific animation
  variable Special = None, HeartpullA, HeartpullB
 
// Used in various actions to control logic flow and assist in code reuse
variable AnimationSettingsGroup = None, Primary, Secondary, Tertiary
}

transition BasePosture
{
  from Idle to Dead = trDie
  from Turning to Dead = trDie
  from Moving to Dead = trDie
 
  from Dead to Idle = trBackToDead
  from Dead to Turning = trBackToDead
  from Dead to Moving = trBackToDead
  from Dead to Paralyzed = trBackToDead
  from Dead to Stunned = trBackToDead
  from Dead to Alive = trLiveAgain
 
  from Idle to Paralyzed = trParalyze
  from Turning to Paralyzed = trParalyze
  from Moving to Paralyzed = trParalyze
  from Stunned to Paralyzed = trParalyze
 
  from Idle to Stunned = trStun
  from Turning to Stunned = trStun
  from Moving to Stunned = trStun
 
  from Paralyzed to Idle = trIdle
  from Stunned to Idle = trIdle
  from Moving to Idle = trIdle
  from Turning to Idle = trIdle
}

transition OverridePosture {
  from None to Jumping = trDoJump
  from Jumping to Falling = trDoFall
 
  from None to Knockdown = trKnockdown
  from Knockdown to None = trStand
 
  from Dead to Knockdown = trBackToDead
  from Knockdown to Dead = trDie
}

transition MoveType {
  from Normal to Swim = EnterSwim
  from Swim to Normal = LeaveSwim
}

action EnterSwim
{
  force(1) AnimAllBody{
    when BasePosture {
  is Idle:
    anim "swimidle"
      align false
    blend 0.1
    hold 0 seconds
    looping true
    change AlreadyTurning to False
    change CurrentMotion to Idle
  is Moving:
    when MoveDirection {
    is Forward:
        anim "swimforward"
        blend 0.1
        hold 0 seconds
        change CurrentMotion to Forward
      is Backward:
        anim "swimbackwards"
        blend 0.1
        hold 0 seconds 
        change CurrentMotion to Backingup 
      }
    }
  } 
}

action LeaveSwim
{
  force(1) AnimAllBody{
    when BasePosture {
  is Idle:
    anim "idle"
      align false
    blend 0.3
    hold 0 seconds
    looping true
    change AlreadyTurning to False
    change CurrentMotion to Idle
  is Moving:
    when MoveDirection {
    is Forward:
        anim "walkrun"
        blend 0.3
        hold 0 seconds
        change CurrentMotion to Forward
      is Backward:
        anim "backingup"
        blend 0.3
        hold 0 seconds 
        change CurrentMotion to Backingup 
      }
  }
  } 
}


action trDie
{
  force(1) AnimAllBody
  {
    if(OverridePosture != Dead) {
      anim "death"
      hold 1
      blend 0.1
      align false
      looping false
      change AlreadyTurning to False
      change CurrentMotion to Idle
      change Attacking to None
      change IdleType to Dead
      change OverridePosture to Dead
    }
  } 
}
action trLiveAgain
{
  change OverridePosture to None
  change BasePosture to Idle
  change IdleType to Normal
}

action trBackToDead
{
  change IdleType to Dead
  change OverridePosture to Dead
  change BasePosture to Dead
}

action trIdle
{
  force(1) AnimAllBody
  {
    change IdleType to Normal
    call fnIdle
  } 
}

action trStun
{
  force(1) AnimAllBody
  {
    anim "stunned"
    hold 1
    blend 0.25
    align false
    looping true
    change AlreadyTurning to False
    change CurrentMotion to Idle
    change Attacking to None
  } 
}

action trParalyze
{
  force(1) AnimAllBody
  {
    anim "paralyzed"
    hold 1
    blend 0.25
    align false
    looping true
    change AlreadyTurning to False
    change CurrentMotion to Idle
    change Attacking to None
    change IdleType to Paralyzed
  } 
}


action trDoJump
{
  force(1) AnimAllBody
  {
   if(BasePosture != Dead) {
     anim "jump"
     blend .025
     hold 1
     looping false
     FreezeLastSequence true
     change OverridePosture to Falling
   }
  }
}
action trDoFall
{
force(1) AnimAllBody
  {
if(BasePosture != Dead) {
anim "falling"
      blend .1
      hold .1
      looping true
      FreezeLastSequence true
}
}
}
action trStand
{
  force(2) AnimAllBody
  {
    when IdleType {
    is Knockdown:
    anim "standup"  // Just a placeholder till we get standup
    DEFAULT:
    // do nothing
    }
   
    hold 0.9
    blend 0.25
    align false
    looping false
    change IdleType to Normal
    change AlreadyTurning to False
    change CurrentMotion to Idle
    change Attacking to None
  }
}
action trKnockdown
{
force(1) AnimAllBody
{
anim "knockdown"
hold 1
blend 0.25
align false
looping false
change AlreadyTurning to False
change CurrentMotion to Idle
change Attacking to None
change IdleType to Knockdown
}
}



action Default
{
  call fnAnimAllBodyChannel
 

}

action fnAnimAllBodyChannel {
  // Setting the channel and its priority is handled by the individual funciton calls


call fnOverridePosture

  when BaseMode {
  is Normal:
    call fnBaseBehaviors               // Basic Postures, Idle, Moving, Turning etc
  is Combat:
    call fnEvalCombatInputs               // Basic Behaviors, idle, move, turn
     
    if (Attacking != None) {
      call fnAttackBehaviors
    }
    call fnBaseBehaviors
  DEFAULT:
    call fnBaseBehaviors
  }
}



action fnEvalCombatInputs {
  if((BasePosture = Prone) OR (BasePosture = Dead) OR (BasePosture = Moving) OR (BasePosture = Turning)) {
    //change Attacking to None
   //change Special to None
  }

  if(Attacking != None) {
    change CurrentMotion to CombatMove
    change IdleType to Normal             // This cancels special idles like aiming
    change ImpactHit to None              // Cancel our impact if we are attacking
  }
}

action fnAttackBehaviors {
  force(1) AnimAllBody
  {   
    call fnEvalAttackInputs
 
  change AnimationSettingsGroup to Primary
 
    when Attacking {
    is None:
      // pass through
    DEFAULT:
      anim str("", Attacking )
      change MoveType to Normal
      change ImpactHit to None
    }
   
    when AnimationSettingsGroup {
    is None:
    return
    is Primary:
    blend 0.1
      hold 1
      looping false
      change Attacking to None
      stop
    }
  }
}
action fnEvalAttackInputs {
 
  return // nothing to do yet
 
  when Attacking {
  DEFAULT:
  }
}
 
 


action fnBaseBehaviors {
  when BaseMode {
  DEFAULT:
    when BasePosture {
    is Turning:
      return
    is Moving:
      call fnMovement
    is Dead:
      call fnDead
    DEFAULT:
      call fnIdle
    }
  }
}



action fnEvaluateIdleInputs {
  change AlreadyTurning to False
  change CurrentMotion to Idle
}

action fnDead {
  set(1) AnimAllBody
  {
    when IdleType {
    is Dead:
      anim "death"
    DEFAULT:
     when BaseMode {
     is Combat:
        anim "death"
     DEFAULT:
        anim "death"
       
     }
    }
  }
}

action fnIdle {
  set(1) AnimAllBody
  {
    call fnEvaluateIdleInputs
 
    change AnimationSettingsGroup to Primary      // Groups of Align/Blend/Hold/Looping settings that are used in common
   
                                                      //   by many animations
    when IdleType {             
    is Dead:
      anim "death"
      align false
      blend 0
      hold 0
      looping true
      stop
    is Paralyzed:
    anim "paralzyed"
    is Knockdown:
    anim "knockdown"
    DEFAULT:     
      when BaseMode {
      is Combat:
      when WeaponType {
      is Bow:
      return
      DEFAULT:
      anim "idle"
      }
change AnimationSettingsGroup to Secondary
DEFAULT:
when WeaponType {
is Bow:
return
DEFAULT:
      anim "idle"
      }
  }
  align true
      blend 0
      hold 0
      looping true
    }
   
    when AnimationSettingsGroup {
    is None:
      return
    is Primary:
      align false
      blend 0.5
      hold 0.5 seconds recycle
      looping true
      stop
    is Secondary:
  align false
blend 0.25
hold 0.25 seconds recycle
looping true
change AlreadyTurning to False
change CurrentMotion to Idle
stop
    is Tertiary:
      looping true
      hold 1
      align true
      blend 0
      stop
    }
  }
}

// Movement behavior, translates inputs into the appropriate move animation
action fnMovement {
  set(1) AnimAllBody
  {   
    when MoveDirection {
    is Forward:
      when MoveType {
      is Normal:
        anim "walkrun"
      is Swim:
        anim "swimforward"
      DEFAULT:
        when BaseMode {
        DEFAULT:
          anim "walkrun"
        }
      }
      blend 0
      hold 0 seconds
      change CurrentMotion to Forward
    is Backward:
      when MoveType {
        is Normal:
          anim "backingup"
        is Swim:
          anim "swimbackwards"
      DEFAULT:
        when BaseMode {
        DEFAULT:
          anim "backingup"
        }
      }
      blend 0.25
      hold 0.25 seconds
      change CurrentMotion to Backingup
    }
    align false
    looping true
    change AlreadyTurning to False
  }
}

action fnOverridePosture {
  set(1) AnimAllBody
  { 
    if(BasePosture != Dead) {   
      when OverridePosture {
      is Jumping:
       anim "jump"
       blend .025
       hold 1
       looping false
       FreezeLastSequence true
       stop
      is Falling:
       anim "falling"
       blend .1
       hold .1
       looping true
        FreezeLastSequence true
        stop
      is Landing:
        anim "landing"
        blend .1
        hold .5
        looping false
        FreezeLastSequence false
        change OverridePosture to None
        stop
      is Knockback:
        anim "knockback"
        blend .1
        hold .5
        looping false
        change OverridePosture to None
        stop
      is Knockdown:
    anim "knockdown"
      blend 0.3
      hold 0.1
      looping true
      stop
      }
    }
  }
}
Logged
[img]http://screencast.com/t/x7btcSSyp3h0[\img]

keeperofstars

  • General Accounts
  • *
  • Posts: 998
    • View Profile
    • StarKeeper Online
Re: Base Animation Script Files
« Reply #1 on: Aug 22, 13, 10:14:57 PM »

Here is the animationset.dat file.

Code: [Select]
!
!Basic AnimationSet.dat with a tempalte idle sequence listed
Version=1
[SEQUENCES]
  idle
  walk
  run
  backingup
  death
  walkrun
  jump
  falling
  landing
  knockdown
  standup
  knockback
  stunned
  paralyzed
  swimidle
  swimforward
  swimbackwards
 
Logged
[img]http://screencast.com/t/x7btcSSyp3h0[\img]

keeperofstars

  • General Accounts
  • *
  • Posts: 998
    • View Profile
    • StarKeeper Online
Re: Base Animation Script Files
« Reply #2 on: Aug 22, 13, 10:25:02 PM »

If you name your animation files the same name as what is found in the animationset.dat file all the .asq files I've attached should work for you out of the box.

Note there might be a timing glitch or a blending glitch etc with your animations and how things flow with the default animation scripts, but it will get you 99% of the way there, for having your character animated with all the default character controller states. From this point on it's just a matter of modifying it to meet your needs.

Bet you didn't think you would need so many animations just for default character movement did you. LOL

Oh and also note: when controlling an NPC swim controls are not passed. Meaning the controller pieces for npc doesn't react to water volumes. Didnt want you to think it was broken, if you tried it.
If you don't have all of the animations just trim out the ones you don't need from the animationset.dat file so the game won't look for them. You will just get errors for the controller not finding an animation but won't be a problem.
Logged
[img]http://screencast.com/t/x7btcSSyp3h0[\img]

Amanda_Brooks

  • General Accounts
  • *
  • Posts: 514
    • View Profile
    • Heroes and Villains
Re: Base Animation Script Files
« Reply #3 on: Aug 23, 13, 12:47:00 AM »

Thanks for these - they'll be useful.
Logged
"Heroes and Villains" - www.heroes-and-villains.com
Facebook: https://www.facebook.com/HeroesAndVillainsMMORPG
Twitter: @Plan_Z_Studios

Gassy_the_Goblin

  • World Owners
  • ****
  • Posts: 20
    • View Profile
    • joshpurple.com
Re: Base Animation Script Files
« Reply #4 on: Sep 22, 13, 11:15:06 PM »

Excellent, Thank You keeperofstars :) .


And please forgive my newbie questions;

I've had success using the Hero Character Tools exporting from Max,
where I left the Track Masks Editor at default (no channels added).
In your .AAS file I see,
Code: [Select]
channels
{
  AnimAllBody
}
Will I need to add any channels with the Track Masks Editor
(walk, run, swim, etc. ), or, I'm guessing, all of these animations will run through the default  AnimAllBody channel?

So these are set-up to run with a default Hero Character Tool export,
along with creating and exporting out the animations for the character,
-without needing to use the Track Masks Editor, or the Animation Tools
(where I'm just using one animation sequence in each Max file to start).

Thanks again, I appreciate it & your scripts looks great  :D !
Logged

WorldWideZ

  • World Owners
  • ****
  • Posts: 524
    • View Profile
    • World Wide Zed
Re: Base Animation Script Files
« Reply #5 on: Sep 23, 13, 01:00:18 AM »

Track masks are for when you want to combine animations , and can be weighted just like bones . the same animations are then applied to the model as when using AnimAllBody

examples might be UpperBody , LowerBody . using these masks i could have a walk animation and a static attack animation combined together to make a walk attack.
Logged

Gassy_the_Goblin

  • World Owners
  • ****
  • Posts: 20
    • View Profile
    • joshpurple.com
Re: Base Animation Script Files
« Reply #6 on: Sep 23, 13, 10:30:37 AM »

Track masks are for when you want to combine animations , and can be weighted just like bones . the same animations are then applied to the model as when using AnimAllBody

examples might be UpperBody , LowerBody . using these masks i could have a walk animation and a static attack animation combined together to make a walk attack.
Thank You WorldWideZ  :) ,  I appreciate it!

Logged

Gassy_the_Goblin

  • World Owners
  • ****
  • Posts: 20
    • View Profile
    • joshpurple.com
Re: Base Animation Script Files
« Reply #7 on: Sep 23, 13, 08:46:13 PM »

Just had to say Thank You again keeperofstars  ;D !

Your scripts are working, and it is a GREAT feeling to see the animations working in the Hero Engine !

Thank You again too WorldWideZ, I DIG your Facebook page !
Logged

keeperofstars

  • General Accounts
  • *
  • Posts: 998
    • View Profile
    • StarKeeper Online
Re: Base Animation Script Files
« Reply #8 on: Sep 29, 13, 07:22:11 PM »

not a problem I wanted to provide a simpler animation script that didn't have a billion emotes, and custom attacks in it. and since the wiki doesn't give a base one, I took the one from the sunok and trimmed him down to just the core 13 or so animations.

Then provided examples for all the components. I personally think it makes it much easier to learn from. I kept all the transition script stuff which isn't "needed" but provides some good building blocks with reuse options. So wanted to keep that level of confusion in. lol

Glad it's helping people get their characters going.

Logged
[img]http://screencast.com/t/x7btcSSyp3h0[\img]

Thazager

  • General Accounts
  • *
  • Posts: 1160
  • Never stop learning
    • View Profile
Re: Base Animation Script Files
« Reply #9 on: Sep 29, 13, 07:31:12 PM »

Its good to see when you trim the extra off, so that people can understand the basics of a system. Many systems have a lot added, and for that reason, they become too hard for many to understand.
Logged
Lead scripter for EO, Repop helper.
HSL Video tutorials:
https://community.heroengine.com/forums/index.php/topic,1719.msg36858.html#msg3685

TheRabid

  • General Accounts
  • *
  • Posts: 41
    • View Profile
Re: Base Animation Script Files
« Reply #10 on: Sep 29, 13, 09:31:40 PM »

This is a wonderful resource, should most definitely be wiki'd!


I have gone through this process once before, and now I am going through it again because I am switching my characters to CAT from biped and this has been a great shortcut from last time!



Logged

TheRabid

  • General Accounts
  • *
  • Posts: 41
    • View Profile
Re: Base Animation Script Files
« Reply #11 on: Oct 02, 13, 07:07:32 PM »

Hey just a little note to any one using these as your begining character animation template.


One thing to note, is if you want jump to behave similar to what the HeroEngine default does as in Jump>Fall>Land instead of Fall>Fall>Land you will need to slightly modify the .AAS


transition OverridePosture
  from None to Jumping = trDoJump 
  from Jumping to Falling = trDoFall  (<<<<< delete this part <<<<<)

If some one has  a more elegant solution please let me know, but through my testing this seems to be the "correct" default character behavior.
« Last Edit: Oct 02, 13, 07:14:50 PM by TheRabid »
Logged

Gassy_the_Goblin

  • World Owners
  • ****
  • Posts: 20
    • View Profile
    • joshpurple.com
Re: Base Animation Script Files
« Reply #12 on: Oct 06, 13, 10:09:42 PM »

Hey just a little note to any one using these as your begining character animation template.


One thing to note, is if you want jump to behave similar to what the HeroEngine default does as in Jump>Fall>Land instead of Fall>Fall>Land you will need to slightly modify the .AAS


transition OverridePosture
  from None to Jumping = trDoJump 
  from Jumping to Falling = trDoFall  (<<<<< delete this part <<<<<)

If some one has  a more elegant solution please let me know, but through my testing this seems to be the "correct" default character behavior.
That is a great tip, Thank You  :) !

 
As a beginner with Hero Script, I completely agree with the others; wonderful resource, should be wiki'd, it's good to see when you trim the extra off -it certainly helps.  Brilliant idea Keeper of Stars  ;D  !

----------------------------------------------
And another newbie question :)

When I possess an NPC, and select (for example) a Monkeytok & attack it, -instead of my possessed NPC attacking the Monkeytok, the (for example) Ranger Character attacks the Monkeytok.

I'm guessing this is due to the Ranger Character being a $CharacterClass (with the GUI connected to the $CharacterClass), -if I want the possessed NPC to attack the Monkeytok, I would need to make the NPC a $CharacterClass?

Or, is it possible to have the possessed NPC attack the Monkeytok?  ( <-- and/or maybe that would be working in the 'wrong direction,' -since it would probably not be a useful in-game function?)


Thanks again  :) !
Logged

keeperofstars

  • General Accounts
  • *
  • Posts: 998
    • View Profile
    • StarKeeper Online
Re: Base Animation Script Files
« Reply #13 on: Oct 13, 13, 04:03:16 AM »

yeah would need to change a few things up in the base character controller / gui stuff. To read or pay attention that you are in "NPC Mode"
While you can take control of a NPC and it passes the inputs to that NPC, all the other scripts don't pay attention to the fact you have done this. aka the combat scripts are still looking at your client node aka player.
So it's one of those the pieces are there and when you go to build out your own combat systems you can start building out checks for which mode you are in to say.
Logged
[img]http://screencast.com/t/x7btcSSyp3h0[\img]

Gassy_the_Goblin

  • World Owners
  • ****
  • Posts: 20
    • View Profile
    • joshpurple.com
Re: Base Animation Script Files
« Reply #14 on: Oct 13, 13, 10:43:46 AM »

Thanks again Keeper of Stars  :) !   I appreciate it   !

----------------------------------------------------

As I use these scripts, and add the animations to go with them, I notice when my character (NPC) is doing it's idle animation, this Console message will frequently run,

"SCRIPT:[E_ACCControllerClassMethods]:E_ACCControllerClassMethods line 993 (_onPostAnimUpdate) has determined I should be falling"

I will create a new Idle animation, and see if that corrects it (easy to do :) ).  I'll make sure to lock the granny bone so it's not moving during any of the Idle animations, and uncheck all Inherit checkboxes in the Link Info.

Is my understanding correct that, this might be due to the granny bone being detected as going up, off of  ' 0 ',  which is possibly why the script 'E_ACCControllerClassMethods' then runs the 'falling' (and sometimes 'landing') animations  (the script is doing what it should be) ?
Logged
Pages: [1] 2