forked from MagicBane/Server
Merge remote-tracking branch 'origin/mobile-effects' into magicbox-1.5.2
This commit is contained in:
@@ -1268,61 +1268,69 @@ public enum CombatManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Called when character takes damage.
|
//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;
|
return;
|
||||||
|
|
||||||
if (ac.equals(tarAc))
|
if (attacker.equals(target))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (tarAc.isMoving() && tarAc.getObjectType().equals(GameObjectType.PlayerCharacter))
|
if (target.isMoving() && target.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!tarAc.isAlive() || !ac.isAlive())
|
if (!target.isAlive() || !attacker.isAlive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
boolean isCombat = tarAc.isCombat();
|
boolean isCombat = target.isCombat();
|
||||||
|
|
||||||
//If target in combat and has no target, then attack back
|
//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 ((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 (tarAc.getObjectType().equals(GameObjectType.PlayerCharacter)) { // we are in combat with no valid target
|
if (target.getObjectType().equals(GameObjectType.PlayerCharacter)) { // we are in combat with no valid target
|
||||||
|
|
||||||
PlayerCharacter pc = (PlayerCharacter) tarAc;
|
PlayerCharacter pc = (PlayerCharacter) target;
|
||||||
tarAc.setCombatTarget(ac);
|
target.setCombatTarget(attacker);
|
||||||
pc.setLastTarget(ac.getObjectType(), ac.getObjectUUID());
|
pc.setLastTarget(attacker.getObjectType(), attacker.getObjectUUID());
|
||||||
|
|
||||||
if (tarAc.getTimers() != null)
|
if (target.getTimers() != null)
|
||||||
if (!tarAc.getTimers().containsKey("Attack" + MBServerStatics.SLOT_MAINHAND))
|
if (!target.getTimers().containsKey("Attack" + MBServerStatics.SLOT_MAINHAND))
|
||||||
CombatManager.AttackTarget((PlayerCharacter) tarAc, tarAc.getCombatTarget());
|
CombatManager.AttackTarget((PlayerCharacter) target, target.getCombatTarget());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handle pet retaliate if assist is on and pet doesn't have a target.
|
//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)
|
if (pet != null && pet.assist && pet.getCombatTarget() == null)
|
||||||
pet.setCombatTarget(ac);
|
pet.setCombatTarget(attacker);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handle Mob Retaliate.
|
//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())
|
if (retaliater.getCombatTarget() != null && !retaliater.isSiege())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ac.getObjectType() == GameObjectType.Mob && retaliater.isSiege())
|
if (attacker.getObjectType() == GameObjectType.Mob && retaliater.isSiege())
|
||||||
return;
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ public enum NPCManager {
|
|||||||
mob.patrolPoints.add(newPatrolPoint);
|
mob.patrolPoints.add(newPatrolPoint);
|
||||||
|
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
mob.loc = newPatrolPoint;
|
mob.setLoc(newPatrolPoint);
|
||||||
mob.endLoc = newPatrolPoint;
|
mob.endLoc = newPatrolPoint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1124,7 +1124,10 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.combatTarget = value;
|
this.combatTarget = value;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentHashMap<String, JobContainer> getTimers() {
|
public final ConcurrentHashMap<String, JobContainer> getTimers() {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import engine.jobs.DeferredPowerJob;
|
|||||||
import engine.jobs.UpgradeNPCJob;
|
import engine.jobs.UpgradeNPCJob;
|
||||||
import engine.math.Bounds;
|
import engine.math.Bounds;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
|
import engine.mobileAI.utilities.MovementUtilities;
|
||||||
import engine.net.ByteBufferWriter;
|
import engine.net.ByteBufferWriter;
|
||||||
import engine.net.Dispatch;
|
import engine.net.Dispatch;
|
||||||
import engine.net.DispatchMessage;
|
import engine.net.DispatchMessage;
|
||||||
@@ -427,6 +428,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
else
|
else
|
||||||
mobile.contractUUID = contract.getContractID();
|
mobile.contractUUID = contract.getContractID();
|
||||||
|
|
||||||
|
|
||||||
return mobile;
|
return mobile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1117,6 +1119,26 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
this.defenseRating = 0;
|
this.defenseRating = 0;
|
||||||
return;
|
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 {
|
try {
|
||||||
calculateAtrDamageForWeapon(this.equip.get(MBServerStatics.SLOT_MAINHAND), true);
|
calculateAtrDamageForWeapon(this.equip.get(MBServerStatics.SLOT_MAINHAND), true);
|
||||||
@@ -1656,6 +1678,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
}
|
}
|
||||||
NPCManager.applyMobbaseEffects(this);
|
NPCManager.applyMobbaseEffects(this);
|
||||||
NPCManager.applyEquipmentResists(this);
|
NPCManager.applyEquipmentResists(this);
|
||||||
|
NPCManager.applyMobbaseSkill(this);
|
||||||
this.recalculateStats();
|
this.recalculateStats();
|
||||||
this.setHealth(this.healthMax);
|
this.setHealth(this.healthMax);
|
||||||
|
|
||||||
@@ -1670,6 +1693,16 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
if (this.agentType.equals(AIAgentType.MOBILE))
|
if (this.agentType.equals(AIAgentType.MOBILE))
|
||||||
NPCManager.AssignPatrolPoints(this);
|
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;
|
this.deathTime = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ public class MobBaseStats {
|
|||||||
private final int baseSpi;
|
private final int baseSpi;
|
||||||
private final int baseDex;
|
private final int baseDex;
|
||||||
|
|
||||||
|
private final int mobbaseSkill;
|
||||||
|
private final int mobbaseSkillAmount;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ResultSet Constructor
|
* ResultSet Constructor
|
||||||
@@ -31,6 +34,8 @@ public class MobBaseStats {
|
|||||||
this.baseCon = rs.getInt("Constitution");
|
this.baseCon = rs.getInt("Constitution");
|
||||||
this.baseSpi = rs.getInt("Spirit");
|
this.baseSpi = rs.getInt("Spirit");
|
||||||
this.baseDex = rs.getInt("Dexterity");
|
this.baseDex = rs.getInt("Dexterity");
|
||||||
|
this.mobbaseSkill = rs.getInt("baseSkills");
|
||||||
|
this.mobbaseSkillAmount = rs.getInt("skillAmount");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,6 +48,8 @@ public class MobBaseStats {
|
|||||||
this.baseCon = 0;
|
this.baseCon = 0;
|
||||||
this.baseSpi = 0;
|
this.baseSpi = 0;
|
||||||
this.baseDex = 0;
|
this.baseDex = 0;
|
||||||
|
this.mobbaseSkill = 0;
|
||||||
|
this.mobbaseSkillAmount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MobBaseStats GetGenericStats() {
|
public static MobBaseStats GetGenericStats() {
|
||||||
@@ -72,5 +79,8 @@ public class MobBaseStats {
|
|||||||
return baseDex;
|
return baseDex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getBaseSkill(){return mobbaseSkill;}
|
||||||
|
|
||||||
|
public int getBaseSkillAmount(){return mobbaseSkillAmount;}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user