From 7aa870825c0e851e69703d9730e20db6eb94a675 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20Chilliet?= Date: Sat, 19 Aug 2017 02:11:00 +0200 Subject: [PATCH] Moved hurtidle anim to PersonType to avoid hardcoded wolftype test --- Source/Objects/Person.cpp | 4 ++-- Source/Objects/PersonType.cpp | 7 +++++++ Source/Objects/PersonType.hpp | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Source/Objects/Person.cpp b/Source/Objects/Person.cpp index 8898cac..279fb32 100644 --- a/Source/Objects/Person.cpp +++ b/Source/Objects/Person.cpp @@ -618,8 +618,8 @@ int Person::getIdle() } } } - if ((damage > permanentdamage || damage > damagetolerance * .8 || deathbleeding > 0) && creature != wolftype) { - return hurtidleanim; + if ((damage > permanentdamage || damage > damagetolerance * .8 || deathbleeding > 0) && PersonType::types[creature].hasAnimHurtIdle()) { + return PersonType::types[creature].animHurtIdle; } if (howactive == typesitting) { return sitanim; diff --git a/Source/Objects/PersonType.cpp b/Source/Objects/PersonType.cpp index 0cf880c..41d07c2 100644 --- a/Source/Objects/PersonType.cpp +++ b/Source/Objects/PersonType.cpp @@ -24,6 +24,7 @@ std::vector PersonType::types; PersonType::PersonType() { animTalkIdle = tempanim; + animHurtIdle = tempanim; } bool PersonType::hasAnimTalkIdle() @@ -31,6 +32,11 @@ bool PersonType::hasAnimTalkIdle() return (animTalkIdle != tempanim); } +bool PersonType::hasAnimHurtIdle() +{ + return (animHurtIdle != tempanim); +} + void PersonType::Load() { types.resize(2); @@ -99,6 +105,7 @@ void PersonType::Load() types[rabbittype].animFightIdle = fightidleanim; types[rabbittype].animBounceIdle = bounceidleanim; types[rabbittype].animTalkIdle = talkidleanim; + types[rabbittype].animHurtIdle = hurtidleanim; types[rabbittype].soundsAttack[0] = rabbitattacksound; types[rabbittype].soundsAttack[1] = rabbitattack2sound; diff --git a/Source/Objects/PersonType.hpp b/Source/Objects/PersonType.hpp index f981113..5502b4c 100644 --- a/Source/Objects/PersonType.hpp +++ b/Source/Objects/PersonType.hpp @@ -44,6 +44,7 @@ public: animation_type animFightIdle; animation_type animBounceIdle; animation_type animTalkIdle; + animation_type animHurtIdle; sound_type soundsAttack[4]; sound_type soundsTalk[2]; @@ -69,6 +70,7 @@ public: PersonType(); bool hasAnimTalkIdle(); + bool hasAnimHurtIdle(); static std::vector types; static void Load(); -- 2.39.5