LordStark Posted July 3, 2022 Report Share Posted July 3, 2022 I can't seem to figure out what determines whether a unit runs or walks. Does anyone know how I can get my wolf to run when attacking? My actor file: Spoiler <?xml version="1.0" encoding="utf-8"?> <actor version="1"> <castshadow/> <group> <variant frequency="100" name="Mesh"> <mesh>skeletal/wolf.dae</mesh> <animations> <animation file="quadraped/wolf_walk.dae" name="Walk" speed="75"/> <animation file="quadraped/wolf_run.dae" name="Run" speed="10"/> <animation file="quadraped/wolf_attack_01.dae" name="attack_melee" speed="165"/> <animation file="quadraped/wolf_attack_02.dae" name="attack_melee" speed="165"/> <animation file="quadraped/wolf_idle_01.dae" name="Idle" speed="100"/> <animation file="quadraped/wolf_idle_02.dae" name="Idle" speed="100"/> <animation file="quadraped/wolf_idle_03.dae" name="Idle" speed="100"/> <animation file="quadraped/wolf_death_01.dae" name="death" speed="100"/> <animation file="quadraped/wolf_death_02.dae" name="death" speed="100"/> </animations> </variant> </group> <group> <variant frequency="4" name="fur-grey"> <textures> <texture file="skeletal/animal_wolf_grey.png" name="baseTex"/> </textures> </variant> </group> <group> <variant frequency="100" name="Idle"/> <variant name="death"> <props> <prop actor="props/units/blood_01.xml" attachpoint="root"/> </props> </variant> </group> <material>default.xml</material> </actor> Quote Link to comment Share on other sites More sharing options...
Freagarach Posted July 3, 2022 Report Share Posted July 3, 2022 Hey, you'll need to mess around in the UnitAI.js component (https://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js). Regarding the first question: UnitMotion deteremines the switch from walking to running, based on the units current speed. So you don't need extra work in the actor, but have to ensure in the above file that you want to run when approaching for attacks. E.g. in functions https://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js#L1269 and https://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js#L2057 you'll need to set the entity to running. And in functions https://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js#L1282 and https://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js#L2071, respectively, you'll need to reset the speed multiplier to normal. One can take a look at how it's done for chasing (search for `"chasing":` in that file). Quote Link to comment Share on other sites More sharing options...
LordStark Posted July 3, 2022 Author Report Share Posted July 3, 2022 So as an example, I need to edit this: Spoiler 1267 "COMBAT": { 1268 "APPROACHING": { 1269 "enter": function() { 1270 let cmpFormation = Engine.QueryInterface(this.entity, IID_Formation); 1271 cmpFormation.SetRearrange(true); 1272 cmpFormation.MoveMembersIntoFormation(true, true, "combat"); this.SetSpeedMultiplier(this.GetRunMultiplier()); 1273 1274 if (!this.MoveFormationToTargetAttackRange(this.order.data.target)) 1275 { 1276 this.FinishOrder(); 1277 return true; 1278 } 1279 return false; 1280 }, 1281 1282 "leave": function() { 1283 this.StopMoving(); 1284 }, 1285 1286 "MovementUpdate": function(msg) { 1287 let target = this.order.data.target; 1288 let cmpTargetUnitAI = Engine.QueryInterface(target, IID_UnitAI); 1289 if (cmpTargetUnitAI && cmpTargetUnitAI.IsFormationMember()) 1290 target = cmpTargetUnitAI.GetFormationController(); 1291 let cmpAttack = Engine.QueryInterface(this.entity, IID_Attack); 1292 this.CallMemberFunction("Attack", [target, this.order.data.allowCapture, false]); 1293 if (cmpAttack.CanAttackAsFormation()) 1294 this.SetNextState("COMBAT.ATTACKING"); 1295 else 1296 this.SetNextState("MEMBER"); 1297 }, 1298 }, Also, won't this mean that all units will begin running to attack the enemy rather than just my wolf? Here is my unit motion in the wolf template file: Spoiler <UnitMotion> <WalkSpeed op="mul">1.5</WalkSpeed> <RunMultiplier>2</RunMultiplier> </UnitMotion> Quote Link to comment Share on other sites More sharing options...
Stan` Posted July 3, 2022 Report Share Posted July 3, 2022 24 minutes ago, LordStark said: Also, won't this mean that all units will begin running to attack the enemy rather than just my wolf? You probably need a condition on the wolfclass. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.