Improved teleblock condition checking

This commit is contained in:
Ceikry
2023-08-20 02:27:21 +00:00
committed by Ryan
parent 5cb9ef8511
commit e424478a1c
@@ -91,7 +91,7 @@ public final class TeleblockSpell extends CombatSpell {
entity.asPlayer().sendMessage("You and your opponent must both be in the wilderness for you to use this spell."); entity.asPlayer().sendMessage("You and your opponent must both be in the wilderness for you to use this spell.");
return false; return false;
} }
if (((Player) target).isTeleBlocked()) { if (hasTimerActive(target.asPlayer(), "teleblock")) {
entity.asPlayer().sendMessage("That player is already affected by this spell."); entity.asPlayer().sendMessage("That player is already affected by this spell.");
return false; return false;
} }
@@ -113,13 +113,13 @@ public final class TeleblockSpell extends CombatSpell {
@Override @Override
public void fireEffect(Entity entity, Entity victim, BattleState state) { public void fireEffect(Entity entity, Entity victim, BattleState state) {
if(!victim.isTeleBlocked() && victim instanceof Player && state.getStyle().getSwingHandler().isAccurateImpact(entity, victim)){ if(!hasTimerActive(victim, "teleblock") && victim instanceof Player && state.getStyle().getSwingHandler().isAccurateImpact(entity, victim)){
int ticks = 500; int ticks = 500;
if(((Player) victim).getPrayer().get(PrayerType.PROTECT_FROM_MAGIC)){ if(((Player) victim).getPrayer().get(PrayerType.PROTECT_FROM_MAGIC)){
ticks /= 2; ticks /= 2;
} }
registerTimer(victim, spawnTimer("teleblock", ticks)); registerTimer(victim, spawnTimer("teleblock", ticks));
} else if(victim.isTeleBlocked()){ } else if(hasTimerActive(victim, "teleblock")){
entity.asPlayer().sendMessage("Your target is already blocked from teleporting."); entity.asPlayer().sendMessage("Your target is already blocked from teleporting.");
} }
} }