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 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 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 Share on other sites More sharing options...
1daBread Posted August 26, 2014 Share Posted August 26, 2014 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 Link to comment 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 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.