Browse Source

Final CombatManager

combat-2
MagicBot 8 months ago
parent
commit
0fa042cece
  1. 5
      src/engine/gameManager/CombatManager.java
  2. 4
      src/engine/jobs/AttackJob.java
  3. 18
      src/engine/mobileAI/MobAI.java
  4. 4
      src/engine/net/client/ClientMessagePump.java
  5. 13
      src/engine/net/client/handlers/AttackCmdMsgHandler.java
  6. 10
      src/engine/objects/AbstractCharacter.java
  7. 4
      src/engine/powers/poweractions/StealPowerAction.java

5
src/engine/gameManager/FinalCombatManager.java → src/engine/gameManager/CombatManager.java

@ -19,7 +19,10 @@ import java.util.EnumSet; @@ -19,7 +19,10 @@ import java.util.EnumSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom;
public class FinalCombatManager {
public enum CombatManager {
COMBAT_MANAGER;
public static void combatCycle(AbstractCharacter attacker, AbstractWorldObject target) {
//early exit checks

4
src/engine/jobs/AttackJob.java

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
package engine.jobs;
import engine.gameManager.FinalCombatManager;
import engine.gameManager.CombatManager;
import engine.job.AbstractJob;
import engine.objects.AbstractCharacter;
@ -28,7 +28,7 @@ public class AttackJob extends AbstractJob { @@ -28,7 +28,7 @@ public class AttackJob extends AbstractJob {
@Override
protected void doJob() {
FinalCombatManager.combatCycle(this.source,this.source.combatTarget);
CombatManager.combatCycle(this.source, this.source.combatTarget);
}
public boolean success() {

18
src/engine/mobileAI/MobAI.java

@ -125,7 +125,7 @@ public class MobAI { @@ -125,7 +125,7 @@ public class MobAI {
ItemBase offHand = mob.getWeaponItemBase(false);
if (mainHand == null && offHand == null) {
FinalCombatManager.combatCycle(mob, target);
CombatManager.combatCycle(mob, target);
int delay = 3000;
if (mob.isSiege())
delay = 11000;
@ -134,13 +134,13 @@ public class MobAI { @@ -134,13 +134,13 @@ public class MobAI {
int delay = 3000;
if (mob.isSiege())
delay = 11000;
FinalCombatManager.combatCycle(mob, target);
CombatManager.combatCycle(mob, target);
mob.setLastAttackTime(System.currentTimeMillis() + delay);
} else if (mob.getWeaponItemBase(false) != null) {
int attackDelay = 3000;
if (mob.isSiege())
attackDelay = 11000;
FinalCombatManager.combatCycle(mob, target);
CombatManager.combatCycle(mob, target);
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
}
}
@ -179,7 +179,7 @@ public class MobAI { @@ -179,7 +179,7 @@ public class MobAI {
ItemBase offHand = mob.getWeaponItemBase(false);
if (mainHand == null && offHand == null) {
FinalCombatManager.combatCycle(mob, target);
CombatManager.combatCycle(mob, target);
int delay = 3000;
if (mob.isSiege())
delay = 15000;
@ -188,13 +188,13 @@ public class MobAI { @@ -188,13 +188,13 @@ public class MobAI {
int attackDelay = 3000;
if (mob.isSiege())
attackDelay = 15000;
FinalCombatManager.combatCycle(mob, target);
CombatManager.combatCycle(mob, target);
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
} else if (mob.getWeaponItemBase(false) != null) {
int attackDelay = 3000;
if (mob.isSiege())
attackDelay = 15000;
FinalCombatManager.combatCycle(mob, target);
CombatManager.combatCycle(mob, target);
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
}
@ -222,7 +222,7 @@ public class MobAI { @@ -222,7 +222,7 @@ public class MobAI {
ItemBase offHand = mob.getWeaponItemBase(false);
if (mainHand == null && offHand == null) {
FinalCombatManager.combatCycle(mob, target);
CombatManager.combatCycle(mob, target);
int delay = 3000;
if (mob.isSiege())
delay = 11000;
@ -231,13 +231,13 @@ public class MobAI { @@ -231,13 +231,13 @@ public class MobAI {
int attackDelay = 3000;
if (mob.isSiege())
attackDelay = 11000;
FinalCombatManager.combatCycle(mob, target);
CombatManager.combatCycle(mob, target);
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
} else if (mob.getWeaponItemBase(false) != null) {
int attackDelay = 3000;
if (mob.isSiege())
attackDelay = 11000;
FinalCombatManager.combatCycle(mob, target);
CombatManager.combatCycle(mob, target);
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
if (target.getCombatTarget() == null) {
target.setCombatTarget(mob);

4
src/engine/net/client/ClientMessagePump.java

@ -1445,10 +1445,10 @@ public class ClientMessagePump implements NetMsgHandler { @@ -1445,10 +1445,10 @@ public class ClientMessagePump implements NetMsgHandler {
social((SocialMsg) msg, origin);
break;
case COMBATMODE:
FinalCombatManager.toggleCombat(((ToggleCombatMsg) msg).toggleCombat(),origin);
CombatManager.toggleCombat(((ToggleCombatMsg) msg).toggleCombat(), origin);
break;
case ARCCOMBATMODEATTACKING:
FinalCombatManager.toggleCombat(((SetCombatModeMsg) msg).getToggle(),origin);
CombatManager.toggleCombat(((SetCombatModeMsg) msg).getToggle(), origin);
break;
case MODIFYGUILDSTATE:
ToggleLfgRecruitingMsg tlrm = (ToggleLfgRecruitingMsg) msg;

13
src/engine/net/client/handlers/AttackCmdMsgHandler.java

@ -3,12 +3,15 @@ package engine.net.client.handlers; @@ -3,12 +3,15 @@ package engine.net.client.handlers;
import engine.Enum;
import engine.exception.MsgSendException;
import engine.gameManager.BuildingManager;
import engine.gameManager.FinalCombatManager;
import engine.gameManager.CombatManager;
import engine.net.client.ClientConnection;
import engine.net.client.msg.AttackCmdMsg;
import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.TargetedActionMsg;
import engine.objects.*;
import engine.objects.AbstractWorldObject;
import engine.objects.Mob;
import engine.objects.NPC;
import engine.objects.PlayerCharacter;
/*
* @Author:
@ -72,14 +75,14 @@ public class AttackCmdMsgHandler extends AbstractClientMsgHandler { @@ -72,14 +75,14 @@ public class AttackCmdMsgHandler extends AbstractClientMsgHandler {
if (!playerCharacter.isCombat()) {
//CombatManager.toggleCombat(true, origin);
FinalCombatManager.toggleCombat(true,origin);
CombatManager.toggleCombat(true, origin);
}
//make character stand if sitting
if (playerCharacter.isSit())
FinalCombatManager.toggleSit(false, origin);
CombatManager.toggleSit(false, origin);
FinalCombatManager.combatCycle(playerCharacter,target);
CombatManager.combatCycle(playerCharacter, target);
return true;
}

10
src/engine/objects/AbstractCharacter.java

@ -1328,7 +1328,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -1328,7 +1328,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
//TODO why is Handle REtaliate and cancelontakedamage in modifyHealth? shouldnt this be outside this method?
if (value < 0f && !fromCost) {
this.cancelOnTakeDamage();
FinalCombatManager.handleRetaliate(this, attacker);
CombatManager.handleRetaliate(this, attacker);
}
if(this.getObjectType().equals(GameObjectType.Mob)){
@ -1395,7 +1395,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -1395,7 +1395,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
}
if (value < 0f && !fromCost) {
this.cancelOnTakeDamage();
FinalCombatManager.handleRetaliate(this, attacker);
CombatManager.handleRetaliate(this, attacker);
}
return newMana - oldMana;
}
@ -1434,7 +1434,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -1434,7 +1434,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
}
if (value < 0f && !fromCost) {
this.cancelOnTakeDamage();
FinalCombatManager.handleRetaliate(this, attacker);
CombatManager.handleRetaliate(this, attacker);
}
return newStamina - oldStamina;
}
@ -1469,7 +1469,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -1469,7 +1469,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
}
if (oldMana > newMana && !fromCost) {
this.cancelOnTakeDamage();
FinalCombatManager.handleRetaliate(this, attacker);
CombatManager.handleRetaliate(this, attacker);
}
return newMana - oldMana;
}
@ -1504,7 +1504,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -1504,7 +1504,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
}
if (oldStamina > newStamina && !fromCost) {
this.cancelOnTakeDamage();
FinalCombatManager.handleRetaliate(this, attacker);
CombatManager.handleRetaliate(this, attacker);
}
return newStamina - oldStamina;

4
src/engine/powers/poweractions/StealPowerAction.java

@ -12,7 +12,7 @@ package engine.powers.poweractions; @@ -12,7 +12,7 @@ package engine.powers.poweractions;
import engine.Enum;
import engine.Enum.ItemType;
import engine.gameManager.ChatManager;
import engine.gameManager.FinalCombatManager;
import engine.gameManager.CombatManager;
import engine.math.Vector3fImmutable;
import engine.net.Dispatch;
import engine.net.DispatchMessage;
@ -132,7 +132,7 @@ public class StealPowerAction extends AbstractPowerAction { @@ -132,7 +132,7 @@ public class StealPowerAction extends AbstractPowerAction {
ownerPC.setLastPlayerAttackTime();
//Handle target attacking back if in combat and has no other target
FinalCombatManager.handleRetaliate(ownerAC, sourcePlayer);
CombatManager.handleRetaliate(ownerAC, sourcePlayer);
} else
return;

Loading…
Cancel
Save