Jump to content

Wolf - How to get it to run when attacking?


LordStark
 Share

Recommended Posts

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>
 

 

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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>

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...