Jump to content

Need help with DST code


Recommended Posts

Hey !
I'd like to make it so my character regains health when killing things (like catcoons, pigs etc)
does anyone know what the line of code for that would be and where I could copy paste it in the prefabs ? Thanks in advance :)

Link to comment
Share on other sites

 

local function KilledMob(inst, data)
	if data.victim
    and not data.victim:HasTag("prey") 
    and not data.victim:HasTag("veggie") -- Checks if the victim is really a mob (possible needs more checks)
    and not data.victim:HasTag("structure") then
        inst.components.health:DoDelta(life to be gained (number), false)
    	-- Exemple:
    	inst.components.health:DoDelta(5, false)
	end
end

-- [In your character]
inst:ListenForEvent("killed", KilledMob)

 

Link to comment
Share on other sites

43 minutes ago, Leonidas IV said:

thank you so so much !!! :D


local function KilledMob(inst, data)
	if data.victim
    and not data.victim:HasTag("prey") 
    and not data.victim:HasTag("veggie") -- Checks if the victim is really a mob (possible needs more checks)
    and not data.victim:HasTag("structure") then
        inst.components.health:DoDelta(life to be gained (number), false)
    	-- Exemple:
    	inst.components.health:DoDelta(5, false)
	end
end

-- [In your character]
inst:ListenForEvent("killed", KilledMob)

 

 

Link to comment
Share on other sites

15 hours ago, Leonidas IV said:

hey ! I finished my mod and put in the code, but sadly it didn't work :(
do you know what the issue could be ?


local function KilledMob(inst, data)
	if data.victim
    and not data.victim:HasTag("prey") 
    and not data.victim:HasTag("veggie") -- Checks if the victim is really a mob (possible needs more checks)
    and not data.victim:HasTag("structure") then
        inst.components.health:DoDelta(life to be gained (number), false)
    	-- Exemple:
    	inst.components.health:DoDelta(5, false)
	end
end

-- [In your character]
inst:ListenForEvent("killed", KilledMob)

 

 

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