Jump to content

[Question] Can you change animation speed based on reload speed?


ivailogeimara

Recommended Posts

I imported a gun, into the game, with animations for fire and reload but a perk that increases reload speed messes up the animation of the gun because the animation is timed for normal reload speed and plays for longer than the actual reload. Is there a way to speed up animations based on stat modifiers (perk, etc)?

My items.xml:

<configs>
 <set xpath="/items/item[@name='gunPistol']/property[@name='Meshfile']/@value">#@modfolder:Resources/M12Nova.unity3d?M12NovaPrefab</set>
 <set xpath="/items/item[@name='gunPistol']/property[@name='CrosshairOnAim']/@value">false</set>
 <set xpath="/items/item[@name='gunPistol']/property[@class='Action0']/property[@name='Sound_start']/@value">M12NovaFire</set>
 <set xpath="/items/item[@name='gunPistol']/property[@class='Action1']/property[@name='ScopeCameraOffset']/@value">0,.025,0</set>
 <append xpath="/items/item[@name='gunPistol']/effect_group[@name='gunPistol']">
   <triggered_effect trigger="onSelfPrimaryActionStart" action="AnimatorFireTrigger" target="self" property="WeaponFire" value=""/>
   <triggered_effect trigger="onReloadStart" action="AnimatorFireTrigger" target="self" property="TReload" value=""/>
 </append>
</configs>

I basically replaced the model of the normal pistol instead of adding another one.

Link to comment
Share on other sites

Should be possible, but might need some experimenting for the syntax. You need to change the value of ReloadSpeed in the player controller for that modifier. I think the default is 2.0, but that should vary based on the weapon. So maybe: triggered_effect trigger="onReloadStart" action="AnimatorSetFloat" property="ReloadSpeed" value="3.0"/>

Link to comment
Share on other sites

Should be possible, but might need some experimenting for the syntax. You need to change the value of ReloadSpeed in the player controller for that modifier. I think the default is 2.0, but that should vary based on the weapon. So maybe: triggered_effect trigger="onReloadStart" action="AnimatorSetFloat" property="ReloadSpeed" value="3.0"/>

 

Either I misunderstood something or you misunderstood what I am asking. By "change the value of ReloadSpeed in the player controller" you mean this right?:

<append xpath="/entity_classes/entity_class[@name='playerMale']/effect_group">
       <triggered_effect trigger="onReloadStart" action="AnimatorSetFloat" property="ReloadSpeed" value="3.0"/>
</append>

But this speeds up the whole reload amimation (hands + gun) and this is not what I am going for.

Some mods and perks/skills increase reload speed. More than 1 mod/skill can be applied at the time. In 7DaysToDie there is 1 perk and 1 mod that increase reload speed of the pistol: {perkGunslinger} and {modArmorBandolier through buffBandolier}. They both increase the "passive_effect" "ReloadSpeedMultiplier". I was wondering if somehow I can pass the actual ReloadSpeed amount (after applying all the multipliers) or the ReloadSpeedMultiplier to the AnimationController of my weapon or something like that. The closest thing I came with was to set CVars when perkGunslinger and buffBandolier apply to the amount of the ReloadSpeedMultiplier they add and then combine them to single CVar with the total ReloadSpeedMultiplier amount but I can't send it to the animation controller bacause AnimatorSetFloat doesn't accept CVars as value.

Link to comment
Share on other sites

So there are 2 ways to do it:

(Animator==Animator Controller)

The first one as xyth mentioned is through animator float property named "ReloadSpeed". Basically this property gets set automatically in your weapon's Animator Controller by the game. So I just added property of type float with name ReloadSpeed in the weapon's Animator Controller and set the reload animation Speed -> Multiplier to ReloadSpeed and set the default value in the Parameters window in the Animator to 1.0.

 

The second way which gives you more control is:

It's kinda messy but unless TFP give us the ability to pass CVar values to AnimatorSet functions (which takes like additional 5-10 lines of code in 3 classes) (I might make myself DMT mod for that when A18 is released) this is the only way (I think) to do it.

 

