Browse Source

Project reformat.

postwipe-mines
MagicBot 5 months ago
parent
commit
c935ea1986
  1. 42
      src/engine/gameManager/CombatManager.java
  2. 6
      src/engine/mobileAI/MobAI.java
  3. 4
      src/engine/objects/AbstractCharacter.java
  4. 12
      src/engine/objects/Bane.java
  5. 4
      src/engine/objects/City.java
  6. 19
      src/engine/powers/poweractions/OpenGatePowerAction.java
  7. 6
      src/engine/workthreads/HourlyJobThread.java

42
src/engine/gameManager/CombatManager.java

@ -12,7 +12,6 @@ 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.Vector3f;
import engine.mbEnums; import engine.mbEnums;
import engine.net.client.ClientConnection; import engine.net.client.ClientConnection;
import engine.net.client.msg.TargetedActionMsg; import engine.net.client.msg.TargetedActionMsg;
@ -124,9 +123,9 @@ public enum CombatManager {
return; return;
//check if this slot is on attack timer, if timer has passed clear it, else early exit //check if this slot is on attack timer, if timer has passed clear it, else early exit
if(attacker.getTimers() != null && attacker.getTimers().containsKey("Attack"+slot.name())) if (attacker.getTimers() != null && attacker.getTimers().containsKey("Attack" + slot.name()))
if(attacker.getTimers().get("Attack"+slot.name()).timeToExecutionLeft() <= 0) if (attacker.getTimers().get("Attack" + slot.name()).timeToExecutionLeft() <= 0)
attacker.getTimers().remove("Attack"+slot.name()); attacker.getTimers().remove("Attack" + slot.name());
else else
return; return;
} }
@ -156,12 +155,12 @@ public enum CombatManager {
boolean inRange = false; boolean inRange = false;
if (AbstractCharacter.IsAbstractCharacter(target)) { if (AbstractCharacter.IsAbstractCharacter(target)) {
attackRange += ((AbstractCharacter)target).calcHitBox(); attackRange += ((AbstractCharacter) target).calcHitBox();
} else { } else {
} }
if(attackRange > 15 && attacker.isMoving()){ if (attackRange > 15 && attacker.isMoving()) {
//cannot shoot bow while moving; //cannot shoot bow while moving;
return; return;
} }
@ -178,14 +177,14 @@ public enum CombatManager {
inRange = true; inRange = true;
break; break;
case Building: case Building:
if(attackRange > 15){ if (attackRange > 15) {
float rangeSquared = (attackRange + target.getBounds().getHalfExtents().x) * (attackRange + target.getBounds().getHalfExtents().x); float rangeSquared = (attackRange + target.getBounds().getHalfExtents().x) * (attackRange + target.getBounds().getHalfExtents().x);
//float distanceSquared = attacker.loc.distanceSquared(target.loc); //float distanceSquared = attacker.loc.distanceSquared(target.loc);
if(distanceSquared < rangeSquared) { if (distanceSquared < rangeSquared) {
inRange = true; inRange = true;
break; break;
} }
}else { } else {
float locX = target.loc.x - target.getBounds().getHalfExtents().x; float locX = target.loc.x - target.getBounds().getHalfExtents().x;
float locZ = target.loc.z - target.getBounds().getHalfExtents().y; float locZ = target.loc.z - target.getBounds().getHalfExtents().y;
float sizeX = (target.getBounds().getHalfExtents().x + attackRange) * 2; float sizeX = (target.getBounds().getHalfExtents().x + attackRange) * 2;
@ -309,7 +308,7 @@ public enum CombatManager {
DispatchManager.sendToAllInRange(attacker, msg); DispatchManager.sendToAllInRange(attacker, msg);
//we need to send the animation even if the attacker misses //we need to send the animation even if the attacker misses
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template,null,slot)); TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template, null, slot));
DispatchManager.sendToAllInRange(target, cmm); DispatchManager.sendToAllInRange(target, cmm);
//set auto attack job //set auto attack job
@ -349,7 +348,7 @@ public enum CombatManager {
DispatchManager.dispatchMsgToInterestArea(target, msg, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); DispatchManager.dispatchMsgToInterestArea(target, msg, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
//we need to send the animation even if the attacker misses //we need to send the animation even if the attacker misses
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template,null,slot)); TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template, null, slot));
DispatchManager.sendToAllInRange(target, cmm); DispatchManager.sendToAllInRange(target, cmm);
//set auto attack job //set auto attack job
setAutoAttackJob(attacker, slot, delay); setAutoAttackJob(attacker, slot, delay);
@ -364,7 +363,7 @@ public enum CombatManager {
setAutoAttackJob(attacker, slot, delay); setAutoAttackJob(attacker, slot, delay);
return; return;
} }
if(attacker.getObjectType().equals(mbEnums.GameObjectType.Mob) && ((Mob)attacker).isPet()) if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob) && ((Mob) attacker).isPet())
calculatePetDamage(attacker); calculatePetDamage(attacker);
//get the damage type //get the damage type
@ -434,7 +433,7 @@ public enum CombatManager {
if (resists.immuneTo(damageType)) { if (resists.immuneTo(damageType)) {
//set auto attack job //set auto attack job
//we need to send the animation even if the attacker misses //we need to send the animation even if the attacker misses
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template,null,slot)); TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template, null, slot));
DispatchManager.sendToAllInRange(target, cmm); DispatchManager.sendToAllInRange(target, cmm);
setAutoAttackJob(attacker, slot, delay); setAutoAttackJob(attacker, slot, delay);
return; return;
@ -545,7 +544,7 @@ public enum CombatManager {
} }
//Item has no equipment slots and should not try to return an animation, return default instead //Item has no equipment slots and should not try to return an animation, return default instead
if(wb.item_eq_slots_or == null || wb.item_eq_slots_or.isEmpty()){ if (wb.item_eq_slots_or == null || wb.item_eq_slots_or.isEmpty()) {
return 75; return 75;
} }
@ -554,14 +553,14 @@ public enum CombatManager {
int random; int random;
//Item can only be equipped in one slot, return animation for that slot //Item can only be equipped in one slot, return animation for that slot
if(wb.item_eq_slots_or.size() == 1){ if (wb.item_eq_slots_or.size() == 1) {
if (wb.item_eq_slots_or.iterator().next().equals(mbEnums.EquipSlotType.RHELD)) { if (wb.item_eq_slots_or.iterator().next().equals(mbEnums.EquipSlotType.RHELD)) {
anim = wb.weapon_attack_anim_right.get(0)[0]; anim = wb.weapon_attack_anim_right.get(0)[0];
if (dpj != null) { if (dpj != null) {
random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size()); random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size());
anim = wb.weapon_attack_anim_right.get(random)[0]; anim = wb.weapon_attack_anim_right.get(random)[0];
} }
}else { } else {
anim = wb.weapon_attack_anim_left.get(0)[0]; anim = wb.weapon_attack_anim_left.get(0)[0];
if (dpj != null) { if (dpj != null) {
random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size()); random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size());
@ -578,7 +577,7 @@ public enum CombatManager {
random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size()); random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size());
anim = wb.weapon_attack_anim_right.get(random)[0]; anim = wb.weapon_attack_anim_right.get(random)[0];
} }
}else { } else {
anim = wb.weapon_attack_anim_left.get(0)[0]; anim = wb.weapon_attack_anim_left.get(0)[0];
if (dpj != null) { if (dpj != null) {
random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size()); random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size());
@ -588,8 +587,8 @@ public enum CombatManager {
return anim; return anim;
} }
public static int getPassiveAnimation(mbEnums.PassiveType passiveType){ public static int getPassiveAnimation(mbEnums.PassiveType passiveType) {
switch(passiveType){ switch (passiveType) {
case Block: case Block:
return COMBAT_BLOCK_ANIMATION; return COMBAT_BLOCK_ANIMATION;
case Parry: case Parry:
@ -604,7 +603,7 @@ public enum CombatManager {
public static void setAutoAttackJob(AbstractCharacter attacker, mbEnums.EquipSlotType slot, long delay) { public static void setAutoAttackJob(AbstractCharacter attacker, mbEnums.EquipSlotType slot, long delay) {
//calculate next allowed attack and update the timestamp //calculate next allowed attack and update the timestamp
if(attacker.getTimestamps().containsKey("Attack" + slot.name()) && attacker.getTimestamps().get("Attack" + slot.name()) > System.currentTimeMillis()) if (attacker.getTimestamps().containsKey("Attack" + slot.name()) && attacker.getTimestamps().get("Attack" + slot.name()) > System.currentTimeMillis())
return; return;
attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis() + delay); attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis() + delay);
@ -621,6 +620,7 @@ public enum CombatManager {
Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID()); Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID());
} }
public static int calculatePetDamage(AbstractCharacter agent) { public static int calculatePetDamage(AbstractCharacter agent) {
//damage calc for pet //damage calc for pet
float range; float range;
@ -635,6 +635,7 @@ public enum CombatManager {
damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2; damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2;
return (int) (damage * dmgMultiplier); return (int) (damage * dmgMultiplier);
} }
public static double getMinDmg(double min, AbstractCharacter agent) { public static double getMinDmg(double min, AbstractCharacter agent) {
int primary = agent.getStatStrCurrent(); int primary = agent.getStatStrCurrent();
int secondary = agent.getStatDexCurrent(); int secondary = agent.getStatDexCurrent();
@ -642,6 +643,7 @@ public enum CombatManager {
int masteryLevel = 0; int masteryLevel = 0;
return min * (pow(0.0048 * primary + .049 * (primary - 0.75), 0.5) + pow(0.0066 * secondary + 0.064 * (secondary - 0.75), 0.5) + +0.01 * (focusLevel + masteryLevel)); return min * (pow(0.0048 * primary + .049 * (primary - 0.75), 0.5) + pow(0.0066 * secondary + 0.064 * (secondary - 0.75), 0.5) + +0.01 * (focusLevel + masteryLevel));
} }
public static double getMaxDmg(double max, AbstractCharacter agent) { public static double getMaxDmg(double max, AbstractCharacter agent) {
int primary = agent.getStatStrCurrent(); int primary = agent.getStatStrCurrent();
int secondary = agent.getStatDexCurrent(); int secondary = agent.getStatDexCurrent();

6
src/engine/mobileAI/MobAI.java

@ -100,7 +100,7 @@ public class MobAI {
public static void attackPlayer(Mob mob, PlayerCharacter target) { public static void attackPlayer(Mob mob, PlayerCharacter target) {
try { try {
if(target == null || !target.isAlive() || !target.isActive() ) { if (target == null || !target.isAlive() || !target.isActive()) {
mob.setCombatTarget(null); mob.setCombatTarget(null);
return; return;
} }
@ -175,7 +175,7 @@ public class MobAI {
public static void attackMob(Mob mob, Mob target) { public static void attackMob(Mob mob, Mob target) {
try { try {
if(mob == null || target == null) if (mob == null || target == null)
return; return;
if (mob.getRange() >= 30 && mob.isMoving()) if (mob.getRange() >= 30 && mob.isMoving())
@ -976,7 +976,7 @@ public class MobAI {
private static void hamletGuardAggro(Mob mob) { private static void hamletGuardAggro(Mob mob) {
Realm realm = RealmMap.getRealmAtLocation(mob.loc); Realm realm = RealmMap.getRealmAtLocation(mob.loc);
if(realm.getRealmName().equals("Uthgaard")){ if (realm.getRealmName().equals("Uthgaard")) {
HashSet<AbstractWorldObject> loadedMobs = WorldGrid.getObjectsInRangePartial(mob.loc, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_MOB); HashSet<AbstractWorldObject> loadedMobs = WorldGrid.getObjectsInRangePartial(mob.loc, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_MOB);
for (AbstractWorldObject awo : loadedMobs) { for (AbstractWorldObject awo : loadedMobs) {
Mob targetMob = (Mob) awo; Mob targetMob = (Mob) awo;

4
src/engine/objects/AbstractCharacter.java

@ -806,7 +806,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
speed *= (1 + abstractCharacter.bonuses.getFloatPercentAll(ModType.WeaponSpeed, SourceType.None)); speed *= (1 + abstractCharacter.bonuses.getFloatPercentAll(ModType.WeaponSpeed, SourceType.None));
PlayerBonuses bonuses = abstractCharacter.bonuses; PlayerBonuses bonuses = abstractCharacter.bonuses;
if(bonuses != null){ if (bonuses != null) {
ModType modType = ModType.AttackDelay; ModType modType = ModType.AttackDelay;
for (AbstractEffectModifier mod : bonuses.bonusFloats.keySet()) { for (AbstractEffectModifier mod : bonuses.bonusFloats.keySet()) {
@ -1829,7 +1829,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
Mob target = (Mob) this; Mob target = (Mob) this;
if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter)) { if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter)) {
if(target.playerAgroMap.containsKey(attacker.getObjectUUID())) if (target.playerAgroMap.containsKey(attacker.getObjectUUID()))
target.playerAgroMap.put(attacker.getObjectUUID(), target.playerAgroMap.get(attacker.getObjectUUID()) + value); target.playerAgroMap.put(attacker.getObjectUUID(), target.playerAgroMap.get(attacker.getObjectUUID()) + value);
else else
target.playerAgroMap.put(attacker.getObjectUUID(), value); target.playerAgroMap.put(attacker.getObjectUUID(), value);

12
src/engine/objects/Bane.java

@ -641,18 +641,18 @@ public final class Bane {
return cityUUID; return cityUUID;
} }
public void startBane(){ public void startBane() {
City city = this.getCity(); City city = this.getCity();
if(city == null) if (city == null)
return; return;
this.isStarted = true; //flag the bane as started this.isStarted = true; //flag the bane as started
for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(city.loc,mbEnums.CityBoundsType.ZONE.halfExtents + 64,MBServerStatics.MASK_BUILDING)){ for (AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(city.loc, mbEnums.CityBoundsType.ZONE.halfExtents + 64, MBServerStatics.MASK_BUILDING)) {
Building building = (Building)awo; Building building = (Building) awo;
if(building == null) if (building == null)
continue; continue;
if(building.protectionState.equals(ProtectionState.UNDERSIEGE) == false) if (building.protectionState.equals(ProtectionState.UNDERSIEGE) == false)
building.protectionState = ProtectionState.UNDERSIEGE; building.protectionState = ProtectionState.UNDERSIEGE;
} }

4
src/engine/objects/City.java

@ -300,7 +300,7 @@ public class City extends AbstractWorldObject {
//handle compiling of cities able to be teleported to for lore rule-set //handle compiling of cities able to be teleported to for lore rule-set
for (AbstractGameObject ago : worldCities.values()) { for (AbstractGameObject ago : worldCities.values()) {
City city = (City) ago; City city = (City) ago;
if(city.cityName.equals("Perdition") || city.cityName.equals("Bastion")) if (city.cityName.equals("Perdition") || city.cityName.equals("Bastion"))
continue; // cannot teleport to perdition or bastion continue; // cannot teleport to perdition or bastion
if (city.isNpc == 1 && city.getGuild().charter.equals(pc.guild.charter)) { if (city.isNpc == 1 && city.getGuild().charter.equals(pc.guild.charter)) {
cities.add(city); // anyone of the same charter can teleport to a safehold of that charter cities.add(city); // anyone of the same charter can teleport to a safehold of that charter
@ -407,7 +407,7 @@ public class City extends AbstractWorldObject {
//handle compiling of cities able to be repledged to for lore rule-set //handle compiling of cities able to be repledged to for lore rule-set
for (AbstractGameObject ago : worldCities.values()) { for (AbstractGameObject ago : worldCities.values()) {
City city = (City) ago; City city = (City) ago;
if(city.cityName.equals("Perdition") || city.cityName.equals("Bastion")) if (city.cityName.equals("Perdition") || city.cityName.equals("Bastion"))
continue; // cannot repledge to perdition or bastion continue; // cannot repledge to perdition or bastion
if (city.isNpc == 1 && city.getGuild().charter.canJoin(playerCharacter)) { if (city.isNpc == 1 && city.getGuild().charter.canJoin(playerCharacter)) {
cities.add(city); // anyone of the same charter can teleport to a safehold of that charter cities.add(city); // anyone of the same charter can teleport to a safehold of that charter

19
src/engine/powers/poweractions/OpenGatePowerAction.java

@ -11,7 +11,6 @@ package engine.powers.poweractions;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.mbEnums; import engine.mbEnums;
import engine.mbEnums.BuildingGroup;
import engine.mbEnums.GameObjectType; import engine.mbEnums.GameObjectType;
import engine.mbEnums.PortalType; import engine.mbEnums.PortalType;
import engine.objects.AbstractCharacter; import engine.objects.AbstractCharacter;
@ -54,15 +53,17 @@ public class OpenGatePowerAction extends AbstractPowerAction {
return; return;
// Make sure target building is a runegate // Make sure target building is a runegate
if(targetBuilding.meshUUID != 24500) // runegate
if (targetBuilding.meshUUID != 24500) // runegate
return; return;
// Which runegate was clicked on? // Which runegate was clicked on?
Runegate runeGate = Runegate._runegates.get(targetBuilding.getObjectUUID()); Runegate runeGate = Runegate._runegates.get(targetBuilding.getObjectUUID());
if(runeGate == null){ if (runeGate == null)
return; // mob camp prop runegate cannot be opened return; // mob camp prop runegate cannot be opened
}
// Which portal was opened? // Which portal was opened?
token = pb.getToken(); token = pb.getToken();
@ -72,41 +73,31 @@ public class OpenGatePowerAction extends AbstractPowerAction {
case 428937084: //Death Gate case 428937084: //Death Gate
portalType = PortalType.OBLIV; portalType = PortalType.OBLIV;
break; break;
case 429756284: //Chaos Gate case 429756284: //Chaos Gate
portalType = PortalType.CHAOS; portalType = PortalType.CHAOS;
break; break;
case 429723516: //Khar Gate case 429723516: //Khar Gate
portalType = PortalType.MERCHANT; portalType = PortalType.MERCHANT;
break; break;
case 429559676: //Spirit Gate case 429559676: //Spirit Gate
portalType = PortalType.SPIRIT; portalType = PortalType.SPIRIT;
break; break;
case 429592444: //Water Gate case 429592444: //Water Gate
portalType = PortalType.WATER; portalType = PortalType.WATER;
break; break;
case 429428604: //Fire Gate case 429428604: //Fire Gate
portalType = PortalType.FIRE; portalType = PortalType.FIRE;
break; break;
case 429526908: //Air Gate case 429526908: //Air Gate
portalType = PortalType.AIR; portalType = PortalType.AIR;
break; break;
case 429625212: //Earth Gate case 429625212: //Earth Gate
portalType = PortalType.EARTH; portalType = PortalType.EARTH;
break; break;
default: default:
} }
runeGate.activatePortal(portalType); runeGate.activatePortal(portalType);
} }
@Override @Override

6
src/engine/workthreads/HourlyJobThread.java

@ -289,10 +289,10 @@ public class HourlyJobThread implements Runnable {
Logger.info(PurgeOprhans.recordsDeleted.toString() + "orphaned items deleted"); Logger.info(PurgeOprhans.recordsDeleted.toString() + "orphaned items deleted");
} }
public static void processBanes(){ public static void processBanes() {
//handle banes //handle banes
for(Bane bane : Bane.banes.values()){ for (Bane bane : Bane.banes.values()) {
if(bane.getLiveDate() != null && DateTime.now().isAfter(bane.getLiveDate().minusMinutes(1)) && bane.isStarted == false) if (bane.getLiveDate() != null && DateTime.now().isAfter(bane.getLiveDate().minusMinutes(1)) && bane.isStarted == false)
bane.startBane(); bane.startBane();
} }
} }

Loading…
Cancel
Save