]> git.jsancho.org Git - lugaru.git/commitdiff
Simplify idle animations
authorAlexander Monakov <amonakov@gmail.com>
Fri, 31 Dec 2010 00:29:23 +0000 (03:29 +0300)
committerAlexander Monakov <amonakov@gmail.com>
Fri, 31 Dec 2010 00:29:23 +0000 (03:29 +0300)
Source/Animation.def
Source/Animation.h
Source/Person.cpp
Source/Person.h

index 9726a80ed6e0c8b6aedbe26029ed9f8178235945..54dc3adcb5082e89cf51f9d39ae39193ee8331aa 100644 (file)
@@ -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)
index 0720426efa38724a0144b81346d34560b383c881..668cac3456e5d482c255f4ffbbb17320ae6da7fc 100644 (file)
@@ -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();
index 818e6ce29c404ed5a61a206bc1d7362b814df377..6eb59f04a07e1b240bcf49a60399160a5a3773ad 100644 (file)
@@ -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<numplayers)){
index 5c5a96983c2c17abffd02dc568d22232c8736183..10f6ab2808d96779aac7119e180fc870109957b0 100644 (file)
@@ -33,6 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "Sprite.h"
 #include <cmath>
 #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();