Jump to content

Help Special Powers


ooitsme

Recommended Posts

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

Just look at her prefab file.

These are what you need:

As part of the prefab/custom_char.lua...

In your main function

inst:ListenForEvent("entity_death", function(wrld, data) onkill(inst, data) end, GetWorld())

Leech code

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	endend
Link to comment
Share on other sites

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

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

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.

×
  • Create New...