Compare commits

..

34 Commits

Author SHA1 Message Date
FatBoy 38983cbcc6 fix new AI syntax error 2025-12-27 11:58:03 -06:00
FatBoy 0258fd8c7d boons are nation friendly 2025-12-27 11:56:41 -06:00
FatBoy 96e63f769c fix pets and siege engines 2025-12-27 11:50:51 -06:00
FatBoy cc740a97fc replace werewolf and werebear with undead guard captain drops 2025-12-27 11:45:16 -06:00
FatBoy a62197d32d wall archer defense and ATR increases 2025-12-27 11:40:10 -06:00
FatBoy 96fc6e741d fix add NPC 2025-12-27 11:20:22 -06:00
FatBoy b8f3c4b240 stack resources command 2025-09-30 12:01:52 -05:00
FatBoy 1ecdcf60a5 handle retaliate even when missed 2025-09-30 11:45:06 -05:00
FatBoy cc09fb04ce add more exclusions to junk command 2025-09-30 11:42:07 -05:00
FatBoy 68d525f91c remove distance reduction for mine production 2025-09-30 11:13:54 -05:00
FatBoy b26a260bf3 allow xpac mines to change production 2025-09-30 11:11:53 -05:00
FatBoy ec736f03be fixed bug with vorg rates being WAY too low because of equip drop limits 2025-09-30 11:01:17 -05:00
FatBoy 1f88bb38fc increase player gold and bank gold limits 2025-09-30 10:53:58 -05:00
FatBoy 27946e695c all player inventory gold limit checks to use MBServerStatics.PLAYER_GOLD_LIMIT 2025-09-30 10:51:52 -05:00
FatBoy 72a72e6bde add ranger and assassin bow to rollable items on bowyer 2025-09-30 10:24:09 -05:00
FatBoy ad45a17abe ToL gets an additional NPC slot 2025-09-22 12:03:00 -05:00
FatBoy 4fdbf12691 allow banker, siege engineer and alchemist on ToL 2025-09-22 11:59:53 -05:00
FatBoy 9b6c75d170 runegates are always open all the time 2025-09-22 11:44:58 -05:00
FatBoy b6546b437b random vorg timers 2025-09-22 11:42:17 -05:00
FatBoy d4d320264c autoloot 2025-09-14 19:19:00 -05:00
FatBoy f66902753c junk from inventory 2025-09-14 19:05:36 -05:00
FatBoy 849e30841c junk from inventory 2025-09-14 18:50:19 -05:00
FatBoy da28279fc1 test 2025-09-14 18:46:09 -05:00
FatBoy e8e43185aa test 2025-09-14 10:20:29 -05:00
FatBoy b334399e65 test 2025-09-14 09:11:54 -05:00
FatBoy 5225898434 create system allowing players to delete items form inventory for gold value (junk hut in bag) 2025-09-14 08:57:03 -05:00
FatBoy bcdaa81357 create system allowing players to delete items form inventory for gold value (junk hut in bag) 2025-09-14 07:54:18 -05:00
MagicBot 3649c629b7 Revert "DamageType defined as in JSON"
This reverts commit 1c31070fc8.
2024-04-01 12:04:12 -04:00
MagicBot 1c31070fc8 DamageType defined as in JSON 2024-04-01 12:01:59 -04:00
MagicBot bff41967db Revert "Out of combat mode when patrolling."
This reverts commit d3692d0fb7.
2023-09-08 13:07:15 -04:00
MagicBot d3692d0fb7 Out of combat mode when patrolling. 2023-09-08 13:04:29 -04:00
FatBoy 074a799d01 added health recovery to mobs 2023-08-22 20:58:52 -05:00
FatBoy 36ffd08a72 guard minions logic work 2023-08-22 20:52:45 -05:00
FatBoy 58f828b3cd items removed properly from inventory, NPCs nop longer stock base items 2023-08-22 20:52:26 -05:00
43 changed files with 1308 additions and 801 deletions
+10 -10
View File
@@ -2822,6 +2822,7 @@ public class Enum {
public enum MobBehaviourType {
None(null, false, false, false, false, false),
//Power
Power(null, false, true, true, true, false),
PowerHelpee(Power, false, true, true, false, true),
PowerHelpeeWimpy(Power, true, false, true, false, false),
@@ -2846,7 +2847,6 @@ public class Enum {
//Independent Types
SimpleStandingGuard(null, false, false, false, false, false),
Pet1(null, false, false, true, false, false),
SiegeEngine(null, false, false, false, false, false),
Simple(null, false, false, true, false, false),
Helpee(null, false, true, true, false, true),
HelpeeWimpy(null, true, false, true, false, false),
@@ -2855,14 +2855,16 @@ public class Enum {
GuardWallArcher(null, false, true, false, false, false),
Wanderer(null, false, true, true, false, false),
HamletGuard(null, false, true, false, false, false),
AggroWanderer(null, false, false, true, false, false);
AggroWanderer(null, false, false, true, false, false),
Siege(null, false, false, false, false, false);
public final MobBehaviourType BehaviourHelperType;
public final boolean isWimpy;
public final boolean isAgressive;
public final boolean canRoam;
public final boolean callsForHelp;
public final boolean respondsToCallForHelp;
private static HashMap<Integer, MobBehaviourType> _behaviourTypes = new HashMap<>();
public MobBehaviourType BehaviourHelperType;
public boolean isWimpy;
public boolean isAgressive;
public boolean canRoam;
public boolean callsForHelp;
public boolean respondsToCallForHelp;
MobBehaviourType(MobBehaviourType helpeebehaviourType, boolean wimpy, boolean agressive, boolean canroam, boolean callsforhelp, boolean respondstocallforhelp) {
this.BehaviourHelperType = helpeebehaviourType;
@@ -2879,8 +2881,6 @@ public class Enum {
MOBILE,
PET,
CHARMED,
SIEGEENGINE,
GUARD;
}
}
@@ -467,7 +467,7 @@ public enum InterestManager implements Runnable {
if (awonpc.despawned == true)
continue;
awonpc.playerAgroMap.put(player.getObjectUUID(), 0f);
awonpc.playerAgroMap.put(player.getObjectUUID(), false);
((Mob) awonpc).setCombatTarget(null);
lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii());
@@ -480,7 +480,7 @@ public enum InterestManager implements Runnable {
if (!awonpc.isAlive())
continue;
awonpc.playerAgroMap.put(player.getObjectUUID(), 0f);
awonpc.playerAgroMap.put(player.getObjectUUID(), false);
if ((awonpc.agentType.equals(Enum.AIAgentType.MOBILE)))
((Mob) awonpc).setCombatTarget(null);
+22 -17
View File
@@ -28,26 +28,31 @@ public class dbMobHandler extends dbHandlerBase {
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
}
public Mob PERSIST(Mob toAdd) {
public Mob ADD_MOB(Mob toAdd) {
Mob mobile = null;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("CALL `mob_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) {
preparedStatement.setLong(1, toAdd.parentZoneUUID);
preparedStatement.setInt(2, toAdd.loadID);
preparedStatement.setInt(3, toAdd.guildUUID);
preparedStatement.setFloat(4, toAdd.bindLoc.x);
preparedStatement.setFloat(5, toAdd.bindLoc.y);
preparedStatement.setFloat(6, toAdd.bindLoc.z);
preparedStatement.setLong(1, toAdd.getParentZoneID());
preparedStatement.setInt(2, toAdd.getMobBaseID());
preparedStatement.setInt(3, toAdd.getGuildUUID());
preparedStatement.setFloat(4, toAdd.getSpawnX());
preparedStatement.setFloat(5, toAdd.getSpawnY());
preparedStatement.setFloat(6, toAdd.getSpawnZ());
preparedStatement.setInt(7, 0);
preparedStatement.setFloat(8, toAdd.spawnRadius);
preparedStatement.setInt(9, toAdd.spawnTime);
preparedStatement.setInt(10, toAdd.contractUUID);
preparedStatement.setInt(11, toAdd.buildingUUID);
preparedStatement.setInt(12, toAdd.level);
preparedStatement.setString(13, toAdd.firstName);
preparedStatement.setFloat(8, toAdd.getSpawnRadius());
preparedStatement.setInt(9, toAdd.getTrueSpawnTime());
if (toAdd.getContract() != null)
preparedStatement.setInt(10, toAdd.getContract().getContractID());
else
preparedStatement.setInt(10, 0);
preparedStatement.setInt(11, toAdd.getBuildingID());
preparedStatement.setInt(12, toAdd.getLevel());
preparedStatement.setString(13, toAdd.getFirstName());
ResultSet rs = preparedStatement.executeQuery();
@@ -101,17 +106,17 @@ public class dbMobHandler extends dbHandlerBase {
return row_count;
}
public void LOAD_GUARD_MINIONS(Mob guardCaptain) {
public void LOAD_PATROL_POINTS(Mob captain) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_guards` WHERE `captainUID` = ?")) {
preparedStatement.setInt(1, guardCaptain.getObjectUUID());
preparedStatement.setInt(1, captain.getObjectUUID());
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
String minionName = rs.getString("name");
Mob toCreate = Mob.createGuardMinion(guardCaptain, guardCaptain.getLevel(), minionName);
String name = rs.getString("name");
Mob toCreate = Mob.createGuardMob(captain, captain.getGuild(), captain.getParentZone(), captain.building.getLoc(), captain.getLevel(), name);
if (toCreate == null)
return;
+4 -3
View File
@@ -14,6 +14,7 @@ import engine.gameManager.ChatManager;
import engine.objects.AbstractGameObject;
import engine.objects.Item;
import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
/**
* @author Eighty
@@ -46,10 +47,10 @@ public class AddGoldCmd extends AbstractDevCmd {
throwbackError(pc, "Quantity must be a number, " + words[0] + " is invalid");
return;
}
if (amt < 1 || amt > 10000000) {
throwbackError(pc, "Quantity must be between 1 and 10000000 (10 million)");
if (amt < 1 || amt > MBServerStatics.PLAYER_GOLD_LIMIT) {
throwbackError(pc, "Quantity must be between 1 and " + MBServerStatics.PLAYER_GOLD_LIMIT);
return;
} else if ((curAmt + amt) > 10000000) {
} else if ((curAmt + amt) > MBServerStatics.PLAYER_GOLD_LIMIT) {
throwbackError(pc, "This would place your inventory over 10,000,000 gold.");
return;
}
+2 -2
View File
@@ -43,7 +43,7 @@ public class AddMobCmd extends AbstractDevCmd {
MobBase mb = (MobBase) mobbaseAGO;
int loadID = mb.getObjectUUID();
Mob mob = Mob.createMob(loadID, Vector3fImmutable.getRandomPointInCircle(pc.getLoc(), 100),
null, zone, null, null, "", 1);
null, true, zone, null, 0, "", 1);
if (mob != null) {
mob.updateDatabase();
this.setResult(String.valueOf(mob.getDBID()));
@@ -84,7 +84,7 @@ public class AddMobCmd extends AbstractDevCmd {
Mob mob = Mob.createMob(loadID, pc.getLoc(),
null, zone, null, null, "", 1);
null, true, zone, null, 0, "", 1);
if (mob != null) {
mob.updateDatabase();
ChatManager.chatSayInfo(pc,
+21 -18
View File
@@ -13,6 +13,7 @@ import engine.Enum.GameObjectType;
import engine.InterestManagement.WorldGrid;
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.*;
import engine.math.Vector3fImmutable;
import engine.objects.*;
import org.pmw.tinylog.Logger;
@@ -70,28 +71,30 @@ public class AddNPCCmd extends AbstractDevCmd {
throwbackError(pc, "Failed to find zone to place npc in.");
return;
}
Building building = null;
if (target != null)
if (target.getObjectType() == GameObjectType.Building) {
Building parentBuilding = (Building) target;
BuildingManager.addHirelingForWorld(parentBuilding, pc, parentBuilding.getLoc(), parentBuilding.getParentZone(), contract, level);
return;
building = (Building)target;
}
NPC npc = NPC.createNPC(name, contractID,
pc.getLoc(), null, zone, (short) level, null);
if (npc != null) {
WorldGrid.addObject(npc, pc);
ChatManager.chatSayInfo(pc,
"NPC with ID " + npc.getDBID() + " added");
this.setResult(String.valueOf(npc.getDBID()));
} else {
throwbackError(pc, "Failed to create npc of contract type "
+ contractID);
Logger.error(
"Failed to create npc of contract type " + contractID);
NPC created;
Guild guild = null;
Vector3fImmutable loc;
if(building != null){
guild = building.getGuild();
loc = building.loc;
} else{
loc = pc.loc;
}
created = NPC.createNPC(name, contractID, loc, guild, zone, (short)level, building);
created.bindLoc = loc;
if(building != null) {
created.buildingUUID = building.getObjectUUID();
created.building = building;
NPCManager.slotCharacterInBuilding(created);
}
created.setLoc(created.bindLoc);
created.updateDatabase();
throwbackInfo(pc, "Created NPC with UUID: " + created.getObjectUUID());
}
@Override
+1 -3
View File
@@ -440,9 +440,7 @@ public class InfoCmd extends AbstractDevCmd {
output += "isSummonedPet: true";
else
output += "isSummonedPet: false";
PlayerCharacter owner = (PlayerCharacter) targetMob.guardCaptain;
PlayerCharacter owner = targetMob.getOwner();
if (owner != null)
output += " owner: " + owner.getObjectUUID();
output += newline;
+2 -2
View File
@@ -59,7 +59,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
if (npc != null) {
for (Mob mob : npc.siegeMinionMap.keySet()) {
for (Mob mob : npc.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob);
@@ -151,7 +151,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
if (npc != null) {
for (Mob mob : npc.siegeMinionMap.keySet()) {
for (Mob mob : npc.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob);
+2 -2
View File
@@ -154,7 +154,7 @@ public class RemoveObjectCmd extends AbstractDevCmd {
mobA = (Mob) ac;
if (npc != null) {
for (Mob mob : npc.siegeMinionMap.keySet()) {
for (Mob mob : npc.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob);
@@ -209,7 +209,7 @@ public class RemoveObjectCmd extends AbstractDevCmd {
if (npc.building != null)
npc.building.getHirelings().remove(npc);
for (Mob mob : npc.siegeMinionMap.keySet()) {
for (Mob mob : npc.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
if (mob.getParentZone() != null)
+1 -1
View File
@@ -110,7 +110,7 @@ public class SplatMobCmd extends AbstractDevCmd {
mobile = Mob.createMob(_mobileUUID,
Vector3fImmutable.getRandomPointInCircle(_currentLocation, _targetRange),
null, serverZone, null, null, "", 1);
null, true, serverZone, null, 0, "", 1);
if (mobile != null) {
mobile.updateDatabase();
+15 -21
View File
@@ -11,7 +11,6 @@ package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.PowersManager;
import engine.objects.AbstractGameObject;
import engine.objects.Mob;
import engine.objects.PlayerCharacter;
@@ -57,41 +56,36 @@ public class aiInfoCmd extends AbstractDevCmd {
Mob mob = (Mob) target;
output = "Mob AI Information:" + newline;
output += mob.getName() + newline;
if (mob.behaviourType != null) {
output += "BehaviourType: " + mob.behaviourType.toString() + newline;
if (mob.behaviourType.BehaviourHelperType != null) {
output += "Behaviour Helper Type: " + mob.behaviourType.BehaviourHelperType.toString() + newline;
if (mob.BehaviourType != null) {
output += "BehaviourType: " + mob.BehaviourType.toString() + newline;
if (mob.BehaviourType.BehaviourHelperType != null) {
output += "Behaviour Helper Type: " + mob.BehaviourType.BehaviourHelperType.toString() + newline;
} else {
output += "Behaviour Helper Type: NULL" + newline;
}
output += "Wimpy: " + mob.behaviourType.isWimpy + newline;
output += "Agressive: " + mob.behaviourType.isAgressive + newline;
output += "Can Roam: " + mob.behaviourType.canRoam + newline;
output += "Calls For Help: " + mob.behaviourType.callsForHelp + newline;
output += "Responds To Call For Help: " + mob.behaviourType.respondsToCallForHelp + newline;
} else {
output += "BehaviourType: NULL" + newline;
}
output += "Wimpy: " + mob.BehaviourType.isWimpy + newline;
output += "Agressive: " + mob.BehaviourType.isAgressive + newline;
output += "Can Roam: " + mob.BehaviourType.canRoam + newline;
output += "Calls For Help: " + mob.BehaviourType.callsForHelp + newline;
output += "Responds To Call For Help: " + mob.BehaviourType.respondsToCallForHelp + newline;
} else {
output += "BehaviourType: NULL" + newline;
}
output += "Aggro Range: " + mob.getAggroRange() + newline;
output += "Player Aggro Map Size: " + mob.playerAgroMap.size() + newline;
if (mob.playerAgroMap.size() > 0) {
output += "Players Loaded:" + newline;
}
for (Map.Entry<Integer, Float> entry : mob.playerAgroMap.entrySet()) {
output += "Player ID: " + entry.getKey() + " Hate Value: " + entry.getValue() + newline;
for (Map.Entry<Integer, Boolean> entry : mob.playerAgroMap.entrySet()) {
output += "Player ID: " + entry.getKey() + " Hate Value: " + (PlayerCharacter.getPlayerCharacter(entry.getKey())).getHateValue() + newline;
}
if (mob.getCombatTarget() != null)
output += "Current Target: " + mob.getCombatTarget().getName() + newline;
else
output += "Current Target: NULL" + newline;
if (mob.guardedCity != null)
output += "Patrolling: " + mob.guardedCity.getCityName() + newline;
output += "Powers:" + newline;
for (int token : mob.mobPowers.keySet())
output += PowersManager.getPowerByToken(token).getName() + newline;
output += token + newline;
throwbackInfo(playerCharacter, output);
}
+3 -3
View File
@@ -535,7 +535,7 @@ public enum BuildingManager {
if (NPC.ISWallArcher(contract)) {
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank);
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank);
if (mob == null)
return false;
@@ -547,7 +547,7 @@ public enum BuildingManager {
if (NPC.ISGuardCaptain(contract.getContractID())) {
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank);
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank);
if (mob == null)
return false;
@@ -559,7 +559,7 @@ public enum BuildingManager {
if (contract.getContractID() == 910) {
//guard dog
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank);
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank);
if (mob == null)
return false;
+48 -4
View File
@@ -29,10 +29,7 @@ import engine.server.world.WorldServer;
import engine.session.Session;
import org.pmw.tinylog.Logger;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.*;
public enum ChatManager {
@@ -189,6 +186,53 @@ public enum ChatManager {
return;
}
if(text.startsWith("./junk")){
//junk command
PlayerCharacter pc = (PlayerCharacter)player;
for(Item i : pc.getCharItemManager().getInventory()){
ItemBase ib = i.getItemBase();
if(ib.isGlass() || ib.getType().equals(Enum.ItemType.CONTRACT) || ib.isVorg() || ib.getType().equals(Enum.ItemType.RUNE)
|| ib.getType().equals(Enum.ItemType.SCROLL) || ib.getType().equals(Enum.ItemType.POTION) || ib.getType().equals(Enum.ItemType.RESOURCE)
|| ib.getType().equals(Enum.ItemType.OFFERING) || ib.getType().equals(Enum.ItemType.REALMCHARTER))
continue;
int value = ib.getBaseValue();
if(pc.getCharItemManager().getGoldInventory().getNumOfItems() + value > MBServerStatics.PLAYER_GOLD_LIMIT)
continue; // cannot hold gold value
pc.getCharItemManager().addGoldToInventory(value,false);
pc.getCharItemManager().junk(i);
}
pc.getCharItemManager().updateInventory();
}
if(text.startsWith("./stackresources")){
HashMap<Integer,Integer> resources = new HashMap<>();
PlayerCharacter pc = (PlayerCharacter)player;
for(Item i : pc.getCharItemManager().getInventory()){
ItemBase ib = i.getItemBase();
if(ib.getType().equals(Enum.ItemType.RESOURCE)){
if(resources.containsKey(ib.getUUID())){
//already logged this resource, add to count
int count = resources.get(ib.getUUID());
count += i.getNumOfItems();
resources.put(ib.getUUID(),count);
}else{
//have not logged this resource yet
resources.put(ib.getUUID(),i.getNumOfItems());
}
pc.getCharItemManager().junk(i);
}
}
for(int id : resources.keySet()){
ItemBase ib = ItemBase.getItemBase(id);
MobLoot ml = new MobLoot(pc,ib,resources.get(id),false);
Item i = ml.promoteToItem(pc);
pc.getCharItemManager().addItemToInventory(i);
}
pc.getCharItemManager().updateInventory();
}
if (ChatManager.isDevCommand(text) == true) {
ChatManager.processDevCommand(player, text);
return;
+8 -4
View File
@@ -763,9 +763,14 @@ public enum CombatManager {
//return if passive (Block, Parry, Dodge) fired
if (passiveFired)
return;
if (passiveFired) {
try {
handleRetaliate(tarAc, ac);
}catch(Exception ignored){
}
return;
}
errorTrack = 9;
//Hit and no passives
@@ -826,8 +831,7 @@ public enum CombatManager {
damage *= 2.5f; //increase damage if sitting
if (tarAc.getObjectType() == GameObjectType.Mob) {
if(ac.getObjectType().equals(GameObjectType.PlayerCharacter))
((Mob)tarAc).playerAgroMap.put(ac.getObjectUUID(), ((Mob) tarAc).playerAgroMap.get(ac.getObjectUUID()) + damage);
ac.setHateValue(damage * MBServerStatics.PLAYER_COMBAT_HATE_MODIFIER);
((Mob) tarAc).handleDirectAggro(ac);
}
+8 -5
View File
@@ -171,6 +171,10 @@ public enum LootManager {
if (itemUUID == 0)
return null;
if(itemUUID == 980103 || itemUUID == 980104 || itemUUID == 980110 || itemUUID == 980111){
itemUUID = 980100;
}
if (ItemBase.getItemBase(itemUUID).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) {
int amount = ThreadLocalRandom.current().nextInt(tableRow.minSpawn, tableRow.maxSpawn + 1);
return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false);
@@ -319,8 +323,10 @@ public enum LootManager {
MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone);
if (toAdd != null)
if (toAdd != null) {
toAdd.setIsID(true);
mob.getCharItemManager().addItemToInventory(toAdd);
}
} catch (Exception e) {
//TODO chase down loot generation error, affects roughly 2% of drops
@@ -331,7 +337,6 @@ public enum LootManager {
public static void GenerateEquipmentDrop(Mob mob) {
//do equipment here
int dropCount = 0;
if (mob.getEquip() != null)
for (MobEquipment me : mob.getEquip().values()) {
@@ -346,12 +351,10 @@ public enum LootManager {
MobLoot ml = new MobLoot(mob, me.getItemBase(), false);
if (ml != null && dropCount < 1) {
if (ml != null){
ml.setIsID(true);
ml.setDurabilityCurrent((short) (ml.getDurabilityCurrent() - ThreadLocalRandom.current().nextInt(5) + 1));
mob.getCharItemManager().addItemToInventory(ml);
dropCount = 1;
//break; // Exit on first successful roll.
}
}
}
+13 -67
View File
@@ -23,6 +23,14 @@ public enum NPCManager {
NPC_MANAGER;
public static HashMap<Integer, ArrayList<Integer>> _runeSetMap = new HashMap<>();
public static void LoadAllRuneSets() {
_runeSetMap = DbManager.ItemBaseQueries.LOAD_RUNES_FOR_NPC_AND_MOBS();
}
public static void LoadAllBootySets() {
LootManager._bootySetMap = DbManager.LootQueries.LOAD_BOOTY_TABLES();
}
public static void applyRuneSetEffects(Mob mob) {
// Early exit
@@ -119,12 +127,10 @@ public enum NPCManager {
DbManager.removeFromCache(necroPet);
PlayerCharacter petOwner = (PlayerCharacter) necroPet.guardCaptain;
PlayerCharacter petOwner = necroPet.getOwner();
if (petOwner != null) {
necroPet.guardCaptain = null;
necroPet.setOwner(null);
petOwner.setPet(null);
if (updateOwner == false)
@@ -222,14 +228,12 @@ public enum NPCManager {
WorldGrid.removeObject(toRemove);
DbManager.removeFromCache(toRemove);
PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain;
PlayerCharacter petOwner = toRemove.getOwner();
if (petOwner != null) {
petOwner.setPet(null);
toRemove.guardCaptain = null;
toRemove.setOwner(null);
PetMsg petMsg = new PetMsg(5, null);
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
@@ -336,19 +340,10 @@ public enum NPCManager {
else
buildingSlot = BuildingManager.getAvailableSlot(abstractCharacter.building);
// Override slot for siege engines
if (abstractCharacter.getObjectType().equals(Enum.GameObjectType.Mob) && ((Mob) abstractCharacter).behaviourType.equals(Enum.MobBehaviourType.SiegeEngine)) {
Mob siegeMobile = (Mob) abstractCharacter;
buildingSlot = siegeMobile.guardCaptain.siegeMinionMap.size() + 2;
}
if (buildingSlot == -1)
Logger.error("No available slot for NPC: " + abstractCharacter.getObjectUUID());
// Pets are regular mobiles not hirelings (Siege engines)
if (abstractCharacter.contract != null)
abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot);
abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot);
// Override bind and location for this npc derived
// from BuildingManager slot location data.
@@ -375,53 +370,4 @@ public enum NPCManager {
return buildingSlot;
}
public static int getMaxMinions(Mob guardCaptain) {
int maxSlots;
switch (guardCaptain.getRank()) {
case 3:
maxSlots = 2;
break;
case 4:
case 5:
maxSlots = 3;
break;
case 6:
maxSlots = 4;
break;
case 7:
maxSlots = 5;
break;
case 1:
case 2:
default:
maxSlots = 1;
}
return maxSlots;
}
public static void AssignPatrolPoints(Mob mob) {
mob.patrolPoints = new ArrayList<>();
for (int i = 0; i < 5; ++i) {
float patrolRadius = mob.getSpawnRadius();
if (patrolRadius > 256)
patrolRadius = 256;
if (patrolRadius < 60)
patrolRadius = 60;
Vector3fImmutable newPatrolPoint = Vector3fImmutable.getRandomPointInCircle(mob.getBindLoc(), patrolRadius);
mob.patrolPoints.add(newPatrolPoint);
if (i == 1) {
mob.loc = newPatrolPoint;
mob.endLoc = newPatrolPoint;
}
}
}
}
@@ -839,6 +839,8 @@ public enum PowersManager {
return;
}
playerCharacter.setHateValue(pb.getHateValue(trains));
//Send Cast Message.
// PerformActionMsg castMsg = new PerformActionMsg(msg);
// castMsg.setNumTrains(9999);
@@ -889,6 +891,8 @@ public enum PowersManager {
//Power is aiding a target, handle aggro if combat target is a Mob.
if (!pb.isHarmful() && target.getObjectType() == GameObjectType.PlayerCharacter) {
PlayerCharacter pcTarget = (PlayerCharacter) target;
if (!pb.isHarmful())
Mob.HandleAssistedAggro(playerCharacter, pcTarget);
}
// update target of used power timer
+2 -2
View File
@@ -29,7 +29,7 @@ public class EndFearJob extends AbstractEffectJob {
if (this.target == null || (!(this.target instanceof Mob)))
return;
((Mob) this.target).fearedObject = null;
((Mob) this.target).setFearedObject(null);
}
@Override
@@ -40,6 +40,6 @@ public class EndFearJob extends AbstractEffectJob {
if (this.target == null || (!(this.target instanceof Mob)))
return;
((Mob) this.target).fearedObject = null;
((Mob) this.target).setFearedObject(null);
}
}
+74 -91
View File
@@ -96,7 +96,7 @@ public class MobAI {
return;
}
if (mob.behaviourType.callsForHelp)
if (mob.BehaviourType.callsForHelp)
MobCallForHelp(mob);
if (!MovementUtilities.inRangeDropAggro(mob, target)) {
@@ -165,7 +165,7 @@ public class MobAI {
if (playercity != null)
for (Mob guard : playercity.getParent().zoneMobSet)
if (guard.behaviourType != null && guard.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
if (guard.BehaviourType != null && guard.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal())
if (guard.getCombatTarget() == null && !guard.getGuild().equals(mob.getGuild()))
guard.setCombatTarget(mob);
@@ -260,7 +260,7 @@ public class MobAI {
//guard captains inherit barracks patrol points dynamically
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) {
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) {
Building barracks = mob.building;
@@ -280,7 +280,7 @@ public class MobAI {
MovementUtilities.aiMove(mob, mob.destination, true);
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
if (mob.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet())
//make sure mob is out of combat stance
@@ -312,9 +312,9 @@ public class MobAI {
int contractID;
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion))
contractID = mob.guardCaptain.contract.getContractID();
else
if(mob.BehaviourType.equals(Enum.MobBehaviourType.GuardMinion))
contractID = mob.npcOwner.contract.getContractID();
else
contractID = mob.contract.getContractID();
if(Enum.MinionType.ContractToMinionMap.get(contractID).isMage() == false)
@@ -350,7 +350,7 @@ public class MobAI {
ArrayList<Integer> purgeTokens;
AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget();
if (mob.behaviourType.callsForHelp)
if (mob.BehaviourType.callsForHelp)
MobCallForHelp(mob);
// Generate a list of tokens from the mob powers for this mobile.
@@ -433,7 +433,7 @@ public class MobAI {
ArrayList<Integer> purgeTokens;
AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget();
if (mob.behaviourType.callsForHelp)
if (mob.BehaviourType.callsForHelp)
MobCallForHelp(mob);
// Generate a list of tokens from the mob powers for this mobile.
@@ -564,7 +564,7 @@ public class MobAI {
Zone mobCamp = mob.getParentZone();
for (Mob helper : mobCamp.zoneMobSet) {
if (helper.behaviourType.respondsToCallForHelp && helper.behaviourType.BehaviourHelperType.equals(mob.behaviourType)) {
if (helper.BehaviourType.respondsToCallForHelp && helper.BehaviourType.BehaviourHelperType.equals(mob.BehaviourType)) {
helper.setCombatTarget(mob.getCombatTarget());
callGotResponse = true;
}
@@ -608,8 +608,8 @@ public class MobAI {
if (mob.despawned && mob.isPlayerGuard) {
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) {
if (mob.guardCaptain.isAlive() == false || ((Mob) mob.guardCaptain).despawned == true) {
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) {
if (mob.npcOwner.isAlive() == false || ((Mob) mob.npcOwner).despawned == true) {
//minions don't respawn while guard captain is dead
@@ -625,7 +625,7 @@ public class MobAI {
//check to send mob home for player guards to prevent exploit of dragging guards away and then teleporting
if (mob.behaviourType.equals(Enum.MobBehaviourType.Pet1) == false)
if (mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal())
CheckToSendMobHome(mob);
return;
@@ -646,7 +646,7 @@ public class MobAI {
return;
}
if (mob.behaviourType.equals(Enum.MobBehaviourType.Pet1) == false)
if (mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal())
CheckToSendMobHome(mob);
if (mob.getCombatTarget() != null) {
@@ -673,7 +673,7 @@ public class MobAI {
}
}
switch (mob.behaviourType) {
switch (mob.BehaviourType) {
case GuardCaptain:
GuardCaptainLogic(mob);
break;
@@ -684,7 +684,8 @@ public class MobAI {
GuardWallArcherLogic(mob);
break;
case Pet1:
case SiegeEngine:
PetLogic(mob);
case Siege:
PetLogic(mob);
break;
case HamletGuard:
@@ -694,6 +695,8 @@ public class MobAI {
DefaultLogic(mob);
break;
}
if(mob.isAlive())
RecoverHealth(mob);
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage());
}
@@ -708,7 +711,7 @@ public class MobAI {
if (!aiAgent.isAlive())
return;
ConcurrentHashMap<Integer, Float> loadedPlayers = aiAgent.playerAgroMap;
ConcurrentHashMap<Integer, Boolean> loadedPlayers = aiAgent.playerAgroMap;
for (Entry playerEntry : loadedPlayers.entrySet()) {
@@ -783,39 +786,33 @@ public class MobAI {
mob.updateLocation();
switch (mob.behaviourType) {
switch (mob.BehaviourType) {
case Pet1:
if ((PlayerCharacter) mob.guardCaptain == null)
if (mob.getOwner() == null)
return;
if (!mob.playerAgroMap.containsKey(((PlayerCharacter) mob.guardCaptain).getObjectUUID())) {
if (!mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID())) {
//mob no longer has its owner loaded, translocate pet to owner
MovementManager.translocate(mob, ((PlayerCharacter) mob.guardCaptain).getLoc(), null);
MovementManager.translocate(mob, mob.getOwner().getLoc(), null);
return;
}
if (mob.getCombatTarget() == null) {
//move back to owner
if (CombatUtilities.inRange2D(mob, (PlayerCharacter) mob.guardCaptain, 6))
if (CombatUtilities.inRange2D(mob, mob.getOwner(), 6))
return;
mob.destination = ((PlayerCharacter) mob.guardCaptain).getLoc();
mob.destination = mob.getOwner().getLoc();
MovementUtilities.moveToLocation(mob, mob.destination, 5);
} else
chaseTarget(mob);
break;
case GuardMinion:
if (!mob.guardCaptain.isAlive() || ((Mob) mob.guardCaptain).despawned)
if (!mob.npcOwner.isAlive() && mob.getCombatTarget() == null)
randomGuardPatrolPoint(mob);
else {
if (mob.getCombatTarget() != null) {
@@ -834,6 +831,7 @@ public class MobAI {
chaseTarget(mob);
}
break;
}
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckMobMovement" + " " + e.getMessage());
@@ -900,8 +898,7 @@ public class MobAI {
if (mob.getCombatTarget() == null)
return;
if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false &&
mob.behaviourType.equals(Enum.MobBehaviourType.Pet1) == false) {
if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false && mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) {
mob.setCombatTarget(null);
return;
@@ -917,10 +914,10 @@ public class MobAI {
private static void CheckToSendMobHome(Mob mob) {
try {
if (mob.behaviourType.isAgressive) {
if (mob.BehaviourType.isAgressive) {
if (mob.isPlayerGuard()) {
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal())
CheckForPlayerGuardAggro(mob);
} else {
CheckForAggro(mob);
@@ -940,7 +937,7 @@ public class MobAI {
PowersManager.useMobPower(mob, mob, recall, 40);
mob.setCombatTarget(null);
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain) && mob.isAlive()) {
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal() && mob.isAlive()) {
//guard captain pulls his minions home with him
@@ -956,8 +953,8 @@ public class MobAI {
PowersManager.useMobPower(mob, mob, recall, 40);
mob.setCombatTarget(null);
for (Integer playerEntry : mob.playerAgroMap.keySet())
mob.playerAgroMap.put(playerEntry,0f);
for (Entry playerEntry : mob.playerAgroMap.entrySet())
PlayerCharacter.getFromCache((int) playerEntry.getKey()).setHateValue(0);
}
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckToSendMobHome" + " " + e.getMessage());
@@ -1021,7 +1018,7 @@ public class MobAI {
if ((aggroMob.agentType.equals(Enum.AIAgentType.GUARD)))
continue;
if (aggroMob.behaviourType.equals(Enum.MobBehaviourType.Pet1))
if(aggroMob.BehaviourType.equals(Enum.MobBehaviourType.Pet1))
continue;
if (mob.getLoc().distanceSquared2D(aggroMob.getLoc()) > sqr(50))
@@ -1051,7 +1048,6 @@ public class MobAI {
mob.setCombatTarget(newTarget);
}
CheckMobMovement(mob);
CheckForAttack(mob);
} catch (Exception e) {
@@ -1062,29 +1058,15 @@ public class MobAI {
public static void GuardMinionLogic(Mob mob) {
try {
if (!mob.guardCaptain.isAlive()) {
if (mob.getCombatTarget() == null) {
CheckForPlayerGuardAggro(mob);
} else {
AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
if (newTarget != null) {
if (newTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
if (GuardCanAggro(mob, (PlayerCharacter) newTarget))
mob.setCombatTarget(newTarget);
} else
mob.setCombatTarget(newTarget);
}
}
boolean isComanded = mob.npcOwner.isAlive();
if (!isComanded) {
GuardCaptainLogic(mob);
}else {
if (mob.guardCaptain.getCombatTarget() != null)
mob.setCombatTarget(mob.guardCaptain.getCombatTarget());
else if (mob.getCombatTarget() != null)
mob.setCombatTarget(null);
if (mob.npcOwner.getCombatTarget() != null)
mob.setCombatTarget(mob.npcOwner.getCombatTarget());
else
if (mob.getCombatTarget() != null)
mob.setCombatTarget(null);
}
CheckMobMovement(mob);
CheckForAttack(mob);
@@ -1109,31 +1091,14 @@ public class MobAI {
try {
if (mob.guardCaptain == null && mob.isNecroPet() == false && mob.isSiege() == false)
if (mob.getOwner() == null && mob.isNecroPet() == false && mob.isSiege() == false)
if (ZoneManager.getSeaFloor().zoneMobSet.contains(mob))
mob.killCharacter("no owner");
if (MovementUtilities.canMove(mob) && mob.behaviourType.canRoam)
if (MovementUtilities.canMove(mob) && mob.BehaviourType.canRoam)
CheckMobMovement(mob);
CheckForAttack(mob);
//recover health
if (mob.getTimestamps().containsKey("HEALTHRECOVERED") == false)
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
if (mob.isSit() && mob.getTimeStamp("HEALTHRECOVERED") < System.currentTimeMillis() + 3000)
if (mob.getHealth() < mob.getHealthMax()) {
float recoveredHealth = mob.getHealthMax() * ((1 + mob.getBonuses().getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None)) * 0.01f);
mob.setHealth(mob.getHealth() + recoveredHealth);
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
if (mob.getHealth() > mob.getHealthMax())
mob.setHealth(mob.getHealthMax());
}
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: PetLogic" + " " + e.getMessage());
}
@@ -1164,7 +1129,7 @@ public class MobAI {
if (mob.getCombatTarget() != null && mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false)
mob.setCombatTarget(null);
if (mob.behaviourType.isAgressive) {
if (mob.BehaviourType.isAgressive) {
AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
@@ -1172,7 +1137,7 @@ public class MobAI {
mob.setCombatTarget(newTarget);
else {
if (mob.getCombatTarget() == null) {
if (mob.behaviourType == Enum.MobBehaviourType.HamletGuard)
if (mob.BehaviourType == Enum.MobBehaviourType.HamletGuard)
SafeGuardAggro(mob); //safehold guard
else
CheckForAggro(mob); //normal aggro
@@ -1182,12 +1147,12 @@ public class MobAI {
//check if mob can move for patrol or moving to target
if (mob.behaviourType.canRoam)
if (mob.BehaviourType.canRoam)
CheckMobMovement(mob);
//check if mob can attack if it isn't wimpy
if (!mob.behaviourType.isWimpy && mob.getCombatTarget() != null)
if (!mob.BehaviourType.isWimpy && mob.getCombatTarget() != null)
CheckForAttack(mob);
} catch (Exception e) {
@@ -1204,7 +1169,7 @@ public class MobAI {
if (!mob.isAlive())
return;
ConcurrentHashMap<Integer, Float> loadedPlayers = mob.playerAgroMap;
ConcurrentHashMap<Integer, Boolean> loadedPlayers = mob.playerAgroMap;
for (Entry playerEntry : loadedPlayers.entrySet()) {
@@ -1252,8 +1217,8 @@ public class MobAI {
if (mob.getGuild().getNation().equals(target.getGuild().getNation()))
return false;
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) {
if (((Mob) mob.guardCaptain).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) {
if (((Mob) mob.npcOwner).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
return true;
}
} else if (mob.building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
@@ -1337,7 +1302,7 @@ public class MobAI {
MovementUtilities.aiMove(mob, mob.destination, true);
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) {
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) {
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) {
//make sure mob is out of combat stance
@@ -1364,7 +1329,7 @@ public class MobAI {
float CurrentHateValue = 0;
if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
CurrentHateValue = mob.playerAgroMap.get(mob.combatTarget.getObjectUUID()).floatValue();
CurrentHateValue = ((PlayerCharacter) mob.getCombatTarget()).getHateValue();
AbstractWorldObject mostHatedTarget = null;
@@ -1375,8 +1340,8 @@ public class MobAI {
if (potentialTarget.equals(mob.getCombatTarget()))
continue;
if (potentialTarget != null && mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) {
CurrentHateValue = mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue();
if (potentialTarget != null && potentialTarget.getHateValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) {
CurrentHateValue = potentialTarget.getHateValue();
mostHatedTarget = potentialTarget;
}
@@ -1387,4 +1352,22 @@ public class MobAI {
}
return null;
}
public static void RecoverHealth(Mob mob){
//recover health
if (mob.getTimestamps().containsKey("HEALTHRECOVERED") == false)
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
if (mob.isSit() && mob.getTimeStamp("HEALTHRECOVERED") < System.currentTimeMillis() + 3000)
if (mob.getHealth() < mob.getHealthMax()) {
float recoveredHealth = mob.getHealthMax() * ((1 + mob.getBonuses().getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None)) * 0.01f);
mob.setHealth(mob.getHealth() + recoveredHealth);
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
if (mob.getHealth() > mob.getHealthMax())
mob.setHealth(mob.getHealthMax());
}
}
}
@@ -48,7 +48,7 @@ public class CombatUtilities {
}
public static boolean inRange2D(AbstractWorldObject entity1, AbstractWorldObject entity2, double range) {
return entity1.getLoc().distanceSquared2D(entity2.getLoc()) < range * range;
return entity1.getLoc().distance2D(entity2.getLoc()) < range;
}
public static void swingIsBlock(Mob agent, AbstractWorldObject target, int animation) {
@@ -13,10 +13,10 @@ import engine.Enum;
import engine.Enum.GameObjectType;
import engine.Enum.ModType;
import engine.Enum.SourceType;
import engine.mobileAI.Threads.MobAIThread;
import engine.exception.MsgSendException;
import engine.gameManager.MovementManager;
import engine.math.Vector3fImmutable;
import engine.mobileAI.Threads.MobAIThread;
import engine.net.client.msg.MoveToPointMsg;
import engine.objects.*;
import org.pmw.tinylog.Logger;
@@ -38,7 +38,7 @@ public class MovementUtilities {
if (agent.getContract() != null)
guardCaptain = agent;
else
guardCaptain = (Mob) agent.guardCaptain;
guardCaptain = (Mob) agent.npcOwner;
if (guardCaptain != null) {
Building barracks = guardCaptain.building;
+31 -3
View File
@@ -560,12 +560,40 @@ public class ClientMessagePump implements NetMsgHandler {
if (!itemManager.inventoryContains(i))
return;
if (i.isCanDestroy())
if (itemManager.delete(i) == true) {
if (i.isCanDestroy()) {
if (itemManager.delete(i)) {
Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
}
}
ItemBase ib = i.getItemBase();
if(ib == null)
return;
if(ib.getUUID() == 7) // don't allow gold to junk for gold
return;
int value = ib.getBaseValue();
Item gold = itemManager.getGoldInventory();
int curAmt;
if (gold == null)
curAmt = 0;
else
curAmt = gold.getNumOfItems();
if ((curAmt + value) > MBServerStatics.PLAYER_GOLD_LIMIT) {
ChatManager.chatSystemInfo(sourcePlayer, "This would place your inventory over " + MBServerStatics.PLAYER_GOLD_LIMIT + " gold.");
return;
}
itemManager.addGoldToInventory(value, false);
itemManager.updateInventory();
//test
}
private static void ackBankWindowOpened(AckBankWindowOpenedMsg msg, ClientConnection origin) {
@@ -1259,7 +1287,7 @@ public class ClientMessagePump implements NetMsgHandler {
cost *= profit;
if (gold.getNumOfItems() + cost > 10000000) {
if (gold.getNumOfItems() + cost > MBServerStatics.PLAYER_GOLD_LIMIT) {
return;
}
@@ -147,7 +147,7 @@ public class MerchantMsgHandler extends AbstractClientMsgHandler {
Building shrineBuilding;
Shrine shrine;
if (npc.getGuild() != player.getGuild())
if (!npc.getGuild().getNation().equals(player.getGuild().getNation()))
return;
shrineBuilding = npc.getBuilding();
@@ -8,6 +8,7 @@ import engine.gameManager.BuildingManager;
import engine.gameManager.DbManager;
import engine.gameManager.NPCManager;
import engine.gameManager.SessionManager;
import engine.math.Vector3fImmutable;
import engine.net.Dispatch;
import engine.net.DispatchMessage;
import engine.net.client.ClientConnection;
@@ -41,6 +42,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
if (player == null)
return true;
if (minionMsg.getNpcType() == Enum.GameObjectType.NPC.ordinal()) {
NPC npc = NPC.getFromCache(minionMsg.getNpcID());
@@ -61,10 +63,10 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
Mob toRemove = Mob.getFromCache(minionMsg.getUUID());
if (!npc.siegeMinionMap.containsKey(toRemove))
if (!npc.getSiegeMinionMap().containsKey(toRemove))
return true;
npc.siegeMinionMap.remove(toRemove);
npc.getSiegeMinionMap().remove(toRemove);
WorldGrid.RemoveWorldObject(toRemove);
@@ -72,18 +74,14 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
toRemove.getParentZone().zoneMobSet.remove(toRemove);
DbManager.removeFromCache(toRemove);
PlayerCharacter petOwner = toRemove.getOwner();
if(toRemove.guardCaptain.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain;
if (petOwner != null) {
petOwner.setPet(null);
toRemove.guardCaptain = null;
PetMsg petMsg = new PetMsg(5, null);
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
}
if (petOwner != null) {
petOwner.setPet(null);
toRemove.setOwner(null);
PetMsg petMsg = new PetMsg(5, null);
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
}
// we Found the move to remove, lets break the for loop so it doesnt look for more.
@@ -117,7 +115,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
if (npc.getContractID() == 842)
maxSlots = 1;
if (npc.siegeMinionMap.size() == maxSlots)
if (npc.getSiegeMinionMap().size() == maxSlots)
return true;
int mobBase;
@@ -148,10 +146,42 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
if (mobBase == 0)
return true;
Mob siegeMob = Mob.createSiegeMinion(npc, mobBase);
Mob siegeMob = Mob.createSiegeMob(npc, mobBase, npc.getGuild(), zone, b.getLoc(), (short) 1);
if (siegeMob == null)
return true;
if (siegeMob != null) {
siegeMob.setSpawnTime(60 * 15);
Building building = BuildingManager.getBuilding(((MinionTrainingMessage) baseMsg).getBuildingID());
siegeMob.building = building;
siegeMob.parentZone = zone;
// Slot siege minion
// Can be either corner tower or bulwark.
int slot;
if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.ARTYTOWER))
slot = 2;
else
slot = ((NPC) siegeMob.npcOwner).getSiegeMinionMap().get(siegeMob) + 1; // First slot is for the captain
BuildingLocation slotLocation = BuildingManager._slotLocations.get(building.meshUUID).get(slot);
siegeMob.bindLoc = building.getLoc().add(slotLocation.getLocation());
// Rotate slot position by the building rotation
siegeMob.bindLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(), siegeMob.bindLoc, building.getBounds().getQuaternion().angleY);
siegeMob.loc = new Vector3fImmutable(siegeMob.bindLoc);
siegeMob.endLoc = new Vector3fImmutable(siegeMob.bindLoc);
zone.zoneMobSet.add(siegeMob);
siegeMob.setLoc(siegeMob.bindLoc);
}
}
ManageNPCMsg mnm = new ManageNPCMsg(npc);
@@ -198,14 +228,11 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
toRemove.getParentZone().zoneMobSet.remove(toRemove);
DbManager.removeFromCache(toRemove);
PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain;
PlayerCharacter petOwner = toRemove.getOwner();
if (petOwner != null) {
petOwner.setPet(null);
toRemove.guardCaptain = null;
toRemove.setOwner(null);
PetMsg petMsg = new PetMsg(5, null);
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
@@ -271,12 +298,12 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
String pirateName = NPCManager.getPirateName(mobBase);
Mob toCreate = Mob.createGuardMinion(npc, npc.getLevel(), pirateName);
if (toCreate == null)
if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1))
return true;
if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1))
Mob toCreate = Mob.createGuardMob(npc, npc.getGuild(), zone, building.getLoc(), npc.getLevel(), pirateName);
if (toCreate == null)
return true;
if (toCreate != null) {
@@ -212,6 +212,10 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
return;
}
for (AbstractCharacter guard : building.getHirelings().keySet()) {
if (guard.getObjectType() == GameObjectType.Mob)
((Mob) guard).setPatrolPointIndex(0);
}
} else if (building.getPatrolPoints() != null)
ClearPatrolPoints(building.getObjectUUID());
@@ -219,6 +223,10 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
AddSentryPoints(building.getObjectUUID(), orderNpcMsg.getSentryPoints());
} else if (building.getSentryPoints() != null)
ClearSentryPoints(building.getObjectUUID());
// Dispatch dispatch = Dispatch.borrow(pc, msg);
// DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
}
private static void processUpgradeNPC(PlayerCharacter player, AbstractCharacter abstractCharacter) {
@@ -533,7 +541,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
} else if (orderNPCMsg.getObjectType() == GameObjectType.Mob.ordinal()) {
mob = Mob.getMob(orderNPCMsg.getNpcUUID());
mob = Mob.getFromCacheDBID(orderNPCMsg.getNpcUUID());
if (mob == null)
return true;
+4 -4
View File
@@ -343,7 +343,7 @@ public class ManageNPCMsg extends ClientNetMsg {
writer.putInt(0); //runemaster list
//artillery captain list
ConcurrentHashMap<Mob, Integer> siegeMinions = npc.siegeMinionMap;
ConcurrentHashMap<Mob, Integer> siegeMinions = npc.getSiegeMinionMap();
writer.putInt(1 + siegeMinions.size());
serializeBulwarkList(writer, 1); //Trebuchet
//serializeBulwarkList(writer, 2); //Ballista
@@ -366,7 +366,7 @@ public class ManageNPCMsg extends ClientNetMsg {
long timeLife = upgradeTime - curTime;
if (upgradeTime * 1000 > System.currentTimeMillis()) {
if (mob.guardCaptain.isAlive()) {
if (mob.npcOwner.isAlive()) {
writer.put((byte) 0);//shows respawning timer
writer.putInt(mob.spawnTime);
writer.putInt(mob.spawnTime);
@@ -557,7 +557,7 @@ public class ManageNPCMsg extends ClientNetMsg {
} else if (this.targetType == GameObjectType.Mob.ordinal()) {
mobA = Mob.getMob(this.targetID);
mobA = Mob.getFromCacheDBID(this.targetID);
if (mobA == null) {
Logger.error("Missing Mob of ID " + this.targetID);
@@ -689,7 +689,7 @@ public class ManageNPCMsg extends ClientNetMsg {
long timeLife = upgradeTime - curTime;
if (upgradeTime * 1000 > System.currentTimeMillis()) {
if (mob.guardCaptain.isAlive()) {
if (mob.npcOwner.isAlive()) {
writer.put((byte) 0);//shows respawning timer
writer.putInt(mob.spawnTime);
writer.putInt(mob.spawnTime);
+38 -23
View File
@@ -52,8 +52,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
public int contractUUID;
public Contract contract;
public String firstName;
public String lastName;
protected String firstName;
protected String lastName;
protected short statStrCurrent;
protected short statDexCurrent;
protected short statConCurrent;
@@ -117,33 +117,16 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
protected boolean movingUp = false;
private float desiredAltitude = 0;
private long takeOffTime = 0;
private float hateValue = 0;
private long lastHateUpdate = 0;
private boolean collided = false;
private byte aoecntr = 0;
public final ConcurrentHashMap<Mob, Integer> siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
public AbstractCharacter() {
super();
this.firstName = "";
this.lastName = "";
this.statStrCurrent = (short) 0;
this.statDexCurrent = (short) 0;
this.statConCurrent = (short) 0;
this.statIntCurrent = (short) 0;
this.statSpiCurrent = (short) 0;
this.unusedStatPoints = (short) 0;
this.level = (short) 0; // TODO get this from MobsBase later
this.exp = 1;
this.walkMode = true;
this.bindLoc = Vector3fImmutable.ZERO;
this.faceDir = Vector3fImmutable.ZERO;
this.runningTrains = (byte) 0;
this.skills = new ConcurrentHashMap<>();
this.powers = new ConcurrentHashMap<>();
this.powers = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
this.initializeCharacter();
}
@@ -231,6 +214,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
this.initializeCharacter();
// Dangerous to use THIS in a constructor!!!
this.charItemManager = new CharacterItemManager(this);
}
/**
@@ -273,6 +258,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
this.powers = new ConcurrentHashMap<>();
this.initializeCharacter();
// Dangerous to use THIS in a constructor!!!
this.charItemManager = new CharacterItemManager(this);
}
/**
@@ -304,6 +291,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
this.powers = new ConcurrentHashMap<>();
initializeCharacter();
// Dangerous to use THIS in a constructor!!!
this.charItemManager = new CharacterItemManager(this);
}
/**
@@ -353,6 +342,9 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
this.powers = new ConcurrentHashMap<>();
this.initializeCharacter();
// Dangerous to use THIS in a constructor!!!
this.charItemManager = new CharacterItemManager(this);
}
public static int getBankCapacity() {
@@ -1766,6 +1758,29 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
this.inBuildingID = inBuildingID;
}
public float getHateValue() {
if (this.hateValue <= 0) {
this.hateValue = 0;
return hateValue;
}
if (this.lastHateUpdate == 0) {
this.lastHateUpdate = System.currentTimeMillis();
return this.hateValue;
}
long duration = System.currentTimeMillis() - this.lastHateUpdate;
//convert duration to seconds and multiply Hate Delimiter.
float modAmount = duration / 1000 * MBServerStatics.PLAYER_HATE_DELIMITER;
this.hateValue -= modAmount;
this.lastHateUpdate = System.currentTimeMillis();
return this.hateValue;
}
public void setHateValue(float hateValue) {
this.lastHateUpdate = System.currentTimeMillis();
this.hateValue = hateValue;
}
public int getInFloorID() {
return inFloorID;
}
@@ -9,7 +9,6 @@
package engine.objects;
import ch.claude_martin.enumbitset.EnumBitSet;
import engine.Enum;
import engine.Enum.GameObjectType;
import engine.Enum.ModType;
@@ -32,20 +31,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
protected Vector3fImmutable lastBindLoc;
public boolean assist = false;
public Enum.AIAgentType agentType = Enum.AIAgentType.MOBILE;
public boolean isPlayerGuard = false;
public AbstractCharacter guardCaptain;
public EnumBitSet<Enum.MonsterType> notEnemy = EnumBitSet.noneOf(Enum.MonsterType.class);
public EnumBitSet<Enum.MonsterType> enemy = EnumBitSet.noneOf(Enum.MonsterType.class);
;
public Enum.MobBehaviourType behaviourType;
public ArrayList<Vector3fImmutable> patrolPoints;
public int lastPatrolPointIndex = 0;
public long stopPatrolTime = 0;
public City guardedCity;
public AbstractIntelligenceAgent() {
super();
}
public AbstractIntelligenceAgent(ResultSet rs) throws SQLException {
super(rs);
@@ -101,8 +87,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
this.agentType = Enum.AIAgentType.CHARMED;
if (this.getObjectType().equals(GameObjectType.Mob)) {
((Mob) this).guardCaptain = owner;
((Mob) this).setOwner(owner);
}
}
@@ -125,6 +110,14 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
return 0;
}
public PlayerCharacter getOwner() {
if (this.getObjectType().equals(GameObjectType.Mob))
return this.getOwner();
return null;
}
public boolean getSafeZone() {
ArrayList<Zone> allIn = ZoneManager.getAllZonesIn(this.getLoc());
@@ -165,7 +158,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
//clear owner
PlayerCharacter owner = (PlayerCharacter) this.guardCaptain;
PlayerCharacter owner = this.getOwner();
//close pet window
@@ -181,7 +174,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
owner.setPet(null);
if (this.getObjectType().equals(GameObjectType.Mob))
((Mob) this).guardCaptain = null;
((Mob) this).setOwner(null);
}
+1 -3
View File
@@ -357,9 +357,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
Mob mob = (Mob) this;
if (mob.isSiege()) {
if (mob.isPet()) {
PlayerCharacter petOwner = (PlayerCharacter) mob.guardCaptain;
PlayerCharacter petOwner = mob.getOwner();
if (petOwner != null && source.equals(EffectSourceType.Effect)) {
petOwner.dismissPet();
return;
+4 -1
View File
@@ -335,13 +335,16 @@ public class Blueprint {
availableSlots = 3;
break;
case 8:
availableSlots = 1;
availableSlots = 3;
break;
default:
availableSlots = 0;
break;
}
if(this.buildingGroup.equals(BuildingGroup.TOL)){
availableSlots += 1;
}
return availableSlots;
}
+2 -3
View File
@@ -970,7 +970,6 @@ public class CharacterItemManager {
// if (i.getObjectType() != GameObjectType.MobLoot)
// CharacterItemManager.junkedItems.add(i);
calculateWeights();
if (updateInventory)
@@ -2335,7 +2334,7 @@ public class CharacterItemManager {
}
if (this.getGoldInventory().getNumOfItems() + goldFrom2 > 10000000) {
if (this.getGoldInventory().getNumOfItems() + goldFrom2 > MBServerStatics.PLAYER_GOLD_LIMIT) {
PlayerCharacter pc = (PlayerCharacter) this.absCharacter;
if (pc.getClientConnection() != null)
ErrorPopupMsg.sendErrorPopup(pc, 202);
@@ -2343,7 +2342,7 @@ public class CharacterItemManager {
}
if (tradingWith.getGoldInventory().getNumOfItems() + goldFrom1 > 10000000) {
if (tradingWith.getGoldInventory().getNumOfItems() + goldFrom1 > MBServerStatics.PLAYER_GOLD_LIMIT) {
PlayerCharacter pc = (PlayerCharacter) tradingWith.absCharacter;
if (pc.getClientConnection() != null)
ErrorPopupMsg.sendErrorPopup(pc, 202);
+6
View File
@@ -86,6 +86,12 @@ public class Contract extends AbstractGameObject {
this.iconID = rs.getInt("iconID");
this.vendorID = rs.getInt("vendorID");
this.allowedBuildings = EnumBitSet.asEnumBitSet(rs.getLong("allowedBuildingTypeID"), Enum.BuildingGroup.class);
switch(this.contractID){
case 866: //banker
case 865: //siege engineer
case 899: //alchemist
this.allowedBuildings.add(Enum.BuildingGroup.TOL);
}
this.equipmentSet = rs.getInt("equipSetID");
this.inventorySet = rs.getInt("inventorySet");
+4
View File
@@ -914,4 +914,8 @@ public class ItemBase {
public void setAutoID(boolean autoID) {
this.autoID = autoID;
}
public boolean isVorg(){
return (this.name.contains("Vorgrim") || this.name.contains("Bellugh") || this.name.contains("Crimson Circle"));
}
}
+14 -16
View File
@@ -381,8 +381,22 @@ public class Mine extends AbstractGameObject {
}
public boolean validForMine(Resource r) {
//check expacs individually
switch(this.getObjectUUID()){
case 58:
case 59:
return (MineProduction.MAGIC.resources.containsKey(r.UUID) || r.UUID == Resource.BLOODSTONE.UUID);
case 60:
return (MineProduction.LUMBER.resources.containsKey(r.UUID) || r.UUID == Resource.WORMWOOD.UUID);
case 61:
return (MineProduction.GOLD.resources.containsKey(r.UUID) || r.UUID == Resource.GALVOR.UUID);
case 62:
return (MineProduction.ORE.resources.containsKey(r.UUID) || r.UUID == Resource.OBSIDIAN.UUID);
}
if (this.mineType == null)
return false;
return this.mineType.validForMine(r, this.isExpansion());
}
@@ -556,22 +570,6 @@ public class Mine extends AbstractGameObject {
}
//add base production on top;
totalModded += baseProduction;
//skip distance check for expansion.
if (this.isExpansion())
return (int) totalModded;
if (this.owningGuild.isEmptyGuild() == false) {
if (this.owningGuild.getOwnedCity() != null) {
float distanceSquared = this.owningGuild.getOwnedCity().getLoc().distanceSquared2D(mineBuilding.getLoc());
if (distanceSquared > sqr(10000 * 3))
totalModded *= .25f;
else if (distanceSquared > sqr(10000 * 2))
totalModded *= .50f;
else if (distanceSquared > sqr(10000))
totalModded *= .75f;
}
}
return (int) totalModded;
}
File diff suppressed because it is too large Load Diff
+15 -7
View File
@@ -50,6 +50,7 @@ public class NPC extends AbstractCharacter {
// Used for thread safety
public final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
private final ArrayList<MobLoot> rolling = new ArrayList<>();
private final ConcurrentHashMap<Mob, Integer> siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock();
public ArrayList<ProducedItem> forgedItems = new ArrayList<>();
public HashMap<Integer, MobEquipment> equip = null;
@@ -85,7 +86,6 @@ public class NPC extends AbstractCharacter {
public NPC() {
super();
this.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET;
this.currentID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET;
}
@@ -654,14 +654,12 @@ public class NPC extends AbstractCharacter {
WorldGrid.RemoveWorldObject(toRemove);
DbManager.removeFromCache(toRemove);
PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain;
PlayerCharacter petOwner = toRemove.getOwner();
if (petOwner != null) {
petOwner.setPet(null);
toRemove.guardCaptain = null;
toRemove.setOwner(null);
PetMsg petMsg = new PetMsg(5, null);
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
@@ -807,8 +805,6 @@ public class NPC extends AbstractCharacter {
@Override
public void runAfterLoad() {
this.charItemManager = new CharacterItemManager(this);
if (ConfigManager.serverType.equals(ServerType.LOGINSERVER))
return;
@@ -850,6 +846,10 @@ public class NPC extends AbstractCharacter {
if (wordCount(this.name) < 2 && this.contract != null)
this.name += " the " + this.contract.getName();
// Initialize inventory
this.charItemManager = new CharacterItemManager(this);
// Configure parent zone adding this NPC to the
// zone collection
@@ -1061,6 +1061,10 @@ public class NPC extends AbstractCharacter {
break;
}
ItemBase itemBase;
if (this.contract.getVendorID() == 104) { // bowyer
fullItemList.add(7000514); //Shadow Bow
fullItemList.add(7000515); //Beastman's Bow
}
for (Integer itemID : fullItemList) {
itemBase = ItemBase.getItemBase(itemID);
boolean exclude = itemBase.getPercentRequired() == 0 && itemBase.getType() == ItemType.WEAPON;
@@ -1103,6 +1107,10 @@ public class NPC extends AbstractCharacter {
return (int) time;
}
public ConcurrentHashMap<Mob, Integer> getSiegeMinionMap() {
return siegeMinionMap;
}
public boolean remove() {
Building building;
+10 -9
View File
@@ -144,6 +144,7 @@ public class PlayerCharacter extends AbstractCharacter {
private long lastUpdateTime = System.currentTimeMillis();
private long lastStamUpdateTime = System.currentTimeMillis();
private boolean safeZone = false;
private int bindBuildingID;
/*
DataWarehouse based kill/death tracking.
@@ -204,18 +205,15 @@ public class PlayerCharacter extends AbstractCharacter {
this.spiMod.set(spiMod);
this.guildStatus = new AtomicInteger(0);
this.buildingUUID = -1;
this.bindBuildingID = -1;
}
/**
* ResultSet Constructor
*/
public PlayerCharacter(ResultSet rs) throws SQLException {
super(rs, true);
this.charItemManager = new CharacterItemManager(this);
this.runes = DbManager.CharacterRuneQueries.GET_RUNES_FOR_CHARACTER(this.getObjectUUID());
int accountID = rs.getInt("parent");
this.account = DbManager.AccountQueries.GET_ACCOUNT(accountID);
@@ -267,7 +265,7 @@ public class PlayerCharacter extends AbstractCharacter {
this.intMod.set(rs.getShort("char_intMod"));
this.spiMod.set(rs.getShort("char_spiMod"));
this.buildingUUID = rs.getInt("char_bindBuilding");
this.bindBuildingID = rs.getInt("char_bindBuilding");
this.hash = rs.getString("hash");
@@ -2723,12 +2721,12 @@ public class PlayerCharacter extends AbstractCharacter {
*/
public synchronized int getBindBuildingID() {
return this.buildingUUID;
return this.bindBuildingID;
}
public synchronized void setBindBuildingID(int value) {
DbManager.PlayerCharacterQueries.SET_BIND_BUILDING(this, value);
this.buildingUUID = value;
this.bindBuildingID = value;
}
public AbstractGameObject getLastTarget() {
@@ -4563,6 +4561,10 @@ public class PlayerCharacter extends AbstractCharacter {
@Override
public void runAfterLoad() {
// Init inventory
this.charItemManager = new CharacterItemManager(this);
Bounds playerBounds = Bounds.borrow();
playerBounds.setBounds(this.getLoc());
this.setBounds(playerBounds);
@@ -4690,8 +4692,7 @@ public class PlayerCharacter extends AbstractCharacter {
} else if (currentPet.isSiege()) {
currentPet.agentType = AIAgentType.MOBILE;
currentPet.guardCaptain = null;
currentPet.setOwner(null);
currentPet.setCombatTarget(null);
if (currentPet.isAlive())
WorldGrid.updateObject(currentPet);
+6 -3
View File
@@ -32,9 +32,12 @@ public class Runegate {
// Chaos, Khar and Oblivion are on by default
_portals[Enum.PortalType.CHAOS.ordinal()].activate(false);
_portals[Enum.PortalType.OBLIV.ordinal()].activate(false);
_portals[Enum.PortalType.MERCHANT.ordinal()].activate(false);
//_portals[Enum.PortalType.CHAOS.ordinal()].activate(false);
//_portals[Enum.PortalType.OBLIV.ordinal()].activate(false);
//_portals[Enum.PortalType.MERCHANT.ordinal()].activate(false);
for(Portal portal : _portals){
portal.activate(false);
}
}
@@ -11,7 +11,6 @@ package engine.powers.poweractions;
import engine.Enum.GameObjectType;
import engine.Enum.ModType;
import engine.Enum.SourceType;
import engine.InterestManagement.WorldGrid;
import engine.gameManager.ChatManager;
import engine.jobs.ChantJob;
import engine.jobs.DeferredPowerJob;
@@ -23,7 +22,6 @@ import engine.objects.*;
import engine.powers.ActionsBase;
import engine.powers.EffectsBase;
import engine.powers.PowersBase;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
@@ -119,12 +117,20 @@ public class ApplyEffectPowerAction extends AbstractPowerAction {
awo.addEffect(stackType, duration, eff, effect, trains);
} else
awo.applyAllBonuses();
// //TODO if chant, start cycle
// if (pb.isChant() && source.equals(awo)) {
// ChantJob cj = new ChantJob(source, awo, stackType, trains, ab, pb, effect, eff);
// source.setLastChant((int)(pb.getChantDuration()-2) * 1000, cj);
// eff.setChant(true);
// }
if (this.effectID.equals("TAUNT")) {
if (awo != null && awo.getObjectType() == GameObjectType.Mob) {
((Mob) awo).setCombatTarget(source);
ChatSystemMsg msg = ChatManager.CombatInfo(source, awo);
DispatchMessage.sendToAllInRange(source, msg);
((Mob)awo).refresh();
}
}
if (awo != null && awo.getObjectType() == GameObjectType.Mob) {
@@ -134,21 +140,7 @@ public class ApplyEffectPowerAction extends AbstractPowerAction {
}
this.effect.startEffect(source, awo, trains, eff);
}
//apply effects to mobs within range for chants
if(pb.isChant){
for(AbstractGameObject ago : WorldGrid.getObjectsInRangePartial(awo.loc,pb.range, MBServerStatics.MASK_MOB)){
Mob mob = (Mob)ago;
if(mob.playerAgroMap.containsKey(source.getObjectUUID()))
mob.playerAgroMap.put(source.getObjectUUID(), mob.playerAgroMap.get(source.getObjectUUID()).floatValue() + pb.hateValue);
}
}else {
if (awo != null && awo.getObjectType() == GameObjectType.Mob) {
Mob mob = (Mob) awo;
if (mob.playerAgroMap.containsKey(source.getObjectUUID()))
mob.playerAgroMap.put(source.getObjectUUID(), mob.playerAgroMap.get(source.getObjectUUID()).floatValue() + pb.hateValue);
}
}
}
protected void _applyEffectForItem(Item item, int trains) {
@@ -12,6 +12,7 @@ package engine.powers.poweractions;
import engine.Enum;
import engine.InterestManagement.WorldGrid;
import engine.gameManager.DbManager;
import engine.gameManager.MovementManager;
import engine.gameManager.NPCManager;
import engine.gameManager.ZoneManager;
import engine.math.Vector3fImmutable;
@@ -74,7 +75,7 @@ public class CreateMobPowerAction extends AbstractPowerAction {
return;
//create Pet
Mob pet = Mob.createPetMinion(mobID, seaFloor, owner, (short) mobLevel);
Mob pet = Mob.createPet(mobID, guild, seaFloor, owner, (short) mobLevel);
if (pet.getMobBaseID() == 12021 || pet.getMobBaseID() == 12022) { //is a necro pet
@@ -83,6 +84,8 @@ public class CreateMobPowerAction extends AbstractPowerAction {
WorldGrid.RemoveWorldObject(currentPet);
currentPet.setCombatTarget(null);
//if (currentPet.getParentZone() != null)
//currentPet.getParentZone().zoneMobSet.remove(currentPet);
seaFloor.zoneMobSet.remove(currentPet);
currentPet.playerAgroMap.clear();
@@ -92,10 +95,10 @@ public class CreateMobPowerAction extends AbstractPowerAction {
Logger.error(e.getMessage());
}
//currentPet.disableIntelligence();
} else if (currentPet != null && currentPet.isSiege()) {
currentPet.agentType = Enum.AIAgentType.MOBILE;
currentPet.guardCaptain = null;
currentPet.setOwner(null);
currentPet.setCombatTarget(null);
if (currentPet.isAlive())
@@ -103,6 +106,7 @@ public class CreateMobPowerAction extends AbstractPowerAction {
}
//remove 10th pet
NPCManager.spawnNecroPet(owner, pet);
} else { //is not a necro pet
@@ -111,7 +115,7 @@ public class CreateMobPowerAction extends AbstractPowerAction {
DbManager.removeFromCache(currentPet);
currentPet.setCombatTarget(null);
currentPet.guardCaptain = null;
currentPet.setOwner(null);
WorldGrid.RemoveWorldObject(currentPet);
//currentPet.getParentZone().zoneMobSet.remove(currentPet);
seaFloor.zoneMobSet.remove(currentPet);
@@ -121,8 +125,7 @@ public class CreateMobPowerAction extends AbstractPowerAction {
} else {
if (currentPet.isSiege()) {
currentPet.agentType = Enum.AIAgentType.MOBILE;
currentPet.guardCaptain = null;
currentPet.setOwner(null);
currentPet.setCombatTarget(null);
if (currentPet.isAlive())
@@ -134,9 +137,26 @@ public class CreateMobPowerAction extends AbstractPowerAction {
NPCManager.resetNecroPets(owner);
}
}
/* if(owner.getPet() != null) {
if(owner.getPet().getMobBaseID() != 12021 && owner.getPet().getMobBaseID() != 12022) {
//if not a necro pet, remove pet
WorldGrid.removeWorldObject(owner.getPet());
owner.getPet().disableIntelligence();
Mob.removePet(owner.getPet().getUUID());
owner.setPet(null);
}
else {
//if it is a necro pet, add it to the line and set as mob
owner.getPet().setMob();
}
}*/
// if (mobID == 12021 || mobID == 12022) //Necro Pets
// pet.setPet(owner, true);
owner.setPet(pet);
if(pet.isSiege() == false) {
MovementManager.translocate(pet, owner.getLoc(), owner.region);
}
pet.recalculateStats();
pet.healthMax = pet.level * 0.5f * 120;
pet.setHealth(pet.healthMax);
@@ -59,7 +59,7 @@ public class FearPowerAction extends AbstractPowerAction {
int duration = 10 + ((int) (trains * 0.5));
String stackType = ab.getStackType();
EndFearJob efj = new EndFearJob(source, awo, stackType, trains, ab, pb, null);
((Mob) awo).fearedObject = source;
((Mob) awo).setFearedObject(source);
JobScheduler.getInstance().scheduleJob(efj, duration * 1000);
}
+2 -2
View File
@@ -33,11 +33,11 @@ public class MBServerStatics {
// hit box
// calcs
public static final boolean PRINT_INCOMING_OPCODES = false; // print
public static final int BANK_GOLD_LIMIT = 25000000;
public static final int BANK_GOLD_LIMIT = 50000000;
// incoming
// opcodes to
// console
public static final int PLAYER_GOLD_LIMIT = 10000000;
public static final int PLAYER_GOLD_LIMIT = 20000000;
// buildings, npcs
/*
* Login cache flags
+44 -43
View File
@@ -10,6 +10,7 @@
package engine.server.world;
import engine.Enum;
import engine.Enum.BuildingGroup;
import engine.Enum.DispatchChannel;
import engine.Enum.MinionType;
import engine.Enum.SupportMsgType;
@@ -17,7 +18,6 @@ import engine.InterestManagement.HeightMap;
import engine.InterestManagement.RealmMap;
import engine.InterestManagement.WorldGrid;
import engine.db.archive.DataWarehouse;
import engine.db.handlers.dbPowerHandler;
import engine.exception.MsgSendException;
import engine.gameManager.*;
import engine.job.JobContainer;
@@ -334,7 +334,7 @@ public class WorldServer {
DbManager.PromotionQueries.GET_ALL_PROMOTIONS();
Logger.info("Loading NPC and Mob Rune Sets");
NPCManager._runeSetMap = DbManager.ItemBaseQueries.LOAD_RUNES_FOR_NPC_AND_MOBS();
NPCManager.LoadAllRuneSets();
Logger.info("Loading Booty Sets");
LootManager._bootySetMap = DbManager.LootQueries.LOAD_BOOTY_TABLES();
@@ -352,7 +352,7 @@ public class WorldServer {
DbManager.MobBaseQueries.GET_ALL_MOBBASES();
Logger.info("Loading Mob Powers");
PowersManager.AllMobPowers = dbPowerHandler.LOAD_MOB_POWERS();
PowersManager.AllMobPowers = DbManager.PowerQueries.LOAD_MOB_POWERS();
Logger.info("Loading item enchants");
DbManager.LootQueries.LOAD_ENCHANT_VALUES();
@@ -482,7 +482,7 @@ public class WorldServer {
Logger.info("Initializing Client Connection Manager");
initClientConnectionManager();
//intiate mob respawn thread
Logger.info("Starting Mob Respawn Thread");
MobRespawnThread.startRespawnThread();
@@ -551,40 +551,44 @@ public class WorldServer {
}
//Set sea floor object for server
Zone seaFloor = rootParent.get(0);
seaFloor.setParent(null);
ZoneManager.setSeaFloor(seaFloor);
// zoneManager.addZone(seaFloor.getLoadNum(), seaFloor); <- DIE IN A FUCKING CAR FIRE BONUS CODE LIKE THIS SUCKS FUCKING DICK
rootParent.addAll(DbManager.ZoneQueries.GET_ALL_NODES(seaFloor));
long start = System.currentTimeMillis();
for (Zone zone : rootParent) {
ZoneManager.addZone(zone.getLoadNum(), zone);
zone.generateWorldAltitude();
//Handle Buildings
try {
ZoneManager.addZone(zone.getLoadNum(), zone);
try {
zone.generateWorldAltitude();
} catch (Exception e) {
Logger.error(e.getMessage());
e.printStackTrace();
}
//Handle Buildings
ArrayList<Building> bList;
bList = DbManager.BuildingQueries.GET_ALL_BUILDINGS_FOR_ZONE(zone);
for (Building b : bList) {
b.setObjectTypeMask(MBServerStatics.MASK_BUILDING);
b.setLoc(b.getLoc());
try {
b.setObjectTypeMask(MBServerStatics.MASK_BUILDING);
b.setLoc(b.getLoc());
} catch (Exception e) {
Logger.error(b.getObjectUUID() + " returned an Error Message :" + e.getMessage());
}
}
} catch (Exception e) {
Logger.error(e);
e.printStackTrace();
}
//Handle Mobs
try {
//Handle Mobs
ArrayList<Mob> mobs;
mobs = DbManager.MobQueries.GET_ALL_MOBS_FOR_ZONE(zone);
@@ -592,22 +596,15 @@ public class WorldServer {
m.setObjectTypeMask(MBServerStatics.MASK_MOB | m.getTypeMasks());
m.setLoc(m.getLoc());
// Load Minions for Guard Captains here.
if (m.building != null && m.building.getBlueprint() != null && m.building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.BARRACK)
DbManager.MobQueries.LOAD_GUARD_MINIONS(m);
//ADD GUARDS HERE.
if (m.building != null && m.building.getBlueprint() != null && m.building.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK)
DbManager.MobQueries.LOAD_PATROL_POINTS(m);
}
} catch (Exception e) {
Logger.error(e);
e.printStackTrace();
}
//Handle NPCs
try {
//Handle npc's
ArrayList<NPC> npcs;
// Ignore NPCs on the seafloor (npc guild leaders, etc)
// Ignore npc's on the seafloor (npc guild leaders, etc)
if (zone.equals(seaFloor))
continue;
@@ -615,22 +612,26 @@ public class WorldServer {
npcs = DbManager.NPCQueries.GET_ALL_NPCS_FOR_ZONE(zone);
for (NPC n : npcs) {
n.setObjectTypeMask(MBServerStatics.MASK_NPC);
n.setLoc(n.getLoc());
try {
n.setObjectTypeMask(MBServerStatics.MASK_NPC);
n.setLoc(n.getLoc());
} catch (Exception e) {
Logger.error(n.getObjectUUID() + " returned an Error Message :" + e.getMessage());
}
}
//Handle cities
ZoneManager.loadCities(zone);
ZoneManager.populateWorldZones(zone);
} catch (Exception e) {
Logger.error(e);
e.printStackTrace();
Logger.info(e.getMessage() + zone.getName() + ' ' + zone.getObjectUUID());
}
//Handle cities
ZoneManager.loadCities(zone);
ZoneManager.populateWorldZones(zone);
}
Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms");
Logger.info("time to load: " + (System.currentTimeMillis() - start) + " ms");
}
/**
@@ -703,7 +704,7 @@ public class WorldServer {
return;
}
//remove player from loaded mobs agro maps
for (AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(player.getLoc(), MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_MOB)) {
for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(player.getLoc(),MBServerStatics.CHARACTER_LOAD_RANGE,MBServerStatics.MASK_MOB)) {
Mob loadedMob = (Mob) awo;
loadedMob.playerAgroMap.remove(player.getObjectUUID());
}