buffs.xml

<configs>
   <append xpath="/buffs/buff[@name='buffPerkAbilityUpdate']/effect_group">
       <triggered_effect trigger="onSelfBuffStack" action="ModifyCVar" cvar=".GunslingerReloadSpeedMultiplier" operation="set" value="0">
           <requirement name="ProgressionLevel" progression_name="perkGunslinger" operation="Equals" value="0"/>
       </triggered_effect>
       <triggered_effect trigger="onSelfBuffStack" action="ModifyCVar" cvar=".GunslingerReloadSpeedMultiplier" operation="set" value="0.06">
           <requirement name="ProgressionLevel" progression_name="perkGunslinger" operation="Equals" value="1"/>
       </triggered_effect>
       <triggered_effect trigger="onSelfBuffStack" action="ModifyCVar" cvar=".GunslingerReloadSpeedMultiplier" operation="set" value="0.12">
           <requirement name="ProgressionLevel" progression_name="perkGunslinger" operation="Equals" value="2"/>
       </triggered_effect>
       <triggered_effect trigger="onSelfBuffStack" action="ModifyCVar" cvar=".GunslingerReloadSpeedMultiplier" operation="set" value="0.18">
           <requirement name="ProgressionLevel" progression_name="perkGunslinger" operation="Equals" value="3"/>
       </triggered_effect>
       <triggered_effect trigger="onSelfBuffStack" action="ModifyCVar" cvar=".GunslingerReloadSpeedMultiplier" operation="set" value="0.24">
           <requirement name="ProgressionLevel" progression_name="perkGunslinger" operation="Equals" value="4"/>
       </triggered_effect>
       <triggered_effect trigger="onSelfBuffStack" action="ModifyCVar" cvar=".GunslingerReloadSpeedMultiplier" operation="set" value="0.3">
           <requirement name="ProgressionLevel" progression_name="perkGunslinger" operation="Equals" value="5"/>
       </triggered_effect>
   </append>
   <append xpath="/buffs/buff[@name='buffBandolier']/effect_group">
       <triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar=".modBandolierEquiped" operation="set" value="1"/>
       <triggered_effect trigger="onSelfBuffRemove" action="ModifyCVar" cvar=".modBandolierEquiped" operation="set" value="0"/>
   </append>
</configs>

 

items.xml

