Sign in to follow this  
EuedeAdodooedoe

Getting attacker to apply damage to?

Recommended Posts

EuedeAdodooedoe    1187

Trying to set it up so that the damage that Bernie gets from shadow creatures is also applied to shadow creatures themselves. And, subsequently so that they would also teleport within a radius of Bernie upon attacking him, just like they do when a player attacks them.

I've looked through many OnBlocked functions, from scalemail, to cactus picking to even single player's SW cactus armor damage, but NOTHING works! This is my final code that I've come down to:

local function OnAttacked(inst, data)
    if data.attacker ~= nil and data.attacker.components.combat and data.attacker:HasTag("shadow") then
        data.attacker.components.combat:GetAttacked(inst, data.attacker.components.damage)
        --data.attacker.components.health:DoDelta(data.attacker.components.damage)
        data.attacker.components.combat:SetTarget(data.attacker)
        data.attacker.components.combat:ShareTarget(data.attacker, 30, ShareTargetFn, 1)
    end
end

And it doesn't work. Does anybody have any idea as to why and how I could fix it? Mind you, I'm still using that "make a copy of an original file into the mod and edit it" strat, so this code is placed within berniebrain.lua.

Share this post


Link to post
Share on other sites
EuedeAdodooedoe    1187

FIXED:

1) Had to put the code in bernie_active.lua and not berniebrain.lua

2) Had to add this listener in fn() function:

inst:ListenForEvent("attacked", OnAttacked)

3) Had to add negative "data.damage" or " data.attacker.components.combat.defaultdamage
" instead of data.attacker,components.damage

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this