mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-10-19 09:03:02 -04:00
Simplified deathblow code and renamed fields in DeathblowIntent and CreatureKilledIntent
This commit is contained in:
@@ -34,21 +34,21 @@ public class CreatureKilledIntent extends Intent {
|
||||
|
||||
public static final String TYPE = "CreatureKilledIntent";
|
||||
|
||||
private final CreatureObject killerCreature;
|
||||
private final CreatureObject killedCreature;
|
||||
private final CreatureObject killer;
|
||||
private final CreatureObject corpse;
|
||||
|
||||
public CreatureKilledIntent(CreatureObject killerCreature, CreatureObject killedCreature) {
|
||||
public CreatureKilledIntent(CreatureObject killer, CreatureObject corpse) {
|
||||
super(TYPE);
|
||||
this.killerCreature = killerCreature;
|
||||
this.killedCreature = killedCreature;
|
||||
this.killer = killer;
|
||||
this.corpse = corpse;
|
||||
}
|
||||
|
||||
public CreatureObject getKillerCreature() {
|
||||
return killerCreature;
|
||||
public CreatureObject getKiller() {
|
||||
return killer;
|
||||
}
|
||||
|
||||
public CreatureObject getKilledCreature() {
|
||||
return killedCreature;
|
||||
public CreatureObject getCorpse() {
|
||||
return corpse;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -34,25 +34,25 @@ public class DeathblowIntent extends Intent {
|
||||
|
||||
public static final String TYPE = "DeathblowIntent";
|
||||
|
||||
private final CreatureObject killerCreature;
|
||||
private final CreatureObject killedCreature;
|
||||
private final CreatureObject killer;
|
||||
private final CreatureObject corpse;
|
||||
|
||||
/**
|
||||
* @param killerCreature {@code CreatureObject} that's deathblowing
|
||||
* @param killedCreature {@code CreatureObject} that's being deathblown
|
||||
* @param killer {@code CreatureObject} that's deathblowing
|
||||
* @param corpse {@code CreatureObject} that's being deathblown
|
||||
*/
|
||||
public DeathblowIntent(CreatureObject killerCreature, CreatureObject killedCreature) {
|
||||
public DeathblowIntent(CreatureObject killer, CreatureObject corpse) {
|
||||
super(TYPE);
|
||||
this.killerCreature = killerCreature;
|
||||
this.killedCreature = killedCreature;
|
||||
this.killer = killer;
|
||||
this.corpse = corpse;
|
||||
}
|
||||
|
||||
public CreatureObject getKillerCreature() {
|
||||
return killerCreature;
|
||||
public CreatureObject getKiller() {
|
||||
return killer;
|
||||
}
|
||||
|
||||
public CreatureObject getKilledCreature() {
|
||||
return killedCreature;
|
||||
public CreatureObject getCorpse() {
|
||||
return corpse;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -376,40 +376,44 @@ public class CombatManager extends Manager {
|
||||
Log.i(this, "% was revived", revivedCreature);
|
||||
}
|
||||
|
||||
private void killCreature(CreatureObject killerCreature, CreatureObject killedCreature) {
|
||||
killedCreature.setPosture(Posture.DEAD);
|
||||
Log.i(this, "%s was killed", killedCreature);
|
||||
new CreatureKilledIntent(killerCreature, killedCreature).broadcast();
|
||||
private void killCreature(CreatureObject killer, CreatureObject corpse) {
|
||||
corpse.setPosture(Posture.DEAD);
|
||||
Log.i(this, "%s was killed", corpse);
|
||||
new CreatureKilledIntent(killer, corpse).broadcast();
|
||||
}
|
||||
|
||||
private void procesDeathblow(DeathblowIntent i) {
|
||||
CreatureObject killerCreature = i.getKillerCreature();
|
||||
CreatureObject killedCreature = i.getKilledCreature();
|
||||
CreatureObject killer = i.getKiller();
|
||||
CreatureObject corpse = i.getCorpse();
|
||||
|
||||
// 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);
|
||||
// Only deathblowing players is allowed!
|
||||
if (!corpse.isPlayer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// They must be enemies
|
||||
if (!corpse.isEnemy(killer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The target of the deathblow must be incapacitated!
|
||||
if (corpse.getPosture() != Posture.INCAPACITATED) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If they're deathblown while incapacitated, their incapacitation expiration timer should cancel
|
||||
synchronized (incapacitatedCreatures) {
|
||||
Future<?> incapacitationTimer = incapacitatedCreatures.remove(corpse);
|
||||
|
||||
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!", "");
|
||||
}
|
||||
}
|
||||
if (incapacitationTimer != null) {
|
||||
if (incapacitationTimer.cancel(false)) { // If the task is running, let them get back up
|
||||
killCreature(killer, corpse);
|
||||
Log.i(this, "%s was deathblown by %s", corpse, killer);
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,16 +67,16 @@ public final class CorpseService extends Service {
|
||||
}
|
||||
|
||||
private void handleCreatureKilledIntent(CreatureKilledIntent i) {
|
||||
CreatureObject killedCreature = i.getKilledCreature();
|
||||
CreatureObject corpse = i.getCorpse();
|
||||
|
||||
if(killedCreature.isPlayer()) {
|
||||
if(corpse.isPlayer()) {
|
||||
// TODO show cloning system message
|
||||
// TODO show cloning SUI window, with all possible facilities to clone at
|
||||
// TODO after 30 minutes, close the SUI window and force them to clone at the nearest cloning facility
|
||||
// TODO if the SUI window is closed by the player, make sure it reappears
|
||||
} else {
|
||||
// This is a NPC - schedule corpse for deletion
|
||||
executor.schedule(() -> deleteCorpse(killedCreature), 120, TimeUnit.SECONDS);
|
||||
executor.schedule(() -> deleteCorpse(corpse), 120, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user