<configs>
 <set xpath="/items/item[@name='gunPistol']/property[@name='Meshfile']/@value">#@modfolder:Resources/M12Nova.unity3d?M12NovaPrefab</set>
 <set xpath="/items/item[@name='gunPistol']/property[@name='CrosshairOnAim']/@value">false</set>
 <set xpath="/items/item[@name='gunPistol']/property[@class='Action0']/property[@name='Sound_start']/@value">M12NovaFire</set>
 <set xpath="/items/item[@name='gunPistol']/property[@class='Action1']/property[@name='ScopeCameraOffset']/@value">0,.025,0</set>
 <append xpath="/items/item[@name='gunPistol']/effect_group[@name='gunPistol']">
   <triggered_effect trigger="onSelfPrimaryActionStart" action="AnimatorFireTrigger" target="self" property="WeaponFire" value=""/>
       <!-- Only Gunslinger -->
   <triggered_effect trigger="onReloadStart" action="AnimatorSetFloat" target="self" property="ReloadSpeedMult" value="1">
       <requirement  name="CVarCompare" cvar=".GunslingerReloadSpeedMultiplier" target="self" operation="Equals" value="0"/>
   </triggered_effect>
   <triggered_effect trigger="onReloadStart" action="AnimatorSetFloat" target="self" property="ReloadSpeedMult" value="1.06">
       <requirement  name="CVarCompare" cvar=".GunslingerReloadSpeedMultiplier" target="self" operation="Equals" value="0.06"/>
   </triggered_effect>
   <triggered_effect trigger="onReloadStart" action="AnimatorSetFloat" target="self" property="ReloadSpeedMult" value="1.12">
       <requirement  name="CVarCompare" cvar=".GunslingerReloadSpeedMultiplier" target="self" operation="Equals" value="0.12"/>
   </triggered_effect>
   <triggered_effect trigger="onReloadStart" action="AnimatorSetFloat" target="self" property="ReloadSpeedMult" value="1.18">
       <requirement  name="CVarCompare" cvar=".GunslingerReloadSpeedMultiplier" target="self" operation="Equals" value="0.18"/>
   </triggered_effect>
   <triggered_effect trigger="onReloadStart" action="AnimatorSetFloat" target="self" property="ReloadSpeedMult" value="1.24">
       <requirement  name="CVarCompare" cvar=".GunslingerReloadSpeedMultiplier" target="self" operation="Equals" value="0.24"/>
   </triggered_effect>
   <triggered_effect trigger="onReloadStart" action="AnimatorSetFloat" target="self" property="ReloadSpeedMult" value="1.3">
       <requirement  name="CVarCompare" cvar=".GunslingerReloadSpeedMultiplier" target="self" operation="Equals" value="0.3"/>
   </triggered_effect>

   <!-- Only Bandolier mod -->
   <triggered_effect trigger="onReloadStart" action="AnimatorSetFloat" target="self" property="ReloadSpeedMult" value="1.3">
       <requirement  name="CVarCompare" cvar=".modBandolierEquiped" target="self" operation="Equals" value="1"/>
   </triggered_effect>

   <!-- Ginslinger + Bandolier -->
   <triggered_effect trigger="onReloadStart" action="AnimatorSetFloat" target="self" property="ReloadSpeedMult" value="1.36">
       <requirement  name="CVarCompare" cvar=".GunslingerReloadSpeedMultiplier" target="self" operation="Equals" value="0.06"/>
       <requirement  name="CVarCompare" cvar=".modBandolierEquiped" target="self" operation="Equals" value="1"/>
   </triggered_effect>
   <triggered_effect trigger="onReloadStart" action="AnimatorSetFloat" target="self" property="ReloadSpeedMult" value="1.42">
       <requirement  name="CVarCompare" cvar=".GunslingerReloadSpeedMultiplier" target="self" operation="Equals" value="0.12"/>
       <requirement  name="CVarCompare" cvar=".modBandolierEquiped" target="self" operation="Equals" value="1"/>
   </triggered_effect>
   <triggered_effect trigger="onReloadStart" action="AnimatorSetFloat" target="self" property="ReloadSpeedMult" value="1.48">
       <requirement  name="CVarCompare" cvar=".GunslingerReloadSpeedMultiplier" target="self" operation="Equals" value="0.18"/>
       <requirement  name="CVarCompare" cvar=".modBandolierEquiped" target="self" operation="Equals" value="1"/>
   </triggered_effect>
   <triggered_effect trigger="onReloadStart" action="AnimatorSetFloat" target="self" property="ReloadSpeedMult" value="1.54">
       <requirement  name="CVarCompare" cvar=".GunslingerReloadSpeedMultiplier" target="self" operation="Equals" value="0.24"/>
       <requirement  name="CVarCompare" cvar=".modBandolierEquiped" target="self" operation="Equals" value="1"/>
   </triggered_effect>
   <triggered_effect trigger="onReloadStart" action="AnimatorSetFloat" target="self" property="ReloadSpeedMult" value="1.6">
       <requirement  name="CVarCompare" cvar=".GunslingerReloadSpeedMultiplier" target="self" operation="Equals" value="0.3"/>
       <requirement  name="CVarCompare" cvar=".modBandolierEquiped" target="self" operation="Equals" value="1"/>
   </triggered_effect>

   <triggered_effect trigger="onReloadStart" action="AnimatorFireTrigger" target="self" property="TReload" value=""/>
 </append>
</configs>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...