Browse Source

Merge remote-tracking branch 'origin/mobile-effects' into magicbox-1.5.2

combat-2
MagicBot 1 year ago
parent
commit
90cbe90492
  1. 52
      src/engine/gameManager/CombatManager.java
  2. 8
      src/engine/gameManager/NPCManager.java
  3. 3
      src/engine/objects/AbstractCharacter.java
  4. 33
      src/engine/objects/Mob.java
  5. 10
      src/engine/objects/MobBaseStats.java

52
src/engine/gameManager/CombatManager.java

@ -1268,61 +1268,69 @@ public enum CombatManager { @@ -1268,61 +1268,69 @@ public enum CombatManager {
}
//Called when character takes damage.
public static void handleRetaliate(AbstractCharacter tarAc, AbstractCharacter ac) {
public static void handleRetaliate(AbstractCharacter target, AbstractCharacter attacker) {
if (ac == null || tarAc == null)
if (attacker == null || target == null)
return;
if (ac.equals(tarAc))
if (attacker.equals(target))
return;
if (tarAc.isMoving() && tarAc.getObjectType().equals(GameObjectType.PlayerCharacter))
if (target.isMoving() && target.getObjectType().equals(GameObjectType.PlayerCharacter))
return;
if (!tarAc.isAlive() || !ac.isAlive())
if (!target.isAlive() || !attacker.isAlive())
return;
boolean isCombat = tarAc.isCombat();
boolean isCombat = target.isCombat();
//If target in combat and has no target, then attack back
AbstractWorldObject awoCombTar = tarAc.getCombatTarget();
AbstractWorldObject awoCombTar = target.getCombatTarget();
if ((tarAc.isCombat() && awoCombTar == null) || (isCombat && awoCombTar != null && (!awoCombTar.isAlive() || tarAc.isCombat() && NotInRange(tarAc, awoCombTar, tarAc.getRange()))) || (tarAc != null && tarAc.getObjectType() == GameObjectType.Mob && ((Mob) tarAc).isSiege()))
if (tarAc.getObjectType().equals(GameObjectType.PlayerCharacter)) { // we are in combat with no valid target
if ((target.isCombat() && awoCombTar == null) || (isCombat && awoCombTar != null && (!awoCombTar.isAlive() || target.isCombat() && NotInRange(target, awoCombTar, target.getRange()))) || (target != null && target.getObjectType() == GameObjectType.Mob && ((Mob) target).isSiege()))
if (target.getObjectType().equals(GameObjectType.PlayerCharacter)) { // we are in combat with no valid target
PlayerCharacter pc = (PlayerCharacter) tarAc;
tarAc.setCombatTarget(ac);
pc.setLastTarget(ac.getObjectType(), ac.getObjectUUID());
PlayerCharacter pc = (PlayerCharacter) target;
target.setCombatTarget(attacker);
pc.setLastTarget(attacker.getObjectType(), attacker.getObjectUUID());
if (tarAc.getTimers() != null)
if (!tarAc.getTimers().containsKey("Attack" + MBServerStatics.SLOT_MAINHAND))
CombatManager.AttackTarget((PlayerCharacter) tarAc, tarAc.getCombatTarget());
if (target.getTimers() != null)
if (!target.getTimers().containsKey("Attack" + MBServerStatics.SLOT_MAINHAND))
CombatManager.AttackTarget((PlayerCharacter) target, target.getCombatTarget());
}
//Handle pet retaliate if assist is on and pet doesn't have a target.
if (tarAc.getObjectType().equals(GameObjectType.PlayerCharacter)) {
if (target.getObjectType().equals(GameObjectType.PlayerCharacter)) {
Mob pet = ((PlayerCharacter) tarAc).getPet();
Mob pet = ((PlayerCharacter) target).getPet();
if (pet != null && pet.assist && pet.getCombatTarget() == null)
pet.setCombatTarget(ac);
pet.setCombatTarget(attacker);
}
//Handle Mob Retaliate.
if (tarAc.getObjectType() == GameObjectType.Mob) {
if (target.getObjectType() == GameObjectType.Mob) {
Mob retaliater = (Mob) tarAc;
Mob retaliater = (Mob) target;
if (retaliater.getCombatTarget() != null && !retaliater.isSiege())
return;
if (ac.getObjectType() == GameObjectType.Mob && retaliater.isSiege())
if (attacker.getObjectType() == GameObjectType.Mob && retaliater.isSiege())
return;
retaliater.setCombatTarget(ac);
//handle minion informing his captain of the attack
if(attacker.getObjectType().equals(GameObjectType.Mob)){
Mob mob = (Mob)attacker;
if(mob.agentType.equals(AIAgentType.GUARDMINION) && mob.guardCaptain != null && mob.guardCaptain.isAlive())
if(mob.guardCaptain.combatTarget == null)
mob.guardCaptain.combatTarget = attacker;
}
retaliater.setCombatTarget(attacker);
}
}

8
src/engine/gameManager/NPCManager.java

@ -341,7 +341,7 @@ public enum NPCManager { @@ -341,7 +341,7 @@ public enum NPCManager {
mob.patrolPoints.add(newPatrolPoint);
if (i == 1) {
mob.loc = newPatrolPoint;
mob.setLoc(newPatrolPoint);
mob.endLoc = newPatrolPoint;
}
}
@ -399,4 +399,10 @@ public enum NPCManager { @@ -399,4 +399,10 @@ public enum NPCManager {
}
}
}
public static void applyMobbaseSkill(Mob mob) {
SkillsBase baseSkill = DbManager.SkillsBaseQueries.GET_BASE_BY_TOKEN(mob.mobBase.getMobBaseStats().getBaseSkill());
if(baseSkill != null)
mob.getSkills().put(baseSkill.getName(),new CharacterSkill(baseSkill,mob,mob.mobBase.getMobBaseStats().getBaseSkillAmount()));
}
}

3
src/engine/objects/AbstractCharacter.java

@ -1124,7 +1124,10 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -1124,7 +1124,10 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
}
}
}
this.combatTarget = value;
}
public final ConcurrentHashMap<String, JobContainer> getTimers() {

33
src/engine/objects/Mob.java

@ -20,6 +20,7 @@ import engine.jobs.DeferredPowerJob; @@ -20,6 +20,7 @@ import engine.jobs.DeferredPowerJob;
import engine.jobs.UpgradeNPCJob;
import engine.math.Bounds;
import engine.math.Vector3fImmutable;
import engine.mobileAI.utilities.MovementUtilities;
import engine.net.ByteBufferWriter;
import engine.net.Dispatch;
import engine.net.DispatchMessage;
@ -427,6 +428,7 @@ public class Mob extends AbstractIntelligenceAgent { @@ -427,6 +428,7 @@ public class Mob extends AbstractIntelligenceAgent {
else
mobile.contractUUID = contract.getContractID();
return mobile;
}
@ -1117,6 +1119,26 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1117,6 +1119,26 @@ public class Mob extends AbstractIntelligenceAgent {
this.defenseRating = 0;
return;
}
this.atrHandOne = (short) this.mobBase.getAttackRating();
this.minDamageHandOne = (short) this.mobBase.getMinDmg();
this.maxDamageHandOne = (short) this.mobBase.getMaxDmg();
this.rangeHandOne = 6.5f;
this.speedHandOne = 20;
this.atrHandTwo = (short) this.mobBase.getAttackRating();
this.minDamageHandTwo = (short) this.mobBase.getMinDmg();
this.maxDamageHandTwo = (short) this.mobBase.getMaxDmg();
this.rangeHandTwo = 6.5f;
this.speedHandTwo = 20;
if(this.equip.get(MBServerStatics.SLOT_MAINHAND) != null){
//has mainhand weapon to calculate
calculateAtrDamageForWeapon(this.equip.get(MBServerStatics.SLOT_MAINHAND), true);
}
if(this.equip.get(MBServerStatics.SLOT_OFFHAND) != null && !this.equip.get(MBServerStatics.SLOT_OFFHAND).getItemBase().isShield()){
//has offhand weapon to calculate
calculateAtrDamageForWeapon(this.equip.get(MBServerStatics.SLOT_OFFHAND), false);
}
try {
calculateAtrDamageForWeapon(this.equip.get(MBServerStatics.SLOT_MAINHAND), true);
@ -1656,6 +1678,7 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1656,6 +1678,7 @@ public class Mob extends AbstractIntelligenceAgent {
}
NPCManager.applyMobbaseEffects(this);
NPCManager.applyEquipmentResists(this);
NPCManager.applyMobbaseSkill(this);
this.recalculateStats();
this.setHealth(this.healthMax);
@ -1670,6 +1693,16 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1670,6 +1693,16 @@ public class Mob extends AbstractIntelligenceAgent {
if (this.agentType.equals(AIAgentType.MOBILE))
NPCManager.AssignPatrolPoints(this);
if (this.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN)) {
Building barracks = this.building;
if (barracks != null && barracks.patrolPoints != null && !barracks.getPatrolPoints().isEmpty()) {
this.patrolPoints = barracks.patrolPoints;
MovementUtilities.aiMove(this, this.patrolPoints.get(0), true);
}
}
this.deathTime = 0;
}

10
src/engine/objects/MobBaseStats.java

@ -21,6 +21,9 @@ public class MobBaseStats { @@ -21,6 +21,9 @@ public class MobBaseStats {
private final int baseSpi;
private final int baseDex;
private final int mobbaseSkill;
private final int mobbaseSkillAmount;
/**
* ResultSet Constructor
@ -31,6 +34,8 @@ public class MobBaseStats { @@ -31,6 +34,8 @@ public class MobBaseStats {
this.baseCon = rs.getInt("Constitution");
this.baseSpi = rs.getInt("Spirit");
this.baseDex = rs.getInt("Dexterity");
this.mobbaseSkill = rs.getInt("baseSkills");
this.mobbaseSkillAmount = rs.getInt("skillAmount");
}
/**
@ -43,6 +48,8 @@ public class MobBaseStats { @@ -43,6 +48,8 @@ public class MobBaseStats {
this.baseCon = 0;
this.baseSpi = 0;
this.baseDex = 0;
this.mobbaseSkill = 0;
this.mobbaseSkillAmount = 0;
}
public static MobBaseStats GetGenericStats() {
@ -72,5 +79,8 @@ public class MobBaseStats { @@ -72,5 +79,8 @@ public class MobBaseStats {
return baseDex;
}
public int getBaseSkill(){return mobbaseSkill;}
public int getBaseSkillAmount(){return mobbaseSkillAmount;}
}

Loading…
Cancel
Save