Browse Source

removed ItemBase form Combat manager

combat-2
FatBoy-DOTC 8 months ago
parent
commit
836c076884
  1. 43
      src/engine/gameManager/CombatManager.java

43
src/engine/gameManager/CombatManager.java

@ -313,12 +313,12 @@ public enum CombatManager {
boolean isWeapon = true; boolean isWeapon = true;
Item weapon = equipped.get(weaponSlot); Item weapon = equipped.get(weaponSlot);
ItemBase wb = null; ItemTemplate wb = null;
if (weapon == null) if (weapon == null)
isWeapon = false; isWeapon = false;
else { else {
ItemBase ib = weapon.getItemBase(); ItemTemplate ib = weapon.template;
if (ib == null || !weapon.template.item_type.equals(ItemType.WEAPON)) if (ib == null || !weapon.template.item_type.equals(ItemType.WEAPON))
isWeapon = false; isWeapon = false;
@ -336,7 +336,7 @@ public enum CombatManager {
Item weaponOff = equipped.get(EquipSlotType.RHELD); Item weaponOff = equipped.get(EquipSlotType.RHELD);
if (weaponOff != null) { if (weaponOff != null) {
ItemBase ib = weaponOff.getItemBase(); ItemTemplate ib = weaponOff.template;
if (ib == null || !weaponOff.template.item_type.equals(ItemType.WEAPON)) if (ib == null || !weaponOff.template.item_type.equals(ItemType.WEAPON))
hasNoWeapon = true; hasNoWeapon = true;
@ -352,7 +352,7 @@ public enum CombatManager {
//Source can attack. //Source can attack.
//NOTE Don't 'return;' beyond this point until timer created //NOTE Don't 'return;' beyond this point until timer created
boolean attackFailure = (wb != null) && (wb.getRange() > 35f) && abstractCharacter.isMoving(); boolean attackFailure = (wb != null) && (wb.item_weapon_max_range > 35f) && abstractCharacter.isMoving();
//Target can't attack on move with ranged weapons. //Target can't attack on move with ranged weapons.
//if not enough stamina, then skip attack //if not enough stamina, then skip attack
@ -419,7 +419,7 @@ public enum CombatManager {
if (hasNoWeapon || abstractCharacter.getObjectType().equals(GameObjectType.Mob)) if (hasNoWeapon || abstractCharacter.getObjectType().equals(GameObjectType.Mob))
createTimer(abstractCharacter, slot, 20, true); //2 second for no weapon createTimer(abstractCharacter, slot, 20, true); //2 second for no weapon
else { else {
int wepSpeed = (int) (wb.getSpeed()); int wepSpeed = (int) (wb.item_weapon_wepspeed);
if (weapon != null && weapon.getBonusPercent(ModType.WeaponSpeed, SourceType.NONE) != 0f) //add weapon speed bonus if (weapon != null && weapon.getBonusPercent(ModType.WeaponSpeed, SourceType.NONE) != 0f) //add weapon speed bonus
wepSpeed *= (1 + weapon.getBonus(ModType.WeaponSpeed, SourceType.NONE)); wepSpeed *= (1 + weapon.getBonus(ModType.WeaponSpeed, SourceType.NONE));
@ -460,7 +460,7 @@ public enum CombatManager {
/** /**
* Attempt to attack target * Attempt to attack target
*/ */
private static void attack(AbstractCharacter attacker, AbstractWorldObject target, Item weapon, ItemBase wb, boolean mainHand) { private static void attack(AbstractCharacter attacker, AbstractWorldObject target, Item weapon, ItemTemplate wb, boolean mainHand) {
float atr; float atr;
int minDamage, maxDamage; int minDamage, maxDamage;
@ -595,9 +595,9 @@ public enum CombatManager {
// Apply Weapon power effect if any. don't try to apply twice if // Apply Weapon power effect if any. don't try to apply twice if
// dual wielding. Perform after passive test for sync purposes. // dual wielding. Perform after passive test for sync purposes.
ItemTemplate template = ItemTemplate.templates.get(wb.getUUID()); //ItemTemplate template = ItemTemplate.templates.get(wb.getUUID());
if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter) && (mainHand || ItemTemplate.isTwoHanded(template))) { if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter) && (mainHand || ItemTemplate.isTwoHanded(wb))) {
dpj = ((PlayerCharacter) attacker).getWeaponPower(); dpj = ((PlayerCharacter) attacker).getWeaponPower();
@ -692,7 +692,7 @@ public enum CombatManager {
SourceType damageType; SourceType damageType;
if (wb != null) if (wb != null)
damageType = wb.getDamageType(); damageType = (SourceType) wb.item_weapon_damage.keySet().toArray()[0];
else if (attacker.getObjectType().equals(GameObjectType.Mob) && ((Mob) attacker).isSiege()) else if (attacker.getObjectType().equals(GameObjectType.Mob) && ((Mob) attacker).isSiege())
damageType = SourceType.SIEGE; damageType = SourceType.SIEGE;
else else
@ -813,8 +813,7 @@ public enum CombatManager {
// Apply Weapon power effect if any. // Apply Weapon power effect if any.
// don't try to apply twice if dual wielding. // don't try to apply twice if dual wielding.
ItemTemplate template = ItemTemplate.templates.get(wb.getUUID()); if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter) && (mainHand || ItemTemplate.isTwoHanded(wb))) {
if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter) && (mainHand || ItemTemplate.isTwoHanded(template))) {
dpj = ((PlayerCharacter) attacker).getWeaponPower(); dpj = ((PlayerCharacter) attacker).getWeaponPower();
if (dpj != null) { if (dpj != null) {
@ -902,7 +901,7 @@ public enum CombatManager {
if (item == null) if (item == null)
return false; return false;
ItemBase ib = item.getItemBase(); ItemTemplate ib = item.template;
if (ib == null) if (ib == null)
return false; return false;
@ -910,7 +909,7 @@ public enum CombatManager {
if (item.template.item_type.equals(ItemType.WEAPON) == false) if (item.template.item_type.equals(ItemType.WEAPON) == false)
return false; return false;
return ib.getRange() > MBServerStatics.RANGED_WEAPON_RANGE; return ib.item_weapon_max_range > MBServerStatics.RANGED_WEAPON_RANGE;
} }
@ -937,7 +936,7 @@ public enum CombatManager {
return damage; return damage;
} }
private static void sendPassiveDefenseMessage(AbstractCharacter source, ItemBase wb, AbstractWorldObject target, int passiveType, DeferredPowerJob dpj, boolean mainHand) { private static void sendPassiveDefenseMessage(AbstractCharacter source, ItemTemplate wb, AbstractWorldObject target, int passiveType, DeferredPowerJob dpj, boolean mainHand) {
int swingAnimation = getSwingAnimation(wb, dpj, mainHand); int swingAnimation = getSwingAnimation(wb, dpj, mainHand);
@ -950,7 +949,7 @@ public enum CombatManager {
} }
private static void sendCombatMessage(AbstractCharacter source, AbstractWorldObject target, float damage, ItemBase wb, DeferredPowerJob dpj, boolean mainHand) { private static void sendCombatMessage(AbstractCharacter source, AbstractWorldObject target, float damage, ItemTemplate wb, DeferredPowerJob dpj, boolean mainHand) {
int swingAnimation = getSwingAnimation(wb, dpj, mainHand); int swingAnimation = getSwingAnimation(wb, dpj, mainHand);
@ -967,7 +966,7 @@ public enum CombatManager {
DispatchMessage.sendToAllInRange(target, cmm); DispatchMessage.sendToAllInRange(target, cmm);
} }
public static int getSwingAnimation(ItemBase wb, DeferredPowerJob dpj, boolean mainHand) { public static int getSwingAnimation(ItemTemplate wb, DeferredPowerJob dpj, boolean mainHand) {
int token = 0; int token = 0;
if (dpj != null) if (dpj != null)
@ -982,7 +981,7 @@ public enum CombatManager {
if (wb == null) if (wb == null)
return 75; return 75;
ItemTemplate template = ItemTemplate.templates.get(wb.getUUID()); ItemTemplate template = wb;
if (mainHand) { if (mainHand) {
if (template.weapon_attack_anim_right.size() > 0) { if (template.weapon_attack_anim_right.size() > 0) {
@ -1043,7 +1042,7 @@ public enum CombatManager {
} }
String required = template.item_skill_used; String required = template.item_skill_used;
String mastery = wb.getMastery(); String mastery = wb.item_skill_mastery_used;
if (required.equals("Unarmed Combat")) if (required.equals("Unarmed Combat"))
return 75; return 75;
@ -1109,7 +1108,7 @@ public enum CombatManager {
pc.setLastPlayerAttackTime(); pc.setLastPlayerAttackTime();
} }
public static float getWeaponRange(ItemBase weapon, PlayerBonuses bonus) { public static float getWeaponRange(ItemTemplate weapon, PlayerBonuses bonus) {
float rangeMod = 1.0f; float rangeMod = 1.0f;
@ -1119,7 +1118,7 @@ public enum CombatManager {
if (bonus != null) if (bonus != null)
rangeMod += bonus.getFloatPercentAll(ModType.WeaponRange, SourceType.NONE); rangeMod += bonus.getFloatPercentAll(ModType.WeaponRange, SourceType.NONE);
return weapon.getRange() * rangeMod; return weapon.item_weapon_max_range * rangeMod;
} }
public static void toggleCombat(ToggleCombatMsg msg, ClientConnection origin) { public static void toggleCombat(ToggleCombatMsg msg, ClientConnection origin) {
@ -1327,7 +1326,7 @@ public enum CombatManager {
return hitBox; return hitBox;
} }
private static void testItemDamage(AbstractCharacter ac, AbstractWorldObject awo, Item weapon, ItemBase wb) { private static void testItemDamage(AbstractCharacter ac, AbstractWorldObject awo, Item weapon, ItemTemplate wb) {
if (ac == null) if (ac == null)
return; return;
@ -1337,7 +1336,7 @@ public enum CombatManager {
int chance = 4500; int chance = 4500;
if (wb != null) if (wb != null)
if (wb.isGlass()) //glass used weighted so fast weapons don't break faster if (wb.obj_name.contains("Glass")) //glass used weighted so fast weapons don't break faster
chance = 9000 / weapon.template.item_wt; chance = 9000 / weapon.template.item_wt;
//test damaging attackers weapon //test damaging attackers weapon

Loading…
Cancel
Save