From: Côme Chilliet Date: Sun, 5 Feb 2017 21:24:11 +0000 (+0100) Subject: Moved more animation info to PersonType X-Git-Url: https://git.jsancho.org/?p=lugaru.git;a=commitdiff_plain;h=3bc5ee099a4322252ae9afd564335b60856a0054 Moved more animation info to PersonType --- diff --git a/Source/Objects/Person.cpp b/Source/Objects/Person.cpp index c055e57..817ee03 100644 --- a/Source/Objects/Person.cpp +++ b/Source/Objects/Person.cpp @@ -75,6 +75,16 @@ extern XYZ windvector; std::vector> Person::players(1, std::shared_ptr(new Person())); std::vector PersonType::types; +PersonType::PersonType() +{ + animTalkIdle = tempanim; +} + +bool PersonType::hasAnimTalkIdle() +{ + return (animTalkIdle != tempanim); +} + void PersonType::Load() { types.resize(2); @@ -91,6 +101,8 @@ void PersonType::Load() types[wolftype].animStop = wolfstopanim; types[wolftype].animLanding = wolflandanim; types[wolftype].animLandingHard = wolflandhardanim; + types[wolftype].animFightIdle = wolfidle; + types[wolftype].animBounceIdle = wolfidle; types[wolftype].soundsAttack[0] = barksound; types[wolftype].soundsAttack[1] = bark2sound; @@ -130,6 +142,8 @@ void PersonType::Load() types[rabbittype].animStop = stopanim; types[rabbittype].animLanding = landanim; types[rabbittype].animLandingHard = landhardanim; + types[rabbittype].animFightIdle = fightidleanim; + types[rabbittype].animBounceIdle = bounceidleanim; types[rabbittype].soundsAttack[0] = rabbitattacksound; types[rabbittype].soundsAttack[1] = rabbitattack2sound; @@ -676,20 +690,15 @@ void Person::CatchFire() */ int Person::getIdle() { - if (Dialog::inDialog() && (howactive == typeactive) && (creature == rabbittype)) { - return talkidleanim; + if (Dialog::inDialog() && (howactive == typeactive) && PersonType::types[creature].hasAnimTalkIdle()) { + return PersonType::types[creature].animTalkIdle; } if (hasvictim && (victim != this->shared_from_this())) { if ((!victim->dead && victim->aitype != passivetype && victim->aitype != searchtype && aitype != passivetype && aitype != searchtype && victim->id < Person::players.size())) { if ((aitype == playercontrolled && stunned <= 0 && weaponactive == -1) || pause) { - if (creature == rabbittype) { - return fightidleanim; - } - if (creature == wolftype) { - return wolfidle; - } + return PersonType::types[creature].animFightIdle; } if (aitype == playercontrolled && stunned <= 0 && weaponactive != -1) { if (weapons[weaponids[weaponactive]].getType() == knife) { @@ -734,13 +743,7 @@ int Person::getIdle() if (howactive == typedead4) { return dead4anim; } - if (creature == rabbittype) { - return bounceidleanim; - } - if (creature == wolftype) { - return wolfidle; - } - return 0; + return PersonType::types[creature].animBounceIdle; } /* FUNCTION diff --git a/Source/Objects/Person.hpp b/Source/Objects/Person.hpp index ba329fe..4896cbd 100644 --- a/Source/Objects/Person.hpp +++ b/Source/Objects/Person.hpp @@ -67,6 +67,10 @@ public: animation_type animStop; animation_type animLanding; animation_type animLandingHard; + animation_type animFightIdle; + animation_type animBounceIdle; + animation_type animTalkIdle; + sound_type soundsAttack[4]; sound_type soundsTalk[2]; @@ -81,6 +85,9 @@ public: GLubyte bloodText[512 * 512 * 3] = { 0 }; + PersonType(); + bool hasAnimTalkIdle(); + static std::vector types; static void Load(); };