Browse Source

add half player character height to attack range in lieu of hitbox

combat-2
FatBoy-DOTC 7 months ago
parent
commit
79f4a33b6e
  1. 40
      src/engine/gameManager/CombatManager.java

40
src/engine/gameManager/CombatManager.java

@ -113,13 +113,20 @@ public enum CombatManager { @@ -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 { @@ -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 { @@ -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

Loading…
Cancel
Save