MagpieVRaven Posted June 7, 2022 Share Posted June 7, 2022 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 https://forums.kleientertainment.com/forums/topic/140745-need-help-with-dst-code/ Share on other sites More sharing options...
Leonidas IV Posted June 7, 2022 Share Posted June 7, 2022 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 https://forums.kleientertainment.com/forums/topic/140745-need-help-with-dst-code/#findComment-1575756 Share on other sites More sharing options...
MagpieVRaven Posted June 7, 2022 Author Share Posted June 7, 2022 43 minutes ago, Leonidas IV said: thank you so so much !!! 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 https://forums.kleientertainment.com/forums/topic/140745-need-help-with-dst-code/#findComment-1575773 Share on other sites More sharing options...
MagpieVRaven Posted June 8, 2022 Author Share Posted June 8, 2022 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 https://forums.kleientertainment.com/forums/topic/140745-need-help-with-dst-code/#findComment-1575867 Share on other sites More sharing options...
Thomas_klei Posted June 8, 2022 Share Posted June 8, 2022 Can you show your full code, I think this is pre-existing code for wigfrid so it should work. it could be where you are placing the code, sorry could you in fact poste the entire file. 1 Link to comment https://forums.kleientertainment.com/forums/topic/140745-need-help-with-dst-code/#findComment-1575878 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now