How would I go about making a skill that blocks enemy damage for the next turn or deflects it in the turn-based combat system?
How to create a block/deflect skill?
Answers
That's a bit tricky, but here how you could do : create a status "Guard". Make this status "Release at the start of turn >= 1 , 100% chance. (if only at one hit, Release with 100% chance after being attacked) . Then your skill should add target "user" and effect "add status guard".
For blocking damage, for all the skills with damage on HP formula, use for example :
t.hasStatus(12) ? 0 : (u.atk - t.def)
Replace 12 by the ID of Guard status, and u.atk - t.def by the initial formula you wanted to use. The formula means: if target has Guard status: 0 damage, else damages.
To deflect, use option Temporarily change target on all your skills:
Scene.Map.current.targets.map(b => b.player.hasStatus(12) ? Scene.Map.current.user : b)
Replace 12 by the ID of Guard status. It means: replace target by user of skill if one target has status guard.