Adding movement speed effect to a weapon

Started by MightyMonte88, December 16, 2020, 07:45:13 AM

MightyMonte88

Hey i've added a new heavy tier weapon to my modpack, and i'm trying to add the effect of reduced movement speed, and cannot run, the same effects that are applied when equipping heavy armor, i'm not getting any runtime or compile errors, however the effect is simply not working, would you be able to tell me what i am doing wrong? below is a snippet of how i am calling it, and how i have defined it.


This is called under the public class for the new weapon
        protected override void PrepareEffects(Effects effects)
        {
            base.PrepareEffects(effects);
            effects.AddPerk(this, StatName.PerkCannotRun);

            // -10% movement speed
            effects.AddPercent(this, StatName.MoveSpeed, -10);
        }


And this under protoitemweaponsranged

        protected virtual void PrepareEffects(Effects effects)
        {
        }

ai_enabled

Hello!
Weapon is not an equipment (like armor/helmets/implants). It doesn't have a list of effects that are getting applied to the character when it has the weapon selected. If you simply define PrepareEffects method it will not work as it's never called, and also the prepared effects collection is never propagated to the player's effects cache (aka final stats cache).
Implementing this idea would take much more work, unfortunately.

Regards!

MightyMonte88

Yeah i've been looking into it, i think i can see what i need to do but it's extensive, and i would rather wait for the A29 update before attempting changes to the games core functions. I'm hoping you guys plan to add some stat debuff to the new player hand held machine gun  ;). For now i will just decrease accuracy and reduce ammo capacity of the weapon i added. Thanks again AI