Ah; I had hit one too low in the method stack it seems
😉 So, I think just moving my logic up to add_state is the right fix and essentially what I think I meant to do the first time. Also, I made it usable without scripting. If you define a state that is this 'survive an attack' thing and then put it's id in @@catLivesStateId, it should allow you to give this resistance using the normal addState stuff. It might even work for enemies, although (TBH) I didn't try that.
So, try this:
Ruby:
class Game_Battler
attr_accessor :catLives
@@catLivesStateId = 27
def hasCatLives?
return state?(@@catLivesStateId)
end
alias :mrCatLives_addState :add_state
def add_state(state_id)
if state_id == death_state_id && hasCatLives?
@catLives -= 1
revive()
remove_state(@@catLivesStateId) if @catLives <= 0
else
if state_id == @@catLivesStateId
@catLives = 0 if @catLives == nil
@catLives += 1
end
mrCatLives_addState(state_id)
end
end
alias :mrCatLives_eraseState :erase_state
def erase_state(state_id)
@catLives = 0 if state_id == @@catLivesStateId
mrCatLives_eraseState(state_id)
end
end
And then my test event looks like this:
The point being 'CATLIVES' is state 27, in my test, and I add it twice. So, Selenia survives two attacks, then dies on the third. I think that it's fairly easy to get states to be applied as a result of items or attacks or skills or whatever, so that's probably a good UX?
Also note that removing the state will remove ALL cat lives, not just one. I think that's probably fine; if you want to remove just one, deal a ton of damage, I suppose
😉
Anyway, lemme know how it works!