Jump to content

Weapon damage based on distance from target


Recommended Posts

I did some snooping and I couldn't find any topics that answered this question (that or i'm a terrible detective). I'm currently working on a mod and I was wondering if there was a way that could increase a boomerang's impact damage the further it has to travel to it's target.

Link to comment
Share on other sites

On 7/24/2018 at 5:39 AM, Makishim said:

You can start a timer when the function OnThrown's called. When OnHit's called you get the timer value and does: damage + (timer * aditional damage).

Any idea how I would write that in the context of this code:

local function OnThrown(inst, owner, target)
    if target ~= owner then
        owner.SoundEmitter:PlaySound("dontstarve/wilson/boomerang_throw")
    end
    inst.AnimState:PlayAnimation("spin_loop", true)
end

local function OnHit(inst, owner, target)
    if owner == target or owner:HasTag("playerghost") then
if owner ~= nil and owner.components.inventory ~= nil and owner.components.inventory.isopen then
        if inst.components.equippable ~= nil and not owner.components.inventory:GetEquippedItem(inst.components.equippable.equipslot) then
            owner.components.inventory:Equip(inst)
        else
            owner.components.inventory:GiveItem(inst)
        end
        owner:PushEvent("catch")
    end
    else
        ReturnToOwner(inst, owner)
    end
    if target ~= nil and target:IsValid() then
        local impactfx = SpawnPrefab("impact")
        if impactfx ~= nil then
            local follower = impactfx.entity:AddFollower()
            follower:FollowSymbol(target.GUID, target.components.combat.hiteffectsymbol, 0, 0, 0)
            impactfx:FacePoint(inst.Transform:GetWorldPosition())
        end
    end
end

I did have a look at how DS RoG did timers in the SGmoose file as that has a disarm cooldown timer, but it didn't have anything on getting the values of the timer. The help is greatly appreciated.

Link to comment
Share on other sites

Archived

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

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...