From: Alexander Monakov Date: Fri, 31 Dec 2010 00:29:23 +0000 (+0300) Subject: Simplify idle animations X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=fedce5619a42a2ac4f55c6dab16470970ce36cbb;p=lugaru.git Simplify idle animations --- diff --git a/Source/Animation.def b/Source/Animation.def index 9726a80..54dc3ad 100644 --- a/Source/Animation.def +++ b/Source/Animation.def @@ -34,7 +34,7 @@ DECLARE_ANIM_BIT(ab_walljump) #ifdef DECLARE_ANIM DECLARE_ANIM(runanim, "Run", middleheight, neutral, 0) -DECLARE_ANIM(bounceidleanim, "Idle", middleheight, neutral, 0) +DECLARE_ANIM(bounceidleanim, "Idle", middleheight, neutral, ab_idle) DECLARE_ANIM(stopanim, "Stop", middleheight, neutral, 0) DECLARE_ANIM(jumpupanim, "JumpUp", highheight, neutral, 0) DECLARE_ANIM(jumpdownanim, "JumpDown", highheight, neutral, 0) @@ -63,11 +63,11 @@ DECLARE_ANIM(upunchanim, "Upunch", middleheight, normalattack, 0) DECLARE_ANIM(staggerbackhighanim, "Staggerbackhigh", middleheight, neutral, 0) DECLARE_ANIM(upunchreversedanim, "UpunchCaught", middleheight, reversed, 0) DECLARE_ANIM(upunchreversalanim, "UpunchCatch", middleheight, reversal, 0) -DECLARE_ANIM(hurtidleanim, "Hurtidle", middleheight, neutral, 0) +DECLARE_ANIM(hurtidleanim, "Hurtidle", middleheight, neutral, ab_idle) DECLARE_ANIM(backhandspringanim, "Backhandspring", middleheight, neutral, 0) -DECLARE_ANIM(fightidleanim, "Fightidle", middleheight, neutral, 0) +DECLARE_ANIM(fightidleanim, "Fightidle", middleheight, neutral, ab_idle) DECLARE_ANIM(walkanim, "Walk", middleheight, neutral, 0) -DECLARE_ANIM(fightsidestep, "Fightsidestep", middleheight, neutral, 0) +DECLARE_ANIM(fightsidestep, "Fightsidestep", middleheight, neutral, ab_idle) DECLARE_ANIM(killanim, "Kill", middleheight, normalattack, 0) DECLARE_ANIM(sneakattackanim, "Sneakattack", middleheight, reversal, 0) DECLARE_ANIM(sneakattackedanim, "Sneakattacked", middleheight, reversed, 0) @@ -97,10 +97,10 @@ DECLARE_ANIM(leftflipanim, "Leftflip", highheight, neutral, 0) DECLARE_ANIM(walljumpleftanim, "Walljumpleft", highheight, neutral, 0) DECLARE_ANIM(walljumprightkickanim, "Walljumprightkick", highheight, neutral, 0) DECLARE_ANIM(walljumpleftkickanim, "Walljumpleftkick", highheight, neutral, 0) -DECLARE_ANIM(knifefightidleanim, "Knifefightidle", middleheight, neutral, 0) +DECLARE_ANIM(knifefightidleanim, "Knifefightidle", middleheight, neutral, ab_idle) DECLARE_ANIM(knifesneakattackanim, "Knifesneakattack", middleheight, reversal, 0) DECLARE_ANIM(knifesneakattackedanim, "Knifesneakattacked", middleheight, reversed, 0) -DECLARE_ANIM(swordfightidleanim, "swordfightidle", middleheight, neutral, 0) +DECLARE_ANIM(swordfightidleanim, "swordfightidle", middleheight, neutral, ab_idle) DECLARE_ANIM(drawleftanim, "drawleft", middleheight, neutral, 0) DECLARE_ANIM(swordslashanim, "swordslash", middleheight, normalattack, 0) DECLARE_ANIM(swordgroundstabanim, "swordgroundstab", lowheight, normalattack, 0) @@ -111,10 +111,10 @@ DECLARE_ANIM(swordslashreversedanim, "swordslashCaught", middleheight, reversed, DECLARE_ANIM(swordslashreversalanim, "swordslashCatch", middleheight, reversal, 0) DECLARE_ANIM(knifeslashreversedanim, "knifeslashCaught", middleheight, reversed, 0) DECLARE_ANIM(knifeslashreversalanim, "knifeslashCatch", middleheight, reversal, 0) -DECLARE_ANIM(swordfightidlebothanim, "swordfightidleboth", middleheight, neutral, 0) +DECLARE_ANIM(swordfightidlebothanim, "swordfightidleboth", middleheight, neutral, ab_idle) DECLARE_ANIM(swordslashparryanim, "sworduprightparry", middleheight, normalattack, 0) DECLARE_ANIM(swordslashparriedanim, "swordslashparried", middleheight, normalattack, 0) -DECLARE_ANIM(wolfidle, "Wolfidle", middleheight, neutral, 0) +DECLARE_ANIM(wolfidle, "Wolfidle", middleheight, neutral, ab_idle) DECLARE_ANIM(wolfcrouchanim, "Wolfcrouch", lowheight, neutral, 0) DECLARE_ANIM(wolflandanim, "Wolflanding", lowheight, neutral, 0) DECLARE_ANIM(wolflandhardanim, "Wolflandhard", lowheight, neutral, 0) @@ -134,9 +134,9 @@ DECLARE_ANIM(staffhitreversedanim, "StaffHitCaught", middleheight, reversed, 0) DECLARE_ANIM(staffhitreversalanim, "StaffHitCatch", middleheight, reversal, 0) DECLARE_ANIM(staffspinhitreversedanim, "SpinWhackCaught", middleheight, reversed, 0) DECLARE_ANIM(staffspinhitreversalanim, "SpinWhackCatch", middleheight, reversal, 0) -DECLARE_ANIM(sitanim, "Sit", lowheight, neutral, 0) -DECLARE_ANIM(sleepanim, "Sleep", lowheight, neutral, 0) -DECLARE_ANIM(talkidleanim, "TalkIdle", middleheight, neutral, 0) +DECLARE_ANIM(sitanim, "Sit", lowheight, neutral, ab_idle) +DECLARE_ANIM(sleepanim, "Sleep", lowheight, neutral, ab_idle) +DECLARE_ANIM(talkidleanim, "TalkIdle", middleheight, neutral, ab_idle) DECLARE_ANIM(sitwallanim, "Dying", lowheight, neutral, 0) DECLARE_ANIM(dead1anim, "Dead1", lowheight, neutral, 0) DECLARE_ANIM(dead2anim, "Dead2", lowheight, neutral, 0) diff --git a/Source/Animation.h b/Source/Animation.h index 0720426..668cac3 100644 --- a/Source/Animation.h +++ b/Source/Animation.h @@ -38,6 +38,25 @@ enum animation_types { animation_count }; +enum animation_bit_offsets { +#define DECLARE_ANIM_BIT(bit) o_##bit, +#include "Animation.def" +#undef DECLARE_ANIM_BIT +animation_bit_count +}; + +enum animation_bits_def { +#define DECLARE_ANIM_BIT(bit) bit = 1 << o_##bit, +#include "Animation.def" +#undef DECLARE_ANIM_BIT +}; + +static const int animation_bits[animation_count] = { +#define DECLARE_ANIM(id, name, height, type, bits) bits, +#include "Animation.def" +#undef DECLARE_ANIM +}; + extern Animation animation[animation_count]; extern void loadAllAnimations(); diff --git a/Source/Person.cpp b/Source/Person.cpp index 818e6ce..6eb59f0 100644 --- a/Source/Person.cpp +++ b/Source/Person.cpp @@ -174,11 +174,6 @@ void Person::CatchFire(){ onfire=1; } -bool Person::isIdle(){ - if(targetanimation==sleepanim||targetanimation==sitanim||targetanimation==talkidleanim||targetanimation==hurtidleanim||targetanimation==bounceidleanim||targetanimation==talkidleanim||targetanimation==fightidleanim||targetanimation==knifefightidleanim||targetanimation==swordfightidleanim||targetanimation==swordfightidlebothanim||targetanimation==fightsidestep||targetanimation==wolfidle)return 1; - else return 0; -} - bool Person::isSitting(){ if(targetanimation==sitanim)return 1; if(targetanimation==sitwallanim)return 1; @@ -194,10 +189,6 @@ bool Person::isSleeping(){ else return 0; } -bool Person::wasIdle(){ - if(currentanimation==sleepanim||currentanimation==talkidleanim||currentanimation==sitanim||currentanimation==hurtidleanim||currentanimation==bounceidleanim||currentanimation==fightidleanim||currentanimation==swordfightidleanim||currentanimation==swordfightidlebothanim||currentanimation==knifefightidleanim||currentanimation==fightsidestep||currentanimation==wolfidle)return 1; - else return 0; -} int Person::getIdle(){ if(indialogue!=-1&&howactive==typeactive&&creature==rabbittype)return talkidleanim; if(hasvictim&&victim!=this/*||(id==0&&attackkeydown)*/)if(/*(id==0&&attackkeydown)||*/(!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id #include "Weapons.h" +#include "Animation.h" #define passivetype 0 #define guardtype 1 @@ -322,8 +323,14 @@ class Person void DoBloodBig(float howmuch, int which); bool DoBloodBigWhere(float howmuch, int which, XYZ where); - bool wasIdle(); - bool isIdle(); + bool wasIdle() + { + return animation_bits[currentanimation] & ab_idle; + } + bool isIdle() + { + return animation_bits[targetanimation] & ab_idle; + } int getIdle(); bool isSitting();