Jump to content

Help w/ Custom character buffs at low health


Recommended Posts

I want to make a custom character, with a perk that allows them to deal more damage and run faster while at low health. This is my first time modding so being elaborate with any instructions would really help, I am still not completely sure exactly where in the code for the custom perks would go, although i would assume they go somewhere in the character.lua file. Thanks for any help.

Link to comment
Share on other sites

I did some more research and found a thread with a similar problem, I followed what they were doing based on what I was after and got these lines of code. Sadly they didn't seem to achieve what i was after. If anyone knows how to fix it and what im doing wrong your help is greatly appreciated.

local function heroking(inst)
    if (inst.components.health.current:GetPercent() > .2) then
    inst.components.locomotor.walkspeed = 6
    inst.components.locomotor.runspeed = 8
    inst.components.combat.damagemultiplier = 2
    end
end

My goal is to double the damage and increase the speed of the character when at or below 20% health.

Link to comment
Share on other sites

something like this should work :wilson_vforvictory:

 

YOURCHAR.lua

above master_postinit

Spoiler

local function heroking(inst)
	if inst.components.health:GetPercent() <= .2 then
		--make char stronk
	elseif  inst.components.health:GetPercent() >= .2 then
		--make char normal
	end
end

 

inside master_postinit

Spoiler

inst:DoPeriodicTask(2, heroking)

 

 

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...