Compare commits

...

81 Commits

Author SHA1 Message Date
MagicBot c77e7a6190 Check removed 2026-04-26 14:26:18 -04:00
MagicBot 4fde07969b Check removed 2026-04-26 14:06:41 -04:00
MagicBot 2bc7662ccf Handler updated to support fix. 2026-04-26 13:49:37 -04:00
MagicBot ec37634b6a Protocol update. 2026-04-26 13:35:10 -04:00
FatBoy b2bd3b7a92 cancel on take mele damage 2026-02-03 11:51:29 -06:00
FatBoy 461e4e1c3d roollback extra effect cancel on damage 2026-02-03 11:45:47 -06:00
FatBoy 0d1d00e2d1 cancel on take damage for mele dnont flip damage t negatove 2026-02-03 11:33:13 -06:00
FatBoy ec6825d651 cancel on take damage for mele 2026-02-03 11:31:42 -06:00
FatBoy cb561c3b6b validity check for not looking up damage type that doesn't exist 2026-02-03 11:15:24 -06:00
MagicBot cf0f0cf022 Enumeration for server configs. 2026-01-23 11:45:28 -05:00
MagicBot f85673e661 Enumeration for server configs. 2026-01-18 10:08:53 -05:00
MagicBot 84347f8290 statAlt used as offset to terrain. 2026-01-13 14:56:06 -05:00
MagicBot fd2fe92714 Unused methods 2026-01-10 08:45:18 -05:00
MagicBot 955b94eb08 Minor method ordering change 2026-01-10 08:39:13 -05:00
MagicBot a9aa6e9660 Reminder to add power collections later 2026-01-09 13:40:10 -05:00
MagicBot afc080074f Enums needed to support parser. 2026-01-09 13:32:37 -05:00
MagicBot 1039fb1d0b Bonus code added to ConfigManager 2026-01-09 13:26:07 -05:00
MagicBot a955778eed Merge remote-tracking branch 'origin/magicbox-1.5.2.1' into magicbox-1.5.2.1 2026-01-09 13:16:26 -05:00
MagicBot 7717707518 wpak parser added to project 2026-01-09 13:12:40 -05:00
FatBoy 28836a7a4f log null blueprint in destroy city thread 2026-01-08 12:38:42 -06:00
FatBoy 5511dc7899 update lumber hash in mbEnums 2026-01-08 11:53:54 -06:00
FatBoy e5b2247204 disable teleports to cities that are destroyed or errant 2026-01-08 11:52:52 -06:00
FatBoy 0404ca1a94 Allow management of guild mines that are still active 2026-01-08 11:51:12 -06:00
MagicBot 9ad5f239b0 No modtable defaults to workorder. 2024-07-22 16:54:11 -04:00
MagicBot 3db8ee7afd Forge validation for modtables updated. 2024-07-22 16:37:27 -04:00
FatBoy f07974f673 dual wield spam attack issue resolved 2024-07-21 19:46:06 -05:00
FatBoy 0d5cef1652 guilds that have sub guilds can no longer be invited to join nations 2024-07-21 19:36:17 -05:00
FatBoy 04203c092a Lowering stats below item requirement unequips and removes item from map correctly 2024-07-21 19:32:16 -05:00
FatBoy 78feee482b items can now be equipped when skill level exactly meets item requirement 2024-07-21 19:23:34 -05:00
FatBoy 8c35844e08 Huntress pet cannot attack players resolved 2024-07-21 19:16:57 -05:00
FatBoy 0fbb43e021 proc fix 2024-07-12 13:43:28 -04:00
MagicBot 145449f26d Bronzewood mine_production updated. 2024-06-29 14:33:19 -04:00
FatBoy feef6263b4 cleanup 2024-06-27 20:41:43 -05:00
FatBoy 6c622c377f blocked power type structuring 2024-06-27 20:19:11 -05:00
FatBoy 8943121336 blocked power type structuring 2024-06-27 19:54:29 -05:00
FatBoy 70cb469190 final cleanup 2024-06-26 20:44:46 -05:00
FatBoy a42f307a70 immunitiy check compiled to single location 2024-06-26 20:37:28 -05:00
FatBoy 2a3ae6eaec Immunities refresh 2024-06-26 20:24:05 -05:00
FatBoy 9e4b596aa1 enforce KOS for building works 2024-06-26 20:07:37 -05:00
FatBoy aa1fe792a3 Load enforceKOS for buildings 2024-06-26 19:57:50 -05:00
FatBoy 79919121a8 claiming an errant ToL gives ownership to the leader of the guild, not individual player 2024-06-26 19:44:23 -05:00
FatBoy 80ccfff635 Building Management compiled to a single method check 2024-06-26 19:27:32 -05:00
MagicBot 381139af35 Collection of resourceHash 2024-06-26 12:31:08 -04:00
MagicBot e79da63556 Method cleanup. 2024-06-24 03:18:59 -04:00
MagicBot 533565e37e UUID is in keyset 2024-06-24 03:09:38 -04:00
FatBoy da0510d2bc proccing system 2024-06-22 19:50:53 -05:00
FatBoy 1f732a8ca9 failed rune sno longer get consumed 2024-06-22 19:31:13 -05:00
FatBoy 0d24789a93 reverse KOS function completed 2024-06-22 19:22:13 -05:00
FatBoy 35427cfb4a reverse KOS function 2024-06-22 19:04:04 -05:00
MagicBot 695a78b1e2 Noob island filter at 20 2024-06-19 17:57:28 -04:00
MagicBot 9f6710ccb9 More logic work 2024-06-19 17:51:42 -04:00
MagicBot fff1e80f61 More logic work 2024-06-19 17:49:46 -04:00
MagicBot 141af19daa More logic work 2024-06-19 17:38:44 -04:00
MagicBot 630748541f More logic work 2024-06-19 17:36:09 -04:00
MagicBot d32818f351 Rearrange logic 2024-06-19 17:27:04 -04:00
MagicBot d6f94bd0e7 Merged methods 2024-06-19 17:10:49 -04:00
MagicBot db6a4e471d Lore rules added to method 2024-06-19 17:08:56 -04:00
MagicBot a24c611bac Lore rules added to method 2024-06-19 17:01:02 -04:00
MagicBot 3926160ab1 Unused method removed 2024-06-19 16:56:57 -04:00
MagicBot 4a7013de61 Signature update 2024-06-19 16:56:06 -04:00
MagicBot 56564f1c3b Cleanup of teleport list 2024-06-19 16:53:55 -04:00
MagicBot 8a3e39e97d Cleanup of cityChoice handler 2024-06-19 15:05:01 -04:00
MagicBot 5224c79441 Condemned uuid is key not value in map 2024-06-19 14:53:57 -04:00
MagicBot ede016a93d Never null 2024-06-19 14:43:31 -04:00
MagicBot cc1825dec9 Increase to handle larger banks. 2024-06-18 12:43:59 -04:00
MagicBot d257ce50cf Sanity check for null city. 2024-06-18 11:56:19 -04:00
MagicBot 5b246211e1 Warehouse record removed in destruction banes. 2024-06-18 11:51:11 -04:00
FatBoy 33c923b0de fixed immunities in powers manager 2024-06-13 20:47:28 -05:00
FatBoy 02d524663a fixed a lore issue in powers manager 2024-06-13 20:14:43 -05:00
MagicBot 5bd85addb7 Removed count when validating stack withdraw weight. 2024-06-13 15:42:54 -04:00
FatBoy 40bae67443 fixed mob damage defense and ATR 2024-06-12 19:35:20 -05:00
FatBoy 1cf1d731c4 added = to range checks and converted speed to float 2024-06-12 19:23:34 -05:00
MagicBot 24215e21c9 Sanity check for deleted vendors 2024-06-12 14:15:19 -04:00
MagicBot 3accd779b9 Sanity check for deleted vendors 2024-06-12 14:06:18 -04:00
MagicBot 1d673ca2e5 Sanity check for deleted vendors 2024-06-12 14:04:19 -04:00
MagicBot c935ea1986 Project reformat. 2024-06-11 13:40:42 -04:00
MagicBot 678ccafd3c Unused variable removed. 2024-06-11 13:23:49 -04:00
MagicBot 31292785a5 templateHash used in this context. 2024-06-11 13:09:40 -04:00
MagicBot cdc4717033 Update to resources message 2024-06-11 12:54:57 -04:00
MagicBot 35c8ac0289 Update to resources message 2024-06-11 12:53:07 -04:00
MagicBot f5cc4a3290 Update to resource type 2024-06-10 15:19:57 -04:00
53 changed files with 1868 additions and 476 deletions
@@ -58,6 +58,9 @@ public abstract class dbHandlerBase {
int id = rs.getInt(1); int id = rs.getInt(1);
if (id == 39052)
Logger.info(id);
if (DbManager.inCache(localObjectType, id)) { if (DbManager.inCache(localObjectType, id)) {
objectList.add((T) DbManager.getFromCache(localObjectType, id)); objectList.add((T) DbManager.getFromCache(localObjectType, id));
} else { } else {
@@ -136,6 +136,12 @@ public class dbWarehouseHandler extends dbHandlerBase {
int cityUID = rs.getInt("cityUUID"); int cityUID = rs.getInt("cityUUID");
JSONObject jsonObject = new JSONObject(rs.getString("warehouse")); JSONObject jsonObject = new JSONObject(rs.getString("warehouse"));
City city = City.getCity(cityUID); City city = City.getCity(cityUID);
if (city == null) {
Logger.error("No city " + cityUID + " for warehouse");
continue;
}
city.warehouse = new Warehouse(jsonObject); city.warehouse = new Warehouse(jsonObject);
city.warehouse.city = city; city.warehouse.city = city;
@@ -192,6 +198,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
// via the client interface. // via the client interface.
ArrayList<WorkOrder> submitList = new ArrayList<>(); ArrayList<WorkOrder> submitList = new ArrayList<>();
ArrayList<WorkOrder> orphanList = new ArrayList<>();
try (Connection connection = DbManager.getConnection(); try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_workorders`;"); PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_workorders`;");
@@ -209,7 +216,14 @@ public class dbWarehouseHandler extends dbHandlerBase {
// Submit new workOrders to the ForgeManager // Submit new workOrders to the ForgeManager
for (WorkOrder workOrder : submitList) { for (WorkOrder workOrder : submitList) {
DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder); DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder);
// Delete but do not reconstitute orphan workOrders
if (workOrder.vendor == null)
continue;
workOrder.workOrderID = ForgeManager.workOrderCounter.incrementAndGet(); workOrder.workOrderID = ForgeManager.workOrderCounter.incrementAndGet();
DbManager.WarehouseQueries.WRITE_WORKORDER(workOrder); DbManager.WarehouseQueries.WRITE_WORKORDER(workOrder);
ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder);
+57 -67
View File
@@ -104,67 +104,67 @@ public enum BuildingManager {
if (building == null) if (building == null)
return false; return false;
//cannot access destroyed buildings
if (building.getRank() == -1) if (building.getRank() == -1)
return false; return false;
if (IsOwner(building, player)) //admin characters can always access buildings
return true;
//individual friend.
if (building.getFriends() != null && building.getFriends().get(player.getObjectUUID()) != null)
return true;
//Admins can access stuff
if (player.isCSR()) if (player.isCSR())
return true; return true;
//Guild stuff //owner can always access their own building
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)) if (IsOwner(building, player))
return true; return true;
//Somehow guild leader check fails? lets check if Player is true Guild GL. //check for default IC access if building belongs to same guild
if (building.getGuild() != null && building.getGuild().isGuildLeader(player.getObjectUUID())) if(player.guild.equals(building.getGuild())) {
return true; 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;
}
}
}
if (!GuildStatusController.isGuildLeader(player.getGuildStatus()) && !GuildStatusController.isInnerCouncil(player.getGuildStatus())) //check against friends list entries if any present
return false; if (building.getFriends() != null) {
//check individuals
if (building.getFriends().get(player.getObjectUUID()) != null)
return true;
if (building.getFriends().get(player.guild.objectUUID) != null) {
//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;
}
}
}
//did not meet access grant criteria, deny access
return false; return false;
} }
public static synchronized boolean lootBuilding(PlayerCharacter player, Building building) { public static synchronized boolean lootBuilding(PlayerCharacter player, Building building) {
@@ -463,29 +463,19 @@ public enum BuildingManager {
return GuildStatusController.isGuildLeader(player.getGuildStatus()) || GuildStatusController.isInnerCouncil(player.getGuildStatus()); 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) { 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())) if (Guild.sameNationExcludeErrant(building.getGuild(), player.getGuild()))
return false; return false;
if(building.enforceKOS) {
if (building.getCity() != null) {
Building TOL = building.getCity().getTOL();
if (TOL != null) {
building = TOL;
}
}
}
if (!building.reverseKOS) { if (!building.reverseKOS) {
Condemned condemn = building.getCondemned().get(player.getObjectUUID()); Condemned condemn = building.getCondemned().get(player.getObjectUUID());
+61 -28
View File
@@ -12,7 +12,6 @@ import engine.job.JobContainer;
import engine.job.JobScheduler; import engine.job.JobScheduler;
import engine.jobs.AttackJob; import engine.jobs.AttackJob;
import engine.jobs.DeferredPowerJob; import engine.jobs.DeferredPowerJob;
import engine.math.Vector3f;
import engine.mbEnums; import engine.mbEnums;
import engine.net.client.ClientConnection; import engine.net.client.ClientConnection;
import engine.net.client.msg.TargetedActionMsg; import engine.net.client.msg.TargetedActionMsg;
@@ -20,6 +19,7 @@ import engine.net.client.msg.UpdateStateMsg;
import engine.objects.*; import engine.objects.*;
import engine.powers.DamageShield; import engine.powers.DamageShield;
import engine.powers.effectmodifiers.AbstractEffectModifier; import engine.powers.effectmodifiers.AbstractEffectModifier;
import engine.powers.effectmodifiers.WeaponProcEffectModifier;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@@ -124,9 +124,9 @@ public enum CombatManager {
return; return;
//check if this slot is on attack timer, if timer has passed clear it, else early exit //check if this slot is on attack timer, if timer has passed clear it, else early exit
if(attacker.getTimers() != null && attacker.getTimers().containsKey("Attack"+slot.name())) if (attacker.getTimers() != null && attacker.getTimers().containsKey("Attack" + slot.name()))
if(attacker.getTimers().get("Attack"+slot.name()).timeToExecutionLeft() <= 0) if (attacker.getTimers().get("Attack" + slot.name()).timeToExecutionLeft() <= 0)
attacker.getTimers().remove("Attack"+slot.name()); attacker.getTimers().remove("Attack" + slot.name());
else else
return; return;
} }
@@ -156,12 +156,12 @@ public enum CombatManager {
boolean inRange = false; boolean inRange = false;
if (AbstractCharacter.IsAbstractCharacter(target)) { if (AbstractCharacter.IsAbstractCharacter(target)) {
attackRange += ((AbstractCharacter)target).calcHitBox(); attackRange += ((AbstractCharacter) target).calcHitBox();
} else { } else {
} }
if(attackRange > 15 && attacker.isMoving()){ if (attackRange > 15 && attacker.isMoving()) {
//cannot shoot bow while moving; //cannot shoot bow while moving;
return; return;
} }
@@ -169,23 +169,23 @@ public enum CombatManager {
switch (target.getObjectType()) { switch (target.getObjectType()) {
case PlayerCharacter: case PlayerCharacter:
attackRange += ((PlayerCharacter) target).getCharacterHeight() * 0.5f; attackRange += ((PlayerCharacter) target).getCharacterHeight() * 0.5f;
if (distanceSquared < attackRange * attackRange) if (distanceSquared <= attackRange * attackRange)
inRange = true; inRange = true;
break; break;
case Mob: case Mob:
attackRange += ((AbstractCharacter) target).calcHitBox(); attackRange += ((AbstractCharacter) target).calcHitBox();
if (distanceSquared < attackRange * attackRange) if (distanceSquared <= attackRange * attackRange)
inRange = true; inRange = true;
break; break;
case Building: case Building:
if(attackRange > 15){ if (attackRange > 15) {
float rangeSquared = (attackRange + target.getBounds().getHalfExtents().x) * (attackRange + target.getBounds().getHalfExtents().x); float rangeSquared = (attackRange + target.getBounds().getHalfExtents().x) * (attackRange + target.getBounds().getHalfExtents().x);
//float distanceSquared = attacker.loc.distanceSquared(target.loc); //float distanceSquared = attacker.loc.distanceSquared(target.loc);
if(distanceSquared < rangeSquared) { if (distanceSquared < rangeSquared) {
inRange = true; inRange = true;
break; break;
} }
}else { } else {
float locX = target.loc.x - target.getBounds().getHalfExtents().x; float locX = target.loc.x - target.getBounds().getHalfExtents().x;
float locZ = target.loc.z - target.getBounds().getHalfExtents().y; float locZ = target.loc.z - target.getBounds().getHalfExtents().y;
float sizeX = (target.getBounds().getHalfExtents().x + attackRange) * 2; float sizeX = (target.getBounds().getHalfExtents().x + attackRange) * 2;
@@ -202,7 +202,7 @@ public enum CombatManager {
if (weapon != null) { if (weapon != null) {
int wepSpeed = (int) (weapon.template.item_weapon_wepspeed); float wepSpeed = (int) (weapon.template.item_weapon_wepspeed);
if (weapon.getBonusPercent(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None) != 0f) //add weapon speed bonus if (weapon.getBonusPercent(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None) != 0f) //add weapon speed bonus
wepSpeed *= (1 + weapon.getBonus(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None)); wepSpeed *= (1 + weapon.getBonus(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None));
@@ -213,7 +213,7 @@ public enum CombatManager {
if (wepSpeed < 10) if (wepSpeed < 10)
wepSpeed = 10; //Old was 10, but it can be reached lower with legit buffs,effects. wepSpeed = 10; //Old was 10, but it can be reached lower with legit buffs,effects.
delay = wepSpeed * 100L; delay = (long)wepSpeed * 100L;
} }
if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob))
@@ -221,6 +221,16 @@ public enum CombatManager {
if (inRange) { 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;
}
}
//handle retaliate //handle retaliate
if (AbstractCharacter.IsAbstractCharacter(target)) { if (AbstractCharacter.IsAbstractCharacter(target)) {
if (((AbstractCharacter) target).combatTarget == null || !((AbstractCharacter) target).combatTarget.isAlive()) { if (((AbstractCharacter) target).combatTarget == null || !((AbstractCharacter) target).combatTarget.isAlive()) {
@@ -309,7 +319,7 @@ public enum CombatManager {
DispatchManager.sendToAllInRange(attacker, msg); DispatchManager.sendToAllInRange(attacker, msg);
//we need to send the animation even if the attacker misses //we need to send the animation even if the attacker misses
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template,null,slot)); TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template, null, slot));
DispatchManager.sendToAllInRange(target, cmm); DispatchManager.sendToAllInRange(target, cmm);
//set auto attack job //set auto attack job
@@ -349,7 +359,7 @@ public enum CombatManager {
DispatchManager.dispatchMsgToInterestArea(target, msg, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); DispatchManager.dispatchMsgToInterestArea(target, msg, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
//we need to send the animation even if the attacker misses //we need to send the animation even if the attacker misses
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template,null,slot)); TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template, null, slot));
DispatchManager.sendToAllInRange(target, cmm); DispatchManager.sendToAllInRange(target, cmm);
//set auto attack job //set auto attack job
setAutoAttackJob(attacker, slot, delay); setAutoAttackJob(attacker, slot, delay);
@@ -357,6 +367,9 @@ public enum CombatManager {
} }
} }
//check for proccing
checkForProc(attacker,target,weapon);
//calculate the base damage //calculate the base damage
int damage = ThreadLocalRandom.current().nextInt(min, max + 1); int damage = ThreadLocalRandom.current().nextInt(min, max + 1);
if (damage == 0) { if (damage == 0) {
@@ -364,7 +377,7 @@ public enum CombatManager {
setAutoAttackJob(attacker, slot, delay); setAutoAttackJob(attacker, slot, delay);
return; return;
} }
if(attacker.getObjectType().equals(mbEnums.GameObjectType.Mob) && ((Mob)attacker).isPet()) if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob) && ((Mob) attacker).isPet())
calculatePetDamage(attacker); calculatePetDamage(attacker);
//get the damage type //get the damage type
@@ -434,7 +447,7 @@ public enum CombatManager {
if (resists.immuneTo(damageType)) { if (resists.immuneTo(damageType)) {
//set auto attack job //set auto attack job
//we need to send the animation even if the attacker misses //we need to send the animation even if the attacker misses
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template,null,slot)); TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template, null, slot));
DispatchManager.sendToAllInRange(target, cmm); DispatchManager.sendToAllInRange(target, cmm);
setAutoAttackJob(attacker, slot, delay); setAutoAttackJob(attacker, slot, delay);
return; return;
@@ -449,11 +462,12 @@ public enum CombatManager {
if (damage > 0) { if (damage > 0) {
if (AbstractCharacter.IsAbstractCharacter(target)) if (AbstractCharacter.IsAbstractCharacter(target)) {
((AbstractCharacter) target).modifyHealth(-damage, attacker, true); ((AbstractCharacter) target).modifyHealth(-damage, attacker, true);
else ((AbstractCharacter) target).cancelOnTakeDamage();
}else {
((Building) target).modifyHealth(-damage, attacker); ((Building) target).modifyHealth(-damage, attacker);
}
int attackAnim = getSwingAnimation(null, null, slot); int attackAnim = getSwingAnimation(null, null, slot);
if (attacker.charItemManager.getEquipped().get(slot) != null) { if (attacker.charItemManager.getEquipped().get(slot) != null) {
if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) {
@@ -545,7 +559,7 @@ public enum CombatManager {
} }
//Item has no equipment slots and should not try to return an animation, return default instead //Item has no equipment slots and should not try to return an animation, return default instead
if(wb.item_eq_slots_or == null || wb.item_eq_slots_or.isEmpty()){ if (wb.item_eq_slots_or == null || wb.item_eq_slots_or.isEmpty()) {
return 75; return 75;
} }
@@ -554,15 +568,15 @@ public enum CombatManager {
int random; int random;
//Item can only be equipped in one slot, return animation for that slot //Item can only be equipped in one slot, return animation for that slot
if(wb.item_eq_slots_or.size() == 1){ if (wb.item_eq_slots_or.size() == 1) {
if (wb.item_eq_slots_or.iterator().next().equals(mbEnums.EquipSlotType.RHELD)) { if (wb.item_eq_slots_or.iterator().next().equals(mbEnums.EquipSlotType.RHELD)) {
anim = wb.weapon_attack_anim_right.get(0)[0]; anim = wb.weapon_attack_anim_right.get(0)[0];
if (dpj != null) { if (dpj != null) {
random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size()); random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size());
anim = wb.weapon_attack_anim_right.get(random)[0]; anim = wb.weapon_attack_anim_right.get(random)[0];
} }
}else { } else {
anim = wb.weapon_attack_anim_left.get(0)[0]; anim = wb.weapon_attack_anim_left.get(0)[0];
if (dpj != null) { if (dpj != null) {
random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size()); random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size());
anim = wb.weapon_attack_anim_left.get(random)[0]; anim = wb.weapon_attack_anim_left.get(random)[0];
@@ -578,7 +592,7 @@ public enum CombatManager {
random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size()); random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size());
anim = wb.weapon_attack_anim_right.get(random)[0]; anim = wb.weapon_attack_anim_right.get(random)[0];
} }
}else { } else {
anim = wb.weapon_attack_anim_left.get(0)[0]; anim = wb.weapon_attack_anim_left.get(0)[0];
if (dpj != null) { if (dpj != null) {
random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size()); random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size());
@@ -588,8 +602,8 @@ public enum CombatManager {
return anim; return anim;
} }
public static int getPassiveAnimation(mbEnums.PassiveType passiveType){ public static int getPassiveAnimation(mbEnums.PassiveType passiveType) {
switch(passiveType){ switch (passiveType) {
case Block: case Block:
return COMBAT_BLOCK_ANIMATION; return COMBAT_BLOCK_ANIMATION;
case Parry: case Parry:
@@ -604,7 +618,7 @@ public enum CombatManager {
public static void setAutoAttackJob(AbstractCharacter attacker, mbEnums.EquipSlotType slot, long delay) { public static void setAutoAttackJob(AbstractCharacter attacker, mbEnums.EquipSlotType slot, long delay) {
//calculate next allowed attack and update the timestamp //calculate next allowed attack and update the timestamp
if(attacker.getTimestamps().containsKey("Attack" + slot.name()) && attacker.getTimestamps().get("Attack" + slot.name()) > System.currentTimeMillis()) if (attacker.getTimestamps().containsKey("Attack" + slot.name()) && attacker.getTimestamps().get("Attack" + slot.name()) > System.currentTimeMillis())
return; return;
attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis() + delay); attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis() + delay);
@@ -621,6 +635,7 @@ public enum CombatManager {
Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID()); Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID());
} }
public static int calculatePetDamage(AbstractCharacter agent) { public static int calculatePetDamage(AbstractCharacter agent) {
//damage calc for pet //damage calc for pet
float range; float range;
@@ -635,6 +650,7 @@ public enum CombatManager {
damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2; damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2;
return (int) (damage * dmgMultiplier); return (int) (damage * dmgMultiplier);
} }
public static double getMinDmg(double min, AbstractCharacter agent) { public static double getMinDmg(double min, AbstractCharacter agent) {
int primary = agent.getStatStrCurrent(); int primary = agent.getStatStrCurrent();
int secondary = agent.getStatDexCurrent(); int secondary = agent.getStatDexCurrent();
@@ -642,6 +658,7 @@ public enum CombatManager {
int masteryLevel = 0; int masteryLevel = 0;
return min * (pow(0.0048 * primary + .049 * (primary - 0.75), 0.5) + pow(0.0066 * secondary + 0.064 * (secondary - 0.75), 0.5) + +0.01 * (focusLevel + masteryLevel)); return min * (pow(0.0048 * primary + .049 * (primary - 0.75), 0.5) + pow(0.0066 * secondary + 0.064 * (secondary - 0.75), 0.5) + +0.01 * (focusLevel + masteryLevel));
} }
public static double getMaxDmg(double max, AbstractCharacter agent) { public static double getMaxDmg(double max, AbstractCharacter agent) {
int primary = agent.getStatStrCurrent(); int primary = agent.getStatStrCurrent();
int secondary = agent.getStatDexCurrent(); int secondary = agent.getStatDexCurrent();
@@ -649,4 +666,20 @@ public enum CombatManager {
int masteryLevel = 0; 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)); 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);
}
}
}
} }
@@ -164,6 +164,15 @@ public enum ConfigManager {
Logger.info("Compiling regex"); Logger.info("Compiling regex");
regex.put(MB_LOGIN_FNAME_REGEX, Pattern.compile(MB_LOGIN_FNAME_REGEX.getValue())); regex.put(MB_LOGIN_FNAME_REGEX, Pattern.compile(MB_LOGIN_FNAME_REGEX.getValue()));
Logger.info("Loading WPAK data");
// *** Needs powermanager collection
// defined before activation.
// EffectsParser.parseWpakFile();
// PowersParser.parseWpakFile();
// PowerActionParser.parseWpakFile();
return true; return true;
} }
+11 -12
View File
@@ -49,8 +49,15 @@ public enum ForgeManager implements Runnable {
public static final ConcurrentHashMap<NPC, ConcurrentHashMap.KeySetView<WorkOrder, Boolean>> vendorWorkOrderLookup = new ConcurrentHashMap<>(); public static final ConcurrentHashMap<NPC, ConcurrentHashMap.KeySetView<WorkOrder, Boolean>> vendorWorkOrderLookup = new ConcurrentHashMap<>();
public static final ConcurrentHashMap<Item, WorkOrder> itemWorkOrderLookup = new ConcurrentHashMap<>(); public static final ConcurrentHashMap<Item, WorkOrder> itemWorkOrderLookup = new ConcurrentHashMap<>();
@Override public static void start() {
Thread forgeManager;
forgeManager = new Thread(FORGE_MANAGER);
forgeManager.setName("Forge Manager");
forgeManager.start();
}
@Override
public void run() { public void run() {
WorkOrder workOrder; WorkOrder workOrder;
@@ -67,7 +74,7 @@ public enum ForgeManager implements Runnable {
// Early exit for completed workOrders loaded from disk // Early exit for completed workOrders loaded from disk
// or vendors who were re-deeded with items still cooking. // 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; continue;
// This workOrder has completed production. // This workOrder has completed production.
@@ -112,14 +119,6 @@ public enum ForgeManager implements Runnable {
} }
} }
public static void start() {
Thread forgeManager;
forgeManager = new Thread(FORGE_MANAGER);
forgeManager.setName("Forge Manager");
forgeManager.start();
}
public static int submit(WorkOrder workOrder) { public static int submit(WorkOrder workOrder) {
// Must have a city to roll anything // Must have a city to roll anything
@@ -265,12 +264,12 @@ public enum ForgeManager implements Runnable {
// Assign a prefix and suffix to this item if random rolled // Assign a prefix and suffix to this item if random rolled
if (workOrder.prefixToken == 0) if (workOrder.prefixToken == 0 && workOrder.vendor.getItemModTable().contains((template.modTable)))
forgedItem.prefixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.PREFIX, template.modTable); forgedItem.prefixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.PREFIX, template.modTable);
else else
forgedItem.prefixToken = workOrder.prefixToken; forgedItem.prefixToken = workOrder.prefixToken;
if (workOrder.suffixToken == 0) if (workOrder.suffixToken == 0 && workOrder.vendor.getItemModTable().contains((template.modTable)))
forgedItem.suffixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.SUFFIX, template.modTable); forgedItem.suffixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.SUFFIX, template.modTable);
else else
forgedItem.suffixToken = workOrder.suffixToken; forgedItem.suffixToken = workOrder.suffixToken;
+1 -1
View File
@@ -102,7 +102,7 @@ public enum ItemManager {
if (characterSkill == null) if (characterSkill == null)
return false; return false;
if (characterSkill.getModifiedAmountBeforeMods() > required_value) if (characterSkill.getModifiedAmountBeforeMods() >= required_value)
return true; return true;
} }
+22 -10
View File
@@ -176,12 +176,29 @@ public enum PowersManager {
PowersBase pb = PowersManager.powersBaseByToken.get(msg.getPowerUsedID()); PowersBase pb = PowersManager.powersBaseByToken.get(msg.getPowerUsedID());
PlayerCharacter caster = origin.getPlayerCharacter(); PlayerCharacter caster = origin.getPlayerCharacter();
PlayerCharacter target = PlayerCharacter.getFromCache(msg.getTargetID()); PlayerCharacter target = PlayerCharacter.getFromCache(msg.getTargetID());
if (pb != null && pb.isHarmful == false) { if (pb != null && pb.enforceLore()) {
//if (caster.guild.equals(Guild.getErrantGuild())) //if (caster.guild.equals(Guild.getErrantGuild()))
// return; // return;
if (target != null && caster.guild.getGuildType().equals(target.guild.getGuildType()) == false && target.getObjectType().equals(GameObjectType.Building) == false) 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);
}
return; return;
}
} }
} }
@@ -908,10 +925,6 @@ public enum PowersManager {
if (pb.isHarmful()) if (pb.isHarmful())
mobTarget.handleDirectAggro(playerCharacter); 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 // update target of used power timer
@@ -933,8 +946,7 @@ public enum PowersManager {
continue; continue;
// If something blocks the action, then stop // If something blocks the action, then stop
if (ab.blocked(target, pb, trains)) { if (ab.blocked(target,pb.vampDrain)) {
PowersManager.sendEffectMsg(playerCharacter, 5, ab, pb); PowersManager.sendEffectMsg(playerCharacter, 5, ab, pb);
continue; continue;
} }
@@ -1109,7 +1121,7 @@ public enum PowersManager {
continue; continue;
// If something blocks the action, then stop // If something blocks the action, then stop
if (ab.blocked(target, pb, trains)) if (ab.blocked(target,pb.vampDrain))
continue; continue;
// TODO handle overwrite stack order here // TODO handle overwrite stack order here
String stackType = ab.getStackType(); String stackType = ab.getStackType();
@@ -1423,7 +1435,7 @@ public enum PowersManager {
if (trains < ab.getMinTrains() || trains > ab.getMaxTrains()) if (trains < ab.getMinTrains() || trains > ab.getMaxTrains())
continue; continue;
// If something blocks the action, then stop // If something blocks the action, then stop
if (ab.blocked(target, pb, trains)) if (ab.blocked(target,pb.vampDrain))
// sendPowerMsg(pc, 5, msg); // sendPowerMsg(pc, 5, msg);
continue; continue;
// TODO handle overwrite stack order here // TODO handle overwrite stack order here
+8 -1
View File
@@ -84,6 +84,11 @@ public class WorkOrder implements Delayed {
this.completionTime = jsonWorkOrder.getLong("completionTime"); this.completionTime = jsonWorkOrder.getLong("completionTime");
this.runCompleted.set(jsonWorkOrder.getBoolean("runCompleted")); this.runCompleted.set(jsonWorkOrder.getBoolean("runCompleted"));
// Vendor sanity check. Might have been deleted
if (this.vendor == null)
return;
JSONObject productionCostMap = jsonWorkOrder.getJSONObject("production_cost"); JSONObject productionCostMap = jsonWorkOrder.getJSONObject("production_cost");
for (String key : productionCostMap.keySet()) { for (String key : productionCostMap.keySet()) {
@@ -107,6 +112,7 @@ public class WorkOrder implements Delayed {
for (Object o : tokenList) { for (Object o : tokenList) {
int prefix = ((JSONArray) o).getInt(0); int prefix = ((JSONArray) o).getInt(0);
int suffix = ((JSONArray) o).getInt(1); int suffix = ((JSONArray) o).getInt(1);
Item cookingItem = ForgeManager.forgeItem(this); Item cookingItem = ForgeManager.forgeItem(this);
cookingItem.prefixToken = prefix; cookingItem.prefixToken = prefix;
cookingItem.suffixToken = suffix; cookingItem.suffixToken = suffix;
@@ -129,7 +135,8 @@ public class WorkOrder implements Delayed {
if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt)) if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt))
return 30; //30: That person cannot carry that item return 30; //30: That person cannot carry that item
if (!workOrder.vendor.getItemModTable().contains((template.modTable))) if ((workOrder.prefixToken != 0 || workOrder.suffixToken != 0) &&
!workOrder.vendor.getItemModTable().contains((template.modTable)))
return 59; //59: This hireling does not have this formula return 59; //59: This hireling does not have this formula
if (!Warehouse.calcCostOverrun(workOrder).isEmpty()) if (!Warehouse.calcCostOverrun(workOrder).isEmpty())
+136 -34
View File
@@ -831,20 +831,38 @@ public class mbEnums {
SPIRES, SPIRES,
SNARE, SNARE,
STUN, STUN,
BLIND, BLINDNESS,
ROOT, ROOT,
FEAR, FEAR,
CHARM, CHARM,
POWERBLOCK, POWERINHIBITOR,
DEBUFF, DEBUFF,
STEAL, STEAL,
DRAIN; DRAIN;
public static DamageType getDamageType(String modName) { public static DamageType getDamageType(String modName) {
DamageType damageType;
if (modName.isEmpty()) if (modName.isEmpty())
return DamageType.NONE; return DamageType.NONE;
if(modName.toLowerCase().equals("blind"))
modName = "BLINDNESS";
if(modName.toLowerCase().equals("powerblock"))
modName = "POWERINHIBITOR";
//validity check for not looking up damage type that doesn't exist
boolean valid = false;
for(DamageType type : DamageType.values()){
if(type.name().equals(modName))
valid = true;
}
if(!valid)
return DamageType.NONE;
DamageType damageType;
try { try {
damageType = DamageType.valueOf(modName.replace(",", "").toUpperCase()); damageType = DamageType.valueOf(modName.replace(",", "").toUpperCase());
} catch (Exception e) { } catch (Exception e) {
@@ -2715,42 +2733,45 @@ public class mbEnums {
public enum ResourceType { public enum ResourceType {
GOLD(7, 2308551, 100000000, 10), GOLD(7, -1670881623, 2308551, 100000000, 50000),
ADAMANT(1580003, -1741189964, 1000, 10), ADAMANT(1580003, 1557001525, -1741189964, 1000, 10),
AGATE(1580009, 75173057, 2000, 10), AGATE(1580009, -1096157543, 75173057, 2000, 20),
ANTIMONY(1580014, 452320058, 1000, 10), ANTIMONY(1580014, 1256147265, 452320058, 1000, 10),
AZOTH(1580012, 78329697, 2000, 10), AZOTH(1580012, -1205326951, 78329697, 2000, 20),
BLOODSTONE(1580020, -1569826353, 500, 10), BLOODSTONE(1580020, -1912381716, -1569826353, 500, 5),
BRONZEWOOD(1580006, 1334770447, 500, 10), BRONZEWOOD(1580006, -519681813, 1334770447, 1000, 30),
COAL(1580008, 2559427, 3000, 10), COAL(1580008, -1672872311, 2559427, 3000, 30),
DIAMOND(1580010, -1730704107, 2000, 10), DIAMOND(1580010, 1540225085, -1730704107, 2000, 20),
GALVOR(1580017, -1596311545, 2000, 10), GALVOR(1580017, -1683992404, -1596311545, 2000, 5),
IRON(1580002, 2504297, 2000, 10), IRON(1580002, -1673518119, 2504297, 2000, 20),
LUMBER(1580004, -1603256692, 10000, 10), LUMBER(1580004, -1628412684, -1603256692, 10000, 100),
MANDRAKE(1580007, 1191391799, 1000, 10), MANDRAKE(1580007, 1519910613, 1191391799, 1000, 10),
MITHRIL(1580021, -1761257186, 500, 10), MITHRIL(1580021, 626743397, -1761257186, 500, 5),
OAK(1580005, 74767, 3000, 10), OAK(1580005, -1653034775, 74767, 3000, 30),
OBSIDIAN(1580019, -697973233, 500, 10), OBSIDIAN(1580019, 778019055, -697973233, 500, 5),
ONYX(1580011, 2977263, 1000, 10), ONYX(1580011, -1675952151, 2977263, 1000, 10),
ORICHALK(1580013, -2036290524, 3000, 10), ORICHALK(1580013, -1468730955, -2036290524, 3000, 30),
QUICKSILVER(1580016, -472884509, 1000, 10), QUICKSILVER(1580016, -2081208434, -472884509, 1000, 10),
STONE(1580000, 74856115, 10000, 10), STONE(1580000, -1094703863, 74856115, 10000, 100),
SULFUR(1580015, -1586349421, 1000, 10), SULFUR(1580015, -1763687412, -1586349421, 1000, 10),
TRUESTEEL(1580001, -317484979, 2000, 10), TRUESTEEL(1580001, -169012482, -317484979, 2000, 20),
WORMWOOD(1580018, 1532478436, 500, 10); WORMWOOD(1580018, 1204785075, 1532478436, 500, 5);
public static HashMap<Integer, ResourceType> resourceLookup = new HashMap<>(); public static HashMap<Integer, ResourceType> templateLookup = new HashMap<>();
public static HashMap<Integer, ResourceType> hashLookup = new HashMap<>(); public static HashMap<Integer, ResourceType> templateHashLookup = new HashMap<>();
public static HashMap<Integer, ResourceType> resourceHashLookup = new HashMap<>();
public int templateID; public int templateID;
public ItemTemplate template; public ItemTemplate template;
public int hash; public int resourceHash;
public int templateHash;
public int deposit_limit; public int deposit_limit;
public int mine_production; public int mine_production;
ResourceType(int templateID, int hash, int deposit_limit, int mine_production) { ResourceType(int templateID, int resourceHash, int templateHash, int deposit_limit, int mine_production) {
this.templateID = templateID; this.templateID = templateID;
this.template = ItemTemplate.templates.get(this.templateID); this.template = ItemTemplate.templates.get(this.templateID);
this.hash = hash; this.resourceHash = resourceHash;
this.templateHash = templateHash;
this.deposit_limit = deposit_limit; this.deposit_limit = deposit_limit;
this.mine_production = mine_production; this.mine_production = mine_production;
} }
@@ -2758,11 +2779,11 @@ public class mbEnums {
public static void InitializeResourceTypes() { public static void InitializeResourceTypes() {
for (ResourceType resourceType : ResourceType.values()) { for (ResourceType resourceType : ResourceType.values()) {
resourceLookup.put(resourceType.templateID, resourceType); templateLookup.put(resourceType.templateID, resourceType);
hashLookup.put(resourceType.hash, resourceType); templateHashLookup.put(resourceType.templateHash, resourceType);
resourceHashLookup.put(resourceType.resourceHash, resourceType);
} }
} }
} }
@@ -3013,5 +3034,86 @@ public class mbEnums {
PREFIX, PREFIX,
SUFFIX; SUFFIX;
} }
public enum PowerType {
None,
SPELL,
SKILL
}
public enum CostType {
NONE,
HEALTH,
MANA,
STAMINA
}
public enum AreaType {
NONE,
SPHERE,
POINTBLANK,
LINE,
CONE,
WALL
}
public enum ExcludeType {
NONE,
CASTER,
GROUP,
GUILD,
NATION,
PLAYERS,
ALLBUTGROUP,
ALLBUTPETS
}
public enum CastingModeType {
NONE,
COMBAT,
NONCOMBAT,
BOTH
}
public enum TargetSelectType {
NONE,
CLICK,
GROUP,
GUILD,
NEARBYMOBS,
NAME
}
public enum CategoryToPowerType {
None,
GreaterThanOrEqualTo,
GreaterThan,
Always
}
public enum ModificationType {
ADD,
MULTIPLY
}
public enum ServerConfig {
MBDB_108("AERYNTH", "ARAC", "MOURNING", 300000),
MBDB_192("DALGOTH", "ARAC", "GOOK", 300001),
MBDB_162("VORGINA", "LORE", "SAEDRON", 300002),
MBDB_164("VORGINA", "ARAC", "THURIN", 300002);
public final String mapType;
public final String ruleType;
public final String serverName;
public final int realmMap;
ServerConfig(String mapType, String ruleType, String serverName, int realmMap) {
this.mapType = mapType;
this.ruleType = ruleType;
this.serverName = serverName;
this.realmMap = realmMap;
}
}
} }
+27 -27
View File
@@ -100,7 +100,7 @@ public class MobAI {
public static void attackPlayer(Mob mob, PlayerCharacter target) { public static void attackPlayer(Mob mob, PlayerCharacter target) {
try { try {
if(target == null || !target.isAlive() || !target.isActive() ) { if (target == null || !target.isAlive() || !target.isActive()) {
mob.setCombatTarget(null); mob.setCombatTarget(null);
return; return;
} }
@@ -175,7 +175,7 @@ public class MobAI {
public static void attackMob(Mob mob, Mob target) { public static void attackMob(Mob mob, Mob target) {
try { try {
if(mob == null || target == null) if (mob == null || target == null)
return; return;
if (mob.getRange() >= 30 && mob.isMoving()) if (mob.getRange() >= 30 && mob.isMoving())
@@ -975,36 +975,36 @@ public class MobAI {
} }
private static void hamletGuardAggro(Mob mob) { private static void hamletGuardAggro(Mob mob) {
Realm realm = RealmMap.getRealmAtLocation(mob.loc); Realm realm = RealmMap.getRealmAtLocation(mob.loc);
if(realm.getRealmName().equals("Uthgaard")){ if (realm.getRealmName().equals("Uthgaard")) {
HashSet<AbstractWorldObject> loadedMobs = WorldGrid.getObjectsInRangePartial(mob.loc, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_MOB); HashSet<AbstractWorldObject> loadedMobs = WorldGrid.getObjectsInRangePartial(mob.loc, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_MOB);
for (AbstractWorldObject awo : loadedMobs) { for (AbstractWorldObject awo : loadedMobs) {
Mob targetMob = (Mob) awo; Mob targetMob = (Mob) awo;
if (targetMob.equals(mob)) if (targetMob.equals(mob))
continue; continue;
if (!targetMob.isAlive() || targetMob.despawned) if (!targetMob.isAlive() || targetMob.despawned)
continue; continue;
if (targetMob.isPet()) if (targetMob.isPet())
continue; continue;
mob.combatTarget = targetMob; mob.combatTarget = targetMob;
return;
}
return; return;
} }
HashSet<AbstractWorldObject> loadedPlayers = WorldGrid.getObjectsInRangePartial(mob.loc, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_PLAYER); return;
for (AbstractWorldObject awo : loadedPlayers) { }
PlayerCharacter pc = (PlayerCharacter) awo; HashSet<AbstractWorldObject> loadedPlayers = WorldGrid.getObjectsInRangePartial(mob.loc, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_PLAYER);
if (!pc.isAlive() || !pc.isActive()) for (AbstractWorldObject awo : loadedPlayers) {
continue; PlayerCharacter pc = (PlayerCharacter) awo;
if (pc.guild.equals(Guild.getErrantGuild())) { if (!pc.isAlive() || !pc.isActive())
mob.combatTarget = pc; continue;
return; if (pc.guild.equals(Guild.getErrantGuild())) {
}
if (pc.guild.charter.equals(mob.guild.charter))
continue;
mob.combatTarget = pc; mob.combatTarget = pc;
return; return;
} }
if (pc.guild.charter.equals(mob.guild.charter))
continue;
mob.combatTarget = pc;
return;
}
} }
private static void defaultLogic(Mob mob) { private static void defaultLogic(Mob mob) {
+1 -1
View File
@@ -128,7 +128,7 @@ public enum Protocol {
ITEMPRODUCTION(0x3CCE8E30, ItemProductionMsg.class, ItemProductionMsgHandler.class), ITEMPRODUCTION(0x3CCE8E30, ItemProductionMsg.class, ItemProductionMsgHandler.class),
ITEMTOVAULT(0x3ABE4927, ItemToVaultMsg.class, ItemToVaultMsgHandler.class), // Transfer Item to Vault ITEMTOVAULT(0x3ABE4927, ItemToVaultMsg.class, ItemToVaultMsgHandler.class), // Transfer Item to Vault
ITEMFROMVAULT(0x0119A64D, ItemFromVaultMsg.class, ItemFromVaultMsgHandler.class), // Transfer Item from Vault to Inventory ITEMFROMVAULT(0x0119A64D, ItemFromVaultMsg.class, ItemFromVaultMsgHandler.class), // Transfer Item from Vault to Inventory
JOINFORPROVINCE(0x1FB369CD, AcceptSubInviteMsg.class, AcceptSubInviteHandler.class), //Response to invite to swear? JOINFORPROVINCE(0x1FB369CD, AcceptSubInviteMsg.class, SwearInGuildHandler.class), //Response to invite to swear?
JOINFORSWORN(0xF6A4170F, null, null), JOINFORSWORN(0xF6A4170F, null, null),
JOINGROUP(0x7EC5E636, GroupInviteResponseMsg.class, GroupInviteResponseHandler.class), // Accept Group Invite JOINGROUP(0x7EC5E636, GroupInviteResponseMsg.class, GroupInviteResponseHandler.class), // Accept Group Invite
JOINGUILD(0xF0C5F2FF, AcceptInviteToGuildMsg.class, AcceptInviteToGuildHandler.class), // Accept guild invite JOINGUILD(0xF0C5F2FF, AcceptInviteToGuildMsg.class, AcceptInviteToGuildHandler.class), // Accept guild invite
@@ -50,7 +50,7 @@ public class ArcMineChangeProductionMsgHandler extends AbstractClientMsgHandler
//make sure valid resource //make sure valid resource
mbEnums.ResourceType resource = mbEnums.ResourceType.hashLookup.get(changeProductionMsg.getResourceHash()); mbEnums.ResourceType resource = mbEnums.ResourceType.resourceHashLookup.get(changeProductionMsg.getResourceHash());
if (resource == null) if (resource == null)
return true; return true;
@@ -102,7 +102,7 @@ public class ClaimGuildTreeMsgHandler extends AbstractClientMsgHandler {
if (building.getGuild().isEmptyGuild()) if (building.getGuild().isEmptyGuild())
return true; return true;
if (!ManageCityAssetMsgHandler.playerCanManageNotFriends(sourcePlayer, building)) if (!BuildingManager.playerCanManage(sourcePlayer, building))
return true; return true;
@@ -159,7 +159,7 @@ public class ClaimGuildTreeMsgHandler extends AbstractClientMsgHandler {
(building == null) || playerZone == null || playerCity == null) (building == null) || playerZone == null || playerCity == null)
return true; return true;
if (!ManageCityAssetMsgHandler.playerCanManageNotFriends(sourcePlayer, building)) if (!BuildingManager.playerCanManage(sourcePlayer, building))
return true; return true;
boolean open = (msg.getMessageType() == OPEN_CITY); boolean open = (msg.getMessageType() == OPEN_CITY);
@@ -102,6 +102,9 @@ public class InviteToSubHandler extends AbstractClientMsgHandler {
//source guild is limited to 7 subs //source guild is limited to 7 subs
//TODO this should be based on TOL rank //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)) { if (!sourceGuild.canSubAGuild(targetGuild)) {
sendChat(source, "This Guild can't be subbed."); sendChat(source, "This Guild can't be subbed.");
@@ -28,30 +28,6 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler {
super(); 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 @Override
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) { protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) {
@@ -248,7 +248,7 @@ public class MerchantMsgHandler extends AbstractClientMsgHandler {
City targetCity = null; City targetCity = null;
if (isTeleport) if (isTeleport)
cities = City.getCitiesToTeleportTo(player); cities = City.getCitiesToTeleportTo(player, false);
else else
cities = City.getCitiesToRepledgeTo(player); cities = City.getCitiesToRepledgeTo(player);
for (City city : cities) { for (City city : cities) {
@@ -264,8 +264,9 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
player.cancelOnSpell(); player.cancelOnSpell();
break; break;
case RUNE: case RUNE:
ApplyRuneMsg.applyRune(uuid, origin, player); if(ApplyRuneMsg.applyRune(uuid, origin, player)) {
itemMan.consume(item); itemMan.consume(item);
}
break; break;
default: //shouldn't be here, consume item default: //shouldn't be here, consume item
dispatch = Dispatch.borrow(player, msg); dispatch = Dispatch.borrow(player, msg);
@@ -183,7 +183,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
if (building == null) if (building == null)
return; return;
if (ManageCityAssetMsgHandler.playerCanManageNotFriends(player, building) == false) if (BuildingManager.playerCanManage(player, building) == false)
return; return;
if (orderNpcMsg.getPatrolSize() >= 20) if (orderNpcMsg.getPatrolSize() >= 20)
@@ -411,7 +411,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
case 2: case 2:
player = SessionManager.getPlayerCharacter(origin); player = SessionManager.getPlayerCharacter(origin);
if (ManageCityAssetMsgHandler.playerCanManageNotFriends(player, building) == false) if (BuildingManager.playerCanManage(player, building) == false)
return true; return true;
if (building.getHirelings().containsKey(npc) == false) if (building.getHirelings().containsKey(npc) == false)
@@ -54,7 +54,7 @@ public class PetAttackMsgHandler extends AbstractClientMsgHandler {
pet.setCombatTarget(PlayerCharacter.getPlayerCharacter(msg.getTargetID())); pet.setCombatTarget(PlayerCharacter.getPlayerCharacter(msg.getTargetID()));
switch (msg.getTargetType()) { switch (msg.getTargetType()) {
case 53: //player character case 52: //player character
pet.setCombatTarget(PlayerCharacter.getPlayerCharacter(msg.getTargetID())); pet.setCombatTarget(PlayerCharacter.getPlayerCharacter(msg.getTargetID()));
break; break;
case 37://mob case 37://mob
@@ -17,8 +17,8 @@ import engine.net.Dispatch;
import engine.net.client.ClientConnection; import engine.net.client.ClientConnection;
import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.ErrorPopupMsg; import engine.net.client.msg.ErrorPopupMsg;
import engine.net.client.msg.guild.AcceptSubInviteMsg;
import engine.net.client.msg.guild.SendGuildEntryMsg; import engine.net.client.msg.guild.SendGuildEntryMsg;
import engine.net.client.msg.guild.SwearInGuildMsg;
import engine.objects.City; import engine.objects.City;
import engine.objects.Guild; import engine.objects.Guild;
import engine.objects.GuildStatusController; import engine.objects.GuildStatusController;
@@ -36,18 +36,18 @@ public class SwearInGuildHandler extends AbstractClientMsgHandler {
@Override @Override
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) { protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) {
PlayerCharacter player; PlayerCharacter player;
SwearInGuildMsg swearInMsg; AcceptSubInviteMsg swearInMsg;
Guild targetGuild; Guild targetGuild;
Guild nation; Guild nation;
Dispatch dispatch; Dispatch dispatch;
swearInMsg = (SwearInGuildMsg) baseMsg; swearInMsg = (AcceptSubInviteMsg) baseMsg;
player = SessionManager.getPlayerCharacter(origin); player = SessionManager.getPlayerCharacter(origin);
if (player == null) if (player == null)
return true; return true;
targetGuild = (Guild) DbManager.getObject(GameObjectType.Guild, swearInMsg.getGuildUUID()); targetGuild = (Guild) DbManager.getObject(GameObjectType.Guild, swearInMsg.guildUUID());
if (targetGuild == null) { if (targetGuild == null) {
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occured. Please post details for to ensure transaction integrity"); ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occured. Please post details for to ensure transaction integrity");
@@ -66,15 +66,6 @@ public class SwearInGuildHandler extends AbstractClientMsgHandler {
ErrorPopupMsg.sendErrorMsg(player, "Your guild is not a nation!"); ErrorPopupMsg.sendErrorMsg(player, "Your guild is not a nation!");
return true; return true;
} }
if (!nation.getSubGuildList().contains(targetGuild)) {
ErrorPopupMsg.sendErrorMsg(player, "Your do not have such authority!");
return true;
}
if (!Guild.canSwearIn(targetGuild)) {
ErrorPopupMsg.sendErrorMsg(player, targetGuild.getGuildState().name() + "cannot be sworn in");
return true;
}
if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false) { if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false) {
ErrorPopupMsg.sendErrorMsg(player, "Your do not have such authority!"); ErrorPopupMsg.sendErrorMsg(player, "Your do not have such authority!");
@@ -86,16 +77,8 @@ public class SwearInGuildHandler extends AbstractClientMsgHandler {
return true; return true;
} }
switch (targetGuild.getGuildState()) { if (targetGuild.getGuildState().equals(GuildState.Errant))
case Petitioner: GuildManager.updateAllGuildBinds(targetGuild, nation.getOwnedCity());
GuildManager.updateAllGuildBinds(targetGuild, nation.getOwnedCity());
break;
case Protectorate:
break;
default:
//shouldn't get here.
break;
}
//update Guild state. //update Guild state.
targetGuild.setNation(nation); targetGuild.setNation(nation);
@@ -53,7 +53,7 @@ public class TransferGoldToFromBuildingMsgHandler extends AbstractClientMsgHandl
if (msg.getDirection() == 2) { if (msg.getDirection() == 2) {
if (!ManageCityAssetMsgHandler.playerCanManageNotFriends(player, building)) if (!BuildingManager.playerCanManage(player, building))
return true; return true;
if (building.setReserve(msg.getUnknown01(), player)) { if (building.setReserve(msg.getUnknown01(), player)) {
dispatch = Dispatch.borrow(player, msg); dispatch = Dispatch.borrow(player, msg);
@@ -59,7 +59,7 @@ public class SendOwnPlayerMsg extends ClientNetMsg {
@Override @Override
protected int getPowerOfTwoBufferSize() { protected int getPowerOfTwoBufferSize() {
//Larger size for historically larger opcodes //Larger size for historically larger opcodes
return (17); // 2^17 == 131,072 return (18); // 2^17 == 131,072
} }
/** /**
@@ -73,10 +73,8 @@ public class TeleportRepledgeListMsg extends ClientNetMsg {
public void configure() { public void configure() {
if (isTeleport) cities = City.getCitiesToTeleportTo(player, !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())) { for (mbEnums.ResourceType resourceType : (warehouseObject.resources.keySet())) {
writer.putInt(resourceType.hash); writer.putInt(resourceType.templateHash);
writer.putInt((warehouseObject.resources.get(resourceType))); writer.putInt((warehouseObject.resources.get(resourceType)));
@@ -107,7 +107,7 @@ public class ViewResourcesMsg extends ClientNetMsg {
for (mbEnums.ResourceType resourceType : warehouseObject.resources.keySet()) { for (mbEnums.ResourceType resourceType : warehouseObject.resources.keySet()) {
writer.putInt(resourceType.hash); writer.putInt(resourceType.templateHash);
writer.putInt(0); //available? writer.putInt(0); //available?
writer.putInt(resourceType.deposit_limit); //max? writer.putInt(resourceType.deposit_limit); //max?
} }
+9 -9
View File
@@ -656,13 +656,13 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
AssignDamageAtrForPlayers(abstractCharacter, equipped.get(EquipSlotType.LHELD), false, equipped.get(EquipSlotType.LHELD)); AssignDamageAtrForPlayers(abstractCharacter, equipped.get(EquipSlotType.LHELD), false, equipped.get(EquipSlotType.LHELD));
if (abstractCharacter.getObjectType().equals(GameObjectType.Mob)) { if (abstractCharacter.getObjectType().equals(GameObjectType.Mob)) {
Mob mob = (Mob) abstractCharacter; Mob mob = (Mob) abstractCharacter;
abstractCharacter.minDamageHandOne += (int) mob.mobBase.getDamageMin(); abstractCharacter.minDamageHandOne = (int) mob.mobBase.getDamageMin();
abstractCharacter.minDamageHandTwo += (int) mob.mobBase.getDamageMin(); abstractCharacter.minDamageHandTwo = (int) mob.mobBase.getDamageMin();
abstractCharacter.maxDamageHandOne += (int) mob.mobBase.getDamageMax(); abstractCharacter.maxDamageHandOne = (int) mob.mobBase.getDamageMax();
abstractCharacter.maxDamageHandTwo += (int) mob.mobBase.getDamageMax(); abstractCharacter.maxDamageHandTwo = (int) mob.mobBase.getDamageMax();
abstractCharacter.atrHandOne += mob.mobBase.getAttackRating(); abstractCharacter.atrHandOne = mob.mobBase.getAttackRating();
abstractCharacter.atrHandTwo += mob.mobBase.getAttackRating(); abstractCharacter.atrHandTwo = mob.mobBase.getAttackRating();
abstractCharacter.defenseRating += mob.mobBase.getDefenseRating(); abstractCharacter.defenseRating = mob.mobBase.getDefenseRating();
} }
} }
@@ -806,7 +806,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
speed *= (1 + abstractCharacter.bonuses.getFloatPercentAll(ModType.WeaponSpeed, SourceType.None)); speed *= (1 + abstractCharacter.bonuses.getFloatPercentAll(ModType.WeaponSpeed, SourceType.None));
PlayerBonuses bonuses = abstractCharacter.bonuses; PlayerBonuses bonuses = abstractCharacter.bonuses;
if(bonuses != null){ if (bonuses != null) {
ModType modType = ModType.AttackDelay; ModType modType = ModType.AttackDelay;
for (AbstractEffectModifier mod : bonuses.bonusFloats.keySet()) { for (AbstractEffectModifier mod : bonuses.bonusFloats.keySet()) {
@@ -1829,7 +1829,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
Mob target = (Mob) this; Mob target = (Mob) this;
if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter)) { if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter)) {
if(target.playerAgroMap.containsKey(attacker.getObjectUUID())) if (target.playerAgroMap.containsKey(attacker.getObjectUUID()))
target.playerAgroMap.put(attacker.getObjectUUID(), target.playerAgroMap.get(attacker.getObjectUUID()) + value); target.playerAgroMap.put(attacker.getObjectUUID(), target.playerAgroMap.get(attacker.getObjectUUID()) + value);
else else
target.playerAgroMap.put(attacker.getObjectUUID(), value); target.playerAgroMap.put(attacker.getObjectUUID(), value);
+6 -6
View File
@@ -641,18 +641,18 @@ public final class Bane {
return cityUUID; return cityUUID;
} }
public void startBane(){ public void startBane() {
City city = this.getCity(); City city = this.getCity();
if(city == null) if (city == null)
return; return;
this.isStarted = true; //flag the bane as started this.isStarted = true; //flag the bane as started
for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(city.loc,mbEnums.CityBoundsType.ZONE.halfExtents + 64,MBServerStatics.MASK_BUILDING)){ for (AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(city.loc, mbEnums.CityBoundsType.ZONE.halfExtents + 64, MBServerStatics.MASK_BUILDING)) {
Building building = (Building)awo; Building building = (Building) awo;
if(building == null) if (building == null)
continue; continue;
if(building.protectionState.equals(ProtectionState.UNDERSIEGE) == false) if (building.protectionState.equals(ProtectionState.UNDERSIEGE) == false)
building.protectionState = ProtectionState.UNDERSIEGE; building.protectionState = ProtectionState.UNDERSIEGE;
} }
+7 -2
View File
@@ -163,6 +163,11 @@ public class Building extends AbstractWorldObject {
if (upgradeTimeStamp != null) if (upgradeTimeStamp != null)
this.upgradeDateTime = LocalDateTime.ofInstant(upgradeTimeStamp.toInstant(), ZoneId.systemDefault()); this.upgradeDateTime = LocalDateTime.ofInstant(upgradeTimeStamp.toInstant(), ZoneId.systemDefault());
if(rs.getInt("enforceKOS") == 0)
this.enforceKOS = false;
else
this.enforceKOS = true;
} catch (Exception e) { } catch (Exception e) {
Logger.error("Failed for object " + this.blueprintUUID + ' ' + this.getObjectUUID() + e); Logger.error("Failed for object " + this.blueprintUUID + ' ' + this.getObjectUUID() + e);
} }
@@ -954,7 +959,7 @@ public class Building extends AbstractWorldObject {
// Altitude of this building is derived from the heightmap engine. // Altitude of this building is derived from the heightmap engine.
Vector3fImmutable tempLoc = new Vector3fImmutable(this.statLat + this.parentZone.absX, 0, this.statLon + this.parentZone.absZ); Vector3fImmutable tempLoc = new Vector3fImmutable(this.statLat + this.parentZone.absX, 0, this.statLon + this.parentZone.absZ);
tempLoc = new Vector3fImmutable(tempLoc.x, Terrain.getWorldHeight(tempLoc), tempLoc.z); tempLoc = new Vector3fImmutable(tempLoc.x, Terrain.getWorldHeight(tempLoc) + this.statAlt, tempLoc.z);
this.setLoc(tempLoc); this.setLoc(tempLoc);
} }
} }
@@ -1447,7 +1452,7 @@ public class Building extends AbstractWorldObject {
public synchronized boolean setReserve(int amount, PlayerCharacter player) { public synchronized boolean setReserve(int amount, PlayerCharacter player) {
if (!BuildingManager.playerCanManageNotFriends(player, this)) if (!BuildingManager.playerCanManage(player, this))
return false; return false;
if (amount < 0) if (amount < 0)
@@ -1400,6 +1400,7 @@ public class CharacterItemManager {
if (!ItemManager.validForSkills(item, pc.getSkills())) { if (!ItemManager.validForSkills(item, pc.getSkills())) {
this.forceToInventory(slot, item, pc, initialized); this.forceToInventory(slot, item, pc, initialized);
this.equipped.remove(slot);
pc.applyBonuses(); pc.applyBonuses();
} }
} }
+134 -129
View File
@@ -120,9 +120,7 @@ public class City extends AbstractWorldObject {
this.treeOfLifeID = rs.getInt("treeOfLifeUUID"); this.treeOfLifeID = rs.getInt("treeOfLifeUUID");
this.bindX = rs.getFloat("bindX"); this.bindX = rs.getFloat("bindX");
this.bindZ = rs.getFloat("bindZ"); this.bindZ = rs.getFloat("bindZ");
this.bindLoc = new Vector3fImmutable(this.location.getX() + this.bindX, this.bindLoc = new Vector3fImmutable(this.location.getX() + this.bindX, this.location.getY(), this.location.getZ() + this.bindZ);
this.location.getY(),
this.location.getZ() + this.bindZ);
this.radiusType = rs.getInt("radiusType"); this.radiusType = rs.getInt("radiusType");
float bindradiustemp = rs.getFloat("bindRadius"); float bindradiustemp = rs.getFloat("bindRadius");
@@ -288,106 +286,133 @@ public class City extends AbstractWorldObject {
return city.getBindLoc(); return city.getBindLoc();
} }
public static ArrayList<City> getCitiesToTeleportTo(PlayerCharacter pc) { public static ArrayList<City> getCitiesToTeleportTo(PlayerCharacter playerCharacter, boolean repledge) {
ArrayList<City> cities = new ArrayList<>(); ArrayList<City> cities = new ArrayList<>();
if (pc == null) if (playerCharacter == null)
return cities; return cities;
ConcurrentHashMap<Integer, AbstractGameObject> worldCities = DbManager.getMap(mbEnums.GameObjectType.City); ConcurrentHashMap<Integer, AbstractGameObject> worldCities = DbManager.getMap(mbEnums.GameObjectType.City);
if (ConfigManager.MB_RULESET.getValue().equals("LORE")) { //handle compiling of cities able to be teleported to for lore rule-set
//handle compiling of cities able to be teleported to for lore rule-set
for (AbstractGameObject ago : worldCities.values()) { for (AbstractGameObject ago : worldCities.values()) {
City city = (City) ago;
if(city.cityName.equals("Perdition") || city.cityName.equals("Bastion")) City city = (City) ago;
continue; // cannot teleport to perdition or bastion
if (city.isNpc == 1 && city.getGuild().charter.equals(pc.guild.charter)) { // Filter Player cities
cities.add(city); // anyone of the same charter can teleport to a safehold of that charter
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);
continue; continue;
} else if (city.isNoobIsle == 1 && pc.level <= 20) { }
cities.add(city); // everyone can go to noob island if they are under level 20
continue; if (city.isOpen() && city.getTOL().rank > 4) {
} else if (city.cityName.equals("Khan'Ov Srekel")) {
cities.add(city); //everyone anytime can teleport to khan // Filter Lore cities
continue;
} else if (city.isOpen() && city.getTOL().rank > 4 && city.getGuild().charter.equals(pc.guild.charter)) if (ConfigManager.MB_RULESET.getValue().equals("LORE")) {
if (!city.getTOL().reverseKOS) {
cities.add(city);//can teleport to any open ToL that shares charter if (repledge) {
continue; 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 { } else {
if (city.getTOL().getCondemned().contains(pc.objectUUID) && city.getTOL().getCondemned().get(pc.objectUUID).active) { //not reverse KOS, everyone is allowed by default
cities.add(city);//this player is allowed for the reverse KOS
continue; allowed = true;
}
if (city.getTOL().getCondemned().contains(pc.guildUUID) && city.getTOL().getCondemned().get(pc.guildUUID).active) { //specific values are not allowed
cities.add(city);//this guild is allowed for the reverse KOS
continue; if ((city.getTOL().getCondemned().containsKey(playerUUID) && city.getTOL().getCondemned().get(playerUUID).active) ||
} (city.getTOL().getCondemned().containsKey(guildUUID) && city.getTOL().getCondemned().get(guildUUID).active) ||
if (city.getTOL().getCondemned().contains(pc.guild.getNation().getObjectUUID()) && city.getTOL().getCondemned().get(pc.guild.getNation().getObjectUUID()).active) { (city.getTOL().getCondemned().containsKey(nationUUID) && city.getTOL().getCondemned().get(nationUUID).active))
cities.add(city);//this nation is allowed for the reverse KOS allowed = false;
continue;
}
} }
if (city.getGuild().getNation().equals(pc.guild.getNation())) {
cities.add(city);//can always teleport inside your own nation if (allowed)
cities.add(city);
} }
} } else {
} else {
Guild pcG = pc.getGuild(); // Filter NPC cities
//add npc cities
for (AbstractGameObject ago : worldCities.values()) { if (city.isNoobIsle == 1) {
if (ago.getObjectType().equals(GameObjectType.City)) { if (playerCharacter.level < 20)
City city = (City) ago; cities.add(city); // everyone can go to noob island if they are under level 20
if (city.noTeleport) continue;
continue; }
if (city.parentZone != null && city.parentZone.guild_zone) { // Players cannot teleport to perdition or bastion
if (pc.getAccount().status.equals(AccountStatus.ADMIN)) { 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); cities.add(city);
} else } else if (city.getGuild().charter.equals(playerCharacter.guild.charter))
//list Player cities cities.add(city);
//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
}
} }
} }
} }
return cities; return cities;
@@ -407,7 +432,7 @@ public class City extends AbstractWorldObject {
//handle compiling of cities able to be repledged to for lore rule-set //handle compiling of cities able to be repledged to for lore rule-set
for (AbstractGameObject ago : worldCities.values()) { for (AbstractGameObject ago : worldCities.values()) {
City city = (City) ago; City city = (City) ago;
if(city.cityName.equals("Perdition") || city.cityName.equals("Bastion")) if (city.cityName.equals("Perdition") || city.cityName.equals("Bastion"))
continue; // cannot repledge to perdition or bastion continue; // cannot repledge to perdition or bastion
if (city.isNpc == 1 && city.getGuild().charter.canJoin(playerCharacter)) { if (city.isNpc == 1 && city.getGuild().charter.canJoin(playerCharacter)) {
cities.add(city); // anyone of the same charter can teleport to a safehold of that charter cities.add(city); // anyone of the same charter can teleport to a safehold of that charter
@@ -586,7 +611,7 @@ public class City extends AbstractWorldObject {
if (this.siegesWithstood == siegesWithstood) if (this.siegesWithstood == siegesWithstood)
return; return;
if (DbManager.CityQueries.updateSiegesWithstood(this, siegesWithstood) == true) if (DbManager.CityQueries.updateSiegesWithstood(this, siegesWithstood))
this.siegesWithstood = siegesWithstood; this.siegesWithstood = siegesWithstood;
else else
Logger.error("Error when writing to database for cityUUID: " + this.getObjectUUID()); Logger.error("Error when writing to database for cityUUID: " + this.getObjectUUID());
@@ -640,19 +665,12 @@ public class City extends AbstractWorldObject {
public Guild getGuild() { public Guild getGuild() {
if (this.getTOL() == null) if (this.getTOL() == null)
return null; return Guild.getErrantGuild();
if (this.isNpc == 1) { if (this.getTOL().getOwner() == null)
return Guild.getErrantGuild();
if (this.getTOL().getOwner() == null) return this.getTOL().getOwner().getGuild();
return null;
return this.getTOL().getOwner().getGuild();
} else {
if (this.getTOL().getOwner() == null)
return null;
return this.getTOL().getOwner().getGuild();
}
} }
public boolean openCity(boolean open) { public boolean openCity(boolean open) {
@@ -731,7 +749,7 @@ public class City extends AbstractWorldObject {
for (AbstractCharacter npc : getTOL().getHirelings().keySet()) { for (AbstractCharacter npc : getTOL().getHirelings().keySet()) {
if (npc.getObjectType() == GameObjectType.NPC) if (npc.getObjectType() == GameObjectType.NPC)
if (((NPC) npc).getContract().isRuneMaster() == true) if (((NPC) npc).getContract().isRuneMaster())
outNPC = (NPC) npc; outNPC = (NPC) npc;
} }
@@ -764,16 +782,13 @@ public class City extends AbstractWorldObject {
// Set location for this city // Set location for this city
this.location = new Vector3fImmutable(this.parentZone.absX, this.parentZone.absY, this.parentZone.absZ); this.location = new Vector3fImmutable(this.parentZone.absX, this.parentZone.absY, this.parentZone.absZ);
this.bindLoc = new Vector3fImmutable(this.location.x + this.bindX, this.bindLoc = new Vector3fImmutable(this.location.x + this.bindX, this.location.y, this.location.z + this.bindZ);
this.location.y,
this.location.z + this.bindZ);
// set city bounds // set city bounds
Bounds cityBounds = Bounds.borrow(); 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. 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), new Vector2f(mbEnums.CityBoundsType.GRID.halfExtents, mbEnums.CityBoundsType.GRID.halfExtents), 0.0f);
0.0f);
this.setBounds(cityBounds); this.setBounds(cityBounds);
// Sanity check; no tol // Sanity check; no tol
@@ -781,8 +796,7 @@ public class City extends AbstractWorldObject {
if (BuildingManager.getBuilding(this.treeOfLifeID) == null) if (BuildingManager.getBuilding(this.treeOfLifeID) == null)
Logger.info("City UID " + this.getObjectUUID() + " Failed to Load Tree of Life with ID " + this.treeOfLifeID); Logger.info("City UID " + this.getObjectUUID() + " Failed to Load Tree of Life with ID " + this.treeOfLifeID);
if ((ConfigManager.serverType.equals(ServerType.WORLDSERVER)) if ((ConfigManager.serverType.equals(ServerType.WORLDSERVER)) && (this.isNpc == (byte) 0)) {
&& (this.isNpc == (byte) 0)) {
this.realm = RealmMap.getRealmAtLocation(this.getLoc()); this.realm = RealmMap.getRealmAtLocation(this.getLoc());
@@ -802,8 +816,7 @@ public class City extends AbstractWorldObject {
if (this.getGuild().getGuildState() == GuildState.Nation) if (this.getGuild().getGuildState() == GuildState.Nation)
for (Guild sub : this.getGuild().getSubGuildList()) { for (Guild sub : this.getGuild().getSubGuildList()) {
if ((sub.getGuildState() == GuildState.Protectorate) || if ((sub.getGuildState() == GuildState.Protectorate) || (sub.getGuildState() == GuildState.Province)) {
(sub.getGuildState() == GuildState.Province)) {
this.isCapital = 1; this.isCapital = 1;
break; break;
} }
@@ -828,7 +841,7 @@ public class City extends AbstractWorldObject {
this.setHash(); this.setHash();
if (DataWarehouse.recordExists(mbEnums.DataRecordType.CITY, this.getObjectUUID()) == false) { if (!DataWarehouse.recordExists(DataRecordType.CITY, this.getObjectUUID())) {
CityRecord cityRecord = CityRecord.borrow(this, mbEnums.RecordEventType.CREATE); CityRecord cityRecord = CityRecord.borrow(this, mbEnums.RecordEventType.CREATE);
DataWarehouse.pushToWarehouse(cityRecord); DataWarehouse.pushToWarehouse(cityRecord);
} }
@@ -853,9 +866,7 @@ public class City extends AbstractWorldObject {
for (Building building : this.parentZone.zoneBuildingSet) { for (Building building : this.parentZone.zoneBuildingSet) {
if (building.getBlueprint() != null && if (building.getBlueprint() != null && building.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE && building.getBlueprint().getBuildingGroup() != BuildingGroup.TOL) {
building.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE &&
building.getBlueprint().getBuildingGroup() != BuildingGroup.TOL) {
building.healthMax += (building.healthMax * Realm.getRealmHealthMod(this)); building.healthMax += (building.healthMax * Realm.getRealmHealthMod(this));
@@ -937,7 +948,7 @@ public class City extends AbstractWorldObject {
// Reapply effect with timeout? // Reapply effect with timeout?
if (refreshEffect == true) if (refreshEffect)
player.addCityEffect(Integer.toString(effectBase.getUUID()), effectBase, rank, MBServerStatics.FOURTYFIVE_SECONDS, false, this); player.addCityEffect(Integer.toString(effectBase.getUUID()), effectBase, rank, MBServerStatics.FOURTYFIVE_SECONDS, false, this);
} }
@@ -1193,26 +1204,25 @@ public class City extends AbstractWorldObject {
// All protection contracts are void upon transfer of a city // All protection contracts are void upon transfer of a city
//Dont forget to not Flip protection on Banestones and siege Equipment... Noob. //Dont forget to not Flip protection on Banestones and siege Equipment... Noob.
if (cityBuilding.getBlueprint() != null && !cityBuilding.getBlueprint().isSiegeEquip() if (cityBuilding.getBlueprint() != null && !cityBuilding.getBlueprint().isSiegeEquip() && cityBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE)
&& cityBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE)
cityBuilding.setProtectionState(ProtectionState.NONE); cityBuilding.setProtectionState(ProtectionState.NONE);
// Transfer ownership of valid city assets // Transfer ownership of valid city assets
// these assets are autoprotected. // these assets are autoprotected.
if ((cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.TOL) 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.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE) PlayerCharacter guildLeader = PlayerCharacter.getPlayerCharacter(sourcePlayer.guild.getGuildLeaderUUID());
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK) if(guildLeader != null)
|| (cityBuilding.getBlueprint().isWallPiece()) cityBuilding.claim(guildLeader);
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE)) { else
cityBuilding.claim(sourcePlayer);
cityBuilding.claim(sourcePlayer);
cityBuilding.setProtectionState(ProtectionState.PROTECTED); cityBuilding.setProtectionState(ProtectionState.PROTECTED);
} }
} }
this.setForceRename(true); this.setForceRename(true);
// Reset city timer for map update // Reset city timer for map update
City.lastCityUpdate = System.currentTimeMillis(); City.lastCityUpdate = System.currentTimeMillis();
@@ -1245,12 +1255,7 @@ public class City extends AbstractWorldObject {
// Transfer ownership of valid city assets // Transfer ownership of valid city assets
// these assets are autoprotected. // these assets are autoprotected.
if ((cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.TOL) 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.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE)
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK)
|| (cityBuilding.getBlueprint().isWallPiece())
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE)
) {
cityBuilding.claim(sourcePlayer); cityBuilding.claim(sourcePlayer);
cityBuilding.setProtectionState(ProtectionState.PROTECTED); cityBuilding.setProtectionState(ProtectionState.PROTECTED);
@@ -1399,7 +1404,7 @@ public class City extends AbstractWorldObject {
taxPercent = .20f; taxPercent = .20f;
for (int resourceHash : msg.getResources().keySet()) for (int resourceHash : msg.getResources().keySet())
resources.add(ResourceType.hashLookup.get(resourceHash)); resources.add(ResourceType.templateHashLookup.get(resourceHash));
for (ResourceType resourceType : resources) { for (ResourceType resourceType : resources) {
if (Warehouse.isAboveCap(ruledWarehouse, resourceType, (int) (city.warehouse.resources.get(resourceType) * taxPercent))) { if (Warehouse.isAboveCap(ruledWarehouse, resourceType, (int) (city.warehouse.resources.get(resourceType) * taxPercent))) {
+4
View File
@@ -193,12 +193,16 @@ public class Guild extends AbstractWorldObject {
} }
public static boolean sameNationExcludeErrant(Guild a, Guild b) { public static boolean sameNationExcludeErrant(Guild a, Guild b) {
if (a == null || b == null) if (a == null || b == null)
return false; return false;
if (a.getObjectUUID() == b.getObjectUUID()) if (a.getObjectUUID() == b.getObjectUUID())
return true; return true;
if (a.nation == null || b.nation == null) if (a.nation == null || b.nation == null)
return false; return false;
return a.nation.getObjectUUID() == b.nation.getObjectUUID() && !a.nation.isEmptyGuild(); return a.nation.getObjectUUID() == b.nation.getObjectUUID() && !a.nation.isEmptyGuild();
} }
+4 -5
View File
@@ -166,7 +166,7 @@ public class Mine extends AbstractGameObject {
writer.putInt(mine.getObjectUUID()); //actually a hash of mine writer.putInt(mine.getObjectUUID()); //actually a hash of mine
writer.putString(mine.mineType.name); writer.putString(mine.mineType.name);
writer.putString(mine.zoneName); writer.putString(mine.zoneName);
writer.putInt(mine.production.hash); writer.putInt(mine.production.resourceHash);
writer.putInt(mine.production.mine_production); writer.putInt(mine.production.mine_production);
writer.putInt(mine.getModifiedProductionAmount()); //TODO calculate range penalty here writer.putInt(mine.getModifiedProductionAmount()); //TODO calculate range penalty here
writer.putInt(3600); //window in seconds writer.putInt(3600); //window in seconds
@@ -220,8 +220,7 @@ public class Mine extends AbstractGameObject {
// Only inactive mines are returned. // Only inactive mines are returned.
for (Mine mine : Mine.mineMap.keySet()) { for (Mine mine : Mine.mineMap.keySet()) {
if (mine.owningGuild.getObjectUUID() == guildID && if (mine.owningGuild.getObjectUUID() == guildID)
mine.isActive == false)
mineList.add(mine); mineList.add(mine);
} }
return mineList; return mineList;
@@ -393,7 +392,7 @@ public class Mine extends AbstractGameObject {
// writer.putInt(0x215C92BB); //this.unknown1); // writer.putInt(0x215C92BB); //this.unknown1);
writer.putString(this.mineType.name); writer.putString(this.mineType.name);
writer.putString(this.zoneName); writer.putString(this.zoneName);
writer.putInt(this.production.hash); writer.putInt(this.production.resourceHash);
writer.putInt(this.production.mine_production); writer.putInt(this.production.mine_production);
writer.putInt(this.getModifiedProductionAmount()); //TODO calculate range penalty here writer.putInt(this.getModifiedProductionAmount()); //TODO calculate range penalty here
writer.putInt(3600); //window in seconds writer.putInt(3600); //window in seconds
@@ -482,7 +481,7 @@ public class Mine extends AbstractGameObject {
if (this.owningGuild.getOwnedCity().warehouse == null) if (this.owningGuild.getOwnedCity().warehouse == null)
return false; return false;
return Warehouse.depositFromMine(this, mbEnums.ResourceType.resourceLookup.get(this.production.templateID), this.getModifiedProductionAmount(), this.owningGuild.getOwnedCity().warehouse); return Warehouse.depositFromMine(this, mbEnums.ResourceType.templateLookup.get(this.production.templateID), this.getModifiedProductionAmount(), this.owningGuild.getOwnedCity().warehouse);
} }
public boolean updateGuildOwner(PlayerCharacter playerCharacter) { public boolean updateGuildOwner(PlayerCharacter playerCharacter) {
-23
View File
@@ -512,29 +512,6 @@ public class NPC extends AbstractCharacter {
return MinionType.ContractToMinionMap.containsKey(contractID); return MinionType.ContractToMinionMap.containsKey(contractID);
} }
public static boolean UpdateEquipSetID(NPC npc, int equipSetID) {
if (!LootManager._bootySetMap.containsKey(equipSetID))
return false;
if (!DbManager.NPCQueries.UPDATE_EQUIPSET(npc, equipSetID))
return false;
npc.equipmentSetID = equipSetID;
return true;
}
public static boolean UpdateRaceID(NPC npc, int raceID) {
if (!DbManager.NPCQueries.UPDATE_MOBBASE(npc, raceID))
return false;
npc.loadID = raceID;
npc.mobBase = MobBase.getMobBase(npc.loadID);
return true;
}
public static NPCProfits GetNPCProfits(NPC npc) { public static NPCProfits GetNPCProfits(NPC npc) {
return NPCProfits.ProfitCache.get(npc.currentID); return NPCProfits.ProfitCache.get(npc.currentID);
} }
+2 -2
View File
@@ -349,13 +349,13 @@ public class Resists {
if (rb.getBool(ModType.ImmuneTo, SourceType.Stun)) if (rb.getBool(ModType.ImmuneTo, SourceType.Stun))
this.immuneTo.put(mbEnums.DamageType.STUN, true); this.immuneTo.put(mbEnums.DamageType.STUN, true);
if (rb.getBool(ModType.ImmuneTo, SourceType.Blind)) if (rb.getBool(ModType.ImmuneTo, SourceType.Blind))
this.immuneTo.put(mbEnums.DamageType.BLIND, true); this.immuneTo.put(mbEnums.DamageType.BLINDNESS, true);
if (rb.getBool(ModType.ImmuneToAttack, SourceType.None)) if (rb.getBool(ModType.ImmuneToAttack, SourceType.None))
this.immuneTo.put(mbEnums.DamageType.ATTACK, true); this.immuneTo.put(mbEnums.DamageType.ATTACK, true);
if (rb.getBool(ModType.ImmuneToPowers, SourceType.None)) if (rb.getBool(ModType.ImmuneToPowers, SourceType.None))
this.immuneTo.put(mbEnums.DamageType.POWERS, true); this.immuneTo.put(mbEnums.DamageType.POWERS, true);
if (rb.getBool(ModType.ImmuneTo, SourceType.Powerblock)) if (rb.getBool(ModType.ImmuneTo, SourceType.Powerblock))
this.immuneTo.put(mbEnums.DamageType.POWERBLOCK, true); this.immuneTo.put(mbEnums.DamageType.POWERINHIBITOR, true);
if (rb.getBool(ModType.ImmuneTo, SourceType.DeBuff)) if (rb.getBool(ModType.ImmuneTo, SourceType.DeBuff))
this.immuneTo.put(mbEnums.DamageType.DEBUFF, true); this.immuneTo.put(mbEnums.DamageType.DEBUFF, true);
if (rb.getBool(ModType.ImmuneTo, SourceType.Fear)) if (rb.getBool(ModType.ImmuneTo, SourceType.Fear))
+8 -10
View File
@@ -140,7 +140,7 @@ public class Warehouse {
if (warehouse == null) if (warehouse == null)
return; return;
mbEnums.ResourceType resourceType = mbEnums.ResourceType.hashLookup.get(msg.getHashID()); mbEnums.ResourceType resourceType = mbEnums.ResourceType.templateHashLookup.get(msg.getHashID());
if (isResourceLocked(warehouse, resourceType)) { if (isResourceLocked(warehouse, resourceType)) {
ChatManager.chatSystemInfo(playerCharacter, "You cannot withdrawl a locked resource."); ChatManager.chatSystemInfo(playerCharacter, "You cannot withdrawl a locked resource.");
@@ -182,7 +182,7 @@ public class Warehouse {
warehouse = city.warehouse; warehouse = city.warehouse;
mbEnums.ResourceType resourceType = mbEnums.ResourceType.hashLookup.get(hashID); mbEnums.ResourceType resourceType = mbEnums.ResourceType.templateHashLookup.get(hashID);
// toggle lock // toggle lock
@@ -233,7 +233,7 @@ public class Warehouse {
return false; return false;
} }
mbEnums.ResourceType resourceType = mbEnums.ResourceType.resourceLookup.get(resource.templateID); mbEnums.ResourceType resourceType = mbEnums.ResourceType.templateLookup.get(resource.templateID);
if (warehouse.resources.get(resourceType) == null) if (warehouse.resources.get(resourceType) == null)
return false; return false;
@@ -261,7 +261,7 @@ public class Warehouse {
int newAmount = oldAmount + amount; int newAmount = oldAmount + amount;
if (newAmount > mbEnums.ResourceType.resourceLookup.get(resource.templateID).deposit_limit) if (newAmount > mbEnums.ResourceType.templateLookup.get(resource.templateID).deposit_limit)
return false; return false;
if (removeFromInventory) { if (removeFromInventory) {
@@ -381,7 +381,7 @@ public class Warehouse {
int amount = (int) (warehouse.resources.get(resourceType) * taxPercent); int amount = (int) (warehouse.resources.get(resourceType) * taxPercent);
if (amount <= 0) { if (amount <= 0) {
msg.getResources().put(resourceType.hash, 0); msg.getResources().put(resourceType.resourceHash, 0);
continue; continue;
} }
@@ -395,20 +395,18 @@ public class Warehouse {
if (newAmount < amount) if (newAmount < amount)
continue; continue;
msg.getResources().put(resourceType.hash, amount); msg.getResources().put(resourceType.resourceHash, amount);
if (!DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse)) { if (!DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse)) {
msg.getResources().put(resourceType.hash, 0); msg.getResources().put(resourceType.resourceHash, 0);
warehouse.resources.put(resourceType, oldAmount); warehouse.resources.put(resourceType, oldAmount);
continue; continue;
} }
warehouse.resources.put(resourceType, newAmount); warehouse.resources.put(resourceType, newAmount);
depositRealmTaxes(taxer, resourceType, amount, warehouse); depositRealmTaxes(taxer, resourceType, amount, warehouse);
mbEnums.ResourceType resource;
AddTransactionToWarehouse(warehouse, taxer.getObjectType(), taxer.getObjectUUID(), mbEnums.TransactionType.TAXRESOURCE, resourceType, amount); AddTransactionToWarehouse(warehouse, taxer.getObjectType(), taxer.getObjectUUID(), mbEnums.TransactionType.TAXRESOURCE, resourceType, amount);
} }
} }
@@ -431,7 +429,7 @@ public class Warehouse {
return false; return false;
if (addToInventory) if (addToInventory)
if (!itemMan.hasRoomInventory(template.item_wt * amount)) { if (!itemMan.hasRoomInventory(template.item_wt)) {
ChatManager.chatSystemInfo(playerCharacter, "You can not carry any more of that item."); ChatManager.chatSystemInfo(playerCharacter, "You can not carry any more of that item.");
return false; return false;
} }
+17 -28
View File
@@ -11,13 +11,11 @@ package engine.powers;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.gameManager.PowersManager; import engine.gameManager.PowersManager;
import engine.mbEnums;
import engine.mbEnums.ModType; import engine.mbEnums.ModType;
import engine.mbEnums.SourceType; import engine.mbEnums.SourceType;
import engine.mbEnums.StackType; import engine.mbEnums.StackType;
import engine.objects.AbstractCharacter; import engine.objects.*;
import engine.objects.AbstractWorldObject;
import engine.objects.PlayerBonuses;
import engine.objects.Runegate;
import engine.powers.poweractions.AbstractPowerAction; import engine.powers.poweractions.AbstractPowerAction;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@@ -244,32 +242,23 @@ public class ActionsBase {
} }
//Add blocked types here //Add blocked types here
public boolean blocked(AbstractWorldObject awo, PowersBase pb, int trains) { public boolean blocked(AbstractWorldObject awo, boolean vampDrain) {
if (AbstractWorldObject.IsAbstractCharacter(awo)) { //Check for immunities
AbstractCharacter ac = (AbstractCharacter) awo; if (AbstractCharacter.IsAbstractCharacter(awo)){
PlayerBonuses bonus = ac.getBonuses(); AbstractCharacter pcTarget = (AbstractCharacter) awo;
if (bonus == null) PlayerBonuses bonus = pcTarget.getBonuses();
return false;
//TODO make this more efficient then testing strings if(vampDrain)
if (this.stackType.equals("Stun") && bonus.getBool(ModType.ImmuneTo, SourceType.STUN)) return bonus.getBool(ModType.BlockedPowerType, SourceType.VAMPDRAIN);
return true; //Currently stun immune. Skip stun
else if (this.stackType.equals("Snare") && bonus.getBool(ModType.ImmuneTo, SourceType.Snare)) if ((this.stackType.equals("Flight") && bonus.getBool(ModType.NoMod, SourceType.Fly)) ||
return true; //Currently snare immune. Skip snare (this.stackType.equals("Track") && bonus.getBool(ModType.CannotTrack, SourceType.None))) {
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; return true;
// 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)) mbEnums.DamageType damageType = mbEnums.DamageType.getDamageType(this.stackType.toUpperCase());
return true; return pcTarget.getResists().immuneTo(damageType);
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; return false;
} }
+4
View File
@@ -633,4 +633,8 @@ public class PowersBase {
return description; return description;
} }
public boolean enforceLore(){
return this.powerCategory.equals(PowerCategoryType.SUMMON) || this.powerCategory.equals(PowerCategoryType.HEAL)|| this.powerCategory.equals(PowerCategoryType.BUFF);
}
} }
@@ -11,7 +11,6 @@ package engine.powers.poweractions;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.mbEnums; import engine.mbEnums;
import engine.mbEnums.BuildingGroup;
import engine.mbEnums.GameObjectType; import engine.mbEnums.GameObjectType;
import engine.mbEnums.PortalType; import engine.mbEnums.PortalType;
import engine.objects.AbstractCharacter; import engine.objects.AbstractCharacter;
@@ -54,15 +53,17 @@ public class OpenGatePowerAction extends AbstractPowerAction {
return; return;
// Make sure target building is a runegate // Make sure target building is a runegate
if(targetBuilding.meshUUID != 24500) // runegate
if (targetBuilding.meshUUID != 24500) // runegate
return; return;
// Which runegate was clicked on? // Which runegate was clicked on?
Runegate runeGate = Runegate._runegates.get(targetBuilding.getObjectUUID()); Runegate runeGate = Runegate._runegates.get(targetBuilding.getObjectUUID());
if(runeGate == null){ if (runeGate == null)
return; // mob camp prop runegate cannot be opened return; // mob camp prop runegate cannot be opened
}
// Which portal was opened? // Which portal was opened?
token = pb.getToken(); token = pb.getToken();
@@ -72,41 +73,31 @@ public class OpenGatePowerAction extends AbstractPowerAction {
case 428937084: //Death Gate case 428937084: //Death Gate
portalType = PortalType.OBLIV; portalType = PortalType.OBLIV;
break; break;
case 429756284: //Chaos Gate case 429756284: //Chaos Gate
portalType = PortalType.CHAOS; portalType = PortalType.CHAOS;
break; break;
case 429723516: //Khar Gate case 429723516: //Khar Gate
portalType = PortalType.MERCHANT; portalType = PortalType.MERCHANT;
break; break;
case 429559676: //Spirit Gate case 429559676: //Spirit Gate
portalType = PortalType.SPIRIT; portalType = PortalType.SPIRIT;
break; break;
case 429592444: //Water Gate case 429592444: //Water Gate
portalType = PortalType.WATER; portalType = PortalType.WATER;
break; break;
case 429428604: //Fire Gate case 429428604: //Fire Gate
portalType = PortalType.FIRE; portalType = PortalType.FIRE;
break; break;
case 429526908: //Air Gate case 429526908: //Air Gate
portalType = PortalType.AIR; portalType = PortalType.AIR;
break; break;
case 429625212: //Earth Gate case 429625212: //Earth Gate
portalType = PortalType.EARTH; portalType = PortalType.EARTH;
break; break;
default: default:
} }
runeGate.activatePortal(portalType); runeGate.activatePortal(portalType);
} }
@Override @Override
@@ -95,6 +95,12 @@ public class DestroyCityThread implements Runnable {
if (cityBuilding == null) if (cityBuilding == null)
continue; continue;
// check null bluepritn and log error
if (cityBuilding.getBlueprint() == null){
Logger.error("Null Blueprint for building ID: " + cityBuilding.getObjectUUID());
continue;
}
// Do nothing with the banestone. It will be removed elsewhere // Do nothing with the banestone. It will be removed elsewhere
if (cityBuilding.getBlueprint().getBuildingGroup().equals(mbEnums.BuildingGroup.BANESTONE)) if (cityBuilding.getBlueprint().getBuildingGroup().equals(mbEnums.BuildingGroup.BANESTONE))
@@ -125,6 +131,13 @@ public class DestroyCityThread implements Runnable {
cityBuilding.setProtectionState(mbEnums.ProtectionState.NONE); 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;
}
// Destroy all remaining city assets // Destroy all remaining city assets
if ((cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.BARRACK) if ((cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.BARRACK)
+3 -3
View File
@@ -289,10 +289,10 @@ public class HourlyJobThread implements Runnable {
Logger.info(PurgeOprhans.recordsDeleted.toString() + "orphaned items deleted"); Logger.info(PurgeOprhans.recordsDeleted.toString() + "orphaned items deleted");
} }
public static void processBanes(){ public static void processBanes() {
//handle banes //handle banes
for(Bane bane : Bane.banes.values()){ for (Bane bane : Bane.banes.values()) {
if(bane.getLiveDate() != null && DateTime.now().isAfter(bane.getLiveDate().minusMinutes(1)) && bane.isStarted == false) if (bane.getLiveDate() != null && DateTime.now().isAfter(bane.getLiveDate().minusMinutes(1)) && bane.isStarted == false)
bane.startBane(); bane.startBane();
} }
} }
+285
View File
@@ -0,0 +1,285 @@
// ·. · · · · .
// · ·
// · ·
//
// · · ·
// Magicbane Emulator Project © 2013 - 2024
// www.magicbane.com
package engine.wpak;
import engine.gameManager.ConfigManager;
import engine.mbEnums;
import engine.wpak.data.ConditionEntry;
import engine.wpak.data.Effect;
import engine.wpak.data.ModifierEntry;
import org.pmw.tinylog.Logger;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class EffectsParser {
public static String effectsPath = ConfigManager.DEFAULT_DATA_DIR + "wpak/Effects.cfg";
private static final Pattern EFFECT_REGEX = Pattern.compile("(?<=EFFECTBEGIN)(.+?)(?=EFFECTEND)", Pattern.DOTALL);
private static final Pattern SOURCE_REGEX = Pattern.compile("(?<=SOURCEBEGIN)(.+?)(?=SOURCEEND)", Pattern.DOTALL);
private static final Pattern MODS_REGEX = Pattern.compile("(?<=MODSBEGIN)(.+?)(?=MODSEND)", Pattern.DOTALL);
private static final Pattern CONDITIONS_REGEX = Pattern.compile("(?<=CONDITIONBEGIN)(.+?)(?=CONDITIONEND)", Pattern.DOTALL);
private static final Pattern STRSPLIT_REGEX = Pattern.compile("([^\"]\\S*|\"[^\"]*\")\\s*"); // Regex ignores spaces within quotes
public static void parseWpakFile() {
// Read .wpak file from disk
byte[] fileData;
try {
fileData = Files.readAllBytes(Paths.get(effectsPath));
} catch (IOException e) {
throw new RuntimeException(e);
}
String fileContents = new String(fileData);
// Iterate over effect entries from .wpak data
Matcher matcher = EFFECT_REGEX.matcher(fileContents);
while (matcher.find()) {
try {
Effect effect = parseEffectEntry(matcher.group());
// WpakPowerManager._effectsLookup.put(effect.effect_id, effect);
} catch (Exception e) {
Logger.error("EFFECT PARSE FAILED: " + e);
}
}
}
private static Effect parseEffectEntry(String effectData) {
Effect effect = new Effect();
// Parse fields that lie outside the other tags
effect.isItemEffect = effectData.contains("IsItemEffect");
effect.isSpireEffect = effectData.contains("IsSpireEffect");
effect.ignoreNoMod = effectData.contains("IgnoreNoMod");
effect.dontSave = effectData.contains("DontSave");
// Remove all lines that contain a # and leading/trailing blank lines
effectData = effectData.replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", "");
effectData = effectData.trim();
// Parse effect entry header
String firstLine;
ArrayList<String> effectHeader = new ArrayList<>();
// Some effects exist without sources/mods or conditions
// (ACID "MOB" 0)
if (effectData.indexOf('\n') > 0)
firstLine = effectData.substring(0, effectData.indexOf('\n'));
else
firstLine = effectData;
Matcher matcher = STRSPLIT_REGEX.matcher(firstLine);
while (matcher.find())
effectHeader.add(matcher.group().trim());
effect.effect_id = effectHeader.get(0);
effect.effect_name = effectHeader.get(1);
effect.effect_name = effect.effect_name.replaceAll("\"", "");
// Some effect mods have no icon
// (SEEINVIS-SHADE "See Invis")
if (effectHeader.size() == 3)
effect.icon = Integer.parseInt(effectHeader.get(2));
else
effect.icon = 0;
// Parse source entries
matcher = SOURCE_REGEX.matcher(effectData);
while (matcher.find())
effect.sources.add(matcher.group().trim());
// Parse modifier entries
matcher = MODS_REGEX.matcher(effectData);
// Iterate effect entries from .wpak config data
while (matcher.find()) {
ModifierEntry modifierEntry = parseModEntry(matcher.group());
effect.mods.add(modifierEntry);
}
// Parse Conditions
matcher = CONDITIONS_REGEX.matcher(effectData);
while (matcher.find()) {
String[] conditions = matcher.group().trim().split("\n");
for (String condition : conditions) {
List<String> parameters = Arrays.asList(condition.trim().split("\\s+"));
Iterator<String> iterator = parameters.iterator();
ConditionEntry conditionEntry = new ConditionEntry();
conditionEntry.condition = iterator.next();
conditionEntry.arg = Integer.parseInt(iterator.next());
if (iterator.hasNext())
conditionEntry.curveType = mbEnums.CompoundCurveType.valueOf(iterator.next());
while (iterator.hasNext())
conditionEntry.damageTypes.add(mbEnums.DamageType.valueOf(iterator.next().toUpperCase()));
effect.conditions.add(conditionEntry);
}
}
return effect;
}
private static ModifierEntry parseModEntry(String modData) {
ModifierEntry modifierEntry = new ModifierEntry();
String[] modEntries = modData.trim().split("\n");
for (String modEntry : modEntries) {
ArrayList<String> modValues = new ArrayList<>();
Matcher matcher = STRSPLIT_REGEX.matcher(modEntry.trim());
while (matcher.find())
modValues.add(matcher.group().trim());
modifierEntry.type = mbEnums.ModType.valueOf(modValues.get(0).trim());
switch (modifierEntry.type) {
case AnimOverride:
modifierEntry.min = Float.parseFloat(modValues.get(1).trim());
modifierEntry.max = Float.parseFloat(modValues.get(2).trim());
break;
case Health:
case Mana:
case Stamina:
modifierEntry.min = Float.parseFloat(modValues.get(1).trim());
modifierEntry.max = Float.parseFloat(modValues.get(2).trim());
modifierEntry.percentage = Float.parseFloat(modValues.get(3).trim());
modifierEntry.value = Float.parseFloat(modValues.get(4).trim()); // Always zero
modifierEntry.compoundCurveType = mbEnums.CompoundCurveType.valueOf(modValues.get(5).trim());
modifierEntry.arg1 = modValues.get(6).trim();
break;
case Attr:
case Resistance:
case Skill:
case HealthRecoverRate:
case ManaRecoverRate:
case StaminaRecoverRate:
case DamageShield:
case HealthFull:
case ManaFull:
case StaminaFull:
case Slay:
case Fade:
case Durability:
modifierEntry.min = Float.parseFloat(modValues.get(1).trim());
modifierEntry.max = Float.parseFloat(modValues.get(2).trim());
modifierEntry.compoundCurveType = mbEnums.CompoundCurveType.valueOf(modValues.get(3).trim());
if (modValues.size() > 4)
modifierEntry.arg1 = modValues.get(4).trim(); // Some HeathFull entries do not have an argument
break;
case MeleeDamageModifier:
case OCV:
case DCV:
case AttackDelay:
case AdjustAboveDmgCap:
case DamageCap:
case ArmorPiercing:
case Speed:
case PowerDamageModifier:
case DR:
case PassiveDefense:
case MaxDamage:
case Value:
case WeaponSpeed:
case MinDamage:
case PowerCost:
case Block:
case Parry:
case Dodge:
case WeaponRange:
case ScanRange:
case ScaleHeight:
case ScaleWidth:
modifierEntry.min = Float.parseFloat(modValues.get(1).trim());
modifierEntry.max = Float.parseFloat(modValues.get(2).trim());
modifierEntry.compoundCurveType = mbEnums.CompoundCurveType.valueOf(modValues.get(3).trim());
break;
case ItemName:
case BlockedPowerType:
case ImmuneTo:
case BlackMantle:
modifierEntry.arg1 = modValues.get(1).trim();
// Some BlockedPowerType entries have only one argument
if (modValues.size() > 2)
modifierEntry.arg2 = modValues.get(2).trim();
break;
case NoMod:
case ConstrainedAmbidexterity:
case ProtectionFrom:
case ExclusiveDamageCap:
case IgnoreDamageCap:
modifierEntry.arg1 = modValues.get(1).trim();
break;
case WeaponProc:
modifierEntry.min = Float.parseFloat(modValues.get(1).trim());
modifierEntry.arg1 = modValues.get(2).trim();
modifierEntry.max = Float.parseFloat(modValues.get(3).trim());
break;
case BladeTrails: // These tags have no parms or are not parsed
case ImmuneToAttack:
case ImmuneToPowers:
case Ambidexterity:
case Silenced:
case IgnorePassiveDefense:
case Stunned:
case PowerCostHealth:
case Charmed:
case Fly:
case CannotMove:
case CannotTrack:
case CannotAttack:
case CannotCast:
case SpireBlock:
case Invisible:
case SeeInvisible:
break;
default:
Logger.error("Unhandled type: " + modifierEntry.type);
break;
}
}
return modifierEntry;
}
}
+308
View File
@@ -0,0 +1,308 @@
// ·. · · · · .
// · ·
// · ·
//
// · · ·
// Magicbane Emulator Project © 2013 - 2024
// www.magicbane.com
package engine.wpak;
import engine.gameManager.ConfigManager;
import engine.mbEnums;
import engine.wpak.data.Effect;
import engine.wpak.data.PowerAction;
import engine.wpak.data.StatTransfer;
import engine.wpak.data.TrackEntry;
import org.pmw.tinylog.Logger;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PowerActionParser {
private static final Pattern STRSPLIT_REGEX = Pattern.compile("([^\"]\\S*|\"[^\"]*\")\\s*");
private static final Pattern POWER_ACTION_REGEX = Pattern.compile("(?<=POWERACTIONBEGIN)(.+?)(?=POWERACTIONEND)", Pattern.DOTALL);
private static final String powerActionPath = ConfigManager.DEFAULT_DATA_DIR + "wpak/PowerActions.cfg";
public static void parseWpakFile() {
// Read .wpak file from disk
byte[] fileData;
try {
fileData = Files.readAllBytes(Paths.get(powerActionPath));
} catch (IOException e) {
throw new RuntimeException(e);
}
String fileContents = new String(fileData);
// Iterate over power entries from .wpak data
Matcher matcher = POWER_ACTION_REGEX.matcher(fileContents);
while (matcher.find()) {
PowerAction powerAction = parsePowerActionEntry(matcher.group().trim());
// WpakPowerManager._powerActionLookup.put(Hasher.SBStringHash(powerAction.action_id), powerAction);
}
}
private static PowerAction parsePowerActionEntry(String powerActionData) {
PowerAction powerAction = new PowerAction();
Effect effect;
StatTransfer statTransfer;
TrackEntry trackEntry;
// Remove all lines that contain a # and leading/trailing blank lines
powerActionData = powerActionData.replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", "").trim();
List<String> lineData = Arrays.asList(powerActionData.split("\n"));
// Parse effect entry header
Iterator<String> entryIterator = lineData.iterator();
String headerLine = entryIterator.next();
List<String> headerData = new ArrayList<>();
Matcher matcher = STRSPLIT_REGEX.matcher(headerLine.trim());
while (matcher.find())
headerData.add(matcher.group().trim());
Iterator<String> headerIterator = headerData.iterator();
powerAction.action_id = headerIterator.next();
powerAction.action_type = mbEnums.PowerActionType.valueOf(headerIterator.next());
switch (powerAction.action_type) {
case RemoveEffect:
effect = new Effect();
effect.effect_id = headerIterator.next();
powerAction.effects.add(effect);
break;
case CreateMob:
powerAction.petRace = Integer.parseInt(headerIterator.next());
powerAction.petLevel = Integer.parseInt(headerIterator.next());
break;
case DamageOverTime:
effect = new Effect();
effect.effect_id = headerIterator.next();
effect.cycleDuration = Integer.parseInt(headerIterator.next());
effect.cycleDelay = Integer.parseInt(headerIterator.next());
powerAction.effects.add(effect);
break;
case ApplyEffects:
int level = Integer.parseInt(headerIterator.next());
while (headerIterator.hasNext()) {
effect = new Effect();
effect.level = level;
effect.effect_id = headerIterator.next();
powerAction.effects.add(effect);
}
break;
case Transform:
case Invis:
case ApplyEffect:
case DeferredPower:
case DirectDamage:
case SpireDisable:
while (headerIterator.hasNext()) {
effect = new Effect();
effect.effect_id = headerIterator.next();
// Some applyEffect entries are naked withot a level
if (headerData.size() > 3)
effect.level = Integer.parseInt(headerIterator.next());
powerAction.effects.add(effect);
}
break;
case TransferStat:
statTransfer = new StatTransfer();
statTransfer.fromStat = mbEnums.CostType.valueOf(headerIterator.next());
statTransfer.toStat = mbEnums.CostType.valueOf(headerIterator.next());
statTransfer.ramp = Float.parseFloat(headerIterator.next());
statTransfer.rampCurve = mbEnums.CompoundCurveType.valueOf(headerIterator.next());
statTransfer.efficiency = Float.parseFloat(headerIterator.next());
statTransfer.efficiencyCurve = mbEnums.CompoundCurveType.valueOf(headerIterator.next());
statTransfer.fromStatBool = Boolean.parseBoolean(headerIterator.next());
statTransfer.isDrain = Boolean.parseBoolean(headerIterator.next());
powerAction.statTransfer = statTransfer;
break;
case TransferStatOT:
statTransfer = new StatTransfer();
statTransfer.fromStat = mbEnums.CostType.valueOf(headerIterator.next());
statTransfer.toStat = mbEnums.CostType.valueOf(headerIterator.next());
statTransfer.ramp = Float.parseFloat(headerIterator.next());
statTransfer.rampCurve = mbEnums.CompoundCurveType.valueOf(headerIterator.next());
statTransfer.efficiency = Float.parseFloat(headerIterator.next());
statTransfer.efficiencyCurve = mbEnums.CompoundCurveType.valueOf(headerIterator.next());
statTransfer.fromStatBool = Boolean.parseBoolean(headerIterator.next());
statTransfer.isDrain = Boolean.parseBoolean(headerIterator.next());
statTransfer.transfer_action = headerIterator.next();
statTransfer.transfer_ticks = Integer.parseInt(headerIterator.next());
powerAction.statTransfer = statTransfer;
break;
case Charm:
effect = new Effect();
effect.effect_id = headerIterator.next();
effect.level = Integer.parseInt(headerIterator.next());
effect.type = headerIterator.next();
powerAction.effects.add(effect);
break;
case Block:
effect = new Effect();
effect.effect_id = headerIterator.next();
effect.level = Integer.parseInt(headerIterator.next());
powerAction.effects.add(effect);
break;
case Resurrect:
powerAction.levelCap = Integer.parseInt(headerIterator.next());
break;
case SetItemFlag:
powerAction.itemFlag = mbEnums.ItemFlags.valueOf(headerIterator.next());
break;
case Track:
trackEntry = new TrackEntry();
trackEntry.action_id = headerIterator.next();
trackEntry.trackPlayer = Boolean.parseBoolean(headerIterator.next());
trackEntry.trackCorpse = Boolean.parseBoolean(headerIterator.next());
trackEntry.filter = mbEnums.MonsterType.valueOf(headerIterator.next());
trackEntry.min = Integer.parseInt(headerIterator.next());
trackEntry.max = Integer.parseInt(headerIterator.next());
powerAction.trackEntry = trackEntry;
break;
case Teleport:
if (headerIterator.hasNext())
powerAction.ignoreNoTeleSpire = Boolean.parseBoolean(headerIterator.next());
break;
case Recall: // No arguments for these tags or not parsed
case Summon:
case TreeChoke:
case SimpleDamage:
case MobRecall: // One argument always zero
case ClearAggro:
case ClearNearbyAggro:
case Peek:
case ClaimMine:
case RunegateTeleport:
case Steal:
break;
default:
Logger.error("Unhandled type " + powerAction.action_type + " for Pow4erAction: " + powerAction.action_id);
break;
}
// Process key value pairs after header
while (entryIterator.hasNext()) {
String lineValue = entryIterator.next();
List<String> lineValues = Arrays.asList(lineValue.split("="));
String key = lineValues.get(0).trim();
List<String> arguments;
switch (key) {
case "BODYPARTS":
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
for (String bodyPart : arguments)
powerAction.bodyParts.add(Integer.parseInt(bodyPart));
break;
case "FEMALEBODYPARTS":
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
for (String bodyPart : arguments)
powerAction.femaleBodyParts.add(Integer.parseInt(bodyPart));
break;
case "SCALEFACTOR":
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
for (String scaleFactor : arguments)
powerAction.scaleFactor.add(Float.parseFloat(scaleFactor));
break;
case "ISRESISTABLE":
powerAction.isResistible = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "ISAGGRESSIVE":
powerAction.isAggressive = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "BLADETRAILS":
powerAction.bladeTrails = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "SHOULDSHOWWEAPONS":
powerAction.shouldShowWeapons = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "SHOULDSHOWARMOR":
powerAction.shouldShowArmor = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "APPLYEFFECTBLANK":
powerAction.applyEffectBlank = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "WEAROFFEFFECTBLANK":
powerAction.wearOffEffectBlank = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "ATTACKANIMS":
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
for (String animation : arguments)
powerAction.attackAnimations.add(Integer.parseInt(animation));
break;
case "REMOVEALL":
powerAction.removeAll = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "EFFECTID":
effect = new Effect();
effect.effect_id = lineValues.get(1).trim();
powerAction.effects.add(effect);
break;
case "LEVELCAP":
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
powerAction.levelCap = Integer.parseInt(arguments.get(0));
if (arguments.size() > 1) // Not all level caps have a curve
powerAction.levelCapCurve = mbEnums.CompoundCurveType.valueOf(arguments.get(1));
break;
case "CLEARAGGRO":
powerAction.clearAggro = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "TARGETBECOMESPET":
powerAction.targetBecomesPet = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "DESTROYOLDPET":
powerAction.destroyOldPet = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "DAMAGETYPE":
powerAction.damageType = mbEnums.DamageType.valueOf(lineValues.get(1).trim().toUpperCase());
break;
case "ROOTFSMID":
powerAction.rootFsmID = mbEnums.MobBehaviourType.valueOf(lineValues.get(1).trim());
break;
case "SPLASHDAMAGE":
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
powerAction.splashDamageMin = Integer.parseInt(arguments.get(0));
powerAction.splashDamageMax = Integer.parseInt(arguments.get(1));
break;
case "APPLYEFFECTOTHER":
case "APPLYEFFECTSELF":
case "WEAROFFEFFECTOTHER": // Keys not parsed go here.
case "WEAROFFEFFECTSELF":
break;
default:
Logger.error("Unhandled variable type:" + key + " for powerAction: " + powerAction.action_id);
}
}
return powerAction;
}
}
+319
View File
@@ -0,0 +1,319 @@
// ·. · · · · .
// · ·
// · ·
//
// · · ·
// Magicbane Emulator Project © 2013 - 2024
// www.magicbane.com
package engine.wpak;
import engine.gameManager.ConfigManager;
import engine.mbEnums;
import engine.wpak.data.*;
import org.pmw.tinylog.Logger;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PowersParser {
private static final Pattern POWER_REGEX = Pattern.compile("(?<=POWERBEGIN)(.+?)(?=POWEREND)", Pattern.DOTALL);
private static final Pattern STRSPLIT_REGEX = Pattern.compile("([^\"]\\S*|\"[^\"]*\")\\s*");
private static final Pattern CONDITION_REGEX = Pattern.compile("(?<=CONDITIONBEGIN)(.+?)(?=CONDITIONEND)", Pattern.DOTALL);
private static final String powersPath = ConfigManager.DEFAULT_DATA_DIR + "wpak/Powers.cfg";
public static void parseWpakFile() {
// Read .wpak file from disk
byte[] fileData;
try {
fileData = Files.readAllBytes(Paths.get(powersPath));
} catch (IOException e) {
throw new RuntimeException(e);
}
String fileContents = new String(fileData);
// Iterate over power entries from .wpak data
Matcher matcher = POWER_REGEX.matcher(fileContents);
while (matcher.find()) {
Power power = parsePowerEntry(matcher.group().trim());
// @TODO WpakPowerManager._powersLookup.put(Hasher.SBStringHash(power.power_id), power);
}
}
private static Power parsePowerEntry(String powerData) {
Power powerEntry = new Power();
StringBuilder conditionBuilder = new StringBuilder();
StringBuilder powerBuilder = new StringBuilder();
String conditionString;
String powerString;
java.util.Iterator<String> iterator;
java.util.Iterator<String> argumentIterator;
int endPos = 0;
// Separate out any conditions from the power data
Matcher matcher = CONDITION_REGEX.matcher(powerData);
while (matcher.find()) {
conditionBuilder.append(matcher.group().trim());
powerBuilder.append(powerData, endPos, matcher.start());
endPos = matcher.end();
}
powerBuilder.append(powerData.substring(endPos));
// Cleanup dangling tags and lines that contain a # and leading/trailing blank lines
powerString = powerBuilder.toString().replaceAll("CONDITIONBEGINCONDITIONEND", "")
.replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", "");
conditionString = conditionBuilder.toString().replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", "");
// Parse header line in power data
List<String> lineData = Arrays.asList(powerString.trim().split("\n"));
List<String> powerHeader = new ArrayList<>();
String headerString = lineData.get(0);
headerString = headerString.replace("\n", " ");
matcher = STRSPLIT_REGEX.matcher(headerString);
while (matcher.find())
powerHeader.add(matcher.group().trim());
iterator = powerHeader.iterator();
powerEntry.power_id = iterator.next();
powerEntry.power = iterator.next().replaceAll("\"", "");
PowerEntry power = new PowerEntry();
power.power_type = mbEnums.PowerType.valueOf(iterator.next());
power.icon = Integer.parseInt(iterator.next());
power.focusLine = iterator.next().replaceAll("\"", "");
powerEntry.powers.add(power);
String nextValue = iterator.next();
// Account for second definition
if (nextValue.equals("SPELL") || nextValue.equals("SKILL")) {
power = new PowerEntry();
power.power_type = mbEnums.PowerType.valueOf(nextValue);
power.icon = Integer.parseInt(iterator.next());
power.focusLine = iterator.next().replaceAll("\"", "");
powerEntry.powers.add(power);
powerEntry.target_type = mbEnums.PowerTargetType.valueOf(iterator.next());
} else
powerEntry.target_type = mbEnums.PowerTargetType.valueOf(nextValue);
powerEntry.range = Integer.parseInt(iterator.next());
powerEntry.areaType = mbEnums.AreaType.valueOf(iterator.next());
powerEntry.areaRange = Integer.parseInt(iterator.next());
powerEntry.excludeType = mbEnums.ExcludeType.valueOf(iterator.next());
powerEntry.costType = mbEnums.CostType.valueOf(iterator.next());
powerEntry.cost = Float.parseFloat(iterator.next());
powerEntry.difficulty = Float.parseFloat(iterator.next());
powerEntry.precision = Float.parseFloat(iterator.next());
// Cleanup init_time in client data which is 0.35.1 or some such
powerEntry.init_time = Float.parseFloat(iterator.next().replaceAll("(\\.0)+$", ""));
powerEntry.release_time = Float.parseFloat(iterator.next());
powerEntry.recycle_time = Float.parseFloat(iterator.next());
powerEntry.hitRollYN = Integer.parseInt(iterator.next());
powerEntry.castingMode = mbEnums.CastingModeType.valueOf(iterator.next());
powerEntry.initAmin = Integer.parseInt(iterator.next());
powerEntry.releaseAnim = Integer.parseInt(iterator.next());
powerEntry.targetSelect = mbEnums.TargetSelectType.valueOf(iterator.next());
// Process key value pairs after header
iterator = lineData.iterator();
iterator.next(); // Ignore header
while (iterator.hasNext()) {
String lineValue = iterator.next();
List<String> lineValues = Arrays.asList(lineValue.split("="));
String key = lineValues.get(0).trim();
ActionEntry actionEntry;
List<String> arguments;
Matcher argumentMatcher;
switch (key) {
case "ACTION":
actionEntry = new ActionEntry();
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
actionEntry.action_id = arguments.get(0);
actionEntry.minTrains = Integer.parseInt(arguments.get(1));
actionEntry.maxTrains = Integer.parseInt(arguments.get(2));
actionEntry.duration = Float.parseFloat(arguments.get(3));
actionEntry.curve = mbEnums.CompoundCurveType.valueOf(arguments.get(4));
actionEntry.stackingCategory = arguments.get(5);
actionEntry.stackingPriority = Integer.parseInt(arguments.get(6));
actionEntry.categoryToPower = mbEnums.CategoryToPowerType.valueOf(arguments.get(7));
powerEntry.actionEntries.add(actionEntry);
break;
case "MaxLevel":
powerEntry.maxLevel = Integer.parseInt(lineValues.get(1).trim());
break;
case "HateValue":
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
powerEntry.hateValue = Integer.parseInt(arguments.get(0));
// Not all entries have a curve. Defaults to DefaultFlat;
if (arguments.size() > 1)
powerEntry.hateCurve = mbEnums.CompoundCurveType.valueOf(arguments.get(1));
break;
case "LOOPANIMID":
powerEntry.loopAnimID = Integer.parseInt(lineValues.get(1).trim());
break;
case "GRANTOVERRIDEVAR":
powerEntry.grantOverrideVar = lineValues.get(1).trim();
break;
case "DESCRIPTION":
powerEntry.description.add(lineValues.get(1).trim());
break;
case "CATEGORY":
powerEntry.category = mbEnums.PowerCategoryType.valueOf(lineValues.get(1).trim());
break;
case "CURVE":
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
powerEntry.curves.put(arguments.get(0), mbEnums.CompoundCurveType.valueOf(arguments.get(1)));
break;
case "EQPREREQ":
argumentMatcher = STRSPLIT_REGEX.matcher(lineValues.get(1).trim());
arguments = new ArrayList<>();
while (argumentMatcher.find())
arguments.add(argumentMatcher.group().trim());
argumentIterator = arguments.iterator();
while (argumentIterator.hasNext()) {
EquipmentPreReq equipmentPreReq = new EquipmentPreReq();
equipmentPreReq.slot = mbEnums.EquipSlotType.valueOf(argumentIterator.next());
equipmentPreReq.skill = argumentIterator.next().replaceAll("\"", "");
if (argumentIterator.hasNext())
equipmentPreReq.required = Integer.parseInt(argumentIterator.next());
else
equipmentPreReq.required = 0;
powerEntry.equipmentPreReq.add(equipmentPreReq);
}
break;
case "CANCASTWHILEMOVING":
powerEntry.canCastWhileMoving = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "CANCASTWHILEFLYING":
powerEntry.canCastWhileFlying = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "BLADETRAILS":
powerEntry.bladeTrails = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "EFFECTPREREQ":
Effect effectPreReq = new Effect();
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
effectPreReq.effect_id = arguments.get(9);
effectPreReq.level = Integer.parseInt(arguments.get(1));
effectPreReq.message = arguments.get(2);
powerEntry.effectPreReqs.add(effectPreReq);
break;
case "MONSTERTYPERESTRICTS":
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
for (String restriction : arguments)
powerEntry.monsterRestricts.add(mbEnums.MonsterType.valueOf(restriction.trim()));
break;
case "MONSTERTYPEPREREQS":
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
for (String restriction : arguments)
powerEntry.monsterPrereqs.add(mbEnums.MonsterType.valueOf(restriction.trim()));
break;
case "SHOULDCHECKPATH":
powerEntry.shouldCheckPath = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "STICKY":
powerEntry.sticky = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "PULSEINFO":
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
powerEntry.pulseCycle = Integer.parseInt(arguments.get(0));
powerEntry.pulseDuration = Integer.parseInt(arguments.get(1));
break;
case "MAXNUMMOBTARGETS":
powerEntry.maxMobTargets = Integer.parseInt(lineValues.get(1).trim());
break;
case "MAXNUMPLAYERTARGETS":
powerEntry.maxPlayerTargets = Integer.parseInt(lineValues.get(1).trim());
break;
case "ISADMINPOWER":
powerEntry.isAdminPower = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "ISPROJECTILE":
powerEntry.isProjectile = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "CASTERSPULSEPARTICLE":
powerEntry.casterPulseParticle = Integer.parseInt(lineValues.get(1).trim());
break;
case "TARGETEFFECTPREREQS_ORED":
Effect preReq = new Effect();
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
preReq.effect_id = arguments.get(0);
preReq.level = Integer.parseInt(arguments.get(1));
powerEntry.targetEffectPrereqs.add(preReq);
break;
case "SOUNDS": // Values not parsed
case "APPLYDAMAGESELF":
case "APPLYDAMAGECASTER":
case "APPLYDAMAGEOTHER":
case "APPLYDAMAGETARGET":
case "APPLYEFFECTSELF":
case "APPLYEFFECTOTHER":
case "APPLYEFFECTCASTER":
case "APPLYEFFECTTARGET":
case "FIZZLEOTHER":
case "FIZZLESELF":
case "INITSTRING":
case "SUCCESSOTHER":
case "SUCCESSSELF":
case "WEAROFFEFFECTOTHER":
case "WEAROFFEFFECTSELF":
break;
default:
Logger.error("Unhandled variable type:" + key + " for power: " + powerEntry.power_id);
}
}
// Parse power conditions
if (conditionString.isEmpty() == false) {
List<String> conditions = Arrays.asList(conditionString.split("\n"));
for (String condition : conditions) {
List<String> parameters = Arrays.asList(condition.trim().split("\\s+"));
powerEntry.conditions.put(parameters.get(0), Float.parseFloat(parameters.get(1)));
}
}
return powerEntry;
}
}
+24
View File
@@ -0,0 +1,24 @@
// ·. · · · · .
// · ·
// · ·
//
// · · ·
// Magicbane Emulator Project © 2013 - 2024
// www.magicbane.com
package engine.wpak.data;
import engine.mbEnums;
public class ActionEntry {
public String action_id;
public int minTrains;
public int maxTrains;
public float duration;
public String stackingCategory;
public mbEnums.CompoundCurveType curve;
public int stackingPriority;
public mbEnums.CategoryToPowerType categoryToPower;
}
+21
View File
@@ -0,0 +1,21 @@
// ·. · · · · .
// · ·
// · ·
//
// · · ·
// Magicbane Emulator Project © 2013 - 2024
// www.magicbane.com
//
package engine.wpak.data;
import engine.mbEnums;
import java.util.EnumSet;
public class ConditionEntry {
public String condition;
public int arg;
public mbEnums.CompoundCurveType curveType;
public EnumSet<mbEnums.DamageType> damageTypes = EnumSet.noneOf(mbEnums.DamageType.class);
}
+51
View File
@@ -0,0 +1,51 @@
// ·. · · · · .
// · ·
// · ·
//
// · · ·
// Magicbane Emulator Project © 2013 - 2024
// www.magicbane.com
package engine.wpak.data;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Objects;
public class Effect {
public String effect_id;
public String effect_name;
public int icon;
public HashSet<String> sources = new HashSet<>();
public ArrayList<ModifierEntry> mods = new ArrayList<>();
public ArrayList<ConditionEntry> conditions = new ArrayList<>();
// Additional variables outside of tags or parsed
// elsewhere from Effects.cfg
public boolean isItemEffect;
public boolean isSpireEffect;
public boolean ignoreNoMod;
public boolean dontSave;
public String type;
public int level;
public String message;
public int cycleDuration;
public int cycleDelay;
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Effect effect = (Effect) o;
return Objects.equals(effect_id, effect.effect_id);
}
@Override
public int hashCode() {
return effect_id.hashCode(); // Use only the id field for hashCode
}
}
+19
View File
@@ -0,0 +1,19 @@
// ·. · · · · .
// · ·
// · ·
//
// · · ·
// Magicbane Emulator Project © 2013 - 2024
// www.magicbane.com
package engine.wpak.data;
import engine.mbEnums;
public class EquipmentPreReq {
public mbEnums.EquipSlotType slot;
public String skill;
public int required;
}
+23
View File
@@ -0,0 +1,23 @@
// ·. · · · · .
// · ·
// · ·
//
// · · ·
// Magicbane Emulator Project © 2013 - 2024
// www.magicbane.com
package engine.wpak.data;
import engine.mbEnums;
public class ModifierEntry {
public mbEnums.ModType type;
public float min;
public float max;
public float percentage;
public float value;
public mbEnums.CompoundCurveType compoundCurveType;
public String arg1; // ItemName "Masterwork" ""
public String arg2; // ItemName "" "of the Defender"
}
+96
View File
@@ -0,0 +1,96 @@
// ·. · · · · .
// · ·
// · ·
//
// · · ·
// Magicbane Emulator Project © 2013 - 2024
// www.magicbane.com
package engine.wpak.data;
import engine.mbEnums;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Objects;
public class Power {
public String power_id;
public String power;
public ArrayList<PowerEntry> powers = new ArrayList<>();
public mbEnums.PowerTargetType target_type;
public int range;
public mbEnums.AreaType areaType;
public int areaRange;
public mbEnums.ExcludeType excludeType;
public mbEnums.CostType costType;
public float cost;
public float difficulty;
public float precision;
public float init_time;
public float release_time;
public float recycle_time;
public int hitRollYN;
public mbEnums.CastingModeType castingMode;
public int initAmin;
public int releaseAnim;
public mbEnums.TargetSelectType targetSelect;
// Additional key/value type power entries
public ArrayList<ActionEntry> actionEntries = new ArrayList<>();
public int maxLevel;
public int hateValue;
public mbEnums.CompoundCurveType hateCurve = mbEnums.CompoundCurveType.DefaultFlat;
public int loopAnimID;
public String grantOverrideVar;
public ArrayList<String> description = new ArrayList<>();
public HashMap<String, mbEnums.CompoundCurveType> curves = new HashMap<>();
public mbEnums.PowerCategoryType category;
public boolean canCastWhileMoving = false;
public boolean bladeTrails = false;
public ArrayList<Effect> effectPreReqs = new ArrayList<>();
public ArrayList<EquipmentPreReq> equipmentPreReq = new ArrayList<>();
public EnumSet<mbEnums.MonsterType> monsterRestricts = EnumSet.noneOf(mbEnums.MonsterType.class);
public EnumSet<mbEnums.MonsterType> monsterPrereqs = EnumSet.noneOf(mbEnums.MonsterType.class);
public boolean shouldCheckPath = false;
public boolean sticky = false;
public int pulseCycle;
public int pulseDuration;
public int maxMobTargets;
public int maxPlayerTargets;
public boolean isAdminPower = false;
public int casterPulseParticle;
public ArrayList<Effect> targetEffectPrereqs = new ArrayList<>();
public boolean canCastWhileFlying = false;
public boolean isProjectile = false;
public HashMap<String, Float> conditions = new HashMap<>();
public boolean isSpell() {
return true;
}
public boolean isSkill() {
return true;
}
public boolean isChant() {
return true;
}
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Power power = (Power) o;
return Objects.equals(power_id, power.power_id);
}
@Override
public int hashCode() {
return power_id.hashCode(); // Use only the id field for hashCode
}
}
+68
View File
@@ -0,0 +1,68 @@
// ·. · · · · .
// · ·
// · ·
//
// · · ·
// Magicbane Emulator Project © 2013 - 2024
// www.magicbane.com
package engine.wpak.data;
import engine.mbEnums;
import java.util.ArrayList;
import java.util.Objects;
public class PowerAction {
// Header values
public String action_id;
public mbEnums.PowerActionType action_type;
public ArrayList<Effect> effects = new ArrayList<>();
public int petLevel;
public int petRace;
public StatTransfer statTransfer;
public int levelCap;
public mbEnums.CompoundCurveType levelCapCurve;
public TrackEntry trackEntry;
// Additional variables after header go here.
public ArrayList<Integer> bodyParts = new ArrayList<>();
public ArrayList<Integer> femaleBodyParts = new ArrayList<>();
public boolean shouldShowWeapons = false;
public boolean shouldShowArmor = false;
public boolean bladeTrails = false;
public boolean isResistible = false;
public ArrayList<Float> scaleFactor = new ArrayList<>();
public ArrayList<Integer> attackAnimations = new ArrayList<>();
public boolean isAggressive;
public mbEnums.DamageType damageType;
public boolean applyEffectBlank = false;
public boolean wearOffEffectBlank = false;
public boolean removeAll = false;
public boolean clearAggro = false;
public boolean targetBecomesPet = false;
public boolean destroyOldPet = false;
public mbEnums.ItemFlags itemFlag;
public mbEnums.MobBehaviourType rootFsmID;
public int splashDamageMin;
public int splashDamageMax;
public boolean ignoreNoTeleSpire = false;
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
PowerAction powerAction = (PowerAction) o;
return Objects.equals(action_id, powerAction.action_id);
}
@Override
public int hashCode() {
return action_id.hashCode(); // Use only the id field for hashCode
}
}
+17
View File
@@ -0,0 +1,17 @@
// ·. · · · · .
// · ·
// · ·
//
// · · ·
// Magicbane Emulator Project © 2013 - 2024
// www.magicbane.com
package engine.wpak.data;
import engine.mbEnums;
public class PowerEntry {
public mbEnums.PowerType power_type;
public int icon;
public String focusLine;
}
+24
View File
@@ -0,0 +1,24 @@
// ·. · · · · .
// · ·
// · ·
//
// · · ·
// Magicbane Emulator Project © 2013 - 2024
// www.magicbane.com
package engine.wpak.data;
import engine.mbEnums;
public class StatTransfer {
public mbEnums.CostType fromStat;
public float ramp;
public mbEnums.CompoundCurveType rampCurve;
public mbEnums.CostType toStat;
public float efficiency;
public mbEnums.CompoundCurveType efficiencyCurve;
public boolean fromStatBool;
public boolean isDrain;
public String transfer_action;
public int transfer_ticks;
}
+21
View File
@@ -0,0 +1,21 @@
// ·. · · · · .
// · ·
// · ·
//
// · · ·
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.wpak.data;
import engine.mbEnums;
public class TrackEntry {
public String action_id;
public Boolean trackPlayer;
public Boolean trackCorpse;
public mbEnums.MonsterType filter;
public int min;
public int max;
}