Jump to content

Unexpected symbol near ')'


Recommended Posts

Im new to modding so im sorry if this is an obvious fix. I wanted my character to get 2x damage when they kill an enemy and lose 0.25x damage when they hit an enemy. So I used and edited a code that I found somewhere on the forums but I keep getting "Unexpected symbol near ')' no matter what I do. 

The ')' the game is talking about is below "if inst.components.combat.damagemultiplier > 0.75 then" and above "inst.OnSave"

    inst:ListenForEvent("onkillother", function(inst, data)
     inst.components.combat.damagemultiplier = 2
    end)
    inst:ListenForEvent("onattackother", function(inst, data)
    if inst.components.combat.damagemultiplier > 0.75 then
     inst.components.combat.damagemultiplier = inst.components.combat.damagemultiplier - 0.25
    else
    end)

    inst.OnSave = function(inst, data)
    data.mult = inst.components.combat.damagemultiplier
    end

    inst.OnLoad = function(inst, data)
    inst.components.combat.damagemultiplier = data.mult or 0.75
    end

Link to comment
Share on other sites

Replace your code with this:

    inst:ListenForEvent("onkillother", function(inst, data)
     inst.components.combat.damagemultiplier = 2
    end)
    inst:ListenForEvent("onattackother", function(inst, data)
    if inst.components.combat.damagemultiplier > 0.75 then
     inst.components.combat.damagemultiplier = inst.components.combat.damagemultiplier - 0.25
    end
    end)

    inst.OnSave = function(inst, data)
    data.mult = inst.components.combat.damagemultiplier
    end

    inst.OnLoad = function(inst, data)
    inst.components.combat.damagemultiplier = data.mult or 0.75
    end 

It should work.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...