Compare commits

..

21 Commits

Author SHA1 Message Date
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
11 changed files with 151 additions and 159 deletions
@@ -136,6 +136,12 @@ public class dbWarehouseHandler extends dbHandlerBase {
int cityUID = rs.getInt("cityUUID");
JSONObject jsonObject = new JSONObject(rs.getString("warehouse"));
City city = City.getCity(cityUID);
if (city == null) {
Logger.error("No city " + cityUID + " for warehouse");
continue;
}
city.warehouse = new Warehouse(jsonObject);
city.warehouse.city = city;
@@ -463,26 +463,8 @@ public enum BuildingManager {
return GuildStatusController.isGuildLeader(player.getGuildStatus()) || GuildStatusController.isInnerCouncil(player.getGuildStatus());
}
public static int GetAvailableGold(Building building) {
if (building.getStrongboxValue() == 0)
return 0;
if (building.getStrongboxValue() < building.reserve)
return 0;
return building.getStrongboxValue() - building.reserve;
}
public static boolean IsPlayerHostile(Building building, PlayerCharacter player) {
//Nation Members and Guild members are not hostile.
// if (building.getGuild() != null){
// if (pc.getGuild() != null)
// if (building.getGuild().getObjectUUID() == pc.getGuildUUID()
// || pc.getGuild().getNation().getObjectUUID() == building.getGuild().getNation().getObjectUUID())
// return false;
// }
if (Guild.sameNationExcludeErrant(building.getGuild(), player.getGuild()))
return false;
+32 -4
View File
@@ -176,14 +176,31 @@ public enum PowersManager {
PowersBase pb = PowersManager.powersBaseByToken.get(msg.getPowerUsedID());
PlayerCharacter caster = origin.getPlayerCharacter();
PlayerCharacter target = PlayerCharacter.getFromCache(msg.getTargetID());
if (pb != null && pb.isHarmful == false) {
if (pb != null && pb.enforceLore()) {
//if (caster.guild.equals(Guild.getErrantGuild()))
// 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;
}
}
}
if (usePowerA(msg, origin, sendCastToSelf)) {
// Cast failed for some reason, reset timer
@@ -908,9 +925,20 @@ public enum PowersManager {
if (pb.isHarmful())
mobTarget.handleDirectAggro(playerCharacter);
}
//Power is aiding a target, handle aggro if combat target is a Mob.
if (!pb.isHarmful() && target.getObjectType() == GameObjectType.PlayerCharacter) {
//Check for immunities
if (target.getObjectType() == GameObjectType.PlayerCharacter) {
PlayerCharacter pcTarget = (PlayerCharacter) target;
PlayerBonuses tarBonus = pcTarget.getBonuses();
SourceType source = SourceType.GetSourceType(pb.category);
boolean immune = tarBonus.getBool(ModType.ImmuneTo, source);
if(!immune){
DamageType damageType = DamageType.getDamageType(pb.category);
immune = pcTarget.getResists().immuneTo(damageType);
}
if(immune){
return;
}
}
// update target of used power timer
@@ -248,7 +248,7 @@ public class MerchantMsgHandler extends AbstractClientMsgHandler {
City targetCity = null;
if (isTeleport)
cities = City.getCitiesToTeleportTo(player);
cities = City.getCitiesToTeleportTo(player, false);
else
cities = City.getCitiesToRepledgeTo(player);
for (City city : cities) {
@@ -59,7 +59,7 @@ public class SendOwnPlayerMsg extends ClientNetMsg {
@Override
protected int getPowerOfTwoBufferSize() {
//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() {
if (isTeleport)
cities = City.getCitiesToTeleportTo(player);
else
cities = City.getCitiesToRepledgeTo(player);
cities = City.getCitiesToTeleportTo(player, !isTeleport);
}
/**
+67 -104
View File
@@ -120,9 +120,7 @@ public class City extends AbstractWorldObject {
this.treeOfLifeID = rs.getInt("treeOfLifeUUID");
this.bindX = rs.getFloat("bindX");
this.bindZ = rs.getFloat("bindZ");
this.bindLoc = new Vector3fImmutable(this.location.getX() + this.bindX,
this.location.getY(),
this.location.getZ() + this.bindZ);
this.bindLoc = new Vector3fImmutable(this.location.getX() + this.bindX, this.location.getY(), this.location.getZ() + this.bindZ);
this.radiusType = rs.getInt("radiusType");
float bindradiustemp = rs.getFloat("bindRadius");
@@ -288,108 +286,97 @@ public class City extends AbstractWorldObject {
return city.getBindLoc();
}
public static ArrayList<City> getCitiesToTeleportTo(PlayerCharacter pc) {
public static ArrayList<City> getCitiesToTeleportTo(PlayerCharacter playerCharacter, boolean repledge) {
ArrayList<City> cities = new ArrayList<>();
if (pc == null)
if (playerCharacter == null)
return cities;
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
for (AbstractGameObject ago : worldCities.values()) {
City city = (City) ago;
if (city.cityName.equals("Perdition") || city.cityName.equals("Bastion"))
continue; // cannot teleport to perdition or bastion
if (city.isNpc == 1 && city.getGuild().charter.equals(pc.guild.charter)) {
cities.add(city); // anyone of the same charter can teleport to a safehold of that charter
// Filter Player cities
if (city.parentZone == null)
continue;
} else if (city.isNoobIsle == 1 && pc.level <= 20) {
cities.add(city); // everyone can go to noob island if they are under level 20
if (city.parentZone.guild_zone && city.isOpen() && city.getTOL().rank > 4) {
// Filter Lore cities
if (ConfigManager.MB_RULESET.getValue().equals("LORE")) {
if (!repledge)
if (!city.getGuild().charter.equals(playerCharacter.guild.charter))
continue;
} else if (city.cityName.equals("Khan'Ov Srekel")) {
cities.add(city); //everyone anytime can teleport to khan
if (repledge)
if (!city.getGuild().charter.canJoin(playerCharacter))
continue;
} else if (city.isOpen() && city.getTOL().rank > 4 && city.getGuild().charter.equals(pc.guild.charter))
}
if (!city.getTOL().reverseKOS) {
cities.add(city);//can teleport to any open ToL that shares charter
continue;
} else {
if (city.getTOL().getCondemned().contains(pc.objectUUID) && city.getTOL().getCondemned().get(pc.objectUUID).active) {
}
if (city.getTOL().getCondemned().containsKey(playerCharacter.objectUUID) && city.getTOL().getCondemned().get(playerCharacter.objectUUID).active) {
cities.add(city);//this player is allowed for the reverse KOS
continue;
}
if (city.getTOL().getCondemned().contains(pc.guildUUID) && city.getTOL().getCondemned().get(pc.guildUUID).active) {
if (city.getTOL().getCondemned().containsKey(playerCharacter.guildUUID) && city.getTOL().getCondemned().get(playerCharacter.guildUUID).active) {
cities.add(city);//this guild is allowed for the reverse KOS
continue;
}
if (city.getTOL().getCondemned().contains(pc.guild.getNation().getObjectUUID()) && city.getTOL().getCondemned().get(pc.guild.getNation().getObjectUUID()).active) {
if (city.getTOL().getCondemned().containsKey(playerCharacter.guild.getNation().getObjectUUID()) && city.getTOL().getCondemned().get(playerCharacter.guild.getNation().getObjectUUID()).active) {
cities.add(city);//this nation is allowed for the reverse KOS
continue;
}
}
if (city.getGuild().getNation().equals(pc.guild.getNation())) {
cities.add(city);//can always teleport inside your own nation
// Filter NPC cities
if (city.isNoobIsle == 1) {
if (playerCharacter.level < 20)
cities.add(city); // everyone can go to noob island if they are under level 20
continue;
}
}
} else {
Guild pcG = pc.getGuild();
//add npc cities
// Players cannot teleport to perdition or bastion
for (AbstractGameObject ago : worldCities.values()) {
if (ago.getObjectType().equals(GameObjectType.City)) {
City city = (City) ago;
if (city.noTeleport)
if (city.cityName.equals("Perdition") || city.cityName.equals("Bastion"))
continue;
if (city.parentZone != null && city.parentZone.guild_zone) {
// These cities are available for anyone off noob island
if (pc.getAccount().status.equals(AccountStatus.ADMIN)) {
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);
} else
//list Player cities
continue;
}
//open city, just list
// Add Lore cities
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())) {
if (repledge) {
if (city.getGuild().charter.canJoin(playerCharacter))
cities.add(city);
} else if (city.getGuild().charter.equals(playerCharacter.guild.charter))
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;
}
@@ -586,7 +573,7 @@ public class City extends AbstractWorldObject {
if (this.siegesWithstood == siegesWithstood)
return;
if (DbManager.CityQueries.updateSiegesWithstood(this, siegesWithstood) == true)
if (DbManager.CityQueries.updateSiegesWithstood(this, siegesWithstood))
this.siegesWithstood = siegesWithstood;
else
Logger.error("Error when writing to database for cityUUID: " + this.getObjectUUID());
@@ -640,20 +627,13 @@ public class City extends AbstractWorldObject {
public Guild getGuild() {
if (this.getTOL() == null)
return null;
if (this.isNpc == 1) {
return Guild.getErrantGuild();
if (this.getTOL().getOwner() == null)
return null;
return this.getTOL().getOwner().getGuild();
} else {
return Guild.getErrantGuild();
if (this.getTOL().getOwner() == null)
return null;
return this.getTOL().getOwner().getGuild();
}
}
public boolean openCity(boolean open) {
@@ -731,7 +711,7 @@ public class City extends AbstractWorldObject {
for (AbstractCharacter npc : getTOL().getHirelings().keySet()) {
if (npc.getObjectType() == GameObjectType.NPC)
if (((NPC) npc).getContract().isRuneMaster() == true)
if (((NPC) npc).getContract().isRuneMaster())
outNPC = (NPC) npc;
}
@@ -764,16 +744,13 @@ public class City extends AbstractWorldObject {
// Set location for this city
this.location = new Vector3fImmutable(this.parentZone.absX, this.parentZone.absY, this.parentZone.absZ);
this.bindLoc = new Vector3fImmutable(this.location.x + this.bindX,
this.location.y,
this.location.z + this.bindZ);
this.bindLoc = new Vector3fImmutable(this.location.x + this.bindX, this.location.y, this.location.z + this.bindZ);
// set city bounds
Bounds cityBounds = Bounds.borrow();
cityBounds.setBounds(new Vector2f(this.location.x + 64, this.location.z + 64), // location x and z are offset by 64 from the center of the city.
new Vector2f(mbEnums.CityBoundsType.GRID.halfExtents, mbEnums.CityBoundsType.GRID.halfExtents),
0.0f);
new Vector2f(mbEnums.CityBoundsType.GRID.halfExtents, mbEnums.CityBoundsType.GRID.halfExtents), 0.0f);
this.setBounds(cityBounds);
// Sanity check; no tol
@@ -781,8 +758,7 @@ public class City extends AbstractWorldObject {
if (BuildingManager.getBuilding(this.treeOfLifeID) == null)
Logger.info("City UID " + this.getObjectUUID() + " Failed to Load Tree of Life with ID " + this.treeOfLifeID);
if ((ConfigManager.serverType.equals(ServerType.WORLDSERVER))
&& (this.isNpc == (byte) 0)) {
if ((ConfigManager.serverType.equals(ServerType.WORLDSERVER)) && (this.isNpc == (byte) 0)) {
this.realm = RealmMap.getRealmAtLocation(this.getLoc());
@@ -802,8 +778,7 @@ public class City extends AbstractWorldObject {
if (this.getGuild().getGuildState() == GuildState.Nation)
for (Guild sub : this.getGuild().getSubGuildList()) {
if ((sub.getGuildState() == GuildState.Protectorate) ||
(sub.getGuildState() == GuildState.Province)) {
if ((sub.getGuildState() == GuildState.Protectorate) || (sub.getGuildState() == GuildState.Province)) {
this.isCapital = 1;
break;
}
@@ -828,7 +803,7 @@ public class City extends AbstractWorldObject {
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);
DataWarehouse.pushToWarehouse(cityRecord);
}
@@ -853,9 +828,7 @@ public class City extends AbstractWorldObject {
for (Building building : this.parentZone.zoneBuildingSet) {
if (building.getBlueprint() != null &&
building.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE &&
building.getBlueprint().getBuildingGroup() != BuildingGroup.TOL) {
if (building.getBlueprint() != null && building.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE && building.getBlueprint().getBuildingGroup() != BuildingGroup.TOL) {
building.healthMax += (building.healthMax * Realm.getRealmHealthMod(this));
@@ -937,7 +910,7 @@ public class City extends AbstractWorldObject {
// Reapply effect with timeout?
if (refreshEffect == true)
if (refreshEffect)
player.addCityEffect(Integer.toString(effectBase.getUUID()), effectBase, rank, MBServerStatics.FOURTYFIVE_SECONDS, false, this);
}
@@ -1193,18 +1166,13 @@ public class City extends AbstractWorldObject {
// All protection contracts are void upon transfer of a city
//Dont forget to not Flip protection on Banestones and siege Equipment... Noob.
if (cityBuilding.getBlueprint() != null && !cityBuilding.getBlueprint().isSiegeEquip()
&& cityBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE)
if (cityBuilding.getBlueprint() != null && !cityBuilding.getBlueprint().isSiegeEquip() && cityBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE)
cityBuilding.setProtectionState(ProtectionState.NONE);
// Transfer ownership of valid city assets
// these assets are autoprotected.
if ((cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.TOL)
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE)
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK)
|| (cityBuilding.getBlueprint().isWallPiece())
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE)) {
if ((cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.TOL) || (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE) || (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK) || (cityBuilding.getBlueprint().isWallPiece()) || (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE)) {
cityBuilding.claim(sourcePlayer);
cityBuilding.setProtectionState(ProtectionState.PROTECTED);
@@ -1245,12 +1213,7 @@ public class City extends AbstractWorldObject {
// Transfer ownership of valid city assets
// these assets are autoprotected.
if ((cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.TOL)
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE)
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK)
|| (cityBuilding.getBlueprint().isWallPiece())
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE)
) {
if ((cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.TOL) || (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE) || (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK) || (cityBuilding.getBlueprint().isWallPiece()) || (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE)) {
cityBuilding.claim(sourcePlayer);
cityBuilding.setProtectionState(ProtectionState.PROTECTED);
+4
View File
@@ -193,12 +193,16 @@ public class Guild extends AbstractWorldObject {
}
public static boolean sameNationExcludeErrant(Guild a, Guild b) {
if (a == null || b == null)
return false;
if (a.getObjectUUID() == b.getObjectUUID())
return true;
if (a.nation == null || b.nation == null)
return false;
return a.nation.getObjectUUID() == b.nation.getObjectUUID() && !a.nation.isEmptyGuild();
}
+1 -1
View File
@@ -429,7 +429,7 @@ public class Warehouse {
return false;
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.");
return false;
}
+4
View File
@@ -633,4 +633,8 @@ public class PowersBase {
return description;
}
public boolean enforceLore(){
return this.powerCategory.equals(PowerCategoryType.SUMMON) || this.powerCategory.equals(PowerCategoryType.HEAL)|| this.powerCategory.equals(PowerCategoryType.BUFF);
}
}
@@ -125,6 +125,13 @@ public class DestroyCityThread implements Runnable {
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
if ((cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.BARRACK)