forked from MagicBane/Server
Renamed class to not conflict with the java.lang version.
This commit is contained in:
@@ -8,11 +8,11 @@
|
||||
|
||||
package engine.gameManager;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.job.JobContainer;
|
||||
import engine.job.JobScheduler;
|
||||
import engine.jobs.AttackJob;
|
||||
import engine.jobs.DeferredPowerJob;
|
||||
import engine.mbEnums;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.TargetedActionMsg;
|
||||
@@ -46,40 +46,40 @@ public enum CombatManager {
|
||||
case PlayerCharacter:
|
||||
case Mob:
|
||||
PlayerBonuses bonuses = ((AbstractCharacter) target).getBonuses();
|
||||
if (bonuses != null && bonuses.getBool(Enum.ModType.ImmuneToAttack, Enum.SourceType.None))
|
||||
if (bonuses != null && bonuses.getBool(mbEnums.ModType.ImmuneToAttack, mbEnums.SourceType.None))
|
||||
return;
|
||||
break;
|
||||
case NPC:
|
||||
return;
|
||||
}
|
||||
|
||||
Item mainWeapon = attacker.charItemManager.getEquipped().get(Enum.EquipSlotType.RHELD);
|
||||
Item offWeapon = attacker.charItemManager.getEquipped().get(Enum.EquipSlotType.LHELD);
|
||||
Item mainWeapon = attacker.charItemManager.getEquipped().get(mbEnums.EquipSlotType.RHELD);
|
||||
Item offWeapon = attacker.charItemManager.getEquipped().get(mbEnums.EquipSlotType.LHELD);
|
||||
|
||||
if (mainWeapon == null && offWeapon == null) {
|
||||
//no weapons equipped, punch with both fists
|
||||
processAttack(attacker, target, Enum.EquipSlotType.RHELD);
|
||||
processAttack(attacker, target, Enum.EquipSlotType.LHELD);
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD);
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.LHELD);
|
||||
} else if (mainWeapon == null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block")) {
|
||||
//no weapon equipped with a shield, punch with one hand
|
||||
processAttack(attacker, target, Enum.EquipSlotType.RHELD);
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD);
|
||||
} else if (mainWeapon != null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block")) {
|
||||
//one weapon equipped with a shield, swing with one hand
|
||||
processAttack(attacker, target, Enum.EquipSlotType.RHELD);
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD);
|
||||
} else if (mainWeapon != null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block") == false) {
|
||||
//two weapons equipped, swing both hands
|
||||
processAttack(attacker, target, Enum.EquipSlotType.RHELD);
|
||||
processAttack(attacker, target, Enum.EquipSlotType.LHELD);
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD);
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.LHELD);
|
||||
} else if (mainWeapon == null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block") == false) {
|
||||
//swing left hand only
|
||||
processAttack(attacker, target, Enum.EquipSlotType.LHELD);
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.LHELD);
|
||||
} else if (mainWeapon != null && offWeapon == null) {
|
||||
//swing left hand only
|
||||
processAttack(attacker, target, Enum.EquipSlotType.RHELD);
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD);
|
||||
}
|
||||
}
|
||||
|
||||
public static void processAttack(AbstractCharacter attacker, AbstractWorldObject target, Enum.EquipSlotType slot) {
|
||||
public static void processAttack(AbstractCharacter attacker, AbstractWorldObject target, mbEnums.EquipSlotType slot) {
|
||||
|
||||
// heck if character can even attack yet
|
||||
|
||||
@@ -98,12 +98,12 @@ public enum CombatManager {
|
||||
|
||||
if (weapon != null) {
|
||||
if (bonus != null)
|
||||
rangeMod += bonus.getFloatPercentAll(Enum.ModType.WeaponRange, Enum.SourceType.None);
|
||||
rangeMod += bonus.getFloatPercentAll(mbEnums.ModType.WeaponRange, mbEnums.SourceType.None);
|
||||
|
||||
attackRange = weapon.template.item_weapon_max_range * rangeMod;
|
||||
}
|
||||
|
||||
if (attacker.getObjectType().equals(Enum.GameObjectType.Mob))
|
||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob))
|
||||
if (((Mob) attacker).isSiege())
|
||||
attackRange = 300;
|
||||
|
||||
@@ -133,7 +133,7 @@ public enum CombatManager {
|
||||
|
||||
//get the proper stats based on which slot is attacking
|
||||
|
||||
if (slot == Enum.EquipSlotType.LHELD) {
|
||||
if (slot == mbEnums.EquipSlotType.LHELD) {
|
||||
min = attacker.minDamageHandTwo;
|
||||
max = attacker.maxDamageHandTwo;
|
||||
atr = attacker.atrHandTwo;
|
||||
@@ -156,10 +156,10 @@ public enum CombatManager {
|
||||
else
|
||||
hitChance = ((int) (450 * (dif - 0.8f)) + 4);
|
||||
|
||||
if (target.getObjectType() == Enum.GameObjectType.Building)
|
||||
if (target.getObjectType() == mbEnums.GameObjectType.Building)
|
||||
hitChance = 100;
|
||||
|
||||
int passiveAnim = getSwingAnimation(null, null, slot.equals(Enum.EquipSlotType.RHELD));
|
||||
int passiveAnim = getSwingAnimation(null, null, slot.equals(mbEnums.EquipSlotType.RHELD));
|
||||
if (attacker.charItemManager.getEquipped().get(slot) != null) {
|
||||
passiveAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, null, true);
|
||||
}
|
||||
@@ -167,8 +167,8 @@ public enum CombatManager {
|
||||
if (ThreadLocalRandom.current().nextInt(100) > hitChance) {
|
||||
TargetedActionMsg msg = new TargetedActionMsg(attacker, target, 0f, passiveAnim);
|
||||
|
||||
if (target.getObjectType() == Enum.GameObjectType.PlayerCharacter)
|
||||
DispatchMessage.dispatchMsgToInterestArea(target, msg, Enum.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
if (target.getObjectType() == mbEnums.GameObjectType.PlayerCharacter)
|
||||
DispatchMessage.dispatchMsgToInterestArea(target, msg, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
else
|
||||
DispatchMessage.sendToAllInRange(attacker, msg);
|
||||
|
||||
@@ -177,8 +177,8 @@ public enum CombatManager {
|
||||
|
||||
//calculate passive chances only if target is AbstractCharacter
|
||||
|
||||
if (EnumSet.of(Enum.GameObjectType.PlayerCharacter, Enum.GameObjectType.NPC, Enum.GameObjectType.Mob).contains(target.getObjectType())) {
|
||||
Enum.PassiveType passiveType = Enum.PassiveType.None;
|
||||
if (EnumSet.of(mbEnums.GameObjectType.PlayerCharacter, mbEnums.GameObjectType.NPC, mbEnums.GameObjectType.Mob).contains(target.getObjectType())) {
|
||||
mbEnums.PassiveType passiveType = mbEnums.PassiveType.None;
|
||||
int hitRoll = ThreadLocalRandom.current().nextInt(100);
|
||||
|
||||
float dodgeChance = ((AbstractCharacter) target).getPassiveChance("Dodge", attacker.getLevel(), true);
|
||||
@@ -192,18 +192,18 @@ public enum CombatManager {
|
||||
parryChance = Math.max(0, Math.min(75, parryChance));
|
||||
|
||||
if (hitRoll < dodgeChance)
|
||||
passiveType = Enum.PassiveType.Dodge;
|
||||
passiveType = mbEnums.PassiveType.Dodge;
|
||||
else if (hitRoll < blockChance)
|
||||
passiveType = Enum.PassiveType.Block;
|
||||
passiveType = mbEnums.PassiveType.Block;
|
||||
else if (hitRoll < parryChance)
|
||||
passiveType = Enum.PassiveType.Parry;
|
||||
passiveType = mbEnums.PassiveType.Parry;
|
||||
|
||||
|
||||
if (passiveType.equals(Enum.PassiveType.None) == false) {
|
||||
if (passiveType.equals(mbEnums.PassiveType.None) == false) {
|
||||
TargetedActionMsg msg = new TargetedActionMsg(attacker, passiveAnim, target, passiveType.value);
|
||||
|
||||
if (target.getObjectType() == Enum.GameObjectType.PlayerCharacter)
|
||||
DispatchMessage.dispatchMsgToInterestArea(target, msg, Enum.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
if (target.getObjectType() == mbEnums.GameObjectType.PlayerCharacter)
|
||||
DispatchMessage.dispatchMsgToInterestArea(target, msg, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
else
|
||||
DispatchMessage.sendToAllInRange(attacker, msg);
|
||||
|
||||
@@ -218,15 +218,15 @@ public enum CombatManager {
|
||||
|
||||
//get the damage type
|
||||
|
||||
Enum.DamageType damageType;
|
||||
mbEnums.DamageType damageType;
|
||||
|
||||
if (attacker.charItemManager.getEquipped().get(slot) == null) {
|
||||
damageType = Enum.DamageType.CRUSHING;
|
||||
if (attacker.getObjectType().equals(Enum.GameObjectType.Mob))
|
||||
damageType = mbEnums.DamageType.CRUSHING;
|
||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob))
|
||||
if (((Mob) attacker).isSiege())
|
||||
damageType = Enum.DamageType.SIEGE;
|
||||
damageType = mbEnums.DamageType.SIEGE;
|
||||
} else {
|
||||
damageType = (Enum.DamageType) attacker.charItemManager.getEquipped().get(slot).template.item_weapon_damage.keySet().toArray()[0];
|
||||
damageType = (mbEnums.DamageType) attacker.charItemManager.getEquipped().get(slot).template.item_weapon_damage.keySet().toArray()[0];
|
||||
}
|
||||
|
||||
//get resists
|
||||
@@ -298,16 +298,16 @@ public enum CombatManager {
|
||||
else
|
||||
((Building) target).setCurrentHitPoints(target.getCurrentHitpoints() - damage);
|
||||
|
||||
int attackAnim = getSwingAnimation(null, null, slot.equals(Enum.EquipSlotType.RHELD));
|
||||
int attackAnim = getSwingAnimation(null, null, slot.equals(mbEnums.EquipSlotType.RHELD));
|
||||
if (attacker.charItemManager.getEquipped().get(slot) != null) {
|
||||
attackAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, null, slot.equals(Enum.EquipSlotType.RHELD));
|
||||
attackAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, null, slot.equals(mbEnums.EquipSlotType.RHELD));
|
||||
}
|
||||
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) damage, attackAnim);
|
||||
DispatchMessage.sendToAllInRange(target, cmm);
|
||||
}
|
||||
DeferredPowerJob dpj = null;
|
||||
|
||||
if (attacker.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
|
||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) {
|
||||
|
||||
dpj = ((PlayerCharacter) attacker).getWeaponPower();
|
||||
|
||||
@@ -326,11 +326,11 @@ public enum CombatManager {
|
||||
|
||||
int wepSpeed = (int) (weapon.template.item_weapon_wepspeed);
|
||||
|
||||
if (weapon.getBonusPercent(Enum.ModType.WeaponSpeed, Enum.SourceType.None) != 0f) //add weapon speed bonus
|
||||
wepSpeed *= (1 + weapon.getBonus(Enum.ModType.WeaponSpeed, Enum.SourceType.None));
|
||||
if (weapon.getBonusPercent(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None) != 0f) //add weapon speed bonus
|
||||
wepSpeed *= (1 + weapon.getBonus(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None));
|
||||
|
||||
if (attacker.getBonuses() != null && attacker.getBonuses().getFloatPercentAll(Enum.ModType.AttackDelay, Enum.SourceType.None) != 0f) //add effects speed bonus
|
||||
wepSpeed *= (1 + attacker.getBonuses().getFloatPercentAll(Enum.ModType.AttackDelay, Enum.SourceType.None));
|
||||
if (attacker.getBonuses() != null && attacker.getBonuses().getFloatPercentAll(mbEnums.ModType.AttackDelay, mbEnums.SourceType.None) != 0f) //add effects speed bonus
|
||||
wepSpeed *= (1 + attacker.getBonuses().getFloatPercentAll(mbEnums.ModType.AttackDelay, mbEnums.SourceType.None));
|
||||
|
||||
if (wepSpeed < 10)
|
||||
wepSpeed = 10; //Old was 10, but it can be reached lower with legit buffs,effects.
|
||||
@@ -368,7 +368,7 @@ public enum CombatManager {
|
||||
|
||||
UpdateStateMsg rwss = new UpdateStateMsg();
|
||||
rwss.setPlayer(playerCharacter);
|
||||
DispatchMessage.dispatchMsgToInterestArea(playerCharacter, rwss, Enum.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
||||
DispatchMessage.dispatchMsgToInterestArea(playerCharacter, rwss, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
||||
}
|
||||
|
||||
public static void toggleSit(boolean toggle, ClientConnection origin) {
|
||||
@@ -381,7 +381,7 @@ public enum CombatManager {
|
||||
playerCharacter.setSit(toggle);
|
||||
UpdateStateMsg rwss = new UpdateStateMsg();
|
||||
rwss.setPlayer(playerCharacter);
|
||||
DispatchMessage.dispatchMsgToInterestArea(playerCharacter, rwss, Enum.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
DispatchMessage.dispatchMsgToInterestArea(playerCharacter, rwss, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -395,7 +395,7 @@ public enum CombatManager {
|
||||
if (attacker.equals(target))
|
||||
return;
|
||||
|
||||
if (target.isMoving() && target.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
|
||||
if (target.isMoving() && target.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter))
|
||||
return;
|
||||
|
||||
if (!target.isAlive() || !attacker.isAlive())
|
||||
|
||||
Reference in New Issue
Block a user