Page 1 of 1

Problem with superloading damage_types.lua

Posted: Tue Oct 22, 2013 1:33 pm
by MisiuPysiu
Hey,

I'm working on my first addon ever.
At one point i have to superload the damage_types.lua file to get an effect similar to elemental_harmony (when damaged, get a buff)

Code: Select all

local _M                    = loadPrevious(...)

local base_setDefaultProjector = _M.setDefaultProjector

function _M:setDefaultProjector(src, x, y, type, dam, tmp, no_martyr)
-- Do stuff "before" loading the original file
    base_setDefaultProjector(self, src, x, y, type, dam, tmp, no_martyr)
-- Do stuff "after" loading the original file
	if not target.dead and dam > 0 and target:attr("might_in_pain") and not target:hasEffect(target.EFF_MIGHT_IN_PAIN) and type == "BLEED"
	then
	target:setEffect(target.EFF_MIGHT_IN_PAIN, target:callTalent(target.T_MIGHT_IN_PAIN, "getDuration"), {power=target:attr("might_in_pain"), type=type, no_ct_effect=true})			
	end

--  	if not target.dead and dam > 0  then
	--	target:setEffect(target.EFF_MIGHT_IN_PAIN, target:callTalent(target.T_MIGHT_IN_PAIN, "getDuration"), {power=target:attr("might_in_pain"), type=type, no_ct_effect=true})	
--		target:setEffect(target.EFF_CUT, 5, power=1000)	
--	end

end

return _M
sadly the code doesn't seem to be working, in fact it doesn't seem to be run at all. I tried the commented code (get a big CUT effect after beeing damaged) and it never went off.

I'm grateful for every suggestion.

Cheers.

Re: Problem with superloading damage_types.lua

Posted: Tue Oct 22, 2013 5:56 pm
by darkgod
Dont superload it :)

Just make a nwe file in your data folder and load it in your ToME:load hook like that:

Code: Select all

	local DamageType = require "engine.DamageType"
	DamageType:loadDefinition("/data-myaddon/damage_types.lua")

Re: Problem with superloading damage_types.lua

Posted: Tue Oct 22, 2013 6:48 pm
by MisiuPysiu
yeah,

I did eventually use the hook for setDefaultProjector and it worked very nice:)
The code still throws a heap of errors but its only a matter of time when this is fixed.

Cheers:)