• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code How does fire work?

xmrmeow

Grizzled Veteran
  • Mar 23, 2015
    1,009
    11
    OK so I know where a lot of things are in the code of the game, but one thing I still don't fully understand is where fire damage exactly "is".

    I know that when firing a flamethrower at a zed, it will do damage to that zed, and apply the DoT. What I want to know is where can I change the damage it does, and where are DoT damages calculated.

    What I want to do it is reduce the the on-hit damage to either 0 or a very low number, and make the DoT damage higher to compensate, as well as making ground fire last much longer, that way firebug will be all about spraying paths of fire to light up zeds and burn them to death with the DoT, rather than spraying the flamethrower directly at the zeds.

    The 2 things I want to know are:
    • where is the on-hit damage on the flamethrower
    • what does the DoTDamageScale variable base it's scale off of

    I believe it is the X and Y components in Spray Damage in the spray archetype but I'm not sure.


    Also, does anyone know how I would go about giving a weapon an ability that has a cooldown? It'd just be something simple like fire a projectile, but using it would have a cooldown.
     
    Last edited:
    I know this thread is old, but I hate it when I search for things and I see threads like this and wish there was an answer. So here it is:

    As far as I can tell, yes, the SprayDamage.X and .Y in SprayActor_Flame are responsible for the "impact" damage. In KFSprayActor:

    Code:
    /** Damage amounts done at DamageInterval. X = damage closest to nozzle, Y = damage at far end of spray */
    var(SprayDamage) vector2d    SprayDamage;

    As for the DoT_DamageScale variable, in KFWeap_FlameBase:

    Code:
    static simulated function float CalculateTraderWeaponStatDamage()
    {
        local float BaseDamage, DoTDamage;
        local class<KFDamageType> DamageType;
    
        BaseDamage = default.FlameSprayArchetype.SprayDamage.X;
    
        DamageType = default.FlameSprayArchetype.MyDamageType;
        if( DamageType != none && DamageType.default.DoT_Type != DOT_None )
        {
            DoTDamage = (DamageType.default.DoT_Duration / DamageType.default.DoT_Interval) * (BaseDamage * DamageType.default.DoT_DamageScale);
        }
    
        return BaseDamage + DoTDamage;
    }

    Also, in KFPawn.ApplyDamageOverTime:

    Code:
    NewDoTDamage = Round( Damage * KFDT.default.DoT_DamageScale );

    So it appears that the damage applied on each tick of the DoT is simply the damage of the "impact" damage multiplied by the DoT_DamageScale.

    To give a weapon a cooldown, you can simply use timers. Each time you perform the attack, set a timer to the cooldown duration, and each time you attempt to perform the attack, check if the timer is inactive. You can check an implementation of this in KFWeap_MeleeBase for the cooldown of parries, in the state MeleeBlocking. You would do something like:

    Code:
    if(!IsTimerActive(nameof(SomeTimer))) //or !IsTimerActive('SomeTimer')
    {
        //perform the attack
        //reset the timer
    }

    And you can stick some code in that timer function if you wanted something to happen when it finished.
     
    Upvote 0