Index: binaries/data/mods/public/simulation/components/Attack.js =================================================================== --- binaries/data/mods/public/simulation/components/Attack.js +++ binaries/data/mods/public/simulation/components/Attack.js @@ -401,15 +401,20 @@ return aPreference - bPreference; }; +Attack.prototype.GetRepeatTime = function(type) +{ + if(!this.template[type] || !this.template[type].RepeatTime) + return 1000; + + return ApplyValueModificationsToEntity("Attack/" + type + "/RepeatTime", +this.template[type].RepeatTime, this.entity) +}; + Attack.prototype.GetTimers = function(type) { let prepare = +(this.template[type].PrepareTime || 0); prepare = ApplyValueModificationsToEntity("Attack/" + type + "/PrepareTime", prepare, this.entity); - let repeat = +(this.template[type].RepeatTime || 1000); - repeat = ApplyValueModificationsToEntity("Attack/" + type + "/RepeatTime", repeat, this.entity); - - return { "prepare": prepare, "repeat": repeat }; + return { "prepare": prepare, "repeat": GetRepeatTime(type) }; }; Attack.prototype.GetSplashDamage = function(type) Index: binaries/data/mods/public/simulation/components/interfaces/Attack.js =================================================================== --- binaries/data/mods/public/simulation/components/interfaces/Attack.js +++ binaries/data/mods/public/simulation/components/interfaces/Attack.js @@ -1,5 +1,3 @@ -Engine.RegisterInterface("Attack"); - /** * Message of the form { "attacker": number, "target": number, "type": string, "damage": number, "attackerOwner": number } * sent from Attack component and by Damage component to the target entity, each time the target is attacked or damaged. Index: source/simulation2/TypeList.h =================================================================== --- source/simulation2/TypeList.h +++ source/simulation2/TypeList.h @@ -79,6 +79,9 @@ INTERFACE(AIManager) COMPONENT(AIManager) +INTERFACE(Attack) +COMPONENT(AttackScripted) + INTERFACE(CinemaManager) COMPONENT(CinemaManager) Index: source/tools/atlas/GameInterface/ActorViewer.cpp =================================================================== --- source/tools/atlas/GameInterface/ActorViewer.cpp +++ source/tools/atlas/GameInterface/ActorViewer.cpp @@ -48,6 +48,7 @@ #include "renderer/WaterManager.h" #include "scriptinterface/ScriptInterface.h" #include "simulation2/Simulation2.h" +#include "simulation2/components/ICmpAttack.h" #include "simulation2/components/ICmpOwnership.h" #include "simulation2/components/ICmpPosition.h" #include "simulation2/components/ICmpRangeManager.h" @@ -377,11 +378,14 @@ if (needsAnimReload) { + // Emulate the typical simulation animation behaviour CStr anim = animation.LowerCase(); + CStr sound = anim; - // Emulate the typical simulation animation behaviour - float speed; - float repeattime = 0.f; + // speed will be ignored if we have a repeattime + float speed = 1.f; + float repeattime = 0.0f; + m.CurrentSpeed = speed; if (anim == "walk") { CmpPtr cmpUnitMotion(m.Simulation2, m.Entity); @@ -402,29 +406,33 @@ m.CurrentSpeed = speed; } - else if (anim == "melee") + else if (anim == "attack_melee") + { + CmpPtr cmpAttack(m.Simulation2, m.Entity); + if (cmpAttack) + repeattime = static_cast(cmpAttack->GetRepeatTime("Melee")); + } + else if (anim == "attack_ranged") { - speed = 1.f; // speed will be ignored if we have a repeattime - m.CurrentSpeed = 0.f; + CmpPtr cmpAttack(m.Simulation2, m.Entity); + if (cmpAttack) + repeattime = static_cast(cmpAttack->GetRepeatTime("Ranged")); - CStr code = "var cmp = Engine.QueryInterface("+CStr::FromUInt(m.Entity)+", IID_Attack); " + - "if (cmp) cmp.GetTimers(cmp.GetBestAttack()).repeat; else 0;"; - m.Simulation2.GetScriptInterface().Eval(code.c_str(), repeattime); } - else + else if (anim == "attack_slaughter") { - // Play the animation at normal speed, but movement speed is zero - speed = 1.f; - m.CurrentSpeed = 0.f; + CmpPtr cmpAttack(m.Simulation2, m.Entity); + if (cmpAttack) + repeattime = static_cast(cmpAttack->GetRepeatTime("Slaugther")); + + } + else if (anim == "attack_capture") + { + CmpPtr cmpAttack(m.Simulation2, m.Entity); + if (cmpAttack) + repeattime = static_cast(cmpAttack->GetRepeatTime("Capture")); } - CStr sound; - if (anim == "melee") - sound = "attack"; - else if (anim == "build") - sound = "build"; - else if (anim.Find("gather_") == 0) - sound = anim; CmpPtr cmpVisual(m.Simulation2, m.Entity); if (cmpVisual) @@ -439,6 +447,7 @@ m.UpdatePropList(); } + m.CurrentUnitID = id; m.CurrentUnitAnim = animation; }