|
|
@ -12,6 +12,7 @@ import engine.job.JobContainer; |
|
|
|
import engine.job.JobScheduler; |
|
|
|
import engine.job.JobScheduler; |
|
|
|
import engine.jobs.AttackJob; |
|
|
|
import engine.jobs.AttackJob; |
|
|
|
import engine.jobs.DeferredPowerJob; |
|
|
|
import engine.jobs.DeferredPowerJob; |
|
|
|
|
|
|
|
import engine.math.Bounds; |
|
|
|
import engine.mbEnums; |
|
|
|
import engine.mbEnums; |
|
|
|
import engine.net.DispatchMessage; |
|
|
|
import engine.net.DispatchMessage; |
|
|
|
import engine.net.client.ClientConnection; |
|
|
|
import engine.net.client.ClientConnection; |
|
|
@ -23,6 +24,8 @@ import engine.powers.effectmodifiers.AbstractEffectModifier; |
|
|
|
import engine.server.MBServerStatics; |
|
|
|
import engine.server.MBServerStatics; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.awt.geom.Point2D; |
|
|
|
|
|
|
|
import java.awt.geom.Rectangle2D; |
|
|
|
import java.util.EnumSet; |
|
|
|
import java.util.EnumSet; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.concurrent.ThreadLocalRandom; |
|
|
|
import java.util.concurrent.ThreadLocalRandom; |
|
|
@ -109,7 +112,29 @@ public enum CombatManager { |
|
|
|
|
|
|
|
|
|
|
|
float distanceSquared = attacker.loc.distanceSquared(target.loc); |
|
|
|
float distanceSquared = attacker.loc.distanceSquared(target.loc); |
|
|
|
|
|
|
|
|
|
|
|
if (distanceSquared > attackRange * attackRange) |
|
|
|
boolean inRange = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float attackerHitbox = attacker.calcHitBox(); |
|
|
|
|
|
|
|
switch(target.getObjectType()){ |
|
|
|
|
|
|
|
case PlayerCharacter: |
|
|
|
|
|
|
|
case Mob: |
|
|
|
|
|
|
|
float targetHitbox = ((AbstractCharacter)target).calcHitBox(); |
|
|
|
|
|
|
|
if(distanceSquared < ((attackRange + attackerHitbox + targetHitbox) * 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; |
|
|
|
|
|
|
|
Rectangle2D.Float rect = new Rectangle2D.Float(locX,locZ,sizeX,sizeZ); |
|
|
|
|
|
|
|
if(rect.contains(new Point2D.Float(attacker.loc.x,attacker.loc.z))) |
|
|
|
|
|
|
|
inRange = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!inRange) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
// take stamina away from attacker
|
|
|
|
// take stamina away from attacker
|
|
|
|