Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c0cd365c1d | |||
| ee5620036d | |||
| 8ff06b1200 | |||
| a348056c86 | |||
| 1c10f8a872 | |||
| 4f28fefbc2 | |||
| 9ff7e07545 | |||
| d5809fc4b1 | |||
| 0c00832264 | |||
| 300452d2d8 | |||
| 9a9ea99bc7 | |||
| d9ab1032f4 | |||
| c2ea4424cf | |||
| b22c07b000 | |||
| 8e70e0597e | |||
| cf58e7b984 | |||
| ba81a24622 | |||
| 007299eae5 | |||
| 5f92345d3e |
@@ -136,12 +136,6 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
||||
int cityUID = rs.getInt("cityUUID");
|
||||
JSONObject jsonObject = new JSONObject(rs.getString("warehouse"));
|
||||
City city = City.getCity(cityUID);
|
||||
|
||||
if (city == null) {
|
||||
Logger.error("No city " + cityUID + " for warehouse");
|
||||
continue;
|
||||
}
|
||||
|
||||
city.warehouse = new Warehouse(jsonObject);
|
||||
city.warehouse.city = city;
|
||||
|
||||
@@ -198,7 +192,6 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
||||
// via the client interface.
|
||||
|
||||
ArrayList<WorkOrder> submitList = new ArrayList<>();
|
||||
ArrayList<WorkOrder> orphanList = new ArrayList<>();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_workorders`;");
|
||||
@@ -216,14 +209,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
||||
// Submit new workOrders to the ForgeManager
|
||||
|
||||
for (WorkOrder workOrder : submitList) {
|
||||
|
||||
DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder);
|
||||
|
||||
// Delete but do not reconstitute orphan workOrders
|
||||
|
||||
if (workOrder.vendor == null)
|
||||
continue;
|
||||
|
||||
workOrder.workOrderID = ForgeManager.workOrderCounter.incrementAndGet();
|
||||
DbManager.WarehouseQueries.WRITE_WORKORDER(workOrder);
|
||||
ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder);
|
||||
|
||||
@@ -104,67 +104,67 @@ public enum BuildingManager {
|
||||
if (building == null)
|
||||
return false;
|
||||
|
||||
//cannot access destroyed buildings
|
||||
if (building.getRank() == -1)
|
||||
return false;
|
||||
|
||||
//admin characters can always access buildings
|
||||
if (player.isCSR())
|
||||
return true;
|
||||
|
||||
//owner can always access their own building
|
||||
if (IsOwner(building, player))
|
||||
return true;
|
||||
|
||||
//check for default IC access if building belongs to same guild
|
||||
if(player.guild.equals(building.getGuild())) {
|
||||
if (building.getBlueprint() != null && building.getBlueprint().getBuildingGroup() != null) {
|
||||
switch (building.getBlueprint().getBuildingGroup()) {
|
||||
case TOL:
|
||||
case BARRACK:
|
||||
case SPIRE:
|
||||
case SHRINE:
|
||||
case BANESTONE:
|
||||
case MINE:
|
||||
case WAREHOUSE:
|
||||
case BULWARK:
|
||||
case SIEGETENT:
|
||||
if (GuildStatusController.isInnerCouncil(player.getGuildStatus()))
|
||||
return true;
|
||||
if (GuildStatusController.isGuildLeader(player.getGuildStatus()))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//individual friend.
|
||||
|
||||
//check against friends list entries if any present
|
||||
if (building.getFriends() != null) {
|
||||
if (building.getFriends() != null && building.getFriends().get(player.getObjectUUID()) != null)
|
||||
return true;
|
||||
|
||||
//check individuals
|
||||
if (building.getFriends().get(player.getObjectUUID()) != null)
|
||||
return true;
|
||||
//Admins can access stuff
|
||||
|
||||
if (building.getFriends().get(player.guild.objectUUID) != null) {
|
||||
if (player.isCSR())
|
||||
return true;
|
||||
|
||||
//check friend type for guild related access
|
||||
switch (building.getFriends().get(player.guild.objectUUID).friendType) {
|
||||
case 8: //full member
|
||||
if (GuildStatusController.isFullMember(player.getGuildStatus()))
|
||||
return true;
|
||||
break;
|
||||
case 9: //Inner Council
|
||||
if (GuildStatusController.isInnerCouncil(player.getGuildStatus()))
|
||||
return true;
|
||||
if (GuildStatusController.isGuildLeader(player.getGuildStatus()))
|
||||
return true;
|
||||
break;
|
||||
//Guild stuff
|
||||
|
||||
if (building.getGuild().isGuildLeader(player.getObjectUUID()))
|
||||
return true;
|
||||
|
||||
if (building.getFriends().get(player.getGuild().getObjectUUID()) != null && building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 8)
|
||||
return true;
|
||||
|
||||
if (building.getFriends().get(player.getGuild().getObjectUUID()) != null && building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 9 && GuildStatusController.isInnerCouncil(player.getGuildStatus()))
|
||||
return true;
|
||||
|
||||
if (Guild.sameGuild(building.getGuild(), player.getGuild()) && GuildStatusController.isInnerCouncil(player.getGuildStatus()))
|
||||
return true;
|
||||
|
||||
return Guild.sameGuild(building.getGuild(), player.getGuild()) && GuildStatusController.isGuildLeader(player.getGuildStatus());
|
||||
|
||||
//TODO test friends list once added
|
||||
//does not meet above criteria. Cannot access.
|
||||
}
|
||||
|
||||
public static boolean playerCanManageNotFriends(PlayerCharacter player, Building building) {
|
||||
|
||||
//Player Can only Control Building if player is in Same Guild as Building and is higher rank than IC.
|
||||
|
||||
if (player == null)
|
||||
return false;
|
||||
|
||||
if (building == null)
|
||||
return false;
|
||||
|
||||
if (building.getRank() == -1)
|
||||
return false;
|
||||
|
||||
if (IsOwner(building, player))
|
||||
return true;
|
||||
|
||||
//Somehow guild leader check fails? lets check if Player is true Guild GL.
|
||||
if (building.getGuild() != null && building.getGuild().isGuildLeader(player.getObjectUUID()))
|
||||
return true;
|
||||
|
||||
if (!GuildStatusController.isGuildLeader(player.getGuildStatus()) && !GuildStatusController.isInnerCouncil(player.getGuildStatus()))
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
//did not meet access grant criteria, deny access
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static synchronized boolean lootBuilding(PlayerCharacter player, Building building) {
|
||||
@@ -463,19 +463,29 @@ public enum BuildingManager {
|
||||
return GuildStatusController.isGuildLeader(player.getGuildStatus()) || GuildStatusController.isInnerCouncil(player.getGuildStatus());
|
||||
}
|
||||
|
||||
public static int GetAvailableGold(Building building) {
|
||||
|
||||
if (building.getStrongboxValue() == 0)
|
||||
return 0;
|
||||
|
||||
if (building.getStrongboxValue() < building.reserve)
|
||||
return 0;
|
||||
|
||||
return building.getStrongboxValue() - building.reserve;
|
||||
}
|
||||
|
||||
public static boolean IsPlayerHostile(Building building, PlayerCharacter player) {
|
||||
|
||||
//Nation Members and Guild members are not hostile.
|
||||
// if (building.getGuild() != null){
|
||||
// if (pc.getGuild() != null)
|
||||
// if (building.getGuild().getObjectUUID() == pc.getGuildUUID()
|
||||
// || pc.getGuild().getNation().getObjectUUID() == building.getGuild().getNation().getObjectUUID())
|
||||
// return false;
|
||||
// }
|
||||
if (Guild.sameNationExcludeErrant(building.getGuild(), player.getGuild()))
|
||||
return false;
|
||||
|
||||
if(building.enforceKOS) {
|
||||
if (building.getCity() != null) {
|
||||
Building TOL = building.getCity().getTOL();
|
||||
if (TOL != null) {
|
||||
building = TOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!building.reverseKOS) {
|
||||
|
||||
Condemned condemn = building.getCondemned().get(player.getObjectUUID());
|
||||
@@ -798,7 +808,7 @@ public enum BuildingManager {
|
||||
// Attempt to write to database or delete the building
|
||||
// if we are destroying it.
|
||||
|
||||
if (rank < 0)
|
||||
if (rank == -1)
|
||||
success = DbManager.BuildingQueries.DELETE_FROM_DATABASE(building);
|
||||
else
|
||||
success = DbManager.BuildingQueries.updateBuildingRank(building, rank);
|
||||
|
||||
@@ -19,7 +19,6 @@ import engine.net.client.msg.UpdateStateMsg;
|
||||
import engine.objects.*;
|
||||
import engine.powers.DamageShield;
|
||||
import engine.powers.effectmodifiers.AbstractEffectModifier;
|
||||
import engine.powers.effectmodifiers.WeaponProcEffectModifier;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
@@ -48,7 +47,7 @@ public enum CombatManager {
|
||||
public static final int COMBAT_PARRY_ANIMATION = 299;
|
||||
public static final int COMBAT_DODGE_ANIMATION = 300;
|
||||
|
||||
public static void combatCycle(AbstractCharacter attacker, AbstractWorldObject target) {
|
||||
public static void combatCycle(AbstractCharacter attacker, AbstractWorldObject target, long addedDelay) {
|
||||
|
||||
//early exit checks
|
||||
|
||||
@@ -79,411 +78,413 @@ public enum CombatManager {
|
||||
|
||||
if (mainWeapon == null && offWeapon == null) {
|
||||
//no weapons equipped, punch with both fists
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD);
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD,addedDelay);
|
||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter))
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.LHELD);
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.LHELD,addedDelay);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mainWeapon != null && offWeapon == null) {
|
||||
//swing right hand only
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD);
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD,addedDelay);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mainWeapon == null && offWeapon != null && !offWeapon.template.item_skill_used.equals("Block")) {
|
||||
//swing left hand only
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.LHELD);
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.LHELD,addedDelay);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mainWeapon == null && offWeapon != null && offWeapon.template.item_skill_used.equals("Block")) {
|
||||
//no weapon equipped with a shield, punch with one hand
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD);
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD,addedDelay);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mainWeapon != null && offWeapon != null && offWeapon.template.item_skill_used.equals("Block")) {
|
||||
//one weapon equipped with a shield, swing with one hand
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD);
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD,addedDelay);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mainWeapon != null && offWeapon != null && !offWeapon.template.item_skill_used.equals("Block")) {
|
||||
//two weapons equipped, swing both hands
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD);
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD,addedDelay);
|
||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter))
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.LHELD);
|
||||
processAttack(attacker, target, mbEnums.EquipSlotType.LHELD,addedDelay);
|
||||
}
|
||||
}
|
||||
|
||||
public static void processAttack(AbstractCharacter attacker, AbstractWorldObject target, mbEnums.EquipSlotType slot) {
|
||||
public static void processAttack(AbstractCharacter attacker, AbstractWorldObject target, mbEnums.EquipSlotType slot, long addedDelay) {
|
||||
|
||||
if (slot == null || target == null || attacker == null)
|
||||
return;
|
||||
|
||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) {
|
||||
if (!attacker.isCombat())
|
||||
return;
|
||||
|
||||
//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().get("Attack" + slot.name()).timeToExecutionLeft() <= 0)
|
||||
attacker.getTimers().remove("Attack" + slot.name());
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
target.combatLock.writeLock().lock();
|
||||
|
||||
// check if character is in range to attack target
|
||||
try {
|
||||
PlayerBonuses bonus = attacker.getBonuses();
|
||||
|
||||
PlayerBonuses bonus = attacker.getBonuses();
|
||||
float rangeMod = 1.0f;
|
||||
float attackRange = MBServerStatics.NO_WEAPON_RANGE;
|
||||
|
||||
float rangeMod = 1.0f;
|
||||
float attackRange = MBServerStatics.NO_WEAPON_RANGE;
|
||||
Item weapon = attacker.charItemManager.getEquipped(slot);
|
||||
|
||||
Item weapon = attacker.charItemManager.getEquipped(slot);
|
||||
if (weapon != null) {
|
||||
if (bonus != null)
|
||||
rangeMod += bonus.getFloatPercentAll(mbEnums.ModType.WeaponRange, mbEnums.SourceType.None);
|
||||
|
||||
if (weapon != null) {
|
||||
if (bonus != null)
|
||||
rangeMod += bonus.getFloatPercentAll(mbEnums.ModType.WeaponRange, mbEnums.SourceType.None);
|
||||
|
||||
attackRange += weapon.template.item_weapon_max_range * rangeMod;
|
||||
}
|
||||
|
||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob))
|
||||
if (((Mob) attacker).isSiege())
|
||||
attackRange = 300;
|
||||
|
||||
float distanceSquared = attacker.loc.distanceSquared(target.loc);
|
||||
|
||||
boolean inRange = false;
|
||||
if (AbstractCharacter.IsAbstractCharacter(target)) {
|
||||
attackRange += ((AbstractCharacter) target).calcHitBox();
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
if (attackRange > 15 && attacker.isMoving()) {
|
||||
//cannot shoot bow while moving;
|
||||
return;
|
||||
}
|
||||
|
||||
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 * attackRange)
|
||||
inRange = true;
|
||||
break;
|
||||
case Building:
|
||||
if (attackRange > 15) {
|
||||
float rangeSquared = (attackRange + target.getBounds().getHalfExtents().x) * (attackRange + target.getBounds().getHalfExtents().x);
|
||||
//float distanceSquared = attacker.loc.distanceSquared(target.loc);
|
||||
if (distanceSquared < rangeSquared) {
|
||||
inRange = true;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
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) * 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;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//get delay for the auto attack job
|
||||
long delay = 5000;
|
||||
|
||||
if (weapon != null) {
|
||||
|
||||
float wepSpeed = (int) (weapon.template.item_weapon_wepspeed);
|
||||
|
||||
if (weapon.getBonusPercent(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None) != 0f) //add weapon speed bonus
|
||||
wepSpeed *= (1 + weapon.getBonus(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None));
|
||||
|
||||
if (attacker.getBonuses() != null && attacker.getBonuses().getFloatPercentAll(mbEnums.ModType.AttackDelay, mbEnums.SourceType.None) != 0f) //add effects speed bonus
|
||||
wepSpeed *= (1 + attacker.getBonuses().getFloatPercentAll(mbEnums.ModType.AttackDelay, mbEnums.SourceType.None));
|
||||
|
||||
if (wepSpeed < 10)
|
||||
wepSpeed = 10; //Old was 10, but it can be reached lower with legit buffs,effects.
|
||||
|
||||
delay = (long)wepSpeed * 100L;
|
||||
}
|
||||
|
||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob))
|
||||
((Mob) attacker).nextAttackTime = System.currentTimeMillis() + delay;
|
||||
|
||||
if (inRange) {
|
||||
|
||||
if(attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)){
|
||||
if(!attacker.getTimestamps().contains(slot.name()+"Attack")){
|
||||
attacker.getTimestamps().put(slot.name()+"Attack", System.currentTimeMillis() - 1000);
|
||||
} else if(System.currentTimeMillis() < attacker.getTimestamps().get(slot.name()+"Attack") + delay){
|
||||
setAutoAttackJob(attacker,slot,delay);
|
||||
return;
|
||||
}
|
||||
attackRange += weapon.template.item_weapon_max_range * rangeMod;
|
||||
}
|
||||
|
||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob))
|
||||
if (((Mob) attacker).isSiege())
|
||||
attackRange = 300;
|
||||
|
||||
//handle retaliate
|
||||
float distanceSquared = attacker.loc.distanceSquared(target.loc);
|
||||
|
||||
boolean inRange = false;
|
||||
if (AbstractCharacter.IsAbstractCharacter(target)) {
|
||||
if (((AbstractCharacter) target).combatTarget == null || !((AbstractCharacter) target).combatTarget.isAlive()) {
|
||||
((AbstractCharacter) target).combatTarget = attacker;
|
||||
if (target.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter) && ((AbstractCharacter) target).isCombat())
|
||||
combatCycle((AbstractCharacter) target, attacker);
|
||||
}
|
||||
attackRange += ((AbstractCharacter) target).calcHitBox();
|
||||
} else {
|
||||
//need to handle building attacks range calculations here
|
||||
}
|
||||
|
||||
// take stamina away from attacker if its not a mob
|
||||
if (weapon != null && !attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) {
|
||||
//check if Out of Stamina
|
||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) {
|
||||
if (attacker.getStamina() < (weapon.template.item_wt / 3f)) {
|
||||
//set auto attack job
|
||||
setAutoAttackJob(attacker, slot, delay);
|
||||
return;
|
||||
}
|
||||
}
|
||||
float stam = weapon.template.item_wt / 3f;
|
||||
stam = (stam < 1) ? 1 : stam;
|
||||
attacker.modifyStamina(-(stam), attacker, true);
|
||||
} else
|
||||
attacker.modifyStamina(1, attacker, true);
|
||||
attackRange += 4; // need to add 4 to the attack range to offset where the client stops short of legitimate range
|
||||
|
||||
//cancel things that are cancelled by an attack
|
||||
|
||||
attacker.cancelOnAttackSwing();
|
||||
|
||||
//declare relevant variables
|
||||
|
||||
int min = attacker.minDamageHandOne;
|
||||
int max = attacker.maxDamageHandOne;
|
||||
int atr = attacker.atrHandOne;
|
||||
|
||||
//get the proper stats based on which slot is attacking
|
||||
|
||||
if (slot == mbEnums.EquipSlotType.LHELD) {
|
||||
min = attacker.minDamageHandTwo;
|
||||
max = attacker.maxDamageHandTwo;
|
||||
atr = attacker.atrHandTwo;
|
||||
}
|
||||
|
||||
//apply weapon powers before early exit for miss or passives
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int def = 0;
|
||||
|
||||
if (AbstractCharacter.IsAbstractCharacter(target))
|
||||
def = ((AbstractCharacter) target).defenseRating;
|
||||
|
||||
//calculate hit chance based off ATR and DEF
|
||||
|
||||
int hitChance;
|
||||
if (def == 0)
|
||||
def = 1;
|
||||
float dif = atr * 1f / def;
|
||||
|
||||
if (dif <= 0.8f)
|
||||
hitChance = 4;
|
||||
else
|
||||
hitChance = ((int) (450 * (dif - 0.8f)) + 4);
|
||||
|
||||
if (target.getObjectType() == mbEnums.GameObjectType.Building)
|
||||
hitChance = 100;
|
||||
int passiveAnim = getPassiveAnimation(mbEnums.PassiveType.None); // checking for a miss due to ATR vs Def
|
||||
if (ThreadLocalRandom.current().nextInt(100) > hitChance) {
|
||||
TargetedActionMsg msg = new TargetedActionMsg(attacker, target, 0f, passiveAnim);
|
||||
|
||||
if (target.getObjectType() == mbEnums.GameObjectType.PlayerCharacter)
|
||||
DispatchManager.dispatchMsgToInterestArea(target, msg, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
else
|
||||
DispatchManager.sendToAllInRange(attacker, msg);
|
||||
|
||||
//we need to send the animation even if the attacker misses
|
||||
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template, null, slot));
|
||||
DispatchManager.sendToAllInRange(target, cmm);
|
||||
|
||||
//set auto attack job
|
||||
setAutoAttackJob(attacker, slot, delay);
|
||||
float distance = target.loc.distance(attacker.loc);
|
||||
if (attackRange > 25 && attacker.isMoving()) {
|
||||
//cannot shoot bow while moving;
|
||||
return;
|
||||
}
|
||||
|
||||
//calculate passive chances only if target is AbstractCharacter
|
||||
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 * attackRange)
|
||||
inRange = true;
|
||||
break;
|
||||
case Building:
|
||||
if (attackRange > 15) {
|
||||
float rangeSquared = (attackRange + target.getBounds().getHalfExtents().x) * (attackRange + target.getBounds().getHalfExtents().x);
|
||||
//float distanceSquared = attacker.loc.distanceSquared(target.loc);
|
||||
if (distanceSquared < rangeSquared) {
|
||||
inRange = true;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
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) * 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;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (EnumSet.of(mbEnums.GameObjectType.PlayerCharacter, mbEnums.GameObjectType.NPC, mbEnums.GameObjectType.Mob).contains(target.getObjectType())) {
|
||||
mbEnums.PassiveType passiveType = mbEnums.PassiveType.None;
|
||||
int hitRoll = ThreadLocalRandom.current().nextInt(100);
|
||||
//get delay for the auto attack job
|
||||
long delay = 5000;
|
||||
|
||||
float dodgeChance = ((AbstractCharacter) target).getPassiveChance("Dodge", attacker.getLevel(), true);
|
||||
float blockChance = ((AbstractCharacter) target).getPassiveChance("Block", attacker.getLevel(), true);
|
||||
float parryChance = ((AbstractCharacter) target).getPassiveChance("Parry", attacker.getLevel(), true);
|
||||
//if (weapon != null) {
|
||||
|
||||
// Passive chance clamped at 75
|
||||
// int wepSpeed = (int) (weapon.template.item_weapon_wepspeed);
|
||||
|
||||
dodgeChance = Math.max(0, Math.min(75, dodgeChance));
|
||||
blockChance = Math.max(0, Math.min(75, blockChance));
|
||||
parryChance = Math.max(0, Math.min(75, parryChance));
|
||||
// if (weapon.getBonusPercent(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None) != 0f) //add weapon speed bonus
|
||||
// wepSpeed *= (1 + weapon.getBonus(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None));
|
||||
|
||||
if (hitRoll < dodgeChance)
|
||||
passiveType = mbEnums.PassiveType.Dodge;
|
||||
else if (hitRoll < blockChance)
|
||||
passiveType = mbEnums.PassiveType.Block;
|
||||
else if (hitRoll < parryChance)
|
||||
passiveType = mbEnums.PassiveType.Parry;
|
||||
// if (attacker.getBonuses() != null && attacker.getBonuses().getFloatPercentAll(mbEnums.ModType.AttackDelay, mbEnums.SourceType.None) != 0f) //add effects speed bonus
|
||||
// wepSpeed *= (1 + attacker.getBonuses().getFloatPercentAll(mbEnums.ModType.AttackDelay, mbEnums.SourceType.None));
|
||||
|
||||
// if (wepSpeed < 10)
|
||||
// wepSpeed = 10; //Old was 10, but it can be reached lower with legit buffs,effects.
|
||||
|
||||
// delay = wepSpeed * 100L;
|
||||
//}
|
||||
|
||||
if(attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)){
|
||||
if(slot.equals(mbEnums.EquipSlotType.RHELD)){
|
||||
delay = (long)(attacker.speedHandOne * 100L);
|
||||
}else{
|
||||
delay = (long)(attacker.speedHandTwo * 100L);
|
||||
}
|
||||
}
|
||||
|
||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob))
|
||||
((Mob) attacker).nextAttackTime = System.currentTimeMillis() + delay;
|
||||
delay += addedDelay;
|
||||
if (inRange) {
|
||||
|
||||
//handle retaliate
|
||||
if (AbstractCharacter.IsAbstractCharacter(target)) {
|
||||
if (((AbstractCharacter) target).combatTarget == null || !((AbstractCharacter) target).combatTarget.isAlive()) {
|
||||
((AbstractCharacter) target).combatTarget = attacker;
|
||||
if (target.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter) && ((AbstractCharacter) target).isCombat())
|
||||
combatCycle((AbstractCharacter) target, attacker,0);
|
||||
}
|
||||
}
|
||||
|
||||
// take stamina away from attacker if its not a mob
|
||||
if (weapon != null && !attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) {
|
||||
//check if Out of Stamina
|
||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) {
|
||||
if (attacker.getStamina() < (weapon.template.item_wt / 3f)) {
|
||||
//set auto attack job
|
||||
setAutoAttackJob(attacker, slot, delay);
|
||||
return;
|
||||
}
|
||||
}
|
||||
float stam = weapon.template.item_wt / 3f;
|
||||
stam = (stam < 1) ? 1 : stam;
|
||||
attacker.modifyStamina(-(stam), attacker, true);
|
||||
} else
|
||||
attacker.modifyStamina(1, attacker, true);
|
||||
|
||||
//cancel things that are cancelled by an attack
|
||||
|
||||
attacker.cancelOnAttackSwing();
|
||||
|
||||
//declare relevant variables
|
||||
|
||||
int min = attacker.minDamageHandOne;
|
||||
int max = attacker.maxDamageHandOne;
|
||||
int atr = attacker.atrHandOne;
|
||||
|
||||
//get the proper stats based on which slot is attacking
|
||||
|
||||
if (slot == mbEnums.EquipSlotType.LHELD) {
|
||||
min = attacker.minDamageHandTwo;
|
||||
max = attacker.maxDamageHandTwo;
|
||||
atr = attacker.atrHandTwo;
|
||||
}
|
||||
|
||||
//apply weapon powers before early exit for miss or passives
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!passiveType.equals(mbEnums.PassiveType.None)) {
|
||||
passiveAnim = getPassiveAnimation(passiveType);
|
||||
TargetedActionMsg msg = new TargetedActionMsg(attacker, passiveAnim, target, passiveType.value);
|
||||
int def = 0;
|
||||
|
||||
if (AbstractCharacter.IsAbstractCharacter(target))
|
||||
def = ((AbstractCharacter) target).defenseRating;
|
||||
|
||||
//calculate hit chance based off ATR and DEF
|
||||
|
||||
int hitChance;
|
||||
if (def == 0)
|
||||
def = 1;
|
||||
float dif = atr * 1f / def;
|
||||
|
||||
if (dif <= 0.8f)
|
||||
hitChance = 4;
|
||||
else
|
||||
hitChance = ((int) (450 * (dif - 0.8f)) + 4);
|
||||
|
||||
if (target.getObjectType() == mbEnums.GameObjectType.Building)
|
||||
hitChance = 100;
|
||||
int passiveAnim = getPassiveAnimation(mbEnums.PassiveType.None); // checking for a miss due to ATR vs Def
|
||||
if (ThreadLocalRandom.current().nextInt(100) > hitChance) {
|
||||
TargetedActionMsg msg = new TargetedActionMsg(attacker, target, 0f, passiveAnim);
|
||||
|
||||
if (target.getObjectType() == mbEnums.GameObjectType.PlayerCharacter)
|
||||
DispatchManager.dispatchMsgToInterestArea(target, msg, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
else
|
||||
DispatchManager.sendToAllInRange(attacker, msg);
|
||||
|
||||
//we need to send the animation even if the attacker misses
|
||||
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template, null, slot));
|
||||
DispatchManager.sendToAllInRange(target, cmm);
|
||||
|
||||
//set auto attack job
|
||||
setAutoAttackJob(attacker, slot, delay);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//check for proccing
|
||||
checkForProc(attacker,target,weapon);
|
||||
//calculate passive chances only if target is AbstractCharacter
|
||||
|
||||
//calculate the base damage
|
||||
int damage = ThreadLocalRandom.current().nextInt(min, max + 1);
|
||||
if (damage == 0) {
|
||||
//set auto attack job
|
||||
setAutoAttackJob(attacker, slot, delay);
|
||||
return;
|
||||
}
|
||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob) && ((Mob) attacker).isPet())
|
||||
calculatePetDamage(attacker);
|
||||
if (EnumSet.of(mbEnums.GameObjectType.PlayerCharacter, mbEnums.GameObjectType.NPC, mbEnums.GameObjectType.Mob).contains(target.getObjectType())) {
|
||||
mbEnums.PassiveType passiveType = mbEnums.PassiveType.None;
|
||||
int hitRoll = ThreadLocalRandom.current().nextInt(100);
|
||||
|
||||
//get the damage type
|
||||
float dodgeChance = ((AbstractCharacter) target).getPassiveChance("Dodge", attacker.getLevel(), true);
|
||||
float blockChance = ((AbstractCharacter) target).getPassiveChance("Block", attacker.getLevel(), true);
|
||||
float parryChance = ((AbstractCharacter) target).getPassiveChance("Parry", attacker.getLevel(), true);
|
||||
|
||||
mbEnums.DamageType damageType;
|
||||
// Passive chance clamped at 75
|
||||
|
||||
if (attacker.charItemManager.getEquipped().get(slot) == null) {
|
||||
damageType = mbEnums.DamageType.CRUSHING;
|
||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob))
|
||||
if (((Mob) attacker).isSiege())
|
||||
damageType = mbEnums.DamageType.SIEGE;
|
||||
} else {
|
||||
damageType = (mbEnums.DamageType) attacker.charItemManager.getEquipped().get(slot).template.item_weapon_damage.keySet().toArray()[0];
|
||||
}
|
||||
dodgeChance = Math.max(0, Math.min(75, dodgeChance));
|
||||
blockChance = Math.max(0, Math.min(75, blockChance));
|
||||
parryChance = Math.max(0, Math.min(75, parryChance));
|
||||
|
||||
//get resists
|
||||
if (hitRoll < dodgeChance)
|
||||
passiveType = mbEnums.PassiveType.Dodge;
|
||||
else if (hitRoll < blockChance)
|
||||
passiveType = mbEnums.PassiveType.Block;
|
||||
else if (hitRoll < parryChance)
|
||||
passiveType = mbEnums.PassiveType.Parry;
|
||||
|
||||
Resists resists;
|
||||
|
||||
if (!AbstractCharacter.IsAbstractCharacter(target))
|
||||
resists = ((Building) target).getResists(); //this is a building
|
||||
else
|
||||
resists = ((AbstractCharacter) target).getResists(); //this is a character
|
||||
if (!passiveType.equals(mbEnums.PassiveType.None)) {
|
||||
passiveAnim = getPassiveAnimation(passiveType);
|
||||
TargetedActionMsg msg = new TargetedActionMsg(attacker, passiveAnim, target, passiveType.value);
|
||||
|
||||
if (AbstractCharacter.IsAbstractCharacter(target)) {
|
||||
AbstractCharacter absTarget = (AbstractCharacter) target;
|
||||
if (target.getObjectType() == mbEnums.GameObjectType.PlayerCharacter)
|
||||
DispatchManager.dispatchMsgToInterestArea(target, msg, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
|
||||
//check damage shields
|
||||
|
||||
PlayerBonuses bonuses = absTarget.getBonuses();
|
||||
|
||||
if (bonuses != null) {
|
||||
|
||||
ConcurrentHashMap<AbstractEffectModifier, DamageShield> damageShields = bonuses.getDamageShields();
|
||||
float total = 0;
|
||||
|
||||
for (DamageShield ds : damageShields.values()) {
|
||||
|
||||
//get amount to damage back
|
||||
|
||||
float amount;
|
||||
|
||||
if (ds.usePercent())
|
||||
amount = damage * ds.getAmount() / 100;
|
||||
else
|
||||
amount = ds.getAmount();
|
||||
|
||||
//get resisted damage for damagetype
|
||||
|
||||
if (resists != null)
|
||||
amount = resists.getResistedDamage(absTarget, attacker, ds.getDamageType(), amount, 0);
|
||||
total += amount;
|
||||
}
|
||||
|
||||
if (total > 0) {
|
||||
//apply Damage back
|
||||
attacker.modifyHealth(-total, absTarget, true);
|
||||
TargetedActionMsg cmm = new TargetedActionMsg(attacker, attacker, total, 0);
|
||||
DispatchManager.sendToAllInRange(target, cmm);
|
||||
}
|
||||
}
|
||||
|
||||
if (resists != null) {
|
||||
|
||||
//check for damage type immunities
|
||||
|
||||
if (resists.immuneTo(damageType)) {
|
||||
//set auto attack job
|
||||
//we need to send the animation even if the attacker misses
|
||||
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template, null, slot));
|
||||
DispatchManager.sendToAllInRange(target, cmm);
|
||||
//set auto attack job
|
||||
setAutoAttackJob(attacker, slot, delay);
|
||||
return;
|
||||
}
|
||||
//calculate resisted damage including fortitude
|
||||
|
||||
damage = (int) resists.getResistedDamage(attacker, (AbstractCharacter) target, damageType, damage, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//remove damage from target health
|
||||
//calculate the base damage
|
||||
int damage = ThreadLocalRandom.current().nextInt(min, max + 1);
|
||||
if (damage == 0) {
|
||||
//set auto attack job
|
||||
setAutoAttackJob(attacker, slot, delay);
|
||||
return;
|
||||
}
|
||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob) && ((Mob) attacker).isPet())
|
||||
calculatePetDamage(attacker);
|
||||
|
||||
if (damage > 0) {
|
||||
//get the damage type
|
||||
|
||||
if (AbstractCharacter.IsAbstractCharacter(target))
|
||||
((AbstractCharacter) target).modifyHealth(-damage, attacker, true);
|
||||
mbEnums.DamageType damageType;
|
||||
|
||||
if (attacker.charItemManager.getEquipped().get(slot) == null) {
|
||||
damageType = mbEnums.DamageType.CRUSHING;
|
||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob))
|
||||
if (((Mob) attacker).isSiege())
|
||||
damageType = mbEnums.DamageType.SIEGE;
|
||||
} else {
|
||||
damageType = (mbEnums.DamageType) attacker.charItemManager.getEquipped().get(slot).template.item_weapon_damage.keySet().toArray()[0];
|
||||
}
|
||||
|
||||
//get resists
|
||||
|
||||
Resists resists;
|
||||
|
||||
if (!AbstractCharacter.IsAbstractCharacter(target))
|
||||
resists = ((Building) target).getResists(); //this is a building
|
||||
else
|
||||
((Building) target).modifyHealth(-damage, attacker);
|
||||
resists = ((AbstractCharacter) target).getResists(); //this is a character
|
||||
|
||||
int attackAnim = getSwingAnimation(null, null, slot);
|
||||
if (attacker.charItemManager.getEquipped().get(slot) != null) {
|
||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) {
|
||||
DeferredPowerJob weaponPower = ((PlayerCharacter) attacker).getWeaponPower();
|
||||
attackAnim = getSwingAnimation(weapon.template, weaponPower, slot);
|
||||
} else {
|
||||
attackAnim = getSwingAnimation(weapon.template, null, slot);
|
||||
if (AbstractCharacter.IsAbstractCharacter(target)) {
|
||||
AbstractCharacter absTarget = (AbstractCharacter) target;
|
||||
|
||||
//check damage shields
|
||||
|
||||
PlayerBonuses bonuses = absTarget.getBonuses();
|
||||
|
||||
if (bonuses != null) {
|
||||
|
||||
ConcurrentHashMap<AbstractEffectModifier, DamageShield> damageShields = bonuses.getDamageShields();
|
||||
float total = 0;
|
||||
|
||||
for (DamageShield ds : damageShields.values()) {
|
||||
|
||||
//get amount to damage back
|
||||
|
||||
float amount;
|
||||
|
||||
if (ds.usePercent())
|
||||
amount = damage * ds.getAmount() / 100;
|
||||
else
|
||||
amount = ds.getAmount();
|
||||
|
||||
//get resisted damage for damagetype
|
||||
|
||||
if (resists != null)
|
||||
amount = resists.getResistedDamage(absTarget, attacker, ds.getDamageType(), amount, 0);
|
||||
total += amount;
|
||||
}
|
||||
|
||||
if (total > 0) {
|
||||
//apply Damage back
|
||||
attacker.modifyHealth(-total, absTarget, true);
|
||||
TargetedActionMsg cmm = new TargetedActionMsg(attacker, attacker, total, 0);
|
||||
DispatchManager.sendToAllInRange(target, cmm);
|
||||
}
|
||||
}
|
||||
|
||||
if (resists != null) {
|
||||
|
||||
//check for damage type immunities
|
||||
|
||||
if (resists.immuneTo(damageType)) {
|
||||
//set auto attack job
|
||||
//we need to send the animation even if the attacker misses
|
||||
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template, null, slot));
|
||||
DispatchManager.sendToAllInRange(target, cmm);
|
||||
setAutoAttackJob(attacker, slot, delay);
|
||||
return;
|
||||
}
|
||||
//calculate resisted damage including fortitude
|
||||
if(attacker.getObjectType().equals(mbEnums.GameObjectType.Mob))
|
||||
if(((Mob)attacker).isPet())
|
||||
damage *= attacker.level * 0.1f;
|
||||
damage = (int) resists.getResistedDamage(attacker, (AbstractCharacter) target, damageType, damage, 0);
|
||||
}
|
||||
}
|
||||
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) damage, attackAnim);
|
||||
DispatchManager.sendToAllInRange(target, cmm);
|
||||
|
||||
//remove damage from target health
|
||||
|
||||
if (damage > 0) {
|
||||
|
||||
if (AbstractCharacter.IsAbstractCharacter(target))
|
||||
((AbstractCharacter) target).modifyHealth(-damage, attacker, true);
|
||||
else
|
||||
((Building) target).modifyHealth(-damage, attacker);
|
||||
|
||||
int attackAnim = getSwingAnimation(null, null, slot);
|
||||
if (attacker.charItemManager.getEquipped().get(slot) != null) {
|
||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) {
|
||||
DeferredPowerJob weaponPower = ((PlayerCharacter) attacker).getWeaponPower();
|
||||
attackAnim = getSwingAnimation(weapon.template, weaponPower, slot);
|
||||
} else {
|
||||
attackAnim = getSwingAnimation(weapon.template, null, slot);
|
||||
}
|
||||
}
|
||||
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) damage, attackAnim);
|
||||
DispatchManager.sendToAllInRange(target, cmm);
|
||||
}
|
||||
}
|
||||
|
||||
//set auto attack job
|
||||
setAutoAttackJob(attacker, slot, delay);
|
||||
} catch (Exception ex) {
|
||||
cancelAutoAttackJob(attacker,slot);
|
||||
//Logger.error("COMBAT CAUGHT ERROR: " + ex.getMessage());
|
||||
} finally {
|
||||
target.combatLock.writeLock().unlock();
|
||||
}
|
||||
|
||||
//set auto attack job
|
||||
setAutoAttackJob(attacker, slot, delay);
|
||||
|
||||
}
|
||||
|
||||
public static void toggleCombat(boolean toggle, ClientConnection origin) {
|
||||
@@ -558,7 +559,7 @@ public enum CombatManager {
|
||||
}
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
@@ -567,15 +568,15 @@ public enum CombatManager {
|
||||
int random;
|
||||
|
||||
//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)) {
|
||||
anim = wb.weapon_attack_anim_right.get(0)[0];
|
||||
if (dpj != null) {
|
||||
random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size());
|
||||
anim = wb.weapon_attack_anim_right.get(random)[0];
|
||||
}
|
||||
} else {
|
||||
anim = wb.weapon_attack_anim_left.get(0)[0];
|
||||
}else {
|
||||
anim = wb.weapon_attack_anim_left.get(0)[0];
|
||||
if (dpj != null) {
|
||||
random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size());
|
||||
anim = wb.weapon_attack_anim_left.get(random)[0];
|
||||
@@ -591,7 +592,7 @@ public enum CombatManager {
|
||||
random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size());
|
||||
anim = wb.weapon_attack_anim_right.get(random)[0];
|
||||
}
|
||||
} else {
|
||||
}else {
|
||||
anim = wb.weapon_attack_anim_left.get(0)[0];
|
||||
if (dpj != null) {
|
||||
random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size());
|
||||
@@ -601,8 +602,8 @@ public enum CombatManager {
|
||||
return anim;
|
||||
}
|
||||
|
||||
public static int getPassiveAnimation(mbEnums.PassiveType passiveType) {
|
||||
switch (passiveType) {
|
||||
public static int getPassiveAnimation(mbEnums.PassiveType passiveType){
|
||||
switch(passiveType){
|
||||
case Block:
|
||||
return COMBAT_BLOCK_ANIMATION;
|
||||
case Parry:
|
||||
@@ -617,7 +618,10 @@ public enum CombatManager {
|
||||
public static void setAutoAttackJob(AbstractCharacter attacker, mbEnums.EquipSlotType slot, long delay) {
|
||||
//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.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter) == false)
|
||||
return; //mobs dont submit auto attack jobs
|
||||
|
||||
if(attacker.getTimestamps().containsKey("Attack" + slot.name()) && attacker.getTimestamps().get("Attack" + slot.name()) > System.currentTimeMillis())
|
||||
return;
|
||||
|
||||
attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis() + delay);
|
||||
@@ -626,7 +630,7 @@ public enum CombatManager {
|
||||
ConcurrentHashMap<String, JobContainer> timers = attacker.getTimers();
|
||||
|
||||
if (timers != null) {
|
||||
AttackJob aj = new AttackJob(attacker, slot.ordinal(), true);
|
||||
AttackJob aj = new AttackJob(attacker, slot.ordinal(), true, attacker.getCombatTarget());
|
||||
JobContainer job;
|
||||
job = JobScheduler.getInstance().scheduleJob(aj, (System.currentTimeMillis() + delay)); // offset 1 millisecond so no overlap issue
|
||||
timers.put("Attack" + slot.name(), job);
|
||||
@@ -634,8 +638,22 @@ public enum CombatManager {
|
||||
Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID());
|
||||
|
||||
}
|
||||
public static void cancelAutoAttackJob(AbstractCharacter attacker, mbEnums.EquipSlotType slot) {
|
||||
|
||||
public static int calculatePetDamage(AbstractCharacter agent) {
|
||||
if(attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter) == false)
|
||||
return;
|
||||
attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis());
|
||||
|
||||
//handle auto attack job creation
|
||||
ConcurrentHashMap<String, JobContainer> timers = attacker.getTimers();
|
||||
|
||||
if (timers != null) {
|
||||
timers.get("Attack" + slot.name()).cancelJob();
|
||||
} else
|
||||
Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID());
|
||||
|
||||
}
|
||||
public static void calculatePetDamage(AbstractCharacter agent) {
|
||||
//damage calc for pet
|
||||
float range;
|
||||
float damage;
|
||||
@@ -647,9 +665,7 @@ public enum CombatManager {
|
||||
dmgMultiplier += agent.getLevel() * 0.1f;
|
||||
range = (float) (maxDmg - minDmg);
|
||||
damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2;
|
||||
return (int) (damage * dmgMultiplier);
|
||||
}
|
||||
|
||||
public static double getMinDmg(double min, AbstractCharacter agent) {
|
||||
int primary = agent.getStatStrCurrent();
|
||||
int secondary = agent.getStatDexCurrent();
|
||||
@@ -657,7 +673,6 @@ public enum CombatManager {
|
||||
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));
|
||||
}
|
||||
|
||||
public static double getMaxDmg(double max, AbstractCharacter agent) {
|
||||
int primary = agent.getStatStrCurrent();
|
||||
int secondary = agent.getStatDexCurrent();
|
||||
@@ -665,20 +680,4 @@ public enum CombatManager {
|
||||
int masteryLevel = 0;
|
||||
return max * (pow(0.0124 * primary + 0.118 * (primary - 0.75), 0.5) + pow(0.0022 * secondary + 0.028 * (secondary - 0.75), 0.5) + 0.0075 * (focusLevel + masteryLevel));
|
||||
}
|
||||
|
||||
public static void checkForProc(AbstractCharacter attacker, AbstractWorldObject target, Item weapon){
|
||||
|
||||
if(weapon == null) // cant proc without a weapon
|
||||
return;
|
||||
|
||||
for(Effect eff : weapon.effects.values()){
|
||||
for(AbstractEffectModifier mod : eff.getEffectsBase().getModifiers()){
|
||||
if(mod.modType.equals(mbEnums.ModType.WeaponProc))
|
||||
if(ThreadLocalRandom.current().nextInt(0,101) < 6)
|
||||
((WeaponProcEffectModifier)mod).applyProc(attacker,target);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public enum ForgeManager implements Runnable {
|
||||
// Early exit for completed workOrders loaded from disk
|
||||
// or vendors who were re-deeded with items still cooking.
|
||||
|
||||
if (workOrder.vendor == null || workOrder.runCompleted.get())
|
||||
if (workOrder.vendor == null && workOrder.runCompleted.get())
|
||||
continue;
|
||||
|
||||
// This workOrder has completed production.
|
||||
@@ -265,12 +265,12 @@ public enum ForgeManager implements Runnable {
|
||||
|
||||
// Assign a prefix and suffix to this item if random rolled
|
||||
|
||||
if (workOrder.prefixToken == 0 && workOrder.vendor.getItemModTable().contains((template.modTable)))
|
||||
if (workOrder.prefixToken == 0)
|
||||
forgedItem.prefixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.PREFIX, template.modTable);
|
||||
else
|
||||
forgedItem.prefixToken = workOrder.prefixToken;
|
||||
|
||||
if (workOrder.suffixToken == 0 && workOrder.vendor.getItemModTable().contains((template.modTable)))
|
||||
if (workOrder.suffixToken == 0)
|
||||
forgedItem.suffixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.SUFFIX, template.modTable);
|
||||
else
|
||||
forgedItem.suffixToken = workOrder.suffixToken;
|
||||
|
||||
@@ -102,7 +102,7 @@ public enum ItemManager {
|
||||
if (characterSkill == null)
|
||||
return false;
|
||||
|
||||
if (characterSkill.getModifiedAmountBeforeMods() >= required_value)
|
||||
if (characterSkill.getModifiedAmountBeforeMods() > required_value)
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@@ -172,33 +172,16 @@ public enum PowersManager {
|
||||
public static void usePower(final PerformActionMsg msg, ClientConnection origin,
|
||||
boolean sendCastToSelf) {
|
||||
|
||||
if (ConfigManager.MB_RULESET.getValue().equals("LORE")) {
|
||||
if (ConfigManager.MB_RULESET.getValue().equals("LORE") && getPowerByToken(msg.getPowerUsedID()).ignoreLore() == false) {
|
||||
PowersBase pb = PowersManager.powersBaseByToken.get(msg.getPowerUsedID());
|
||||
PlayerCharacter caster = origin.getPlayerCharacter();
|
||||
PlayerCharacter target = PlayerCharacter.getFromCache(msg.getTargetID());
|
||||
if (pb != null && pb.enforceLore()) {
|
||||
if (pb != null && pb.isHarmful == false) {
|
||||
//if (caster.guild.equals(Guild.getErrantGuild()))
|
||||
// return;
|
||||
|
||||
if (target != null && caster.guild.getGuildType().equals(target.guild.getGuildType()) == false && target.getObjectType().equals(GameObjectType.Building) == false) {
|
||||
RecyclePowerMsg recyclePowerMsg = new RecyclePowerMsg(msg.getPowerUsedID());
|
||||
Dispatch dispatch = Dispatch.borrow(origin.getPlayerCharacter(), recyclePowerMsg);
|
||||
DispatchManager.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||
|
||||
// Send Fail to cast message
|
||||
PlayerCharacter pc = SessionManager
|
||||
.getPlayerCharacter(origin);
|
||||
|
||||
if (pc != null) {
|
||||
sendPowerMsg(pc, 2, msg);
|
||||
if (pc.isCasting()) {
|
||||
pc.update();
|
||||
}
|
||||
|
||||
pc.setIsCasting(false);
|
||||
}
|
||||
if (target != null && caster.guild.getGuildType().equals(target.guild.getGuildType()) == false && target.getObjectType().equals(GameObjectType.Building) == false)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -925,6 +908,10 @@ public enum PowersManager {
|
||||
if (pb.isHarmful())
|
||||
mobTarget.handleDirectAggro(playerCharacter);
|
||||
}
|
||||
//Power is aiding a target, handle aggro if combat target is a Mob.
|
||||
if (!pb.isHarmful() && target.getObjectType() == GameObjectType.PlayerCharacter) {
|
||||
PlayerCharacter pcTarget = (PlayerCharacter) target;
|
||||
}
|
||||
|
||||
// update target of used power timer
|
||||
|
||||
@@ -946,7 +933,8 @@ public enum PowersManager {
|
||||
continue;
|
||||
// If something blocks the action, then stop
|
||||
|
||||
if (ab.blocked(target,pb.vampDrain)) {
|
||||
if (ab.blocked(target, pb, trains)) {
|
||||
|
||||
PowersManager.sendEffectMsg(playerCharacter, 5, ab, pb);
|
||||
continue;
|
||||
}
|
||||
@@ -1121,7 +1109,7 @@ public enum PowersManager {
|
||||
continue;
|
||||
// If something blocks the action, then stop
|
||||
|
||||
if (ab.blocked(target,pb.vampDrain))
|
||||
if (ab.blocked(target, pb, trains))
|
||||
continue;
|
||||
// TODO handle overwrite stack order here
|
||||
String stackType = ab.getStackType();
|
||||
@@ -1435,7 +1423,7 @@ public enum PowersManager {
|
||||
if (trains < ab.getMinTrains() || trains > ab.getMaxTrains())
|
||||
continue;
|
||||
// If something blocks the action, then stop
|
||||
if (ab.blocked(target,pb.vampDrain))
|
||||
if (ab.blocked(target, pb, trains))
|
||||
// sendPowerMsg(pc, 5, msg);
|
||||
continue;
|
||||
// TODO handle overwrite stack order here
|
||||
|
||||
@@ -12,6 +12,7 @@ package engine.jobs;
|
||||
import engine.gameManager.CombatManager;
|
||||
import engine.job.AbstractJob;
|
||||
import engine.objects.AbstractCharacter;
|
||||
import engine.objects.AbstractWorldObject;
|
||||
|
||||
public class AttackJob extends AbstractJob {
|
||||
|
||||
@@ -19,16 +20,20 @@ public class AttackJob extends AbstractJob {
|
||||
private final int slot;
|
||||
private final boolean success;
|
||||
|
||||
public AttackJob(AbstractCharacter source, int slot, boolean success) {
|
||||
public final AbstractWorldObject target;
|
||||
|
||||
public AttackJob(AbstractCharacter source, int slot, boolean success, AbstractWorldObject target) {
|
||||
super();
|
||||
this.source = source;
|
||||
this.slot = slot;
|
||||
this.success = success;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doJob() {
|
||||
CombatManager.combatCycle(this.source, this.source.combatTarget);
|
||||
|
||||
CombatManager.combatCycle(this.source,target,0);
|
||||
}
|
||||
|
||||
public boolean success() {
|
||||
|
||||
@@ -84,11 +84,6 @@ public class WorkOrder implements Delayed {
|
||||
this.completionTime = jsonWorkOrder.getLong("completionTime");
|
||||
this.runCompleted.set(jsonWorkOrder.getBoolean("runCompleted"));
|
||||
|
||||
// Vendor sanity check. Might have been deleted
|
||||
|
||||
if (this.vendor == null)
|
||||
return;
|
||||
|
||||
JSONObject productionCostMap = jsonWorkOrder.getJSONObject("production_cost");
|
||||
|
||||
for (String key : productionCostMap.keySet()) {
|
||||
@@ -112,7 +107,6 @@ public class WorkOrder implements Delayed {
|
||||
for (Object o : tokenList) {
|
||||
int prefix = ((JSONArray) o).getInt(0);
|
||||
int suffix = ((JSONArray) o).getInt(1);
|
||||
|
||||
Item cookingItem = ForgeManager.forgeItem(this);
|
||||
cookingItem.prefixToken = prefix;
|
||||
cookingItem.suffixToken = suffix;
|
||||
@@ -135,8 +129,7 @@ public class WorkOrder implements Delayed {
|
||||
if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt))
|
||||
return 30; //30: That person cannot carry that item
|
||||
|
||||
if ((workOrder.prefixToken != 0 || workOrder.suffixToken != 0) &&
|
||||
!workOrder.vendor.getItemModTable().contains((template.modTable)))
|
||||
if (!workOrder.vendor.getItemModTable().contains((template.modTable)))
|
||||
return 59; //59: This hireling does not have this formula
|
||||
|
||||
if (!Warehouse.calcCostOverrun(workOrder).isEmpty())
|
||||
|
||||
+33
-42
@@ -831,22 +831,16 @@ public class mbEnums {
|
||||
SPIRES,
|
||||
SNARE,
|
||||
STUN,
|
||||
BLINDNESS,
|
||||
BLIND,
|
||||
ROOT,
|
||||
FEAR,
|
||||
CHARM,
|
||||
POWERINHIBITOR,
|
||||
POWERBLOCK,
|
||||
DEBUFF,
|
||||
STEAL,
|
||||
DRAIN;
|
||||
|
||||
public static DamageType getDamageType(String modName) {
|
||||
if(modName.toLowerCase().equals("blind"))
|
||||
modName = "BLINDNESS";
|
||||
|
||||
if(modName.toLowerCase().equals("powerblock"))
|
||||
modName = "POWERINHIBITOR";
|
||||
|
||||
DamageType damageType;
|
||||
if (modName.isEmpty())
|
||||
return DamageType.NONE;
|
||||
@@ -2721,45 +2715,42 @@ public class mbEnums {
|
||||
|
||||
public enum ResourceType {
|
||||
|
||||
GOLD(7, -1670881623, 2308551, 100000000, 50000),
|
||||
ADAMANT(1580003, 1557001525, -1741189964, 1000, 10),
|
||||
AGATE(1580009, -1096157543, 75173057, 2000, 20),
|
||||
ANTIMONY(1580014, 1256147265, 452320058, 1000, 10),
|
||||
AZOTH(1580012, -1205326951, 78329697, 2000, 20),
|
||||
BLOODSTONE(1580020, -1912381716, -1569826353, 500, 5),
|
||||
BRONZEWOOD(1580006, -519681813, 1334770447, 1000, 30),
|
||||
COAL(1580008, -1672872311, 2559427, 3000, 30),
|
||||
DIAMOND(1580010, 1540225085, -1730704107, 2000, 20),
|
||||
GALVOR(1580017, -1683992404, -1596311545, 2000, 5),
|
||||
IRON(1580002, -1673518119, 2504297, 2000, 20),
|
||||
LUMBER(1580004, -1628412684, -1603256692, 10000, 100),
|
||||
MANDRAKE(1580007, 1519910613, 1191391799, 1000, 10),
|
||||
MITHRIL(1580021, 626743397, -1761257186, 500, 5),
|
||||
OAK(1580005, -1653034775, 74767, 3000, 30),
|
||||
OBSIDIAN(1580019, 778019055, -697973233, 500, 5),
|
||||
ONYX(1580011, -1675952151, 2977263, 1000, 10),
|
||||
ORICHALK(1580013, -1468730955, -2036290524, 3000, 30),
|
||||
QUICKSILVER(1580016, -2081208434, -472884509, 1000, 10),
|
||||
STONE(1580000, -1094703863, 74856115, 10000, 100),
|
||||
SULFUR(1580015, -1763687412, -1586349421, 1000, 10),
|
||||
TRUESTEEL(1580001, -169012482, -317484979, 2000, 20),
|
||||
WORMWOOD(1580018, 1204785075, 1532478436, 500, 5);
|
||||
GOLD(7, 2308551, 100000000, 10),
|
||||
ADAMANT(1580003, -1741189964, 1000, 10),
|
||||
AGATE(1580009, 75173057, 2000, 10),
|
||||
ANTIMONY(1580014, 452320058, 1000, 10),
|
||||
AZOTH(1580012, 78329697, 2000, 10),
|
||||
BLOODSTONE(1580020, -1569826353, 500, 10),
|
||||
BRONZEWOOD(1580006, 1334770447, 500, 10),
|
||||
COAL(1580008, 2559427, 3000, 10),
|
||||
DIAMOND(1580010, -1730704107, 2000, 10),
|
||||
GALVOR(1580017, -1596311545, 2000, 10),
|
||||
IRON(1580002, 2504297, 2000, 10),
|
||||
LUMBER(1580004, -1603256692, 10000, 10),
|
||||
MANDRAKE(1580007, 1191391799, 1000, 10),
|
||||
MITHRIL(1580021, -1761257186, 500, 10),
|
||||
OAK(1580005, 74767, 3000, 10),
|
||||
OBSIDIAN(1580019, -697973233, 500, 10),
|
||||
ONYX(1580011, 2977263, 1000, 10),
|
||||
ORICHALK(1580013, -2036290524, 3000, 10),
|
||||
QUICKSILVER(1580016, -472884509, 1000, 10),
|
||||
STONE(1580000, 74856115, 10000, 10),
|
||||
SULFUR(1580015, -1586349421, 1000, 10),
|
||||
TRUESTEEL(1580001, -317484979, 2000, 10),
|
||||
WORMWOOD(1580018, 1532478436, 500, 10);
|
||||
|
||||
public static HashMap<Integer, ResourceType> templateLookup = new HashMap<>();
|
||||
public static HashMap<Integer, ResourceType> templateHashLookup = new HashMap<>();
|
||||
public static HashMap<Integer, ResourceType> resourceHashLookup = new HashMap<>();
|
||||
public static HashMap<Integer, ResourceType> resourceLookup = new HashMap<>();
|
||||
public static HashMap<Integer, ResourceType> hashLookup = new HashMap<>();
|
||||
public int templateID;
|
||||
public ItemTemplate template;
|
||||
public int resourceHash;
|
||||
public int templateHash;
|
||||
public int hash;
|
||||
public int deposit_limit;
|
||||
public int mine_production;
|
||||
|
||||
ResourceType(int templateID, int resourceHash, int templateHash, int deposit_limit, int mine_production) {
|
||||
ResourceType(int templateID, int hash, int deposit_limit, int mine_production) {
|
||||
this.templateID = templateID;
|
||||
this.template = ItemTemplate.templates.get(this.templateID);
|
||||
this.resourceHash = resourceHash;
|
||||
this.templateHash = templateHash;
|
||||
this.hash = hash;
|
||||
this.deposit_limit = deposit_limit;
|
||||
this.mine_production = mine_production;
|
||||
}
|
||||
@@ -2767,11 +2758,11 @@ public class mbEnums {
|
||||
public static void InitializeResourceTypes() {
|
||||
|
||||
for (ResourceType resourceType : ResourceType.values()) {
|
||||
templateLookup.put(resourceType.templateID, resourceType);
|
||||
templateHashLookup.put(resourceType.templateHash, resourceType);
|
||||
resourceHashLookup.put(resourceType.resourceHash, resourceType);
|
||||
resourceLookup.put(resourceType.templateID, resourceType);
|
||||
hashLookup.put(resourceType.hash, resourceType);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ public class MobAI {
|
||||
public static void attackPlayer(Mob mob, PlayerCharacter target) {
|
||||
|
||||
try {
|
||||
if (target == null || !target.isAlive() || !target.isActive()) {
|
||||
if(target == null || !target.isAlive() || !target.isActive() ) {
|
||||
mob.setCombatTarget(null);
|
||||
return;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ public class MobAI {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mob.behaviourType.callsForHelp)
|
||||
if (mob.behaviourType != null && mob.behaviourType.callsForHelp)
|
||||
mobCallForHelp(mob);
|
||||
|
||||
if (!MovementUtilities.inRangeDropAggro(mob, target)) {
|
||||
@@ -125,7 +125,7 @@ public class MobAI {
|
||||
if (mob.isMoving() && mob.getRange() > 20)
|
||||
return;
|
||||
|
||||
CombatManager.combatCycle(mob, target);
|
||||
CombatManager.combatCycle(mob, target,0);
|
||||
}
|
||||
|
||||
if (target.getPet() != null)
|
||||
@@ -159,7 +159,7 @@ public class MobAI {
|
||||
MovementManager.sendRWSSMsg(mob);
|
||||
|
||||
|
||||
CombatManager.combatCycle(mob, target);
|
||||
CombatManager.combatCycle(mob, target,0);
|
||||
|
||||
if (mob.isSiege()) {
|
||||
PowerProjectileMsg ppm = new PowerProjectileMsg(mob, target);
|
||||
@@ -175,7 +175,7 @@ public class MobAI {
|
||||
public static void attackMob(Mob mob, Mob target) {
|
||||
|
||||
try {
|
||||
if (mob == null || target == null)
|
||||
if(mob == null || target == null)
|
||||
return;
|
||||
|
||||
if (mob.getRange() >= 30 && mob.isMoving())
|
||||
@@ -183,7 +183,7 @@ public class MobAI {
|
||||
|
||||
//no weapons, default mob attack speed 3 seconds.
|
||||
|
||||
CombatManager.combatCycle(mob, target);
|
||||
CombatManager.combatCycle(mob, target,0);
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackMob" + " " + e.getMessage());
|
||||
@@ -975,36 +975,36 @@ public class MobAI {
|
||||
}
|
||||
|
||||
private static void hamletGuardAggro(Mob mob) {
|
||||
Realm realm = RealmMap.getRealmAtLocation(mob.loc);
|
||||
if (realm.getRealmName().equals("Uthgaard")) {
|
||||
HashSet<AbstractWorldObject> loadedMobs = WorldGrid.getObjectsInRangePartial(mob.loc, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_MOB);
|
||||
for (AbstractWorldObject awo : loadedMobs) {
|
||||
Mob targetMob = (Mob) awo;
|
||||
if (targetMob.equals(mob))
|
||||
continue;
|
||||
if (!targetMob.isAlive() || targetMob.despawned)
|
||||
continue;
|
||||
if (targetMob.isPet())
|
||||
continue;
|
||||
mob.combatTarget = targetMob;
|
||||
Realm realm = RealmMap.getRealmAtLocation(mob.loc);
|
||||
if(realm.getRealmName().equals("Uthgaard")){
|
||||
HashSet<AbstractWorldObject> loadedMobs = WorldGrid.getObjectsInRangePartial(mob.loc, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_MOB);
|
||||
for (AbstractWorldObject awo : loadedMobs) {
|
||||
Mob targetMob = (Mob) awo;
|
||||
if (targetMob.equals(mob))
|
||||
continue;
|
||||
if (!targetMob.isAlive() || targetMob.despawned)
|
||||
continue;
|
||||
if (targetMob.isPet())
|
||||
continue;
|
||||
mob.combatTarget = targetMob;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
HashSet<AbstractWorldObject> loadedPlayers = WorldGrid.getObjectsInRangePartial(mob.loc, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_PLAYER);
|
||||
for (AbstractWorldObject awo : loadedPlayers) {
|
||||
PlayerCharacter pc = (PlayerCharacter) awo;
|
||||
if (!pc.isAlive() || !pc.isActive())
|
||||
continue;
|
||||
if (pc.guild.equals(Guild.getErrantGuild())) {
|
||||
HashSet<AbstractWorldObject> loadedPlayers = WorldGrid.getObjectsInRangePartial(mob.loc, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_PLAYER);
|
||||
for (AbstractWorldObject awo : loadedPlayers) {
|
||||
PlayerCharacter pc = (PlayerCharacter) awo;
|
||||
if (!pc.isAlive() || !pc.isActive())
|
||||
continue;
|
||||
if (pc.guild.equals(Guild.getErrantGuild())) {
|
||||
mob.combatTarget = pc;
|
||||
return;
|
||||
}
|
||||
if (pc.guild.charter.equals(mob.guild.charter))
|
||||
continue;
|
||||
mob.combatTarget = pc;
|
||||
return;
|
||||
}
|
||||
if (pc.guild.charter.equals(mob.guild.charter))
|
||||
continue;
|
||||
mob.combatTarget = pc;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private static void defaultLogic(Mob mob) {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ArcMineChangeProductionMsgHandler extends AbstractClientMsgHandler
|
||||
|
||||
//make sure valid resource
|
||||
|
||||
mbEnums.ResourceType resource = mbEnums.ResourceType.resourceHashLookup.get(changeProductionMsg.getResourceHash());
|
||||
mbEnums.ResourceType resource = mbEnums.ResourceType.hashLookup.get(changeProductionMsg.getResourceHash());
|
||||
|
||||
if (resource == null)
|
||||
return true;
|
||||
|
||||
@@ -2,6 +2,7 @@ package engine.net.client.handlers;
|
||||
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.CombatManager;
|
||||
import engine.jobs.AttackJob;
|
||||
import engine.mbEnums;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.AttackCmdMsg;
|
||||
@@ -82,7 +83,29 @@ public class AttackCmdMsgHandler extends AbstractClientMsgHandler {
|
||||
if (playerCharacter.isSit())
|
||||
CombatManager.toggleSit(false, origin);
|
||||
|
||||
CombatManager.combatCycle(playerCharacter, target);
|
||||
long addedDelay = 0;
|
||||
//check if we are changing targets, cancel outstanding jobs if so
|
||||
if (playerCharacter.getTimers().containsKey("Attack" + mbEnums.EquipSlotType.RHELD)) {
|
||||
AttackJob ajR = ((AttackJob)playerCharacter.getTimers().get("Attack" + mbEnums.EquipSlotType.RHELD).getJob());
|
||||
if(ajR.target != null && !ajR.target.equals(target)){
|
||||
playerCharacter.getTimers().get("Attack" + mbEnums.EquipSlotType.RHELD).cancelJob();
|
||||
addedDelay = ajR.getStopTime() - System.currentTimeMillis();
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (playerCharacter.getTimers().containsKey("Attack" + mbEnums.EquipSlotType.LHELD)) {
|
||||
AttackJob ajL = ((AttackJob)playerCharacter.getTimers().get("Attack" + mbEnums.EquipSlotType.LHELD).getJob());
|
||||
if(ajL.target != null && !ajL.target.equals(target)){
|
||||
playerCharacter.getTimers().get("Attack" + mbEnums.EquipSlotType.LHELD).cancelJob();
|
||||
addedDelay = ajL.getStopTime() - System.currentTimeMillis();
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
CombatManager.combatCycle(playerCharacter, target, addedDelay);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class ClaimGuildTreeMsgHandler extends AbstractClientMsgHandler {
|
||||
if (building.getGuild().isEmptyGuild())
|
||||
return true;
|
||||
|
||||
if (!BuildingManager.playerCanManage(sourcePlayer, building))
|
||||
if (!ManageCityAssetMsgHandler.playerCanManageNotFriends(sourcePlayer, building))
|
||||
return true;
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ public class ClaimGuildTreeMsgHandler extends AbstractClientMsgHandler {
|
||||
(building == null) || playerZone == null || playerCity == null)
|
||||
return true;
|
||||
|
||||
if (!BuildingManager.playerCanManage(sourcePlayer, building))
|
||||
if (!ManageCityAssetMsgHandler.playerCanManageNotFriends(sourcePlayer, building))
|
||||
return true;
|
||||
|
||||
boolean open = (msg.getMessageType() == OPEN_CITY);
|
||||
|
||||
@@ -102,9 +102,6 @@ public class InviteToSubHandler extends AbstractClientMsgHandler {
|
||||
//source guild is limited to 7 subs
|
||||
//TODO this should be based on TOL rank
|
||||
|
||||
//cannot be subbed into a nation if you already have your own sub guilds
|
||||
if(targetGuild.getSubGuildList() != null && targetGuild.getSubGuildList().size() > 0)
|
||||
return true;
|
||||
|
||||
if (!sourceGuild.canSubAGuild(targetGuild)) {
|
||||
sendChat(source, "This Guild can't be subbed.");
|
||||
|
||||
@@ -28,6 +28,30 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
super();
|
||||
}
|
||||
|
||||
public static boolean playerCanManageNotFriends(PlayerCharacter player, Building building) {
|
||||
|
||||
//Player Can only Control Building if player is in Same Guild as Building and is higher rank than IC.
|
||||
|
||||
if (player == null)
|
||||
return false;
|
||||
|
||||
if (building.getRank() == -1)
|
||||
return false;
|
||||
|
||||
if (BuildingManager.IsOwner(building, player))
|
||||
return true;
|
||||
|
||||
if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false && GuildStatusController.isInnerCouncil(player.getGuildStatus()) == false)
|
||||
return false;
|
||||
|
||||
//Somehow guild leader check fails above? lets check if Player is true Guild GL.
|
||||
if (building.getGuild() != null && building.getGuild().isGuildLeader(player.getObjectUUID()))
|
||||
return true;
|
||||
|
||||
return Guild.sameGuild(building.getGuild(), player.getGuild());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) {
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ public class MerchantMsgHandler extends AbstractClientMsgHandler {
|
||||
City targetCity = null;
|
||||
|
||||
if (isTeleport)
|
||||
cities = City.getCitiesToTeleportTo(player, false);
|
||||
cities = City.getCitiesToTeleportTo(player);
|
||||
else
|
||||
cities = City.getCitiesToRepledgeTo(player);
|
||||
for (City city : cities) {
|
||||
|
||||
@@ -264,9 +264,8 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
|
||||
player.cancelOnSpell();
|
||||
break;
|
||||
case RUNE:
|
||||
if(ApplyRuneMsg.applyRune(uuid, origin, player)) {
|
||||
itemMan.consume(item);
|
||||
}
|
||||
ApplyRuneMsg.applyRune(uuid, origin, player);
|
||||
itemMan.consume(item);
|
||||
break;
|
||||
default: //shouldn't be here, consume item
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
|
||||
@@ -183,7 +183,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
if (building == null)
|
||||
return;
|
||||
|
||||
if (BuildingManager.playerCanManage(player, building) == false)
|
||||
if (ManageCityAssetMsgHandler.playerCanManageNotFriends(player, building) == false)
|
||||
return;
|
||||
|
||||
if (orderNpcMsg.getPatrolSize() >= 20)
|
||||
@@ -411,7 +411,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
case 2:
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (BuildingManager.playerCanManage(player, building) == false)
|
||||
if (ManageCityAssetMsgHandler.playerCanManageNotFriends(player, building) == false)
|
||||
return true;
|
||||
|
||||
if (building.getHirelings().containsKey(npc) == false)
|
||||
|
||||
@@ -54,7 +54,7 @@ public class PetAttackMsgHandler extends AbstractClientMsgHandler {
|
||||
pet.setCombatTarget(PlayerCharacter.getPlayerCharacter(msg.getTargetID()));
|
||||
|
||||
switch (msg.getTargetType()) {
|
||||
case 52: //player character
|
||||
case 53: //player character
|
||||
pet.setCombatTarget(PlayerCharacter.getPlayerCharacter(msg.getTargetID()));
|
||||
break;
|
||||
case 37://mob
|
||||
|
||||
@@ -53,7 +53,7 @@ public class TransferGoldToFromBuildingMsgHandler extends AbstractClientMsgHandl
|
||||
|
||||
if (msg.getDirection() == 2) {
|
||||
|
||||
if (!BuildingManager.playerCanManage(player, building))
|
||||
if (!ManageCityAssetMsgHandler.playerCanManageNotFriends(player, building))
|
||||
return true;
|
||||
if (building.setReserve(msg.getUnknown01(), player)) {
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
|
||||
@@ -59,7 +59,7 @@ public class SendOwnPlayerMsg extends ClientNetMsg {
|
||||
@Override
|
||||
protected int getPowerOfTwoBufferSize() {
|
||||
//Larger size for historically larger opcodes
|
||||
return (18); // 2^17 == 131,072
|
||||
return (17); // 2^17 == 131,072
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -73,8 +73,10 @@ public class TeleportRepledgeListMsg extends ClientNetMsg {
|
||||
|
||||
public void configure() {
|
||||
|
||||
cities = City.getCitiesToTeleportTo(player, !isTeleport);
|
||||
|
||||
if (isTeleport)
|
||||
cities = City.getCitiesToTeleportTo(player);
|
||||
else
|
||||
cities = City.getCitiesToRepledgeTo(player);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -93,7 +93,7 @@ public class ViewResourcesMsg extends ClientNetMsg {
|
||||
|
||||
for (mbEnums.ResourceType resourceType : (warehouseObject.resources.keySet())) {
|
||||
|
||||
writer.putInt(resourceType.templateHash);
|
||||
writer.putInt(resourceType.hash);
|
||||
writer.putInt((warehouseObject.resources.get(resourceType)));
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ public class ViewResourcesMsg extends ClientNetMsg {
|
||||
|
||||
for (mbEnums.ResourceType resourceType : warehouseObject.resources.keySet()) {
|
||||
|
||||
writer.putInt(resourceType.templateHash);
|
||||
writer.putInt(resourceType.hash);
|
||||
writer.putInt(0); //available?
|
||||
writer.putInt(resourceType.deposit_limit); //max?
|
||||
}
|
||||
|
||||
@@ -656,13 +656,13 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
AssignDamageAtrForPlayers(abstractCharacter, equipped.get(EquipSlotType.LHELD), false, equipped.get(EquipSlotType.LHELD));
|
||||
if (abstractCharacter.getObjectType().equals(GameObjectType.Mob)) {
|
||||
Mob mob = (Mob) abstractCharacter;
|
||||
abstractCharacter.minDamageHandOne = (int) mob.mobBase.getDamageMin();
|
||||
abstractCharacter.minDamageHandTwo = (int) mob.mobBase.getDamageMin();
|
||||
abstractCharacter.maxDamageHandOne = (int) mob.mobBase.getDamageMax();
|
||||
abstractCharacter.maxDamageHandTwo = (int) mob.mobBase.getDamageMax();
|
||||
abstractCharacter.atrHandOne = mob.mobBase.getAttackRating();
|
||||
abstractCharacter.atrHandTwo = mob.mobBase.getAttackRating();
|
||||
abstractCharacter.defenseRating = mob.mobBase.getDefenseRating();
|
||||
abstractCharacter.minDamageHandOne += (int) mob.mobBase.getDamageMin();
|
||||
abstractCharacter.minDamageHandTwo += (int) mob.mobBase.getDamageMin();
|
||||
abstractCharacter.maxDamageHandOne += (int) mob.mobBase.getDamageMax();
|
||||
abstractCharacter.maxDamageHandTwo += (int) mob.mobBase.getDamageMax();
|
||||
abstractCharacter.atrHandOne += mob.mobBase.getAttackRating();
|
||||
abstractCharacter.atrHandTwo += mob.mobBase.getAttackRating();
|
||||
abstractCharacter.defenseRating += mob.mobBase.getDefenseRating();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -806,7 +806,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
speed *= (1 + abstractCharacter.bonuses.getFloatPercentAll(ModType.WeaponSpeed, SourceType.None));
|
||||
|
||||
PlayerBonuses bonuses = abstractCharacter.bonuses;
|
||||
if (bonuses != null) {
|
||||
if(bonuses != null){
|
||||
ModType modType = ModType.AttackDelay;
|
||||
for (AbstractEffectModifier mod : bonuses.bonusFloats.keySet()) {
|
||||
|
||||
@@ -1787,7 +1787,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
final boolean fromCost) {
|
||||
|
||||
try {
|
||||
|
||||
this.combatLock.writeLock().lock();
|
||||
try {
|
||||
boolean ready = this.healthLock.writeLock().tryLock(1, TimeUnit.SECONDS);
|
||||
|
||||
@@ -1829,7 +1829,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
Mob target = (Mob) this;
|
||||
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);
|
||||
else
|
||||
target.playerAgroMap.put(attacker.getObjectUUID(), value);
|
||||
@@ -1852,6 +1852,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
return newHealth - oldHealth;
|
||||
} finally {
|
||||
this.healthLock.writeLock().unlock();
|
||||
this.combatLock.writeLock().unlock();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
|
||||
@@ -59,6 +59,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
|
||||
private Vector3f rot = new Vector3f(0.0f, 0.0f, 0.0f);
|
||||
private int objectTypeMask = 0;
|
||||
private Bounds bounds;
|
||||
public ReentrantReadWriteLock combatLock = new ReentrantReadWriteLock();
|
||||
|
||||
/**
|
||||
* No Id Constructor
|
||||
|
||||
@@ -641,18 +641,18 @@ public final class Bane {
|
||||
return cityUUID;
|
||||
}
|
||||
|
||||
public void startBane() {
|
||||
public void startBane(){
|
||||
City city = this.getCity();
|
||||
if (city == null)
|
||||
if(city == null)
|
||||
return;
|
||||
|
||||
this.isStarted = true; //flag the bane as started
|
||||
|
||||
for (AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(city.loc, mbEnums.CityBoundsType.ZONE.halfExtents + 64, MBServerStatics.MASK_BUILDING)) {
|
||||
Building building = (Building) awo;
|
||||
if (building == null)
|
||||
for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(city.loc,mbEnums.CityBoundsType.ZONE.halfExtents + 64,MBServerStatics.MASK_BUILDING)){
|
||||
Building building = (Building)awo;
|
||||
if(building == null)
|
||||
continue;
|
||||
if (building.protectionState.equals(ProtectionState.UNDERSIEGE) == false)
|
||||
if(building.protectionState.equals(ProtectionState.UNDERSIEGE) == false)
|
||||
building.protectionState = ProtectionState.UNDERSIEGE;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,11 +163,6 @@ public class Building extends AbstractWorldObject {
|
||||
if (upgradeTimeStamp != null)
|
||||
this.upgradeDateTime = LocalDateTime.ofInstant(upgradeTimeStamp.toInstant(), ZoneId.systemDefault());
|
||||
|
||||
if(rs.getInt("enforceKOS") == 0)
|
||||
this.enforceKOS = false;
|
||||
else
|
||||
this.enforceKOS = true;
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error("Failed for object " + this.blueprintUUID + ' ' + this.getObjectUUID() + e);
|
||||
}
|
||||
@@ -561,7 +556,7 @@ public class Building extends AbstractWorldObject {
|
||||
BuildingManager.setRank(barracksBuilding, -1);
|
||||
}
|
||||
|
||||
// If the tree is R8 and deranking, we need to update the
|
||||
// If the tree is R8 and deranking, we need to update it's
|
||||
// mesh along with buildings losing their health bonus
|
||||
|
||||
if (this.rank == 8) {
|
||||
@@ -1452,7 +1447,7 @@ public class Building extends AbstractWorldObject {
|
||||
|
||||
public synchronized boolean setReserve(int amount, PlayerCharacter player) {
|
||||
|
||||
if (!BuildingManager.playerCanManage(player, this))
|
||||
if (!BuildingManager.playerCanManageNotFriends(player, this))
|
||||
return false;
|
||||
|
||||
if (amount < 0)
|
||||
|
||||
@@ -1400,7 +1400,6 @@ public class CharacterItemManager {
|
||||
|
||||
if (!ItemManager.validForSkills(item, pc.getSkills())) {
|
||||
this.forceToInventory(slot, item, pc, initialized);
|
||||
this.equipped.remove(slot);
|
||||
pc.applyBonuses();
|
||||
}
|
||||
}
|
||||
|
||||
+137
-150
@@ -41,7 +41,6 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
public class City extends AbstractWorldObject {
|
||||
@@ -81,7 +80,6 @@ public class City extends AbstractWorldObject {
|
||||
private String hash;
|
||||
public Warehouse warehouse;
|
||||
public Realm realm;
|
||||
public AtomicBoolean isDestroyed = new AtomicBoolean(false);
|
||||
|
||||
/**
|
||||
* ResultSet Constructor
|
||||
@@ -122,7 +120,9 @@ public class City extends AbstractWorldObject {
|
||||
this.treeOfLifeID = rs.getInt("treeOfLifeUUID");
|
||||
this.bindX = rs.getFloat("bindX");
|
||||
this.bindZ = rs.getFloat("bindZ");
|
||||
this.bindLoc = new Vector3fImmutable(this.location.getX() + this.bindX, this.location.getY(), this.location.getZ() + this.bindZ);
|
||||
this.bindLoc = new Vector3fImmutable(this.location.getX() + this.bindX,
|
||||
this.location.getY(),
|
||||
this.location.getZ() + this.bindZ);
|
||||
this.radiusType = rs.getInt("radiusType");
|
||||
|
||||
float bindradiustemp = rs.getFloat("bindRadius");
|
||||
@@ -288,134 +288,106 @@ public class City extends AbstractWorldObject {
|
||||
return city.getBindLoc();
|
||||
}
|
||||
|
||||
public static ArrayList<City> getCitiesToTeleportTo(PlayerCharacter playerCharacter, boolean repledge) {
|
||||
|
||||
public static ArrayList<City> getCitiesToTeleportTo(PlayerCharacter pc) {
|
||||
ArrayList<City> cities = new ArrayList<>();
|
||||
|
||||
if (playerCharacter == null)
|
||||
if (pc == null)
|
||||
return cities;
|
||||
|
||||
ConcurrentHashMap<Integer, AbstractGameObject> worldCities = DbManager.getMap(mbEnums.GameObjectType.City);
|
||||
|
||||
//handle compiling of cities able to be teleported to for lore rule-set
|
||||
|
||||
for (AbstractGameObject ago : worldCities.values()) {
|
||||
|
||||
City city = (City) ago;
|
||||
|
||||
// Filter Player cities
|
||||
|
||||
if (city.parentZone == null)
|
||||
continue;
|
||||
|
||||
// Can't teleport to something without a tree
|
||||
|
||||
if (city.getTOL() == null)
|
||||
continue;
|
||||
|
||||
// No abandoned cities
|
||||
|
||||
if (city.getTOL().getGuild().isEmptyGuild())
|
||||
continue;
|
||||
|
||||
// No destroyed cities
|
||||
|
||||
if (city.getTOL().getRank() == -1)
|
||||
continue;
|
||||
|
||||
//can't repledge to a guild you're already part of
|
||||
|
||||
if (repledge && city.getGuild().equals(playerCharacter.guild))
|
||||
continue;
|
||||
|
||||
if (city.parentZone.guild_zone) {
|
||||
|
||||
//players can all port and repledge inside their own nation
|
||||
|
||||
if(city.getGuild().getNation().equals(playerCharacter.guild.getNation())){
|
||||
cities.add(city);
|
||||
if (ConfigManager.MB_RULESET.getValue().equals("LORE")) {
|
||||
//handle compiling of cities able to be teleported to for lore rule-set
|
||||
for (AbstractGameObject ago : worldCities.values()) {
|
||||
City city = (City) ago;
|
||||
if(city.cityName.equals("Perdition") || city.cityName.equals("Bastion"))
|
||||
continue; // cannot teleport to perdition or bastion
|
||||
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
|
||||
continue;
|
||||
}
|
||||
|
||||
if (city.isOpen() && city.getTOL().rank > 4) {
|
||||
|
||||
// Filter Lore cities
|
||||
|
||||
if (ConfigManager.MB_RULESET.getValue().equals("LORE")) {
|
||||
|
||||
if (repledge) {
|
||||
if (!city.getGuild().charter.canJoin(playerCharacter))
|
||||
continue;
|
||||
} else if (!city.getGuild().charter.equals(playerCharacter.guild.charter))
|
||||
continue;
|
||||
}
|
||||
|
||||
Integer playerUUID = playerCharacter.objectUUID;
|
||||
Integer guildUUID = playerCharacter.guildUUID;
|
||||
Integer nationUUID = playerCharacter.guild.getNation().getObjectUUID();
|
||||
boolean allowed = false;
|
||||
|
||||
if (city.getTOL().reverseKOS) {
|
||||
|
||||
//reverse KOS, specific values are allowed
|
||||
|
||||
if ((city.getTOL().getCondemned().containsKey(playerUUID) && city.getTOL().getCondemned().get(playerUUID).active) ||
|
||||
(city.getTOL().getCondemned().containsKey(guildUUID) && city.getTOL().getCondemned().get(guildUUID).active) ||
|
||||
(city.getTOL().getCondemned().containsKey(nationUUID) && city.getTOL().getCondemned().get(nationUUID).active))
|
||||
allowed = true;
|
||||
|
||||
} else if (city.isNoobIsle == 1 && pc.level <= 20) {
|
||||
cities.add(city); // everyone can go to noob island if they are under level 20
|
||||
continue;
|
||||
} else if (city.cityName.equals("Khan'Ov Srekel")) {
|
||||
cities.add(city); //everyone anytime can teleport to khan
|
||||
continue;
|
||||
} else if (city.isOpen() && city.getTOL().rank > 4 && city.getGuild().charter.equals(pc.guild.charter))
|
||||
if (!city.getTOL().reverseKOS) {
|
||||
cities.add(city);//can teleport to any open ToL that shares charter
|
||||
continue;
|
||||
} else {
|
||||
//not reverse KOS, everyone is allowed by default
|
||||
if (city.getTOL().getCondemned().contains(pc.objectUUID) && city.getTOL().getCondemned().get(pc.objectUUID).active) {
|
||||
cities.add(city);//this player is allowed for the reverse KOS
|
||||
continue;
|
||||
}
|
||||
if (city.getTOL().getCondemned().contains(pc.guildUUID) && city.getTOL().getCondemned().get(pc.guildUUID).active) {
|
||||
cities.add(city);//this guild is allowed for the reverse KOS
|
||||
continue;
|
||||
}
|
||||
if (city.getTOL().getCondemned().contains(pc.guild.getNation().getObjectUUID()) && city.getTOL().getCondemned().get(pc.guild.getNation().getObjectUUID()).active) {
|
||||
cities.add(city);//this nation is allowed for the reverse KOS
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (city.getGuild().getNation().equals(pc.guild.getNation())) {
|
||||
cities.add(city);//can always teleport inside your own nation
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
allowed = true;
|
||||
Guild pcG = pc.getGuild();
|
||||
//add npc cities
|
||||
|
||||
//specific values are not allowed
|
||||
for (AbstractGameObject ago : worldCities.values()) {
|
||||
|
||||
if ((city.getTOL().getCondemned().containsKey(playerUUID) && city.getTOL().getCondemned().get(playerUUID).active) ||
|
||||
(city.getTOL().getCondemned().containsKey(guildUUID) && city.getTOL().getCondemned().get(guildUUID).active) ||
|
||||
(city.getTOL().getCondemned().containsKey(nationUUID) && city.getTOL().getCondemned().get(nationUUID).active))
|
||||
allowed = false;
|
||||
if (ago.getObjectType().equals(GameObjectType.City)) {
|
||||
City city = (City) ago;
|
||||
|
||||
if (city.noTeleport)
|
||||
continue;
|
||||
|
||||
if (city.parentZone != null && city.parentZone.guild_zone) {
|
||||
|
||||
if (pc.getAccount().status.equals(AccountStatus.ADMIN)) {
|
||||
cities.add(city);
|
||||
} else
|
||||
//list Player cities
|
||||
|
||||
//open city, just list
|
||||
|
||||
if (city.open && city.getTOL() != null && city.getTOL().getRank() > 4) {
|
||||
|
||||
if (!BuildingManager.IsPlayerHostile(city.getTOL(), pc)) {
|
||||
if (ConfigManager.MB_RULESET.getValue().equals("LORE")) {
|
||||
if (city.getGuild().getGuildType().equals(pc.guild.getGuildType())) {
|
||||
cities.add(city);
|
||||
}
|
||||
} else {
|
||||
cities.add(city); //verify nation or guild is same
|
||||
}
|
||||
}
|
||||
} else if (Guild.sameNationExcludeErrant(city.getGuild(), pcG))
|
||||
cities.add(city);
|
||||
|
||||
|
||||
} else if (city.isNpc == 1) {
|
||||
|
||||
//list NPC cities
|
||||
|
||||
Guild g = city.getGuild();
|
||||
if (g == null) {
|
||||
if (city.isNpc == 1)
|
||||
if (city.isNoobIsle == 1) {
|
||||
if (pc.getLevel() < 21)
|
||||
cities.add(city); //verify nation or guild is same
|
||||
} else if (pc.getLevel() > 9)
|
||||
cities.add(city); //verify nation or guild is same
|
||||
|
||||
} else if (pc.getLevel() >= g.getTeleportMin() && pc.getLevel() <= g.getTeleportMax())
|
||||
cities.add(city); //verify nation or guild is same
|
||||
}
|
||||
|
||||
if (allowed)
|
||||
cities.add(city);
|
||||
}
|
||||
} else {
|
||||
|
||||
// Filter NPC cities
|
||||
|
||||
if (city.isNoobIsle == 1) {
|
||||
|
||||
if (playerCharacter.level < 20)
|
||||
cities.add(city); // everyone can go to noob island if they are under level 20
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Players cannot teleport to perdition or bastion
|
||||
|
||||
if (city.cityName.equals("Perdition") || city.cityName.equals("Bastion"))
|
||||
continue;
|
||||
|
||||
// These cities are available for anyone off noob island
|
||||
|
||||
if (playerCharacter.level >= 20 && (city.cityName.equals("Sea Dog's Rest") || city.cityName.equals("Khan'Ov Srekel") || city.cityName.equals("City of Khar Th'Sekt"))) {
|
||||
cities.add(city);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add Lore cities
|
||||
|
||||
if (ConfigManager.MB_RULESET.getValue().equals("LORE")) {
|
||||
|
||||
if (repledge) {
|
||||
if (city.getGuild().charter.canJoin(playerCharacter))
|
||||
cities.add(city);
|
||||
} else if (city.getGuild().charter.equals(playerCharacter.guild.charter))
|
||||
cities.add(city);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return cities;
|
||||
@@ -435,14 +407,13 @@ public class City extends AbstractWorldObject {
|
||||
//handle compiling of cities able to be repledged to for lore rule-set
|
||||
for (AbstractGameObject ago : worldCities.values()) {
|
||||
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
|
||||
if (city.isNpc == 1 && city.getGuild().charter.canJoin(playerCharacter)) {
|
||||
if(city.isNoobIsle == 1 && playerCharacter.level >= 21)
|
||||
continue;
|
||||
cities.add(city); // anyone of the same charter can teleport to a safehold of that charter
|
||||
continue;
|
||||
} else if (city.isNoobIsle == 1 && playerCharacter.level <= 20) {
|
||||
cities.add(city); // everyone can go to noob island if they are under level 20
|
||||
continue;
|
||||
} else if (city.isOpen() && city.getTOL().rank > 4 && city.getGuild().charter.canJoin(playerCharacter))
|
||||
if (!city.getTOL().reverseKOS) {
|
||||
cities.add(city);//can repledge to any open ToL that player can fit into charter
|
||||
@@ -614,7 +585,7 @@ public class City extends AbstractWorldObject {
|
||||
if (this.siegesWithstood == siegesWithstood)
|
||||
return;
|
||||
|
||||
if (DbManager.CityQueries.updateSiegesWithstood(this, siegesWithstood))
|
||||
if (DbManager.CityQueries.updateSiegesWithstood(this, siegesWithstood) == true)
|
||||
this.siegesWithstood = siegesWithstood;
|
||||
else
|
||||
Logger.error("Error when writing to database for cityUUID: " + this.getObjectUUID());
|
||||
@@ -670,10 +641,17 @@ public class City extends AbstractWorldObject {
|
||||
if (this.getTOL() == null)
|
||||
return Guild.getErrantGuild();
|
||||
|
||||
if (this.getTOL().getOwner() == null)
|
||||
return Guild.getErrantGuild();
|
||||
if (this.isNpc == 1) {
|
||||
|
||||
return this.getTOL().getOwner().getGuild();
|
||||
if (this.getTOL().getOwner() == null)
|
||||
return Guild.getErrantGuild();
|
||||
return this.getTOL().getOwner().getGuild();
|
||||
} else {
|
||||
|
||||
if (this.getTOL().getOwner() == null)
|
||||
return Guild.getErrantGuild();
|
||||
return this.getTOL().getOwner().getGuild();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean openCity(boolean open) {
|
||||
@@ -752,7 +730,7 @@ public class City extends AbstractWorldObject {
|
||||
|
||||
for (AbstractCharacter npc : getTOL().getHirelings().keySet()) {
|
||||
if (npc.getObjectType() == GameObjectType.NPC)
|
||||
if (((NPC) npc).getContract().isRuneMaster())
|
||||
if (((NPC) npc).getContract().isRuneMaster() == true)
|
||||
outNPC = (NPC) npc;
|
||||
}
|
||||
|
||||
@@ -785,13 +763,16 @@ public class City extends AbstractWorldObject {
|
||||
// Set location for this city
|
||||
|
||||
this.location = new Vector3fImmutable(this.parentZone.absX, this.parentZone.absY, this.parentZone.absZ);
|
||||
this.bindLoc = new Vector3fImmutable(this.location.x + this.bindX, this.location.y, this.location.z + this.bindZ);
|
||||
this.bindLoc = new Vector3fImmutable(this.location.x + this.bindX,
|
||||
this.location.y,
|
||||
this.location.z + this.bindZ);
|
||||
|
||||
// set city bounds
|
||||
|
||||
Bounds cityBounds = Bounds.borrow();
|
||||
cityBounds.setBounds(new Vector2f(this.location.x + 64, this.location.z + 64), // location x and z are offset by 64 from the center of the city.
|
||||
new Vector2f(mbEnums.CityBoundsType.GRID.halfExtents, mbEnums.CityBoundsType.GRID.halfExtents), 0.0f);
|
||||
new Vector2f(mbEnums.CityBoundsType.GRID.halfExtents, mbEnums.CityBoundsType.GRID.halfExtents),
|
||||
0.0f);
|
||||
this.setBounds(cityBounds);
|
||||
|
||||
// Sanity check; no tol
|
||||
@@ -799,7 +780,8 @@ public class City extends AbstractWorldObject {
|
||||
if (BuildingManager.getBuilding(this.treeOfLifeID) == null)
|
||||
Logger.info("City UID " + this.getObjectUUID() + " Failed to Load Tree of Life with ID " + this.treeOfLifeID);
|
||||
|
||||
if ((ConfigManager.serverType.equals(ServerType.WORLDSERVER)) && (this.isNpc == (byte) 0)) {
|
||||
if ((ConfigManager.serverType.equals(ServerType.WORLDSERVER))
|
||||
&& (this.isNpc == (byte) 0)) {
|
||||
|
||||
this.realm = RealmMap.getRealmAtLocation(this.getLoc());
|
||||
|
||||
@@ -819,7 +801,8 @@ public class City extends AbstractWorldObject {
|
||||
if (this.getGuild().getGuildState() == GuildState.Nation)
|
||||
for (Guild sub : this.getGuild().getSubGuildList()) {
|
||||
|
||||
if ((sub.getGuildState() == GuildState.Protectorate) || (sub.getGuildState() == GuildState.Province)) {
|
||||
if ((sub.getGuildState() == GuildState.Protectorate) ||
|
||||
(sub.getGuildState() == GuildState.Province)) {
|
||||
this.isCapital = 1;
|
||||
break;
|
||||
}
|
||||
@@ -844,7 +827,7 @@ public class City extends AbstractWorldObject {
|
||||
|
||||
this.setHash();
|
||||
|
||||
if (!DataWarehouse.recordExists(DataRecordType.CITY, this.getObjectUUID())) {
|
||||
if (DataWarehouse.recordExists(mbEnums.DataRecordType.CITY, this.getObjectUUID()) == false) {
|
||||
CityRecord cityRecord = CityRecord.borrow(this, mbEnums.RecordEventType.CREATE);
|
||||
DataWarehouse.pushToWarehouse(cityRecord);
|
||||
}
|
||||
@@ -869,7 +852,9 @@ public class City extends AbstractWorldObject {
|
||||
|
||||
for (Building building : this.parentZone.zoneBuildingSet) {
|
||||
|
||||
if (building.getBlueprint() != null && building.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE && building.getBlueprint().getBuildingGroup() != BuildingGroup.TOL) {
|
||||
if (building.getBlueprint() != null &&
|
||||
building.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE &&
|
||||
building.getBlueprint().getBuildingGroup() != BuildingGroup.TOL) {
|
||||
|
||||
building.healthMax += (building.healthMax * Realm.getRealmHealthMod(this));
|
||||
|
||||
@@ -951,7 +936,7 @@ public class City extends AbstractWorldObject {
|
||||
|
||||
// Reapply effect with timeout?
|
||||
|
||||
if (refreshEffect)
|
||||
if (refreshEffect == true)
|
||||
player.addCityEffect(Integer.toString(effectBase.getUUID()), effectBase, rank, MBServerStatics.FOURTYFIVE_SECONDS, false, this);
|
||||
|
||||
}
|
||||
@@ -1119,21 +1104,17 @@ public class City extends AbstractWorldObject {
|
||||
|
||||
public final void destroy() {
|
||||
|
||||
if (this.isDestroyed.compareAndSet(false, true)) {
|
||||
Thread destroyCityThread = new Thread(new DestroyCityThread(this));
|
||||
|
||||
Thread destroyCityThread = new Thread(new DestroyCityThread(this));
|
||||
|
||||
destroyCityThread.setName("destroyCity:" + this.getParent().zoneName);
|
||||
destroyCityThread.start();
|
||||
} else
|
||||
Logger.error("Attempt to destroy destroyed city");
|
||||
destroyCityThread.setName("destroyCity:" + this.getName());
|
||||
destroyCityThread.start();
|
||||
}
|
||||
|
||||
public final void transfer(AbstractCharacter newOwner) {
|
||||
|
||||
Thread transferCityThread = new Thread(new TransferCityThread(this, newOwner));
|
||||
|
||||
transferCityThread.setName("TransferCity:" + this.getParent().zoneName);
|
||||
transferCityThread.setName("TransferCity:" + this.getName());
|
||||
transferCityThread.start();
|
||||
}
|
||||
|
||||
@@ -1211,25 +1192,26 @@ public class City extends AbstractWorldObject {
|
||||
// All protection contracts are void upon transfer of a city
|
||||
//Dont forget to not Flip protection on Banestones and siege Equipment... Noob.
|
||||
|
||||
if (cityBuilding.getBlueprint() != null && !cityBuilding.getBlueprint().isSiegeEquip() && cityBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE)
|
||||
if (cityBuilding.getBlueprint() != null && !cityBuilding.getBlueprint().isSiegeEquip()
|
||||
&& cityBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE)
|
||||
cityBuilding.setProtectionState(ProtectionState.NONE);
|
||||
|
||||
// Transfer ownership of valid city assets
|
||||
// these assets are autoprotected.
|
||||
|
||||
if ((cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.TOL) || (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE) || (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK) || (cityBuilding.getBlueprint().isWallPiece()) || (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE)) {
|
||||
PlayerCharacter guildLeader = PlayerCharacter.getPlayerCharacter(sourcePlayer.guild.getGuildLeaderUUID());
|
||||
if(guildLeader != null)
|
||||
cityBuilding.claim(guildLeader);
|
||||
else
|
||||
cityBuilding.claim(sourcePlayer);
|
||||
if ((cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.TOL)
|
||||
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE)
|
||||
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK)
|
||||
|| (cityBuilding.getBlueprint().isWallPiece())
|
||||
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE)) {
|
||||
|
||||
cityBuilding.claim(sourcePlayer);
|
||||
cityBuilding.setProtectionState(ProtectionState.PROTECTED);
|
||||
}
|
||||
}
|
||||
|
||||
this.setForceRename(true);
|
||||
|
||||
|
||||
// Reset city timer for map update
|
||||
|
||||
City.lastCityUpdate = System.currentTimeMillis();
|
||||
@@ -1262,7 +1244,12 @@ public class City extends AbstractWorldObject {
|
||||
// Transfer ownership of valid city assets
|
||||
// these assets are autoprotected.
|
||||
|
||||
if ((cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.TOL) || (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE) || (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK) || (cityBuilding.getBlueprint().isWallPiece()) || (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE)) {
|
||||
if ((cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.TOL)
|
||||
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE)
|
||||
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK)
|
||||
|| (cityBuilding.getBlueprint().isWallPiece())
|
||||
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE)
|
||||
) {
|
||||
|
||||
cityBuilding.claim(sourcePlayer);
|
||||
cityBuilding.setProtectionState(ProtectionState.PROTECTED);
|
||||
@@ -1411,7 +1398,7 @@ public class City extends AbstractWorldObject {
|
||||
taxPercent = .20f;
|
||||
|
||||
for (int resourceHash : msg.getResources().keySet())
|
||||
resources.add(ResourceType.templateHashLookup.get(resourceHash));
|
||||
resources.add(ResourceType.hashLookup.get(resourceHash));
|
||||
|
||||
for (ResourceType resourceType : resources) {
|
||||
if (Warehouse.isAboveCap(ruledWarehouse, resourceType, (int) (city.warehouse.resources.get(resourceType) * taxPercent))) {
|
||||
|
||||
@@ -193,16 +193,12 @@ public class Guild extends AbstractWorldObject {
|
||||
}
|
||||
|
||||
public static boolean sameNationExcludeErrant(Guild a, Guild b) {
|
||||
|
||||
if (a == null || b == null)
|
||||
return false;
|
||||
|
||||
if (a.getObjectUUID() == b.getObjectUUID())
|
||||
return true;
|
||||
|
||||
if (a.nation == null || b.nation == null)
|
||||
return false;
|
||||
|
||||
return a.nation.getObjectUUID() == b.nation.getObjectUUID() && !a.nation.isEmptyGuild();
|
||||
}
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ public class Mine extends AbstractGameObject {
|
||||
writer.putInt(mine.getObjectUUID()); //actually a hash of mine
|
||||
writer.putString(mine.mineType.name);
|
||||
writer.putString(mine.zoneName);
|
||||
writer.putInt(mine.production.resourceHash);
|
||||
writer.putInt(mine.production.hash);
|
||||
writer.putInt(mine.production.mine_production);
|
||||
writer.putInt(mine.getModifiedProductionAmount()); //TODO calculate range penalty here
|
||||
writer.putInt(3600); //window in seconds
|
||||
@@ -220,7 +220,8 @@ public class Mine extends AbstractGameObject {
|
||||
// Only inactive mines are returned.
|
||||
|
||||
for (Mine mine : Mine.mineMap.keySet()) {
|
||||
if (mine.owningGuild.getObjectUUID() == guildID)
|
||||
if (mine.owningGuild.getObjectUUID() == guildID &&
|
||||
mine.isActive == false)
|
||||
mineList.add(mine);
|
||||
}
|
||||
return mineList;
|
||||
@@ -392,7 +393,7 @@ public class Mine extends AbstractGameObject {
|
||||
// writer.putInt(0x215C92BB); //this.unknown1);
|
||||
writer.putString(this.mineType.name);
|
||||
writer.putString(this.zoneName);
|
||||
writer.putInt(this.production.resourceHash);
|
||||
writer.putInt(this.production.hash);
|
||||
writer.putInt(this.production.mine_production);
|
||||
writer.putInt(this.getModifiedProductionAmount()); //TODO calculate range penalty here
|
||||
writer.putInt(3600); //window in seconds
|
||||
@@ -481,7 +482,7 @@ public class Mine extends AbstractGameObject {
|
||||
if (this.owningGuild.getOwnedCity().warehouse == null)
|
||||
return false;
|
||||
|
||||
return Warehouse.depositFromMine(this, mbEnums.ResourceType.templateLookup.get(this.production.templateID), this.getModifiedProductionAmount(), this.owningGuild.getOwnedCity().warehouse);
|
||||
return Warehouse.depositFromMine(this, mbEnums.ResourceType.resourceLookup.get(this.production.templateID), this.getModifiedProductionAmount(), this.owningGuild.getOwnedCity().warehouse);
|
||||
}
|
||||
|
||||
public boolean updateGuildOwner(PlayerCharacter playerCharacter) {
|
||||
|
||||
@@ -349,13 +349,13 @@ public class Resists {
|
||||
if (rb.getBool(ModType.ImmuneTo, SourceType.Stun))
|
||||
this.immuneTo.put(mbEnums.DamageType.STUN, true);
|
||||
if (rb.getBool(ModType.ImmuneTo, SourceType.Blind))
|
||||
this.immuneTo.put(mbEnums.DamageType.BLINDNESS, true);
|
||||
this.immuneTo.put(mbEnums.DamageType.BLIND, true);
|
||||
if (rb.getBool(ModType.ImmuneToAttack, SourceType.None))
|
||||
this.immuneTo.put(mbEnums.DamageType.ATTACK, true);
|
||||
if (rb.getBool(ModType.ImmuneToPowers, SourceType.None))
|
||||
this.immuneTo.put(mbEnums.DamageType.POWERS, true);
|
||||
if (rb.getBool(ModType.ImmuneTo, SourceType.Powerblock))
|
||||
this.immuneTo.put(mbEnums.DamageType.POWERINHIBITOR, true);
|
||||
this.immuneTo.put(mbEnums.DamageType.POWERBLOCK, true);
|
||||
if (rb.getBool(ModType.ImmuneTo, SourceType.DeBuff))
|
||||
this.immuneTo.put(mbEnums.DamageType.DEBUFF, true);
|
||||
if (rb.getBool(ModType.ImmuneTo, SourceType.Fear))
|
||||
|
||||
@@ -140,7 +140,7 @@ public class Warehouse {
|
||||
if (warehouse == null)
|
||||
return;
|
||||
|
||||
mbEnums.ResourceType resourceType = mbEnums.ResourceType.templateHashLookup.get(msg.getHashID());
|
||||
mbEnums.ResourceType resourceType = mbEnums.ResourceType.hashLookup.get(msg.getHashID());
|
||||
|
||||
if (isResourceLocked(warehouse, resourceType)) {
|
||||
ChatManager.chatSystemInfo(playerCharacter, "You cannot withdrawl a locked resource.");
|
||||
@@ -182,7 +182,7 @@ public class Warehouse {
|
||||
|
||||
warehouse = city.warehouse;
|
||||
|
||||
mbEnums.ResourceType resourceType = mbEnums.ResourceType.templateHashLookup.get(hashID);
|
||||
mbEnums.ResourceType resourceType = mbEnums.ResourceType.hashLookup.get(hashID);
|
||||
|
||||
// toggle lock
|
||||
|
||||
@@ -233,7 +233,7 @@ public class Warehouse {
|
||||
return false;
|
||||
}
|
||||
|
||||
mbEnums.ResourceType resourceType = mbEnums.ResourceType.templateLookup.get(resource.templateID);
|
||||
mbEnums.ResourceType resourceType = mbEnums.ResourceType.resourceLookup.get(resource.templateID);
|
||||
|
||||
if (warehouse.resources.get(resourceType) == null)
|
||||
return false;
|
||||
@@ -261,7 +261,7 @@ public class Warehouse {
|
||||
|
||||
int newAmount = oldAmount + amount;
|
||||
|
||||
if (newAmount > mbEnums.ResourceType.templateLookup.get(resource.templateID).deposit_limit)
|
||||
if (newAmount > mbEnums.ResourceType.resourceLookup.get(resource.templateID).deposit_limit)
|
||||
return false;
|
||||
|
||||
if (removeFromInventory) {
|
||||
@@ -381,7 +381,7 @@ public class Warehouse {
|
||||
int amount = (int) (warehouse.resources.get(resourceType) * taxPercent);
|
||||
|
||||
if (amount <= 0) {
|
||||
msg.getResources().put(resourceType.resourceHash, 0);
|
||||
msg.getResources().put(resourceType.hash, 0);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -395,18 +395,20 @@ public class Warehouse {
|
||||
if (newAmount < amount)
|
||||
continue;
|
||||
|
||||
msg.getResources().put(resourceType.resourceHash, amount);
|
||||
msg.getResources().put(resourceType.hash, amount);
|
||||
|
||||
if (!DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse)) {
|
||||
msg.getResources().put(resourceType.resourceHash, 0);
|
||||
msg.getResources().put(resourceType.hash, 0);
|
||||
warehouse.resources.put(resourceType, oldAmount);
|
||||
continue;
|
||||
}
|
||||
|
||||
warehouse.resources.put(resourceType, newAmount);
|
||||
depositRealmTaxes(taxer, resourceType, amount, warehouse);
|
||||
mbEnums.ResourceType resource;
|
||||
|
||||
AddTransactionToWarehouse(warehouse, taxer.getObjectType(), taxer.getObjectUUID(), mbEnums.TransactionType.TAXRESOURCE, resourceType, amount);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -429,7 +431,7 @@ public class Warehouse {
|
||||
return false;
|
||||
|
||||
if (addToInventory)
|
||||
if (!itemMan.hasRoomInventory(template.item_wt)) {
|
||||
if (!itemMan.hasRoomInventory(template.item_wt * amount)) {
|
||||
ChatManager.chatSystemInfo(playerCharacter, "You can not carry any more of that item.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -11,11 +11,13 @@ package engine.powers;
|
||||
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.mbEnums;
|
||||
import engine.mbEnums.ModType;
|
||||
import engine.mbEnums.SourceType;
|
||||
import engine.mbEnums.StackType;
|
||||
import engine.objects.*;
|
||||
import engine.objects.AbstractCharacter;
|
||||
import engine.objects.AbstractWorldObject;
|
||||
import engine.objects.PlayerBonuses;
|
||||
import engine.objects.Runegate;
|
||||
import engine.powers.poweractions.AbstractPowerAction;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
@@ -242,23 +244,32 @@ public class ActionsBase {
|
||||
}
|
||||
|
||||
//Add blocked types here
|
||||
public boolean blocked(AbstractWorldObject awo, boolean vampDrain) {
|
||||
//Check for immunities
|
||||
if (AbstractCharacter.IsAbstractCharacter(awo)){
|
||||
AbstractCharacter pcTarget = (AbstractCharacter) awo;
|
||||
PlayerBonuses bonus = pcTarget.getBonuses();
|
||||
public boolean blocked(AbstractWorldObject awo, PowersBase pb, int trains) {
|
||||
if (AbstractWorldObject.IsAbstractCharacter(awo)) {
|
||||
AbstractCharacter ac = (AbstractCharacter) awo;
|
||||
PlayerBonuses bonus = ac.getBonuses();
|
||||
if (bonus == null)
|
||||
return false;
|
||||
|
||||
if(vampDrain)
|
||||
return bonus.getBool(ModType.BlockedPowerType, SourceType.VAMPDRAIN);
|
||||
|
||||
if ((this.stackType.equals("Flight") && bonus.getBool(ModType.NoMod, SourceType.Fly)) ||
|
||||
(this.stackType.equals("Track") && bonus.getBool(ModType.CannotTrack, SourceType.None))) {
|
||||
//TODO make this more efficient then testing strings
|
||||
if (this.stackType.equals("Stun") && bonus.getBool(ModType.ImmuneTo, SourceType.STUN))
|
||||
return true; //Currently stun immune. Skip stun
|
||||
else if (this.stackType.equals("Snare") && bonus.getBool(ModType.ImmuneTo, SourceType.Snare))
|
||||
return true; //Currently snare immune. Skip snare
|
||||
else if (this.stackType.equals("Blindness") && bonus.getBool(ModType.ImmuneTo, SourceType.Blind))
|
||||
return true; //Currently blind immune. Skip blind
|
||||
else if (this.stackType.equals("PowerInhibitor") && bonus.getBool(ModType.ImmuneTo, SourceType.Powerblock))
|
||||
return true; //Currently power block immune. Skip power block
|
||||
else if (this.stackType.equals("Root") && bonus.getBool(ModType.ImmuneTo, SourceType.Root))
|
||||
return true;
|
||||
}
|
||||
|
||||
mbEnums.DamageType damageType = mbEnums.DamageType.getDamageType(this.stackType.toUpperCase());
|
||||
return pcTarget.getResists().immuneTo(damageType);
|
||||
|
||||
// else if (pb.isHeal() && (bonus.getByte("immuneTo.Heal")) >= trains)
|
||||
// return true; //Currently shadowmantled. Skip heals
|
||||
else if (this.stackType.equals("Flight") && bonus.getBool(ModType.NoMod, SourceType.Fly))
|
||||
return true;
|
||||
else if (this.stackType.equals("Track") && bonus.getBool(ModType.CannotTrack, SourceType.None))
|
||||
return true;
|
||||
else
|
||||
return pb.vampDrain() && bonus.getBool(ModType.BlockedPowerType, SourceType.VAMPDRAIN);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -633,8 +633,15 @@ public class PowersBase {
|
||||
return description;
|
||||
}
|
||||
|
||||
public boolean enforceLore(){
|
||||
return this.powerCategory.equals(PowerCategoryType.SUMMON) || this.powerCategory.equals(PowerCategoryType.HEAL)|| this.powerCategory.equals(PowerCategoryType.BUFF);
|
||||
public boolean ignoreLore(){
|
||||
switch(this.category){
|
||||
case "HEAL":
|
||||
case "BUFF":
|
||||
case "DISPELL":
|
||||
case "SUMMON":
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ package engine.powers.poweractions;
|
||||
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.mbEnums;
|
||||
import engine.mbEnums.BuildingGroup;
|
||||
import engine.mbEnums.GameObjectType;
|
||||
import engine.mbEnums.PortalType;
|
||||
import engine.objects.AbstractCharacter;
|
||||
@@ -53,17 +54,15 @@ public class OpenGatePowerAction extends AbstractPowerAction {
|
||||
return;
|
||||
|
||||
// Make sure target building is a runegate
|
||||
|
||||
if (targetBuilding.meshUUID != 24500) // runegate
|
||||
if(targetBuilding.meshUUID != 24500) // runegate
|
||||
return;
|
||||
|
||||
// Which runegate was clicked on?
|
||||
|
||||
Runegate runeGate = Runegate._runegates.get(targetBuilding.getObjectUUID());
|
||||
|
||||
if (runeGate == null)
|
||||
if(runeGate == null){
|
||||
return; // mob camp prop runegate cannot be opened
|
||||
|
||||
}
|
||||
// Which portal was opened?
|
||||
|
||||
token = pb.getToken();
|
||||
@@ -73,31 +72,41 @@ public class OpenGatePowerAction extends AbstractPowerAction {
|
||||
case 428937084: //Death Gate
|
||||
portalType = PortalType.OBLIV;
|
||||
break;
|
||||
|
||||
case 429756284: //Chaos Gate
|
||||
portalType = PortalType.CHAOS;
|
||||
break;
|
||||
|
||||
case 429723516: //Khar Gate
|
||||
portalType = PortalType.MERCHANT;
|
||||
break;
|
||||
|
||||
case 429559676: //Spirit Gate
|
||||
portalType = PortalType.SPIRIT;
|
||||
break;
|
||||
|
||||
case 429592444: //Water Gate
|
||||
portalType = PortalType.WATER;
|
||||
break;
|
||||
|
||||
case 429428604: //Fire Gate
|
||||
portalType = PortalType.FIRE;
|
||||
break;
|
||||
|
||||
case 429526908: //Air Gate
|
||||
portalType = PortalType.AIR;
|
||||
break;
|
||||
|
||||
case 429625212: //Earth Gate
|
||||
portalType = PortalType.EARTH;
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
|
||||
|
||||
runeGate.activatePortal(portalType);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -53,117 +53,116 @@ public class DestroyCityThread implements Runnable {
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
try {
|
||||
cityZone = city.getParent();
|
||||
newParent = cityZone.parent;
|
||||
formerGuild = city.getTOL().getGuild();
|
||||
cityZone = city.getParent();
|
||||
newParent = cityZone.parent;
|
||||
formerGuild = city.getTOL().getGuild();
|
||||
|
||||
Logger.info("Destroy city thread started for: " + cityZone.zoneName);
|
||||
// Former guild loses it's tree!
|
||||
|
||||
// Former guild loses tree!
|
||||
if (DbManager.GuildQueries.SET_GUILD_OWNED_CITY(formerGuild.getObjectUUID(), 0)) {
|
||||
|
||||
if (DbManager.GuildQueries.SET_GUILD_OWNED_CITY(formerGuild.getObjectUUID(), 0)) {
|
||||
//Successful Update of guild
|
||||
|
||||
//Successful Update of guild
|
||||
|
||||
formerGuild.setGuildState(mbEnums.GuildState.Errant);
|
||||
formerGuild.setNation(null);
|
||||
formerGuild.setCityUUID(0);
|
||||
GuildManager.updateAllGuildTags(formerGuild);
|
||||
GuildManager.updateAllGuildBinds(formerGuild, null);
|
||||
}
|
||||
|
||||
// By losing the tree, the former owners lose all of their subguilds.
|
||||
|
||||
if (!formerGuild.getSubGuildList().isEmpty()) {
|
||||
|
||||
subGuildList = new ArrayList<>();
|
||||
|
||||
subGuildList.addAll(formerGuild.getSubGuildList());
|
||||
|
||||
for (Guild subGuild : subGuildList) {
|
||||
formerGuild.removeSubGuild(subGuild);
|
||||
}
|
||||
}
|
||||
|
||||
// Build list of buildings within this parent zone
|
||||
|
||||
ArrayList<Building> destroySet = new ArrayList<>();
|
||||
|
||||
for (Building cityBuilding : cityZone.zoneBuildingSet) {
|
||||
|
||||
// Sanity Check in case player deletes the building
|
||||
// before this thread can get to it
|
||||
|
||||
if (cityBuilding == null)
|
||||
continue;
|
||||
|
||||
// Do nothing with the banestone. It will be removed elsewhere
|
||||
|
||||
if (cityBuilding.getBlueprint().getBuildingGroup().equals(mbEnums.BuildingGroup.BANESTONE))
|
||||
continue;
|
||||
|
||||
// All buildings are moved to a location relative
|
||||
// to their new parent zone
|
||||
|
||||
localCoords = ZoneManager.worldToLocal(cityBuilding.getLoc(), newParent);
|
||||
|
||||
DbManager.BuildingQueries.MOVE_BUILDING(cityBuilding.getObjectUUID(), newParent.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
|
||||
|
||||
// All buildings are re-parented to a zone one node
|
||||
// higher in the tree (continent) as we will be
|
||||
// deleting the city zone very shortly.
|
||||
|
||||
if (cityBuilding.getParentZoneID() != newParent.getParentZoneID())
|
||||
cityBuilding.setParentZone(newParent);
|
||||
|
||||
// No longer a tree, no longer any protection contract!
|
||||
|
||||
cityBuilding.setProtectionState(mbEnums.ProtectionState.NONE);
|
||||
|
||||
// Remove warehouse entry if one exists.
|
||||
|
||||
if (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.WAREHOUSE) {
|
||||
DbManager.WarehouseQueries.DELETE_WAREHOUSE(city.warehouse);
|
||||
city.warehouse = null;
|
||||
}
|
||||
|
||||
// Mark all auto protected buildings for destruction
|
||||
|
||||
if ((cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.BARRACK) || (cityBuilding.getBlueprint().isWallPiece()) || (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.SHRINE) || (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.TOL) || (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.SPIRE) || (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.WAREHOUSE))
|
||||
destroySet.add(cityBuilding);
|
||||
}
|
||||
|
||||
// Destroy set of auto-protected buildings
|
||||
|
||||
for (Building building : destroySet)
|
||||
if (building.getRank() != -1)
|
||||
BuildingManager.setRank(building, -1);
|
||||
|
||||
if (city.realm != null) {
|
||||
city.realm.removeCity(city.getObjectUUID());
|
||||
city.realm = null;
|
||||
}
|
||||
|
||||
// It's now safe to delete the city zone from the database
|
||||
// which will cause a cascade delete of everything else
|
||||
|
||||
if (!DbManager.ZoneQueries.DELETE_ZONE(cityZone)) {
|
||||
Logger.error("DestroyCityThread", "Database error when deleting city zone: " + cityZone.getObjectUUID());
|
||||
return;
|
||||
}
|
||||
|
||||
// Refresh the city for map requests
|
||||
|
||||
City.lastCityUpdate = System.currentTimeMillis();
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
formerGuild.setGuildState(mbEnums.GuildState.Errant);
|
||||
formerGuild.setNation(null);
|
||||
formerGuild.setCityUUID(0);
|
||||
GuildManager.updateAllGuildTags(formerGuild);
|
||||
GuildManager.updateAllGuildBinds(formerGuild, null);
|
||||
}
|
||||
|
||||
// By losing the tree, the former owners lose all of their subguilds.
|
||||
|
||||
if (!formerGuild.getSubGuildList().isEmpty()) {
|
||||
|
||||
subGuildList = new ArrayList<>();
|
||||
|
||||
subGuildList.addAll(formerGuild.getSubGuildList());
|
||||
|
||||
for (Guild subGuild : subGuildList) {
|
||||
formerGuild.removeSubGuild(subGuild);
|
||||
}
|
||||
}
|
||||
|
||||
Building tol = null;
|
||||
|
||||
// Build list of buildings within this parent zone
|
||||
|
||||
for (Building cityBuilding : cityZone.zoneBuildingSet) {
|
||||
|
||||
// Sanity Check in case player deletes the building
|
||||
// before this thread can get to it
|
||||
|
||||
if (cityBuilding == null)
|
||||
continue;
|
||||
|
||||
// Do nothing with the banestone. It will be removed elsewhere
|
||||
|
||||
if (cityBuilding.getBlueprint().getBuildingGroup().equals(mbEnums.BuildingGroup.BANESTONE))
|
||||
continue;
|
||||
|
||||
// TOL is processed after all other structures in the city zone
|
||||
|
||||
if (cityBuilding.getBlueprint().getBuildingGroup().equals(mbEnums.BuildingGroup.TOL)) {
|
||||
tol = cityBuilding;
|
||||
continue;
|
||||
}
|
||||
|
||||
// All buildings are moved to a location relative
|
||||
// to their new parent zone
|
||||
|
||||
localCoords = ZoneManager.worldToLocal(cityBuilding.getLoc(), newParent);
|
||||
|
||||
DbManager.BuildingQueries.MOVE_BUILDING(cityBuilding.getObjectUUID(), newParent.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
|
||||
|
||||
// All buildings are re-parented to a zone one node
|
||||
// higher in the tree (continent) as we will be
|
||||
// deleting the city zone very shortly.
|
||||
|
||||
if (cityBuilding.getParentZoneID() != newParent.getParentZoneID())
|
||||
cityBuilding.setParentZone(newParent);
|
||||
|
||||
// No longer a tree, no longer any protection contract!
|
||||
|
||||
cityBuilding.setProtectionState(mbEnums.ProtectionState.NONE);
|
||||
|
||||
// Destroy all remaining city assets
|
||||
|
||||
if ((cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.BARRACK)
|
||||
|| (cityBuilding.getBlueprint().isWallPiece())
|
||||
|| (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.SHRINE)
|
||||
|| (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.TOL)
|
||||
|| (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.SPIRE)
|
||||
|| (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.WAREHOUSE)) {
|
||||
|
||||
if (cityBuilding.getRank() != -1)
|
||||
BuildingManager.setRank(cityBuilding, -1);
|
||||
}
|
||||
}
|
||||
|
||||
// Destroy the tol
|
||||
|
||||
if (tol != null)
|
||||
BuildingManager.setRank(tol, -1);
|
||||
|
||||
if (city.realm != null)
|
||||
city.realm.removeCity(city.getObjectUUID());
|
||||
|
||||
// It's now safe to delete the city zone from the database
|
||||
// which will cause a cascade delete of everything else
|
||||
|
||||
|
||||
if (DbManager.ZoneQueries.DELETE_ZONE(cityZone) == false) {
|
||||
Logger.error("DestroyCityThread", "Database error when deleting city zone: " + cityZone.getObjectUUID());
|
||||
return;
|
||||
}
|
||||
|
||||
// Refresh the city for map requests
|
||||
|
||||
City.lastCityUpdate = System.currentTimeMillis();
|
||||
|
||||
// Zone and city should vanish upon next reboot
|
||||
// if the codebase reaches here.
|
||||
|
||||
Logger.info(city.getParent().zoneName + " uuid: " + city.getObjectUUID() + " has been destroyed!");
|
||||
Logger.info(city.getParent().zoneName + " uuid:" + city.getObjectUUID() + "has been destroyed!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,10 +289,10 @@ public class HourlyJobThread implements Runnable {
|
||||
Logger.info(PurgeOprhans.recordsDeleted.toString() + "orphaned items deleted");
|
||||
}
|
||||
|
||||
public static void processBanes() {
|
||||
public static void processBanes(){
|
||||
//handle banes
|
||||
for (Bane bane : Bane.banes.values()) {
|
||||
if (bane.getLiveDate() != null && DateTime.now().isAfter(bane.getLiveDate().minusMinutes(1)) && bane.isStarted == false)
|
||||
for(Bane bane : Bane.banes.values()){
|
||||
if(bane.getLiveDate() != null && DateTime.now().isAfter(bane.getLiveDate().minusMinutes(1)) && bane.isStarted == false)
|
||||
bane.startBane();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user