Jump to content

Recommended Posts

Hello, I need a little bit of help R9mG9xk.gif.

So, my character has a dodge power thing & when he dodges he becomes invincible for as long as his dodging but the problem is while his dodging & his invincible if she's wearing any armor & he gets hit while dodging then the armor takes damage even though he's supposed to be invincible! And that's kinda problem-ish :shock:!

Can someone tell me if there's a way to fix this or is there no way to make armor invincible as well?

Here's the code if you need to see it & if you need my character to help me then please let me know & I will upload as fast as possible R9mG9xk.gif!

local DODGE = GLOBAL.Action()
DODGE.str = "Dodge"
DODGE.id = "DODGE"
DODGE.fn = function(act)
if act.target.components.hunger.current >= 10 and act.target.flawless_mode == nil then
if act.target:HasTag("playerghost") or act.target.components.health:IsDead() or act.target.sg:HasStateTag("giving") or act.target.sg:HasStateTag("playing") 
or act.target.sg:HasStateTag("busy") or act.target.sg:HasStateTag("working") or act.target.sg:HasStateTag("fishing") or act.target.sg:HasStateTag("doing") then
return
end
act.target.sg:GoToState("dodge")
act.target.components.hunger:DoDelta(-10)
act.target.components.health.invincible = true
act.target:DoTaskInTime(0.73, function()
if act.target:HasTag("playerghost")
or act.target.components.health:IsDead()
then
return
end
act.target.components.health.invincible = false
end)
elseif act.target.components.hunger.current <= 9.99
and act.target.components.sanity:IsSane() then
if act.target:HasTag("playerghost")
or act.target.components.health:IsDead()
then
return
end
act.target.components.talker:Say("Ugh...")
elseif act.target.components.hunger.current <= 9.99
and not act.target.components.sanity:IsSane() then
if act.target:HasTag("playerghost")
or act.target.components.health:IsDead()
then
return
end
act.target.components.talker:Say("We NeEd FoOd!!!")
end
end

R9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gifR9mG9xk.gif

Edited by SuperDavid

@SuperDavid Seems like the easiest way to do this is to just override the combat component's GetAttacked function (this would also hand the invincibility for you):

local _GetAttacked = inst.components.combat.GetAttacked
function inst.components.combat:GetAttacked(...)
	if inst.is_dodging then --or however you're saving the dodge state
		return false --false means the damage was "blocked"
	end
	return _GetAttacked(self, ...)
end

You'd put this in the character's master_postinit.

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
×
  • Create New...