ooitsme Posted August 25, 2014 Share Posted August 25, 2014 Hi everyone, i'm new to the forums and modding and i've made my own character mod that works in game now. I was hoping someone could help me with adding the special power to my character that wigfrid has of life leech and sanity leech from killing her enemies. I appreciate any help i can get, thanks! Link to comment https://forums.kleientertainment.com/forums/topic/39840-help-special-powers/ Share on other sites More sharing options...
1daBread Posted August 25, 2014 Share Posted August 25, 2014 Just look at her prefab file.These are what you need:As part of the prefab/custom_char.lua...In your main functioninst:ListenForEvent("entity_death", function(wrld, data) onkill(inst, data) end, GetWorld())Leech codelocal function onkill(inst, data) if data.cause == inst.prefab and not data.inst:HasTag("prey") and not data.inst:HasTag("veggie") and not data.inst:HasTag("structure") then local delta = (data.inst.components.combat.defaultdamage) * 0.25 inst.components.health:DoDelta(delta, false, "battleborn") inst.components.sanity:DoDelta(delta) if math.random() < .1 and not data.inst.components.health.nofadeout then local time = data.inst.components.health.destroytime or 2 inst:DoTaskInTime(time, function() local s = medScale if data.inst:HasTag("smallcreature") then s = smallScale elseif data.inst:HasTag("largecreature") then s = largeScale end local fx = SpawnPrefab("wathgrithr_spirit") fx.Transform:SetPosition(data.inst:GetPosition():Get()) fx.Transform:SetScale(s,s,s) end) end endend Link to comment https://forums.kleientertainment.com/forums/topic/39840-help-special-powers/#findComment-526834 Share on other sites More sharing options...
ooitsme Posted August 25, 2014 Author Share Posted August 25, 2014 hmm I put both of those codes in my custom prefab lua like this when i made this post: local function onkill(inst, data) if data.cause == inst.prefab and not data.inst:HasTag("prey") and not data.inst:HasTag("veggie") and not data.inst:HasTag("structure") then local delta = (data.inst.components.combat.defaultdamage) * 0.25 inst.components.health:DoDelta(delta, false, "battleborn") inst.components.sanity:DoDelta(delta) if math.random() < .1 and not data.inst.components.health.nofadeout then local time = data.inst.components.health.destroytime or 2 inst:DoTaskInTime(time, function() local s = medScale if data.inst:HasTag("smallcreature") then s = smallScale elseif data.inst:HasTag("largecreature") then s = largeScale end local fx = SpawnPrefab("wathgrithr_spirit") fx.Transform:SetPosition(data.inst:GetPosition():Get()) fx.Transform:SetScale(s,s,s) end) end inst:ListenForEvent("entity_death", function(wrld, data) onkill(inst, data) end, GetWorld()) end end I'm at work right now so i can't mess around with it, but does it need to be formatted differently? Link to comment https://forums.kleientertainment.com/forums/topic/39840-help-special-powers/#findComment-526851 Share on other sites More sharing options...
1daBread Posted August 26, 2014 Share Posted August 26, 2014 (edited) inst:ListenForEvent("entity_death", function(wrld, data) onkill(inst, data) end, GetWorld()) goes in the function that is called by Prefab("",fn,assets) at that end of of your character_prefab.lua So if that was the function call then fn would be where you want to put it. At this point the onKill function does not need to be changed Edited August 26, 2014 by 1daBread Link to comment https://forums.kleientertainment.com/forums/topic/39840-help-special-powers/#findComment-527297 Share on other sites More sharing options...
ooitsme Posted August 26, 2014 Author Share Posted August 26, 2014 Ah okay, i think i understand. i'll give it a try. In the meantime i added damage absorption which is a decent alternative lol. Thank you for your help! Link to comment https://forums.kleientertainment.com/forums/topic/39840-help-special-powers/#findComment-527366 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