Jump to content

Recommended Posts

Hi! I'm making character mod but I don't have knowledge about modding.

I want make if my character's health is lower, then I want to give damage boost.

 

Quote

local function onhealthchange(inst)
    if inst.components.health.currenthealth > (50)  then
        inst.components.combat.damagemultiplier = 1.5
    
    elseif  inst.components.health.currenthealth > (0) and inst.components.health.currenthealth <= (50) then
        inst.components.combat.damagemultiplier = 2.5
    end
end

 

This is my script, and it's not working.

What's wrong with that?

Or, How can I make my character have that perk?

I'm sorry about my poor English. Please help me:wilson_cry:

Edited by Bee333

What you did there is just declare a function, but it is called nowhere, that's why it's not working.

As you want to make it dependend on the health of the character, add this line to the masterpostinit:

inst:ListenForEvent("healthdelta",onhealthchange)

This calls your function each time the health of the character changes.

  • Like 1
On 8/11/2021 at 3:50 PM, Monti18 said:

What you did there is just declare a function, but it is called nowhere, that's why it's not working.

As you want to make it dependend on the health of the character, add this line to the masterpostinit:


inst:ListenForEvent("healthdelta",onhealthchange)

This calls your function each time the health of the character changes.

Thanks you so much! It works now :encouragement:

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
×
  • Create New...