Index: ps/trunk/source/simulation2/components/ICmpAttack.h =================================================================== --- ps/trunk/source/simulation2/components/ICmpAttack.h +++ ps/trunk/source/simulation2/components/ICmpAttack.h @@ -18,12 +18,14 @@ #ifndef INCLUDED_ICMPATTACK #define INCLUDED_ICMPATTACK +#include "ps/CStr.h" #include "simulation2/system/Interface.h" class ICmpAttack : public IComponent { public: virtual float GetRepeatTime(const std::string& type) const = 0; + virtual std::vector GetAttackTypes() const = 0; DECLARE_INTERFACE_TYPE(Attack) }; Index: ps/trunk/source/simulation2/components/ICmpAttack.cpp =================================================================== --- ps/trunk/source/simulation2/components/ICmpAttack.cpp +++ ps/trunk/source/simulation2/components/ICmpAttack.cpp @@ -31,10 +31,15 @@ public: DEFAULT_SCRIPT_WRAPPER(AttackScripted) - virtual float GetRepeatTime(const std::string& type) const - { - return m_Script.Call("GetRepeatTime", type); - } + virtual float GetRepeatTime(const std::string& type) const + { + return m_Script.Call("GetRepeatTime", type); + } + + virtual std::vector GetAttackTypes() const + { + return m_Script.Call>("GetAttackTypes"); + } }; REGISTER_COMPONENT_SCRIPT_WRAPPER(AttackScripted) Index: ps/trunk/source/tools/atlas/GameInterface/ActorViewer.cpp =================================================================== --- ps/trunk/source/tools/atlas/GameInterface/ActorViewer.cpp +++ ps/trunk/source/tools/atlas/GameInterface/ActorViewer.cpp @@ -382,7 +382,7 @@ CStr anim = animation.LowerCase(); float speed = 1.0f; // Speed will be ignored if we have a repeat time. - float repeattime = 0.0f; + float repeatTime = 0.0f; m.CurrentSpeed = 0.0f; if (anim == "walk") { @@ -403,22 +403,25 @@ m.CurrentSpeed = speed; } - else if (anim == "attack_melee") - repeattime = GetRepeatTimeByAttackType("Melee"); - else if (anim == "attack_ranged") - repeattime = GetRepeatTimeByAttackType("Ranged"); - else if (anim == "attack_slaughter") - repeattime = GetRepeatTimeByAttackType("Slaughter"); - else if (anim == "attack_capture") - repeattime = GetRepeatTimeByAttackType("Capture"); + else if (anim.Find("attack_") == 0) + { + CmpPtr cmpAttack(m.Simulation2, m.Entity); + if (cmpAttack) + for (const CStr& type : cmpAttack->GetAttackTypes()) + if (anim == "attack_" + type.LowerCase()) + { + repeatTime = GetRepeatTimeByAttackType(type); + break; + } + } CmpPtr cmpVisual(m.Simulation2, m.Entity); if (cmpVisual) { // TODO: SetEntitySelection(anim) cmpVisual->SelectAnimation(anim, false, fixed::FromFloat(speed)); - if (repeattime) - cmpVisual->SetAnimationSyncRepeat(fixed::FromFloat(repeattime)); + if (repeatTime > 0.0f) + cmpVisual->SetAnimationSyncRepeat(fixed::FromFloat(repeatTime)); } // update prop list for new entity/animation (relies on needsAnimReload also getting called for entire entity changes)