From 79f4a33b6efc87bc2f3db81ef02c3cbc9183ab47 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 13 Apr 2024 19:10:10 -0500 Subject: [PATCH] add half player character height to attack range in lieu of hitbox --- src/engine/gameManager/CombatManager.java | 40 ++++++++++++++--------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 9f9566b2..0a61159c 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -113,13 +113,20 @@ public enum CombatManager { float distanceSquared = attacker.loc.distanceSquared(target.loc); boolean inRange = false; - - attackRange += attacker.calcHitBox(); + if(attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)){ + attackRange += ((PlayerCharacter)attacker).getCharacterHeight() * 0.5f; + }else { + attackRange += attacker.calcHitBox(); + } switch(target.getObjectType()){ case PlayerCharacter: + attackRange += ((PlayerCharacter)target).getCharacterHeight() * 0.5f; + if(distanceSquared < attackRange * attackRange) + inRange = true; + break; case Mob: attackRange += ((AbstractCharacter)target).calcHitBox(); - if(distanceSquared < attackRange * 2) + if(distanceSquared < attackRange * attackRange) inRange = true; break; case Building: @@ -143,6 +150,20 @@ public enum CombatManager { } } + DeferredPowerJob dpj = null; + + if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { + + dpj = ((PlayerCharacter) attacker).getWeaponPower(); + + if (dpj != null) { + dpj.attack(target, attackRange); + + if (dpj.getPower() != null && (dpj.getPowerToken() == -1851459567 || dpj.getPowerToken() == -1851489518)) + ((PlayerCharacter) attacker).setWeaponPower(dpj); + } + } + // take stamina away from attacker if (weapon != null) { @@ -336,19 +357,6 @@ public enum CombatManager { TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) damage, attackAnim); DispatchMessage.sendToAllInRange(target, cmm); } - DeferredPowerJob dpj = null; - - if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { - - dpj = ((PlayerCharacter) attacker).getWeaponPower(); - - if (dpj != null) { - dpj.attack(target, attackRange); - - if (dpj.getPower() != null && (dpj.getPowerToken() == -1851459567 || dpj.getPowerToken() == -1851489518)) - ((PlayerCharacter) attacker).setWeaponPower(dpj); - } - } } //calculate next allowed attack and update the timestamp