Compare commits

..

117 Commits

Author SHA1 Message Date
MagicBot 6641651f3c Unused method removed. 2023-08-31 07:27:03 -04:00
MagicBot dbf164bfb2 bonus code removal 2023-08-30 15:47:08 -04:00
MagicBot 8a617c3008 Siege minion spawn time set to 15m. 2023-08-30 15:33:55 -04:00
FatBoy a50a2430ba hate value for chants to affect mobs in range 2023-08-29 21:49:02 -05:00
FatBoy 5c3c552288 usage of AIAgentType for default patrol points 2023-08-29 21:17:44 -05:00
FatBoy 69fdddfc71 hate value fix 2023-08-29 21:01:00 -05:00
FatBoy db5b988275 usage of AIAgentType for pet checks in run after load 2023-08-29 20:18:05 -05:00
FatBoy 4284757035 pet level set in run after load removed 2023-08-29 20:16:00 -05:00
FatBoy b93a47acc0 pet death and dismissal fix 2023-08-29 20:12:48 -05:00
MagicBot d59f9857ce Cleanup in pet minion 2023-08-28 00:56:13 -04:00
FatBoy 8ce212b74b Merge remote-tracking branch 'origin/mob-refactor2' into mob-refactor2 2023-08-27 23:53:12 -05:00
FatBoy e78aea5735 Assign patrol points added as static method to NPC manager 2023-08-27 23:52:40 -05:00
MagicBot 9a3c5c3f40 Siege minion assigned UUID. 2023-08-28 00:46:39 -04:00
FatBoy 60ca3f9c34 remove siege minion 2023-08-27 23:42:04 -05:00
FatBoy e7e740dff1 blocked player character specific block in minion training message handler 2023-08-27 23:23:17 -05:00
MagicBot 8343a98d77 Minion added to map after runafterload. 2023-08-28 00:08:35 -04:00
MagicBot 5862039a00 Minion added to map after runafterload. 2023-08-28 00:07:40 -04:00
MagicBot 8af989b75f Fix is patrol logic bloc conditional. 2023-08-27 23:55:02 -04:00
MagicBot 08d0e5ff75 Logic isn't needed here. 2023-08-27 23:32:23 -04:00
MagicBot 5196d10e5c Logic isn't needed here. 2023-08-27 23:31:32 -04:00
MagicBot 3392ec463d Removed unused methods. 2023-08-27 23:29:45 -04:00
MagicBot 33529404cf Logic fix in siege minions. 2023-08-27 23:25:44 -04:00
MagicBot 00e7a36013 Logic fix in siege minions. 2023-08-27 23:22:28 -04:00
FatBoy 3060b394ab removed siegeminion map from NPC 2023-08-27 22:10:13 -05:00
MagicBot a43d9022fe Siege engine slot override. 2023-08-27 22:57:11 -04:00
FatBoy 6abdc68ca5 removed un-needed cast to player character for pets 2023-08-27 21:46:44 -05:00
FatBoy 61c66b0e96 trebs slot in proper locations 2023-08-27 21:38:31 -05:00
FatBoy 36cc23457a optimized slot for siege engines 2023-08-27 21:26:00 -05:00
FatBoy d573b238de refactored mob get/set owner 2023-08-27 21:04:34 -05:00
FatBoy 8afe25fe85 siege minions added to arty captain minion map 2023-08-27 20:50:13 -05:00
MagicBot f80647ff0d Spawn time set to 15s for debug. 2023-08-27 21:42:58 -04:00
MagicBot 7e64cbabf8 Update to slotting logic. 2023-08-27 21:30:57 -04:00
MagicBot 14a06410ae Update to slotting logic. 2023-08-27 21:25:43 -04:00
MagicBot 85c2a4f4f0 Add all as hirelings 2023-08-27 21:20:00 -04:00
FatBoy da9e211ec7 SiegeEngine enum and logic added 2023-08-27 20:05:18 -05:00
MagicBot a81070c471 Pet level += 20 to conform to 24.3 2023-08-26 15:47:10 -04:00
MagicBot e3ad7efa4f Method renamed for new convention. 2023-08-26 15:35:42 -04:00
MagicBot a4dafd7155 Unused variable in signature. 2023-08-26 15:34:27 -04:00
MagicBot 645aec853e Bindloc not adjusted for pets. 2023-08-26 15:21:50 -04:00
MagicBot d8d5e4a3c4 Name set to default. 2023-08-26 15:19:17 -04:00
MagicBot 7a48c04057 Mobbase set properly. 2023-08-26 15:10:14 -04:00
MagicBot 64aaaa707e Behaviour type set for pets. 2023-08-26 15:00:43 -04:00
MagicBot 445d40dc5f Bonus code removed. 2023-08-26 14:59:25 -04:00
MagicBot ebdcb531f2 AI methods moved to ai class. 2023-08-26 14:54:43 -04:00
MagicBot c9cdb891d6 Cleanup of ownerNPC mess. 2023-08-26 14:52:18 -04:00
MagicBot f5c6c002a8 Unused method removed. 2023-08-26 13:53:32 -04:00
MagicBot d171c6bb9a Unused method removed. 2023-08-26 13:47:41 -04:00
MagicBot 1c81a4faed Wall archers static reverted. 2023-08-26 13:38:09 -04:00
MagicBot e7d1d5cb71 Constructor removed. 2023-08-26 12:38:54 -04:00
MagicBot 060d831d50 Comment for clarity. 2023-08-26 12:37:28 -04:00
MagicBot 316bd6dd01 Siege engines use slot system. 2023-08-26 12:35:14 -04:00
MagicBot 34081e5903 Ordinal comparison fix. 2023-08-26 12:21:47 -04:00
MagicBot e2d843b65e Signature refactor. 2023-08-26 12:03:33 -04:00
MagicBot a796f5fe4b More siege engine work. 2023-08-26 11:55:18 -04:00
MagicBot 51ee41c773 use of SiegeEngine Behaviour Type 2023-08-26 11:19:36 -04:00
MagicBot 7e5ed3efe5 sqrMagnitude not sqrRoot 2023-08-26 11:09:58 -04:00
MagicBot 8dd25ac315 Minions inherit patrol points form barracks. 2023-08-26 11:06:48 -04:00
MagicBot 1cdaa58e7a Wall archers set to static grid type. 2023-08-26 10:11:13 -04:00
MagicBot fa3aa24a3d Update to minion building/location mechanic. 2023-08-26 09:41:58 -04:00
MagicBot 091431d95b Dynamic set in all constructors. 2023-08-26 09:31:10 -04:00
MagicBot 1ecf0122ab Unused variable removed. 2023-08-26 09:29:12 -04:00
MagicBot 79980a1725 NoID constructor removed. 2023-08-26 06:45:34 -04:00
MagicBot 8badcc3f6e Refactored out redundant stat-xyz variables. 2023-08-26 06:24:05 -04:00
MagicBot 4d6e57257c Unused methods removed. 2023-08-26 06:19:03 -04:00
MagicBot a7a93b8500 Tweak to bindloc for minions. 2023-08-25 17:05:46 -04:00
MagicBot 85cc34fb4c AIinfo updated. 2023-08-25 16:57:25 -04:00
MagicBot 772a996b6e Tweak to behavior type setup. 2023-08-25 16:49:26 -04:00
MagicBot e67eff822d Propagate guardedCity. 2023-08-25 16:44:45 -04:00
MagicBot c39ed6120f Cleanup of bind/loc logic. 2023-08-25 16:19:04 -04:00
MagicBot c38f4e6543 Mask only needs be set once. 2023-08-25 16:01:18 -04:00
MagicBot 098433b697 Needs contract null check 2023-08-25 15:46:09 -04:00
MagicBot c8e20c905b Add to cache before setloc 2023-08-25 15:37:02 -04:00
MagicBot bd2446ba0a Minion uuid set pre configure 2023-08-25 15:34:47 -04:00
MagicBot c179e4aaf3 Don't override level or name for minions. 2023-08-25 15:29:42 -04:00
MagicBot 2f8de2a919 Worthless collection only used in 2 places. 2023-08-25 15:23:02 -04:00
MagicBot 338110973d Mobbase cannot be null. 2023-08-25 15:19:25 -04:00
MagicBot 3c9c4495bc playerGuard = true. 2023-08-25 15:14:33 -04:00
MagicBot 93476f782c Bind loc not overwritten. 2023-08-25 15:03:37 -04:00
MagicBot 3aec6ee578 More minion setup work. 2023-08-25 14:45:47 -04:00
MagicBot 3bca76d4c8 Setloc to spawn minion. 2023-08-25 14:38:09 -04:00
MagicBot b9d6f35aac Unused variable. 2023-08-25 14:35:02 -04:00
MagicBot 9b6959414a More flushing out minion support. 2023-08-25 14:33:43 -04:00
MagicBot 400dd6aa5e More granular error reporting. 2023-08-25 14:08:43 -04:00
MagicBot 14af2f6efd Minion spawning re-enabled for refactoring. 2023-08-25 14:01:47 -04:00
MagicBot 0a2de9e0d5 Contract handling cleanup. 2023-08-25 13:41:22 -04:00
MagicBot 89bfad78a6 Contract handling cleanup. 2023-08-25 13:31:56 -04:00
MagicBot 52486fa278 Contract handling cleanup. 2023-08-25 13:24:07 -04:00
MagicBot dc0e14eb21 AI added earlier in sequence for availability. 2023-08-25 13:07:47 -04:00
MagicBot 70278374e7 manager init moved to the top of method. 2023-08-25 12:57:21 -04:00
MagicBot ac3588c76a manager init moved to the top of method. 2023-08-25 12:54:03 -04:00
MagicBot ab335aef2a Enums are fragile. 2023-08-25 12:32:36 -04:00
MagicBot 719c855bdb Cleanup of inventoryManager usage. 2023-08-25 12:27:58 -04:00
MagicBot f283e50018 Disabled minions for now. 2023-08-25 12:18:36 -04:00
MagicBot 99b952ee28 Refactor towards new constructor. 2023-08-25 12:12:54 -04:00
MagicBot 24639b62c0 Refactor towards new constructor. 2023-08-25 12:11:50 -04:00
MagicBot 573cc531bf Refactor towards new constructor. 2023-08-25 11:59:59 -04:00
MagicBot 29e24bae93 Unused constructor removed. 2023-08-25 11:37:56 -04:00
MagicBot 22e4cc07c0 Separate pet and siege behaviour types. 2023-08-25 11:26:09 -04:00
MagicBot 9264347698 Minions inherit enemy/notenemy from captain. 2023-08-25 11:24:15 -04:00
MagicBot 579c26ac59 InitializeMob removed. 2023-08-23 13:19:57 -04:00
MagicBot ef577dd313 Removed catch to propagate error. 2023-08-23 13:03:59 -04:00
MagicBot 62c7e52487 Starting to whittle away at initmob method. 2023-08-23 13:01:36 -04:00
MagicBot 3534ac6477 Starting to whittle away at initmob method. 2023-08-23 12:48:34 -04:00
MagicBot 1738f7b311 Starting to whittle away at initmob method. 2023-08-23 12:38:46 -04:00
MagicBot eb25caec81 Object creation moved out of rs const. 2023-08-23 12:24:43 -04:00
MagicBot a6c60e2c04 Merge remote-tracking branch 'origin/master' into mobile-cleanup 2023-08-22 07:50:46 -04:00
MagicBot adafbdf6d3 Duplicate building and building ID values. 2023-08-21 17:20:57 -04:00
MagicBot 7eab14938d Exception for siege when slotting. 2023-08-21 17:11:20 -04:00
MagicBot 039e55673b Exception for siege when slotting. 2023-08-21 17:00:27 -04:00
MagicBot ec3a9b6cb4 Minions don't have contracts. 2023-08-21 16:50:15 -04:00
MagicBot 17a6494b2b Unused code. 2023-08-21 16:41:21 -04:00
MagicBot 0b05c7074f Slot all agents but true mobiles. 2023-08-21 16:37:52 -04:00
MagicBot 876ccc7cbf New constructor created. 2023-08-21 16:12:06 -04:00
MagicBot bdf14b8f24 Ordinal comparisons refactored. 2023-08-21 15:37:21 -04:00
MagicBot 43375a6f5b Only mobiles with contracts can be slotted. 2023-08-21 15:22:08 -04:00
MagicBot e00328ae13 Siege pets use slotting mechanic. 2023-08-21 15:09:10 -04:00
MagicBot 07c553294b Mobiles use new slotting mechanic. 2023-08-21 15:04:32 -04:00
193 changed files with 3455 additions and 11991 deletions
+25 -41
View File
@@ -9,13 +9,15 @@
package engine; package engine;
import ch.claude_martin.enumbitset.EnumBitSetHelper; import ch.claude_martin.enumbitset.EnumBitSetHelper;
import engine.gameManager.BuildingManager;
import engine.gameManager.ConfigManager; import engine.gameManager.ConfigManager;
import engine.gameManager.PowersManager; import engine.gameManager.PowersManager;
import engine.gameManager.ZoneManager; import engine.gameManager.ZoneManager;
import engine.math.Vector2f; import engine.math.Vector2f;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.objects.*; import engine.objects.AbstractCharacter;
import engine.objects.ItemBase;
import engine.objects.Shrine;
import engine.objects.Zone;
import engine.powers.EffectsBase; import engine.powers.EffectsBase;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@@ -137,8 +139,8 @@ public class Enum {
HALFGIANTMALE(2010, MonsterType.HalfGiant, RunSpeed.STANDARD, CharacterSex.MALE, 1.15f), HALFGIANTMALE(2010, MonsterType.HalfGiant, RunSpeed.STANDARD, CharacterSex.MALE, 1.15f),
HUMANMALE(2011, MonsterType.Human, RunSpeed.STANDARD, CharacterSex.MALE, 1), HUMANMALE(2011, MonsterType.Human, RunSpeed.STANDARD, CharacterSex.MALE, 1),
HUMANFEMALE(2012, MonsterType.Human, RunSpeed.STANDARD, CharacterSex.FEMALE, 1), HUMANFEMALE(2012, MonsterType.Human, RunSpeed.STANDARD, CharacterSex.FEMALE, 1),
IREKEIMALE(2013, MonsterType.Irekei, RunSpeed.IREKEI, CharacterSex.MALE, 1.1f), IREKEIMALE(2013, MonsterType.Irekei, RunSpeed.STANDARD, CharacterSex.MALE, 1.1f),
IREKEIFEMALE(2014, MonsterType.Irekei, RunSpeed.IREKEI, CharacterSex.FEMALE, 1.1f), IREKEIFEMALE(2014, MonsterType.Irekei, RunSpeed.STANDARD, CharacterSex.FEMALE, 1.1f),
SHADEMALE(2015, MonsterType.Shade, RunSpeed.STANDARD, CharacterSex.MALE, 1), SHADEMALE(2015, MonsterType.Shade, RunSpeed.STANDARD, CharacterSex.MALE, 1),
SHADEFEMALE(2016, MonsterType.Shade, RunSpeed.STANDARD, CharacterSex.FEMALE, 1), SHADEFEMALE(2016, MonsterType.Shade, RunSpeed.STANDARD, CharacterSex.FEMALE, 1),
MINOMALE(2017, MonsterType.Minotaur, RunSpeed.MINOTAUR, CharacterSex.MALE, 1.3f), MINOMALE(2017, MonsterType.Minotaur, RunSpeed.MINOTAUR, CharacterSex.MALE, 1.3f),
@@ -150,8 +152,7 @@ public class Enum {
NEPHFEMALE(2026, MonsterType.Nephilim, RunSpeed.STANDARD, CharacterSex.FEMALE, 1.1f), NEPHFEMALE(2026, MonsterType.Nephilim, RunSpeed.STANDARD, CharacterSex.FEMALE, 1.1f),
HALFGIANTFEMALE(2027, MonsterType.HalfGiant, RunSpeed.STANDARD, CharacterSex.FEMALE, 1.15f), HALFGIANTFEMALE(2027, MonsterType.HalfGiant, RunSpeed.STANDARD, CharacterSex.FEMALE, 1.15f),
VAMPMALE(2028, MonsterType.Vampire, RunSpeed.STANDARD, CharacterSex.MALE, 1), VAMPMALE(2028, MonsterType.Vampire, RunSpeed.STANDARD, CharacterSex.MALE, 1),
VAMPFEMALE(2029, MonsterType.Vampire, RunSpeed.STANDARD, CharacterSex.FEMALE, 1), VAMPFEMALE(2029, MonsterType.Vampire, RunSpeed.STANDARD, CharacterSex.FEMALE, 1);
SAETOR(1999,MonsterType.Minotaur, RunSpeed.MINOTAUR, CharacterSex.MALE,1);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private static HashMap<Integer, RaceType> _raceTypeByID = new HashMap<>(); private static HashMap<Integer, RaceType> _raceTypeByID = new HashMap<>();
@@ -207,8 +208,8 @@ public class Enum {
SENTINEL(0, 0, 0, 0, 0, 0, 0), SENTINEL(0, 0, 0, 0, 0, 0, 0),
STANDARD(6.1900001f, 13.97f, 4.2199998f, 13.97f, 6.3299999f, 18.379999f, 6.5f), STANDARD(6.1900001f, 13.97f, 4.2199998f, 13.97f, 6.3299999f, 18.379999f, 6.5f),
CENTAUR(6.1900001f, 16.940001f, 5.5500002f, 16.940001f, 6.3299999f, 18.379999f, 6.5f), CENTAUR(6.1900001f, 16.940001f, 5.5500002f, 16.940001f, 6.3299999f, 18.379999f, 6.5f),
MINOTAUR(6.6300001f, 15.95f, 4.2199998f, 15.95f, 6.3299999f, 18.379999f, 6.5f), MINOTAUR(6.6300001f, 15.95f, 4.2199998f, 15.95f, 6.3299999f, 18.379999f, 6.5f);
IREKEI(6.499500105f, 14.6685f, 4.2199998f, 14.6685f, 6.3299999f, 18.379999f, 6.5f);
private float walkStandard; private float walkStandard;
private float walkCombat; private float walkCombat;
private float runStandard; private float runStandard;
@@ -468,14 +469,11 @@ public class Enum {
// 14001 does not have a banestone to bind at // 14001 does not have a banestone to bind at
if (ruinZone.getLoadNum() == 14001) { if (ruinZone.getLoadNum() == 14001)
spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc(), 30); spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc(), 30);
}else { else
//spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc() spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc()
//.add(new Vector3fImmutable(-196.016f, 2.812f, 203.621f)), 30); .add(new Vector3fImmutable(-196.016f, 2.812f, 203.621f)), 30);
spawnLocation = Vector3fImmutable.getRandomPointOnCircle(BuildingManager.getBuilding(27977).loc,30f);
}
} }
@@ -778,7 +776,6 @@ public class Enum {
Combat, Combat,
Spires, Spires,
Snare, Snare,
Snared,
Stun, Stun,
Blind, Blind,
Root, Root,
@@ -881,7 +878,6 @@ public class Enum {
Siege, Siege,
Slash, Slash,
Snare, Snare,
Snared,
Sorcery, Sorcery,
Spear, Spear,
SpearMastery, SpearMastery,
@@ -961,17 +957,6 @@ public class Enum {
Wizardry; Wizardry;
public static SourceType GetSourceType(String modName) { public static SourceType GetSourceType(String modName) {
switch(modName){
case "Slashing":
modName = "Slash";
break;
case "Crushing":
modName = "Crush";
break;
case "Piercing":
modName = "Pierce";
break;
}
SourceType returnMod; SourceType returnMod;
if (modName.isEmpty()) if (modName.isEmpty())
return SourceType.None; return SourceType.None;
@@ -1031,7 +1016,6 @@ public class Enum {
Silence, Silence,
Slash, Slash,
Snare, Snare,
Snared,
Stance, Stance,
Stun, Stun,
Summon, Summon,
@@ -1156,7 +1140,6 @@ public class Enum {
SkillDebuff, SkillDebuff,
SlashResistanceDebuff, SlashResistanceDebuff,
Snare, Snare,
Snared,
StackableAttrCONBuff, StackableAttrCONBuff,
StackableAttrDEXBuff, StackableAttrDEXBuff,
StackableAttrSTRBuff, StackableAttrSTRBuff,
@@ -2323,9 +2306,9 @@ public class Enum {
public enum CityBoundsType { public enum CityBoundsType {
GRID(544), GRID(640),
ZONE(672), ZONE(875),
PLACEMENT(673); PLACEMENT(876);
public final float extents; public final float extents;
@@ -2839,7 +2822,6 @@ public class Enum {
public enum MobBehaviourType { public enum MobBehaviourType {
None(null, false, false, false, false, false), None(null, false, false, false, false, false),
//Power
Power(null, false, true, true, true, false), Power(null, false, true, true, true, false),
PowerHelpee(Power, false, true, true, false, true), PowerHelpee(Power, false, true, true, false, true),
PowerHelpeeWimpy(Power, true, false, true, false, false), PowerHelpeeWimpy(Power, true, false, true, false, false),
@@ -2864,6 +2846,7 @@ public class Enum {
//Independent Types //Independent Types
SimpleStandingGuard(null, false, false, false, false, false), SimpleStandingGuard(null, false, false, false, false, false),
Pet1(null, false, false, true, false, false), Pet1(null, false, false, true, false, false),
SiegeEngine(null, false, false, false, false, false),
Simple(null, false, false, true, false, false), Simple(null, false, false, true, false, false),
Helpee(null, false, true, true, false, true), Helpee(null, false, true, true, false, true),
HelpeeWimpy(null, true, false, true, false, false), HelpeeWimpy(null, true, false, true, false, false),
@@ -2874,13 +2857,12 @@ public class Enum {
HamletGuard(null, false, true, false, false, false), HamletGuard(null, false, true, false, false, false),
AggroWanderer(null, false, false, true, false, false); AggroWanderer(null, false, false, true, false, false);
private static HashMap<Integer, MobBehaviourType> _behaviourTypes = new HashMap<>(); public final MobBehaviourType BehaviourHelperType;
public MobBehaviourType BehaviourHelperType; public final boolean isWimpy;
public boolean isWimpy; public final boolean isAgressive;
public boolean isAgressive; public final boolean canRoam;
public boolean canRoam; public final boolean callsForHelp;
public boolean callsForHelp; public final boolean respondsToCallForHelp;
public boolean respondsToCallForHelp;
MobBehaviourType(MobBehaviourType helpeebehaviourType, boolean wimpy, boolean agressive, boolean canroam, boolean callsforhelp, boolean respondstocallforhelp) { MobBehaviourType(MobBehaviourType helpeebehaviourType, boolean wimpy, boolean agressive, boolean canroam, boolean callsforhelp, boolean respondstocallforhelp) {
this.BehaviourHelperType = helpeebehaviourType; this.BehaviourHelperType = helpeebehaviourType;
@@ -2897,6 +2879,8 @@ public class Enum {
MOBILE, MOBILE,
PET, PET,
CHARMED, CHARMED,
SIEGEENGINE,
GUARD; GUARD;
} }
} }
@@ -19,7 +19,10 @@ import engine.net.AbstractNetMsg;
import engine.net.Dispatch; import engine.net.Dispatch;
import engine.net.DispatchMessage; import engine.net.DispatchMessage;
import engine.net.client.ClientConnection; import engine.net.client.ClientConnection;
import engine.net.client.msg.*; import engine.net.client.msg.LoadCharacterMsg;
import engine.net.client.msg.LoadStructureMsg;
import engine.net.client.msg.MoveToPointMsg;
import engine.net.client.msg.UnloadObjectsMsg;
import engine.objects.*; import engine.objects.*;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@@ -464,7 +467,7 @@ public enum InterestManager implements Runnable {
if (awonpc.despawned == true) if (awonpc.despawned == true)
continue; continue;
awonpc.playerAgroMap.put(player.getObjectUUID(), false); awonpc.playerAgroMap.put(player.getObjectUUID(), 0f);
((Mob) awonpc).setCombatTarget(null); ((Mob) awonpc).setCombatTarget(null);
lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii()); lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii());
@@ -477,7 +480,7 @@ public enum InterestManager implements Runnable {
if (!awonpc.isAlive()) if (!awonpc.isAlive())
continue; continue;
awonpc.playerAgroMap.put(player.getObjectUUID(), false); awonpc.playerAgroMap.put(player.getObjectUUID(), 0f);
if ((awonpc.agentType.equals(Enum.AIAgentType.MOBILE))) if ((awonpc.agentType.equals(Enum.AIAgentType.MOBILE)))
((Mob) awonpc).setCombatTarget(null); ((Mob) awonpc).setCombatTarget(null);
@@ -518,10 +521,10 @@ public enum InterestManager implements Runnable {
// Update loaded upbjects lists // Update loaded upbjects lists
player.isBoxed = PlayerCharacter.checkIfBoxed(player);
player.setDirtyLoad(true); player.setDirtyLoad(true);
updateStaticList(player, origin); updateStaticList(player, origin);
updateMobileList(player, origin); updateMobileList(player, origin);
} }
public synchronized void HandleLoadForTeleport(PlayerCharacter playerCharacter) { public synchronized void HandleLoadForTeleport(PlayerCharacter playerCharacter) {
-139
View File
@@ -1,139 +0,0 @@
package engine;
import engine.InterestManagement.WorldGrid;
import engine.gameManager.BuildingManager;
import engine.gameManager.ChatManager;
import engine.math.Vector3fImmutable;
import engine.objects.*;
import engine.server.MBServerStatics;
import java.util.ArrayList;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
public class PlayerAi {
public static ArrayList<PlayerCharacter> ai_players = new ArrayList<>();
public static void addPlayer(PlayerCharacter pc){
ai_players.add(pc);
int index = ai_players.indexOf(pc);
pc.setObjectUUID(MBServerStatics.NO_DB_ROW_ASSIGNED_YET - (1 + index));
}
public static void populate_world(){
for(Mine mine : Mine.getMines()){
Building tower = BuildingManager.getBuildingFromCache(mine.getBuildingID());
if(tower != null){
for(int i = 0; i < mine.capSize; i++){
addPlayer(createPlayer(tower));
}
}
}
}
public static PlayerCharacter createPlayer(Building tower){
Vector3fImmutable loc = Vector3fImmutable.getRandomPointOnCircle(tower.loc,40f);
//get random race
Race race = null;
while(race == null) {
int raceId = ThreadLocalRandom.current().nextInt(1999, 2030);
while (raceId == 2021 || raceId == 2020 || raceId == 2019 || raceId == 2018) {
raceId = ThreadLocalRandom.current().nextInt(1999, 2030);
}
race = Race.getRace(raceId);
}
//get random baseClass
BaseClass baseClass = null;
while(baseClass == null) {
int baseId = ThreadLocalRandom.current().nextInt(2499, 2505);
BaseClass temp = BaseClass.getBaseClass(baseId);
if (temp == null || !race.getValidBaseClasses().contains(temp)) {
continue;
}
baseClass = BaseClass.getBaseClass(baseId);
}
PlayerCharacter newPLayer = new PlayerCharacter("", "AI POWERED", (short) 5, (short) 5, (short) 5, (short) 5,
(short) 5, Guild.getGuild(5), (byte) 0, (Account) null, race, baseClass
, (byte) 1, (byte) 1,
(byte) 1, (byte) 1, (byte) 1);
newPLayer.runAfterLoad();
if(newPLayer.isMale()) {
newPLayer.setFirstName(getMaleName());
}else {
newPLayer.setFirstName(getFemaleName());
}
newPLayer.setLevel((short)10);
PromotionClass promo = null;
while(promo == null){
int promoId = ThreadLocalRandom.current().nextInt(2508,2526);
PromotionClass temp = PromotionClass.GetPromtionClassFromCache(promoId);
if(temp == null)
continue;
if(!temp.isAllowedRune(race.getToken()))
continue;
if(!temp.isAllowedRune(baseClass.getToken()))
continue;
promo = PromotionClass.GetPromtionClassFromCache(promoId);
}
newPLayer.setPromotionClass(promo.getObjectUUID());
newPLayer.setLevel((short)75);
newPLayer.setLoc(loc);
newPLayer.setObjectTypeMask(MBServerStatics.MASK_PLAYER);
WorldGrid.addObject(newPLayer,loc.x,loc.z);
return newPLayer;
}
public static void run_ai_players() {
for (PlayerCharacter pc : ai_players) {
}
}
public static String getMaleName(){
String[] maleNames = {
"James", "John", "Robert", "Michael", "William", "David", "Richard", "Joseph", "Thomas", "Charles",
"Christopher", "Daniel", "Matthew", "Anthony", "Mark", "Donald", "Steven", "Paul", "Andrew", "Joshua",
"Kenneth", "Kevin", "Brian", "George", "Edward", "Ronald", "Timothy", "Jason", "Jeffrey", "Ryan",
"Jacob", "Gary", "Nicholas", "Eric", "Jonathan", "Stephen", "Larry", "Justin", "Scott", "Brandon",
"Benjamin", "Samuel", "Gregory", "Alexander", "Patrick", "Frank", "Raymond", "Jack", "Dennis", "Jerry",
"Tyler", "Aaron", "Jose", "Adam", "Nathan", "Henry", "Douglas", "Zachary", "Peter", "Kyle",
"Walter", "Ethan", "Jeremy", "Harold", "Keith", "Christian", "Roger", "Noah", "Gerald", "Carl",
"Terry", "Sean", "Austin", "Arthur", "Lawrence", "Jesse", "Dylan", "Bryan", "Joe", "Jordan",
"Billy", "Bruce", "Albert", "Willie", "Gabriel", "Logan", "Alan", "Juan", "Wayne", "Roy",
"Ralph", "Randy", "Eugene", "Vincent", "Russell", "Louis", "Philip", "Bobby", "Johnny", "Bradley"
};
Random random = new Random();
return maleNames[random.nextInt(maleNames.length)];
}
public static String getFemaleName(){
String[] femaleNames = {
"Mary", "Patricia", "Jennifer", "Linda", "Elizabeth", "Barbara", "Susan", "Jessica", "Sarah", "Karen",
"Nancy", "Lisa", "Betty", "Margaret", "Sandra", "Ashley", "Kimberly", "Emily", "Donna", "Michelle",
"Carol", "Amanda", "Melissa", "Deborah", "Stephanie", "Rebecca", "Laura", "Sharon", "Cynthia", "Kathleen",
"Amy", "Shirley", "Angela", "Helen", "Anna", "Brenda", "Pamela", "Nicole", "Samantha", "Katherine",
"Christine", "Debra", "Rachel", "Catherine", "Carolyn", "Janet", "Ruth", "Maria", "Heather", "Diane",
"Virginia", "Julie", "Joyce", "Victoria", "Kelly", "Christina", "Lauren", "Joan", "Evelyn", "Judith",
"Olivia", "Frances", "Martha", "Cheryl", "Megan", "Andrea", "Hannah", "Jacqueline", "Ann", "Gloria",
"Jean", "Kathryn", "Alice", "Teresa", "Sara", "Janice", "Doris", "Madison", "Julia", "Grace",
"Judy", "Abigail", "Marie", "Denise", "Beverly", "Amber", "Theresa", "Marilyn", "Danielle", "Diana",
"Brittany", "Natalie", "Sophia", "Rose", "Isabella", "Alexis", "Kayla", "Charlotte", "Faith", "Alyssa"
};
Random random = new Random();
return femaleNames[random.nextInt(femaleNames.length)];
}
}
-116
View File
@@ -1,116 +0,0 @@
package engine.ZergMehcanics;
import engine.InterestManagement.WorldGrid;
import engine.gameManager.BuildingManager;
import engine.gameManager.ZergManager;
import engine.objects.*;
import engine.server.MBServerStatics;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
public class MineAntiZerg {
public static HashMap<Mine,HashMap<PlayerCharacter,Long>> leaveTimers = new HashMap<>();
public static HashMap<Mine,ArrayList<PlayerCharacter>> currentPlayers = new HashMap<>();
public static void runMines(){
for(Mine mine : Mine.getMines()){
Building tower = BuildingManager.getBuildingFromCache(mine.getBuildingID());
if(tower == null)
continue;
if(!mine.isActive)
continue;
logPlayersPresent(tower,mine);
auditPlayersPresent(tower,mine);
auditPlayers(mine);
}
}
public static void logPlayersPresent(Building tower, Mine mine){
HashSet<AbstractWorldObject> loadedPlayers = WorldGrid.getObjectsInRangePartial(tower.loc, MBServerStatics.CHARACTER_LOAD_RANGE * 3,MBServerStatics.MASK_PLAYER);
ArrayList<PlayerCharacter> playersPresent = new ArrayList<>();
for(AbstractWorldObject player : loadedPlayers){
playersPresent.add((PlayerCharacter)player);
}
currentPlayers.put(mine,playersPresent);
}
public static void auditPlayersPresent(Building tower, Mine mine){
HashSet<AbstractWorldObject> loadedPlayers = WorldGrid.getObjectsInRangePartial(tower.loc, MBServerStatics.CHARACTER_LOAD_RANGE * 3,MBServerStatics.MASK_PLAYER);
ArrayList<PlayerCharacter> toRemove = new ArrayList<>();
for(PlayerCharacter player : currentPlayers.get(mine)){
if(!loadedPlayers.contains(player)){
toRemove.add(player);
}
}
currentPlayers.get(mine).removeAll(toRemove);
for(PlayerCharacter player : toRemove){
if(leaveTimers.containsKey(mine)){
leaveTimers.get(mine).put(player,System.currentTimeMillis());
}else{
HashMap<PlayerCharacter,Long> leaveTime = new HashMap<>();
leaveTime.put(player,System.currentTimeMillis());
leaveTimers.put(mine,leaveTime);
}
}
toRemove.clear();
for(PlayerCharacter player : leaveTimers.get(mine).keySet()){
long timeGone = System.currentTimeMillis() - leaveTimers.get(mine).get(player);
if(timeGone > 180000L) {//3 minutes
toRemove.add(player);
player.ZergMultiplier = 1.0f;
}
}
for(PlayerCharacter player : toRemove) {
leaveTimers.get(mine).remove(player);
}
}
public static void auditPlayers(Mine mine){
HashMap<Guild,ArrayList<PlayerCharacter>> playersByNation = new HashMap<>();
for(PlayerCharacter player : currentPlayers.get(mine)){
if(playersByNation.containsKey(player.guild.getNation())){
playersByNation.get(player.guild.getNation()).add(player);
}else{
ArrayList<PlayerCharacter> players = new ArrayList<>();
players.add(player);
playersByNation.put(player.guild.getNation(),players);
}
}
for(PlayerCharacter player : leaveTimers.get(mine).keySet()){
if(playersByNation.containsKey(player.guild.getNation())){
playersByNation.get(player.guild.getNation()).add(player);
}else{
ArrayList<PlayerCharacter> players = new ArrayList<>();
players.add(player);
playersByNation.put(player.guild.getNation(),players);
}
}
for(Guild nation : playersByNation.keySet()){
for(PlayerCharacter player : playersByNation.get(nation)){
player.ZergMultiplier = ZergManager.getCurrentMultiplier(playersByNation.get(nation).size(), mine.capSize);
}
}
}
}
+4 -12
View File
@@ -13,8 +13,6 @@ import engine.Enum;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
import engine.gameManager.ConfigManager; import engine.gameManager.ConfigManager;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.net.DispatchMessage;
import engine.net.client.msg.chat.ChatSystemMsg;
import engine.objects.Account; import engine.objects.Account;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@@ -79,24 +77,18 @@ public class dbAccountHandler extends dbHandlerBase {
} }
} }
public void SET_TRASH(String machineID, String type) { public void SET_TRASH(String machineID) {
try (Connection connection = DbManager.getConnection(); try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement( PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO dyn_trash(`machineID`, `count`)"
"INSERT INTO dyn_trash(`machineID`, `count`, `type`)" + " VALUES (?, 1) ON DUPLICATE KEY UPDATE `count` = `count` + 1;")) {
+ " VALUES (?, 1, ?) ON DUPLICATE KEY UPDATE `count` = `count` + 1;")) {
preparedStatement.setString(1, machineID); preparedStatement.setString(1, machineID);
preparedStatement.setString(2, type);
preparedStatement.execute(); preparedStatement.execute();
} catch (SQLException e) { } catch (SQLException e) {
Logger.error(e); Logger.error(e);
} }
ChatSystemMsg chatMsg = new ChatSystemMsg(null, "Account: " + machineID + " has been kicked from game for cheating");
chatMsg.setMessageType(10);
chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID());
DispatchMessage.dispatchMsgToAll(chatMsg);
} }
public ArrayList<String> GET_TRASH_LIST() { public ArrayList<String> GET_TRASH_LIST() {
+8 -158
View File
@@ -10,13 +10,17 @@
package engine.db.handlers; package engine.db.handlers;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.gameManager.ZoneManager; import engine.objects.Bane;
import engine.math.Vector3fImmutable; import engine.objects.Building;
import engine.objects.*; import engine.objects.City;
import engine.objects.PlayerCharacter;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.sql.*; import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class dbBaneHandler extends dbHandlerBase { public class dbBaneHandler extends dbHandlerBase {
@@ -85,139 +89,6 @@ public class dbBaneHandler extends dbHandlerBase {
return true; return true;
} }
public boolean SET_BANE_TIME_NEW(int hour, int cityUUID) {
hour += 12; // Adjust hour
try (Connection connection = DbManager.getConnection();
PreparedStatement getStatement = connection.prepareStatement("SELECT `placementDate`, `liveDate` FROM `dyn_banes` WHERE `cityUUID`=?");
PreparedStatement updateStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `liveDate`=?, `time_set`=? WHERE `cityUUID`=?")) {
// Retrieve placementDate and liveDate
getStatement.setInt(1, cityUUID);
try (ResultSet rs = getStatement.executeQuery()) {
if (rs.next()) {
DateTime placementDate = new DateTime(rs.getTimestamp("placementDate").getTime());
Timestamp liveDateTimestamp = rs.getTimestamp("liveDate");
// Explicitly check if liveDate is null
DateTime toSet;
if (liveDateTimestamp == null) {
// If liveDate is null, default to placementDate
toSet = placementDate;
} else {
// If liveDate is not null, use it
DateTime liveDate = new DateTime(liveDateTimestamp.getTime());
toSet = liveDate;
}
// Adjust the time
toSet = toSet.withHourOfDay(hour).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0);
// Update liveDate and time_set flag
updateStatement.setTimestamp(1, new java.sql.Timestamp(toSet.getMillis()));
updateStatement.setInt(2, 1); // time_set flag
updateStatement.setInt(3, cityUUID);
updateStatement.execute();
return true;
}
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean SET_BANE_DAY_NEW(int dayOffset, int cityUUID) {
try (Connection connection = DbManager.getConnection();
PreparedStatement getStatement = connection.prepareStatement("SELECT `placementDate`, `liveDate` FROM `dyn_banes` WHERE `cityUUID`=?");
PreparedStatement updateStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `liveDate`=?, `day_set`=? WHERE `cityUUID`=?")) {
// Retrieve placementDate and liveDate
getStatement.setInt(1, cityUUID);
try (ResultSet rs = getStatement.executeQuery()) {
if (rs.next()) {
DateTime placementDate = new DateTime(rs.getTimestamp("placementDate").getTime());
Timestamp liveDateTimestamp = rs.getTimestamp("liveDate");
// Explicitly check if liveDate is null
DateTime liveDate;
if (liveDateTimestamp == null) {
// If liveDate is null, default to placementDate
liveDate = placementDate;
} else {
// If liveDate is not null, use it
liveDate = new DateTime(liveDateTimestamp.getTime());
}
// Calculate the new liveDate while preserving the time component
DateTime updatedDate = placementDate.plusDays(dayOffset)
.withHourOfDay(liveDate.getHourOfDay())
.withMinuteOfHour(liveDate.getMinuteOfHour())
.withSecondOfMinute(liveDate.getSecondOfMinute())
.withMillisOfSecond(liveDate.getMillisOfSecond());
// Update liveDate and day_set flag
updateStatement.setTimestamp(1, new java.sql.Timestamp(updatedDate.getMillis()));
updateStatement.setInt(2, 1); // day_set flag
updateStatement.setInt(3, cityUUID);
updateStatement.execute();
return true;
}
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean SET_BANE_CAP_NEW(int count, int cityUUID) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `cap_size`=? WHERE `cityUUID`=?")) {
preparedStatement.setInt(1, count);
preparedStatement.setLong(2, cityUUID);
preparedStatement.execute();
} catch (SQLException e) {
Logger.error(e);
return false;
}
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `cap_set`=? WHERE `cityUUID`=?")) {
preparedStatement.setInt(1, 1);
preparedStatement.setLong(2, cityUUID);
preparedStatement.execute();
} catch (SQLException e) {
Logger.error(e);
return false;
}
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `cap_size`=? WHERE `cityUUID`=?")) {
preparedStatement.setInt(1, count);
preparedStatement.setLong(2, cityUUID);
preparedStatement.execute();
} catch (SQLException e) {
Logger.error(e);
return false;
}
return true;
}
public boolean REMOVE_BANE(Bane bane) { public boolean REMOVE_BANE(Bane bane) {
if (bane == null) if (bane == null)
@@ -236,25 +107,4 @@ public class dbBaneHandler extends dbHandlerBase {
return true; return true;
} }
public DateTime getLiveDate(int cityUUID) {
try (Connection connection = DbManager.getConnection();
PreparedStatement statement = connection.prepareStatement("SELECT `liveDate` FROM `dyn_banes` WHERE `cityUUID`=?")) {
statement.setInt(1, cityUUID);
try (ResultSet rs = statement.executeQuery()) {
if (rs.next()) {
Timestamp liveDateTimestamp = rs.getTimestamp("liveDate");
if (liveDateTimestamp != null) {
return new DateTime(liveDateTimestamp.getTime());
}
}
}
} catch (SQLException e) {
Logger.error(e);
}
return null; // Return null if liveDate is not found or an error occurs
}
} }
+4 -10
View File
@@ -11,7 +11,10 @@ package engine.db.handlers;
import engine.Enum; import engine.Enum;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.objects.*; import engine.objects.AbstractGameObject;
import engine.objects.Building;
import engine.objects.City;
import engine.objects.Zone;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.sql.*; import java.sql.*;
@@ -92,16 +95,7 @@ public class dbCityHandler extends dbHandlerBase {
return objectList; return objectList;
} }
public Integer GET_CAPITAL_CITY_COUNT() {
int cityCount = 0;
for(Realm realm : Realm._realms.values()){
if(realm.isRuled())
cityCount ++;
}
return cityCount;
}
public ArrayList<City> GET_CITIES_BY_ZONE(final int objectUUID) { public ArrayList<City> GET_CITIES_BY_ZONE(final int objectUUID) {
ArrayList<City> cityList = new ArrayList<>(); ArrayList<City> cityList = new ArrayList<>();
@@ -98,7 +98,6 @@ public class dbContractHandler extends dbHandlerBase {
public void LOAD_SELL_LIST_FOR_CONTRACT(final Contract contract) { public void LOAD_SELL_LIST_FOR_CONTRACT(final Contract contract) {
if(!contract.getName().contains("Sage")) {
try (Connection connection = DbManager.getConnection(); try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_contract_selltype` WHERE `contractID` = ?;")) { PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_contract_selltype` WHERE `contractID` = ?;")) {
@@ -126,27 +125,6 @@ public class dbContractHandler extends dbHandlerBase {
} catch (SQLException e) { } catch (SQLException e) {
Logger.error(e); Logger.error(e);
} }
}else{
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_contract_selltype`;")) {
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
int value = rs.getInt("value");
if(!contract.getBuySkillToken().contains(value))
contract.getBuySkillToken().add(value);
if(!contract.getBuyItemType().contains(value))
contract.getBuyItemType().add(value);
if(!contract.getBuyUnknownToken().contains(value))
contract.getBuyUnknownToken().add(value);
}
} catch (SQLException e) {
Logger.error(e);
}
}
} }
public boolean updateAllowedBuildings(final Contract con, final long slotbitvalue) { public boolean updateAllowedBuildings(final Contract con, final long slotbitvalue) {
+1 -16
View File
@@ -32,6 +32,7 @@ public abstract class dbHandlerBase {
try { try {
if (rs.next()) { if (rs.next()) {
abstractGameObject = localClass.getConstructor(ResultSet.class).newInstance(rs); abstractGameObject = localClass.getConstructor(ResultSet.class).newInstance(rs);
DbManager.addToCache(abstractGameObject); DbManager.addToCache(abstractGameObject);
} }
} catch (Exception e) { } catch (Exception e) {
@@ -56,28 +57,12 @@ public abstract class dbHandlerBase {
while (rs.next()) { while (rs.next()) {
int id = rs.getInt(1); int id = rs.getInt(1);
try {
if (rs.getInt("capSize") == 0) {
continue;
}
}catch(Exception e){
//not a mine
}
if (DbManager.inCache(localObjectType, id)) { if (DbManager.inCache(localObjectType, id)) {
objectList.add((T) DbManager.getFromCache(localObjectType, id)); objectList.add((T) DbManager.getFromCache(localObjectType, id));
} else { } else {
try{
if(rs.getInt("mineLiveHour") == 1)
continue;
}catch(Exception e){
//not a mine
}
AbstractGameObject toAdd = localClass.getConstructor(ResultSet.class).newInstance(rs); AbstractGameObject toAdd = localClass.getConstructor(ResultSet.class).newInstance(rs);
DbManager.addToCache(toAdd); DbManager.addToCache(toAdd);
if(toAdd.getObjectType().equals(GameObjectType.Zone) && rs.getInt("canLoad") == 0){
continue;
}
objectList.add((T) toAdd); objectList.add((T) toAdd);
if (toAdd != null && toAdd instanceof AbstractWorldObject) if (toAdd != null && toAdd instanceof AbstractWorldObject)
@@ -22,7 +22,6 @@ import java.util.HashMap;
public class dbItemBaseHandler extends dbHandlerBase { public class dbItemBaseHandler extends dbHandlerBase {
public static final HashMap<Integer,Float> dexReductions = new HashMap<>();
public dbItemBaseHandler() { public dbItemBaseHandler() {
} }
@@ -46,14 +45,6 @@ public class dbItemBaseHandler extends dbHandlerBase {
} }
} }
public void LOAD_DEX_REDUCTION(ItemBase itemBase) {
if(dexReductions.containsKey(itemBase.getUUID())){
itemBase.dexReduction = dexReductions.get(itemBase.getUUID());
}else{
itemBase.dexReduction = 0.0f;
}
}
public void LOAD_ANIMATIONS(ItemBase itemBase) { public void LOAD_ANIMATIONS(ItemBase itemBase) {
ArrayList<Integer> tempList = new ArrayList<>(); ArrayList<Integer> tempList = new ArrayList<>();
@@ -103,21 +94,6 @@ public class dbItemBaseHandler extends dbHandlerBase {
} }
Logger.info("read: " + recordsRead + " cached: " + ItemBase.getUUIDCache().size()); Logger.info("read: " + recordsRead + " cached: " + ItemBase.getUUIDCache().size());
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_dexpenalty`")) {
ResultSet rs = preparedStatement.executeQuery();
// Check if a result was found
if (rs.next()) {
int ID = rs.getInt("ID");
float factor = rs.getInt("item_bulk_factor");
dexReductions.put(ID,factor);
}
} catch (SQLException e) {
Logger.error(e);
}
} }
public HashMap<Integer, ArrayList<Integer>> LOAD_RUNES_FOR_NPC_AND_MOBS() { public HashMap<Integer, ArrayList<Integer>> LOAD_RUNES_FOR_NPC_AND_MOBS() {
+2 -20
View File
@@ -134,13 +134,9 @@ public class dbItemHandler extends dbHandlerBase {
ResultSet rs = preparedStatement.executeQuery(); ResultSet rs = preparedStatement.executeQuery();
if (rs.next()) { if (rs.next())
try {
worked = rs.getBoolean("result"); worked = rs.getBoolean("result");
}catch(Exception e){
worked = false;
}
}
} catch (SQLException e) { } catch (SQLException e) {
Logger.error(e); Logger.error(e);
} }
@@ -500,18 +496,4 @@ public class dbItemHandler extends dbHandlerBase {
return false; return false;
} }
} }
public boolean UPDATE_NUM_ITEMS(final Item item, int newValue) {
if (item.getItemBase().getType().equals(ItemType.GOLD))
return false;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_numberOfItems`=? WHERE `UID`=?")) {
preparedStatement.setInt(1, newValue);
preparedStatement.setLong(2, item.getObjectUUID());
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
return false;
}
}
} }
+17 -22
View File
@@ -28,31 +28,26 @@ public class dbMobHandler extends dbHandlerBase {
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName()); this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
} }
public Mob ADD_MOB(Mob toAdd) { public Mob PERSIST(Mob toAdd) {
Mob mobile = null; Mob mobile = null;
try (Connection connection = DbManager.getConnection(); try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("CALL `mob_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) { PreparedStatement preparedStatement = connection.prepareStatement("CALL `mob_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) {
preparedStatement.setLong(1, toAdd.getParentZoneID()); preparedStatement.setLong(1, toAdd.parentZoneUUID);
preparedStatement.setInt(2, toAdd.getMobBaseID()); preparedStatement.setInt(2, toAdd.loadID);
preparedStatement.setInt(3, toAdd.getGuildUUID()); preparedStatement.setInt(3, toAdd.guildUUID);
preparedStatement.setFloat(4, toAdd.getSpawnX()); preparedStatement.setFloat(4, toAdd.bindLoc.x);
preparedStatement.setFloat(5, toAdd.getSpawnY()); preparedStatement.setFloat(5, toAdd.bindLoc.y);
preparedStatement.setFloat(6, toAdd.getSpawnZ()); preparedStatement.setFloat(6, toAdd.bindLoc.z);
preparedStatement.setInt(7, 0); preparedStatement.setInt(7, 0);
preparedStatement.setFloat(8, toAdd.getSpawnRadius()); preparedStatement.setFloat(8, toAdd.spawnRadius);
preparedStatement.setInt(9, toAdd.getTrueSpawnTime()); preparedStatement.setInt(9, toAdd.spawnTime);
preparedStatement.setInt(10, toAdd.contractUUID);
if (toAdd.getContract() != null) preparedStatement.setInt(11, toAdd.buildingUUID);
preparedStatement.setInt(10, toAdd.getContract().getContractID()); preparedStatement.setInt(12, toAdd.level);
else preparedStatement.setString(13, toAdd.firstName);
preparedStatement.setInt(10, 0);
preparedStatement.setInt(11, toAdd.getBuildingID());
preparedStatement.setInt(12, toAdd.getLevel());
preparedStatement.setString(13, toAdd.getFirstName());
ResultSet rs = preparedStatement.executeQuery(); ResultSet rs = preparedStatement.executeQuery();
@@ -106,17 +101,17 @@ public class dbMobHandler extends dbHandlerBase {
return row_count; return row_count;
} }
public void LOAD_PATROL_POINTS(Mob captain) { public void LOAD_GUARD_MINIONS(Mob guardCaptain) {
try (Connection connection = DbManager.getConnection(); try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_guards` WHERE `captainUID` = ?")) { PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_guards` WHERE `captainUID` = ?")) {
preparedStatement.setInt(1, captain.getObjectUUID()); preparedStatement.setInt(1, guardCaptain.getObjectUUID());
ResultSet rs = preparedStatement.executeQuery(); ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) { while (rs.next()) {
String name = rs.getString("name"); String minionName = rs.getString("name");
Mob toCreate = Mob.createGuardMob(captain, captain.getGuild(), captain.getParentZone(), captain.building.getLoc(), captain.getLevel(), name); Mob toCreate = Mob.createGuardMinion(guardCaptain, guardCaptain.getLevel(), minionName);
if (toCreate == null) if (toCreate == null)
return; return;
-38
View File
@@ -131,32 +131,6 @@ public class dbNPCHandler extends dbHandlerBase {
return npc; return npc;
} }
public int BANE_COMMANDER_EXISTS(final int objectUUID) {
int uid = 0;
String query = "SELECT `UID` FROM `obj_npc` WHERE `npc_buildingID` = ? LIMIT 1;";
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(query)) {
preparedStatement.setInt(1, objectUUID);
try (ResultSet rs = preparedStatement.executeQuery()) {
if (rs.next()) {
// Retrieve the UID column value
uid = rs.getInt("UID");
}
}
} catch (SQLException e) {
Logger.error(e);
}
return uid;
}
public int MOVE_NPC(long npcID, long parentID, float locX, float locY, float locZ) { public int MOVE_NPC(long npcID, long parentID, float locX, float locY, float locZ) {
int rowCount; int rowCount;
@@ -202,18 +176,6 @@ public class dbNPCHandler extends dbHandlerBase {
return result; return result;
} }
public static void updateSpecialPricing(final NPC npc){
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_npc SET specialPrice=? WHERE UID = ?")) {
preparedStatement.setInt(1, npc.getSpecialPrice());
preparedStatement.setInt(2, npc.getDBID());
preparedStatement.executeUpdate();
} catch (SQLException e) {
Logger.error(e);
}
}
public void updateDatabase(final NPC npc) { public void updateDatabase(final NPC npc) {
try (Connection connection = DbManager.getConnection(); try (Connection connection = DbManager.getConnection();
+2 -2
View File
@@ -43,7 +43,7 @@ public class AddMobCmd extends AbstractDevCmd {
MobBase mb = (MobBase) mobbaseAGO; MobBase mb = (MobBase) mobbaseAGO;
int loadID = mb.getObjectUUID(); int loadID = mb.getObjectUUID();
Mob mob = Mob.createMob(loadID, Vector3fImmutable.getRandomPointInCircle(pc.getLoc(), 100), Mob mob = Mob.createMob(loadID, Vector3fImmutable.getRandomPointInCircle(pc.getLoc(), 100),
null, true, zone, null, 0, "", 1); null, zone, null, null, "", 1);
if (mob != null) { if (mob != null) {
mob.updateDatabase(); mob.updateDatabase();
this.setResult(String.valueOf(mob.getDBID())); this.setResult(String.valueOf(mob.getDBID()));
@@ -84,7 +84,7 @@ public class AddMobCmd extends AbstractDevCmd {
Mob mob = Mob.createMob(loadID, pc.getLoc(), Mob mob = Mob.createMob(loadID, pc.getLoc(),
null, true, zone, null, 0, "", 1); null, zone, null, null, "", 1);
if (mob != null) { if (mob != null) {
mob.updateDatabase(); mob.updateDatabase();
ChatManager.chatSayInfo(pc, ChatManager.chatSayInfo(pc,
+25 -20
View File
@@ -13,7 +13,6 @@ import engine.Enum.GameObjectType;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.devcmd.AbstractDevCmd; import engine.devcmd.AbstractDevCmd;
import engine.gameManager.*; import engine.gameManager.*;
import engine.math.Vector3fImmutable;
import engine.objects.*; import engine.objects.*;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@@ -32,6 +31,7 @@ public class AddNPCCmd extends AbstractDevCmd {
int contractID; int contractID;
String name = ""; String name = "";
int level = 0; int level = 0;
if (words.length < 2) { if (words.length < 2) {
this.sendUsage(pc); this.sendUsage(pc);
return; return;
@@ -39,54 +39,59 @@ public class AddNPCCmd extends AbstractDevCmd {
try { try {
contractID = Integer.parseInt(words[0]); contractID = Integer.parseInt(words[0]);
level = Integer.parseInt(words[1]); level = Integer.parseInt(words[1]);
for (int i = 2; i < words.length; i++) { for (int i = 2; i < words.length; i++) {
name += words[i]; name += words[i];
if (i + 1 < words.length) if (i + 1 < words.length)
name += ""; name += "";
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throwbackError(pc, throwbackError(pc,
"Failed to parse supplied contractID or level to an Integer."); "Failed to parse supplied contractID or level to an Integer.");
return; // NaN return; // NaN
} }
Contract contract = DbManager.ContractQueries.GET_CONTRACT(contractID); Contract contract = DbManager.ContractQueries.GET_CONTRACT(contractID);
if (contract == null || level < 1 || level > 75) { if (contract == null || level < 1 || level > 75) {
throwbackError(pc, throwbackError(pc,
"Invalid addNPC Command. Need contract ID, and level"); "Invalid addNPC Command. Need contract ID, and level");
return; // NaN return; // NaN
} }
// Pick a random name // Pick a random name
if (name.isEmpty()) if (name.isEmpty())
name = NPCManager.getPirateName(contract.getMobbaseID()); name = NPCManager.getPirateName(contract.getMobbaseID());
Zone zone = ZoneManager.findSmallestZone(pc.getLoc()); Zone zone = ZoneManager.findSmallestZone(pc.getLoc());
if (zone == null) { if (zone == null) {
throwbackError(pc, "Failed to find zone to place npc in."); throwbackError(pc, "Failed to find zone to place npc in.");
return; return;
} }
Building building = null;
if (target != null) if (target != null)
if (target.getObjectType() == GameObjectType.Building) { if (target.getObjectType() == GameObjectType.Building) {
building = (Building)target; Building parentBuilding = (Building) target;
BuildingManager.addHirelingForWorld(parentBuilding, pc, parentBuilding.getLoc(), parentBuilding.getParentZone(), contract, level);
return;
} }
NPC created;
Guild guild = null; NPC npc = NPC.createNPC(name, contractID,
Vector3fImmutable loc; pc.getLoc(), null, zone, (short) level, null);
if(building != null){
guild = building.getGuild(); if (npc != null) {
loc = building.loc; WorldGrid.addObject(npc, pc);
ChatManager.chatSayInfo(pc,
"NPC with ID " + npc.getDBID() + " added");
this.setResult(String.valueOf(npc.getDBID()));
} else { } else {
loc = pc.loc; throwbackError(pc, "Failed to create npc of contract type "
+ contractID);
Logger.error(
"Failed to create npc of contract type " + contractID);
} }
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 @Override
-63
View File
@@ -1,63 +0,0 @@
// ·. · · · · .
// · ·
// · ·
//
// · · ·
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.ItemContainerType;
import engine.Enum.ItemType;
import engine.Enum.OwnerType;
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.ChatManager;
import engine.gameManager.DbManager;
import engine.objects.*;
import engine.powers.EffectsBase;
import java.util.ArrayList;
/**
* @author Eighty
*/
public class GimmeCmd extends AbstractDevCmd {
public GimmeCmd() {
super("gimme");
}
@Override
protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) {
int amt = 0;
int currentGold = pc.getCharItemManager().getGoldInventory().getNumOfItems();
amt = 10000000 - currentGold;
if (!pc.getCharItemManager().addGoldToInventory(amt, true)) {
throwbackError(pc, "Failed to add gold to inventory");
return;
}
ChatManager.chatSayInfo(pc, amt + " gold added to inventory");
if(pc.level < 75) {
pc.setLevel((short) 75);
ChatManager.chatSayInfo(pc, "Level set to 75");
}
pc.getCharItemManager().updateInventory();
}
@Override
protected String _getHelpString() {
return "Round up current gold in inventory to 10,000,000";
}
@Override
protected String _getUsageString() {
return "'./gimme";
}
}
+77
View File
@@ -0,0 +1,77 @@
// ·. · · · · .
// · ·
// · ·
//
// · · ·
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.ZoneManager;
import engine.objects.AbstractGameObject;
import engine.objects.PlayerCharacter;
/**
* ./hotzone <- display the current hotzone & time remaining
* ./hotzone random <- change hotzone to random new zone
*/
public class HotzoneCmd extends AbstractDevCmd {
public HotzoneCmd() {
super("hotzone");
}
@Override
protected void _doCmd(PlayerCharacter playerCharacter, String[] words,
AbstractGameObject target) {
StringBuilder data = new StringBuilder();
String outString;
for (String s : words) {
data.append(s);
data.append(' ');
}
String input = data.toString().trim();
if (input.length() == 0) {
outString = "Current hotZone: " + ZoneManager.hotZone.getName() + "\r\n";
outString += "Available hotZones: " + ZoneManager.availableHotZones();
throwbackInfo(playerCharacter, outString);
return;
}
if (input.equalsIgnoreCase("random")) {
ZoneManager.generateAndSetRandomHotzone();
outString = "New hotZone: " + ZoneManager.hotZone.getName() + "\r\n";
outString += "Available hotZones: " + ZoneManager.availableHotZones();
throwbackInfo(playerCharacter, outString);
return;
}
if (input.equalsIgnoreCase("reset")) {
ZoneManager.resetHotZones();
throwbackInfo(playerCharacter, "Available hotZones: " + ZoneManager.availableHotZones());
return;
}
return;
}
@Override
protected String _getHelpString() {
return "Use no arguments to see the current hotzone or \"random\" to change it randomly.";
}
@Override
protected String _getUsageString() {
return "'./hotzone [random]";
}
}
+12 -29
View File
@@ -15,13 +15,9 @@ import engine.Enum.GameObjectType;
import engine.Enum.TargetColor; import engine.Enum.TargetColor;
import engine.devcmd.AbstractDevCmd; import engine.devcmd.AbstractDevCmd;
import engine.gameManager.BuildingManager; import engine.gameManager.BuildingManager;
import engine.gameManager.PowersManager;
import engine.gameManager.SessionManager; import engine.gameManager.SessionManager;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.objects.*; import engine.objects.*;
import engine.powers.EffectsBase;
import engine.powers.PowersBase;
import engine.server.MBServerStatics;
import engine.util.StringUtils; import engine.util.StringUtils;
import java.text.DecimalFormat; import java.text.DecimalFormat;
@@ -335,18 +331,13 @@ public class InfoCmd extends AbstractDevCmd {
output += "Movement State: " + targetPC.getMovementState().name(); output += "Movement State: " + targetPC.getMovementState().name();
output += newline; output += newline;
output += "Movement Speed: " + targetPC.getSpeed(); output += "Movement Speed: " + targetPC.getSpeed();
output += newline;
output += "Altitude : " + targetPC.getLoc().y; output += "Altitude : " + targetPC.getLoc().y;
output += newline;
output += "Swimming : " + targetPC.isSwimming(); output += "Swimming : " + targetPC.isSwimming();
output += newline; output += newline;
output += "isMoving : " + targetPC.isMoving(); output += "isMoving : " + targetPC.isMoving();
output += newline;
output += "Zerg Multiplier : " + targetPC.ZergMultiplier + newline;
output += "Hidden : " + targetPC.getHidden() + newline;
output += "Target Loc: " + targetPC.loc + newline;
output += "Player Loc: " + pc.loc + newline;
output += "Distance Squared: " + pc.loc.distanceSquared(targetPC.loc);
break; break;
case NPC: case NPC:
@@ -449,7 +440,9 @@ public class InfoCmd extends AbstractDevCmd {
output += "isSummonedPet: true"; output += "isSummonedPet: true";
else else
output += "isSummonedPet: false"; output += "isSummonedPet: false";
PlayerCharacter owner = targetMob.getOwner();
PlayerCharacter owner = (PlayerCharacter) targetMob.guardCaptain;
if (owner != null) if (owner != null)
output += " owner: " + owner.getObjectUUID(); output += " owner: " + owner.getObjectUUID();
output += newline; output += newline;
@@ -501,16 +494,13 @@ public class InfoCmd extends AbstractDevCmd {
output += newline; output += newline;
output += "No building found." + newline; output += "No building found." + newline;
} }
int max = (int)(4.882 * targetMob.level + 121.0);
output += "Damage: " + targetMob.mobBase.getDamageMin() + " - " + targetMob.mobBase.getDamageMax() + newline; if(max > 321){
output += "ATR: " + targetMob.mobBase.getAttackRating() + newline; max = 321;
output += "DEF: " + targetMob.defenseRating + newline;
output += "RANGE: " + targetMob.getRange() + newline;
output += "Effects:" + newline;
for(MobBaseEffects mbe : targetMob.mobBase.mobbaseEffects){
EffectsBase eb = PowersManager.getEffectByToken(mbe.getToken());
output += eb.getName() + newline;
} }
int min = (int)(4.469 * targetMob.level - 3.469);
output += "Min Loot Roll = " + min;
output += "Max Loot Roll = " + max;
break; break;
case Item: //intentional passthrough case Item: //intentional passthrough
case MobLoot: case MobLoot:
@@ -541,13 +531,6 @@ public class InfoCmd extends AbstractDevCmd {
} }
break; break;
case Corpse:
Corpse corpse = (Corpse)target;
Long timeLeft = MBServerStatics.CORPSE_CLEANUP_TIMER_MS - (System.currentTimeMillis() - corpse.spawnedTime);
output += "Despawn in: " + timeLeft;
output += newline;
break;
} }
throwbackInfo(pc, output); throwbackInfo(pc, output);
+2 -3
View File
@@ -16,7 +16,6 @@ import engine.objects.AbstractGameObject;
import engine.objects.Building; import engine.objects.Building;
import engine.objects.Mine; import engine.objects.Mine;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
import engine.workthreads.HalfHourlyJobThread;
import engine.workthreads.HourlyJobThread; import engine.workthreads.HourlyJobThread;
/** /**
@@ -42,10 +41,10 @@ public class MineActiveCmd extends AbstractDevCmd {
String trigger = args[0]; String trigger = args[0];
switch (trigger) { switch (trigger) {
case "true": case "true":
HalfHourlyJobThread.mineWindowOpen(mine); HourlyJobThread.mineWindowOpen(mine);
break; break;
case "false": case "false":
HalfHourlyJobThread.mineWindowClose(mine); HourlyJobThread.mineWindowClose(mine);
break; break;
default: default:
this.sendUsage(pcSender); this.sendUsage(pcSender);
@@ -49,8 +49,6 @@ public class PrintSkillsCmd extends AbstractDevCmd {
+ skill.getModifiedAmount() + '(' + skill.getModifiedAmount() + '('
+ skill.getTotalSkillPercet() + " )"); + skill.getTotalSkillPercet() + " )");
} }
//throwbackInfo(pc, "= = = = = NEW CALCULATIONS = = = = =");
// PlayerCombatStats.PrintSkillsToClient(pc);
} else } else
throwbackInfo(pc, "Skills not found for player"); throwbackInfo(pc, "Skills not found for player");
} }
+17 -38
View File
@@ -9,9 +9,7 @@
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.Enum;
import engine.devcmd.AbstractDevCmd; import engine.devcmd.AbstractDevCmd;
import engine.gameManager.PowersManager;
import engine.objects.*; import engine.objects.*;
import java.util.HashMap; import java.util.HashMap;
@@ -58,42 +56,23 @@ public class PrintStatsCmd extends AbstractDevCmd {
public void printStatsPlayer(PlayerCharacter pc, PlayerCharacter tar) { public void printStatsPlayer(PlayerCharacter pc, PlayerCharacter tar) {
String newline = "\r\n "; String newline = "\r\n ";
String out = "Server stats for Player " + tar.getFirstName() + newline;
String newOut = "Server stats for Player " + tar.getFirstName() + newline; out += "Unused Stats: " + tar.getUnusedStatPoints() + newline;
newOut += "HEALTH: " + tar.getHealth() + " / " + tar.getHealthMax() + newline; out += "Stats Base (Modified)" + newline;
newOut += "MANA: " + tar.getMana() + " / " + tar.getManaMax() + newline; out += " Str: " + (int) tar.statStrBase + " (" + tar.getStatStrCurrent() + ')' + ", maxStr: " + tar.getStrMax() + newline;
newOut += "STAMINA: " + tar.getStamina() + " / " + tar.getStaminaMax() + newline; out += " Dex: " + (int) tar.statDexBase + " (" + tar.getStatDexCurrent() + ')' + ", maxDex: " + tar.getDexMax() + newline;
newOut += "Unused Stats: " + tar.getUnusedStatPoints() + newline; out += " Con: " + (int) tar.statConBase + " (" + tar.getStatConCurrent() + ')' + ", maxCon: " + tar.getConMax() + newline;
newOut += "Stats Base (Modified)" + newline; out += " Int: " + (int) tar.statIntBase + " (" + tar.getStatIntCurrent() + ')' + ", maxInt: " + tar.getIntMax() + newline;
newOut += " Str: " + (int) tar.statStrBase + " (" + tar.getStatStrCurrent() + ')' + ", maxStr: " + tar.getStrMax() + newline; out += " Spi: " + (int) tar.statSpiBase + " (" + tar.getStatSpiCurrent() + ')' + ", maxSpi: " + tar.getSpiMax() + newline;
newOut += " Dex: " + (int) tar.statDexBase + " (" + tar.getStatDexCurrent() + ')' + ", maxDex: " + tar.getDexMax() + newline; throwbackInfo(pc, out);
newOut += " Con: " + (int) tar.statConBase + " (" + tar.getStatConCurrent() + ')' + ", maxCon: " + tar.getConMax() + newline; out = "Health: " + tar.getHealth() + ", maxHealth: " + tar.getHealthMax() + newline;
newOut += " Int: " + (int) tar.statIntBase + " (" + tar.getStatIntCurrent() + ')' + ", maxInt: " + tar.getIntMax() + newline; out += "Mana: " + tar.getMana() + ", maxMana: " + tar.getManaMax() + newline;
newOut += " Spi: " + (int) tar.statSpiBase + " (" + tar.getStatSpiCurrent() + ')' + ", maxSpi: " + tar.getSpiMax() + newline; out += "Stamina: " + tar.getStamina() + ", maxStamina: " + tar.getStaminaMax() + newline;
newOut += "Move Speed: " + tar.getSpeed() + newline; out += "Defense: " + tar.getDefenseRating() + newline;
newOut += "Health Regen: " + tar.combatStats.healthRegen + newline; out += "Main Hand: atr: " + tar.getAtrHandOne() + ", damage: " + tar.getMinDamageHandOne() + " to " + tar.getMaxDamageHandOne() + ", speed: " + tar.getSpeedHandOne() + newline;
newOut += "Mana Regen: " + tar.combatStats.manaRegen + newline; out += "Off Hand: atr: " + tar.getAtrHandTwo() + ", damage: " + tar.getMinDamageHandTwo() + " to " + tar.getMaxDamageHandTwo() + ", speed: " + tar.getSpeedHandTwo() + newline;
newOut += "Stamina Regen: " + tar.combatStats.staminaRegen + newline; out += "isAlive: " + tar.isAlive() + ", Combat: " + tar.isCombat() + newline;
newOut += "DEFENSE: " + tar.combatStats.defense + newline; throwbackInfo(pc, out);
newOut += "HAND ONE" + newline;
newOut += "ATR: " + tar.combatStats.atrHandOne + newline;
newOut += "MIN: " + tar.combatStats.minDamageHandOne + newline;
newOut += "MAX: " + tar.combatStats.maxDamageHandOne + newline;
newOut += "RANGE: " + tar.combatStats.rangeHandOne + newline;
newOut += "ATTACK SPEED: " + tar.combatStats.attackSpeedHandOne + newline;
newOut += "HAND TWO" + newline;
newOut += "ATR: " + tar.combatStats.atrHandTwo + newline;
newOut += "MIN: " + tar.combatStats.minDamageHandTwo + newline;
newOut += "MAX: " + tar.combatStats.maxDamageHandTwo + newline;
newOut += "RANGE: " + tar.combatStats.rangeHandTwo + newline;
newOut += "ATTACK SPEED: " + tar.combatStats.attackSpeedHandTwo + newline;
newOut += "=== POWERS ===" + newline;
for(CharacterPower power : pc.getPowers().values()){
if(power.getPower().requiresHitRoll) {
newOut += power.getPower().name + " ATR: " + Math.round(PlayerCombatStats.getSpellAtr(pc,power.getPower())) + newline;
}
}
throwbackInfo(pc, newOut);
} }
public void printStatsMob(PlayerCharacter pc, Mob tar) { public void printStatsMob(PlayerCharacter pc, Mob tar) {
+2 -2
View File
@@ -59,7 +59,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
if (npc != null) { if (npc != null) {
for (Mob mob : npc.getSiegeMinionMap().keySet()) { for (Mob mob : npc.siegeMinionMap.keySet()) {
WorldGrid.RemoveWorldObject(mob); WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc); WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob); //Mob.getRespawnMap().remove(mob);
@@ -151,7 +151,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
if (npc != null) { if (npc != null) {
for (Mob mob : npc.getSiegeMinionMap().keySet()) { for (Mob mob : npc.siegeMinionMap.keySet()) {
WorldGrid.RemoveWorldObject(mob); WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc); WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob); //Mob.getRespawnMap().remove(mob);
+8 -25
View File
@@ -1,12 +1,8 @@
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.Enum;
import engine.InterestManagement.WorldGrid;
import engine.PlayerAi;
import engine.devcmd.AbstractDevCmd; import engine.devcmd.AbstractDevCmd;
import engine.math.Vector3fImmutable; import engine.objects.AbstractGameObject;
import engine.objects.*; import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
/** /**
@@ -28,25 +24,12 @@ public class RebootCmd extends AbstractDevCmd {
protected void _doCmd(PlayerCharacter pc, String[] args, protected void _doCmd(PlayerCharacter pc, String[] args,
AbstractGameObject target) { AbstractGameObject target) {
//try { try {
// Runtime rt = Runtime.getRuntime(); Runtime rt = Runtime.getRuntime();
// rt.exec("./mbrestart.sh"); rt.exec("./mbrestart.sh");
//} catch (java.io.IOException err) { } catch (java.io.IOException err) {
// Logger.info(err.getMessage()); Logger.info(err.getMessage());
//} }
PlayerCharacter newPLayer = new PlayerCharacter("AiPlayer", "AI POWERED", (short) 5, (short) 5, (short) 5, (short) 5,
(short) 5, Guild.getErrantGuild(), (byte) 0, (Account) null, Race.getRace(1999), BaseClass.getBaseClass(2500)
, (byte) 1, (byte) 1,
(byte) 1, (byte) 1, (byte) 1);
newPLayer.runAfterLoad();
newPLayer.setLoc(pc.loc);
newPLayer.setObjectTypeMask(MBServerStatics.MASK_PLAYER);
WorldGrid.addObject(newPLayer,pc.loc.x,pc.loc.z);
//WorldGrid.updateObject(newPLayer);
PlayerAi.addPlayer(newPLayer);
} }
+2 -2
View File
@@ -154,7 +154,7 @@ public class RemoveObjectCmd extends AbstractDevCmd {
mobA = (Mob) ac; mobA = (Mob) ac;
if (npc != null) { if (npc != null) {
for (Mob mob : npc.getSiegeMinionMap().keySet()) { for (Mob mob : npc.siegeMinionMap.keySet()) {
WorldGrid.RemoveWorldObject(mob); WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc); WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob); //Mob.getRespawnMap().remove(mob);
@@ -209,7 +209,7 @@ public class RemoveObjectCmd extends AbstractDevCmd {
if (npc.building != null) if (npc.building != null)
npc.building.getHirelings().remove(npc); npc.building.getHirelings().remove(npc);
for (Mob mob : npc.getSiegeMinionMap().keySet()) { for (Mob mob : npc.siegeMinionMap.keySet()) {
WorldGrid.RemoveWorldObject(mob); WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc); WorldGrid.removeObject(mob, pc);
if (mob.getParentZone() != null) if (mob.getParentZone() != null)
+2 -2
View File
@@ -46,7 +46,7 @@ public class SetLevelCmd extends AbstractDevCmd {
this.sendUsage(pc); this.sendUsage(pc);
return; return;
} }
if (level < 1 || level > 80) { if (level < 1 || level > 75) {
this.sendHelp(pc); this.sendHelp(pc);
return; return;
} }
@@ -62,7 +62,7 @@ public class SetLevelCmd extends AbstractDevCmd {
@Override @Override
protected String _getHelpString() { protected String _getHelpString() {
return "Sets your character's level to 'amount'. 'amount' must be between 1-80"; return "Sets your character's level to 'amount'. 'amount' must be between 1-75";
} }
@Override @Override
+2 -70
View File
@@ -1,6 +1,5 @@
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.Enum;
import engine.devcmd.AbstractDevCmd; import engine.devcmd.AbstractDevCmd;
import engine.gameManager.LootManager; import engine.gameManager.LootManager;
import engine.gameManager.ZoneManager; import engine.gameManager.ZoneManager;
@@ -11,8 +10,6 @@ import java.util.ArrayList;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
public class SimulateBootyCmd extends AbstractDevCmd { public class SimulateBootyCmd extends AbstractDevCmd {
public int simCount = 250;
public SimulateBootyCmd() { public SimulateBootyCmd() {
super("bootysim"); super("bootysim");
} }
@@ -27,61 +24,8 @@ public class SimulateBootyCmd extends AbstractDevCmd {
String newline = "\r\n "; String newline = "\r\n ";
String output; String output;
if(target.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){
int ATR = Integer.parseInt(words[0]);
int DEF = Integer.parseInt(words[1]);
int attacks = Integer.parseInt(words[2]);
int hits = 0; output = "Booty Simulation:" + newline;
int misses = 0;
int defaultHits = 0;
int defualtMisses = 0;
float chance = (ATR-((ATR+DEF) * 0.315f)) / ((DEF-((ATR+DEF) * 0.315f)) + (ATR-((ATR+DEF) * 0.315f)));
float convertedChance = chance * 100;
output = "" + newline;
output += "DEF VS ATR SIMULATION: " + attacks + " ATTACKS SIMULATED" + newline;
output += "DEF = " + DEF + newline;
output += "ATR = " + ATR + newline;
output += "CHANCE TO LAND HIT: " + convertedChance + "%" + newline;
if(convertedChance < 5){
output += "CHANCE ADJUSTED TO 5.0%" + newline;
convertedChance = 5.0f;
}
if(convertedChance > 95){
output += "CHANCE ADJUSTED TO 95.0%" + newline;
convertedChance = 95.0f;
}
for(int i = 0; i < attacks; i++){
int roll = ThreadLocalRandom.current().nextInt(101);
if(roll <= convertedChance){
hits += 1;
}else{
misses += 1;
}
}
float totalHits = defaultHits + hits;
float totalMisses = defualtMisses + misses;
float hitPercent = Math.round(totalHits / attacks * 100);
float missPercent = Math.round(totalMisses / attacks * 100);
output += "HITS LANDED: " + (defaultHits + hits) + "(" + Math.round(hitPercent) + "%)" + newline;
output += "HITS MISSED: " + (defualtMisses + misses) + "(" + Math.round(missPercent) + "%)";
throwbackInfo(playerCharacter,output);
return;
}
try
{
simCount = Integer.parseInt(words[0]);
}catch(Exception e)
{
}
output = "Booty Simulation: Rolls:" + simCount + newline;
Mob mob = (Mob) target; Mob mob = (Mob) target;
output += "Name: " + mob.getName() + newline; output += "Name: " + mob.getName() + newline;
@@ -100,7 +44,6 @@ public class SimulateBootyCmd extends AbstractDevCmd {
ArrayList<Item> Resources = new ArrayList<Item>(); ArrayList<Item> Resources = new ArrayList<Item>();
ArrayList<Item> Runes = new ArrayList<Item>(); ArrayList<Item> Runes = new ArrayList<Item>();
ArrayList<Item> Contracts = new ArrayList<Item>(); ArrayList<Item> Contracts = new ArrayList<Item>();
ArrayList<Item> GuardContracts = new ArrayList<Item>();
ArrayList<Item> Offerings = new ArrayList<Item>(); ArrayList<Item> Offerings = new ArrayList<Item>();
ArrayList<Item> OtherDrops = new ArrayList<Item>(); ArrayList<Item> OtherDrops = new ArrayList<Item>();
ArrayList<Item> EquipmentDrops = new ArrayList<Item>(); ArrayList<Item> EquipmentDrops = new ArrayList<Item>();
@@ -108,16 +51,13 @@ public class SimulateBootyCmd extends AbstractDevCmd {
int failures = 0; int failures = 0;
int goldAmount = 0; int goldAmount = 0;
for (int i = 0; i < simCount; ++i) { for (int i = 0; i < 100; ++i) {
try { try {
mob.loadInventory(); mob.loadInventory();
for (Item lootItem : mob.getCharItemManager().getInventory()) { for (Item lootItem : mob.getCharItemManager().getInventory()) {
switch (lootItem.getItemBase().getType()) { switch (lootItem.getItemBase().getType()) {
case CONTRACT: //CONTRACT case CONTRACT: //CONTRACT
if(lootItem.getName().contains("Captain"))
GuardContracts.add(lootItem);
else
Contracts.add(lootItem); Contracts.add(lootItem);
break; break;
case OFFERING: //OFFERING case OFFERING: //OFFERING
@@ -190,17 +130,9 @@ public class SimulateBootyCmd extends AbstractDevCmd {
} }
} }
int baseBound = 100000;
int levelPenalty = (int) (Math.max(0, Math.abs(50 - mob.level)) * 0.01 * 100000);
int totalRange = baseBound + levelPenalty;
if(mob.level >= 50){
totalRange = baseBound;
}
output += "TOTAL ROLL POTENTIAL: " + totalRange + newline;
output += "GLASS DROPS: " + GlassItems.size() + newline; output += "GLASS DROPS: " + GlassItems.size() + newline;
output += "RUNE DROPS: " + Runes.size() + newline; output += "RUNE DROPS: " + Runes.size() + newline;
output += "CONTRACTS DROPS: " + Contracts.size() + newline; output += "CONTRACTS DROPS: " + Contracts.size() + newline;
output += "GUARD CONTRACTS DROPS: " + GuardContracts.size() + newline;
output += "RESOURCE DROPS: " + Resources.size() + newline; output += "RESOURCE DROPS: " + Resources.size() + newline;
output += "OFFERINGS DROPPED: " + Offerings.size() + newline; output += "OFFERINGS DROPPED: " + Offerings.size() + newline;
output += "ENCHANTED ITEMS DROPPED: " + OtherDrops.size() + newline; output += "ENCHANTED ITEMS DROPPED: " + OtherDrops.size() + newline;
+1 -1
View File
@@ -110,7 +110,7 @@ public class SplatMobCmd extends AbstractDevCmd {
mobile = Mob.createMob(_mobileUUID, mobile = Mob.createMob(_mobileUUID,
Vector3fImmutable.getRandomPointInCircle(_currentLocation, _targetRange), Vector3fImmutable.getRandomPointInCircle(_currentLocation, _targetRange),
null, true, serverZone, null, 0, "", 1); null, serverZone, null, null, "", 1);
if (mobile != null) { if (mobile != null) {
mobile.updateDatabase(); mobile.updateDatabase();
+18 -12
View File
@@ -11,6 +11,7 @@ package engine.devcmd.cmds;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
import engine.devcmd.AbstractDevCmd; import engine.devcmd.AbstractDevCmd;
import engine.gameManager.PowersManager;
import engine.objects.AbstractGameObject; import engine.objects.AbstractGameObject;
import engine.objects.Mob; import engine.objects.Mob;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
@@ -56,18 +57,18 @@ public class aiInfoCmd extends AbstractDevCmd {
Mob mob = (Mob) target; Mob mob = (Mob) target;
output = "Mob AI Information:" + newline; output = "Mob AI Information:" + newline;
output += mob.getName() + newline; output += mob.getName() + newline;
if (mob.BehaviourType != null) { if (mob.behaviourType != null) {
output += "BehaviourType: " + mob.BehaviourType.toString() + newline; output += "BehaviourType: " + mob.behaviourType.toString() + newline;
if (mob.BehaviourType.BehaviourHelperType != null) { if (mob.behaviourType.BehaviourHelperType != null) {
output += "Behaviour Helper Type: " + mob.BehaviourType.BehaviourHelperType.toString() + newline; output += "Behaviour Helper Type: " + mob.behaviourType.BehaviourHelperType.toString() + newline;
} else { } else {
output += "Behaviour Helper Type: NULL" + newline; output += "Behaviour Helper Type: NULL" + newline;
} }
output += "Wimpy: " + mob.BehaviourType.isWimpy + newline; output += "Wimpy: " + mob.behaviourType.isWimpy + newline;
output += "Agressive: " + mob.BehaviourType.isAgressive + newline; output += "Agressive: " + mob.behaviourType.isAgressive + newline;
output += "Can Roam: " + mob.BehaviourType.canRoam + newline; output += "Can Roam: " + mob.behaviourType.canRoam + newline;
output += "Calls For Help: " + mob.BehaviourType.callsForHelp + newline; output += "Calls For Help: " + mob.behaviourType.callsForHelp + newline;
output += "Responds To Call For Help: " + mob.BehaviourType.respondsToCallForHelp + newline; output += "Responds To Call For Help: " + mob.behaviourType.respondsToCallForHelp + newline;
} else { } else {
output += "BehaviourType: NULL" + newline; output += "BehaviourType: NULL" + newline;
} }
@@ -76,16 +77,21 @@ public class aiInfoCmd extends AbstractDevCmd {
if (mob.playerAgroMap.size() > 0) { if (mob.playerAgroMap.size() > 0) {
output += "Players Loaded:" + newline; output += "Players Loaded:" + newline;
} }
for (Map.Entry<Integer, Boolean> entry : mob.playerAgroMap.entrySet()) { for (Map.Entry<Integer, Float> entry : mob.playerAgroMap.entrySet()) {
output += "Player ID: " + entry.getKey() + " Hate Value: " + (PlayerCharacter.getPlayerCharacter(entry.getKey())).getHateValue() + newline; output += "Player ID: " + entry.getKey() + " Hate Value: " + entry.getValue() + newline;
} }
if (mob.getCombatTarget() != null) if (mob.getCombatTarget() != null)
output += "Current Target: " + mob.getCombatTarget().getName() + newline; output += "Current Target: " + mob.getCombatTarget().getName() + newline;
else else
output += "Current Target: NULL" + newline; output += "Current Target: NULL" + newline;
if (mob.guardedCity != null)
output += "Patrolling: " + mob.guardedCity.getCityName() + newline;
output += "Powers:" + newline;
for (int token : mob.mobPowers.keySet()) for (int token : mob.mobPowers.keySet())
output += token + newline; output += PowersManager.getPowerByToken(token).getName() + newline;
throwbackInfo(playerCharacter, output); throwbackInfo(playerCharacter, output);
} }
-168
View File
@@ -1,168 +0,0 @@
package engine.gameManager;
import engine.Enum;
import engine.InterestManagement.WorldGrid;
import engine.exception.MsgSendException;
import engine.math.Vector3f;
import engine.math.Vector3fImmutable;
import engine.objects.*;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
public class ArenaManager {
private static final List<Arena> activeArenas = new ArrayList<>();
public static final List<PlayerCharacter> playerQueue = new ArrayList<>();
public static Long pulseDelay = 180000L;
public static Long lastExecution = 0L;
public static void pulseArenas() {
if(lastExecution == 0L){
lastExecution = System.currentTimeMillis();
}
if(activeArenas.isEmpty() && playerQueue.isEmpty())
return;
Iterator<Arena> iterator = activeArenas.iterator();
while (iterator.hasNext()) {
Arena arena = iterator.next();
if (arena.checkToComplete()) {
iterator.remove();
}
}
if(lastExecution + pulseDelay > System.currentTimeMillis())
return;
lastExecution = System.currentTimeMillis();
while (playerQueue.size() > 1) {
createArena();
}
}
public static void joinQueue(PlayerCharacter player) {
if (!playerQueue.contains(player)) {
playerQueue.add(player);
}
for(PlayerCharacter pc : playerQueue){
if(pc.equals(player))
continue;
ChatManager.chatSystemInfo(pc, player.getName() + " has joined the arena que. There are now " + playerQueue.size() + " players queued.");
}
}
public static void leaveQueue(PlayerCharacter player) {
playerQueue.remove(player);
for(PlayerCharacter pc : playerQueue){
if(pc.equals(player))
continue;
ChatManager.chatSystemInfo(pc, player.getName() + " has left the arena que. There are now " + playerQueue.size() + " players queued.");
}
}
private static void createArena() {
if (playerQueue.size() > 1) {
Collections.shuffle(playerQueue);
Arena newArena = new Arena();
//set starting time
newArena.startTime = System.currentTimeMillis();
//decide an arena location
newArena.loc = selectRandomArenaLocation();
// Assign players to the arena
newArena.player1 = playerQueue.remove(0);
newArena.player2 = playerQueue.remove(0);
// Teleport players to the arena location
Zone sdr = ZoneManager.getZoneByUUID(656);
MovementManager.translocate(newArena.player1, Vector3fImmutable.getRandomPointOnCircle(newArena.loc,75f), null);
MovementManager.translocate(newArena.player2, Vector3fImmutable.getRandomPointOnCircle(newArena.loc,75f), null);
// Add the new arena to the active arenas list
activeArenas.add(newArena);
}
}
public static void endArena(Arena arena, PlayerCharacter winner, PlayerCharacter loser, String condition){
if (winner != null && loser != null) {
Logger.info("[ARENA] The fight between {} and {} is concluded. Victor: {}",
arena.player1.getName(), arena.player2.getName(), winner.getName());
} else {
Logger.info("[ARENA] The fight between {} and {} is concluded. No Winner Declared.",
arena.player1.getName(), arena.player2.getName());
}
// Teleport players to the arena location
Zone sdr = ZoneManager.getZoneByUUID(656);
MovementManager.translocate(arena.player1, Vector3fImmutable.getRandomPointOnCircle(sdr.getLoc(),50f), null);
MovementManager.translocate(arena.player2, Vector3fImmutable.getRandomPointOnCircle(sdr.getLoc(),50f), null);
activeArenas.remove(arena);
if(winner != null){
ChatManager.chatPVP("[ARENA] " + winner.getName() + " has slain " + loser.getName() + " in the arena!");
//handle prize distribution
//ItemBase specialLoot = ItemBase.getItemBase(866);
//Item promoted = new MobLoot(winner, specialLoot, 1, false).promoteToItem(winner);
//promoted.setNumOfItems(21235);
//promoted.setName("Special Banker(21235)");
//DbManager.ItemQueries.UPDATE_NUM_ITEMS(promoted,21235);
//winner.getCharItemManager().addItemToInventory(promoted);
//winner.getCharItemManager().updateInventory();
}
}
public static Vector3fImmutable selectRandomArenaLocation() {
boolean locSet = false;
Vector3fImmutable loc = Vector3fImmutable.ZERO;
while (!locSet) {
try {
float x = ThreadLocalRandom.current().nextInt(114300, 123600);
float z = ThreadLocalRandom.current().nextInt(82675, 91700);
float y = 0; // Y coordinate is always 0
loc = new Vector3fImmutable(x, y, z * -1);
HashSet<AbstractWorldObject> inRange = WorldGrid.getObjectsInRangePartial(loc,500f, MBServerStatics.MASK_PLAYER);
if(inRange.isEmpty() && !isUnderWater(loc))
locSet = true;
//}
}catch(Exception e){
}
}
return loc;
}
public static boolean isUnderWater(Vector3fImmutable loc) {
try {
Zone zone = ZoneManager.findSmallestZone(loc);
if (zone.getSeaLevel() != 0) {
float localAltitude = loc.y;
if (localAltitude < zone.getSeaLevel())
return true;
} else {
if (loc.y < 0)
return true;
}
} catch (Exception e) {
}
return false;
}
}
+4 -39
View File
@@ -438,18 +438,6 @@ public enum BuildingManager {
public static boolean IsPlayerHostile(Building building, PlayerCharacter player) { public static boolean IsPlayerHostile(Building building, PlayerCharacter player) {
if(building.getBlueprint() != null && building.getBlueprint().getBuildingGroup() != null && building.getBlueprint().getBuildingGroup().equals(BuildingGroup.BANESTONE))
{
Guild playerNation = player.guild.getNation();
City banedCity = ZoneManager.getCityAtLocation(building.loc);
if(banedCity != null){
if(banedCity.getGuild().getNation().equals(playerNation)){
return false;
}else{
return true;
}
}
}
//Nation Members and Guild members are not hostile. //Nation Members and Guild members are not hostile.
// if (building.getGuild() != null){ // if (building.getGuild() != null){
// if (pc.getGuild() != null) // if (pc.getGuild() != null)
@@ -532,30 +520,7 @@ public enum BuildingManager {
if (building.getBlueprintUUID() == 0) if (building.getBlueprintUUID() == 0)
return false; return false;
if(building.getBlueprint().getBuildingGroup().equals(BuildingGroup.TOL)){ if (building.getBlueprint().getMaxSlots() == building.getHirelings().size())
if(contract.getContractID() == 850) {
boolean hasRunemaster = false;
for (AbstractCharacter npc : building.getHirelings().keySet()) {
if (npc.getObjectType() != GameObjectType.NPC)
continue;
if(npc.contractUUID == 850)
hasRunemaster = true;
}
if(hasRunemaster)
return false;
}
}
int maxSlots = building.getBlueprint().getMaxSlots();
if(building.getBlueprint().getBuildingGroup() != null) {
maxSlots = building.getBlueprint().getSlotsForRank(building.getRank());
}
if (maxSlots == building.getHirelings().size())
return false; return false;
String pirateName = NPCManager.getPirateName(contract.getMobbaseID()); String pirateName = NPCManager.getPirateName(contract.getMobbaseID());
@@ -570,7 +535,7 @@ public enum BuildingManager {
if (NPC.ISWallArcher(contract)) { if (NPC.ISWallArcher(contract)) {
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank); mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank);
if (mob == null) if (mob == null)
return false; return false;
@@ -582,7 +547,7 @@ public enum BuildingManager {
if (NPC.ISGuardCaptain(contract.getContractID())) { if (NPC.ISGuardCaptain(contract.getContractID())) {
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank); mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank);
if (mob == null) if (mob == null)
return false; return false;
@@ -594,7 +559,7 @@ public enum BuildingManager {
if (contract.getContractID() == 910) { if (contract.getContractID() == 910) {
//guard dog //guard dog
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank); mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank);
if (mob == null) if (mob == null)
return false; return false;
-5
View File
@@ -27,7 +27,6 @@ import engine.objects.*;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import engine.server.world.WorldServer; import engine.server.world.WorldServer;
import engine.session.Session; import engine.session.Session;
import engine.util.KeyCloneAudit;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.util.ArrayList; import java.util.ArrayList;
@@ -85,10 +84,6 @@ public enum ChatManager {
if ((checkTime > 0L) && (curMsgTime - checkTime < FLOOD_TIME_THRESHOLD)) if ((checkTime > 0L) && (curMsgTime - checkTime < FLOOD_TIME_THRESHOLD))
isFlood = true; isFlood = true;
if(KeyCloneAudit.auditChatMsg(pc,msg.getMessage())){
return;
}
switch (protocolMsg) { switch (protocolMsg) {
case CHATSAY: case CHATSAY:
ChatManager.chatSay(pc, msg.getMessage(), isFlood); ChatManager.chatSay(pc, msg.getMessage(), isFlood);
+40 -212
View File
@@ -26,6 +26,7 @@ import engine.powers.effectmodifiers.WeaponProcEffectModifier;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.util.HashSet;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
@@ -300,17 +301,6 @@ public enum CombatManager {
if (target == null) if (target == null)
return 0; return 0;
//pet to assist in attacking target
if(abstractCharacter.getObjectType().equals(GameObjectType.PlayerCharacter)){
PlayerCharacter attacker = (PlayerCharacter)abstractCharacter;
if(attacker.getPet() != null){
Mob pet = attacker.getPet();
if(pet.combatTarget == null && pet.assist)
pet.setCombatTarget(attacker.combatTarget);
}
}
//target must be valid type //target must be valid type
if (AbstractWorldObject.IsAbstractCharacter(target)) { if (AbstractWorldObject.IsAbstractCharacter(target)) {
@@ -462,17 +452,6 @@ public enum CombatManager {
//Range check. //Range check.
if(abstractCharacter.isMoving()){
range += (abstractCharacter.getSpeed() * 0.1f);
}
if(AbstractWorldObject.IsAbstractCharacter(target)) {
AbstractCharacter tarAc = (AbstractCharacter) target;
if(tarAc != null && tarAc.isMoving()){
range += (tarAc.getSpeed() * 0.1f);
}
}
if (NotInRange(abstractCharacter, target, range)) { if (NotInRange(abstractCharacter, target, range)) {
//target is in stealth and can't be seen by source //target is in stealth and can't be seen by source
@@ -504,14 +483,6 @@ public enum CombatManager {
createTimer(abstractCharacter, slot, 20, true); //2 second for no weapon createTimer(abstractCharacter, slot, 20, true); //2 second for no weapon
else { else {
int wepSpeed = (int) (wb.getSpeed()); int wepSpeed = (int) (wb.getSpeed());
if(abstractCharacter.getObjectType().equals(GameObjectType.PlayerCharacter)){
PlayerCharacter pc = (PlayerCharacter)abstractCharacter;
if(slot == 1){
wepSpeed = (int) pc.combatStats.attackSpeedHandOne;
}else{
wepSpeed = (int) pc.combatStats.attackSpeedHandTwo;
}
}else {
if (weapon != null && weapon.getBonusPercent(ModType.WeaponSpeed, SourceType.None) != 0f) //add weapon speed bonus if (weapon != null && weapon.getBonusPercent(ModType.WeaponSpeed, SourceType.None) != 0f) //add weapon speed bonus
wepSpeed *= (1 + weapon.getBonus(ModType.WeaponSpeed, SourceType.None)); wepSpeed *= (1 + weapon.getBonus(ModType.WeaponSpeed, SourceType.None));
@@ -521,7 +492,7 @@ public enum CombatManager {
if (wepSpeed < 10) if (wepSpeed < 10)
wepSpeed = 10; //Old was 10, but it can be reached lower with legit buffs,effects. wepSpeed = 10; //Old was 10, but it can be reached lower with legit buffs,effects.
}
createTimer(abstractCharacter, slot, wepSpeed, true); createTimer(abstractCharacter, slot, wepSpeed, true);
} }
@@ -566,23 +537,6 @@ public enum CombatManager {
if (target == null) if (target == null)
return; return;
if(ac.getObjectType().equals(GameObjectType.PlayerCharacter)){
PlayerCharacter pc = (PlayerCharacter) ac;
if( pc.combatStats == null){
pc.combatStats = new PlayerCombatStats(pc);
}
pc.combatStats.calculateATR(true);
pc.combatStats.calculateATR(false);
if (mainHand) {
atr = pc.combatStats.atrHandOne;
minDamage = pc.combatStats.minDamageHandOne;
maxDamage = pc.combatStats.maxDamageHandOne;
} else {
atr = pc.combatStats.atrHandTwo;
minDamage = pc.combatStats.minDamageHandTwo;
maxDamage = pc.combatStats.maxDamageHandTwo;
}
}else {
if (mainHand) { if (mainHand) {
atr = ac.getAtrHandOne(); atr = ac.getAtrHandOne();
minDamage = ac.getMinDamageHandOne(); minDamage = ac.getMinDamageHandOne();
@@ -592,7 +546,6 @@ public enum CombatManager {
minDamage = ac.getMinDamageHandTwo(); minDamage = ac.getMinDamageHandTwo();
maxDamage = ac.getMaxDamageHandTwo(); maxDamage = ac.getMaxDamageHandTwo();
} }
}
boolean tarIsRat = false; boolean tarIsRat = false;
@@ -685,12 +638,7 @@ public enum CombatManager {
} }
} else { } else {
AbstractCharacter tar = (AbstractCharacter) target; AbstractCharacter tar = (AbstractCharacter) target;
if(tar.getObjectType().equals(GameObjectType.PlayerCharacter)){
((PlayerCharacter)tar).combatStats.calculateDefense();
defense = ((PlayerCharacter)tar).combatStats.defense;
}else {
defense = tar.getDefenseRating(); defense = tar.getDefenseRating();
}
handleRetaliate(tar, ac); //Handle target attacking back if in combat and has no other target handleRetaliate(tar, ac); //Handle target attacking back if in combat and has no other target
} }
@@ -698,24 +646,24 @@ public enum CombatManager {
//Get hit chance //Get hit chance
//int chance; int chance;
//float dif = atr - defense; float dif = atr - defense;
//if (dif > 100) if (dif > 100)
// chance = 94; chance = 94;
//else if (dif < -100) else if (dif < -100)
// chance = 4; chance = 4;
//else else
// chance = (int) ((0.45 * dif) + 49); chance = (int) ((0.45 * dif) + 49);
errorTrack = 5; errorTrack = 5;
//calculate hit/miss //calculate hit/miss
int roll = ThreadLocalRandom.current().nextInt(100);
DeferredPowerJob dpj = null; DeferredPowerJob dpj = null;
boolean hitLanded = LandHit((int)atr,(int)defense); if (roll < chance) {
if (hitLanded) {
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter)) if (ac.getObjectType().equals(GameObjectType.PlayerCharacter))
updateAttackTimers((PlayerCharacter) ac, target, true); updateAttackTimers((PlayerCharacter) ac, target, true);
@@ -744,25 +692,7 @@ public enum CombatManager {
PlayerBonuses bonus = ac.getBonuses(); PlayerBonuses bonus = ac.getBonuses();
float attackRange = getWeaponRange(wb, bonus); float attackRange = getWeaponRange(wb, bonus);
if(ac.isMoving()){
attackRange += (ac.getSpeed() * 0.1f);
}
if(AbstractWorldObject.IsAbstractCharacter(target)) {
//AbstractCharacter tarAc = (AbstractCharacter) target;
if(tarAc != null && tarAc.isMoving()){
attackRange += (tarAc.getSpeed() * 0.1f);
}
}
if(specialCaseHitRoll(dpj.getPowerToken())) {
if(hitLanded) {
dpj.attack(target, attackRange); dpj.attack(target, attackRange);
}
}else{
dpj.attack(target, attackRange);
}
if (dpj.getPower() != null && (dpj.getPowerToken() == -1851459567 || dpj.getPowerToken() == -1851489518)) if (dpj.getPower() != null && (dpj.getPowerToken() == -1851459567 || dpj.getPowerToken() == -1851489518))
((PlayerCharacter) ac).setWeaponPower(dpj); ((PlayerCharacter) ac).setWeaponPower(dpj);
@@ -777,26 +707,8 @@ public enum CombatManager {
if (dpj != null && dpj.getPower() != null && (dpj.getPowerToken() == -1851459567 || dpj.getPowerToken() == -1851489518)) { if (dpj != null && dpj.getPower() != null && (dpj.getPowerToken() == -1851459567 || dpj.getPowerToken() == -1851489518)) {
float attackRange = getWeaponRange(wb, bonuses); float attackRange = getWeaponRange(wb, bonuses);
if(ac.isMoving()){
attackRange += (ac.getSpeed() * 0.1f);
}
if(AbstractWorldObject.IsAbstractCharacter(target)) {
//AbstractCharacter tarAc = (AbstractCharacter) target;
if(tarAc != null && tarAc.isMoving()){
attackRange += (tarAc.getSpeed() * 0.1f);
}
}
if(specialCaseHitRoll(dpj.getPowerToken())) {
if(hitLanded) {
dpj.attack(target, attackRange); dpj.attack(target, attackRange);
} }
}else{
dpj.attack(target, attackRange);
}
}
} }
errorTrack = 7; errorTrack = 7;
@@ -902,22 +814,6 @@ public enum CombatManager {
else else
damage = calculateDamage(ac, tarAc, minDamage, maxDamage, damageType, resists); damage = calculateDamage(ac, tarAc, minDamage, maxDamage, damageType, resists);
if(weapon != null && weapon.effects != null){
float armorPierce = 0;
for(Effect eff : weapon.effects.values()){
for(AbstractEffectModifier mod : eff.getEffectModifiers()){
if(mod.modType.equals(ModType.ArmorPiercing)){
armorPierce += mod.getPercentMod() + (mod.getRamp() * eff.getTrains());
}
}
}
if(armorPierce > 0){
damage *= 1 + (armorPierce * 0.01f);
}
}
//Resists.handleFortitude(tarAc,damageType,damage);
float d = 0f; float d = 0f;
errorTrack = 12; errorTrack = 12;
@@ -930,15 +826,14 @@ public enum CombatManager {
damage *= 2.5f; //increase damage if sitting damage *= 2.5f; //increase damage if sitting
if (tarAc.getObjectType() == GameObjectType.Mob) { if (tarAc.getObjectType() == GameObjectType.Mob) {
ac.setHateValue(damage * MBServerStatics.PLAYER_COMBAT_HATE_MODIFIER); if(ac.getObjectType().equals(GameObjectType.PlayerCharacter))
((Mob)tarAc).playerAgroMap.put(ac.getObjectUUID(), ((Mob) tarAc).playerAgroMap.get(ac.getObjectUUID()) + damage);
((Mob) tarAc).handleDirectAggro(ac); ((Mob) tarAc).handleDirectAggro(ac);
} }
if (tarAc.getHealth() > 0) if (tarAc.getHealth() > 0)
d = tarAc.modifyHealth(-damage, ac, false); d = tarAc.modifyHealth(-damage, ac, false);
tarAc.cancelOnTakeDamage();
} else if (target.getObjectType().equals(GameObjectType.Building)) { } else if (target.getObjectType().equals(GameObjectType.Building)) {
if (BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) { if (BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) {
@@ -972,18 +867,27 @@ public enum CombatManager {
if (weapon != null && tarAc != null && tarAc.isAlive()) { if (weapon != null && tarAc != null && tarAc.isAlive()) {
if(weapon.effects != null){ ConcurrentHashMap<String, Effect> effects = weapon.getEffects();
for (Effect eff : weapon.effects.values()){
for(AbstractEffectModifier mod : eff.getEffectModifiers()){ for (Effect eff : effects.values()) {
if(mod.modType.equals(ModType.WeaponProc)){ if (eff == null)
continue;
HashSet<AbstractEffectModifier> aems = eff.getEffectModifiers();
if (aems != null) {
for (AbstractEffectModifier aem : aems) {
if (!tarAc.isAlive())
break;
if (aem instanceof WeaponProcEffectModifier) {
int procChance = ThreadLocalRandom.current().nextInt(100); int procChance = ThreadLocalRandom.current().nextInt(100);
if (procChance < MBServerStatics.PROC_CHANCE) {
try { if (procChance < MBServerStatics.PROC_CHANCE)
((WeaponProcEffectModifier) mod).applyProc(ac, target); ((WeaponProcEffectModifier) aem).applyProc(ac, target);
}catch(Exception e){
Logger.error(eff.getName() + " Failed To Cast Proc");
}
}
} }
} }
} }
@@ -1012,26 +916,7 @@ public enum CombatManager {
if (wp.requiresHitRoll() == false) { if (wp.requiresHitRoll() == false) {
PlayerBonuses bonus = ac.getBonuses(); PlayerBonuses bonus = ac.getBonuses();
float attackRange = getWeaponRange(wb, bonus); float attackRange = getWeaponRange(wb, bonus);
if(ac.isMoving()){
attackRange += (ac.getSpeed() * 0.1f);
}
if(AbstractWorldObject.IsAbstractCharacter(target)) {
AbstractCharacter tarAc = (AbstractCharacter) target;
if(tarAc != null && tarAc.isMoving()){
attackRange += (tarAc.getSpeed() * 0.1f);
}
}
if(specialCaseHitRoll(dpj.getPowerToken())) {
if(hitLanded) {
dpj.attack(target, attackRange); dpj.attack(target, attackRange);
}
}else{
dpj.attack(target, attackRange);
}
} else } else
((PlayerCharacter) ac).setWeaponPower(null); ((PlayerCharacter) ac).setWeaponPower(null);
} }
@@ -1069,12 +954,6 @@ public enum CombatManager {
AbstractCharacter tar = (AbstractCharacter) target; AbstractCharacter tar = (AbstractCharacter) target;
if(target.getObjectType().equals(GameObjectType.PlayerCharacter)){
PlayerCharacter pc = (PlayerCharacter) target;
if(pc.getRaceID() == 1999)
return true;
}
CharacterItemManager acItem = ac.getCharItemManager(); CharacterItemManager acItem = ac.getCharItemManager();
CharacterItemManager tarItem = tar.getCharItemManager(); CharacterItemManager tarItem = tar.getCharItemManager();
@@ -1144,11 +1023,9 @@ public enum CombatManager {
//calculate resists in if any //calculate resists in if any
if (resists != null) if (resists != null)
damage = resists.getResistedDamage(source, target, damageType, damage, 0); return resists.getResistedDamage(source, target, damageType, damage, 0);
else
return damage; return damage;
} }
@@ -1178,10 +1055,6 @@ public enum CombatManager {
if (eff.getPower() != null && (eff.getPower().getToken() == 429506943 || eff.getPower().getToken() == 429408639 || eff.getPower().getToken() == 429513599 || eff.getPower().getToken() == 429415295)) if (eff.getPower() != null && (eff.getPower().getToken() == 429506943 || eff.getPower().getToken() == 429408639 || eff.getPower().getToken() == 429513599 || eff.getPower().getToken() == 429415295))
swingAnimation = 0; swingAnimation = 0;
if(source != null && source.getObjectType().equals(GameObjectType.PlayerCharacter)){
damage *= ((PlayerCharacter)source).ZergMultiplier;
} // Health modifications are modified by the ZergMechanic
TargetedActionMsg cmm = new TargetedActionMsg(source, target, damage, swingAnimation); TargetedActionMsg cmm = new TargetedActionMsg(source, target, damage, swingAnimation);
DispatchMessage.sendToAllInRange(target, cmm); DispatchMessage.sendToAllInRange(target, cmm);
} }
@@ -1303,14 +1176,6 @@ public enum CombatManager {
private static boolean testPassive(AbstractCharacter source, AbstractCharacter target, String type) { private static boolean testPassive(AbstractCharacter source, AbstractCharacter target, String type) {
if(target.getBonuses() != null)
if(target.getBonuses().getBool(ModType.Stunned, SourceType.None))
return false;
if(source.getBonuses() != null)
if(source.getBonuses().getBool(ModType.IgnorePassiveDefense, SourceType.None))
return false;
float chance = target.getPassiveChance(type, source.getLevel(), true); float chance = target.getPassiveChance(type, source.getLevel(), true);
if (chance == 0f) if (chance == 0f)
@@ -1321,7 +1186,7 @@ public enum CombatManager {
if (chance > 75f) if (chance > 75f)
chance = 75f; chance = 75f;
int roll = ThreadLocalRandom.current().nextInt(1,100); int roll = ThreadLocalRandom.current().nextInt(100);
return roll < chance; return roll < chance;
@@ -1373,16 +1238,13 @@ public enum CombatManager {
DispatchMessage.dispatchMsgToInterestArea(pc, rwss, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); DispatchMessage.dispatchMsgToInterestArea(pc, rwss, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
} }
public static void toggleSit(boolean toggle, ClientConnection origin) { private static void toggleSit(boolean toggle, ClientConnection origin) {
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin); PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
if (pc == null) if (pc == null)
return; return;
if(pc.isFlying())
pc.setSit(false);
else
pc.setSit(toggle); pc.setSit(toggle);
UpdateStateMsg rwss = new UpdateStateMsg(); UpdateStateMsg rwss = new UpdateStateMsg();
@@ -1461,13 +1323,6 @@ public enum CombatManager {
return; return;
retaliater.setCombatTarget(ac); retaliater.setCombatTarget(ac);
if(retaliater.isPlayerGuard && (retaliater.BehaviourType.equals(MobBehaviourType.GuardMinion) || retaliater.BehaviourType.equals(MobBehaviourType.GuardCaptain))){
for(Mob guard : retaliater.guardedCity.getParent().zoneMobSet){
if(guard.isPlayerGuard && guard.combatTarget == null){
guard.setCombatTarget(ac);
}
}
}
} }
} }
@@ -1499,9 +1354,9 @@ public enum CombatManager {
Resists resists = ac.getResists(); Resists resists = ac.getResists();
if (resists != null) { if (resists != null)
amount = resists.getResistedDamage(target, ac, ds.getDamageType(), amount, 0); amount = resists.getResistedDamage(target, ac, ds.getDamageType(), amount, 0);
}
total += amount; total += amount;
} }
@@ -1584,31 +1439,4 @@ public enum CombatManager {
((AbstractCharacter) awo).getCharItemManager().damageRandomArmor(1); ((AbstractCharacter) awo).getCharItemManager().damageRandomArmor(1);
} }
public static boolean LandHit(int ATR, int DEF){
//float chance = (ATR-((ATR+DEF) * 0.315f)) / ((DEF-((ATR+DEF) * 0.315f)) + (ATR-((ATR+DEF) * 0.315f)));
//float convertedChance = chance * 100;
int roll = ThreadLocalRandom.current().nextInt(101);
//if(roll <= 5)//always 5% chance to miss
// return false;
//if(roll >= 95)//always 5% chance to hit
// return true;
float chance = PlayerCombatStats.getHitChance(ATR,DEF);
return chance >= roll;
}
public static boolean specialCaseHitRoll(int powerID){
switch(powerID) {
case 563200808: // Naargal's Bite
case 563205337: // Naargal's Dart
case 563205930: // Sword of Saint Malorn
return true;
default:
return false;
}
}
} }
+1 -3
View File
@@ -65,7 +65,6 @@ public enum ConfigManager {
MB_WORLD_MAINTENANCE, MB_WORLD_MAINTENANCE,
MB_WORLD_GREETING, MB_WORLD_GREETING,
MB_WORLD_KEYCLONE_MAX, MB_WORLD_KEYCLONE_MAX,
MB_WORLD_TESTMODE,
MB_USE_RUINS, MB_USE_RUINS,
// Mobile AI modifiers // Mobile AI modifiers
@@ -98,8 +97,7 @@ public enum ConfigManager {
MB_MAGICBOT_FORTOFIX, MB_MAGICBOT_FORTOFIX,
MB_MAGICBOT_RECRUIT, MB_MAGICBOT_RECRUIT,
MB_MAGICBOT_MAGICBOX, MB_MAGICBOT_MAGICBOX,
MB_MAGICBOT_ADMINLOG, MB_MAGICBOT_ADMINLOG;
MB_WORLD_BOXLIMIT;
// Map to hold our config pulled in from the environment // Map to hold our config pulled in from the environment
// We also use the config to point to the current message pump // We also use the config to point to the current message pump
+3 -37
View File
@@ -79,6 +79,7 @@ public enum DevCmdManager {
DevCmdManager.registerDevCmd(new AddGoldCmd()); DevCmdManager.registerDevCmd(new AddGoldCmd());
DevCmdManager.registerDevCmd(new ZoneInfoCmd()); DevCmdManager.registerDevCmd(new ZoneInfoCmd());
DevCmdManager.registerDevCmd(new DebugMeleeSyncCmd()); DevCmdManager.registerDevCmd(new DebugMeleeSyncCmd());
DevCmdManager.registerDevCmd(new HotzoneCmd());
DevCmdManager.registerDevCmd(new MineActiveCmd()); DevCmdManager.registerDevCmd(new MineActiveCmd());
// Dev // Dev
DevCmdManager.registerDevCmd(new ApplyStatModCmd()); DevCmdManager.registerDevCmd(new ApplyStatModCmd());
@@ -102,7 +103,6 @@ public enum DevCmdManager {
DevCmdManager.registerDevCmd(new SetAdminRuneCmd()); DevCmdManager.registerDevCmd(new SetAdminRuneCmd());
DevCmdManager.registerDevCmd(new SetInvulCmd()); DevCmdManager.registerDevCmd(new SetInvulCmd());
DevCmdManager.registerDevCmd(new MakeItemCmd()); DevCmdManager.registerDevCmd(new MakeItemCmd());
DevCmdManager.registerDevCmd(new GimmeCmd());
DevCmdManager.registerDevCmd(new EnchantCmd()); DevCmdManager.registerDevCmd(new EnchantCmd());
DevCmdManager.registerDevCmd(new SetSubRaceCmd()); DevCmdManager.registerDevCmd(new SetSubRaceCmd());
// Admin // Admin
@@ -177,44 +177,10 @@ public enum DevCmdManager {
return false; return false;
} }
if(!pcSender.getTimestamps().containsKey("DEVCOMMAND"))
pcSender.getTimestamps().put("DEVCOMMAND",System.currentTimeMillis() - 1500L);
else if(System.currentTimeMillis() - pcSender.getTimestamps().get("DEVCOMMAND") < 1000L)
return false;
//kill any commands not available to everyone on production server //kill any commands not available to everyone on production server
//only admin level can run dev commands on production //only admin level can run dev commands on production
boolean playerAllowed = false;
if(ConfigManager.MB_WORLD_TESTMODE.getValue().equals("true")) { if (a.status.equals(Enum.AccountStatus.ADMIN) == false) {
switch (adc.getMainCmdString()) {
case "printresists":
case "printstats":
case "printskills":
case "printpowers":
case "gimme":
case "goto":
case "teleportmode":
case "printbonuses":
playerAllowed = true;
if (!a.status.equals(Enum.AccountStatus.ADMIN))
target = pcSender;
break;
}
}else{
switch (adc.getMainCmdString()) {
case "printresists":
case "printstats":
case "printskills":
case "printpowers":
case "printbonuses":
//case "gimme":
playerAllowed = true;
if (!a.status.equals(Enum.AccountStatus.ADMIN))
target = pcSender;
break;
}
}
if (!playerAllowed && !a.status.equals(Enum.AccountStatus.ADMIN)) {
Logger.info("Account " + a.getUname() + "attempted to use dev command " + cmd); Logger.info("Account " + a.getUname() + "attempted to use dev command " + cmd);
return false; return false;
} }
+59 -637
View File
@@ -14,13 +14,10 @@ import engine.net.DispatchMessage;
import engine.net.client.msg.ErrorPopupMsg; import engine.net.client.msg.ErrorPopupMsg;
import engine.net.client.msg.chat.ChatSystemMsg; import engine.net.client.msg.chat.ChatSystemMsg;
import engine.objects.*; import engine.objects.*;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
/** /**
@@ -37,21 +34,6 @@ public enum LootManager {
public static HashMap<Integer, ArrayList<ModTableEntry>> _modTables = new HashMap<>(); public static HashMap<Integer, ArrayList<ModTableEntry>> _modTables = new HashMap<>();
public static HashMap<Integer, ArrayList<ModTypeTableEntry>> _modTypeTables = new HashMap<>(); public static HashMap<Integer, ArrayList<ModTypeTableEntry>> _modTypeTables = new HashMap<>();
public static final ArrayList<Integer> vorg_ha_uuids = new ArrayList<>(Arrays.asList(27580, 27590, 188500, 188510, 188520, 188530, 188540, 188550, 189510));
public static final ArrayList<Integer> vorg_ma_uuids = new ArrayList<>(Arrays.asList(27570,188900,188910,188920,188930,188940,188950,189500));
public static final ArrayList<Integer> vorg_la_uuids = new ArrayList<>(Arrays.asList(27550,27560,189100,189110,189120,189130,189140,189150));
public static final ArrayList<Integer> vorg_cloth_uuids = new ArrayList<>(Arrays.asList(27600,188700,188720,189550,189560));
public static final ArrayList<Integer> racial_guard_uuids = new ArrayList<>(Arrays.asList(841,951,952,1050,1052,1180,1182,1250,1252,1350,1352,1450,1452,1500,1502,1525,1527,1550,1552,1575,1577,1600,1602,1650,1652,1700,980100,980102));
public static final ArrayList<Integer> static_rune_ids = new ArrayList<>(Arrays.asList(
250001, 250002, 250003, 250004, 250005, 250006, 250007, 250008, 250010, 250011,
250012, 250013, 250014, 250015, 250016, 250017, 250019, 250020, 250021, 250022,
250023, 250024, 250025, 250026, 250028, 250029, 250030, 250031, 250032, 250033,
250034, 250035, 250037, 250038, 250039, 250040, 250041, 250042, 250043, 250044,
250115, 250118, 250119, 250120, 250121, 250122, 252123, 252124, 252125, 252126,
252127
));
// Drop Rates // Drop Rates
public static float NORMAL_DROP_RATE; public static float NORMAL_DROP_RATE;
@@ -86,39 +68,16 @@ public enum LootManager {
public static void GenerateMobLoot(Mob mob) { public static void GenerateMobLoot(Mob mob) {
if(mob == null){
return;
}
//determine if mob is in hotzone //determine if mob is in hotzone
boolean inHotzone = false; boolean inHotzone = ZoneManager.inHotZone(mob.getLoc());
//iterate the booty sets //iterate the booty sets
if(mob.mobBase == null || mob.getMobBaseID() == 253003){ if (mob.getMobBase().bootySet != 0 && _bootySetMap.containsKey(mob.getMobBase().bootySet) == true)
int i = 0;
}
if (mob.getMobBase().bootySet != 0 && _bootySetMap.containsKey(mob.getMobBase().bootySet))
RunBootySet(_bootySetMap.get(mob.getMobBase().bootySet), mob, inHotzone); RunBootySet(_bootySetMap.get(mob.getMobBase().bootySet), mob, inHotzone);
if (mob.bootySet != 0 && _bootySetMap.containsKey(mob.bootySet)) { if (mob.bootySet != 0 && _bootySetMap.containsKey(mob.bootySet) == true)
RunBootySet(_bootySetMap.get(mob.bootySet), mob, inHotzone); RunBootySet(_bootySetMap.get(mob.bootySet), mob, inHotzone);
}else if(mob.bootySet != 0 && ItemBase.getItemBase(mob.bootySet) != null){
MobLoot specialDrop = null;
specialDrop = new MobLoot(mob,ItemBase.getItemBase(mob.bootySet),true);
if(specialDrop != null) {
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().getName() + " has found the " + specialDrop.getName() + ". Are you tough enough to take it?");
chatMsg.setMessageType(10);
chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID());
DispatchMessage.dispatchMsgToAll(chatMsg);
mob.getCharItemManager().addItemToInventory(specialDrop);
mob.setResists(new Resists("Dropper"));
if(!Mob.discDroppers.contains(mob))
Mob.AddDiscDropper(mob);
}
}
//lastly, check mobs inventory for godly or disc runes to send a server announcement //lastly, check mobs inventory for godly or disc runes to send a server announcement
for (Item it : mob.getInventory()) { for (Item it : mob.getInventory()) {
@@ -139,74 +98,18 @@ public enum LootManager {
private static void RunBootySet(ArrayList<BootySetEntry> entries, Mob mob, boolean inHotzone) { private static void RunBootySet(ArrayList<BootySetEntry> entries, Mob mob, boolean inHotzone) {
boolean hotzoneWasRan = false; boolean hotzoneWasRan = false;
float dropRate; float dropRate = 1.0f;
if (!mob.getSafeZone()) {
int contractLow = 1, contractHigh = 400;
int runeLow = 401, runeHigh = 800;
int resourceLow = 801, resourceHigh = 900;
int glassLow = 901, glassHigh = 910;
int guardLow = 911, guardHigh = 920;
// Pre-compute adjusted high values
int contractAdjust = 0, runeAdjust = 0, resourceAdjust = 0, glassAdjust = 0, guardAdjust = 0;
if (mob.level < 50) {
int dif = 50 - mob.level;
contractAdjust = (int)(400 * (dif * 0.02f));
runeAdjust = (int)(400 * (dif * 0.02f));
resourceAdjust = (int)(100 * (dif * 0.02f));
glassAdjust = (int)(10 * (dif * 0.02f));
guardAdjust = (int)(10 * (dif * 0.02f));
}
// Generate a single random roll
int specialCaseRoll = ThreadLocalRandom.current().nextInt(1, 100001);
// Calculate adjusted high values once
int contractHighAdjusted = contractHigh - contractAdjust;
int runeHighAdjusted = runeHigh - runeAdjust;
int resourceHighAdjusted = resourceHigh - resourceAdjust;
int glassHighAdjusted = glassHigh - glassAdjust;
int guardHighAdjusted = guardHigh - guardAdjust;
// Check the roll range and handle accordingly
if (specialCaseRoll >= contractLow && specialCaseRoll <= contractHighAdjusted) {
SpecialCaseContractDrop(mob, entries);
} else if (specialCaseRoll >= runeLow && specialCaseRoll <= runeHighAdjusted) {
SpecialCaseRuneDrop(mob, entries);
} else if (specialCaseRoll >= resourceLow && specialCaseRoll <= resourceHighAdjusted) {
SpecialCaseResourceDrop(mob, entries);
} else if (specialCaseRoll >= glassLow && specialCaseRoll <= glassHighAdjusted) {
int glassID = rollRandomItem(126);
ItemBase glassItem = ItemBase.getItemBase(glassID);
if (glassItem != null) {
MobLoot toAddGlass = new MobLoot(mob, glassItem, false);
mob.getCharItemManager().addItemToInventory(toAddGlass);
}
} else if (specialCaseRoll >= guardLow && specialCaseRoll <= guardHighAdjusted) {
int guardContractID = racial_guard_uuids.get(new java.util.Random().nextInt(racial_guard_uuids.size()));
ItemBase guardContract = ItemBase.getItemBase(guardContractID);
if (guardContract != null) {
MobLoot toAddContract = new MobLoot(mob, guardContract, false);
mob.getCharItemManager().addItemToInventory(toAddContract);
}
}
}
// Iterate all entries in this bootySet and process accordingly // Iterate all entries in this bootySet and process accordingly
Zone zone = ZoneManager.findSmallestZone(mob.loc);
for (BootySetEntry bse : entries) { for (BootySetEntry bse : entries) {
switch (bse.bootyType) { switch (bse.bootyType) {
case "GOLD": case "GOLD":
if (zone != null && zone.getSafeZone() == (byte)1)
return; // no loot to drop in safezones
GenerateGoldDrop(mob, bse, inHotzone); GenerateGoldDrop(mob, bse, inHotzone);
break; break;
case "LOOT": case "LOOT":
if (zone != null && zone.getSafeZone() == (byte)1)
return; // no loot to drop in safezones
if (mob.getSafeZone() == false)
dropRate = LootManager.NORMAL_DROP_RATE; dropRate = LootManager.NORMAL_DROP_RATE;
if (inHotzone == true) if (inHotzone == true)
@@ -232,116 +135,6 @@ public enum LootManager {
} }
} }
public static void SpecialCaseContractDrop(Mob mob,ArrayList<BootySetEntry> entries){
int lootTableID = 0;
for(BootySetEntry entry : entries){
if(entry.bootyType.equals("LOOT")){
lootTableID = entry.genTable;
break;
}
}
if(lootTableID == 0)
return;
int ContractTableID = 0;
for(GenTableEntry entry : _genTables.get(lootTableID)){
try {
if (ItemBase.getItemBase(_itemTables.get(entry.itemTableID).get(0).cacheID).getType().equals(Enum.ItemType.CONTRACT)) {
ContractTableID = entry.itemTableID;
break;
}
}catch(Exception e){
}
}
if(ContractTableID == 0)
return;
ItemBase ib = ItemBase.getItemBase(rollRandomItem(ContractTableID));
if(ib != null){
MobLoot toAdd = new MobLoot(mob,ib,false);
mob.getCharItemManager().addItemToInventory(toAdd);
}
}
public static void SpecialCaseRuneDrop(Mob mob,ArrayList<BootySetEntry> entries){
//int lootTableID = 0;
//for(BootySetEntry entry : entries){
// if(entry.bootyType.equals("LOOT")){
// lootTableID = entry.genTable;
// break;
// }
//}
// if(lootTableID == 0)
// return;
//int RuneTableID = 0;
//for(GenTableEntry entry : _genTables.get(lootTableID)){
// try {
// if (ItemBase.getItemBase(_itemTables.get(entry.itemTableID).get(0).cacheID).getType().equals(Enum.ItemType.RUNE)) {
// RuneTableID = entry.itemTableID;
// break;
// }
// }catch(Exception e){
// }
//}
//if(RuneTableID == 0)
// return;
int roll = ThreadLocalRandom.current().nextInt(static_rune_ids.size() + 1);
int itemId = static_rune_ids.get(0);
try {
itemId = static_rune_ids.get(roll);
}catch(Exception e){
}
ItemBase ib = ItemBase.getItemBase(itemId);
if(ib != null){
MobLoot toAdd = new MobLoot(mob,ib,false);
mob.getCharItemManager().addItemToInventory(toAdd);
}
}
public static void SpecialCaseResourceDrop(Mob mob,ArrayList<BootySetEntry> entries){
int lootTableID = 0;
for(BootySetEntry entry : entries){
if(entry.bootyType.equals("LOOT")){
lootTableID = entry.genTable;
break;
}
}
if(lootTableID == 0)
return;
int ResourceTableID = 0;
for(GenTableEntry entry : _genTables.get(lootTableID)){
try {
if (ItemBase.getItemBase(_itemTables.get(entry.itemTableID).get(0).cacheID).getType().equals(Enum.ItemType.RESOURCE)) {
ResourceTableID = entry.itemTableID;
break;
}
}catch(Exception e){
}
}
if(ResourceTableID == 0)
return;
ItemBase ib = ItemBase.getItemBase(rollRandomItem(ResourceTableID));
if(ib != null){
MobLoot toAdd = new MobLoot(mob,ib,false);
mob.getCharItemManager().addItemToInventory(toAdd);
}
}
public static MobLoot getGenTableItem(int genTableID, AbstractCharacter mob, Boolean inHotzone) { public static MobLoot getGenTableItem(int genTableID, AbstractCharacter mob, Boolean inHotzone) {
if (mob == null || _genTables.containsKey(genTableID) == false) if (mob == null || _genTables.containsKey(genTableID) == false)
@@ -363,10 +156,11 @@ public enum LootManager {
//gets the 1-320 roll for this mob //gets the 1-320 roll for this mob
int itemTableRoll = 0; int itemTableRoll = 0;
int objectType = mob.getObjectType().ordinal();
if(mob.getObjectType().ordinal() == 52) { //52 = player character if(mob.getObjectType().ordinal() == 52) { //52 = player character
itemTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); itemTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1);
} else{ } else{
itemTableRoll = TableRoll(mob.level); itemTableRoll = TableRoll(mob.level, inHotzone);
} }
ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, itemTableRoll); ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, itemTableRoll);
if (tableRow == null) if (tableRow == null)
@@ -378,23 +172,13 @@ public enum LootManager {
return null; return null;
if (ItemBase.getItemBase(itemUUID).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) { if (ItemBase.getItemBase(itemUUID).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) {
if(ThreadLocalRandom.current().nextInt(1,101) < 91)
return null; // cut down world drops rates of resources by 90%
int amount = ThreadLocalRandom.current().nextInt(tableRow.minSpawn, tableRow.maxSpawn + 1); int amount = ThreadLocalRandom.current().nextInt(tableRow.minSpawn, tableRow.maxSpawn + 1);
return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false); return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false);
} }
if(ItemBase.getItemBase(itemUUID).getType().equals(Enum.ItemType.RUNE)){
int randomRune = rollRandomItem(itemTableId);
if(randomRune != 0) {
itemUUID = randomRune;
}
} else if(ItemBase.getItemBase(itemUUID).getType().equals(Enum.ItemType.CONTRACT)){
int randomContract = rollRandomItem(itemTableId);
if(randomContract != 0) {
itemUUID = randomContract;
}
}
outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false);
Enum.ItemType outType = outItem.getItemBase().getType();
if(selectedRow.pModTable != 0){ if(selectedRow.pModTable != 0){
try { try {
@@ -412,12 +196,6 @@ public enum LootManager {
Logger.error("Failed to GenerateSuffix for item: " + outItem.getName()); Logger.error("Failed to GenerateSuffix for item: " + outItem.getName());
} }
} }
if(outItem.getItemBase().getType().equals(Enum.ItemType.CONTRACT) || outItem.getItemBase().getType().equals(Enum.ItemType.RUNE)){
if(ThreadLocalRandom.current().nextInt(1,101) < 66)
return null; // cut down world drops rates of resources by 65%
}
return outItem; return outItem;
} }
@@ -438,7 +216,7 @@ public enum LootManager {
if(mob.getObjectType().ordinal() == 52) { if(mob.getObjectType().ordinal() == 52) {
prefixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); prefixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1);
} else{ } else{
prefixTableRoll = TableRoll(mob.level); prefixTableRoll = TableRoll(mob.level, inHotzone);
} }
ModTableEntry prefixMod = ModTableEntry.rollTable(prefixTable.modTableID, prefixTableRoll); ModTableEntry prefixMod = ModTableEntry.rollTable(prefixTable.modTableID, prefixTableRoll);
@@ -470,34 +248,14 @@ public enum LootManager {
if(mob.getObjectType().ordinal() == 52) { if(mob.getObjectType().ordinal() == 52) {
suffixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); suffixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1);
} else{ } else{
suffixTableRoll = TableRoll(mob.level); suffixTableRoll = TableRoll(mob.level, inHotzone);
} }
ModTableEntry suffixMod = ModTableEntry.rollTable(suffixTable.modTableID, suffixTableRoll); ModTableEntry suffixMod = ModTableEntry.rollTable(suffixTable.modTableID, suffixTableRoll);
if (suffixMod == null) if (suffixMod == null)
return inItem; return inItem;
int moveSpeedRoll = ThreadLocalRandom.current().nextInt(100); if (suffixMod.action.length() > 0) {
if(inItem.getItemBase().getValidSlot() == MBServerStatics.SLOT_FEET && moveSpeedRoll < 10){
int rankRoll = ThreadLocalRandom.current().nextInt(10);
String suffixSpeed = "SUF-148";
switch(rankRoll) {
case 1:
case 2:
case 3:
suffixSpeed = "SUF-149";
break;
case 4:
case 5:
case 6:
case 7:
suffixSpeed = "SUF-150";
break;
}
inItem.setSuffix(suffixSpeed);
inItem.addPermanentEnchantment(suffixSpeed, 0, suffixMod.level, false);
}else if (suffixMod.action.length() > 0) {
inItem.setSuffix(suffixMod.action); inItem.setSuffix(suffixMod.action);
inItem.addPermanentEnchantment(suffixMod.action, 0, suffixMod.level, false); inItem.addPermanentEnchantment(suffixMod.action, 0, suffixMod.level, false);
} }
@@ -505,36 +263,23 @@ public enum LootManager {
return inItem; return inItem;
} }
public static int TableRoll(int mobLevel) { public static int TableRoll(int mobLevel, Boolean inHotzone) {
int rank = (int)(mobLevel * 0.1f); if (mobLevel > 65)
int min = 50; mobLevel = 65;
int max = 100;
switch(rank){ int max = (int) (4.882 * mobLevel + 127.0);
case 1:
min = 200; if (max > 319)
max = 250; max = 319;
break;
case 2: int min = (int) (4.469 * mobLevel - 3.469);
min = 210;
max = 275; if (min < 70)
break; min = 70;
case 3:
min = 220; if (inHotzone)
max = 300; min += mobLevel;
break;
case 4:
min = 230;
max = 320;
break;
case 5:
case 6:
case 7:
case 8:
min = 240;
max = 320;
break;
}
int roll = ThreadLocalRandom.current().nextInt(min, max + 1); int roll = ThreadLocalRandom.current().nextInt(min, max + 1);
@@ -554,7 +299,12 @@ public enum LootManager {
int high = bse.highGold; int high = bse.highGold;
int low = bse.lowGold; int low = bse.lowGold;
int gold = (int) (ThreadLocalRandom.current().nextInt(low, high + 1) * NORMAL_GOLD_RATE); int gold = ThreadLocalRandom.current().nextInt(low, high + 1);
if (inHotzone == true)
gold = (int) (gold * HOTZONE_GOLD_RATE);
else
gold = (int) (gold * NORMAL_GOLD_RATE);
if (gold > 0) { if (gold > 0) {
MobLoot goldAmount = new MobLoot(mob, gold); MobLoot goldAmount = new MobLoot(mob, gold);
@@ -565,61 +315,43 @@ public enum LootManager {
public static void GenerateLootDrop(Mob mob, int tableID, Boolean inHotzone) { public static void GenerateLootDrop(Mob mob, int tableID, Boolean inHotzone) {
MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone); try {
if(toAdd != null){
ItemBase ib = toAdd.getItemBase();
switch(ib.getType()){
case CONTRACT:
case RUNE:
case RESOURCE:
return;
}
toAdd.setIsID(true);
mob.getCharItemManager().addItemToInventory(toAdd);
}
}
MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone);
if (toAdd != null)
mob.getCharItemManager().addItemToInventory(toAdd);
} catch (Exception e) {
//TODO chase down loot generation error, affects roughly 2% of drops
int i = 0;
}
}
public static void GenerateEquipmentDrop(Mob mob) { public static void GenerateEquipmentDrop(Mob mob) {
if (mob == null || mob.getSafeZone())
return; // no equipment to drop in safezones
if(mob.StrongholdGuardian || mob.StrongholdCommander || mob.StrongholdEpic)
return; // stronghold mobs don't drop equipment
//do equipment here //do equipment here
if (mob.getEquip() != null) { int dropCount = 0;
boolean isVorg = false; if (mob.getEquip() != null)
for (MobEquipment me : mob.getEquip().values()) { for (MobEquipment me : mob.getEquip().values()) {
if (me.getDropChance() == 0) if (me.getDropChance() == 0)
continue; continue;
String name = me.getItemBase().getName().toLowerCase();
if (name.contains("vorgrim legionnaire's") || name.contains("vorgrim auxiliary's") ||name.contains("bellugh nuathal") || name.contains("crimson circle"))
isVorg = true;
if(isVorg && !mob.isDropper){
continue;
}
float equipmentRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); float equipmentRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1);
float dropChance = me.getDropChance() * 100; float dropChance = me.getDropChance() * 100;
ItemBase itemBase = me.getItemBase();
if(isVorg) {
mob.spawnTime = ThreadLocalRandom.current().nextInt(300, 2700);
dropChance = 7.5f;
itemBase = getRandomVorg(itemBase);
}
if (equipmentRoll > dropChance) if (equipmentRoll > dropChance)
continue; continue;
MobLoot ml = new MobLoot(mob, itemBase, false); MobLoot ml = new MobLoot(mob, me.getItemBase(), false);
if (ml != null && dropCount < 1) {
ml.setIsID(true); ml.setIsID(true);
ml.setDurabilityCurrent((short) (ml.getDurabilityCurrent() - ThreadLocalRandom.current().nextInt(5) + 1)); ml.setDurabilityCurrent((short) (ml.getDurabilityCurrent() - ThreadLocalRandom.current().nextInt(5) + 1));
mob.getCharItemManager().addItemToInventory(ml); mob.getCharItemManager().addItemToInventory(ml);
dropCount = 1;
//break; // Exit on first successful roll.
} }
} }
} }
@@ -635,89 +367,10 @@ public enum LootManager {
MobLoot lootItem = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true); MobLoot lootItem = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true);
if (lootItem != null) { if (lootItem != null)
mob.getCharItemManager().addItemToInventory(lootItem); mob.getCharItemManager().addItemToInventory(lootItem);
if(lootItem.getItemBase().isDiscRune() && !Mob.discDroppers.contains(mob))
Mob.AddDiscDropper(mob);
}
} }
public static void newFatePeddler(PlayerCharacter playerCharacter, Item gift) {
CharacterItemManager itemMan = playerCharacter.getCharItemManager();
if (itemMan == null)
return;
//check if player owns the gift he is trying to open
if (!itemMan.doesCharOwnThisItem(gift.getObjectUUID()))
return;
ItemBase ib = gift.getItemBase();
MobLoot winnings = null;
if (ib == null)
return;
switch (ib.getUUID()) {
case 971070: //wrapped rune
ItemBase runeBase = null;
int roll = ThreadLocalRandom.current().nextInt(static_rune_ids.size() + 1);
int itemId = static_rune_ids.get(0);
try {
itemId = static_rune_ids.get(roll);
}catch(Exception e){
}
runeBase = ItemBase.getItemBase(itemId);
if(runeBase != null) {
winnings = new MobLoot(playerCharacter, runeBase, 1, false);
}
break;
case 971012: //wrapped glass
int chance = ThreadLocalRandom.current().nextInt(100);
if(chance == 50){
int ID = 7000000;
int additional = ThreadLocalRandom.current().nextInt(0,28);
ID += (additional * 10);
ItemBase glassBase = ItemBase.getItemBase(ID);
if(glassBase != null) {
winnings = new MobLoot(playerCharacter, glassBase, 1, false);
ChatManager.chatSystemInfo(playerCharacter, "You've Won A " + glassBase.getName());
}
}else{
ChatManager.chatSystemInfo(playerCharacter, "Please Try Again!");
}
break;
}
if (winnings == null) {
itemMan.consume(gift);
itemMan.updateInventory();
return;
}
//early exit if the inventory of the player will not hold the item
if (!itemMan.hasRoomInventory(winnings.getItemBase().getWeight())) {
ErrorPopupMsg.sendErrorPopup(playerCharacter, 21);
return;
}
winnings.setIsID(true);
//remove gift from inventory
itemMan.consume(gift);
//add winnings to player inventory
Item playerWinnings = winnings.promoteToItem(playerCharacter);
itemMan.addItemToInventory(playerWinnings);
itemMan.updateInventory();
}
public static void peddleFate(PlayerCharacter playerCharacter, Item gift) { public static void peddleFate(PlayerCharacter playerCharacter, Item gift) {
//get table ID for the itembase ID //get table ID for the itembase ID
@@ -739,12 +392,12 @@ public enum LootManager {
//check if player owns the gift he is trying to open //check if player owns the gift he is trying to open
if (!itemMan.doesCharOwnThisItem(gift.getObjectUUID())) if (itemMan.doesCharOwnThisItem(gift.getObjectUUID()) == false)
return; return;
//roll 1-100 for the gen table selection //roll 1-100 for the gen table selection
int genRoll = ThreadLocalRandom.current().nextInt(94, 100) + 1; int genRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1);
GenTableEntry selectedRow = GenTableEntry.rollTable(tableID, genRoll, LootManager.NORMAL_DROP_RATE); GenTableEntry selectedRow = GenTableEntry.rollTable(tableID, genRoll, LootManager.NORMAL_DROP_RATE);
if(selectedRow == null) if(selectedRow == null)
@@ -760,22 +413,12 @@ public enum LootManager {
//create the item from the table, quantity is always 1 //create the item from the table, quantity is always 1
ItemBase ib = ItemBase.getItemBase(selectedItem.cacheID); MobLoot winnings = new MobLoot(playerCharacter, ItemBase.getItemBase(selectedItem.cacheID), 1, false);
if(ib.getUUID() == Warehouse.coalIB.getUUID()){
//no more coal, give gold instead
if (itemMan.getGoldInventory().getNumOfItems() + 250000 > 10000000) {
ErrorPopupMsg.sendErrorPopup(playerCharacter, 21);
return;
}
itemMan.addGoldToInventory(250000,false);
itemMan.updateInventory();
}else {
MobLoot winnings = new MobLoot(playerCharacter, ib, 1, false);
if (winnings == null) if (winnings == null)
return; return;
//early exit if the inventory of the player will not hold the item //early exit if the inventory of the player will not old the item
if (itemMan.hasRoomInventory(winnings.getItemBase().getWeight()) == false) { if (itemMan.hasRoomInventory(winnings.getItemBase().getWeight()) == false) {
ErrorPopupMsg.sendErrorPopup(playerCharacter, 21); ErrorPopupMsg.sendErrorPopup(playerCharacter, 21);
@@ -812,224 +455,3 @@ public enum LootManager {
itemMan.updateInventory(); itemMan.updateInventory();
} }
} }
public static int rollRandomItem(int itemTable){
int returnedID = ItemTableEntry.getRandomItem(itemTable);
return returnedID;
}
public static ItemBase getRandomVorg(ItemBase itemBase){
int roll = 0;
if(vorg_ha_uuids.contains(itemBase.getUUID())) {
roll = ThreadLocalRandom.current().nextInt(0, 9);
switch (roll) {
case 1:
return ItemBase.getItemBase(vorg_ha_uuids.get(0));
case 2:
return ItemBase.getItemBase(vorg_ha_uuids.get(1));
case 3:
return ItemBase.getItemBase(vorg_ha_uuids.get(2));
case 4:
return ItemBase.getItemBase(vorg_ha_uuids.get(3));
case 5:
return ItemBase.getItemBase(vorg_ha_uuids.get(4));
case 6:
return ItemBase.getItemBase(vorg_ha_uuids.get(5));
case 7:
return ItemBase.getItemBase(vorg_ha_uuids.get(6));
case 8:
return ItemBase.getItemBase(vorg_ha_uuids.get(7));
default:
return ItemBase.getItemBase(vorg_ha_uuids.get(8));
}
}
if(vorg_ma_uuids.contains(itemBase.getUUID())) {
roll = ThreadLocalRandom.current().nextInt(0, 8);
switch (roll) {
case 1:
return ItemBase.getItemBase(vorg_ma_uuids.get(0));
case 2:
return ItemBase.getItemBase(vorg_ma_uuids.get(1));
case 3:
return ItemBase.getItemBase(vorg_ma_uuids.get(2));
case 4:
return ItemBase.getItemBase(vorg_ma_uuids.get(3));
case 5:
return ItemBase.getItemBase(vorg_ma_uuids.get(4));
case 6:
return ItemBase.getItemBase(vorg_ma_uuids.get(5));
case 7:
return ItemBase.getItemBase(vorg_ma_uuids.get(6));
default:
return ItemBase.getItemBase(vorg_ma_uuids.get(7));
}
}
if(vorg_la_uuids.contains(itemBase.getUUID())) {
roll = ThreadLocalRandom.current().nextInt(0, 8);
switch (roll) {
case 1:
return ItemBase.getItemBase(vorg_la_uuids.get(0));
case 2:
return ItemBase.getItemBase(vorg_la_uuids.get(1));
case 3:
return ItemBase.getItemBase(vorg_la_uuids.get(2));
case 4:
return ItemBase.getItemBase(vorg_la_uuids.get(3));
case 5:
return ItemBase.getItemBase(vorg_la_uuids.get(4));
case 6:
return ItemBase.getItemBase(vorg_la_uuids.get(5));
case 7:
return ItemBase.getItemBase(vorg_la_uuids.get(6));
default:
return ItemBase.getItemBase(vorg_la_uuids.get(7));
}
}
if(vorg_cloth_uuids.contains(itemBase.getUUID())) {
roll = ThreadLocalRandom.current().nextInt(0, 5);
switch (roll) {
case 1:
return ItemBase.getItemBase(vorg_cloth_uuids.get(0));
case 2:
return ItemBase.getItemBase(vorg_cloth_uuids.get(1));
case 3:
return ItemBase.getItemBase(vorg_cloth_uuids.get(2));
case 4:
return ItemBase.getItemBase(vorg_cloth_uuids.get(3));
default:
return ItemBase.getItemBase(vorg_cloth_uuids.get(4));
}
}
return null;
}
public static void DropPresent(Mob mob){
int random = 971049 + ThreadLocalRandom.current().nextInt(24);
if (random > 971071)
random = 971071;
ItemBase present = ItemBase.getItemBase(random);
if (present != null) {
MobLoot toAdd = new MobLoot(mob, present, true);
if (toAdd != null)
mob.getCharItemManager().addItemToInventory(toAdd);
}
}
public static void GenerateStrongholdLoot(Mob mob, boolean commander, boolean epic) {
mob.getCharItemManager().clearInventory();
int multiplier = 1;
if (commander)
multiplier = 2;
if(epic)
multiplier = 10;
int high = 125000;
int low = 50000;
int gold = ThreadLocalRandom.current().nextInt(low, high + 1) * multiplier;
if (gold > 0) {
MobLoot goldAmount = new MobLoot(mob, gold);
mob.getCharItemManager().addItemToInventory(goldAmount);
}
//present drop chance for all
if (ThreadLocalRandom.current().nextInt(100) < 35)
DropPresent(mob);
//random contract drop chance for all
if (ThreadLocalRandom.current().nextInt(100) < 40) {
int contractTableID = 250;
contractTableID += ThreadLocalRandom.current().nextInt(0, 11);
if (contractTableID > 259)
contractTableID = 659;
int id = rollRandomItem(contractTableID);
ItemBase ib = ItemBase.getItemBase(id);
if (ib != null) {
MobLoot contract = new MobLoot(mob, ib, true);
if (contract != null)
mob.getCharItemManager().addItemToInventory(contract);
}
}
//special commander drop chances
if (commander)
GenerateCommanderLoot(mob,false);
//special epic drop chances
if (epic) {
GenerateCommanderLoot(mob, true);
GenerateCommanderLoot(mob,false);
}
}
public static void GenerateCommanderLoot(Mob mob, boolean epic){
//present chance
if (ThreadLocalRandom.current().nextInt(100) < 25)
DropPresent(mob);
//present chance
if (ThreadLocalRandom.current().nextInt(100) < 25)
DropPresent(mob);
//chance for glass
if (ThreadLocalRandom.current().nextInt(100) < 75) {
int glassID = rollRandomItem(126);
ItemBase glassItem = ItemBase.getItemBase(glassID);
if (glassItem != null) {
MobLoot toAdd2 = new MobLoot(mob, glassItem, true);
if (toAdd2 != null)
mob.getCharItemManager().addItemToInventory(toAdd2);
}
}
//chance for disc
if (ThreadLocalRandom.current().nextInt(100) < 75) {
int discID = rollRandomItem(3202);
ItemBase discItem = ItemBase.getItemBase(discID);
if (discItem != null) {
MobLoot toAdd3 = new MobLoot(mob, discItem, true);
if (toAdd3 != null)
mob.getCharItemManager().addItemToInventory(toAdd3);
}
}
//chance for stat rune
if (ThreadLocalRandom.current().nextInt(100) < 75) {
int runeID = rollRandomItem(3201);
ItemBase runeItem = ItemBase.getItemBase(runeID);
if (runeItem != null) {
MobLoot toAdd4 = new MobLoot(mob, runeItem, true);
if (toAdd4 != null)
mob.getCharItemManager().addItemToInventory(toAdd4);
}
}
if(epic){
int contractTableID = 250;
contractTableID += ThreadLocalRandom.current().nextInt(0, 11);
if (contractTableID > 259)
contractTableID = 659;
int id = rollRandomItem(contractTableID);
ItemBase ib = ItemBase.getItemBase(id);
if (ib != null) {
MobLoot contract = new MobLoot(mob, ib, true);
if (contract != null)
mob.getCharItemManager().addItemToInventory(contract);
}
}
}
}
+108 -15
View File
@@ -24,7 +24,7 @@ public enum MaintenanceManager {
public static void setMaintDateTime(Building building, LocalDateTime maintDate) { public static void setMaintDateTime(Building building, LocalDateTime maintDate) {
building.maintDateTime = maintDate.withHour(1).withMinute(0).withSecond(0); building.maintDateTime = maintDate;
DbManager.BuildingQueries.updateMaintDate(building); DbManager.BuildingQueries.updateMaintDate(building);
} }
@@ -49,15 +49,19 @@ public enum MaintenanceManager {
if (chargeUpkeep(building) == false) if (chargeUpkeep(building) == false)
derankList.add(building); derankList.add(building);
else
setMaintDateTime(building, LocalDateTime.now().plusDays(7));
} }
// Reset maintenance dates for these buildings
for (Building building : maintList) {
setMaintDateTime(building, LocalDateTime.now().plusDays(7));
for (Building building : derankList) {
building.destroyOrDerank(null);
if(building.getRank() > 0)
setMaintDateTime(building, LocalDateTime.now().plusDays(1));
} }
// Derak or destroy buildings that did not
// have funds available.
for (Building building : derankList)
building.destroyOrDerank(null);
Logger.info("Structures: " + buildingList.size() + " Maint: " + maintList.size() + " Derank: " + derankList.size()); Logger.info("Structures: " + buildingList.size() + " Maint: " + maintList.size() + " Derank: " + derankList.size());
} }
@@ -94,10 +98,6 @@ public enum MaintenanceManager {
continue; continue;
} }
//only ToL pays maintenance
if(building.getBlueprint().getBuildingGroup() != null && !building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.TOL))
continue;
// No maintenance on banestones omfg // No maintenance on banestones omfg
if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.BANESTONE)) if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.BANESTONE))
@@ -122,9 +122,9 @@ public enum MaintenanceManager {
//no maintenance if day of week doesnt match //no maintenance if day of week doesnt match
//if (LocalDateTime.now().getDayOfWeek().ordinal() != building.maintDateTime.getDayOfWeek().ordinal()) { if (LocalDateTime.now().getDayOfWeek().ordinal() != building.maintDateTime.getDayOfWeek().ordinal()) {
// continue; continue;
//} }
// Add building to maintenance queue // Add building to maintenance queue
maintList.add(building); maintList.add(building);
@@ -186,8 +186,49 @@ public enum MaintenanceManager {
// If this is an R8 tree, validate that we can // If this is an R8 tree, validate that we can
// cover the resources required // cover the resources required
if (building.getRank() == 8) {
hasResources = true;
if (warehouse == null)
hasResources = false;
else {
resourceValue = warehouse.getResources().get(Warehouse.stoneIB);
if (resourceValue < 1500)
hasResources = false;
resourceValue = warehouse.getResources().get(Warehouse.lumberIB);
if (resourceValue < 1500)
hasResources = false;
resourceValue = warehouse.getResources().get(Warehouse.galvorIB);
if (resourceValue < 5)
hasResources = false;
resourceValue = warehouse.getResources().get(Warehouse.wormwoodIB);
if (resourceValue < 5)
hasResources = false;
}
}
// Validation completed but has failed. We can derank
// the target building and early exit
if ((hasFunds == false) ||
((building.getRank() == 8) && !hasResources)) {
// Add cash back to strongbox for lost rank if the building isn't being destroyed
// and it's not an R8 deranking
if ((building.getRank() > 1) && (building.getRank() < 8)) {
building.setStrongboxValue(building.getStrongboxValue() + building.getBlueprint().getRankCost(Math.min(building.getRank(), 7)));
}
if (hasFunds == false) {
return false; // Early exit for having failed to meet maintenance return false; // Early exit for having failed to meet maintenance
} }
@@ -212,6 +253,58 @@ public enum MaintenanceManager {
} }
} }
// Early exit as we're done if we're not an R8 tree
if (building.getRank() < 8)
return true;
// Now for the resources if it's an R8 tree
// Withdraw Stone
resourceValue = warehouse.getResources().get(Warehouse.stoneIB);
if (DbManager.WarehouseQueries.updateStone(warehouse, resourceValue - 1500) == true) {
warehouse.getResources().put(Warehouse.stoneIB, resourceValue - 1500);
warehouse.AddTransactionToWarehouse(Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.STONE, 1500);
} else {
Logger.error("stone update failed for warehouse of UUID:" + warehouse.getObjectUUID());
return true;
}
// Withdraw Lumber
resourceValue = warehouse.getResources().get(Warehouse.lumberIB);
if (DbManager.WarehouseQueries.updateLumber(warehouse, resourceValue - 1500) == true) {
warehouse.getResources().put(Warehouse.lumberIB, resourceValue - 1500);
warehouse.AddTransactionToWarehouse(Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.LUMBER, 1500);
} else {
Logger.error("lumber update failed for warehouse of UUID:" + warehouse.getObjectUUID());
return true;
}
// Withdraw Galvor
resourceValue = warehouse.getResources().get(Warehouse.galvorIB);
if (DbManager.WarehouseQueries.updateGalvor(warehouse, resourceValue - 5) == true) {
warehouse.getResources().put(Warehouse.galvorIB, resourceValue - 5);
warehouse.AddTransactionToWarehouse(Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.GALVOR, 5);
} else {
Logger.error("galvor update failed for warehouse of UUID:" + warehouse.getObjectUUID());
return true;
}
resourceValue = warehouse.getResources().get(Warehouse.wormwoodIB);
if (DbManager.WarehouseQueries.updateWormwood(warehouse, resourceValue - 5) == true) {
warehouse.getResources().put(Warehouse.wormwoodIB, resourceValue - 5);
warehouse.AddTransactionToWarehouse(Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.WORMWOOD, 5);
} else {
Logger.error("wyrmwood update failed for warehouse of UUID:" + warehouse.getObjectUUID());
}
return true; return true;
} }
+5 -9
View File
@@ -67,10 +67,8 @@ public enum MovementManager {
return; return;
if (toMove.getObjectType().equals(GameObjectType.PlayerCharacter)) { if (toMove.getObjectType().equals(GameObjectType.PlayerCharacter)) {
if (((PlayerCharacter) toMove).isCasting()) { if (((PlayerCharacter) toMove).isCasting())
((PlayerCharacter) toMove).updateLocation(); ((PlayerCharacter) toMove).update();
((PlayerCharacter) toMove).updateMovementState();
}
} }
@@ -98,7 +96,7 @@ public enum MovementManager {
if (!toMove.isMoving()) if (!toMove.isMoving())
toMove.resetLastSetLocUpdate(); toMove.resetLastSetLocUpdate();
else else
toMove.update(false); toMove.update();
// Update movement for the player // Update movement for the player
@@ -353,7 +351,7 @@ public enum MovementManager {
ChatManager.chatSystemInfo((PlayerCharacter) ac, "Finished Alt change, setting the end location to " + ac.getEndLoc().getX() + ' ' + ac.getEndLoc().getZ() + " moving=" + ac.isMoving() + " and current location is " + curLoc.getX() + ' ' + curLoc.getZ()); ChatManager.chatSystemInfo((PlayerCharacter) ac, "Finished Alt change, setting the end location to " + ac.getEndLoc().getX() + ' ' + ac.getEndLoc().getZ() + " moving=" + ac.isMoving() + " and current location is " + curLoc.getX() + ' ' + curLoc.getZ());
//Send run/walk/sit/stand to tell the client we are flying / landing etc //Send run/walk/sit/stand to tell the client we are flying / landing etc
ac.update(false); ac.update();
ac.stopMovement(ac.getLoc()); ac.stopMovement(ac.getLoc());
if (ac.isAlive()) if (ac.isAlive())
MovementManager.sendRWSSMsg(ac); MovementManager.sendRWSSMsg(ac);
@@ -410,9 +408,7 @@ public enum MovementManager {
if (bonus.getBool(ModType.Stunned, SourceType.None) || bonus.getBool(ModType.CannotMove, SourceType.None)) if (bonus.getBool(ModType.Stunned, SourceType.None) || bonus.getBool(ModType.CannotMove, SourceType.None))
continue; continue;
//member.update(false); member.update();
member.updateLocation();
member.updateMovementState();
// All checks passed, let's move the player // All checks passed, let's move the player
+68 -14
View File
@@ -23,14 +23,6 @@ public enum NPCManager {
NPC_MANAGER; NPC_MANAGER;
public static HashMap<Integer, ArrayList<Integer>> _runeSetMap = new HashMap<>(); 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) { public static void applyRuneSetEffects(Mob mob) {
// Early exit // Early exit
@@ -127,10 +119,12 @@ public enum NPCManager {
DbManager.removeFromCache(necroPet); DbManager.removeFromCache(necroPet);
PlayerCharacter petOwner = necroPet.getOwner();
PlayerCharacter petOwner = (PlayerCharacter) necroPet.guardCaptain;
if (petOwner != null) { if (petOwner != null) {
necroPet.setOwner(null);
necroPet.guardCaptain = null;
petOwner.setPet(null); petOwner.setPet(null);
if (updateOwner == false) if (updateOwner == false)
@@ -228,12 +222,14 @@ public enum NPCManager {
WorldGrid.removeObject(toRemove); WorldGrid.removeObject(toRemove);
DbManager.removeFromCache(toRemove); DbManager.removeFromCache(toRemove);
PlayerCharacter petOwner = toRemove.getOwner();
PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain;
if (petOwner != null) { if (petOwner != null) {
petOwner.setPet(null); petOwner.setPet(null);
toRemove.setOwner(null);
toRemove.guardCaptain = null;
PetMsg petMsg = new PetMsg(5, null); PetMsg petMsg = new PetMsg(5, null);
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg); Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
@@ -340,9 +336,18 @@ public enum NPCManager {
else else
buildingSlot = BuildingManager.getAvailableSlot(abstractCharacter.building); buildingSlot = BuildingManager.getAvailableSlot(abstractCharacter.building);
//if (buildingSlot == -1) // Override slot for siege engines
//Logger.error("No available slot for NPC: " + abstractCharacter.getObjectUUID());
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 // Override bind and location for this npc derived
@@ -370,4 +375,53 @@ public enum NPCManager {
return buildingSlot; 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;
}
}
}
} }
+39 -389
View File
@@ -10,7 +10,6 @@ package engine.gameManager;
import engine.Enum.*; import engine.Enum.*;
import engine.InterestManagement.HeightMap; import engine.InterestManagement.HeightMap;
import engine.InterestManagement.InterestManager;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.db.handlers.dbEffectsBaseHandler; import engine.db.handlers.dbEffectsBaseHandler;
import engine.db.handlers.dbPowerHandler; import engine.db.handlers.dbPowerHandler;
@@ -164,28 +163,6 @@ public enum PowersManager {
public static void usePower(final PerformActionMsg msg, ClientConnection origin, public static void usePower(final PerformActionMsg msg, ClientConnection origin,
boolean sendCastToSelf) { boolean sendCastToSelf) {
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
if(pc == null)
return;
if(!pc.isFlying() && powersBaseByToken.get(msg.getPowerUsedID()) != null && powersBaseByToken.get(msg.getPowerUsedID()).isSpell) //cant be sitting if flying
CombatManager.toggleSit(false,origin);
if(pc.isMoving())
pc.stopMovement(pc.getMovementLoc());
if(msg.getPowerUsedID() == 429429978){
applyPower(origin.getPlayerCharacter(),origin.getPlayerCharacter(),origin.getPlayerCharacter().getLoc(),429429978,msg.getNumTrains(),false);
origin.getPlayerCharacter().getRecycleTimers().remove(429429978);
return;
}
if(!origin.getPlayerCharacter().getPowers().containsKey(msg.getPowerUsedID())){
Logger.error(origin.getPlayerCharacter().getFirstName() + " attempted to cast a power they do not have");
return;
}
if (usePowerA(msg, origin, sendCastToSelf)) { if (usePowerA(msg, origin, sendCastToSelf)) {
// Cast failed for some reason, reset timer // Cast failed for some reason, reset timer
@@ -194,10 +171,13 @@ public enum PowersManager {
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
// Send Fail to cast message // Send Fail to cast message
PlayerCharacter pc = SessionManager
.getPlayerCharacter(origin);
if (pc != null) { if (pc != null) {
sendPowerMsg(pc, 2, msg); sendPowerMsg(pc, 2, msg);
if (pc.isCasting()) { if (pc.isCasting()) {
pc.update(false); pc.update();
} }
pc.setIsCasting(false); pc.setIsCasting(false);
@@ -212,8 +192,7 @@ public enum PowersManager {
msg.setUnknown04(1); msg.setUnknown04(1);
if (useMobPowerA(msg, caster)) { if (useMobPowerA(msg, caster)) {
if(pb.token == -1994153779) //sendMobPowerMsg(caster,2,msg); //Lol wtf was i thinking sending msg's to mobs... ZZZZ
InterestManager.setObjectDirty(caster);
} }
} }
@@ -226,48 +205,6 @@ public enum PowersManager {
boolean CSRCast = false; boolean CSRCast = false;
if(msg.getPowerUsedID() == 430628895) {
boolean failed = false;// group teleport
City city = ZoneManager.getCityAtLocation(playerCharacter.loc);
if (city == null) {
failed = true;
}//else{
// Bane bane = city.getBane();
// if (bane == null) {
// failed = true;
// }else{
// if(!bane.getSiegePhase().equals(SiegePhase.WAR)){
// failed = true;
// }
// }
//}
if(failed){
//check to see if we are at an active mine
Zone zone = ZoneManager.findSmallestZone(playerCharacter.loc);
if(zone != null){
Mine mine = null;
for(Building building : zone.zoneBuildingSet){
if(building.getBlueprint().getBuildingGroup().equals(BuildingGroup.MINE)){
mine = Mine.getMineFromTower(building.getObjectUUID());
}
}
if(mine != null){
failed = !mine.isActive;
}
}
}
if(failed) {
playerCharacter.setIsCasting(false);
RecyclePowerMsg recyclePowerMsg = new RecyclePowerMsg(msg.getPowerUsedID());
Dispatch dispatch = Dispatch.borrow(playerCharacter, recyclePowerMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
return false;
}
}
if (MBServerStatics.POWERS_DEBUG) { if (MBServerStatics.POWERS_DEBUG) {
ChatManager.chatSayInfo( ChatManager.chatSayInfo(
@@ -304,7 +241,6 @@ public enum PowersManager {
// get power // get power
PowersBase pb = PowersManager.powersBaseByToken.get(msg.getPowerUsedID()); PowersBase pb = PowersManager.powersBaseByToken.get(msg.getPowerUsedID());
if (pb == null) { if (pb == null) {
ChatManager.chatSayInfo(playerCharacter, ChatManager.chatSayInfo(playerCharacter,
"This power is not implemented yet."); "This power is not implemented yet.");
@@ -316,35 +252,6 @@ public enum PowersManager {
// return false; // return false;
} }
//check for movement buffs while flying
if(playerCharacter.isFlying()) {
switch(pb.token){
case 429005674:
case 429505739:
case 431054700:
case 428005600:
case 431610080:
case 427935608:
case 427857146:
case 427988218:
case 431854842:
case 421074170:
case 429611355:
case 428955899:
case 1794395699:
case 429428796:
case 1514898036:
ChatManager.chatSystemInfo(playerCharacter, "You Cannot Fly While Having A MovementBuff");
//resync stamina
playerCharacter.setStamina(playerCharacter.getStamina(), playerCharacter);
// Update all surrounding clients.
TargetedActionMsg cmm = new TargetedActionMsg(playerCharacter);
DispatchMessage.dispatchMsgToInterestArea(playerCharacter, cmm, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
return true;
}
}
if (playerCharacter.getLastPower() != null) if (playerCharacter.getLastPower() != null)
return true; return true;
@@ -352,7 +259,6 @@ public enum PowersManager {
// Check powers for normal users // Check powers for normal users
if(msg.getPowerUsedID() != 421084024) {
if (playerCharacter.getPowers() == null || !playerCharacter.getPowers().containsKey(msg.getPowerUsedID())) if (playerCharacter.getPowers() == null || !playerCharacter.getPowers().containsKey(msg.getPowerUsedID()))
if (!playerCharacter.isCSR()) { if (!playerCharacter.isCSR()) {
if (!MBServerStatics.POWERS_DEBUG) { if (!MBServerStatics.POWERS_DEBUG) {
@@ -363,7 +269,7 @@ public enum PowersManager {
} }
} else } else
CSRCast = true; CSRCast = true;
}
// get numTrains for power // get numTrains for power
int trains = msg.getNumTrains(); int trains = msg.getNumTrains();
@@ -373,14 +279,6 @@ public enum PowersManager {
msg.setNumTrains(trains); msg.setNumTrains(trains);
} }
//double stack point values for some useless disc spells
switch(pb.token){
case 429420458: // BH eyes
case 429601664: // huntsman skin the beast
msg.setNumTrains(msg.getNumTrains() * 2);
break;
}
// can't go over total trains by player // can't go over total trains by player
if (playerCharacter.getPowers() != null && playerCharacter.getPowers().containsKey(msg.getPowerUsedID())) { if (playerCharacter.getPowers() != null && playerCharacter.getPowers().containsKey(msg.getPowerUsedID())) {
CharacterPower cp = playerCharacter.getPowers().get(msg.getPowerUsedID()); CharacterPower cp = playerCharacter.getPowers().get(msg.getPowerUsedID());
@@ -472,20 +370,15 @@ public enum PowersManager {
float range = pb.getRange(); float range = pb.getRange();
// verify target is in range // verify target is in range
if(pb.token != 429396028) {
if (verifyInvalidRange(playerCharacter, target, range)) if (verifyInvalidRange(playerCharacter, target, range))
// (pc.getLoc().distance(target.getLoc()) > pb.getRange()) { // (pc.getLoc().distance(target.getLoc()) > pb.getRange()) {
// TODO send message that target is out of range // TODO send message that target is out of range
return true; return true;
// verify target is valid type // verify target is valid type
if (!validateTarget(target, playerCharacter, pb)) if (!validateTarget(target, playerCharacter, pb))
return true; return true;
}else{
pb.isSpell = false;
}
if (AbstractWorldObject.IsAbstractCharacter(target)) if (AbstractWorldObject.IsAbstractCharacter(target))
@@ -516,23 +409,6 @@ public enum PowersManager {
} }
} }
if(!passed){
if (playerCharacter.getRace().getName().contains("Shade")) {
if(playerCharacter.getHidden() > 0){
switch(msg.getPowerUsedID()){
case -1851459567:
case 2094922127:
case -355707373:
case 246186475:
case 666419835:
case 1480354319:
passed = true;
break;
}
}
}
}
if (!passed) if (!passed)
return true; return true;
} }
@@ -611,6 +487,7 @@ public enum PowersManager {
// Validity checks passed, move on to casting spell // Validity checks passed, move on to casting spell
//get caster's live counter //get caster's live counter
int casterLiveCounter = playerCharacter.getLiveCounter(); int casterLiveCounter = playerCharacter.getLiveCounter();
// run recycle job for when cast is available again, don't bother adding the timer for CSRs // run recycle job for when cast is available again, don't bother adding the timer for CSRs
if (time > 0) { if (time > 0) {
FinishRecycleTimeJob frtj = new FinishRecycleTimeJob(playerCharacter, msg); FinishRecycleTimeJob frtj = new FinishRecycleTimeJob(playerCharacter, msg);
@@ -637,7 +514,7 @@ public enum PowersManager {
// make person casting stand up if spell (unless they're casting a chant which does not make them stand up) // make person casting stand up if spell (unless they're casting a chant which does not make them stand up)
if (pb.isSpell() && !pb.isChant() && playerCharacter.isSit()) { if (pb.isSpell() && !pb.isChant() && playerCharacter.isSit()) {
playerCharacter.update(false); playerCharacter.update();
playerCharacter.setSit(false); playerCharacter.setSit(false);
UpdateStateMsg updateStateMsg = new UpdateStateMsg(playerCharacter); UpdateStateMsg updateStateMsg = new UpdateStateMsg(playerCharacter);
DispatchMessage.dispatchMsgToInterestArea(playerCharacter, updateStateMsg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); DispatchMessage.dispatchMsgToInterestArea(playerCharacter, updateStateMsg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
@@ -645,12 +522,10 @@ public enum PowersManager {
} }
// update cast (use skill) fail condition // update cast (use skill) fail condition
if(pb.token != 429396028 && pb.breaksForm) {
playerCharacter.cancelOnCast(); playerCharacter.cancelOnCast();
}
// update castSpell (use spell) fail condition if spell // update castSpell (use spell) fail condition if spell
if (pb.isSpell() && pb.breaksForm) if (pb.isSpell())
playerCharacter.cancelOnSpell(); playerCharacter.cancelOnSpell();
// get cast time in ms. // get cast time in ms.
@@ -660,12 +535,13 @@ public enum PowersManager {
if (time > 100) { if (time > 100) {
playerCharacter.update(false); playerCharacter.update();
playerCharacter.setIsCasting(true); playerCharacter.setIsCasting(true);
} }
playerCharacter.setLastMovementState(playerCharacter.getMovementState()); playerCharacter.setLastMovementState(playerCharacter.getMovementState());
// run timer job to end cast // run timer job to end cast
if (time < 1) // run immediately if (time < 1) // run immediately
finishUsePower(copyMsg, playerCharacter, casterLiveCounter, targetLiveCounter); finishUsePower(copyMsg, playerCharacter, casterLiveCounter, targetLiveCounter);
@@ -791,11 +667,10 @@ public enum PowersManager {
// make person casting stand up if spell (unless they're casting a chant which does not make them stand up) // make person casting stand up if spell (unless they're casting a chant which does not make them stand up)
// update cast (use skill) fail condition // update cast (use skill) fail condition
if(pb.breaksForm)
caster.cancelOnCast(); caster.cancelOnCast();
// update castSpell (use spell) fail condition if spell // update castSpell (use spell) fail condition if spell
if (pb.isSpell() && pb.breaksForm) if (pb.isSpell())
caster.cancelOnSpell(); caster.cancelOnSpell();
// get cast time in ms. // get cast time in ms.
@@ -831,37 +706,8 @@ public enum PowersManager {
if (playerCharacter == null || msg == null) if (playerCharacter == null || msg == null)
return; return;
//handle sprint for bard sprint
if(msg.getPowerUsedID() == 429005674){
msg.setPowerUsedID(429611355);
}
//handle root and snare break for wildkin's chase
if(msg.getPowerUsedID() == 429494441) {
playerCharacter.removeEffectBySource(EffectSourceType.Root,40,true);
playerCharacter.removeEffectBySource(EffectSourceType.Snare,40,true);
}
//handle power block portion for shade hide
if(playerCharacter.getRace().getName().contains("Shade")) {
if (msg.getPowerUsedID() == 429407306 || msg.getPowerUsedID() == 429495514) {
int trains = msg.getNumTrains() - 1;
if (trains < 1)
trains = 1;
applyPower(playerCharacter, playerCharacter, playerCharacter.loc, 429397210, trains, false);
playerCharacter.removeEffectBySource(EffectSourceType.Invisibility,40,true);
applyPower(playerCharacter, playerCharacter, playerCharacter.loc, msg.getPowerUsedID(), msg.getNumTrains(), false);
}
}
if(msg.getTargetType() == GameObjectType.PlayerCharacter.ordinal()) {
PlayerCharacter target = PlayerCharacter.getPlayerCharacter(msg.getTargetID());
if (msg.getPowerUsedID() == 429601664)
if(target.getPromotionClassID() != 2516)//templar
PlayerCharacter.getPlayerCharacter(msg.getTargetID()).removeEffectBySource(EffectSourceType.Transform, msg.getNumTrains(), true);
}
if (playerCharacter.isCasting()) { if (playerCharacter.isCasting()) {
playerCharacter.update(false); playerCharacter.update();
playerCharacter.updateStamRegen(-100); playerCharacter.updateStamRegen(-100);
} }
@@ -901,9 +747,6 @@ public enum PowersManager {
return; return;
} }
if(pb.targetSelf)
msg.setTargetID(playerCharacter.getObjectUUID());
int trains = msg.getNumTrains(); int trains = msg.getNumTrains();
// verify player is not stunned or power type is blocked // verify player is not stunned or power type is blocked
@@ -966,7 +809,6 @@ public enum PowersManager {
} }
float range = pb.getRange() + speedRange; float range = pb.getRange() + speedRange;
if(pb.token != 429396028) {
if (verifyInvalidRange(playerCharacter, mainTarget, range)) { if (verifyInvalidRange(playerCharacter, mainTarget, range)) {
@@ -975,7 +817,7 @@ public enum PowersManager {
} }
// (pc.getLoc().distance(target.getLoc()) > pb.getRange()) { // (pc.getLoc().distance(target.getLoc()) > pb.getRange()) {
// TODO send message that target is out of range // TODO send message that target is out of range
}
} }
@@ -997,8 +839,6 @@ public enum PowersManager {
return; return;
} }
playerCharacter.setHateValue(pb.getHateValue(trains));
//Send Cast Message. //Send Cast Message.
// PerformActionMsg castMsg = new PerformActionMsg(msg); // PerformActionMsg castMsg = new PerformActionMsg(msg);
// castMsg.setNumTrains(9999); // castMsg.setNumTrains(9999);
@@ -1049,8 +889,6 @@ public enum PowersManager {
//Power is aiding a target, handle aggro if combat target is a Mob. //Power is aiding a target, handle aggro if combat target is a Mob.
if (!pb.isHarmful() && target.getObjectType() == GameObjectType.PlayerCharacter) { if (!pb.isHarmful() && target.getObjectType() == GameObjectType.PlayerCharacter) {
PlayerCharacter pcTarget = (PlayerCharacter) target; PlayerCharacter pcTarget = (PlayerCharacter) target;
if (!pb.isHarmful())
Mob.HandleAssistedAggro(playerCharacter, pcTarget);
} }
// update target of used power timer // update target of used power timer
@@ -1391,7 +1229,7 @@ public enum PowersManager {
PlayerCharacter target = SessionManager PlayerCharacter target = SessionManager
.getPlayerCharacterByLowerCaseName(msg.getTargetName()); .getPlayerCharacterByLowerCaseName(msg.getTargetName());
if (target == null || target.equals(pc)) { if (target == null || target.equals(pc) || target.isCombat()) {
if (target == null) // Player not found. Send not found message if (target == null) // Player not found. Send not found message
ChatManager.chatInfoError(pc, ChatManager.chatInfoError(pc,
@@ -1495,16 +1333,6 @@ public enum PowersManager {
else else
duration = 45000; // Belgosh Summons, 45 seconds duration = 45000; // Belgosh Summons, 45 seconds
boolean enemiesNear = false;
for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(pc.loc,MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_PLAYER)){
PlayerCharacter playerCharacter = (PlayerCharacter)awo;
if(!playerCharacter.guild.getNation().equals(pc.guild.getNation())){
enemiesNear = true;
}
}
if(enemiesNear && !pc.isInSafeZone())
duration += 60000;
// Teleport to summoners location // Teleport to summoners location
FinishSummonsJob fsj = new FinishSummonsJob(source, pc); FinishSummonsJob fsj = new FinishSummonsJob(source, pc);
@@ -1630,28 +1458,8 @@ public enum PowersManager {
} }
// create list of characters // create list of characters
HashSet<AbstractCharacter> trackChars; HashSet<AbstractCharacter> trackChars = RangeBasedAwo.getTrackList(
allTargets, playerCharacter, maxTargets);
PowersBase trackPower = PowersManager.getPowerByToken(msg.getPowerToken());
if(trackPower != null && trackPower.category.equals("TRACK")){
trackChars = getTrackList(playerCharacter);
}else{
trackChars = RangeBasedAwo.getTrackList(allTargets, playerCharacter, maxTargets);
}
//switch(msg.getPowerToken()){
// case 431511776: // Hunt Foe Huntress
// case 429578587: // Hunt Foe Scout
// case 429503360: // Track Huntsman
// case 44106356: //
// trackChars = getTrackList(playerCharacter);
// break;
// default:
// trackChars = RangeBasedAwo.getTrackList(allTargets, playerCharacter, maxTargets);
// break;
//}
TrackWindowMsg trackWindowMsg = new TrackWindowMsg(msg); TrackWindowMsg trackWindowMsg = new TrackWindowMsg(msg);
@@ -1664,30 +1472,6 @@ public enum PowersManager {
} }
public static HashSet<AbstractCharacter> getTrackList(PlayerCharacter tracker){
HashSet<AbstractCharacter> list = new HashSet<AbstractCharacter>();
HashSet<AbstractWorldObject> shortList = WorldGrid.getObjectsInRangePartial(tracker.loc,MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_PLAYER);
HashSet<AbstractWorldObject> fullList = WorldGrid.getObjectsInRangePartial(tracker.loc,1408, MBServerStatics.MASK_PLAYER);
ArrayList<Guild> guildsPresent = new ArrayList<>();
for(AbstractWorldObject awo : shortList){
PlayerCharacter pc = (PlayerCharacter)awo;
if(!guildsPresent.contains(pc.guild.getNation())){
guildsPresent.add(pc.guild.getNation());
}
}
for(AbstractWorldObject awo : fullList){
if(awo.equals(tracker))
continue;
PlayerCharacter pc = (PlayerCharacter)awo;
if(!pc.isAlive())
continue;
if(guildsPresent.contains(pc.guild.getNation()))
list.add(pc);
}
return list;
}
private static void sendRecyclePower(int token, ClientConnection origin) { private static void sendRecyclePower(int token, ClientConnection origin) {
RecyclePowerMsg recyclePowerMsg = new RecyclePowerMsg(token); RecyclePowerMsg recyclePowerMsg = new RecyclePowerMsg(token);
@@ -2401,7 +2185,7 @@ public enum PowersManager {
// set player is not casting for regens // set player is not casting for regens
if (pc.isCasting()) { if (pc.isCasting()) {
pc.update(false); pc.update();
} }
pc.setIsCasting(false); pc.setIsCasting(false);
@@ -2443,8 +2227,7 @@ public enum PowersManager {
public static boolean testAttack(PlayerCharacter pc, AbstractWorldObject awo, public static boolean testAttack(PlayerCharacter pc, AbstractWorldObject awo,
PowersBase pb, PerformActionMsg msg) { PowersBase pb, PerformActionMsg msg) {
// Get defense for target // Get defense for target
//float atr = CharacterSkill.getATR(pc, pb.getSkillName()); float atr = CharacterSkill.getATR(pc, pb.getSkillName());
float atr = PlayerCombatStats.getSpellAtr(pc, pb);
float defense; float defense;
if (AbstractWorldObject.IsAbstractCharacter(awo)) { if (AbstractWorldObject.IsAbstractCharacter(awo)) {
@@ -2454,26 +2237,28 @@ public enum PowersManager {
defense = 0f; defense = 0f;
// Get hit chance // Get hit chance
//if (pc.getDebug(16)) { if (pc.getDebug(16)) {
// String smsg = "ATR: " + atr + ", Defense: " + defense; String smsg = "ATR: " + atr + ", Defense: " + defense;
// ChatManager.chatSystemInfo(pc, smsg); ChatManager.chatSystemInfo(pc, smsg);
//} }
//int chance; int chance;
//if (atr > defense || defense == 0) if (atr > defense || defense == 0)
// chance = 94; chance = 94;
//else { else {
// float dif = atr / defense; float dif = atr / defense;
// if (dif <= 0.8f) if (dif <= 0.8f)
// chance = 4; chance = 4;
// else else
// chance = ((int) (450 * (dif - 0.8f)) + 4); chance = ((int) (450 * (dif - 0.8f)) + 4);
//} }
// calculate hit/miss // calculate hit/miss
int roll = ThreadLocalRandom.current().nextInt(100);
if (CombatManager.LandHit((int)atr,(int)defense)) { boolean disable = true;
if (roll < chance) {
// Hit, check if dodge kicked in // Hit, check if dodge kicked in
if (awo instanceof AbstractCharacter) { if (awo instanceof AbstractCharacter) {
AbstractCharacter tarAc = (AbstractCharacter) awo; AbstractCharacter tarAc = (AbstractCharacter) awo;
@@ -2485,13 +2270,6 @@ public enum PowersManager {
dodgeMsg.setTargetID(awo.getObjectUUID()); dodgeMsg.setTargetID(awo.getObjectUUID());
sendPowerMsg(pc, 4, dodgeMsg); sendPowerMsg(pc, 4, dodgeMsg);
return true; return true;
} else if (testPassive(pc, tarAc, "Block")) {
// Dodge fired, send dodge message
PerformActionMsg dodgeMsg = new PerformActionMsg(msg);
dodgeMsg.setTargetType(awo.getObjectType().ordinal());
dodgeMsg.setTargetID(awo.getObjectUUID());
sendPowerMsg(pc, 4, dodgeMsg);
return true;
} }
} }
return false; return false;
@@ -2539,12 +2317,7 @@ public enum PowersManager {
if (AbstractWorldObject.IsAbstractCharacter(awo)) { if (AbstractWorldObject.IsAbstractCharacter(awo)) {
AbstractCharacter tarAc = (AbstractCharacter) awo; AbstractCharacter tarAc = (AbstractCharacter) awo;
// Handle Dodge passive // Handle Dodge passive
boolean passiveFired = false; return testPassive(caster, tarAc, "Dodge");
passiveFired = testPassive(caster, tarAc, "Dodge");
if(!passiveFired)
passiveFired = testPassive(caster, tarAc, "Block");
return passiveFired;
} }
return false; return false;
} else } else
@@ -2785,9 +2558,7 @@ public enum PowersManager {
} }
public static void cancelOnStun(AbstractCharacter ac) { public static void cancelOnStun(AbstractCharacter ac) {
if(ac.getObjectType().equals(GameObjectType.PlayerCharacter)){
//PlayerCharacter.GroundPlayer((PlayerCharacter)ac);
}
} }
private static PowersBase getLastPower(AbstractCharacter ac) { private static PowersBase getLastPower(AbstractCharacter ac) {
@@ -2933,127 +2704,6 @@ public enum PowersManager {
} }
} }
public static boolean breakForm(int token) {
switch (token) {
case 429505865:
case 429407561:
case 429492073:
case 429644123:
case 429393769:
case 429545819:
case 429426537:
case 429590377:
case 429508425:
case 429541193:
case 429573961:
case 427924330:
case 429402918:
case 429545688:
case 429005674:
case 429637823:
case 429590426:
case 428066972:
case 429441862:
case 431611756:
case 431578988:
case 429502506:
case 429398191:
case 429447384:
case 428892191:
case 431579167:
case 430977067:
case 429409100:
case 429441868:
case 429594877:
case 427908971:
case 683741153:
case 429770569:
case 429452379:
case 429605055:
case 429086971:
case 429443230:
case 429505400:
case 429492122:
case 429643992:
case 550062236:
case 429498252:
case 429611224:
case 429441834:
case 428918940:
case 429633739:
case 429633579:
case 429568043:
case 429048646:
case 428392639:
case 428425407:
case 429054168:
case 429021400:
case 428955864:
case 429119704:
case 428890328:
case 428923096:
case 429218008:
case 429086936:
case 428988632:
case 428688204:
case 429514603:
case 428924959:
case 429393818:
case 429720966:
case 428982463:
case 427933887:
case 429572287:
case 429501222:
case 430694431:
case 429436131:
case 430006124:
case 429611355:
case 428005600:
case 427935608:
case 428949695:
case 427988218:
case 429414616:
case 429496495:
case 429428796:
case 563795754:
case 428988217:
case 429432716:
case 428955899:
case 429393286:
case 550062220:
case 429495557:
case 429401278:
case 428377478:
case 429409094:
case 428191947:
case 429434474:
case 429403363:
case 429512920:
case 429419611:
case 429645676:
case 429602895:
case 429605071:
case 429592428:
case 429500010:
case 429406602:
case 429426586:
case 429633898:
case 550062212:
case 429994027:
case 430813227:
case 429928491:
case 430026795:
case 429517915:
case 431854842:
case 429767544:
case 429502507:
case 428398816:
case 429446315:
case 429441979:
return false;
}
return true;
}
} }
+14 -29
View File
@@ -10,7 +10,10 @@ package engine.gameManager;
import engine.Enum; import engine.Enum;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
import engine.objects.*; import engine.objects.AbstractGameObject;
import engine.objects.City;
import engine.objects.PlayerCharacter;
import engine.objects.Runegate;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.sql.Connection; import java.sql.Connection;
@@ -30,7 +33,7 @@ public enum SimulationManager {
SERVERHEARTBEAT; SERVERHEARTBEAT;
private static final long CITY_PULSE = 2000; private static final long CITY_PULSE = 2000;
private static final long RUNEGATE_PULSE = 1000; private static final long RUNEGATE_PULSE = 3000;
private static final long UPDATE_PULSE = 1000; private static final long UPDATE_PULSE = 1000;
private static final long FlIGHT_PULSE = 100; private static final long FlIGHT_PULSE = 100;
public static Duration executionTime = Duration.ofNanos(1); public static Duration executionTime = Duration.ofNanos(1);
@@ -93,10 +96,13 @@ public enum SimulationManager {
} }
try { try {
if ((_updatePulseTime != 0) && (System.currentTimeMillis() > _updatePulseTime)) if ((_updatePulseTime != 0)
&& (System.currentTimeMillis() > _updatePulseTime))
pulseUpdate(); pulseUpdate();
} catch (Exception e) { } catch (Exception e) {
Logger.error("Fatal error in Update Pulse: DISABLED"); Logger.error(
"Fatal error in Update Pulse: DISABLED");
// _runegatePulseTime = 0;
} }
try { try {
@@ -110,19 +116,10 @@ public enum SimulationManager {
} }
try { try {
if ((_cityPulseTime != 0) && (System.currentTimeMillis() > _cityPulseTime)) { if ((_cityPulseTime != 0)
try { && (System.currentTimeMillis() > _cityPulseTime))
pulseCities(); pulseCities();
} catch (Exception e) { } catch (Exception e) {
}
try {
ArenaManager.pulseArenas();
}catch(Exception e){
}
}
} catch (Exception e) {
Logger.error( Logger.error(
"Fatal error in City Pulse: DISABLED. Error Message : " "Fatal error in City Pulse: DISABLED. Error Message : "
+ e.getMessage()); + e.getMessage());
@@ -157,11 +154,7 @@ public enum SimulationManager {
if (player == null) if (player == null)
continue; continue;
try { player.update();
player.update(false);
}catch(Exception e){
}
} }
_updatePulseTime = System.currentTimeMillis() + 500; _updatePulseTime = System.currentTimeMillis() + 500;
@@ -210,12 +203,8 @@ public enum SimulationManager {
city = (City) cityObject; city = (City) cityObject;
city.onEnter(); city.onEnter();
} }
for(Mine mine : Mine.getMines()){
if(mine != null && mine.isActive)
mine.onEnter();
}
_cityPulseTime = System.currentTimeMillis() + CITY_PULSE;
_cityPulseTime = System.currentTimeMillis() + CITY_PULSE;
} }
/* /*
@@ -225,10 +214,6 @@ public enum SimulationManager {
private void pulseRunegates() { private void pulseRunegates() {
for (Runegate runegate : Runegate._runegates.values()) { for (Runegate runegate : Runegate._runegates.values()) {
for(Portal portal : runegate._portals)
if(!portal.isActive())
portal.activate(false);
runegate.collidePortals(); runegate.collidePortals();
} }
@@ -1,347 +0,0 @@
package engine.gameManager;
import engine.Enum;
import engine.InterestManagement.InterestManager;
import engine.InterestManagement.WorldGrid;
import engine.math.Vector3f;
import engine.math.Vector3fImmutable;
import engine.objects.*;
import org.pmw.tinylog.Logger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.ThreadLocalRandom;
public class StrongholdManager {
public static void processStrongholds() {
ArrayList<Mine> mines = Mine.getMines();
//process strongholds selecting 3 randomly to become active
int count = 0;
while (count < 3) {
int random = ThreadLocalRandom.current().nextInt(1, mines.size()) - 1;
Mine mine = mines.get(random);
if (mine != null) {
if (!mine.isActive && !mine.isStronghold) {
StartStronghold(mine);
count++;
}
}
}
}
public static void StartStronghold(Mine mine){
//remove buildings
Building tower = BuildingManager.getBuilding(mine.getBuildingID());
if(tower == null)
return;
mine.isStronghold = true;
mine.strongholdMobs = new ArrayList<>();
mine.oldBuildings = new HashMap<>();
Zone mineZone = ZoneManager.findSmallestZone(tower.loc);
for(Building building : mineZone.zoneBuildingSet){
mine.oldBuildings.put(building.getObjectUUID(),building.meshUUID);
building.setMeshUUID(407650);
building.setMeshScale(new Vector3f(0,0,0));
InterestManager.setObjectDirty(building);
WorldGrid.updateObject(building);
}
//update tower to become stronghold mesh
tower.setMeshUUID(getStrongholdMeshID(mine.getParentZone()));
tower.setMeshScale(new Vector3f(1,1,1));
InterestManager.setObjectDirty(tower);
WorldGrid.updateObject(tower);
//create elite mobs
for(int i = 0; i < mine.capSize * 2; i++){
Vector3fImmutable loc = Vector3fImmutable.getRandomPointOnCircle(tower.loc,30);
MobBase guardBase = MobBase.getMobBase(getStrongholdGuardianID(tower.meshUUID));
Mob guard = Mob.createStrongholdMob(guardBase.getLoadID(), loc, Guild.getErrantGuild(),true,mineZone,null,0, guardBase.getFirstName(),65);
if(guard != null){
guard.parentZone = mine.getParentZone();
guard.bindLoc = loc;
guard.setLoc(loc);
guard.StrongholdGuardian = true;
guard.equipmentSetID = getStrongholdMobEquipSetID(guard);
guard.runAfterLoad();
guard.setLevel((short)65);
guard.setResists(new Resists("Elite"));
guard.spawnTime = 1000000000;
guard.BehaviourType = Enum.MobBehaviourType.Aggro;
mine.strongholdMobs.add(guard);
LootManager.GenerateStrongholdLoot(guard,false,false);
guard.healthMax = 12500;
guard.setHealth(guard.healthMax);
guard.maxDamageHandOne = 1550;
guard.minDamageHandOne = 750;
guard.atrHandOne = 1800;
guard.defenseRating = 2200;
guard.setFirstName("Elite Guardian");
InterestManager.setObjectDirty(guard);
WorldGrid.addObject(guard,loc.x,loc.z);
WorldGrid.updateObject(guard);
guard.stronghold = mine;
guard.mobPowers.clear();
guard.mobPowers.put(429399948,20); // find weakness
}
}
//create stronghold commander
Vector3fImmutable loc = tower.loc;
MobBase commanderBase = MobBase.getMobBase(getStrongholdCommanderID(tower.meshUUID));
Mob commander = Mob.createStrongholdMob(commanderBase.getLoadID(), loc,Guild.getErrantGuild(),true,mineZone,null,0, commanderBase.getFirstName(),75);
if(commander != null){
commander.parentZone = mine.getParentZone();
commander.bindLoc = loc;
commander.setLoc(loc);
commander.StrongholdCommander = true;
commander.equipmentSetID = getStrongholdMobEquipSetID(commander);
commander.runAfterLoad();
commander.setLevel((short)75);
commander.setResists(new Resists("Elite"));
commander.spawnTime = 1000000000;
commander.BehaviourType = Enum.MobBehaviourType.Aggro;
commander.mobPowers.clear();
commander.mobPowers.put(429032838, 40); // gravechill
commander.mobPowers.put(429757701,20); // magebolt
commander.mobPowers.put(429121388,20); // blight
commander.mobPowers.put(431566891,20); // lightning bolt
commander.mobPowers.put(428716075,20); // fire bolt
commander.mobPowers.put(429010987,20); // ice bolt
mine.strongholdMobs.add(commander);
LootManager.GenerateStrongholdLoot(commander,true, false);
commander.healthMax = 50000;
commander.setHealth(commander.healthMax);
commander.maxDamageHandOne = 3500;
commander.minDamageHandOne = 1500;
commander.atrHandOne = 3500;
commander.defenseRating = 3500;
commander.setFirstName("Guardian Commander");
InterestManager.setObjectDirty(commander);
WorldGrid.addObject(commander,loc.x,loc.z);
WorldGrid.updateObject(commander);
commander.stronghold = mine;
}
mine.isActive = true;
tower.setProtectionState(Enum.ProtectionState.PROTECTED);
tower.getBounds().setRegions(tower);
InterestManager.setObjectDirty(tower);
WorldGrid.updateObject(tower);
ChatManager.chatSystemChannel(mine.getZoneName() + "'s Stronghold Has Begun!");
Logger.info(mine.getZoneName() + "'s Stronghold Has Begun!");
}
public static void EndStronghold(Mine mine){
//restore the buildings
Building tower = BuildingManager.getBuilding(mine.getBuildingID());
if(tower == null)
return;
mine.isStronghold = false;
//get rid of the mobs
for(Mob mob : mine.strongholdMobs) {
mob.despawn();
mob.removeFromCache();
DbManager.MobQueries.DELETE_MOB(mob);
}
//restore the buildings
Zone mineZone = ZoneManager.findSmallestZone(tower.loc);
for(Building building : mineZone.zoneBuildingSet){
if(mine.oldBuildings.containsKey(building.getObjectUUID())) {
building.setMeshUUID(mine.oldBuildings.get(building.getObjectUUID()));
building.setMeshScale(new Vector3f(1, 1, 1));
InterestManager.setObjectDirty(building);
WorldGrid.updateObject(building);
}
}
//update tower to become Mine Tower again
tower.setMeshUUID(1500100);
mine.isActive = false;
tower.setProtectionState(Enum.ProtectionState.NPC);
tower.getBounds().setRegions(tower);
InterestManager.setObjectDirty(tower);
WorldGrid.updateObject(tower);
ChatManager.chatSystemChannel(mine.getZoneName() + "'s Stronghold Has Concluded!");
Logger.info(mine.getZoneName() + "'s Stronghold Has Concluded!");
}
public static int getStrongholdMeshID(Zone parent){
while(!parent.isMacroZone()){
parent = parent.getParent();
if(parent.getName().equalsIgnoreCase("seafloor")){
return 0;
}
}
switch(parent.getObjectUUID()){
case 197:
case 234:
case 178:
case 122:
return 814000; //Frost Giant Hall (ICE)
case 968:
case 951:
case 313:
case 331:
return 5001500; // Lich Queens Keep (UNDEAD)
case 785:
case 761:
case 717:
case 737:
return 1306600; // Temple of the Dragon (DESERT)
case 353:
case 371:
case 388:
case 532:
return 564600; // Undead Lord's Keep (SWAMP)
case 550:
case 508:
case 475:
case 418:
return 1326600; // elven hall
case 437:
case 491:
case 590:
case 569:
return 602400;
case 824:
case 842:
case 632:
return 1600000; // chaos temple
}
return 456100; // small stockade
}
public static int getStrongholdGuardianID(int ID){
switch(ID){
case 814000:
return 253004; // Mountain Giant Raider Axe
case 5001500:
return 253008; // Vampire Spear Warrior
case 1306600:
return 253007; // Desert Orc Warrior
case 564600:
return 253010; // Kolthoss Warrior
case 1326600:
return 253005; //elven warrior
case 602400:
return 253009; // templar missionary
case 1600000:
return 253006; // scourger
}
return 13434; // human sword and board warrior
}
public static int getStrongholdEpicID(int ID){
switch(ID){
case 814000:
return 253023; // Mountain Giant Raider Axe
case 5001500:
return 253022; // Vampire Spear Warrior
case 1306600:
return 253021; // Desert Orc Warrior
case 564600:
return 253018; // Kolthoss Warrior
case 1326600:
return 253019; //elven warrior
case 602400:
return 253024; // templar missionary
case 1600000:
return 253020; // scourger
}
return 13434; // human sword and board warrior
}
public static int getStrongholdCommanderID(int ID){
switch(ID){
case 814000:
return 253017;
case 5001500:
return 253012;
case 1306600:
return 253016; // Desert Orc Xbow
case 564600:
return 253011; // xbow kolthoss
case 1326600:
return 253013; //elven bow warrior
case 602400:
return 253015; // dune giant with xbow
case 1600000:
return 253014; // barbator
}
return 13433;
}
public static int getStrongholdMobEquipSetID(Mob mob) {
if(mob.StrongholdGuardian){
return 6327;
}else{
return 10790;
}
}
public static void CheckToEndStronghold(Mine mine) {
boolean stillAlive = false;
for (Mob mob : mine.strongholdMobs)
if (mob.isAlive())
stillAlive = true;
if (!stillAlive) {
// Epic encounter
Building tower = BuildingManager.getBuilding(mine.getBuildingID());
if (tower == null)
return;
Zone mineZone = ZoneManager.findSmallestZone(tower.loc);
Vector3fImmutable loc = tower.loc;
MobBase commanderBase = MobBase.getMobBase(getStrongholdEpicID(tower.meshUUID));
Mob commander = Mob.createStrongholdMob(commanderBase.getLoadID(), loc, Guild.getErrantGuild(), true, mineZone, null, 0, commanderBase.getFirstName(), 75);
if (commander != null) {
commander.parentZone = mine.getParentZone();
commander.bindLoc = loc;
commander.setLoc(loc);
commander.StrongholdEpic = true;
commander.equipmentSetID = getStrongholdMobEquipSetID(commander);
commander.runAfterLoad();
commander.setLevel((short) 85);
commander.setResists(new Resists("Elite"));
commander.spawnTime = 1000000000;
commander.BehaviourType = Enum.MobBehaviourType.Aggro;
commander.mobPowers.clear();
commander.mobPowers.put(429032838, 40); // gravechill
commander.mobPowers.put(429757701,40); // magebolt
commander.mobPowers.put(429121388,40); // blight
commander.mobPowers.put(431566891,40); // lightning bolt
commander.mobPowers.put(428716075,40); // fire bolt
commander.mobPowers.put(429010987,40); // ice bolt
mine.strongholdMobs.add(commander);
LootManager.GenerateStrongholdLoot(commander, true, true);
commander.healthMax = 250000;
commander.setHealth(commander.healthMax);
commander.maxDamageHandOne = 5000;
commander.minDamageHandOne = 2500;
commander.atrHandOne = 5000;
commander.defenseRating = 3500;
commander.setFirstName("Defender of " + mine.getParentZone().getParent().getName());
InterestManager.setObjectDirty(commander);
WorldGrid.addObject(commander,loc.x,loc.z);
WorldGrid.updateObject(commander);
commander.stronghold = mine;
}
}
}
}
-195
View File
@@ -1,195 +0,0 @@
package engine.gameManager;
import engine.objects.Guild;
public class ZergManager {
public static float getCurrentMultiplier(int count, int maxCount){
switch(maxCount) {
case 3: return getMultiplier3Man(count);
case 5: return getMultiplier5Man(count);
case 10: return getMultiplier10Man(count);
case 20: return getMultiplier20Man(count);
case 30: return getMultiplier30Man(count);
case 40: return getMultiplier40Man(count);
default: return 1.0f; //unlimited
}
}
public static float getMultiplier3Man(int count) {
if(count < 4)
return 1.0f;
if(count > 6)
return 0.0f;
switch(count){
case 4: return 0.63f;
case 5: return 0.40f;
case 6: return 0.25f;
default: return 1.0f;
}
}
public static float getMultiplier5Man(int count) {
if(count < 6)
return 1.0f;
if(count > 10)
return 0.0f;
switch(count){
case 6: return 0.75f;
case 7: return 0.57f;
case 8: return 0.44f;
case 9: return 0.33f;
case 10: return 0.25f;
default: return 1.0f;
}
}
public static float getMultiplier10Man(int count) {
if(count < 11)
return 1.0f;
if(count > 20)
return 0.0f;
switch(count){
case 11: return 0.86f;
case 12: return 0.75f;
case 13: return 0.65f;
case 14: return 0.57f;
case 15: return 0.50f;
case 16: return 0.44f;
case 17: return 0.38f;
case 18: return 0.33f;
case 19: return 0.29f;
case 20: return 0.25f;
default: return 1.0f;
}
}
public static float getMultiplier20Man(int count) {
if(count < 21)
return 1.0f;
if(count > 40)
return 0.0f;
switch (count)
{
case 21: return 0.93f;
case 22: return 0.86f;
case 23: return 0.80f;
case 24: return 0.75f;
case 25: return 0.70f;
case 26: return 0.65f;
case 27: return 0.61f;
case 28: return 0.57f;
case 29: return 0.53f;
case 30: return 0.50f;
case 31: return 0.47f;
case 32: return 0.44f;
case 33: return 0.41f;
case 34: return 0.38f;
case 35: return 0.36f;
case 36: return 0.33f;
case 37: return 0.31f;
case 38: return 0.29f;
case 39: return 0.27f;
case 40: return 0.25f;
default: return 1.0f;
}
}
public static float getMultiplier30Man(int count) {
if(count < 31)
return 1.0f;
if(count > 60)
return 0.0f;
switch (count)
{
case 31: return 0.95f;
case 32: return 0.91f;
case 33: return 0.86f;
case 34: return 0.82f;
case 35: return 0.79f;
case 36: return 0.75f;
case 37: return 0.72f;
case 38: return 0.68f;
case 39: return 0.65f;
case 40: return 0.63f;
case 41: return 0.60f;
case 42: return 0.57f;
case 43: return 0.55f;
case 44: return 0.52f;
case 45: return 0.50f;
case 46: return 0.48f;
case 47: return 0.46f;
case 48: return 0.44f;
case 49: return 0.42f;
case 50: return 0.40f;
case 51: return 0.38f;
case 52: return 0.37f;
case 53: return 0.35f;
case 54: return 0.33f;
case 55: return 0.32f;
case 56: return 0.30f;
case 57: return 0.29f;
case 58: return 0.28f;
case 59: return 0.26f;
case 60: return 0.25f;
default: return 1.0f;
}
}
public static float getMultiplier40Man(int count) {
if(count < 41)
return 1.0f;
if(count > 80)
return 0.0f;
switch (count)
{
case 41: return 0.96f;
case 42: return 0.93f;
case 43: return 0.90f;
case 44: return 0.86f;
case 45: return 0.83f;
case 46: return 0.80f;
case 47: return 0.78f;
case 48: return 0.75f;
case 49: return 0.72f;
case 50: return 0.70f;
case 51: return 0.68f;
case 52: return 0.65f;
case 53: return 0.63f;
case 54: return 0.61f;
case 55: return 0.59f;
case 56: return 0.57f;
case 57: return 0.55f;
case 58: return 0.53f;
case 59: return 0.52f;
case 60: return 0.50f;
case 61: return 0.48f;
case 62: return 0.47f;
case 63: return 0.45f;
case 64: return 0.44f;
case 65: return 0.42f;
case 66: return 0.41f;
case 67: return 0.40f;
case 68: return 0.38f;
case 69: return 0.37f;
case 70: return 0.36f;
case 71: return 0.35f;
case 72: return 0.33f;
case 73: return 0.32f;
case 74: return 0.31f;
case 75: return 0.30f;
case 76: return 0.29f;
case 77: return 0.28f;
case 78: return 0.27f;
case 79: return 0.26f;
case 80: return 0.25f;
default: return 1.0f;
}
}
}
+73
View File
@@ -19,12 +19,14 @@ import engine.objects.Building;
import engine.objects.City; import engine.objects.City;
import engine.objects.Zone; import engine.objects.Zone;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom;
/* /*
* Class contains methods and structures which * Class contains methods and structures which
@@ -107,6 +109,20 @@ public enum ZoneManager {
} }
// Returns the number of available hotZones
// remaining in this cycle (1am)
public static int availableHotZones() {
int count = 0;
for (Zone zone : ZoneManager.macroZones)
if (ZoneManager.validHotZone(zone))
count = count + 1;
return count;
}
// Resets the availability of hotZones // Resets the availability of hotZones
// for this cycle // for this cycle
@@ -201,6 +217,63 @@ public enum ZoneManager {
ZoneManager.playerCityZones.add(zone); ZoneManager.playerCityZones.add(zone);
} }
public static final void generateAndSetRandomHotzone() {
Zone hotZone;
ArrayList<Integer> zoneArray = new ArrayList<>();
if (ZoneManager.macroZones.isEmpty())
return;
// Reset hotZone availability if none are left.
if (ZoneManager.availableHotZones() == 0)
ZoneManager.resetHotZones();
for (Zone zone : ZoneManager.macroZones)
if (validHotZone(zone))
zoneArray.add(zone.getObjectUUID());
int entryIndex = ThreadLocalRandom.current().nextInt(zoneArray.size());
hotZone = ZoneManager.getZoneByUUID(zoneArray.get(entryIndex));
if (hotZone == null) {
Logger.error("Hotzone is null");
return;
}
ZoneManager.setHotZone(hotZone);
}
public static final boolean validHotZone(Zone zone) {
if (zone.getSafeZone() == (byte) 1)
return false; // no safe zone hotzones// if (this.hotzone == null)
if (zone.getNodes().isEmpty())
return false;
if (zone.equals(ZoneManager.seaFloor))
return false;
//no duplicate hotZones
if (zone.hasBeenHotzone == true)
return false;
// Enforce min level
if (zone.minLvl < Integer.parseInt(ConfigManager.MB_HOTZONE_MIN_LEVEL.getValue()))
return false;
if (ZoneManager.hotZone != null)
return ZoneManager.hotZone.getObjectUUID() != zone.getObjectUUID();
return true;
}
// Converts world coordinates to coordinates local to a given zone. // Converts world coordinates to coordinates local to a given zone.
public static Vector3fImmutable worldToLocal(Vector3fImmutable worldVector, public static Vector3fImmutable worldToLocal(Vector3fImmutable worldVector,
+1 -1
View File
@@ -68,7 +68,7 @@ public abstract class AbstractJob implements Runnable {
this.markStopRunTime(); this.markStopRunTime();
} }
public abstract void doJob(); protected abstract void doJob();
public void executeJob(String threadName) { public void executeJob(String threadName) {
this.workerID.set(threadName); this.workerID.set(threadName);
+1 -1
View File
@@ -17,7 +17,7 @@ public abstract class AbstractScheduleJob extends AbstractJob {
} }
@Override @Override
public abstract void doJob(); protected abstract void doJob();
public void cancelJob() { public void cancelJob() {
JobScheduler.getInstance().cancelScheduledJob(this); JobScheduler.getInstance().cancelScheduledJob(this);
+1 -1
View File
@@ -16,7 +16,7 @@ public class JobContainer implements Comparable<JobContainer> {
final long timeOfExecution; final long timeOfExecution;
final boolean noTimer; final boolean noTimer;
public JobContainer(AbstractJob job, long timeOfExecution) { JobContainer(AbstractJob job, long timeOfExecution) {
if (job == null) { if (job == null) {
throw new IllegalArgumentException("No 'null' jobs allowed."); throw new IllegalArgumentException("No 'null' jobs allowed.");
} }
-75
View File
@@ -1,75 +0,0 @@
package engine.job;
import engine.server.world.WorldServer;
import org.pmw.tinylog.Logger;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
public class JobThread implements Runnable {
private final AbstractJob currentJob;
private final ReentrantLock lock = new ReentrantLock();
private static Long nextThreadPrint;
public JobThread(AbstractJob job){
this.currentJob = job;
}
@Override
public void run() {
try {
if (this.currentJob != null) {
if (lock.tryLock(5, TimeUnit.SECONDS)) { // Timeout to prevent deadlock
try {
this.currentJob.doJob();
} finally {
lock.unlock();
}
} else {
Logger.warn("JobThread could not acquire lock in time, skipping job.");
}
}
} catch (Exception e) {
Logger.error(e);
}
}
public static void startJobThread(AbstractJob job){
JobThread jobThread = new JobThread(job);
Thread thread = new Thread(jobThread);
thread.setName("JOB THREAD: " + job.getWorkerID());
thread.start();
if(JobThread.nextThreadPrint == null){
JobThread.nextThreadPrint = System.currentTimeMillis();
}else{
if(JobThread.nextThreadPrint < System.currentTimeMillis()){
JobThread.tryPrintThreads();
JobThread.nextThreadPrint = System.currentTimeMillis() + 10000L;
}
}
}
public static void tryPrintThreads(){
ThreadGroup rootGroup = Thread.currentThread().getThreadGroup();
while (rootGroup.getParent() != null) {
rootGroup = rootGroup.getParent();
}
// Estimate the number of threads
int activeThreads = rootGroup.activeCount();
// Create an array to hold the threads
Thread[] threads = new Thread[activeThreads];
// Get the active threads
rootGroup.enumerate(threads, true);
int availableThreads = Runtime.getRuntime().availableProcessors();
// Print the count
if(threads.length > 30)
Logger.info("Total threads in application: " + threads.length + " / " + availableThreads);
}
}
+2 -5
View File
@@ -58,13 +58,10 @@ public class JobWorker extends ControlledRunnable {
} else { } else {
// execute the new job.. // execute the new job..
//this.currentJob.executeJob(this.getThreadName()); this.currentJob.executeJob(this.getThreadName());
if(this.currentJob != null) {
JobThread.startJobThread(this.currentJob);
this.currentJob = null; this.currentJob = null;
} }
}
Thread.yield();
} }
return true; return true;
} }
+2 -2
View File
@@ -45,7 +45,7 @@ public abstract class AbstractEffectJob extends AbstractScheduleJob {
} }
@Override @Override
public abstract void doJob(); protected abstract void doJob();
@Override @Override
protected abstract void _cancelJob(); protected abstract void _cancelJob();
@@ -117,7 +117,7 @@ public abstract class AbstractEffectJob extends AbstractScheduleJob {
} }
public void endEffect() { public void endEffect() {
if (this.eb == null || this.power == null) if (this.eb == null)
return; return;
this.eb.endEffect(this.source, this.target, this.trains, this.power, this); this.eb.endEffect(this.source, this.target, this.trains, this.power, this);
} }
+1 -1
View File
@@ -29,7 +29,7 @@ public class ActivateBaneJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
City city; City city;
+1 -1
View File
@@ -27,7 +27,7 @@ public class AttackJob extends AbstractJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
CombatManager.doCombat(this.source, slot); CombatManager.doCombat(this.source, slot);
} }
+1 -1
View File
@@ -24,7 +24,7 @@ public class BaneDefaultTimeJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
//bane already set. //bane already set.
if (this.bane.getLiveDate() != null) { if (this.bane.getLiveDate() != null) {
+1 -1
View File
@@ -97,7 +97,7 @@ public class BasicScheduledJob extends AbstractJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
if (execution == null) { if (execution == null) {
Logger.error("BasicScheduledJob executed with nothing to execute."); Logger.error("BasicScheduledJob executed with nothing to execute.");
return; return;
+1 -1
View File
@@ -22,7 +22,7 @@ public class BonusCalcJob extends AbstractJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
if (this.ac != null) { if (this.ac != null) {
this.ac.applyBonuses(); this.ac.applyBonuses();
+1 -1
View File
@@ -22,7 +22,7 @@ public class CSessionCleanupJob extends AbstractJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
SessionManager.cSessionCleanup(secKey); SessionManager.cSessionCleanup(secKey);
} }
} }
+1 -1
View File
@@ -27,7 +27,7 @@ public class ChangeAltitudeJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
if (this.ac != null) if (this.ac != null)
MovementManager.finishChangeAltitude(ac, targetAlt); MovementManager.finishChangeAltitude(ac, targetAlt);
} }
+1 -1
View File
@@ -36,7 +36,7 @@ public class ChantJob extends AbstractEffectJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
if (this.aej == null || this.source == null || this.target == null || this.action == null || this.power == null || this.source == null || this.eb == null) if (this.aej == null || this.source == null || this.target == null || this.action == null || this.power == null || this.source == null || this.eb == null)
return; return;
PlayerBonuses bonuses = null; PlayerBonuses bonuses = null;
+1 -1
View File
@@ -29,7 +29,7 @@ public class CloseGateJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
if (building == null) { if (building == null) {
Logger.error("Rungate building was null"); Logger.error("Rungate building was null");
+1 -3
View File
@@ -37,7 +37,7 @@ public class DamageOverTimeJob extends AbstractEffectJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
if (this.target.getObjectType().equals(GameObjectType.Building) if (this.target.getObjectType().equals(GameObjectType.Building)
&& ((Building) this.target).isVulnerable() == false) { && ((Building) this.target).isVulnerable() == false) {
_cancelJob(); _cancelJob();
@@ -60,8 +60,6 @@ public class DamageOverTimeJob extends AbstractEffectJob {
if (this.iteration < 0) { if (this.iteration < 0) {
PowersManager.finishEffectTime(this.source, this.target, this.action, this.trains); PowersManager.finishEffectTime(this.source, this.target, this.action, this.trains);
if (AbstractWorldObject.IsAbstractCharacter(source))
eb.startEffect((AbstractCharacter) this.source, this.target, this.trains, this);
return; return;
} }
this.skipSendEffect = true; this.skipSendEffect = true;
+1 -1
View File
@@ -28,7 +28,7 @@ public class DatabaseUpdateJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
if (this.ago == null) if (this.ago == null)
return; return;
ago.removeDatabaseJob(this.type, false); ago.removeDatabaseJob(this.type, false);
+1 -1
View File
@@ -29,7 +29,7 @@ public class DebugTimerJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
if (this.pc == null) { if (this.pc == null) {
return; return;
} }
+1 -1
View File
@@ -37,7 +37,7 @@ public class DeferredPowerJob extends AbstractEffectJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
//Power ended with no attack, cancel weapon power boost //Power ended with no attack, cancel weapon power boost
if (this.source != null && this.source instanceof PlayerCharacter) { if (this.source != null && this.source instanceof PlayerCharacter) {
((PlayerCharacter) this.source).setWeaponPower(null); ((PlayerCharacter) this.source).setWeaponPower(null);
+1 -1
View File
@@ -22,7 +22,7 @@ public class DisconnectJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
if (this.origin != null) { if (this.origin != null) {
this.origin.disconnect(); this.origin.disconnect();
} }
+1 -1
View File
@@ -28,7 +28,7 @@ public class DoorCloseJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
int doorNumber; int doorNumber;
+3 -3
View File
@@ -22,14 +22,14 @@ public class EndFearJob extends AbstractEffectJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
//cancel fear for mob. //cancel fear for mob.
if (this.target == null || (!(this.target instanceof Mob))) if (this.target == null || (!(this.target instanceof Mob)))
return; return;
((Mob) this.target).setFearedObject(null); ((Mob) this.target).fearedObject = null;
} }
@Override @Override
@@ -40,6 +40,6 @@ public class EndFearJob extends AbstractEffectJob {
if (this.target == null || (!(this.target instanceof Mob))) if (this.target == null || (!(this.target instanceof Mob)))
return; return;
((Mob) this.target).setFearedObject(null); ((Mob) this.target).fearedObject = null;
} }
} }
+1 -1
View File
@@ -26,7 +26,7 @@ public class FinishCooldownTimeJob extends AbstractJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
PowersManager.finishCooldownTime(this.msg, this.pc); PowersManager.finishCooldownTime(this.msg, this.pc);
} }
} }
+1 -1
View File
@@ -22,7 +22,7 @@ public class FinishEffectTimeJob extends AbstractEffectJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
PowersManager.finishEffectTime(this.source, this.target, this.action, this.trains); PowersManager.finishEffectTime(this.source, this.target, this.action, this.trains);
} }
+1 -1
View File
@@ -26,7 +26,7 @@ public class FinishRecycleTimeJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
PowersManager.finishRecycleTime(this.msg, this.pc, false); PowersManager.finishRecycleTime(this.msg, this.pc, false);
} }
+1 -1
View File
@@ -20,7 +20,7 @@ public class FinishSpireEffectJob extends AbstractEffectJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
PlayerCharacter pc = (PlayerCharacter) target; PlayerCharacter pc = (PlayerCharacter) target;
+6 -6
View File
@@ -31,7 +31,7 @@ public class FinishSummonsJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
if (this.target == null) if (this.target == null)
return; return;
@@ -47,13 +47,13 @@ public class FinishSummonsJob extends AbstractScheduleJob {
return; return;
// cannot summon a player in combat // cannot summon a player in combat
//if (this.target.isCombat()) { if (this.target.isCombat()) {
// ErrorPopupMsg.sendErrorMsg(this.source, "Cannot summon player in combat."); ErrorPopupMsg.sendErrorMsg(this.source, "Cannot summon player in combat.");
// PowersManager.finishRecycleTime(428523680, this.source, false); PowersManager.finishRecycleTime(428523680, this.source, false);
// return; return;
//} }
if (this.target.getBonuses() != null && this.target.getBonuses().getBool(ModType.BlockedPowerType, SourceType.SUMMON)) { if (this.target.getBonuses() != null && this.target.getBonuses().getBool(ModType.BlockedPowerType, SourceType.SUMMON)) {
ErrorPopupMsg.sendErrorMsg(this.target, "You have been blocked from receiving summons!"); ErrorPopupMsg.sendErrorMsg(this.target, "You have been blocked from receiving summons!");
+1 -1
View File
@@ -28,7 +28,7 @@ public class LoadEffectsJob extends AbstractJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
if (this.originToSend == null) { if (this.originToSend == null) {
return; return;
} }
+1 -1
View File
@@ -25,7 +25,7 @@ public class LogoutCharacterJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
server.logoutCharacter(this.pc); server.logoutCharacter(this.pc);
} }
+1 -1
View File
@@ -19,7 +19,7 @@ public class NoTimeJob extends AbstractEffectJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
} }
@Override @Override
+1 -1
View File
@@ -40,7 +40,7 @@ public class PersistentAoeJob extends AbstractEffectJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
if (this.aej == null || this.source == null || this.action == null || this.power == null || this.source == null || this.eb == null) if (this.aej == null || this.source == null || this.action == null || this.power == null || this.source == null || this.eb == null)
return; return;
+1 -1
View File
@@ -45,7 +45,7 @@ public class RefreshGroupJob extends AbstractJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
if (this.pc == null || this.origin == null || grp == null) { if (this.pc == null || this.origin == null || grp == null) {
return; return;
+1 -1
View File
@@ -22,7 +22,7 @@ public class RemoveCorpseJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
if (this.corpse != null) if (this.corpse != null)
Corpse.removeCorpse(corpse, true); Corpse.removeCorpse(corpse, true);
+1 -1
View File
@@ -25,7 +25,7 @@ public class SiegeSpireWithdrawlJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
if (spire == null) if (spire == null)
return; return;
+1 -1
View File
@@ -30,7 +30,7 @@ public class StuckJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
Vector3fImmutable stuckLoc; Vector3fImmutable stuckLoc;
Building building = null; Building building = null;
+1 -1
View File
@@ -27,7 +27,7 @@ public class SummonSendJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
if (this.source == null) if (this.source == null)
return; return;
+1 -1
View File
@@ -39,7 +39,7 @@ public class TeleportJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
if (this.pc == null || this.npc == null || this.origin == null) if (this.pc == null || this.npc == null || this.origin == null)
return; return;
+1 -1
View File
@@ -35,7 +35,7 @@ public class TrackJob extends AbstractEffectJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
if (this.tpa == null || this.target == null || this.action == null || this.source == null || this.eb == null || !(this.source instanceof PlayerCharacter)) if (this.tpa == null || this.target == null || this.action == null || this.source == null || this.eb == null || !(this.source instanceof PlayerCharacter))
return; return;
+1 -1
View File
@@ -29,7 +29,7 @@ public class TransferStatOTJob extends AbstractEffectJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
if (this.dot == null || this.target == null || this.action == null || this.source == null || this.eb == null || this.action == null || this.power == null) if (this.dot == null || this.target == null || this.action == null || this.source == null || this.eb == null || this.action == null || this.power == null)
return; return;
if (!this.target.isAlive()) { if (!this.target.isAlive()) {
+1 -1
View File
@@ -26,7 +26,7 @@ public class UpdateGroupJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
if (this.group == null) if (this.group == null)
return; return;
+1 -15
View File
@@ -1,9 +1,7 @@
package engine.jobs; package engine.jobs;
import engine.gameManager.ZoneManager;
import engine.job.AbstractScheduleJob; import engine.job.AbstractScheduleJob;
import engine.objects.Building; import engine.objects.Building;
import engine.objects.City;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
/* /*
@@ -22,7 +20,7 @@ public class UpgradeBuildingJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
// Must have a building to rank! // Must have a building to rank!
@@ -43,18 +41,6 @@ public class UpgradeBuildingJob extends AbstractScheduleJob {
rankingBuilding.setRank(rankingBuilding.getRank() + 1); rankingBuilding.setRank(rankingBuilding.getRank() + 1);
if(rankingBuilding.getBlueprint().isWallPiece()){
City cityObject = ZoneManager.getCityAtLocation(rankingBuilding.loc);
if(cityObject.getTOL().getRank() == 8) {
if (rankingBuilding.getBlueprint() != null && rankingBuilding.getBlueprint().getBuildingGroup() != null && rankingBuilding.getBlueprint().isWallPiece()) {
float currentHealthRatio = rankingBuilding.getCurrentHitpoints() / rankingBuilding.healthMax;
float newMax = rankingBuilding.healthMax * 1.1f;
rankingBuilding.setMaxHitPoints(newMax);
rankingBuilding.setHealth(rankingBuilding.healthMax * currentHealthRatio);
}
}
}
// Reload the object // Reload the object
+1 -1
View File
@@ -27,7 +27,7 @@ public class UpgradeNPCJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
int newRank; int newRank;
+1 -1
View File
@@ -34,7 +34,7 @@ public class UseItemJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
PowersManager.finishApplyPower(ac, target, Vector3fImmutable.ZERO, pb, trains, liveCounter); PowersManager.finishApplyPower(ac, target, Vector3fImmutable.ZERO, pb, trains, liveCounter);
} }
+1 -1
View File
@@ -35,7 +35,7 @@ public class UseMobPowerJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
PowersManager.finishUseMobPower(this.msg, this.caster, casterLiveCounter, targetLiveCounter); PowersManager.finishUseMobPower(this.msg, this.caster, casterLiveCounter, targetLiveCounter);
} }
+1 -1
View File
@@ -35,7 +35,7 @@ public class UsePowerJob extends AbstractScheduleJob {
} }
@Override @Override
public void doJob() { protected void doJob() {
PowersManager.finishUsePower(this.msg, this.pc, casterLiveCounter, targetLiveCounter); PowersManager.finishUsePower(this.msg, this.pc, casterLiveCounter, targetLiveCounter);
} }
+2 -16
View File
@@ -9,12 +9,10 @@
package engine.loot; package engine.loot;
import engine.gameManager.LootManager; import engine.gameManager.LootManager;
import org.pmw.tinylog.Logger;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.List; import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
public class ItemTableEntry { public class ItemTableEntry {
public int minRoll; public int minRoll;
@@ -37,23 +35,11 @@ public class ItemTableEntry {
List<ItemTableEntry> itemTableEntryList; List<ItemTableEntry> itemTableEntryList;
itemTableEntryList = LootManager._itemTables.get(itemTable); itemTableEntryList = LootManager._itemTables.get(itemTable);
if(itemTableEntryList != null) {
for (ItemTableEntry iteration : itemTableEntryList) for (ItemTableEntry iteration : itemTableEntryList)
if (roll >= iteration.minRoll && roll <= iteration.maxRoll) if (roll >= iteration.minRoll && roll <= iteration.maxRoll)
itemTableEntry = iteration; itemTableEntry = iteration;
}
return itemTableEntry; return itemTableEntry;
} }
public static Integer getRandomItem(int itemTable) {
int id = 0;
List<ItemTableEntry> itemTableEntryList;
itemTableEntryList = LootManager._itemTables.get(itemTable);
if(itemTableEntryList != null && itemTableEntryList.size() > 1){
id = itemTableEntryList.get(ThreadLocalRandom.current().nextInt(0, itemTableEntryList.size())).cacheID;
}
return id;
}
} }
+2 -2
View File
@@ -33,11 +33,11 @@ public class ModTableEntry {
List<ModTableEntry> itemTableEntryList; List<ModTableEntry> itemTableEntryList;
itemTableEntryList = LootManager._modTables.get(modTablwe); itemTableEntryList = LootManager._modTables.get(modTablwe);
if(itemTableEntryList != null) {
for (ModTableEntry iteration : itemTableEntryList) for (ModTableEntry iteration : itemTableEntryList)
if (roll >= iteration.minRoll && roll <= iteration.maxRoll) if (roll >= iteration.minRoll && roll <= iteration.maxRoll)
modTableEntry = iteration; modTableEntry = iteration;
}
return modTableEntry; return modTableEntry;
} }
} }
+1 -1
View File
@@ -220,7 +220,7 @@ public class Bounds {
//player is inside building region, skip collision check. we only do collision from the outside. //player is inside building region, skip collision check. we only do collision from the outside.
if (player.region != null && player.region.parentBuildingID == building.getObjectUUID()) if (player.region != null && player.region.parentBuildingID == building.getObjectUUID())
continue; continue;
if (building.getBounds() == null || building.getBounds().colliders == null) if (building.getBounds().colliders == null)
continue; continue;
for (Colliders collider : building.getBounds().colliders) { for (Colliders collider : building.getBounds().colliders) {
+131 -200
View File
@@ -9,7 +9,7 @@
package engine.mobileAI; package engine.mobileAI;
import engine.Enum; import engine.Enum;
import engine.InterestManagement.InterestManager; import engine.Enum.DispatchChannel;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.gameManager.*; import engine.gameManager.*;
import engine.math.Vector3f; import engine.math.Vector3f;
@@ -19,7 +19,7 @@ import engine.mobileAI.utilities.CombatUtilities;
import engine.mobileAI.utilities.MovementUtilities; import engine.mobileAI.utilities.MovementUtilities;
import engine.net.DispatchMessage; import engine.net.DispatchMessage;
import engine.net.client.msg.PerformActionMsg; import engine.net.client.msg.PerformActionMsg;
import engine.net.client.msg.UpdateStateMsg; import engine.net.client.msg.PowerProjectileMsg;
import engine.objects.*; import engine.objects.*;
import engine.powers.ActionsBase; import engine.powers.ActionsBase;
import engine.powers.PowersBase; import engine.powers.PowersBase;
@@ -49,19 +49,18 @@ public class MobAI {
return; return;
} }
//mob casting disabled if (target.getObjectType() == Enum.GameObjectType.PlayerCharacter && canCast(mob)) {
//if (target.getObjectType() == Enum.GameObjectType.PlayerCharacter && canCast(mob)) {
//if (mob.isPlayerGuard() == false && MobCast(mob)) { if (mob.isPlayerGuard() == false && MobCast(mob)) {
// mob.updateLocation(); mob.updateLocation();
// return; return;
//} }
//if (mob.isPlayerGuard() == true && GuardCast(mob)) { if (mob.isPlayerGuard() == true && GuardCast(mob)) {
// mob.updateLocation(); mob.updateLocation();
// return; return;
//} }
//} }
if (!CombatUtilities.inRangeToAttack(mob, target)) if (!CombatUtilities.inRangeToAttack(mob, target))
return; return;
@@ -83,16 +82,6 @@ public class MobAI {
mob.updateLocation(); mob.updateLocation();
if(mob.StrongholdGuardian || mob.StrongholdEpic){
// attempt to ground all players in attack range
for(int i : mob.playerAgroMap.keySet()){
PlayerCharacter tar = PlayerCharacter.getFromCache(i);
if(tar != null && tar.loc.distanceSquared(mob.loc) < 80){
PowersManager.applyPower(mob,tar,tar.loc, 111111,40,false);
}
}
}
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackTarget" + " " + e.getMessage()); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackTarget" + " " + e.getMessage());
} }
@@ -107,16 +96,10 @@ public class MobAI {
return; return;
} }
if(target.getPet() != null && target.getPet().isAlive() && !target.getPet().isSiege()){ if (mob.behaviourType.callsForHelp)
mob.setCombatTarget(target.getPet());
AttackTarget(mob,mob.combatTarget);
return;
}
if (mob.BehaviourType.callsForHelp)
MobCallForHelp(mob); MobCallForHelp(mob);
if (MovementUtilities.outOfAggroRange(mob, target)) { if (!MovementUtilities.inRangeDropAggro(mob, target)) {
mob.setCombatTarget(null); mob.setCombatTarget(null);
return; return;
} }
@@ -163,12 +146,6 @@ public class MobAI {
if (target.getPet().getCombatTarget() == null && target.getPet().assist == true) if (target.getPet().getCombatTarget() == null && target.getPet().assist == true)
target.getPet().setCombatTarget(mob); target.getPet().setCombatTarget(mob);
try{
InterestManager.forceLoad(mob);
}catch(Exception e){
}
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackPlayer" + " " + e.getMessage()); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackPlayer" + " " + e.getMessage());
} }
@@ -179,9 +156,6 @@ public class MobAI {
try { try {
if(mob == null || target == null)
return;
if (target.getRank() == -1 || !target.isVulnerable() || BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) { if (target.getRank() == -1 || !target.isVulnerable() || BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) {
mob.setCombatTarget(null); mob.setCombatTarget(null);
return; return;
@@ -191,8 +165,8 @@ public class MobAI {
if (playercity != null) if (playercity != null)
for (Mob guard : playercity.getParent().zoneMobSet) for (Mob guard : playercity.getParent().zoneMobSet)
if (guard.BehaviourType != null && guard.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) if (guard.behaviourType != null && guard.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
if (guard.getCombatTarget() == null && guard.getGuild() != null && mob.getGuild() != null && !guard.getGuild().equals(mob.getGuild())) if (guard.getCombatTarget() == null && !guard.getGuild().equals(mob.getGuild()))
guard.setCombatTarget(mob); guard.setCombatTarget(mob);
if (mob.isSiege()) if (mob.isSiege())
@@ -221,11 +195,11 @@ public class MobAI {
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
} }
//if (mob.isSiege()) { if (mob.isSiege()) {
// PowerProjectileMsg ppm = new PowerProjectileMsg(mob, target); PowerProjectileMsg ppm = new PowerProjectileMsg(mob, target);
// ppm.setRange(50); ppm.setRange(50);
// DispatchMessage.dispatchMsgToInterestArea(mob, ppm, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); DispatchMessage.dispatchMsgToInterestArea(mob, ppm, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
//} }
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackBuilding" + " " + e.getMessage()); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackBuilding" + " " + e.getMessage());
@@ -286,7 +260,7 @@ public class MobAI {
//guard captains inherit barracks patrol points dynamically //guard captains inherit barracks patrol points dynamically
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) { if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) {
Building barracks = mob.building; Building barracks = mob.building;
@@ -306,7 +280,7 @@ public class MobAI {
MovementUtilities.aiMove(mob, mob.destination, true); 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()) for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet())
//make sure mob is out of combat stance //make sure mob is out of combat stance
@@ -334,32 +308,28 @@ public class MobAI {
if (mob == null) if (mob == null)
return false; return false;
if (mob.nextCastTime == 0) if(mob.isPlayerGuard == true){
mob.nextCastTime = System.currentTimeMillis() - 1000L;
if(mob.nextCastTime > System.currentTimeMillis()) int contractID;
return false;
if(mob.isPlayerGuard){ if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion))
contractID = mob.guardCaptain.contract.getContractID();
int contractID = 0; else
if(mob.BehaviourType.equals(Enum.MobBehaviourType.GuardMinion) && mob.npcOwner != null)
contractID = mob.npcOwner.contract.getContractID();
else if(mob.contract != null)
contractID = mob.contract.getContractID(); contractID = mob.contract.getContractID();
if(Enum.MinionType.ContractToMinionMap.containsKey(contractID) && !Enum.MinionType.ContractToMinionMap.get(contractID).isMage()) if(Enum.MinionType.ContractToMinionMap.get(contractID).isMage() == false)
return false; return false;
} }
if (mob.mobPowers == null || mob.mobPowers.isEmpty()) if (mob.mobPowers.isEmpty())
return false; return false;
if (!mob.canSee((PlayerCharacter) mob.getCombatTarget())) { if (!mob.canSee((PlayerCharacter) mob.getCombatTarget())) {
mob.setCombatTarget(null); mob.setCombatTarget(null);
return false; return false;
} }
if (mob.nextCastTime == 0)
mob.nextCastTime = System.currentTimeMillis();
return mob.nextCastTime <= System.currentTimeMillis(); return mob.nextCastTime <= System.currentTimeMillis();
@@ -380,7 +350,7 @@ public class MobAI {
ArrayList<Integer> purgeTokens; ArrayList<Integer> purgeTokens;
AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget(); AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget();
if (mob.BehaviourType.callsForHelp) if (mob.behaviourType.callsForHelp)
MobCallForHelp(mob); MobCallForHelp(mob);
// Generate a list of tokens from the mob powers for this mobile. // Generate a list of tokens from the mob powers for this mobile.
@@ -418,9 +388,6 @@ public class MobAI {
PowersBase mobPower = PowersManager.getPowerByToken(powerToken); PowersBase mobPower = PowersManager.getPowerByToken(powerToken);
if(mobPower.powerCategory.equals(Enum.PowerCategoryType.DEBUFF))
return false;
//check for hit-roll //check for hit-roll
if (mobPower.requiresHitRoll) if (mobPower.requiresHitRoll)
@@ -433,7 +400,7 @@ public class MobAI {
PerformActionMsg msg; PerformActionMsg msg;
if (!mob.StrongholdCommander && !mob.StrongholdEpic && (!mobPower.isHarmful() || mobPower.targetSelf)) { if (!mobPower.isHarmful() || mobPower.targetSelf) {
PowersManager.useMobPower(mob, mob, mobPower, powerRank); PowersManager.useMobPower(mob, mob, mobPower, powerRank);
msg = PowersManager.createPowerMsg(mobPower, powerRank, mob, mob); msg = PowersManager.createPowerMsg(mobPower, powerRank, mob, mob);
} else { } else {
@@ -444,9 +411,9 @@ public class MobAI {
msg.setUnknown04(2); msg.setUnknown04(2);
PowersManager.finishUseMobPower(msg, mob, 0, 0); PowersManager.finishUseMobPower(msg, mob, 0, 0);
long delay = 20000L; long randomCooldown = (long)((ThreadLocalRandom.current().nextInt(10,15) * 1000) * MobAIThread.AI_CAST_FREQUENCY);
mob.nextCastTime = System.currentTimeMillis() + delay;
mob.nextCastTime = System.currentTimeMillis() + randomCooldown;
return true; return true;
} }
} catch (Exception e) { } catch (Exception e) {
@@ -466,7 +433,7 @@ public class MobAI {
ArrayList<Integer> purgeTokens; ArrayList<Integer> purgeTokens;
AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget(); AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget();
if (mob.BehaviourType.callsForHelp) if (mob.behaviourType.callsForHelp)
MobCallForHelp(mob); MobCallForHelp(mob);
// Generate a list of tokens from the mob powers for this mobile. // Generate a list of tokens from the mob powers for this mobile.
@@ -569,6 +536,7 @@ public class MobAI {
PowersManager.finishUseMobPower(msg, mob, 0, 0); PowersManager.finishUseMobPower(msg, mob, 0, 0);
long randomCooldown = (long)((ThreadLocalRandom.current().nextInt(10,15) * 1000) * MobAIThread.AI_CAST_FREQUENCY); long randomCooldown = (long)((ThreadLocalRandom.current().nextInt(10,15) * 1000) * MobAIThread.AI_CAST_FREQUENCY);
mob.nextCastTime = System.currentTimeMillis() + randomCooldown;
return true; return true;
} }
} catch (Exception e) { } catch (Exception e) {
@@ -596,7 +564,7 @@ public class MobAI {
Zone mobCamp = mob.getParentZone(); Zone mobCamp = mob.getParentZone();
for (Mob helper : mobCamp.zoneMobSet) { 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()); helper.setCombatTarget(mob.getCombatTarget());
callGotResponse = true; callGotResponse = true;
} }
@@ -640,8 +608,8 @@ public class MobAI {
if (mob.despawned && mob.isPlayerGuard) { if (mob.despawned && mob.isPlayerGuard) {
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) { if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) {
if (mob.npcOwner.isAlive() == false || ((Mob) mob.npcOwner).despawned == true) { if (mob.guardCaptain.isAlive() == false || ((Mob) mob.guardCaptain).despawned == true) {
//minions don't respawn while guard captain is dead //minions don't respawn while guard captain is dead
@@ -657,6 +625,9 @@ public class MobAI {
//check to send mob home for player guards to prevent exploit of dragging guards away and then teleporting //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)
CheckToSendMobHome(mob);
return; return;
} }
@@ -675,11 +646,7 @@ public class MobAI {
return; return;
} }
if(mob.isAlive()) if (mob.behaviourType.equals(Enum.MobBehaviourType.Pet1) == false)
if(!mob.getMovementLoc().equals(Vector3fImmutable.ZERO))
mob.setLoc(mob.getMovementLoc());
if(mob.isPet() == false && mob.isPlayerGuard == false)
CheckToSendMobHome(mob); CheckToSendMobHome(mob);
if (mob.getCombatTarget() != null) { if (mob.getCombatTarget() != null) {
@@ -706,7 +673,7 @@ public class MobAI {
} }
} }
switch (mob.BehaviourType) { switch (mob.behaviourType) {
case GuardCaptain: case GuardCaptain:
GuardCaptainLogic(mob); GuardCaptainLogic(mob);
break; break;
@@ -717,6 +684,7 @@ public class MobAI {
GuardWallArcherLogic(mob); GuardWallArcherLogic(mob);
break; break;
case Pet1: case Pet1:
case SiegeEngine:
PetLogic(mob); PetLogic(mob);
break; break;
case HamletGuard: case HamletGuard:
@@ -726,8 +694,6 @@ public class MobAI {
DefaultLogic(mob); DefaultLogic(mob);
break; break;
} }
if(mob.isAlive())
RecoverHealth(mob);
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage()); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage());
} }
@@ -742,7 +708,7 @@ public class MobAI {
if (!aiAgent.isAlive()) if (!aiAgent.isAlive())
return; return;
ConcurrentHashMap<Integer, Boolean> loadedPlayers = aiAgent.playerAgroMap; ConcurrentHashMap<Integer, Float> loadedPlayers = aiAgent.playerAgroMap;
for (Entry playerEntry : loadedPlayers.entrySet()) { for (Entry playerEntry : loadedPlayers.entrySet()) {
@@ -817,33 +783,39 @@ public class MobAI {
mob.updateLocation(); mob.updateLocation();
switch (mob.BehaviourType) { switch (mob.behaviourType) {
case Pet1: case Pet1:
if (mob.getOwner() == null)
if ((PlayerCharacter) mob.guardCaptain == null)
return; return;
if (!mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID())) {
if (!mob.playerAgroMap.containsKey(((PlayerCharacter) mob.guardCaptain).getObjectUUID())) {
//mob no longer has its owner loaded, translocate pet to owner //mob no longer has its owner loaded, translocate pet to owner
MovementManager.translocate(mob, mob.getOwner().getLoc(), null);
MovementManager.translocate(mob, ((PlayerCharacter) mob.guardCaptain).getLoc(), null);
return; return;
} }
if (mob.getCombatTarget() == null) { if (mob.getCombatTarget() == null) {
//move back to owner //move back to owner
if (CombatUtilities.inRange2D(mob, mob.getOwner(), 6))
if (CombatUtilities.inRange2D(mob, (PlayerCharacter) mob.guardCaptain, 6))
return; return;
mob.destination = mob.getOwner().getLoc();
mob.destination = ((PlayerCharacter) mob.guardCaptain).getLoc();
MovementUtilities.moveToLocation(mob, mob.destination, 5); MovementUtilities.moveToLocation(mob, mob.destination, 5);
} else } else
chaseTarget(mob); chaseTarget(mob);
break; break;
case GuardMinion: case GuardMinion:
if (!mob.npcOwner.isAlive() && mob.getCombatTarget() == null) if (!mob.guardCaptain.isAlive() || ((Mob) mob.guardCaptain).despawned)
randomGuardPatrolPoint(mob); randomGuardPatrolPoint(mob);
else { else {
if (mob.getCombatTarget() != null) { if (mob.getCombatTarget() != null) {
@@ -862,7 +834,6 @@ public class MobAI {
chaseTarget(mob); chaseTarget(mob);
} }
break; break;
} }
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckMobMovement" + " " + e.getMessage()); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckMobMovement" + " " + e.getMessage());
@@ -890,7 +861,9 @@ public class MobAI {
return; return;
} }
//No items in inventory. //No items in inventory.
} else if (aiAgent.isHasLoot()) { } else {
//Mob's Loot has been looted.
if (aiAgent.isHasLoot()) {
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) { if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) {
aiAgent.despawn(); aiAgent.despawn();
aiAgent.deathTime = System.currentTimeMillis(); aiAgent.deathTime = System.currentTimeMillis();
@@ -904,17 +877,10 @@ public class MobAI {
return; return;
} }
} }
return;
} }
} else if (System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000))) {
if(Mob.discDroppers.contains(aiAgent)) if (Zone.respawnQue.contains(aiAgent) == false) {
return;
if(aiAgent.StrongholdGuardian || aiAgent.StrongholdEpic || aiAgent.StrongholdCommander)
return;
if (aiAgent.despawned && System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000L))) {
if (!Zone.respawnQue.contains(aiAgent)) {
Zone.respawnQue.add(aiAgent); Zone.respawnQue.add(aiAgent);
} }
} }
@@ -934,10 +900,9 @@ public class MobAI {
if (mob.getCombatTarget() == null) if (mob.getCombatTarget() == null)
return; return;
if(!mob.isCombat()) if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false &&
enterCombat(mob); mob.behaviourType.equals(Enum.MobBehaviourType.Pet1) == false) {
if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.outOfAggroRange(mob, (PlayerCharacter) mob.getCombatTarget()) && mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) {
mob.setCombatTarget(null); mob.setCombatTarget(null);
return; return;
} }
@@ -951,31 +916,20 @@ public class MobAI {
private static void CheckToSendMobHome(Mob mob) { private static void CheckToSendMobHome(Mob mob) {
if(mob.isNecroPet())
return;
try { try {
if (mob.behaviourType.isAgressive) {
//trebs dont recall
if(mob.isSiege())
return;
if(mob.BehaviourType.equals(Enum.MobBehaviourType.Pet1)){
if(mob.loc.distanceSquared(mob.getOwner().loc) > 60 * 60)
mob.teleport(mob.getOwner().loc);
return;
}
if (mob.BehaviourType.isAgressive) {
if (mob.isPlayerGuard()) { if (mob.isPlayerGuard()) {
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
CheckForPlayerGuardAggro(mob); CheckForPlayerGuardAggro(mob);
} else { } else {
CheckForAggro(mob); CheckForAggro(mob);
} }
} }
if (mob.getCombatTarget() != null && CombatUtilities.inRange2D(mob, mob.getCombatTarget(), MobAIThread.AI_BASE_AGGRO_RANGE * 0.5f))
return;
if (mob.isPlayerGuard() && !mob.despawned) { if (mob.isPlayerGuard() && !mob.despawned) {
City current = ZoneManager.getCityAtLocation(mob.getLoc()); City current = ZoneManager.getCityAtLocation(mob.getLoc());
@@ -985,7 +939,8 @@ public class MobAI {
PowersBase recall = PowersManager.getPowerByToken(-1994153779); PowersBase recall = PowersManager.getPowerByToken(-1994153779);
PowersManager.useMobPower(mob, mob, recall, 40); PowersManager.useMobPower(mob, mob, recall, 40);
mob.setCombatTarget(null); mob.setCombatTarget(null);
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal() && mob.isAlive()) {
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain) && mob.isAlive()) {
//guard captain pulls his minions home with him //guard captain pulls his minions home with him
@@ -995,15 +950,14 @@ public class MobAI {
} }
} }
} }
} else if (!MovementUtilities.inRangeOfBindLocation(mob)) { } else if (MovementUtilities.inRangeOfBindLocation(mob) == false) {
PowersBase recall = PowersManager.getPowerByToken(-1994153779); PowersBase recall = PowersManager.getPowerByToken(-1994153779);
PowersManager.useMobPower(mob, mob, recall, 40); PowersManager.useMobPower(mob, mob, recall, 40);
mob.setCombatTarget(null); mob.setCombatTarget(null);
for (Entry playerEntry : mob.playerAgroMap.entrySet()) for (Integer playerEntry : mob.playerAgroMap.keySet())
PlayerCharacter.getFromCache((int) playerEntry.getKey()).setHateValue(0); mob.playerAgroMap.put(playerEntry,0f);
mob.setCombatTarget(null);
} }
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckToSendMobHome" + " " + e.getMessage()); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckToSendMobHome" + " " + e.getMessage());
@@ -1014,11 +968,6 @@ public class MobAI {
try { try {
if(mob.combatTarget != null && mob.combatTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && !mob.canSee((PlayerCharacter)mob.combatTarget)){
mob.setCombatTarget(null);
return;
}
float rangeSquared = mob.getRange() * mob.getRange(); float rangeSquared = mob.getRange() * mob.getRange();
float distanceSquared = mob.getLoc().distanceSquared2D(mob.getCombatTarget().getLoc()); float distanceSquared = mob.getLoc().distanceSquared2D(mob.getCombatTarget().getLoc());
@@ -1062,7 +1011,7 @@ public class MobAI {
//dont scan self. //dont scan self.
if (mob.equals(awoMob) || (mob.agentType.equals(Enum.AIAgentType.GUARD)) || (mob.agentType.equals(Enum.AIAgentType.PET))) if (mob.equals(awoMob) || (mob.agentType.equals(Enum.AIAgentType.GUARD)) == true)
continue; continue;
Mob aggroMob = (Mob) awoMob; Mob aggroMob = (Mob) awoMob;
@@ -1072,7 +1021,7 @@ public class MobAI {
if ((aggroMob.agentType.equals(Enum.AIAgentType.GUARD))) if ((aggroMob.agentType.equals(Enum.AIAgentType.GUARD)))
continue; continue;
if(aggroMob.BehaviourType.equals(Enum.MobBehaviourType.Pet1)) if (aggroMob.behaviourType.equals(Enum.MobBehaviourType.Pet1))
continue; continue;
if (mob.getLoc().distanceSquared2D(aggroMob.getLoc()) > sqr(50)) if (mob.getLoc().distanceSquared2D(aggroMob.getLoc()) > sqr(50))
@@ -1085,22 +1034,9 @@ public class MobAI {
} }
} }
public static void checkToDropGuardAggro(Mob mob){
City city = mob.guardedCity;
if(city == null)
return;
if(mob.combatTarget == null)
return;
//if(city._playerMemory.contains(mob.combatTarget.getObjectUUID()) && mob.combatTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
// mob.setCombatTarget(null);
}
public static void GuardCaptainLogic(Mob mob) { public static void GuardCaptainLogic(Mob mob) {
try { try {
checkToDropGuardAggro(mob);
if (mob.getCombatTarget() == null) if (mob.getCombatTarget() == null)
CheckForPlayerGuardAggro(mob); CheckForPlayerGuardAggro(mob);
@@ -1115,6 +1051,7 @@ public class MobAI {
mob.setCombatTarget(newTarget); mob.setCombatTarget(newTarget);
} }
CheckMobMovement(mob); CheckMobMovement(mob);
CheckForAttack(mob); CheckForAttack(mob);
} catch (Exception e) { } catch (Exception e) {
@@ -1125,16 +1062,28 @@ public class MobAI {
public static void GuardMinionLogic(Mob mob) { public static void GuardMinionLogic(Mob mob) {
try { try {
checkToDropGuardAggro(mob); if (!mob.guardCaptain.isAlive()) {
boolean isComanded = mob.npcOwner.isAlive(); if (mob.getCombatTarget() == null) {
if (!isComanded) { CheckForPlayerGuardAggro(mob);
GuardCaptainLogic(mob);
} else { } else {
if (mob.npcOwner.getCombatTarget() != null)
mob.setCombatTarget(mob.npcOwner.getCombatTarget()); AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
else
if (mob.getCombatTarget() != null) if (newTarget != null) {
if (newTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
if (GuardCanAggro(mob, (PlayerCharacter) newTarget))
mob.setCombatTarget(newTarget);
} else
mob.setCombatTarget(newTarget);
}
}
}else {
if (mob.guardCaptain.getCombatTarget() != null)
mob.setCombatTarget(mob.guardCaptain.getCombatTarget());
else if (mob.getCombatTarget() != null)
mob.setCombatTarget(null); mob.setCombatTarget(null);
} }
CheckMobMovement(mob); CheckMobMovement(mob);
@@ -1147,8 +1096,6 @@ public class MobAI {
public static void GuardWallArcherLogic(Mob mob) { public static void GuardWallArcherLogic(Mob mob) {
try { try {
checkToDropGuardAggro(mob);
if (mob.getCombatTarget() == null) if (mob.getCombatTarget() == null)
CheckForPlayerGuardAggro(mob); CheckForPlayerGuardAggro(mob);
else else
@@ -1162,18 +1109,31 @@ public class MobAI {
try { try {
if (mob.getOwner() == null && mob.isNecroPet() == false && mob.isSiege() == false)
if (mob.guardCaptain == null && mob.isNecroPet() == false && mob.isSiege() == false)
if (ZoneManager.getSeaFloor().zoneMobSet.contains(mob)) if (ZoneManager.getSeaFloor().zoneMobSet.contains(mob))
mob.killCharacter("no owner"); mob.killCharacter("no owner");
if(!mob.isSiege()) if (MovementUtilities.canMove(mob) && mob.behaviourType.canRoam)
mob.BehaviourType.canRoam = true;
if (MovementUtilities.canMove(mob) && mob.BehaviourType.canRoam)
CheckMobMovement(mob); CheckMobMovement(mob);
CheckForAttack(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) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: PetLogic" + " " + e.getMessage()); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: PetLogic" + " " + e.getMessage());
} }
@@ -1204,7 +1164,7 @@ public class MobAI {
if (mob.getCombatTarget() != null && mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false) if (mob.getCombatTarget() != null && mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false)
mob.setCombatTarget(null); mob.setCombatTarget(null);
if (mob.BehaviourType.isAgressive) { if (mob.behaviourType.isAgressive) {
AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob); AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
@@ -1212,7 +1172,7 @@ public class MobAI {
mob.setCombatTarget(newTarget); mob.setCombatTarget(newTarget);
else { else {
if (mob.getCombatTarget() == null) { if (mob.getCombatTarget() == null) {
if (mob.BehaviourType == Enum.MobBehaviourType.HamletGuard) if (mob.behaviourType == Enum.MobBehaviourType.HamletGuard)
SafeGuardAggro(mob); //safehold guard SafeGuardAggro(mob); //safehold guard
else else
CheckForAggro(mob); //normal aggro CheckForAggro(mob); //normal aggro
@@ -1222,15 +1182,14 @@ public class MobAI {
//check if mob can move for patrol or moving to target //check if mob can move for patrol or moving to target
if (mob.BehaviourType.canRoam) if (mob.behaviourType.canRoam)
CheckMobMovement(mob); CheckMobMovement(mob);
//check if mob can attack if it isn't wimpy //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); CheckForAttack(mob);
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DefaultLogic" + " " + e.getMessage()); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DefaultLogic" + " " + e.getMessage());
} }
@@ -1245,7 +1204,7 @@ public class MobAI {
if (!mob.isAlive()) if (!mob.isAlive())
return; return;
ConcurrentHashMap<Integer, Boolean> loadedPlayers = mob.playerAgroMap; ConcurrentHashMap<Integer, Float> loadedPlayers = mob.playerAgroMap;
for (Entry playerEntry : loadedPlayers.entrySet()) { for (Entry playerEntry : loadedPlayers.entrySet()) {
@@ -1293,8 +1252,8 @@ public class MobAI {
if (mob.getGuild().getNation().equals(target.getGuild().getNation())) if (mob.getGuild().getNation().equals(target.getGuild().getNation()))
return false; return false;
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) { if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) {
if (((Mob) mob.npcOwner).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) { if (((Mob) mob.guardCaptain).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
return true; return true;
} }
} else if (mob.building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) { } else if (mob.building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
@@ -1378,7 +1337,7 @@ public class MobAI {
MovementUtilities.aiMove(mob, mob.destination, true); MovementUtilities.aiMove(mob, mob.destination, true);
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) { if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) {
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) { for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) {
//make sure mob is out of combat stance //make sure mob is out of combat stance
@@ -1405,7 +1364,7 @@ public class MobAI {
float CurrentHateValue = 0; float CurrentHateValue = 0;
if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
CurrentHateValue = ((PlayerCharacter) mob.getCombatTarget()).getHateValue(); CurrentHateValue = mob.playerAgroMap.get(mob.combatTarget.getObjectUUID()).floatValue();
AbstractWorldObject mostHatedTarget = null; AbstractWorldObject mostHatedTarget = null;
@@ -1416,8 +1375,8 @@ public class MobAI {
if (potentialTarget.equals(mob.getCombatTarget())) if (potentialTarget.equals(mob.getCombatTarget()))
continue; continue;
if (potentialTarget != null && potentialTarget.getHateValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) { if (potentialTarget != null && mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) {
CurrentHateValue = potentialTarget.getHateValue(); CurrentHateValue = mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue();
mostHatedTarget = potentialTarget; mostHatedTarget = potentialTarget;
} }
@@ -1428,32 +1387,4 @@ public class MobAI {
} }
return null; return null;
} }
public static void RecoverHealth(Mob mob) {
//recover health
try {
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: RecoverHealth" + " " + e.getMessage());
}
}
public static void enterCombat(Mob mob){
mob.setCombat(true);
UpdateStateMsg rwss = new UpdateStateMsg();
rwss.setPlayer(mob);
DispatchMessage.sendToAllInRange(mob, rwss);
}
} }
@@ -1,33 +0,0 @@
package engine.mobileAI.MobBehaviours;
import engine.gameManager.ZoneManager;
import engine.mobileAI.utilities.MovementUtilities;
import engine.objects.Mob;
import org.pmw.tinylog.Logger;
public class Pet {
public static void run(Mob pet){
try {
if(StaticBehaviours.EarlyExit(pet))
return;
if (pet.getOwner() == null && pet.isNecroPet() == false && pet.isSiege() == false)
if (ZoneManager.getSeaFloor().zoneMobSet.contains(pet))
pet.killCharacter("no owner");
if(!pet.isSiege())
pet.BehaviourType.canRoam = true;
if (MovementUtilities.canMove(pet) && pet.BehaviourType.canRoam)
StaticBehaviours.CheckMobMovement(pet);
StaticBehaviours.CheckForAttack(pet);
} catch (Exception e) {
Logger.info(pet.getObjectUUID() + " " + pet.getName() + " Failed At: PetLogic" + " " + e.getMessage());
}
}
}
@@ -1,146 +0,0 @@
package engine.mobileAI.MobBehaviours;
import engine.Enum;
import engine.objects.AbstractWorldObject;
import engine.objects.Mob;
import engine.objects.PlayerCharacter;
import org.pmw.tinylog.Logger;
public class PlayerGuard {
public static void run(Mob guard) {
if(StaticBehaviours.EarlyExit(guard))
return;
if (guard.mobPowers.isEmpty()) {
//mele
if (guard.BehaviourType.equals(Enum.MobBehaviourType.GuardWallArcher)) {
GuardWallArcherLogic(guard);
} else {
if (guard.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) {
GuardCaptainLogic(guard);
} else if (guard.BehaviourType.equals(Enum.MobBehaviourType.GuardMinion)) {
GuardMinionLogic(guard);
}
}
} else {
//caster
if (guard.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) {
MagisterCaptainLogic(guard);
} else if (guard.BehaviourType.equals(Enum.MobBehaviourType.GuardMinion)) {
MagisterMinionLogic(guard);
}
}
}
public static void GuardCaptainLogic(Mob mob) {
try {
StaticBehaviours.checkToDropGuardAggro(mob);
if (mob.getCombatTarget() == null)
StaticBehaviours.CheckForPlayerGuardAggro(mob);
AbstractWorldObject newTarget = StaticBehaviours.ChangeTargetFromHateValue(mob);
if (newTarget != null) {
if (newTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
if (StaticBehaviours.GuardCanAggro(mob, (PlayerCharacter) newTarget))
mob.setCombatTarget(newTarget);
} else
mob.setCombatTarget(newTarget);
}
StaticBehaviours.CheckMobMovement(mob);
StaticBehaviours.CheckForAttack(mob);
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardCaptainLogic" + " " + e.getMessage());
}
}
public static void GuardMinionLogic(Mob mob) {
try {
StaticBehaviours.checkToDropGuardAggro(mob);
boolean isComanded = mob.npcOwner.isAlive();
if (!isComanded) {
GuardCaptainLogic(mob);
}else {
if (mob.npcOwner.getCombatTarget() != null)
mob.setCombatTarget(mob.npcOwner.getCombatTarget());
else
if (mob.getCombatTarget() != null)
mob.setCombatTarget(null);
}
StaticBehaviours.CheckMobMovement(mob);
StaticBehaviours.CheckForAttack(mob);
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardMinionLogic" + " " + e.getMessage());
}
}
public static void GuardWallArcherLogic(Mob mob) {
try {
StaticBehaviours.checkToDropGuardAggro(mob);
if (mob.getCombatTarget() == null)
StaticBehaviours.CheckForPlayerGuardAggro(mob);
else
StaticBehaviours.CheckForAttack(mob);
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardWallArcherLogic" + " " + e.getMessage());
}
}
public static void MagisterCaptainLogic(Mob mob){
try {
StaticBehaviours.checkToDropGuardAggro(mob);
if (mob.getCombatTarget() == null)
StaticBehaviours.CheckForPlayerGuardAggro(mob);
AbstractWorldObject newTarget = StaticBehaviours.ChangeTargetFromHateValue(mob);
if (newTarget != null) {
if (newTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
if (StaticBehaviours.GuardCanAggro(mob, (PlayerCharacter) newTarget))
mob.setCombatTarget(newTarget);
} else
mob.setCombatTarget(newTarget);
}
StaticBehaviours.CheckMobMovement(mob);
CheckForCast(mob);
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardCaptainLogic" + " " + e.getMessage());
}
}
public static void MagisterMinionLogic(Mob mob){
try {
StaticBehaviours.checkToDropGuardAggro(mob);
boolean isComanded = mob.npcOwner.isAlive();
if (!isComanded) {
MagisterCaptainLogic(mob);
}else {
if (mob.npcOwner.getCombatTarget() != null)
mob.setCombatTarget(mob.npcOwner.getCombatTarget());
else
if (mob.getCombatTarget() != null)
mob.setCombatTarget(null);
}
StaticBehaviours.CheckMobMovement(mob);
CheckForCast(mob);
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardMinionLogic" + " " + e.getMessage());
}
}
public static void CheckForCast(Mob mob){
}
}
@@ -1,27 +0,0 @@
package engine.mobileAI.MobBehaviours;
import engine.Enum;
import engine.objects.Mob;
public class SiegeEngine {
public static void run(Mob engine){
if(StaticBehaviours.EarlyExit(engine))
return;
if(engine.getOwner() == null)
return;
if(engine.combatTarget == null)
return;
if(engine.combatTarget.loc.distanceSquared(engine.loc) > engine.getRange() * engine.getRange())
return;
if(!engine.combatTarget.getObjectType().equals(Enum.GameObjectType.Building))
return;
StaticBehaviours.CheckForAttack(engine);
}
}
@@ -1,53 +0,0 @@
package engine.mobileAI.MobBehaviours;
import engine.Enum;
import engine.objects.AbstractWorldObject;
import engine.objects.Mob;
import org.pmw.tinylog.Logger;
public class Standard {
public static void run(Mob mob){
try {
if(StaticBehaviours.EarlyExit(mob))
return;
//check for players that can be aggroed if mob is agressive and has no target
if (mob.getCombatTarget() != null && !mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()))
mob.setCombatTarget(null);
if (mob.BehaviourType.isAgressive) {
AbstractWorldObject newTarget = StaticBehaviours.ChangeTargetFromHateValue(mob);
if (newTarget != null)
mob.setCombatTarget(newTarget);
else {
if (mob.getCombatTarget() == null) {
if (mob.BehaviourType == Enum.MobBehaviourType.HamletGuard)
StaticBehaviours.SafeGuardAggro(mob); //safehold guard
else
StaticBehaviours.CheckForAggro(mob); //normal aggro
}
}
}
//check if mob can move for patrol or moving to target
if (mob.BehaviourType.canRoam)
StaticBehaviours.CheckMobMovement(mob);
//check if mob can attack if it isn't wimpy
if (!mob.BehaviourType.isWimpy && mob.getCombatTarget() != null)
StaticBehaviours.CheckForAttack(mob);
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DefaultLogic" + " " + e.getMessage());
}
}
}
File diff suppressed because it is too large Load Diff
+6 -16
View File
@@ -3,7 +3,6 @@ package engine.mobileAI.Threads;
import engine.gameManager.ConfigManager; import engine.gameManager.ConfigManager;
import engine.mobileAI.MobAI; import engine.mobileAI.MobAI;
import engine.gameManager.ZoneManager; import engine.gameManager.ZoneManager;
import engine.mobileAI.MobBehaviours.StaticBehaviours;
import engine.objects.Mob; import engine.objects.Mob;
import engine.objects.Zone; import engine.objects.Zone;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
@@ -29,29 +28,20 @@ public class MobAIThread implements Runnable{
AI_BASE_AGGRO_RANGE = (int)(60 * Float.parseFloat(ConfigManager.MB_AI_AGGRO_RANGE.getValue())); AI_BASE_AGGRO_RANGE = (int)(60 * Float.parseFloat(ConfigManager.MB_AI_AGGRO_RANGE.getValue()));
while (true) { while (true) {
for (Zone zone : ZoneManager.getAllZones()) { for (Zone zone : ZoneManager.getAllZones()) {
if (zone != null && zone.zoneMobSet != null) {
synchronized (zone.zoneMobSet) {
for (Mob mob : zone.zoneMobSet) { for (Mob mob : zone.zoneMobSet) {
try { try {
if (mob != null) { if (mob != null)
//MobAI.DetermineAction(mob); MobAI.DetermineAction(mob);
StaticBehaviours.runBehaviour(mob);
}
} catch (Exception e) { } catch (Exception e) {
Logger.error("Error processing Mob [Name: {}, UUID: {}]", mob.getName(), mob.getObjectUUID(), e); Logger.error("Mob: " + mob.getName() + " UUID: " + mob.getObjectUUID() + " ERROR: " + e);
e.printStackTrace();
} }
} }
} }
} }
} }
try {
Thread.sleep(100);
} catch (InterruptedException e) {
Logger.error("AI Thread interrupted", e);
Thread.currentThread().interrupt();
}
}
}
public static void startAIThread() { public static void startAIThread() {
Thread aiThread; Thread aiThread;
aiThread = new Thread(new MobAIThread()); aiThread = new Thread(new MobAIThread());
@@ -13,9 +13,6 @@ import engine.objects.Mob;
import engine.objects.Zone; import engine.objects.Zone;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.util.ArrayList;
import java.util.Collection;
/** /**
* Thread blocks until MagicBane dispatch messages are * Thread blocks until MagicBane dispatch messages are
* enqueued then processes them in FIFO order. The collection * enqueued then processes them in FIFO order. The collection
@@ -28,48 +25,41 @@ import java.util.Collection;
public class MobRespawnThread implements Runnable { public class MobRespawnThread implements Runnable {
private volatile boolean running = true;
private static final long RESPAWN_INTERVAL = 100; // Configurable interval
public MobRespawnThread() { public MobRespawnThread() {
Logger.info("MobRespawnThread initialized."); Logger.info(" MobRespawnThread thread has started!");
} }
@Override @Override
public void run() { public void run() {
while (running) {
while (true) {
try { try {
Collection<Zone> zones = ZoneManager.getAllZones(); for (Zone zone : ZoneManager.getAllZones()) {
if (zones != null) {
for (Zone zone : zones) { if (zone.respawnQue.isEmpty() == false && zone.lastRespawn + 100 < System.currentTimeMillis()) {
synchronized (zone) { // Optional: Synchronize on zone
if (!Zone.respawnQue.isEmpty() && Zone.lastRespawn + RESPAWN_INTERVAL < System.currentTimeMillis()) { Mob respawner = zone.respawnQue.iterator().next();
if (respawner == null)
continue;
Mob respawner = Zone.respawnQue.iterator().next();
if (respawner != null) {
respawner.respawn(); respawner.respawn();
Zone.respawnQue.remove(respawner); zone.respawnQue.remove(respawner);
Zone.lastRespawn = System.currentTimeMillis(); zone.lastRespawn = System.currentTimeMillis();
Thread.sleep(100);
} }
} }
}
}
}
Thread.sleep(100); // Prevent busy-waiting
} catch (Exception e) { } catch (Exception e) {
Logger.error("Error in MobRespawnThread", e); Logger.error(e);
}
}
Logger.info("MobRespawnThread stopped.");
} }
public void stop() {
running = false;
} }
}
public static void startRespawnThread() { public static void startRespawnThread() {
Thread respawnThread = new Thread(new MobRespawnThread()); Thread respawnThread;
respawnThread = new Thread(new MobRespawnThread());
respawnThread.setName("respawnThread"); respawnThread.setName("respawnThread");
respawnThread.start(); respawnThread.start();
} }
@@ -22,6 +22,7 @@ import org.pmw.tinylog.Logger;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import static engine.math.FastMath.sqr; import static engine.math.FastMath.sqr;
import static java.lang.Math.pow;
public class CombatUtilities { public class CombatUtilities {
@@ -47,7 +48,7 @@ public class CombatUtilities {
} }
public static boolean inRange2D(AbstractWorldObject entity1, AbstractWorldObject entity2, double range) { public static boolean inRange2D(AbstractWorldObject entity1, AbstractWorldObject entity2, double range) {
return entity1.getLoc().distance2D(entity2.getLoc()) < range; return entity1.getLoc().distanceSquared2D(entity2.getLoc()) < range * range;
} }
public static void swingIsBlock(Mob agent, AbstractWorldObject target, int animation) { public static void swingIsBlock(Mob agent, AbstractWorldObject target, int animation) {
@@ -100,18 +101,9 @@ public class CombatUtilities {
if (!target.isAlive()) if (!target.isAlive())
return; return;
if(agent.isPet()){ if (AbstractWorldObject.IsAbstractCharacter(target))
try{
damage *= agent.getOwner().ZergMultiplier;
}catch(Exception ignored){
}
}
if (AbstractWorldObject.IsAbstractCharacter(target)) {
//damage = Resists.handleFortitude((AbstractCharacter) target,DamageType.Crush,damage);
trueDamage = ((AbstractCharacter) target).modifyHealth(-damage, agent, false); trueDamage = ((AbstractCharacter) target).modifyHealth(-damage, agent, false);
}else if (target.getObjectType() == GameObjectType.Building) else if (target.getObjectType() == GameObjectType.Building)
trueDamage = ((Building) target).modifyHealth(-damage, agent); trueDamage = ((Building) target).modifyHealth(-damage, agent);
//Don't send 0 damage kay thanx. //Don't send 0 damage kay thanx.
@@ -147,30 +139,37 @@ public class CombatUtilities {
} }
public static boolean triggerDefense(Mob agent, AbstractWorldObject target) { public static boolean triggerDefense(Mob agent, AbstractWorldObject target) {
int defense = 0; int defenseScore = 0;
int atr = agent.mobBase.getAtr(); int attackScore = agent.getAtrHandOne();
if(agent.getBonuses() != null){
atr += agent.getBonuses().getFloat(ModType.OCV,SourceType.None);
atr *= 1 + agent.getBonuses().getFloatPercentAll(ModType.OCV,SourceType.None);
}
switch (target.getObjectType()) { switch (target.getObjectType()) {
case PlayerCharacter: case PlayerCharacter:
PlayerCharacter pc = (PlayerCharacter)target; defenseScore = ((AbstractCharacter) target).getDefenseRating();
pc.combatStats.calculateDefense();
defense = pc.combatStats.defense;
break; break;
case Mob: case Mob:
Mob mob = (Mob) target; Mob mob = (Mob) target;
if (mob.isSiege()) if (mob.isSiege())
defense = atr; defenseScore = attackScore;
else
defense = ((Mob) target).mobBase.getDefense();
break; break;
case Building: case Building:
return false; return false;
} }
return !CombatManager.LandHit(atr,defense);
int hitChance;
if (attackScore > defenseScore || defenseScore == 0)
hitChance = 94;
else if (attackScore == defenseScore && target.getObjectType() == GameObjectType.Mob)
hitChance = 10;
else {
float dif = attackScore / defenseScore;
if (dif <= 0.8f)
hitChance = 4;
else
hitChance = ((int) (450 * (dif - 0.8f)) + 4);
if (target.getObjectType() == GameObjectType.Building)
hitChance = 100;
}
return ThreadLocalRandom.current().nextInt(100) > hitChance;
} }
public static boolean triggerBlock(Mob agent, AbstractWorldObject ac) { public static boolean triggerBlock(Mob agent, AbstractWorldObject ac) {
@@ -208,10 +207,12 @@ public class CombatUtilities {
return; return;
int anim = 75; int anim = 75;
float speed;
//handle the retaliate here because even if the mob misses you can still retaliate if (mainHand)
if (AbstractWorldObject.IsAbstractCharacter(target)) speed = agent.getSpeedHandOne();
CombatManager.handleRetaliate((AbstractCharacter) target, agent); else
speed = agent.getSpeedHandTwo();
DamageType dt = DamageType.Crush; DamageType dt = DamageType.Crush;
@@ -266,12 +267,12 @@ public class CombatUtilities {
if (agent.getEquip().get(1) != null && agent.getEquip().get(2) != null && agent.getEquip().get(2).getItemBase().isShield() == false) { if (agent.getEquip().get(1) != null && agent.getEquip().get(2) != null && agent.getEquip().get(2).getItemBase().isShield() == false) {
//mob is duel wielding and should conduct an attack for each hand //mob is duel wielding and should conduct an attack for each hand
ItemBase weapon1 = agent.getEquip().get(1).getItemBase(); ItemBase weapon1 = agent.getEquip().get(1).getItemBase();
double range1 = getMaxDmg(agent) - getMinDmg(agent); double range1 = getMaxDmg(weapon1.getMinDamage(), agent, weapon1) - getMinDmg(weapon1.getMinDamage(), agent, weapon1);
double damage1 = getMinDmg(agent) + ((ThreadLocalRandom.current().nextFloat() * range1) + (ThreadLocalRandom.current().nextFloat() * range1)) / 2; double damage1 = getMinDmg(weapon1.getMinDamage(), agent, weapon1) + ((ThreadLocalRandom.current().nextFloat() * range1) + (ThreadLocalRandom.current().nextFloat() * range1)) / 2;
swingIsDamage(agent, target, (float) damage1, CombatManager.getSwingAnimation(weapon1, null, true)); swingIsDamage(agent, target, (float) damage1, CombatManager.getSwingAnimation(weapon1, null, true));
ItemBase weapon2 = agent.getEquip().get(2).getItemBase(); ItemBase weapon2 = agent.getEquip().get(2).getItemBase();
double range2 = getMaxDmg(agent) - getMinDmg(agent); double range2 = getMaxDmg(weapon2.getMinDamage(), agent, weapon2) - getMinDmg(weapon2.getMinDamage(), agent, weapon2);
double damage2 = getMinDmg(agent) + ((ThreadLocalRandom.current().nextFloat() * range2) + (ThreadLocalRandom.current().nextFloat() * range2)) / 2; double damage2 = getMinDmg(weapon2.getMinDamage(), agent, weapon2) + ((ThreadLocalRandom.current().nextFloat() * range2) + (ThreadLocalRandom.current().nextFloat() * range2)) / 2;
swingIsDamage(agent, target, (float) damage2, CombatManager.getSwingAnimation(weapon1, null, false)); swingIsDamage(agent, target, (float) damage2, CombatManager.getSwingAnimation(weapon1, null, false));
} else { } else {
swingIsDamage(agent, target, determineDamage(agent), anim); swingIsDamage(agent, target, determineDamage(agent), anim);
@@ -293,6 +294,11 @@ public class CombatUtilities {
if (((Mob) target).isSiege()) if (((Mob) target).isSiege())
return; return;
//handle the retaliate
if (AbstractWorldObject.IsAbstractCharacter(target))
CombatManager.handleRetaliate((AbstractCharacter) target, agent);
if (target.getObjectType() == GameObjectType.Mob) { if (target.getObjectType() == GameObjectType.Mob) {
Mob targetMob = (Mob) target; Mob targetMob = (Mob) target;
if (targetMob.isSiege()) if (targetMob.isSiege())
@@ -316,9 +322,9 @@ public class CombatUtilities {
float damage = 0; float damage = 0;
DamageType dt = getDamageType(agent); DamageType dt = getDamageType(agent);
if (agent.BehaviourType.equals(MobBehaviourType.Pet1)) { if ((agent.agentType.equals(AIAgentType.PET)) == true || agent.isPet() == true || agent.isNecroPet() == true) {
damage = calculateMobDamage(agent); damage = calculatePetDamage(agent);
} else if (agent.isPlayerGuard()) { } else if (agent.isPlayerGuard() == true) {
//damage = calculateGuardDamage(agent); //damage = calculateGuardDamage(agent);
damage = calculateMobDamage(agent); damage = calculateMobDamage(agent);
} else if (agent.getLevel() > 80) { } else if (agent.getLevel() > 80) {
@@ -327,9 +333,9 @@ public class CombatUtilities {
damage = calculateMobDamage(agent); damage = calculateMobDamage(agent);
} }
if (AbstractWorldObject.IsAbstractCharacter(target)) { if (AbstractWorldObject.IsAbstractCharacter(target)) {
//if (((AbstractCharacter) target).isSit()) { if (((AbstractCharacter) target).isSit()) {
// damage *= 2.5f; //increase damage if sitting damage *= 2.5f; //increase damage if sitting
//} }
return (int) (((AbstractCharacter) target).getResists().getResistedDamage(agent, (AbstractCharacter) target, dt, damage, 0)); return (int) (((AbstractCharacter) target).getResists().getResistedDamage(agent, (AbstractCharacter) target, dt, damage, 0));
} }
if (target.getObjectType() == GameObjectType.Building) { if (target.getObjectType() == GameObjectType.Building) {
@@ -358,8 +364,8 @@ public class CombatUtilities {
float min = 40; float min = 40;
float max = 60; float max = 60;
float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None); float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None);
double minDmg = getMinDmg(agent); double minDmg = getMinDmg(min, agent, null);
double maxDmg = getMaxDmg(agent); double maxDmg = getMaxDmg(max, agent, null);
dmgMultiplier += agent.getLevel() * 0.1f; dmgMultiplier += agent.getLevel() * 0.1f;
range = (float) (maxDmg - minDmg); range = (float) (maxDmg - minDmg);
damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2; damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2;
@@ -375,8 +381,8 @@ public class CombatUtilities {
double minDmg = weapon.getMinDamage(); double minDmg = weapon.getMinDamage();
double maxDmg = weapon.getMaxDamage(); double maxDmg = weapon.getMaxDamage();
double min = getMinDmg(agent); double min = getMinDmg(minDmg, agent, weapon);
double max = getMaxDmg(agent); double max = getMaxDmg(maxDmg, agent, weapon);
DamageType dt = weapon.getDamageType(); DamageType dt = weapon.getDamageType();
@@ -417,48 +423,92 @@ public class CombatUtilities {
} }
public static int calculateMobDamage(Mob agent) { public static int calculateMobDamage(Mob agent) {
double minDmg = getMinDmg(agent); ItemBase weapon = null;
double maxDmg = getMaxDmg(agent); double minDmg;
DamageType dt = getDamageType(agent); double maxDmg;
DamageType dt;
//main hand or offhand damage
if (agent.getEquip().get(1) != null)
weapon = agent.getEquip().get(1).getItemBase();
else if (agent.getEquip().get(2) != null)
weapon = agent.getEquip().get(2).getItemBase();
if (weapon != null) {
minDmg = getMinDmg(weapon.getMinDamage(), agent, weapon);
maxDmg = getMaxDmg(weapon.getMaxDamage(), agent, weapon);
dt = weapon.getDamageType();
} else {
minDmg = agent.getMobBase().getDamageMin();
maxDmg = agent.getMobBase().getDamageMax();
dt = DamageType.Crush;
}
AbstractWorldObject target = agent.getCombatTarget(); AbstractWorldObject target = agent.getCombatTarget();
double damage = ThreadLocalRandom.current().nextInt((int)minDmg,(int)maxDmg + 1); float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None);
double range = maxDmg - minDmg;
double damage = minDmg + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2;
if (AbstractWorldObject.IsAbstractCharacter(target)) if (AbstractWorldObject.IsAbstractCharacter(target))
if (((AbstractCharacter) target).isSit()) if (((AbstractCharacter) target).isSit())
damage *= 2.5f; //increase damage if sitting damage *= 2.5f; //increase damage if sitting
if (AbstractWorldObject.IsAbstractCharacter(target)) if (AbstractWorldObject.IsAbstractCharacter(target))
return (int) (((AbstractCharacter) target).getResists().getResistedDamage(agent, (AbstractCharacter) target, dt, (float) damage, 0)); return (int) (((AbstractCharacter) target).getResists().getResistedDamage(agent, (AbstractCharacter) target, dt, (float) damage, 0) * dmgMultiplier);
return 0; return 0;
} }
public static double getMinDmg(Mob agent) { public static double getMinDmg(double min, Mob agent, ItemBase weapon) {
if(agent.getEquip() != null){
if(agent.getEquip().get(ItemSlotType.RHELD) != null){ int primary = agent.getStatStrCurrent();
return agent.minDamageHandOne; int secondary = agent.getStatDexCurrent();
}else if(agent.getEquip().get(ItemSlotType.LHELD) != null){ int focusLevel = 0;
return agent.getMinDamageHandTwo(); int masteryLevel = 0;
if (weapon != null) {
if (weapon.isStrBased() == true) {
primary = agent.getStatStrCurrent();
secondary = agent.getStatDexCurrent();
} else { } else {
return agent.minDamageHandOne; primary = agent.getStatDexCurrent();
secondary = agent.getStatStrCurrent();
if (agent.getSkills().containsKey(weapon.getSkillRequired())) {
focusLevel = (int) agent.getSkills().get(weapon.getSkillRequired()).getModifiedAmount();
} }
}else{ if (agent.getSkills().containsKey(weapon.getMastery())) {
return agent.minDamageHandOne; masteryLevel = (int) agent.getSkills().get(weapon.getMastery()).getModifiedAmount();
} }
} }
}
return min * (pow(0.0048 * primary + .049 * (primary - 0.75), 0.5) + pow(0.0066 * secondary + 0.064 * (secondary - 0.75), 0.5) + +0.01 * (focusLevel + masteryLevel));
}
public static double getMaxDmg(Mob agent) { public static double getMaxDmg(double max, Mob agent, ItemBase weapon) {
if(agent.getEquip() != null){
if(agent.getEquip().get(ItemSlotType.RHELD) != null){ int primary = agent.getStatStrCurrent();
return agent.maxDamageHandOne; int secondary = agent.getStatDexCurrent();
}else if(agent.getEquip().get(ItemSlotType.LHELD) != null){ int focusLevel = 0;
return agent.getMaxDamageHandTwo(); int masteryLevel = 0;
if (weapon != null) {
if (weapon.isStrBased() == true) {
primary = agent.getStatStrCurrent();
secondary = agent.getStatDexCurrent();
} else { } else {
return agent.maxDamageHandOne; primary = agent.getStatDexCurrent();
secondary = agent.getStatStrCurrent();
} }
}else{
return agent.maxDamageHandOne; if (agent.getSkills().containsKey(weapon.getSkillRequired()))
focusLevel = (int) agent.getSkills().get(weapon.getSkillRequired()).getModifiedAmount();
if (agent.getSkills().containsKey(weapon.getSkillRequired()))
masteryLevel = (int) agent.getSkills().get(weapon.getMastery()).getModifiedAmount();
} }
return max * (pow(0.0124 * primary + 0.118 * (primary - 0.75), 0.5) + pow(0.0022 * secondary + 0.028 * (secondary - 0.75), 0.5) + 0.0075 * (focusLevel + masteryLevel));
} }
} }

Some files were not shown because too many files have changed in this diff Show More