From 0d42d02749476e02247fd5b18695ddb0d7d43dee Mon Sep 17 00:00:00 2001 From: Mads Boddum Date: Mon, 3 Oct 2016 13:26:08 +0200 Subject: [PATCH] DeathblowIntent is now only used for deathblow requests --- scripts/commands/generic/cmdCoupDeGrace.js | 2 +- src/intents/combat/DeathblowIntent.java | 11 +---- src/services/combat/CombatManager.java | 47 ++++++++++------------ 3 files changed, 24 insertions(+), 36 deletions(-) diff --git a/scripts/commands/generic/cmdCoupDeGrace.js b/scripts/commands/generic/cmdCoupDeGrace.js index 6a40df04d..58a3d4547 100644 --- a/scripts/commands/generic/cmdCoupDeGrace.js +++ b/scripts/commands/generic/cmdCoupDeGrace.js @@ -1,4 +1,4 @@ function executeCommand(galacticManager, player, target, args) { var DeathblowIntent = Java.type("intents.combat.DeathblowIntent"); - new DeathblowIntent(true, player.getCreatureObject(), target).broadcast(); + new DeathblowIntent(player.getCreatureObject(), target).broadcast(); } \ No newline at end of file diff --git a/src/intents/combat/DeathblowIntent.java b/src/intents/combat/DeathblowIntent.java index 688cca193..b8e317530 100644 --- a/src/intents/combat/DeathblowIntent.java +++ b/src/intents/combat/DeathblowIntent.java @@ -34,28 +34,19 @@ public class DeathblowIntent extends Intent { public static final String TYPE = "DeathblowIntent"; - private final boolean request; private final CreatureObject killerCreature; private final CreatureObject killedCreature; /** - * - * @param request is {@code true} if a deathblow is being requested and - * {@code false} if the deathblow has happened * @param killerCreature {@code CreatureObject} that's deathblowing * @param killedCreature {@code CreatureObject} that's being deathblown */ - public DeathblowIntent(boolean request, CreatureObject killerCreature, CreatureObject killedCreature) { + public DeathblowIntent(CreatureObject killerCreature, CreatureObject killedCreature) { super(TYPE); - this.request = request; this.killerCreature = killerCreature; this.killedCreature = killedCreature; } - public boolean isRequest() { - return request; - } - public CreatureObject getKillerCreature() { return killerCreature; } diff --git a/src/services/combat/CombatManager.java b/src/services/combat/CombatManager.java index 15b882636..a682b3124 100644 --- a/src/services/combat/CombatManager.java +++ b/src/services/combat/CombatManager.java @@ -383,36 +383,33 @@ public class CombatManager extends Manager { } private void procesDeathblow(DeathblowIntent i) { - if(i.isRequest()) { - CreatureObject killerCreature = i.getKillerCreature(); - CreatureObject killedCreature = i.getKilledCreature(); - - // Only players may deathblow eachother - if(killerCreature.isPlayer() && killedCreature.isPlayer()) { - // They must be enemies - if(killedCreature.isEnemy(killerCreature)) { - // The target of the deathblow must be incapacitated! - if(killedCreature.getPosture() == Posture.INCAPACITATED) { - // If this happens, they obviously can't get back up - synchronized (incapacitatedCreatures) { - Future incapacitationTimer = incapacitatedCreatures.remove(killedCreature); - - if(incapacitationTimer != null) { - if(incapacitationTimer.cancel(false)) { // If the task is running, let them get back up - killCreature(killerCreature, killedCreature); - new DeathblowIntent(false, killerCreature, killedCreature).broadcast(); - Log.i(this, "%s was deathblown by %s", killedCreature, killerCreature); - } - } else { - // Can't happen with the current code, but in case it's ever refactored... - Log.e(this, "Incapacitation timer for player %s being deathblown unexpectedly didn't exist!", ""); + CreatureObject killerCreature = i.getKillerCreature(); + CreatureObject killedCreature = i.getKilledCreature(); + + // Only players may deathblow eachother + if (killerCreature.isPlayer() && killedCreature.isPlayer()) { + // They must be enemies + if (killedCreature.isEnemy(killerCreature)) { + // The target of the deathblow must be incapacitated! + if (killedCreature.getPosture() == Posture.INCAPACITATED) { + // If this happens, they obviously can't get back up + synchronized (incapacitatedCreatures) { + Future incapacitationTimer = incapacitatedCreatures.remove(killedCreature); + + if (incapacitationTimer != null) { + if (incapacitationTimer.cancel(false)) { // If the task is running, let them get back up + killCreature(killerCreature, killedCreature); + Log.i(this, "%s was deathblown by %s", killedCreature, killerCreature); } + } else { + // Can't happen with the current code, but in case it's ever refactored... + Log.e(this, "Incapacitation timer for player %s being deathblown unexpectedly didn't exist!", ""); } } } - } else { - Log.i(this, "%s tried to deathblow NPC %s", killerCreature, killedCreature); } + } else { + Log.i(this, "%s tried to deathblow NPC %s", killerCreature, killedCreature); } }