forked from MagicBane/Server
add hitbox to abs vs abs range checks
This commit is contained in:
@@ -86,9 +86,9 @@ public enum CombatManager {
|
||||
|
||||
// heck if character can even attack yet
|
||||
|
||||
if (attacker.getTimestamps().containsKey("Attack" + slot.name()))
|
||||
if (System.currentTimeMillis() < attacker.getTimestamps().get("Attack" + slot.name()))
|
||||
return;
|
||||
//if (attacker.getTimestamps().containsKey("Attack" + slot.name()))
|
||||
// if (System.currentTimeMillis() < attacker.getTimestamps().get("Attack" + slot.name()))
|
||||
// return;
|
||||
|
||||
// check if character is in range to attack target
|
||||
|
||||
@@ -114,19 +114,19 @@ public enum CombatManager {
|
||||
|
||||
boolean inRange = false;
|
||||
|
||||
float attackerHitbox = attacker.calcHitBox();
|
||||
attackRange += attacker.calcHitBox();
|
||||
switch(target.getObjectType()){
|
||||
case PlayerCharacter:
|
||||
case Mob:
|
||||
float targetHitbox = ((AbstractCharacter)target).calcHitBox();
|
||||
if(distanceSquared < ((attackRange + attackerHitbox + targetHitbox) * 2))
|
||||
attackRange += ((AbstractCharacter)target).calcHitBox();
|
||||
if(distanceSquared < attackRange * 2)
|
||||
inRange = true;
|
||||
break;
|
||||
case Building:
|
||||
float locX = target.loc.x - target.getBounds().getHalfExtents().x;
|
||||
float locZ = target.loc.z - target.getBounds().getHalfExtents().y;
|
||||
float sizeX = (target.getBounds().getHalfExtents().x + attackRange + attackerHitbox) * 2;
|
||||
float sizeZ = (target.getBounds().getHalfExtents().y + attackRange + attackerHitbox) * 2;
|
||||
float sizeX = (target.getBounds().getHalfExtents().x + attackRange) * 2;
|
||||
float sizeZ = (target.getBounds().getHalfExtents().y + attackRange) * 2;
|
||||
Rectangle2D.Float rect = new Rectangle2D.Float(locX,locZ,sizeX,sizeZ);
|
||||
if(rect.contains(new Point2D.Float(attacker.loc.x,attacker.loc.z)))
|
||||
inRange = true;
|
||||
@@ -134,8 +134,7 @@ public enum CombatManager {
|
||||
}
|
||||
|
||||
|
||||
if (!inRange)
|
||||
return;
|
||||
if (inRange) {
|
||||
|
||||
// take stamina away from attacker
|
||||
|
||||
@@ -343,6 +342,7 @@ public enum CombatManager {
|
||||
((PlayerCharacter) attacker).setWeaponPower(dpj);
|
||||
}
|
||||
}
|
||||
}
|
||||
//calculate next allowed attack and update the timestamp
|
||||
|
||||
long delay = 20 * 100;
|
||||
|
||||
Reference in New Issue
Block a user