Compare commits
364 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 44b9ba911d | |||
| c24f8fc85b | |||
| 75c56cbeee | |||
| 15f42c9658 | |||
| 525d0c21bb | |||
| cbf05cfe5b | |||
| aaa506a581 | |||
| a2fbfad00e | |||
| 031c52e25a | |||
| 693dfd827c | |||
| d26a2d35bf | |||
| 9839de128c | |||
| 12872ee51e | |||
| 2af08d6823 | |||
| f646075311 | |||
| dfca767476 | |||
| fd7b5952c2 | |||
| 4b46eddc47 | |||
| e26121177f | |||
| 91eb0c314f | |||
| 1d7a2d4eae | |||
| e4235d4d75 | |||
| 41a83115be | |||
| 3ce887cb34 | |||
| 874eb6189e | |||
| 5c5c491597 | |||
| ff78c1443c | |||
| cdc1c2d776 | |||
| a004c247ab | |||
| 048e90fb8f | |||
| c1498145e6 | |||
| 7654d5183a | |||
| 9b7fc0a93b | |||
| 200318ddcf | |||
| 1fdd0a1b32 | |||
| 8869772fa4 | |||
| 96bc894962 | |||
| 5a9f5f2eca | |||
| bd9dbcbb42 | |||
| f8269bb764 | |||
| c215047c00 | |||
| a313e3f364 | |||
| b34be1184e | |||
| e23c5527da | |||
| 847e62dd27 | |||
| f5d83aa259 | |||
| 4a5c0ae5a0 | |||
| b4a4323906 | |||
| 48fc5af5f7 | |||
| a1753a28ec | |||
| fa4039cf63 | |||
| 4b0814c0a1 | |||
| 78d0b06b36 | |||
| 426bdf5df3 | |||
| 5dbad7ebd0 | |||
| 6ef33c5b7f | |||
| 3737a6eace | |||
| 967e129724 | |||
| e9d549377e | |||
| 924b8af827 | |||
| 045ee73b61 | |||
| 5d9d13ce07 | |||
| 5a1347ec50 | |||
| c705f45856 | |||
| 83fc129d05 | |||
| d7cde3a77f | |||
| afb1ad8e94 | |||
| 15a79ee9bd | |||
| 68794c170b | |||
| a9d84749ba | |||
| dd5fc323ef | |||
| cf1547d077 | |||
| 9664c99e06 | |||
| 17b7fb6999 | |||
| 21a4db8a81 | |||
| eabdabcfcd | |||
| c548383a4c | |||
| 7337f4be1e | |||
| d84f223b9d | |||
| 5431112186 | |||
| ff743151c6 | |||
| b923392b53 | |||
| 15d272c621 | |||
| eefa50b2c3 | |||
| ecc7a152f7 | |||
| 7bf31f9a47 | |||
| 7dc970ff53 | |||
| 97d71ec361 | |||
| 003b939d33 | |||
| 9989cbff24 | |||
| 426ef989f8 | |||
| ca6e079053 | |||
| 13644fd308 | |||
| 1ec76ae3fc | |||
| 51d75146cc | |||
| bc4222646d | |||
| c3e206e3b1 | |||
| 04147e11cc | |||
| 545cb4cddf | |||
| 0f948d4e2a | |||
| 5fb3e0fe14 | |||
| fb87dfd91e | |||
| be8967b05f | |||
| 8acfff7faa | |||
| 18e1f4bd28 | |||
| 74f88a6643 | |||
| 47fe764cb0 | |||
| 9e53770e6c | |||
| a9cc001791 | |||
| c24913d124 | |||
| 63bf0b6070 | |||
| 50792327a4 | |||
| 46e67be8ca | |||
| e7c3ba5eba | |||
| ea86ab2300 | |||
| 501e8c937f | |||
| cae5c36d84 | |||
| 1b92fa76e1 | |||
| bbdb683061 | |||
| 2d04547c74 | |||
| 5192c801f7 | |||
| d966d50bd5 | |||
| 7e20db33f2 | |||
| 669ee7215b | |||
| 6fa00a43a4 | |||
| 4edf740179 | |||
| c7abb4c920 | |||
| df3964110a | |||
| 96231260bc | |||
| 967303d2de | |||
| 955481773d | |||
| d66a7049e8 | |||
| e73b8d2826 | |||
| ea23003807 | |||
| 23f41f8ae7 | |||
| 3f416f83d3 | |||
| 931d1992b6 | |||
| fd927a7052 | |||
| dd46224afe | |||
| be2b29ccc7 | |||
| c93e3bc947 | |||
| 7d49395c41 | |||
| f4c9e6d7b8 | |||
| b7a907c8c8 | |||
| 36485a0f01 | |||
| efec1b4444 | |||
| bdf6500260 | |||
| db4eb0579e | |||
| 76f33534d4 | |||
| 39fea5bc2f | |||
| 660d5c1270 | |||
| 781e2fc9b2 | |||
| c2a2464fe8 | |||
| beb3c15eb3 | |||
| 553010bb7b | |||
| 8d12bbf453 | |||
| fa7588826a | |||
| 332f191e19 | |||
| 8151382a6b | |||
| ae44a21be1 | |||
| b0ff0995de | |||
| e711095ecd | |||
| 08de97a2a8 | |||
| 5eb6302d2a | |||
| 2e346ae7fd | |||
| 1285d12915 | |||
| 8b5cb9258e | |||
| ef3e3a0392 | |||
| 8fca6572f9 | |||
| 33eaf0e583 | |||
| 16acd1c08c | |||
| a8e8804ce3 | |||
| b8c0f997f6 | |||
| 11e63f38b1 | |||
| ff36d8f3db | |||
| 975542d8af | |||
| d71a9415b4 | |||
| e948da95b5 | |||
| 9a6510c320 | |||
| 57ff1ede97 | |||
| 7c0f2563f7 | |||
| d11a954b40 | |||
| f354339af1 | |||
| 89658bb77a | |||
| 1ff0238b6e | |||
| e777434d57 | |||
| ee6efc30a3 | |||
| 0758bb5f38 | |||
| 299d5725a6 | |||
| d7c9b31ec7 | |||
| 6c78bee5c1 | |||
| dba0cbd5f9 | |||
| 0752e780f2 | |||
| c43919ce01 | |||
| 0d95510b72 | |||
| 60fb2571a2 | |||
| 90cbe90492 | |||
| 95c203b0ed | |||
| 449c5c5c77 | |||
| 9aff208403 | |||
| 4318849127 | |||
| 29e8cdf699 | |||
| 4427dbdcad | |||
| af4c3819b9 | |||
| 39379e1ac0 | |||
| 71eeb3f6b8 | |||
| d409ef49af | |||
| e7a80e9280 | |||
| 65c2d2ea0b | |||
| 92666dca21 | |||
| 3e1a79c248 | |||
| 73a1ce083a | |||
| 22dacebc5e | |||
| 80d0948e24 | |||
| 58b427b977 | |||
| a4cab3565a | |||
| 205c9580e3 | |||
| 70a0ed135b | |||
| f556181d77 | |||
| d48e26904e | |||
| 19232ac405 | |||
| 9ee2ccc8af | |||
| 7079bb6a63 | |||
| 0ab5827ee5 | |||
| c5443f622c | |||
| e4aa276cca | |||
| 90ff2d679e | |||
| da26c35d5a | |||
| 779e3da74e | |||
| e358c08773 | |||
| 2945fa3a47 | |||
| ab1541e741 | |||
| 3aeaa709a5 | |||
| 91e627df6b | |||
| d0795e9e1c | |||
| 0e12dd4874 | |||
| 25c0e48181 | |||
| 0d43c3620d | |||
| 2f6137f8df | |||
| 2843b86a93 | |||
| 8235de07ff | |||
| e2f9a4c7f0 | |||
| 55c6e3cf93 | |||
| 11c154e564 | |||
| 7fc0d27c3c | |||
| 1ac76cfcd8 | |||
| c8ed04aaaf | |||
| 6641651f3c | |||
| dbf164bfb2 | |||
| 8a617c3008 | |||
| a50a2430ba | |||
| 5c3c552288 | |||
| 69fdddfc71 | |||
| db5b988275 | |||
| 4284757035 | |||
| b93a47acc0 | |||
| d59f9857ce | |||
| 8ce212b74b | |||
| e78aea5735 | |||
| 9a3c5c3f40 | |||
| 60ca3f9c34 | |||
| e7e740dff1 | |||
| 8343a98d77 | |||
| 5862039a00 | |||
| 8af989b75f | |||
| 08d0e5ff75 | |||
| 5196d10e5c | |||
| 3392ec463d | |||
| 33529404cf | |||
| 00e7a36013 | |||
| 3060b394ab | |||
| a43d9022fe | |||
| 6abdc68ca5 | |||
| 61c66b0e96 | |||
| 36cc23457a | |||
| d573b238de | |||
| 8afe25fe85 | |||
| f80647ff0d | |||
| 7e64cbabf8 | |||
| 14a06410ae | |||
| 85c2a4f4f0 | |||
| da9e211ec7 | |||
| a81070c471 | |||
| e3ad7efa4f | |||
| a4dafd7155 | |||
| 645aec853e | |||
| d8d5e4a3c4 | |||
| 7a48c04057 | |||
| 64aaaa707e | |||
| 445d40dc5f | |||
| ebdcb531f2 | |||
| c9cdb891d6 | |||
| f5c6c002a8 | |||
| d171c6bb9a | |||
| 1c81a4faed | |||
| e7d1d5cb71 | |||
| 060d831d50 | |||
| 316bd6dd01 | |||
| 34081e5903 | |||
| e2d843b65e | |||
| a796f5fe4b | |||
| 51ee41c773 | |||
| 7e5ed3efe5 | |||
| 8dd25ac315 | |||
| 1cdaa58e7a | |||
| fa3aa24a3d | |||
| 091431d95b | |||
| 1ecf0122ab | |||
| 79980a1725 | |||
| 8badcc3f6e | |||
| 4d6e57257c | |||
| a7a93b8500 | |||
| 85cc34fb4c | |||
| 772a996b6e | |||
| e67eff822d | |||
| c39ed6120f | |||
| c38f4e6543 | |||
| 098433b697 | |||
| c8e20c905b | |||
| bd2446ba0a | |||
| c179e4aaf3 | |||
| 2f8de2a919 | |||
| 338110973d | |||
| 3c9c4495bc | |||
| 93476f782c | |||
| 3aec6ee578 | |||
| 3bca76d4c8 | |||
| b9d6f35aac | |||
| 9b6959414a | |||
| 400dd6aa5e | |||
| 14af2f6efd | |||
| 0a2de9e0d5 | |||
| 89bfad78a6 | |||
| 52486fa278 | |||
| dc0e14eb21 | |||
| 70278374e7 | |||
| ac3588c76a | |||
| ab335aef2a | |||
| 719c855bdb | |||
| f283e50018 | |||
| 99b952ee28 | |||
| 24639b62c0 | |||
| 573cc531bf | |||
| 29e24bae93 | |||
| 22e4cc07c0 | |||
| 9264347698 | |||
| 579c26ac59 | |||
| ef577dd313 | |||
| 62c7e52487 | |||
| 3534ac6477 | |||
| 1738f7b311 | |||
| eb25caec81 | |||
| a6c60e2c04 | |||
| adafbdf6d3 | |||
| 7eab14938d | |||
| 039e55673b | |||
| ec3a9b6cb4 | |||
| 17a6494b2b | |||
| 0b05c7074f | |||
| 876ccc7cbf | |||
| bdf14b8f24 | |||
| 43375a6f5b | |||
| e00328ae13 | |||
| 07c553294b |
+26
-42
@@ -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),
|
||||||
@@ -170,8 +172,6 @@ public class Enum {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static RaceType getRaceTypebyRuneID(int runeID) {
|
public static RaceType getRaceTypebyRuneID(int runeID) {
|
||||||
if(runeID == 1999)
|
|
||||||
return _raceTypeByID.get(2017);
|
|
||||||
return _raceTypeByID.get(runeID);
|
return _raceTypeByID.get(runeID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,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;
|
||||||
@@ -469,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);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -779,7 +776,6 @@ public class Enum {
|
|||||||
Combat,
|
Combat,
|
||||||
Spires,
|
Spires,
|
||||||
Snare,
|
Snare,
|
||||||
Snared,
|
|
||||||
Stun,
|
Stun,
|
||||||
Blind,
|
Blind,
|
||||||
Root,
|
Root,
|
||||||
@@ -882,7 +878,6 @@ public class Enum {
|
|||||||
Siege,
|
Siege,
|
||||||
Slash,
|
Slash,
|
||||||
Snare,
|
Snare,
|
||||||
Snared,
|
|
||||||
Sorcery,
|
Sorcery,
|
||||||
Spear,
|
Spear,
|
||||||
SpearMastery,
|
SpearMastery,
|
||||||
@@ -962,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;
|
||||||
@@ -1032,7 +1016,6 @@ public class Enum {
|
|||||||
Silence,
|
Silence,
|
||||||
Slash,
|
Slash,
|
||||||
Snare,
|
Snare,
|
||||||
Snared,
|
|
||||||
Stance,
|
Stance,
|
||||||
Stun,
|
Stun,
|
||||||
Summon,
|
Summon,
|
||||||
@@ -1157,7 +1140,6 @@ public class Enum {
|
|||||||
SkillDebuff,
|
SkillDebuff,
|
||||||
SlashResistanceDebuff,
|
SlashResistanceDebuff,
|
||||||
Snare,
|
Snare,
|
||||||
Snared,
|
|
||||||
StackableAttrCONBuff,
|
StackableAttrCONBuff,
|
||||||
StackableAttrDEXBuff,
|
StackableAttrDEXBuff,
|
||||||
StackableAttrSTRBuff,
|
StackableAttrSTRBuff,
|
||||||
@@ -2324,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;
|
||||||
|
|
||||||
@@ -2840,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),
|
||||||
@@ -2865,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),
|
||||||
@@ -2875,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;
|
||||||
@@ -2896,8 +2877,11 @@ public class Enum {
|
|||||||
|
|
||||||
public enum AIAgentType {
|
public enum AIAgentType {
|
||||||
MOBILE,
|
MOBILE,
|
||||||
|
GUARDCAPTAIN,
|
||||||
|
GUARDMINION,
|
||||||
|
GUARDWALLARCHER,
|
||||||
PET,
|
PET,
|
||||||
CHARMED,
|
CHARMED,
|
||||||
GUARD;
|
SIEGEENGINE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,7 @@ import engine.gameManager.DbManager;
|
|||||||
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.AbstractWorldObject;
|
|
||||||
import engine.objects.Zone;
|
import engine.objects.Zone;
|
||||||
import engine.util.MapLoader;
|
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
@@ -32,6 +30,7 @@ public class HeightMap {
|
|||||||
|
|
||||||
// Class variables
|
// Class variables
|
||||||
|
|
||||||
|
public static float SCALEVALUE = 1.0f / 256;
|
||||||
// Heightmap data for all zones.
|
// Heightmap data for all zones.
|
||||||
|
|
||||||
public static final HashMap<Integer, HeightMap> heightmapByLoadNum = new HashMap<>();
|
public static final HashMap<Integer, HeightMap> heightmapByLoadNum = new HashMap<>();
|
||||||
@@ -45,17 +44,17 @@ public class HeightMap {
|
|||||||
|
|
||||||
public BufferedImage heightmapImage;
|
public BufferedImage heightmapImage;
|
||||||
|
|
||||||
private int heightMapID;
|
private final int heightMapID;
|
||||||
private int maxHeight;
|
private final int maxHeight;
|
||||||
private int fullExtentsX;
|
private final int fullExtentsX;
|
||||||
private int fullExtentsY;
|
private final int fullExtentsY;
|
||||||
|
|
||||||
private float bucketWidthX;
|
private float bucketWidthX;
|
||||||
private float bucketWidthY;
|
private float bucketWidthY;
|
||||||
private int zoneLoadID;
|
private final int zoneLoadID;
|
||||||
private float seaLevel = 0;
|
private float seaLevel = 0;
|
||||||
private float outsetX;
|
private final float outsetX;
|
||||||
private float outsetZ;
|
private final float outsetZ;
|
||||||
private int[][] pixelColorValues;
|
private int[][] pixelColorValues;
|
||||||
|
|
||||||
public HeightMap(ResultSet rs) throws SQLException {
|
public HeightMap(ResultSet rs) throws SQLException {
|
||||||
@@ -88,12 +87,12 @@ public class HeightMap {
|
|||||||
try {
|
try {
|
||||||
this.heightmapImage = ImageIO.read(imageFile);
|
this.heightmapImage = ImageIO.read(imageFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Logger.error("***Error loading heightmap data for heightmap " + this.heightMapID + e.toString());
|
Logger.error("***Error loading heightmap data for heightmap " + this.heightMapID + e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We needed to flip the image as OpenGL and Shadowbane both use the bottom left corner as origin.
|
// We needed to flip the image as OpenGL and Shadowbane both use the bottom left corner as origin.
|
||||||
|
|
||||||
this.heightmapImage = MapLoader.flipImage(this.heightmapImage);
|
// this.heightmapImage = MapLoader.flipImage(this.heightmapImage);
|
||||||
|
|
||||||
// Calculate the data we do not load from table
|
// Calculate the data we do not load from table
|
||||||
|
|
||||||
@@ -104,7 +103,7 @@ public class HeightMap {
|
|||||||
|
|
||||||
// Generate pixel array from image data
|
// Generate pixel array from image data
|
||||||
|
|
||||||
generatePixelData();
|
generatePixelData(this);
|
||||||
|
|
||||||
HeightMap.heightmapByLoadNum.put(this.zoneLoadID, this);
|
HeightMap.heightmapByLoadNum.put(this.zoneLoadID, this);
|
||||||
|
|
||||||
@@ -123,35 +122,26 @@ public class HeightMap {
|
|||||||
this.outsetX = 128;
|
this.outsetX = 128;
|
||||||
this.outsetZ = 128;
|
this.outsetZ = 128;
|
||||||
|
|
||||||
|
|
||||||
// Cache the full extents to avoid the calculation
|
// Cache the full extents to avoid the calculation
|
||||||
|
|
||||||
this.fullExtentsX = halfExtentsX * 2;
|
this.fullExtentsX = halfExtentsX * 2;
|
||||||
this.fullExtentsY = halfExtentsY * 2;
|
this.fullExtentsY = halfExtentsY * 2;
|
||||||
|
|
||||||
|
|
||||||
// load the heightmap image.
|
|
||||||
|
|
||||||
|
|
||||||
// We needed to flip the image as OpenGL and Shadowbane both use the bottom left corner as origin.
|
|
||||||
|
|
||||||
this.heightmapImage = null;
|
this.heightmapImage = null;
|
||||||
|
|
||||||
// Calculate the data we do not load from table
|
// Calculate the data we do not load from table
|
||||||
|
|
||||||
this.bucketWidthX = 1;
|
this.bucketWidthX = halfExtentsX;
|
||||||
this.bucketWidthY = 1;
|
this.bucketWidthY = halfExtentsY;
|
||||||
|
|
||||||
this.pixelColorValues = new int[this.fullExtentsX + 1][this.fullExtentsY + 1];
|
this.pixelColorValues = new int[this.fullExtentsX][this.fullExtentsY];
|
||||||
|
|
||||||
for (int y = 0; y <= this.fullExtentsY; y++) {
|
for (int y = 0; y < this.fullExtentsY; y++) {
|
||||||
for (int x = 0; x <= this.fullExtentsX; x++) {
|
for (int x = 0; x < this.fullExtentsX; x++) {
|
||||||
pixelColorValues[x][y] = 255;
|
pixelColorValues[x][y] = 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HeightMap.heightmapByLoadNum.put(this.zoneLoadID, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HeightMap(Zone zone) {
|
public HeightMap(Zone zone) {
|
||||||
@@ -170,26 +160,21 @@ public class HeightMap {
|
|||||||
this.fullExtentsX = halfExtentsX * 2;
|
this.fullExtentsX = halfExtentsX * 2;
|
||||||
this.fullExtentsY = halfExtentsY * 2;
|
this.fullExtentsY = halfExtentsY * 2;
|
||||||
|
|
||||||
|
|
||||||
// We needed to flip the image as OpenGL and Shadowbane both use the bottom left corner as origin.
|
|
||||||
|
|
||||||
this.heightmapImage = null;
|
this.heightmapImage = null;
|
||||||
|
|
||||||
// Calculate the data we do not load from table
|
// Calculate the data we do not load from table
|
||||||
|
|
||||||
this.bucketWidthX = 1;
|
this.bucketWidthX = halfExtentsX;
|
||||||
this.bucketWidthY = 1;
|
this.bucketWidthY = halfExtentsY;
|
||||||
|
|
||||||
this.pixelColorValues = new int[this.fullExtentsX + 1][this.fullExtentsY + 1];
|
this.pixelColorValues = new int[this.fullExtentsX][this.fullExtentsY];
|
||||||
|
|
||||||
for (int y = 0; y <= this.fullExtentsY; y++) {
|
for (int y = 0; y < this.fullExtentsY; y++) {
|
||||||
for (int x = 0; x <= this.fullExtentsX; x++) {
|
for (int x = 0; x < this.fullExtentsX; x++) {
|
||||||
pixelColorValues[x][y] = 255;
|
pixelColorValues[x][y] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HeightMap.heightmapByLoadNum.put(this.zoneLoadID, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GeneratePlayerCityHeightMap() {
|
public static void GeneratePlayerCityHeightMap() {
|
||||||
@@ -222,113 +207,9 @@ public class HeightMap {
|
|||||||
return nextZone;
|
return nextZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getWorldHeight(AbstractWorldObject worldObject) {
|
public static float getWorldHeight(Zone currentZone, Vector3fImmutable worldLoc) {
|
||||||
|
|
||||||
Vector2f parentLoc = new Vector2f(-1, -1);
|
Vector2f parentLoc = new Vector2f(-1, -1);
|
||||||
Zone currentZone = ZoneManager.findSmallestZone(worldObject.getLoc());
|
|
||||||
|
|
||||||
if (currentZone == null)
|
|
||||||
return worldObject.getAltitude();
|
|
||||||
|
|
||||||
currentZone = getNextZoneWithTerrain(currentZone);
|
|
||||||
|
|
||||||
if (currentZone == ZoneManager.getSeaFloor())
|
|
||||||
return currentZone.getAbsY() + worldObject.getAltitude();
|
|
||||||
|
|
||||||
Zone parentZone = getNextZoneWithTerrain(currentZone.getParent());
|
|
||||||
HeightMap heightMap = currentZone.getHeightMap();
|
|
||||||
|
|
||||||
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(worldObject.getLoc(), currentZone);
|
|
||||||
Vector3fImmutable localLocFromCenter = ZoneManager.worldToLocal(worldObject.getLoc(), currentZone);
|
|
||||||
|
|
||||||
if ((parentZone != null) && (parentZone.getHeightMap() != null))
|
|
||||||
parentLoc = ZoneManager.worldToZoneSpace(worldObject.getLoc(), parentZone);
|
|
||||||
|
|
||||||
float interaltitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
|
|
||||||
|
|
||||||
float worldAltitude = currentZone.getWorldAltitude();
|
|
||||||
|
|
||||||
float realWorldAltitude = interaltitude + worldAltitude;
|
|
||||||
|
|
||||||
//OUTSET
|
|
||||||
|
|
||||||
if (parentZone != null) {
|
|
||||||
|
|
||||||
float parentXRadius = currentZone.getBounds().getHalfExtents().x;
|
|
||||||
float parentZRadius = currentZone.getBounds().getHalfExtents().y;
|
|
||||||
|
|
||||||
float offsetX = Math.abs((localLocFromCenter.x / parentXRadius));
|
|
||||||
float offsetZ = Math.abs((localLocFromCenter.z / parentZRadius));
|
|
||||||
|
|
||||||
float bucketScaleX = heightMap.outsetX / parentXRadius;
|
|
||||||
float bucketScaleZ = heightMap.outsetZ / parentZRadius;
|
|
||||||
|
|
||||||
if (bucketScaleX <= 0.40000001)
|
|
||||||
bucketScaleX = heightMap.outsetZ / parentXRadius;
|
|
||||||
|
|
||||||
if (bucketScaleX > 0.40000001)
|
|
||||||
bucketScaleX = 0.40000001f;
|
|
||||||
|
|
||||||
if (bucketScaleZ <= 0.40000001)
|
|
||||||
bucketScaleZ = heightMap.outsetX / parentZRadius;
|
|
||||||
|
|
||||||
if (bucketScaleZ > 0.40000001)
|
|
||||||
bucketScaleZ = 0.40000001f;
|
|
||||||
|
|
||||||
float outsideGridSizeX = 1 - bucketScaleX; //32/256
|
|
||||||
float outsideGridSizeZ = 1 - bucketScaleZ;
|
|
||||||
float weight;
|
|
||||||
|
|
||||||
double scale;
|
|
||||||
|
|
||||||
if (offsetX > outsideGridSizeX && offsetX > offsetZ) {
|
|
||||||
weight = (offsetX - outsideGridSizeX) / bucketScaleX;
|
|
||||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
|
||||||
|
|
||||||
float scaleChild = (float) ((scale + 1) * .5);
|
|
||||||
float scaleParent = 1 - scaleChild;
|
|
||||||
|
|
||||||
float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
|
||||||
float parentCenterAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone));
|
|
||||||
|
|
||||||
parentCenterAltitude += currentZone.getYCoord();
|
|
||||||
parentCenterAltitude += interaltitude;
|
|
||||||
|
|
||||||
float firstScale = parentAltitude * scaleParent;
|
|
||||||
float secondScale = parentCenterAltitude * scaleChild;
|
|
||||||
float outsetALt = firstScale + secondScale;
|
|
||||||
|
|
||||||
outsetALt += currentZone.getParent().getWorldAltitude();
|
|
||||||
realWorldAltitude = outsetALt;
|
|
||||||
|
|
||||||
} else if (offsetZ > outsideGridSizeZ) {
|
|
||||||
|
|
||||||
weight = (offsetZ - outsideGridSizeZ) / bucketScaleZ;
|
|
||||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
|
||||||
|
|
||||||
float scaleChild = (float) ((scale + 1) * .5);
|
|
||||||
float scaleParent = 1 - scaleChild;
|
|
||||||
float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
|
||||||
float parentCenterAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone));
|
|
||||||
|
|
||||||
parentCenterAltitude += currentZone.getYCoord();
|
|
||||||
parentCenterAltitude += interaltitude;
|
|
||||||
float firstScale = parentAltitude * scaleParent;
|
|
||||||
float secondScale = parentCenterAltitude * scaleChild;
|
|
||||||
float outsetALt = firstScale + secondScale;
|
|
||||||
|
|
||||||
outsetALt += currentZone.getParent().getWorldAltitude();
|
|
||||||
realWorldAltitude = outsetALt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return realWorldAltitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getWorldHeight(Vector3fImmutable worldLoc) {
|
|
||||||
|
|
||||||
Vector2f parentLoc = new Vector2f(-1, -1);
|
|
||||||
Zone currentZone = ZoneManager.findSmallestZone(worldLoc);
|
|
||||||
|
|
||||||
if (currentZone == null)
|
if (currentZone == null)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -352,7 +233,7 @@ public class HeightMap {
|
|||||||
|
|
||||||
float interaltitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
|
float interaltitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
|
||||||
|
|
||||||
float worldAltitude = currentZone.getWorldAltitude();
|
float worldAltitude = currentZone.worldAltitude;
|
||||||
|
|
||||||
float realWorldAltitude = interaltitude + worldAltitude;
|
float realWorldAltitude = interaltitude + worldAltitude;
|
||||||
|
|
||||||
@@ -360,9 +241,6 @@ public class HeightMap {
|
|||||||
|
|
||||||
if (parentZone != null) {
|
if (parentZone != null) {
|
||||||
|
|
||||||
// if (currentZone.getHeightMap() != null && parentZone.getHeightMap() != null && parentZone.getParent() != null && parentZone.getParent().getHeightMap() != null)
|
|
||||||
// return realWorldAltitude;
|
|
||||||
|
|
||||||
float parentXRadius = currentZone.getBounds().getHalfExtents().x;
|
float parentXRadius = currentZone.getBounds().getHalfExtents().x;
|
||||||
float parentZRadius = currentZone.getBounds().getHalfExtents().y;
|
float parentZRadius = currentZone.getBounds().getHalfExtents().y;
|
||||||
|
|
||||||
@@ -378,7 +256,6 @@ public class HeightMap {
|
|||||||
|
|
||||||
double scale;
|
double scale;
|
||||||
|
|
||||||
|
|
||||||
if (offsetX > outsideGridSizeX && offsetX > offsetZ) {
|
if (offsetX > outsideGridSizeX && offsetX > offsetZ) {
|
||||||
weight = (offsetX - outsideGridSizeX) / bucketScaleX;
|
weight = (offsetX - outsideGridSizeX) / bucketScaleX;
|
||||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
||||||
@@ -396,7 +273,7 @@ public class HeightMap {
|
|||||||
float secondScale = parentCenterAltitude * scaleChild;
|
float secondScale = parentCenterAltitude * scaleChild;
|
||||||
float outsetALt = firstScale + secondScale;
|
float outsetALt = firstScale + secondScale;
|
||||||
|
|
||||||
outsetALt += currentZone.getParent().getWorldAltitude();
|
outsetALt += currentZone.getParent().worldAltitude;
|
||||||
realWorldAltitude = outsetALt;
|
realWorldAltitude = outsetALt;
|
||||||
|
|
||||||
} else if (offsetZ > outsideGridSizeZ) {
|
} else if (offsetZ > outsideGridSizeZ) {
|
||||||
@@ -415,7 +292,7 @@ public class HeightMap {
|
|||||||
float secondScale = parentCenterAltitude * scaleChild;
|
float secondScale = parentCenterAltitude * scaleChild;
|
||||||
float outsetALt = firstScale + secondScale;
|
float outsetALt = firstScale + secondScale;
|
||||||
|
|
||||||
outsetALt += currentZone.getParent().getWorldAltitude();
|
outsetALt += currentZone.getParent().worldAltitude;
|
||||||
realWorldAltitude = outsetALt;
|
realWorldAltitude = outsetALt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -423,85 +300,13 @@ public class HeightMap {
|
|||||||
return realWorldAltitude;
|
return realWorldAltitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getOutsetHeight(float interpolatedAltitude, Zone zone, Vector3fImmutable worldLocation) {
|
public static float getWorldHeight(Vector3fImmutable worldLoc) {
|
||||||
|
|
||||||
Vector2f parentLoc;
|
Zone currentZone = ZoneManager.findSmallestZone(worldLoc);
|
||||||
float outsetALt = 0;
|
|
||||||
|
|
||||||
if (zone.getParent() == null || zone.getParent().getHeightMap() == null)
|
if (currentZone == null)
|
||||||
return interpolatedAltitude + zone.getWorldAltitude();
|
return 0;
|
||||||
|
return getWorldHeight(currentZone, worldLoc);
|
||||||
if (zone.getParent() != null && zone.getParent().getHeightMap() != null) {
|
|
||||||
|
|
||||||
parentLoc = ZoneManager.worldToZoneSpace(worldLocation, zone.getParent());
|
|
||||||
|
|
||||||
Vector3fImmutable localLocFromCenter = ZoneManager.worldToLocal(worldLocation, zone);
|
|
||||||
|
|
||||||
float parentXRadius = zone.getBounds().getHalfExtents().x;
|
|
||||||
float parentZRadius = zone.getBounds().getHalfExtents().y;
|
|
||||||
|
|
||||||
float bucketScaleX = zone.getHeightMap().outsetX / parentXRadius;
|
|
||||||
float bucketScaleZ = zone.getHeightMap().outsetZ / parentZRadius;
|
|
||||||
|
|
||||||
float outsideGridSizeX = 1 - bucketScaleX; //32/256
|
|
||||||
float outsideGridSizeZ = 1 - bucketScaleZ;
|
|
||||||
|
|
||||||
float weight;
|
|
||||||
double scale;
|
|
||||||
|
|
||||||
float offsetX = Math.abs((localLocFromCenter.x / parentXRadius));
|
|
||||||
float offsetZ = Math.abs((localLocFromCenter.z / parentZRadius));
|
|
||||||
|
|
||||||
if (offsetX > outsideGridSizeX && offsetX > offsetZ) {
|
|
||||||
weight = (offsetX - outsideGridSizeX) / bucketScaleX;
|
|
||||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
|
||||||
|
|
||||||
float scaleChild = (float) ((scale + 1) * .5);
|
|
||||||
float scaleParent = 1 - scaleChild;
|
|
||||||
|
|
||||||
float parentAltitude = zone.getParent().getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
|
||||||
float parentCenterAltitude = zone.getParent().getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(zone.getLoc(), zone.getParent()));
|
|
||||||
|
|
||||||
parentCenterAltitude += zone.getYCoord();
|
|
||||||
parentCenterAltitude += interpolatedAltitude;
|
|
||||||
|
|
||||||
float firstScale = parentAltitude * scaleParent;
|
|
||||||
float secondScale = parentCenterAltitude * scaleChild;
|
|
||||||
outsetALt = firstScale + secondScale;
|
|
||||||
|
|
||||||
outsetALt += zone.getParent().getAbsY();
|
|
||||||
|
|
||||||
} else if (offsetZ > outsideGridSizeZ) {
|
|
||||||
|
|
||||||
weight = (offsetZ - outsideGridSizeZ) / bucketScaleZ;
|
|
||||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
|
||||||
|
|
||||||
float scaleChild = (float) ((scale + 1) * .5);
|
|
||||||
float scaleParent = 1 - scaleChild;
|
|
||||||
float parentAltitude = zone.getParent().getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
|
||||||
float parentCenterAltitude = zone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(zone.getLoc(), zone));
|
|
||||||
|
|
||||||
parentCenterAltitude += zone.getYCoord();
|
|
||||||
parentCenterAltitude += interpolatedAltitude;
|
|
||||||
|
|
||||||
float firstScale = parentAltitude * scaleParent;
|
|
||||||
float secondScale = parentCenterAltitude * scaleChild;
|
|
||||||
outsetALt = firstScale + secondScale;
|
|
||||||
|
|
||||||
outsetALt += zone.getParent().getAbsY();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return outsetALt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vector2f getGridOffset(Vector2f gridSquare) {
|
|
||||||
|
|
||||||
int floorX = (int) gridSquare.x;
|
|
||||||
int floorY = (int) gridSquare.y;
|
|
||||||
|
|
||||||
return new Vector2f(gridSquare.x - floorX, gridSquare.y - floorY);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -515,7 +320,6 @@ public class HeightMap {
|
|||||||
|
|
||||||
HeightMap.GeneratePlayerCityHeightMap();
|
HeightMap.GeneratePlayerCityHeightMap();
|
||||||
|
|
||||||
|
|
||||||
// Clear all heightmap image data as it's no longer needed.
|
// Clear all heightmap image data as it's no longer needed.
|
||||||
|
|
||||||
for (HeightMap heightMap : HeightMap.heightmapByLoadNum.values()) {
|
for (HeightMap heightMap : HeightMap.heightmapByLoadNum.values()) {
|
||||||
@@ -530,10 +334,25 @@ public class HeightMap {
|
|||||||
float localAltitude = HeightMap.getWorldHeight(currentLoc);
|
float localAltitude = HeightMap.getWorldHeight(currentLoc);
|
||||||
Zone zone = ZoneManager.findSmallestZone(currentLoc);
|
Zone zone = ZoneManager.findSmallestZone(currentLoc);
|
||||||
|
|
||||||
if (localAltitude < zone.getSeaLevel())
|
return localAltitude < zone.getSeaLevel();
|
||||||
return true;
|
}
|
||||||
|
|
||||||
|
private static void generatePixelData(HeightMap heightMap) {
|
||||||
|
|
||||||
|
Color color;
|
||||||
|
|
||||||
|
// Generate altitude lookup table for this heightmap
|
||||||
|
|
||||||
|
heightMap.pixelColorValues = new int[heightMap.heightmapImage.getWidth()][heightMap.heightmapImage.getHeight()];
|
||||||
|
|
||||||
|
for (int y = 0; y < heightMap.heightmapImage.getHeight(); y++) {
|
||||||
|
for (int x = 0; x < heightMap.heightmapImage.getWidth(); x++) {
|
||||||
|
|
||||||
|
color = new Color(heightMap.heightmapImage.getRGB(x, y));
|
||||||
|
heightMap.pixelColorValues[x][y] = color.getRed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2f getGridSquare(Vector2f zoneLoc) {
|
public Vector2f getGridSquare(Vector2f zoneLoc) {
|
||||||
@@ -541,14 +360,18 @@ public class HeightMap {
|
|||||||
if (zoneLoc.x < 0)
|
if (zoneLoc.x < 0)
|
||||||
zoneLoc.setX(0);
|
zoneLoc.setX(0);
|
||||||
|
|
||||||
if (zoneLoc.x > this.fullExtentsX - 1)
|
if (zoneLoc.x >= this.fullExtentsX)
|
||||||
zoneLoc.setX((this.fullExtentsX - 1) + .9999999f);
|
zoneLoc.setX(this.fullExtentsX);
|
||||||
|
|
||||||
if (zoneLoc.y < 0)
|
if (zoneLoc.y < 0)
|
||||||
zoneLoc.setY(0);
|
zoneLoc.setY(0);
|
||||||
|
|
||||||
if (zoneLoc.y > this.fullExtentsY - 1)
|
if (zoneLoc.y > this.fullExtentsY)
|
||||||
zoneLoc.setY((this.fullExtentsY - 1) + .9999999f);
|
zoneLoc.setY(this.fullExtentsY);
|
||||||
|
|
||||||
|
// Flip Y coordinates
|
||||||
|
|
||||||
|
zoneLoc.setY(this.fullExtentsY - zoneLoc.y);
|
||||||
|
|
||||||
float xBucket = (zoneLoc.x / this.bucketWidthX);
|
float xBucket = (zoneLoc.x / this.bucketWidthX);
|
||||||
float yBucket = (zoneLoc.y / this.bucketWidthY);
|
float yBucket = (zoneLoc.y / this.bucketWidthY);
|
||||||
@@ -569,13 +392,10 @@ public class HeightMap {
|
|||||||
int maxX = (int) (this.fullExtentsX / this.bucketWidthX);
|
int maxX = (int) (this.fullExtentsX / this.bucketWidthX);
|
||||||
int maxY = (int) (this.fullExtentsY / this.bucketWidthY);
|
int maxY = (int) (this.fullExtentsY / this.bucketWidthY);
|
||||||
|
|
||||||
//flip the Y so it grabs from the bottom left instead of top left.
|
|
||||||
//zoneLoc.setY(maxZoneHeight - zoneLoc.y);
|
|
||||||
|
|
||||||
gridSquare = getGridSquare(zoneLoc);
|
gridSquare = getGridSquare(zoneLoc);
|
||||||
|
|
||||||
int gridX = (int) gridSquare.x;
|
int gridX = (int) gridSquare.x;
|
||||||
int gridY = (int) (gridSquare.y);
|
int gridY = (int) gridSquare.y;
|
||||||
|
|
||||||
if (gridX > maxX)
|
if (gridX > maxX)
|
||||||
gridX = maxX;
|
gridX = maxX;
|
||||||
@@ -613,76 +433,11 @@ public class HeightMap {
|
|||||||
interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY);
|
interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY);
|
||||||
interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY));
|
interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY));
|
||||||
|
|
||||||
interpolatedHeight *= (float) this.maxHeight / 256; // Scale height
|
interpolatedHeight *= (float) this.maxHeight * SCALEVALUE; // Scale height
|
||||||
|
|
||||||
return interpolatedHeight;
|
return interpolatedHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getInterpolatedTerrainHeight(Vector3fImmutable zoneLoc3f) {
|
|
||||||
|
|
||||||
Vector2f zoneLoc = new Vector2f(zoneLoc3f.x, zoneLoc3f.z);
|
|
||||||
|
|
||||||
Vector2f gridSquare;
|
|
||||||
|
|
||||||
if (zoneLoc.x < 0 || zoneLoc.x > this.fullExtentsX)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (zoneLoc.y < 0 || zoneLoc.y > this.fullExtentsY)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
//flip the Y so it grabs from the bottom left instead of top left.
|
|
||||||
//zoneLoc.setY(maxZoneHeight - zoneLoc.y);
|
|
||||||
|
|
||||||
gridSquare = getGridSquare(zoneLoc);
|
|
||||||
|
|
||||||
int gridX = (int) gridSquare.x;
|
|
||||||
int gridY = (int) (gridSquare.y);
|
|
||||||
|
|
||||||
float offsetX = (gridSquare.x - gridX);
|
|
||||||
float offsetY = gridSquare.y - gridY;
|
|
||||||
|
|
||||||
//get height of the 4 vertices.
|
|
||||||
|
|
||||||
float topLeftHeight = pixelColorValues[gridX][gridY];
|
|
||||||
float topRightHeight = pixelColorValues[gridX + 1][gridY];
|
|
||||||
float bottomLeftHeight = pixelColorValues[gridX][gridY + 1];
|
|
||||||
float bottomRightHeight = pixelColorValues[gridX + 1][gridY + 1];
|
|
||||||
|
|
||||||
float interpolatedHeight;
|
|
||||||
|
|
||||||
interpolatedHeight = topRightHeight * (1 - offsetY) * (offsetX);
|
|
||||||
interpolatedHeight += (bottomRightHeight * offsetY * offsetX);
|
|
||||||
interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY);
|
|
||||||
interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY));
|
|
||||||
|
|
||||||
interpolatedHeight *= (float) this.maxHeight / 256; // Scale height
|
|
||||||
|
|
||||||
return interpolatedHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void generatePixelData() {
|
|
||||||
|
|
||||||
Color color;
|
|
||||||
|
|
||||||
// Generate altitude lookup table for this heightmap
|
|
||||||
|
|
||||||
this.pixelColorValues = new int[this.heightmapImage.getWidth()][this.heightmapImage.getHeight()];
|
|
||||||
|
|
||||||
for (int y = 0; y < this.heightmapImage.getHeight(); y++) {
|
|
||||||
for (int x = 0; x < this.heightmapImage.getWidth(); x++) {
|
|
||||||
|
|
||||||
color = new Color(this.heightmapImage.getRGB(x, y));
|
|
||||||
pixelColorValues[x][y] = color.getRed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getScaledHeightForColor(float color) {
|
|
||||||
|
|
||||||
return (color / 256) * this.maxHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getBucketWidthX() {
|
public float getBucketWidthX() {
|
||||||
return bucketWidthX;
|
return bucketWidthX;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -137,7 +140,7 @@ public enum InterestManager implements Runnable {
|
|||||||
|
|
||||||
else {
|
else {
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
if (pcc.getSeeInvis() < pc.getHidden())
|
if (pcc.getSeeInvis() < pc.hidden)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!cc.sendMsg(uom)) {
|
if (!cc.sendMsg(uom)) {
|
||||||
@@ -337,7 +340,7 @@ public enum InterestManager implements Runnable {
|
|||||||
if (loadedPlayer.getObjectUUID() == player.getObjectUUID())
|
if (loadedPlayer.getObjectUUID() == player.getObjectUUID())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (player.getSeeInvis() < loadedPlayer.getHidden())
|
if (player.getSeeInvis() < loadedPlayer.hidden)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (loadedPlayer.safemodeInvis())
|
if (loadedPlayer.safemodeInvis())
|
||||||
@@ -369,7 +372,7 @@ public enum InterestManager implements Runnable {
|
|||||||
|
|
||||||
if (playerLoadedObject.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
if (playerLoadedObject.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
||||||
PlayerCharacter loadedPlayer = (PlayerCharacter) playerLoadedObject;
|
PlayerCharacter loadedPlayer = (PlayerCharacter) playerLoadedObject;
|
||||||
if (player.getSeeInvis() < loadedPlayer.getHidden())
|
if (player.getSeeInvis() < loadedPlayer.hidden)
|
||||||
toRemove.add(playerLoadedObject);
|
toRemove.add(playerLoadedObject);
|
||||||
else if (loadedPlayer.safemodeInvis())
|
else if (loadedPlayer.safemodeInvis())
|
||||||
toRemove.add(playerLoadedObject);
|
toRemove.add(playerLoadedObject);
|
||||||
@@ -434,7 +437,7 @@ public enum InterestManager implements Runnable {
|
|||||||
|
|
||||||
// dont load if invis
|
// dont load if invis
|
||||||
|
|
||||||
if (player.getSeeInvis() < awopc.getHidden())
|
if (player.getSeeInvis() < awopc.hidden)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
lcm = new LoadCharacterMsg(awopc, PlayerCharacter.hideNonAscii());
|
lcm = new LoadCharacterMsg(awopc, PlayerCharacter.hideNonAscii());
|
||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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() {
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,31 +28,27 @@ 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.setString(14, toAdd.behaviourType.toString());
|
||||||
|
|
||||||
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 +102,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("minionName");
|
||||||
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;
|
||||||
@@ -131,15 +127,13 @@ public class dbMobHandler extends dbHandlerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean ADD_TO_GUARDS(final long captainUID, final int mobBaseID, final String name, final int slot) {
|
public boolean ADD_GUARD_MINION(final long captainUID, final String minionName) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_guards` (`captainUID`, `mobBaseID`,`name`, `slot`) VALUES (?,?,?,?)")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_guards` (`captainUID`, `minionName`) VALUES (?,?)")) {
|
||||||
|
|
||||||
preparedStatement.setLong(1, captainUID);
|
preparedStatement.setLong(1, captainUID);
|
||||||
preparedStatement.setInt(2, mobBaseID);
|
preparedStatement.setString(2, minionName);
|
||||||
preparedStatement.setString(3, name);
|
|
||||||
preparedStatement.setInt(4, slot);
|
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -149,14 +143,13 @@ public class dbMobHandler extends dbHandlerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean REMOVE_FROM_GUARDS(final long captainUID, final int mobBaseID, final int slot) {
|
public boolean REMOVE_GUARD_MINION(final long captainUID, final String minionName) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guards` WHERE `captainUID`=? AND `mobBaseID`=? AND `slot` =?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guards` WHERE `captainUID`=? AND `minionName`=? LIMIT 1;")) {
|
||||||
|
|
||||||
preparedStatement.setLong(1, captainUID);
|
preparedStatement.setLong(1, captainUID);
|
||||||
preparedStatement.setInt(2, mobBaseID);
|
preparedStatement.setString(2, minionName);
|
||||||
preparedStatement.setInt(3, slot);
|
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -166,6 +159,20 @@ public class dbMobHandler extends dbHandlerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean REMOVE_ALL_MINIONS(final long captainUID) {
|
||||||
|
|
||||||
|
try (Connection connection = DbManager.getConnection();
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guards` WHERE `captainUID`=?;")) {
|
||||||
|
|
||||||
|
preparedStatement.setLong(1, captainUID);
|
||||||
|
|
||||||
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ArrayList<Mob> GET_ALL_MOBS_FOR_ZONE(Zone zone) {
|
public ArrayList<Mob> GET_ALL_MOBS_FOR_ZONE(Zone zone) {
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -15,15 +15,9 @@ import engine.gameManager.PowersManager;
|
|||||||
import engine.objects.Mob;
|
import engine.objects.Mob;
|
||||||
import engine.objects.PreparedStatementShared;
|
import engine.objects.PreparedStatementShared;
|
||||||
import engine.powers.EffectsBase;
|
import engine.powers.EffectsBase;
|
||||||
import engine.powers.MobPowerEntry;
|
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
public class dbPowerHandler extends dbHandlerBase {
|
public class dbPowerHandler extends dbHandlerBase {
|
||||||
@@ -86,43 +80,4 @@ public class dbPowerHandler extends dbHandlerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<Integer, ArrayList<MobPowerEntry>> LOAD_MOB_POWERS() {
|
|
||||||
|
|
||||||
HashMap<Integer, ArrayList<MobPowerEntry>> mobPowers = new HashMap<>();
|
|
||||||
MobPowerEntry mobPowerEntry;
|
|
||||||
|
|
||||||
int mobbaseID;
|
|
||||||
int recordsRead = 0;
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_npc_mobbase_powers ORDER BY `id` ASC;")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
|
|
||||||
recordsRead++;
|
|
||||||
|
|
||||||
mobbaseID = rs.getInt("mobbaseUUID");
|
|
||||||
mobPowerEntry = new MobPowerEntry(rs);
|
|
||||||
|
|
||||||
if (mobPowers.get(mobbaseID) == null) {
|
|
||||||
ArrayList<MobPowerEntry> powerList = new ArrayList<>();
|
|
||||||
powerList.add(mobPowerEntry);
|
|
||||||
mobPowers.put(mobbaseID, powerList);
|
|
||||||
} else {
|
|
||||||
ArrayList<MobPowerEntry> powerList = mobPowers.get(mobbaseID);
|
|
||||||
powerList.add(mobPowerEntry);
|
|
||||||
mobPowers.put(mobbaseID, powerList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
return mobPowers;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.info("read: " + recordsRead + " cached: " + mobPowers.size());
|
|
||||||
return mobPowers;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ package engine.db.handlers;
|
|||||||
|
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.objects.RuneBase;
|
import engine.objects.RuneBase;
|
||||||
|
import engine.powers.RunePowerEntry;
|
||||||
|
import engine.powers.RuneSkillAdjustEntry;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -27,6 +29,84 @@ public class dbRuneBaseHandler extends dbHandlerBase {
|
|||||||
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
|
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HashMap<Integer, ArrayList<RunePowerEntry>> LOAD_RUNE_POWERS() {
|
||||||
|
|
||||||
|
HashMap<Integer, ArrayList<RunePowerEntry>> mobPowers = new HashMap<>();
|
||||||
|
RunePowerEntry runePowerEntry;
|
||||||
|
|
||||||
|
int rune_id;
|
||||||
|
int recordsRead = 0;
|
||||||
|
|
||||||
|
try (Connection connection = DbManager.getConnection();
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_rune_powers")) {
|
||||||
|
|
||||||
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
|
||||||
|
recordsRead++;
|
||||||
|
|
||||||
|
rune_id = rs.getInt("rune_id");
|
||||||
|
runePowerEntry = new RunePowerEntry(rs);
|
||||||
|
|
||||||
|
if (mobPowers.get(rune_id) == null) {
|
||||||
|
ArrayList<RunePowerEntry> runePowerList = new ArrayList<>();
|
||||||
|
runePowerList.add(runePowerEntry);
|
||||||
|
mobPowers.put(rune_id, runePowerList);
|
||||||
|
} else {
|
||||||
|
ArrayList<RunePowerEntry> powerList = mobPowers.get(rune_id);
|
||||||
|
powerList.add(runePowerEntry);
|
||||||
|
mobPowers.put(rune_id, powerList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
return mobPowers;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.info("read: " + recordsRead + " cached: " + mobPowers.size());
|
||||||
|
return mobPowers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HashMap<Integer, ArrayList<RuneSkillAdjustEntry>> LOAD_RUNE_SKILL_ADJUSTS() {
|
||||||
|
|
||||||
|
HashMap<Integer, ArrayList<RuneSkillAdjustEntry>> runeSkillAdjusts = new HashMap<>();
|
||||||
|
RuneSkillAdjustEntry runeSkillAdjustEntry;
|
||||||
|
|
||||||
|
int rune_id;
|
||||||
|
int recordsRead = 0;
|
||||||
|
|
||||||
|
try (Connection connection = DbManager.getConnection();
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_rune_skill_adjusts")) {
|
||||||
|
|
||||||
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
|
||||||
|
recordsRead++;
|
||||||
|
|
||||||
|
rune_id = rs.getInt("rune_id");
|
||||||
|
runeSkillAdjustEntry = new RuneSkillAdjustEntry(rs);
|
||||||
|
|
||||||
|
if (runeSkillAdjusts.get(rune_id) == null) {
|
||||||
|
ArrayList<RuneSkillAdjustEntry> skillAdjustList = new ArrayList<>();
|
||||||
|
skillAdjustList.add(runeSkillAdjustEntry);
|
||||||
|
runeSkillAdjusts.put(rune_id, skillAdjustList);
|
||||||
|
} else {
|
||||||
|
ArrayList<RuneSkillAdjustEntry> powerList = runeSkillAdjusts.get(rune_id);
|
||||||
|
powerList.add(runeSkillAdjustEntry);
|
||||||
|
runeSkillAdjusts.put(rune_id, powerList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
return runeSkillAdjusts;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.info("read: " + recordsRead + " cached: " + runeSkillAdjusts.size());
|
||||||
|
return runeSkillAdjusts;
|
||||||
|
}
|
||||||
|
|
||||||
public void GET_RUNE_REQS(final RuneBase rb) {
|
public void GET_RUNE_REQS(final RuneBase rb) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
package engine.devcmd.cmds;
|
package engine.devcmd.cmds;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
import engine.Enum.GameObjectType;
|
import engine.Enum.GameObjectType;
|
||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.gameManager.ChatManager;
|
import engine.gameManager.ChatManager;
|
||||||
@@ -43,7 +44,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, Enum.AIAgentType.MOBILE);
|
||||||
if (mob != null) {
|
if (mob != null) {
|
||||||
mob.updateDatabase();
|
mob.updateDatabase();
|
||||||
this.setResult(String.valueOf(mob.getDBID()));
|
this.setResult(String.valueOf(mob.getDBID()));
|
||||||
@@ -84,7 +85,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, Enum.AIAgentType.MOBILE);
|
||||||
if (mob != null) {
|
if (mob != null) {
|
||||||
mob.updateDatabase();
|
mob.updateDatabase();
|
||||||
ChatManager.chatSayInfo(pc,
|
ChatManager.chatSayInfo(pc,
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
||||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
||||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
||||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
||||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
||||||
// Magicbane Emulator Project © 2013 - 2022
|
|
||||||
// www.magicbane.com
|
|
||||||
|
|
||||||
|
|
||||||
package engine.devcmd.cmds;
|
|
||||||
|
|
||||||
import engine.InterestManagement.HeightMap;
|
|
||||||
import engine.devcmd.AbstractDevCmd;
|
|
||||||
import engine.gameManager.ZoneManager;
|
|
||||||
import engine.math.Vector2f;
|
|
||||||
import engine.math.Vector3fImmutable;
|
|
||||||
import engine.objects.AbstractGameObject;
|
|
||||||
import engine.objects.PlayerCharacter;
|
|
||||||
import engine.objects.Zone;
|
|
||||||
|
|
||||||
public class AuditHeightMapCmd extends AbstractDevCmd {
|
|
||||||
|
|
||||||
public AuditHeightMapCmd() {
|
|
||||||
super("auditheightmap");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void _doCmd(PlayerCharacter pcSender, String[] words,
|
|
||||||
AbstractGameObject target) {
|
|
||||||
|
|
||||||
int count = Integer.parseInt(words[0]);
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
|
|
||||||
|
|
||||||
Zone currentZone = ZoneManager.findSmallestZone(pcSender.getLoc());
|
|
||||||
|
|
||||||
|
|
||||||
Vector3fImmutable currentLoc = Vector3fImmutable.getRandomPointInCircle(currentZone.getLoc(), currentZone.getBounds().getHalfExtents().x < currentZone.getBounds().getHalfExtents().y ? currentZone.getBounds().getHalfExtents().x : currentZone.getBounds().getHalfExtents().y);
|
|
||||||
|
|
||||||
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(currentLoc, currentZone);
|
|
||||||
|
|
||||||
if (currentZone != null && currentZone.getHeightMap() != null) {
|
|
||||||
float altitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
|
|
||||||
float outsetAltitude = HeightMap.getOutsetHeight(altitude, currentZone, pcSender.getLoc());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
long end = System.currentTimeMillis();
|
|
||||||
|
|
||||||
long delta = end - start;
|
|
||||||
|
|
||||||
this.throwbackInfo(pcSender, "Audit Heightmap took " + delta + " ms to run " + count + " times!");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String _getUsageString() {
|
|
||||||
return "' /auditmobs [zone.UUID]'";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String _getHelpString() {
|
|
||||||
return "Audits all the mobs in a zone.";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -13,7 +13,6 @@ import engine.InterestManagement.HeightMap;
|
|||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.gameManager.ZoneManager;
|
import engine.gameManager.ZoneManager;
|
||||||
import engine.math.Vector2f;
|
import engine.math.Vector2f;
|
||||||
import engine.math.Vector3fImmutable;
|
|
||||||
import engine.objects.AbstractGameObject;
|
import engine.objects.AbstractGameObject;
|
||||||
import engine.objects.PlayerCharacter;
|
import engine.objects.PlayerCharacter;
|
||||||
import engine.objects.Zone;
|
import engine.objects.Zone;
|
||||||
@@ -22,205 +21,58 @@ public class GetHeightCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
public GetHeightCmd() {
|
public GetHeightCmd() {
|
||||||
super("getHeight");
|
super("getHeight");
|
||||||
this.addCmdString("height");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
protected void _doCmd(PlayerCharacter playerCharacter, String[] words,
|
||||||
AbstractGameObject target) {
|
AbstractGameObject target) {
|
||||||
|
|
||||||
boolean end = true;
|
Zone currentZone;
|
||||||
|
Zone parentZone;
|
||||||
|
Zone heightmapZone;
|
||||||
|
|
||||||
float height = HeightMap.getWorldHeight(pc);
|
currentZone = ZoneManager.findSmallestZone(playerCharacter.getLoc());
|
||||||
|
heightmapZone = HeightMap.getNextZoneWithTerrain(currentZone);
|
||||||
|
parentZone = HeightMap.getNextZoneWithTerrain(currentZone.getParent());
|
||||||
|
|
||||||
this.throwbackInfo(pc, "Altitude : " + height);
|
float currentHeight = HeightMap.getWorldHeight(currentZone, playerCharacter.getLoc());
|
||||||
|
float parentHeight = HeightMap.getWorldHeight(parentZone, playerCharacter.getLoc());
|
||||||
|
|
||||||
this.throwbackInfo(pc, "Character Height: " + pc.getCharacterHeight());
|
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(playerCharacter.getLoc(), heightmapZone);
|
||||||
this.throwbackInfo(pc, "Character Height to start swimming: " + pc.centerHeight);
|
Vector2f gridSquare = heightmapZone.getHeightMap().getGridSquare(zoneLoc);
|
||||||
|
|
||||||
Zone zone = ZoneManager.findSmallestZone(pc.getLoc());
|
this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.getName());
|
||||||
this.throwbackInfo(pc, "Water Level : " + zone.getSeaLevel());
|
this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.getName());
|
||||||
this.throwbackInfo(pc, "Character Water Level Above : " + (pc.getCharacterHeight() + height - zone.getSeaLevel()));
|
this.throwbackInfo(playerCharacter, "Zone Height: " + heightmapZone.worldAltitude);
|
||||||
|
this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.getSeaLevel());
|
||||||
|
this.throwbackInfo(playerCharacter, "Grid : " + (int) gridSquare.x + "x" + (int) gridSquare.y);
|
||||||
|
this.throwbackInfo(playerCharacter, "*** 256: " + currentHeight);
|
||||||
|
this.throwbackInfo(playerCharacter, "***Adjusted Height: " + (currentHeight + playerCharacter.getCharacterHeight()));
|
||||||
|
|
||||||
if (end)
|
HeightMap.SCALEVALUE = 1f / 255f;
|
||||||
return;
|
currentHeight = HeightMap.getWorldHeight(currentZone, playerCharacter.getLoc());
|
||||||
|
HeightMap.SCALEVALUE = 1f / 256f;
|
||||||
Vector2f gridSquare;
|
|
||||||
Vector2f gridOffset;
|
|
||||||
Vector2f parentGrid;
|
|
||||||
Vector2f parentLoc = new Vector2f(-1, -1);
|
|
||||||
|
|
||||||
Zone currentZone = ZoneManager.findSmallestZone(pc.getLoc());
|
|
||||||
|
|
||||||
if (currentZone == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Zone parentZone = currentZone.getParent();
|
|
||||||
|
|
||||||
HeightMap heightMap = currentZone.getHeightMap();
|
|
||||||
|
|
||||||
|
|
||||||
//find the next parents heightmap if the currentzone heightmap is null.
|
|
||||||
while (heightMap == null) {
|
|
||||||
|
|
||||||
if (currentZone == ZoneManager.getSeaFloor()) {
|
|
||||||
this.throwbackInfo(pc, "Could not find a heightmap to get height.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.throwbackError(pc, "Heightmap does not exist for " + currentZone.getName());
|
|
||||||
this.throwbackInfo(pc, "Using parent zone instead: ");
|
|
||||||
currentZone = currentZone.getParent();
|
|
||||||
heightMap = currentZone.getHeightMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ((heightMap == null) || (currentZone == ZoneManager.getSeaFloor())) {
|
|
||||||
this.throwbackInfo(pc, currentZone.getName() + " has no heightmap ");
|
|
||||||
this.throwbackInfo(pc, "Current altitude: " + currentZone.absY);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(pc.getLoc(), currentZone);
|
|
||||||
|
|
||||||
Vector3fImmutable seaFloorLocalLoc = ZoneManager.worldToLocal(pc.getLoc(), ZoneManager.getSeaFloor());
|
|
||||||
this.throwbackInfo(pc, "SeaFloor Local : " + seaFloorLocalLoc.x + " , " + seaFloorLocalLoc.y);
|
|
||||||
|
|
||||||
|
|
||||||
this.throwbackInfo(pc, "Local Zone Location : " + zoneLoc.x + " , " + zoneLoc.y);
|
|
||||||
Vector3fImmutable localLocFromCenter = ZoneManager.worldToLocal(pc.getLoc(), currentZone);
|
|
||||||
Vector3fImmutable parentLocFromCenter = ZoneManager.worldToLocal(pc.getLoc(), currentZone.getParent());
|
|
||||||
this.throwbackInfo(pc, "Local Zone Location from center : " + localLocFromCenter);
|
|
||||||
this.throwbackInfo(pc, "parent Zone Location from center : " + parentLocFromCenter);
|
|
||||||
|
|
||||||
Vector2f parentZoneLoc = ZoneManager.worldToZoneSpace(pc.getLoc(), currentZone.getParent());
|
|
||||||
this.throwbackInfo(pc, "Parent Zone Location from Bottom Left : " + parentZoneLoc);
|
|
||||||
|
|
||||||
if ((parentZone != null) && (parentZone.getHeightMap() != null)) {
|
|
||||||
parentLoc = ZoneManager.worldToZoneSpace(pc.getLoc(), parentZone);
|
|
||||||
parentGrid = parentZone.getHeightMap().getGridSquare(parentLoc);
|
|
||||||
} else
|
|
||||||
parentGrid = new Vector2f(-1, -1);
|
|
||||||
|
|
||||||
gridSquare = heightMap.getGridSquare(zoneLoc);
|
|
||||||
gridOffset = HeightMap.getGridOffset(gridSquare);
|
|
||||||
|
|
||||||
float interaltitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
|
|
||||||
|
|
||||||
this.throwbackInfo(pc, currentZone.getName());
|
|
||||||
this.throwbackInfo(pc, "Current Grid Square: " + gridSquare.x + " , " + gridSquare.y);
|
|
||||||
this.throwbackInfo(pc, "Grid Offset: " + gridOffset.x + " , " + gridOffset.y);
|
|
||||||
this.throwbackInfo(pc, "Parent Grid: " + parentGrid.x + " , " + parentGrid.y);
|
|
||||||
|
|
||||||
if (parentGrid.x != -1) {
|
|
||||||
float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
|
||||||
this.throwbackInfo(pc, "Parent ALTITUDE: " + (parentAltitude));
|
|
||||||
this.throwbackInfo(pc, "Parent Interpolation: " + (parentAltitude + parentZone.getWorldAltitude()));
|
|
||||||
}
|
|
||||||
this.throwbackInfo(pc, "interpolated height: " + interaltitude);
|
|
||||||
|
|
||||||
this.throwbackInfo(pc, "interpolated height with World: " + (interaltitude + currentZone.getWorldAltitude()));
|
|
||||||
|
|
||||||
float realWorldAltitude = interaltitude + currentZone.getWorldAltitude();
|
|
||||||
|
|
||||||
//OUTSET
|
|
||||||
if (parentZone != null) {
|
|
||||||
float parentXRadius = currentZone.getBounds().getHalfExtents().x;
|
|
||||||
float parentZRadius = currentZone.getBounds().getHalfExtents().y;
|
|
||||||
|
|
||||||
float offsetX = Math.abs((localLocFromCenter.x / parentXRadius));
|
|
||||||
float offsetZ = Math.abs((localLocFromCenter.z / parentZRadius));
|
|
||||||
|
|
||||||
float bucketScaleX = 100 / parentXRadius;
|
|
||||||
float bucketScaleZ = 200 / parentZRadius;
|
|
||||||
|
|
||||||
float outsideGridSizeX = 1 - bucketScaleX; //32/256
|
|
||||||
float outsideGridSizeZ = 1 - bucketScaleZ;
|
|
||||||
float weight;
|
|
||||||
|
|
||||||
double scale;
|
|
||||||
|
|
||||||
|
|
||||||
if (offsetX > outsideGridSizeX && offsetX > offsetZ) {
|
|
||||||
weight = (offsetX - outsideGridSizeX) / bucketScaleX;
|
|
||||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
|
||||||
|
|
||||||
float scaleChild = (float) ((scale + 1) * .5);
|
|
||||||
float scaleParent = 1 - scaleChild;
|
|
||||||
|
|
||||||
|
|
||||||
float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
|
||||||
float parentCenterAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone));
|
|
||||||
|
|
||||||
parentCenterAltitude += currentZone.getYCoord();
|
|
||||||
parentCenterAltitude += interaltitude;
|
|
||||||
|
|
||||||
float firstScale = parentAltitude * scaleParent;
|
|
||||||
float secondScale = parentCenterAltitude * scaleChild;
|
|
||||||
float outsetALt = firstScale + secondScale;
|
|
||||||
|
|
||||||
outsetALt += currentZone.getParent().getAbsY();
|
|
||||||
realWorldAltitude = outsetALt;
|
|
||||||
|
|
||||||
} else if (offsetZ > outsideGridSizeZ) {
|
|
||||||
|
|
||||||
weight = (offsetZ - outsideGridSizeZ) / bucketScaleZ;
|
|
||||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
|
||||||
|
|
||||||
float scaleChild = (float) ((scale + 1) * .5);
|
|
||||||
float scaleParent = 1 - scaleChild;
|
|
||||||
float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
|
||||||
float parentCenterAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone));
|
|
||||||
|
|
||||||
parentCenterAltitude += currentZone.getYCoord();
|
|
||||||
parentCenterAltitude += interaltitude;
|
|
||||||
float firstScale = parentAltitude * scaleParent;
|
|
||||||
float secondScale = parentCenterAltitude * scaleChild;
|
|
||||||
float outsetALt = firstScale + secondScale;
|
|
||||||
|
|
||||||
outsetALt += currentZone.getParent().getAbsY();
|
|
||||||
realWorldAltitude = outsetALt;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float strMod = pc.statStrBase - 40;
|
|
||||||
|
|
||||||
strMod *= .00999999998f;
|
|
||||||
|
|
||||||
strMod += 1f;
|
|
||||||
|
|
||||||
float radius = 0;
|
|
||||||
switch (pc.getRaceID()) {
|
|
||||||
case 2017:
|
|
||||||
radius = 3.1415927f;
|
|
||||||
case 2000:
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
strMod *= 1.5707964f;
|
|
||||||
|
|
||||||
strMod += 3.1415927f;
|
|
||||||
|
|
||||||
strMod -= .5f;
|
|
||||||
|
|
||||||
|
|
||||||
realWorldAltitude += strMod;
|
|
||||||
|
|
||||||
this.throwbackInfo(pc, "interpolated height with World: " + realWorldAltitude);
|
|
||||||
|
|
||||||
|
this.throwbackInfo(playerCharacter, "***255 Adjusted: " + (currentHeight + playerCharacter.getCharacterHeight()));
|
||||||
|
this.throwbackInfo(playerCharacter, "Drowning Height: " + (heightmapZone.getSeaLevel() + playerCharacter.getCharacterHeight()));
|
||||||
|
|
||||||
|
this.throwbackInfo(playerCharacter, "------------");
|
||||||
|
this.throwbackInfo(playerCharacter, "Parent : " + parentZone.getName());
|
||||||
|
this.throwbackInfo(playerCharacter, "Height returned : " + parentHeight);
|
||||||
|
this.throwbackInfo(playerCharacter, "[" + (gridSquare.x) + "][" + (gridSquare.y) + "]");
|
||||||
|
this.throwbackInfo(playerCharacter, "[" + (gridSquare.x + 1) + "][" + (gridSquare.y) + "]");
|
||||||
|
this.throwbackInfo(playerCharacter, "[" + (gridSquare.x) + "][" + (gridSquare.y + 1) + "]");
|
||||||
|
this.throwbackInfo(playerCharacter, "[" + (gridSquare.x + 1) + "][" + (gridSquare.y + 1) + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String _getHelpString() {
|
protected String _getHelpString() {
|
||||||
return "Temporarily Changes SubRace";
|
return "Queries heightmap engine";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String _getUsageString() {
|
protected String _getUsageString() {
|
||||||
return "' /subrace mobBaseID";
|
return "' /getheight";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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]";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
@@ -341,9 +337,7 @@ public class InfoCmd extends AbstractDevCmd {
|
|||||||
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();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NPC:
|
case NPC:
|
||||||
@@ -446,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;
|
||||||
@@ -498,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:
|
||||||
@@ -538,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);
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
+31
-27
@@ -9,55 +9,59 @@
|
|||||||
|
|
||||||
package engine.devcmd.cmds;
|
package engine.devcmd.cmds;
|
||||||
|
|
||||||
import engine.Enum.ItemContainerType;
|
|
||||||
import engine.Enum.ItemType;
|
|
||||||
import engine.Enum.OwnerType;
|
|
||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.gameManager.ChatManager;
|
|
||||||
import engine.gameManager.DbManager;
|
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
import engine.powers.EffectsBase;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Eighty
|
*
|
||||||
*/
|
*/
|
||||||
public class GimmeCmd extends AbstractDevCmd {
|
|
||||||
|
|
||||||
public GimmeCmd() {
|
public class PrintEffectsCmd extends AbstractDevCmd {
|
||||||
super("gimme");
|
|
||||||
|
public PrintEffectsCmd() {
|
||||||
|
super("printeffects");
|
||||||
|
// super("printstats", MBServerStatics.ACCESS_LEVEL_ADMIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemBase getWeaponBase(int slot, HashMap<Integer, MobEquipment> equip) {
|
||||||
|
if (equip.containsKey(slot)) {
|
||||||
|
MobEquipment item = equip.get(slot);
|
||||||
|
if (item != null && item.getItemBase() != null) {
|
||||||
|
return item.getItemBase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||||
AbstractGameObject target) {
|
AbstractGameObject target) {
|
||||||
int amt = 0;
|
|
||||||
int currentGold = pc.getCharItemManager().getGoldInventory().getNumOfItems();
|
AbstractCharacter tar;
|
||||||
amt = 10000000 - currentGold;
|
|
||||||
if (!pc.getCharItemManager().addGoldToInventory(amt, true)) {
|
if (target != null && target instanceof AbstractCharacter) {
|
||||||
throwbackError(pc, "Failed to add gold to inventory");
|
tar = (AbstractCharacter) target;
|
||||||
return;
|
|
||||||
|
String newline = "\r\n ";
|
||||||
|
String output = "Effects For Character: " + tar.getName() + newline;
|
||||||
|
|
||||||
|
for(String effect : tar.effects.keySet()){
|
||||||
|
output += effect + newline;
|
||||||
}
|
}
|
||||||
|
throwbackInfo(pc, output);
|
||||||
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
|
@Override
|
||||||
protected String _getHelpString() {
|
protected String _getHelpString() {
|
||||||
return "Round up current gold in inventory to 10,000,000";
|
return "Returns the player's current stats";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String _getUsageString() {
|
protected String _getUsageString() {
|
||||||
return "'./gimme";
|
return "' /printstats'";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
|
||||||
|
package engine.devcmd.cmds;
|
||||||
|
|
||||||
|
import engine.devcmd.AbstractDevCmd;
|
||||||
|
import engine.objects.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class PrintRunesCmd extends AbstractDevCmd {
|
||||||
|
|
||||||
|
public PrintRunesCmd() {
|
||||||
|
super("printrunes");
|
||||||
|
// super("printstats", MBServerStatics.ACCESS_LEVEL_ADMIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemBase getWeaponBase(int slot, HashMap<Integer, MobEquipment> equip) {
|
||||||
|
if (equip.containsKey(slot)) {
|
||||||
|
MobEquipment item = equip.get(slot);
|
||||||
|
if (item != null && item.getItemBase() != null) {
|
||||||
|
return item.getItemBase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||||
|
AbstractGameObject target) {
|
||||||
|
|
||||||
|
AbstractCharacter tar;
|
||||||
|
|
||||||
|
if (target != null && target instanceof AbstractCharacter) {
|
||||||
|
tar = (AbstractCharacter) target;
|
||||||
|
|
||||||
|
String newline = "\r\n ";
|
||||||
|
String output = "Applied Runes For Character: " + ((AbstractCharacter) target).getName() + newline;
|
||||||
|
|
||||||
|
for(CharacterRune rune : ((AbstractCharacter)target).runes){
|
||||||
|
output += rune.getRuneBaseID() + " " + rune.getRuneBase().getName() + newline;
|
||||||
|
}
|
||||||
|
throwbackInfo(pc, output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String _getHelpString() {
|
||||||
|
return "Returns the player's current stats";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String _getUsageString() {
|
||||||
|
return "' /printstats'";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
package engine.devcmd.cmds;
|
package engine.devcmd.cmds;
|
||||||
|
|
||||||
import engine.Enum;
|
|
||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
|
||||||
@@ -57,36 +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;
|
|
||||||
throwbackInfo(pc, newOut);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printStatsMob(PlayerCharacter pc, Mob tar) {
|
public void printStatsMob(PlayerCharacter pc, Mob tar) {
|
||||||
@@ -117,15 +103,19 @@ public class PrintStatsCmd extends AbstractDevCmd {
|
|||||||
main = getWeaponBase(1, equip);
|
main = getWeaponBase(1, equip);
|
||||||
ItemBase off = null;
|
ItemBase off = null;
|
||||||
|
|
||||||
if (equip != null)
|
if(equip != null){
|
||||||
getWeaponBase(2, equip);
|
if(equip.get(2) != null && !equip.get(2).getItemBase().isShield()){
|
||||||
if (main == null && off == null) {
|
//off hand weapon
|
||||||
out += "Main Hand: atr: " + tar.getAtrHandOne() + ", damage: " + tar.getMinDamageHandOne() + " to " + tar.getMaxDamageHandOne() + ", speed: " + tar.getSpeedHandOne() + ", range: 6" + newline;
|
out += "Attack Rating: " + tar.atrHandTwo + newline;
|
||||||
|
out += "Damage: " + tar.minDamageHandTwo + " - " + tar.maxDamageHandTwo + newline;
|
||||||
|
out += "Range: " + tar.rangeHandTwo + newline;
|
||||||
|
out += "Attack Speed: " + tar.speedHandTwo + newline;
|
||||||
} else{
|
} else{
|
||||||
if (main != null)
|
out += "Attack Rating: " + tar.atrHandOne + newline;
|
||||||
out += "Main Hand: atr: " + tar.getAtrHandOne() + ", damage: " + tar.getMinDamageHandOne() + " to " + tar.getMaxDamageHandOne() + ", speed: " + tar.getSpeedHandOne() + ", range: " + main.getRange() + newline;
|
out += "Damage: " + tar.minDamageHandOne + " - " + tar.maxDamageHandOne + newline;
|
||||||
if (off != null)
|
out += "Range: " + tar.rangeHandOne + newline;
|
||||||
out += "Main Hand: atr: " + tar.getAtrHandTwo() + ", damage: " + tar.getMinDamageHandTwo() + " to " + tar.getMaxDamageHandTwo() + ", speed: " + tar.getSpeedHandTwo() + ", range: " + off.getRange() + newline;
|
out += "Attack Speed: " + tar.speedHandOne + newline;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
out += "isAlive: " + tar.isAlive() + ", Combat: " + tar.isCombat() + newline;
|
out += "isAlive: " + tar.isAlive() + ", Combat: " + tar.isCombat() + newline;
|
||||||
|
|
||||||
|
|||||||
@@ -59,22 +59,25 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
|
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
for (Mob mob : npc.getSiegeMinionMap().keySet()) {
|
for (Integer minionUUID : npc.minions) {
|
||||||
|
Mob mob = Mob.getMob(minionUUID);
|
||||||
WorldGrid.RemoveWorldObject(mob);
|
WorldGrid.RemoveWorldObject(mob);
|
||||||
WorldGrid.removeObject(mob, pc);
|
WorldGrid.removeObject(mob, pc);
|
||||||
//Mob.getRespawnMap().remove(mob);
|
|
||||||
if (mob.getParentZone() != null)
|
if (mob.getParentZone() != null)
|
||||||
mob.getParentZone().zoneMobSet.remove(mob);
|
mob.getParentZone().zoneMobSet.remove(mob);
|
||||||
}
|
}
|
||||||
|
|
||||||
DbManager.NPCQueries.DELETE_NPC(npc);
|
DbManager.NPCQueries.DELETE_NPC(npc);
|
||||||
DbManager.removeFromCache(GameObjectType.NPC,
|
DbManager.removeFromCache(GameObjectType.NPC,
|
||||||
npc.getObjectUUID());
|
npc.getObjectUUID());
|
||||||
WorldGrid.RemoveWorldObject(npc);
|
WorldGrid.RemoveWorldObject(npc);
|
||||||
} else if (mobA != null) {
|
} else if (mobA != null) {
|
||||||
for (Mob mob : mobA.getSiegeMinionMap().keySet()) {
|
for (Integer minionUUID : mobA.minions) {
|
||||||
|
Mob mob = Mob.getMob(minionUUID);
|
||||||
WorldGrid.RemoveWorldObject(mob);
|
WorldGrid.RemoveWorldObject(mob);
|
||||||
WorldGrid.removeObject(mob, pc);
|
WorldGrid.removeObject(mob, pc);
|
||||||
//Mob.getRespawnMap().remove(mob);
|
|
||||||
if (mob.getParentZone() != null)
|
if (mob.getParentZone() != null)
|
||||||
mob.getParentZone().zoneMobSet.remove(mob);
|
mob.getParentZone().zoneMobSet.remove(mob);
|
||||||
}
|
}
|
||||||
@@ -151,10 +154,11 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
|
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
for (Mob mob : npc.getSiegeMinionMap().keySet()) {
|
for (Integer minionUUID : npc.minions) {
|
||||||
|
Mob mob = Mob.getMob(minionUUID);
|
||||||
WorldGrid.RemoveWorldObject(mob);
|
WorldGrid.RemoveWorldObject(mob);
|
||||||
WorldGrid.removeObject(mob, pc);
|
WorldGrid.removeObject(mob, pc);
|
||||||
//Mob.getRespawnMap().remove(mob);
|
|
||||||
if (mob.getParentZone() != null)
|
if (mob.getParentZone() != null)
|
||||||
mob.getParentZone().zoneMobSet.remove(mob);
|
mob.getParentZone().zoneMobSet.remove(mob);
|
||||||
}
|
}
|
||||||
@@ -163,10 +167,11 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
|
|||||||
npc.getObjectUUID());
|
npc.getObjectUUID());
|
||||||
WorldGrid.RemoveWorldObject(npc);
|
WorldGrid.RemoveWorldObject(npc);
|
||||||
} else if (mobA != null) {
|
} else if (mobA != null) {
|
||||||
for (Mob mob : mobA.getSiegeMinionMap().keySet()) {
|
for (Integer minionUUID : mobA.minions) {
|
||||||
|
Mob mob = Mob.getMob(minionUUID);
|
||||||
WorldGrid.RemoveWorldObject(mob);
|
WorldGrid.RemoveWorldObject(mob);
|
||||||
WorldGrid.removeObject(mob, pc);
|
WorldGrid.removeObject(mob, pc);
|
||||||
//Mob.getRespawnMap().remove(mob);
|
|
||||||
if (mob.getParentZone() != null)
|
if (mob.getParentZone() != null)
|
||||||
mob.getParentZone().zoneMobSet.remove(mob);
|
mob.getParentZone().zoneMobSet.remove(mob);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,9 @@
|
|||||||
|
|
||||||
package engine.devcmd.cmds;
|
package engine.devcmd.cmds;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.objects.AbstractGameObject;
|
import engine.objects.*;
|
||||||
import engine.objects.PlayerCharacter;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
@@ -25,42 +25,17 @@ public class RegionCmd extends AbstractDevCmd {
|
|||||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||||
AbstractGameObject target) {
|
AbstractGameObject target) {
|
||||||
|
|
||||||
|
Regions region = ((AbstractCharacter)target).region;
|
||||||
if (pc.region == null) {
|
if (region == null) {
|
||||||
this.throwbackInfo(pc, "No Region Found.");
|
this.throwbackInfo(pc, "No Region Found.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(region != null) {
|
||||||
String newLine = System.getProperty("line.separator");
|
this.throwbackInfo(pc, "Region Info: " + ((AbstractCharacter) target).getName());
|
||||||
String result = "";
|
this.throwbackInfo(pc, "Region Name: " + region);
|
||||||
result += (pc.region.getClass().getSimpleName());
|
this.throwbackInfo(pc, "Region Height: " + region.lerpY((AbstractCharacter)target));
|
||||||
result += (" {");
|
|
||||||
result += (newLine);
|
|
||||||
Field[] fields = pc.region.getClass().getDeclaredFields();
|
|
||||||
|
|
||||||
//print field names paired with their values
|
|
||||||
for (Field field : fields) {
|
|
||||||
field.setAccessible(true);
|
|
||||||
result += (" ");
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (field.getName().contains("Furniture"))
|
|
||||||
continue;
|
|
||||||
result += (field.getName());
|
|
||||||
result += (": ");
|
|
||||||
//requires access to private field:
|
|
||||||
result += (field.get(pc.region).toString());
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
System.out.println(ex);
|
|
||||||
}
|
}
|
||||||
result.trim();
|
|
||||||
result += (newLine);
|
|
||||||
}
|
|
||||||
result += ("}");
|
|
||||||
|
|
||||||
this.throwbackInfo(pc, result.toString());
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ package engine.devcmd.cmds;
|
|||||||
|
|
||||||
import engine.Enum.BuildingGroup;
|
import engine.Enum.BuildingGroup;
|
||||||
import engine.Enum.DbObjectType;
|
import engine.Enum.DbObjectType;
|
||||||
import engine.Enum.GameObjectType;
|
|
||||||
import engine.InterestManagement.WorldGrid;
|
import engine.InterestManagement.WorldGrid;
|
||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.gameManager.BuildingManager;
|
import engine.gameManager.BuildingManager;
|
||||||
@@ -138,49 +137,16 @@ public class RemoveObjectCmd extends AbstractDevCmd {
|
|||||||
Warehouse.warehouseByBuildingUUID.remove(building.getObjectUUID());
|
Warehouse.warehouseByBuildingUUID.remove(building.getObjectUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//remove cached shrines.
|
//remove cached shrines.
|
||||||
if ((building.getBlueprintUUID() != 0)
|
if ((building.getBlueprintUUID() != 0)
|
||||||
&& (building.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE))
|
&& (building.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE))
|
||||||
Shrine.RemoveShrineFromCacheByBuilding(building);
|
Shrine.RemoveShrineFromCacheByBuilding(building);
|
||||||
|
|
||||||
for (AbstractCharacter ac : building.getHirelings().keySet()) {
|
// Remove hirelings for this building
|
||||||
NPC npc = null;
|
|
||||||
Mob mobA = null;
|
|
||||||
|
|
||||||
if (ac.getObjectType() == GameObjectType.NPC)
|
for (AbstractCharacter abstractCharacter : building.getHirelings().keySet())
|
||||||
npc = (NPC) ac;
|
BuildingManager.removeHireling(building, abstractCharacter);
|
||||||
else if (ac.getObjectType() == GameObjectType.Mob)
|
|
||||||
mobA = (Mob) ac;
|
|
||||||
|
|
||||||
if (npc != null) {
|
|
||||||
for (Mob mob : npc.getSiegeMinionMap().keySet()) {
|
|
||||||
WorldGrid.RemoveWorldObject(mob);
|
|
||||||
WorldGrid.removeObject(mob, pc);
|
|
||||||
//Mob.getRespawnMap().remove(mob);
|
|
||||||
if (mob.getParentZone() != null)
|
|
||||||
mob.getParentZone().zoneMobSet.remove(mob);
|
|
||||||
}
|
|
||||||
DbManager.NPCQueries.DELETE_NPC(npc);
|
|
||||||
DbManager.removeFromCache(npc);
|
|
||||||
WorldGrid.RemoveWorldObject(npc);
|
|
||||||
WorldGrid.removeObject(npc, pc);
|
|
||||||
} else if (mobA != null) {
|
|
||||||
for (Mob mob : mobA.getSiegeMinionMap().keySet()) {
|
|
||||||
WorldGrid.RemoveWorldObject(mob);
|
|
||||||
WorldGrid.removeObject(mob, pc);
|
|
||||||
//Mob.getRespawnMap().remove(mob);
|
|
||||||
if (mob.getParentZone() != null)
|
|
||||||
mob.getParentZone().zoneMobSet.remove(mob);
|
|
||||||
}
|
|
||||||
DbManager.MobQueries.DELETE_MOB(mobA);
|
|
||||||
DbManager.removeFromCache(mobA);
|
|
||||||
WorldGrid.RemoveWorldObject(mobA);
|
|
||||||
WorldGrid.removeObject(mobA, pc);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
Zone zone = building.getParentZone();
|
Zone zone = building.getParentZone();
|
||||||
DbManager.BuildingQueries.DELETE_FROM_DATABASE(building);
|
DbManager.BuildingQueries.DELETE_FROM_DATABASE(building);
|
||||||
DbManager.removeFromCache(building);
|
DbManager.removeFromCache(building);
|
||||||
@@ -209,11 +175,13 @@ 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 (Integer minionUUID : npc.minions) {
|
||||||
WorldGrid.RemoveWorldObject(mob);
|
Mob minionMob = Mob.getMob(minionUUID);
|
||||||
WorldGrid.removeObject(mob, pc);
|
WorldGrid.RemoveWorldObject(minionMob);
|
||||||
if (mob.getParentZone() != null)
|
WorldGrid.removeObject(minionMob, pc);
|
||||||
mob.getParentZone().zoneMobSet.remove(mob);
|
|
||||||
|
if (minionMob.getParentZone() != null)
|
||||||
|
minionMob.getParentZone().zoneMobSet.remove(minionMob);
|
||||||
}
|
}
|
||||||
|
|
||||||
DbManager.NPCQueries.DELETE_NPC(npc);
|
DbManager.NPCQueries.DELETE_NPC(npc);
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// 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;
|
||||||
|
import engine.objects.Zone;
|
||||||
|
|
||||||
|
public class SeaAuditCmd extends AbstractDevCmd {
|
||||||
|
|
||||||
|
public SeaAuditCmd() {
|
||||||
|
super("seaaudit");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void _doCmd(PlayerCharacter playerCharacter, String[] words,
|
||||||
|
AbstractGameObject target) {
|
||||||
|
|
||||||
|
for (Zone zone : ZoneManager.getAllZones())
|
||||||
|
if (zone.getSeaLevel() > zone.worldAltitude)
|
||||||
|
this.throwbackInfo(playerCharacter, zone.getObjectUUID() + zone.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String _getHelpString() {
|
||||||
|
return "Queries heightmap engine";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String _getUsageString() {
|
||||||
|
return "' /getheight";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ public class SetSubRaceCmd extends AbstractDevCmd {
|
|||||||
// pum.setEffectID(token);
|
// pum.setEffectID(token);
|
||||||
// pum.setSourceType(pc.getObjectType().ordinal());
|
// pum.setSourceType(pc.getObjectType().ordinal());
|
||||||
// pum.setSourceID(pc.getObjectUUID());
|
// pum.setSourceID(pc.getObjectUUID());
|
||||||
// pum.setTargetType(pc.getObjectType().ordinal());
|
// pum.setStartLocType(pc.getObjectType().ordinal());
|
||||||
// pum.setTargetID(pc.getObjectUUID());
|
// pum.setTargetID(pc.getObjectUUID());
|
||||||
// pum.setNumTrains(40);
|
// pum.setNumTrains(40);
|
||||||
// pum.setDuration(-1);
|
// pum.setDuration(-1);
|
||||||
|
|||||||
@@ -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,5 +1,6 @@
|
|||||||
package engine.devcmd.cmds;
|
package engine.devcmd.cmds;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.gameManager.ZoneManager;
|
import engine.gameManager.ZoneManager;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
@@ -110,7 +111,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, Enum.AIAgentType.MOBILE);
|
||||||
|
|
||||||
if (mobile != null) {
|
if (mobile != null) {
|
||||||
mobile.updateDatabase();
|
mobile.updateDatabase();
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class ZoneInfoCmd extends AbstractDevCmd {
|
|||||||
output += newline;
|
output += newline;
|
||||||
output += "Sea Level = " + zone.getSeaLevel();
|
output += "Sea Level = " + zone.getSeaLevel();
|
||||||
output += newline;
|
output += newline;
|
||||||
output += "World Altitude = " + zone.getWorldAltitude();
|
output += "World Altitude = " + zone.worldAltitude;
|
||||||
throwbackInfo(player, output);
|
throwbackInfo(player, output);
|
||||||
|
|
||||||
City city = ZoneManager.getCityAtLocation(player.getLoc());
|
City city = ZoneManager.getCityAtLocation(player.getLoc());
|
||||||
|
|||||||
@@ -9,12 +9,17 @@
|
|||||||
|
|
||||||
package engine.devcmd.cmds;
|
package engine.devcmd.cmds;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
import engine.Enum.GameObjectType;
|
import engine.Enum.GameObjectType;
|
||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
|
import engine.gameManager.PowersManager;
|
||||||
|
import engine.mobileAI.MobAI;
|
||||||
import engine.objects.AbstractGameObject;
|
import engine.objects.AbstractGameObject;
|
||||||
import engine.objects.Mob;
|
import engine.objects.Mob;
|
||||||
import engine.objects.PlayerCharacter;
|
import engine.objects.PlayerCharacter;
|
||||||
|
import engine.powers.RunePowerEntry;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
@@ -56,18 +61,39 @@ 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) {
|
output += mob.agentType.toString() + newline;
|
||||||
output += "BehaviourType: " + mob.BehaviourType.toString() + newline;
|
|
||||||
if (mob.BehaviourType.BehaviourHelperType != null) {
|
int contractID = 0;
|
||||||
output += "Behaviour Helper Type: " + mob.BehaviourType.BehaviourHelperType.toString() + newline;
|
|
||||||
|
if (mob.isPlayerGuard() == true) {
|
||||||
|
|
||||||
|
if (mob.agentType.equals(Enum.AIAgentType.GUARDMINION))
|
||||||
|
contractID = mob.guardCaptain.contract.getContractID();
|
||||||
|
else
|
||||||
|
contractID = mob.contract.getContractID();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contractID != 0) {
|
||||||
|
|
||||||
|
if (mob.agentType.equals(Enum.AIAgentType.GUARDMINION)) {
|
||||||
|
output += "Captain Contract: " + contractID + newline;
|
||||||
|
output += "Captain UUID: " + mob.guardCaptain.getObjectUUID() + newline;
|
||||||
|
} else
|
||||||
|
output += "Contract: " + contractID + newline;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mob.behaviourType != null) {
|
||||||
|
output += "BehaviourType: " + mob.behaviourType.toString() + newline;
|
||||||
|
if (mob.behaviourType.BehaviourHelperType != null) {
|
||||||
|
output += "Behaviour Helper Type: " + mob.behaviourType.BehaviourHelperType.toString() + newline;
|
||||||
} else {
|
} 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 +102,54 @@ 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;
|
||||||
|
|
||||||
for (int token : mob.mobPowers.keySet())
|
if (mob.guardedCity != null)
|
||||||
output += token + newline;
|
output += "Patrolling: " + mob.guardedCity.getCityName() + newline;
|
||||||
|
output += "See Invis Level: " + mob.mobBase.getSeeInvis() + newline;
|
||||||
|
output += "Can Cast: " + MobAI.canCast(mob) + newline;
|
||||||
|
output += "Powers:" + newline;
|
||||||
|
|
||||||
|
ArrayList<RunePowerEntry> powerEntries = new ArrayList<>(PowersManager.getPowersForRune(mob.getMobBaseID()));
|
||||||
|
|
||||||
|
// Additional powers may come from the contract ID. This is to support
|
||||||
|
// powers for player guards irrespective of the mobbase used.
|
||||||
|
|
||||||
|
if (mob.isPlayerGuard()) {
|
||||||
|
|
||||||
|
ArrayList<RunePowerEntry> contractEntries = new ArrayList<>();
|
||||||
|
|
||||||
|
if (mob.contract != null)
|
||||||
|
contractEntries = new ArrayList<>(PowersManager.getPowersForRune(mob.contractUUID));
|
||||||
|
|
||||||
|
if (mob.agentType.equals(Enum.AIAgentType.GUARDMINION))
|
||||||
|
contractEntries = new ArrayList<>(PowersManager.getPowersForRune(mob.guardCaptain.contractUUID));
|
||||||
|
|
||||||
|
powerEntries.addAll(contractEntries);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for (RunePowerEntry runePowerEntry : powerEntries)
|
||||||
|
output += PowersManager.getPowerByToken(runePowerEntry.token).getName() + newline;
|
||||||
|
|
||||||
|
// List outlaws defined for this player guard's city
|
||||||
|
|
||||||
|
if (mob.isPlayerGuard()) {
|
||||||
|
|
||||||
|
ArrayList<Integer> outlaws = new ArrayList(mob.guardedCity.cityOutlaws);
|
||||||
|
|
||||||
|
if (outlaws.isEmpty() == false)
|
||||||
|
output += "Outlaws: " + newline;
|
||||||
|
|
||||||
|
for (Integer outlawUUID : outlaws)
|
||||||
|
output += outlawUUID + newline;
|
||||||
|
}
|
||||||
|
|
||||||
throwbackInfo(playerCharacter, output);
|
throwbackInfo(playerCharacter, output);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -308,6 +308,72 @@ public enum BuildingManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void removeHireling(Building building, AbstractCharacter hireling) {
|
||||||
|
|
||||||
|
if (hireling.getObjectType().equals(GameObjectType.Mob)) {
|
||||||
|
|
||||||
|
Mob guardCaptain = (Mob) hireling;
|
||||||
|
|
||||||
|
// Clear minions from database if a guard captain
|
||||||
|
|
||||||
|
if (guardCaptain.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN))
|
||||||
|
DbManager.MobQueries.REMOVE_ALL_MINIONS(hireling.getObjectUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear minions from world
|
||||||
|
|
||||||
|
for (Integer minionUUID : hireling.minions) {
|
||||||
|
Mob minionMob = Mob.getMob(minionUUID);
|
||||||
|
DbManager.removeFromCache(minionMob);
|
||||||
|
WorldGrid.RemoveWorldObject(minionMob);
|
||||||
|
WorldGrid.unloadObject(minionMob);
|
||||||
|
|
||||||
|
if (minionMob.getParentZone() != null)
|
||||||
|
minionMob.getParentZone().zoneMobSet.remove(minionMob);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove hireling from building
|
||||||
|
|
||||||
|
building.getHirelings().remove(hireling);
|
||||||
|
|
||||||
|
// Remove from zone mob set
|
||||||
|
|
||||||
|
if (hireling.getObjectType().equals(GameObjectType.Mob)) {
|
||||||
|
|
||||||
|
Mob hirelingMob = (Mob) hireling;
|
||||||
|
|
||||||
|
if (hirelingMob.getParentZone() != null)
|
||||||
|
if (hirelingMob.getParentZone().zoneMobSet.contains(hirelingMob))
|
||||||
|
hirelingMob.getParentZone().zoneMobSet.remove(hireling);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hireling.getObjectType().equals(GameObjectType.NPC)) {
|
||||||
|
|
||||||
|
NPC hirelingNPC = (NPC) hireling;
|
||||||
|
|
||||||
|
if (hirelingNPC.getParentZone() != null)
|
||||||
|
if (hirelingNPC.getParentZone().zoneNPCSet.contains(hirelingNPC))
|
||||||
|
hirelingNPC.getParentZone().zoneNPCSet.remove(hireling);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unload hireling from world
|
||||||
|
|
||||||
|
DbManager.removeFromCache(hireling);
|
||||||
|
WorldGrid.RemoveWorldObject(hireling);
|
||||||
|
WorldGrid.removeObject(hireling);
|
||||||
|
|
||||||
|
// Delete hireling from database
|
||||||
|
|
||||||
|
if (hireling.getObjectType().equals(GameObjectType.Mob))
|
||||||
|
DbManager.MobQueries.DELETE_MOB((Mob) hireling);
|
||||||
|
else
|
||||||
|
DbManager.NPCQueries.DELETE_NPC((NPC) hireling);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void cleanupHirelings(Building building) {
|
public static void cleanupHirelings(Building building) {
|
||||||
|
|
||||||
// Early exit: Cannot have hirelings in a building
|
// Early exit: Cannot have hirelings in a building
|
||||||
@@ -320,42 +386,18 @@ public enum BuildingManager {
|
|||||||
|
|
||||||
if (building.getRank() < 1) {
|
if (building.getRank() < 1) {
|
||||||
|
|
||||||
for (AbstractCharacter slottedNPC : building.getHirelings().keySet()) {
|
for (AbstractCharacter slottedNPC : building.getHirelings().keySet())
|
||||||
|
BuildingManager.removeHireling(building, slottedNPC);
|
||||||
|
|
||||||
if (slottedNPC.getObjectType() == Enum.GameObjectType.NPC)
|
|
||||||
((NPC) slottedNPC).remove();
|
|
||||||
else if (slottedNPC.getObjectType() == Enum.GameObjectType.Mob)
|
|
||||||
NPCManager.removeMobileFromBuilding(((Mob) slottedNPC), building);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete hireling if building has deranked.
|
// Delete hireling if building has deranked.
|
||||||
|
|
||||||
for (AbstractCharacter hireling : building.getHirelings().keySet()) {
|
for (AbstractCharacter hireling : building.getHirelings().keySet()) {
|
||||||
|
|
||||||
NPC npc = null;
|
|
||||||
Mob mob = null;
|
|
||||||
|
|
||||||
if (hireling.getObjectType() == Enum.GameObjectType.NPC)
|
|
||||||
npc = (NPC) hireling;
|
|
||||||
else if (hireling.getObjectType() == Enum.GameObjectType.Mob)
|
|
||||||
mob = (Mob) hireling;
|
|
||||||
|
|
||||||
if (building.getHirelings().get(hireling) > building.getBlueprint().getSlotsForRank(building.getRank()))
|
if (building.getHirelings().get(hireling) > building.getBlueprint().getSlotsForRank(building.getRank()))
|
||||||
|
BuildingManager.removeHireling(building, hireling);
|
||||||
if (npc != null) {
|
|
||||||
if (!npc.remove())
|
|
||||||
Logger.error("Failed to remove npc " + npc.getObjectUUID()
|
|
||||||
+ "from Building " + building.getObjectUUID());
|
|
||||||
else
|
|
||||||
building.getHirelings().remove(npc);
|
|
||||||
} else if (mob != null) {
|
|
||||||
if (!NPCManager.removeMobileFromBuilding(mob, building))
|
|
||||||
Logger.error("Failed to remove npc " + npc.getObjectUUID()
|
|
||||||
+ "from Building " + building.getObjectUUID());
|
|
||||||
else
|
|
||||||
building.getHirelings().remove(npc);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,18 +480,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 +562,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());
|
||||||
@@ -565,41 +572,63 @@ public enum BuildingManager {
|
|||||||
else
|
else
|
||||||
rank = 10;
|
rank = 10;
|
||||||
|
|
||||||
Mob mob;
|
Mob mobile;
|
||||||
NPC npc;
|
NPC npc;
|
||||||
|
|
||||||
if (NPC.ISWallArcher(contract)) {
|
if (NPC.ISWallArcher(contract)) {
|
||||||
|
|
||||||
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank);
|
mobile = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank, Enum.AIAgentType.GUARDWALLARCHER);
|
||||||
|
|
||||||
if (mob == null)
|
if (mobile == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
mob.setLoc(mob.getLoc());
|
// Configure AI and write new mobile to disk
|
||||||
|
|
||||||
|
mobile.behaviourType = Enum.MobBehaviourType.GuardWallArcher;
|
||||||
|
mobile = DbManager.MobQueries.PERSIST(mobile);
|
||||||
|
|
||||||
|
// Spawn new mobile
|
||||||
|
|
||||||
|
mobile.setLoc(mobile.getLoc());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
mobile = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank, Enum.AIAgentType.GUARDCAPTAIN);
|
||||||
|
|
||||||
if (mob == null)
|
if (mobile == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
mob.setLoc(mob.getLoc());
|
// Configure AI and write new mobile to disk
|
||||||
|
|
||||||
|
mobile.behaviourType = Enum.MobBehaviourType.GuardCaptain;
|
||||||
|
mobile = DbManager.MobQueries.PERSIST(mobile);
|
||||||
|
|
||||||
|
// Spawn new mobile
|
||||||
|
|
||||||
|
mobile.setLoc(mobile.getLoc());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
mobile = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank, Enum.AIAgentType.GUARDCAPTAIN);
|
||||||
|
|
||||||
if (mob == null)
|
if (mobile == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
mob.setLoc(mob.getLoc());
|
// Configure AI and write new mobile to disk
|
||||||
|
|
||||||
|
mobile.behaviourType = Enum.MobBehaviourType.GuardCaptain;
|
||||||
|
mobile = DbManager.MobQueries.PERSIST(mobile);
|
||||||
|
|
||||||
|
// Spawn new mobile
|
||||||
|
|
||||||
|
mobile.setLoc(mobile.getLoc());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
@@ -793,7 +788,7 @@ public enum ChatManager {
|
|||||||
it.remove();
|
it.remove();
|
||||||
else {
|
else {
|
||||||
PlayerCharacter pcc = (PlayerCharacter) awo;
|
PlayerCharacter pcc = (PlayerCharacter) awo;
|
||||||
if (pcc.getSeeInvis() < pc.getHidden())
|
if (pcc.getSeeInvis() < pc.hidden)
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ import java.util.HashSet;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
import static engine.math.FastMath.sqr;
|
|
||||||
|
|
||||||
public enum CombatManager {
|
public enum CombatManager {
|
||||||
|
|
||||||
COMBATMANAGER;
|
COMBATMANAGER;
|
||||||
@@ -41,63 +39,6 @@ public enum CombatManager {
|
|||||||
/**
|
/**
|
||||||
* Message sent by player to attack something.
|
* Message sent by player to attack something.
|
||||||
*/
|
*/
|
||||||
public static void setAttackTarget(AttackCmdMsg msg, ClientConnection origin) throws MsgSendException {
|
|
||||||
|
|
||||||
PlayerCharacter player;
|
|
||||||
int targetType;
|
|
||||||
AbstractWorldObject target;
|
|
||||||
|
|
||||||
if (TargetedActionMsg.un2cnt == 60 || TargetedActionMsg.un2cnt == 70)
|
|
||||||
return;
|
|
||||||
|
|
||||||
player = SessionManager.getPlayerCharacter(origin);
|
|
||||||
|
|
||||||
if (player == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//source must match player this account belongs to
|
|
||||||
|
|
||||||
if (player.getObjectUUID() != msg.getSourceID() || player.getObjectType().ordinal() != msg.getSourceType()) {
|
|
||||||
Logger.error("Msg Source ID " + msg.getSourceID() + " Does not Match Player ID " + player.getObjectUUID());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
targetType = msg.getTargetType();
|
|
||||||
|
|
||||||
if (targetType == GameObjectType.PlayerCharacter.ordinal()) {
|
|
||||||
target = PlayerCharacter.getFromCache(msg.getTargetID());
|
|
||||||
} else if (targetType == GameObjectType.Building.ordinal()) {
|
|
||||||
target = BuildingManager.getBuildingFromCache(msg.getTargetID());
|
|
||||||
} else if (targetType == GameObjectType.Mob.ordinal()) {
|
|
||||||
target = Mob.getFromCache(msg.getTargetID());
|
|
||||||
} else {
|
|
||||||
player.setCombatTarget(null);
|
|
||||||
return; //not valid type to attack
|
|
||||||
}
|
|
||||||
|
|
||||||
// quit of the combat target is already the current combat target
|
|
||||||
// or there is no combat target
|
|
||||||
|
|
||||||
if (target == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//set sources target
|
|
||||||
|
|
||||||
player.setCombatTarget(target);
|
|
||||||
|
|
||||||
//put in combat if not already
|
|
||||||
|
|
||||||
if (!player.isCombat())
|
|
||||||
toggleCombat(true, origin);
|
|
||||||
|
|
||||||
//make character stand if sitting
|
|
||||||
|
|
||||||
if (player.isSit())
|
|
||||||
toggleSit(false, origin);
|
|
||||||
|
|
||||||
AttackTarget(player, target);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void AttackTarget(PlayerCharacter playerCharacter, AbstractWorldObject target) {
|
public static void AttackTarget(PlayerCharacter playerCharacter, AbstractWorldObject target) {
|
||||||
|
|
||||||
@@ -141,11 +82,6 @@ public enum CombatManager {
|
|||||||
if (off == null)
|
if (off == null)
|
||||||
CombatManager.createTimer(playerCharacter, MBServerStatics.SLOT_OFFHAND, 1, true); // attack in 0.1 of a second
|
CombatManager.createTimer(playerCharacter, MBServerStatics.SLOT_OFFHAND, 1, true); // attack in 0.1 of a second
|
||||||
}
|
}
|
||||||
|
|
||||||
City playerCity = ZoneManager.getCityAtLocation(playerCharacter.getLoc());
|
|
||||||
|
|
||||||
if (playerCity != null && playerCity.getGuild().getNation().equals(playerCharacter.getGuild().getNation()) == false && playerCity.cityOutlaws.contains(playerCharacter.getObjectUUID()) == false)
|
|
||||||
playerCity.cityOutlaws.add(playerCharacter.getObjectUUID());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setAttackTarget(PetAttackMsg msg, ClientConnection origin) throws MsgSendException {
|
public static void setAttackTarget(PetAttackMsg msg, ClientConnection origin) throws MsgSendException {
|
||||||
@@ -301,17 +237,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)) {
|
||||||
@@ -494,14 +419,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));
|
||||||
@@ -511,7 +428,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -542,7 +459,7 @@ public enum CombatManager {
|
|||||||
/**
|
/**
|
||||||
* Attempt to attack target
|
* Attempt to attack target
|
||||||
*/
|
*/
|
||||||
private static void attack(AbstractCharacter ac, AbstractWorldObject target, Item weapon, ItemBase wb, boolean mainHand) {
|
private static void attack(AbstractCharacter attacker, AbstractWorldObject target, Item weapon, ItemBase wb, boolean mainHand) {
|
||||||
|
|
||||||
float atr;
|
float atr;
|
||||||
int minDamage, maxDamage;
|
int minDamage, maxDamage;
|
||||||
@@ -550,34 +467,20 @@ public enum CombatManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (ac == null)
|
if (attacker == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (target == null)
|
if (target == null)
|
||||||
return;
|
return;
|
||||||
if(ac.getObjectType().equals(GameObjectType.PlayerCharacter)){
|
|
||||||
PlayerCharacter pc = (PlayerCharacter) ac;
|
|
||||||
pc.combatStats.calculateATR(true);
|
|
||||||
pc.combatStats.calculateATR(false);
|
|
||||||
if (mainHand) {
|
if (mainHand) {
|
||||||
atr = pc.combatStats.atrHandOne;
|
atr = attacker.getAtrHandOne();
|
||||||
minDamage = pc.combatStats.minDamageHandOne;
|
minDamage = attacker.getMinDamageHandOne();
|
||||||
maxDamage = pc.combatStats.maxDamageHandOne;
|
maxDamage = attacker.getMaxDamageHandOne();
|
||||||
} else {
|
} else {
|
||||||
atr = pc.combatStats.atrHandTwo;
|
atr = attacker.getAtrHandTwo();
|
||||||
minDamage = pc.combatStats.minDamageHandTwo;
|
minDamage = attacker.getMinDamageHandTwo();
|
||||||
maxDamage = pc.combatStats.maxDamageHandTwo;
|
maxDamage = attacker.getMaxDamageHandTwo();
|
||||||
}
|
|
||||||
}else {
|
|
||||||
if (mainHand) {
|
|
||||||
atr = ac.getAtrHandOne();
|
|
||||||
minDamage = ac.getMinDamageHandOne();
|
|
||||||
maxDamage = ac.getMaxDamageHandOne();
|
|
||||||
} else {
|
|
||||||
atr = ac.getAtrHandTwo();
|
|
||||||
minDamage = ac.getMinDamageHandTwo();
|
|
||||||
maxDamage = ac.getMaxDamageHandTwo();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean tarIsRat = false;
|
boolean tarIsRat = false;
|
||||||
@@ -596,9 +499,9 @@ public enum CombatManager {
|
|||||||
//Dont think we need to do this anymore.
|
//Dont think we need to do this anymore.
|
||||||
|
|
||||||
if (tarIsRat)
|
if (tarIsRat)
|
||||||
if (ac.getBonuses().getFloatPercentAll(ModType.Slay, SourceType.Rat) != 0) { //strip away current % dmg buffs then add with rat %
|
if (attacker.getBonuses().getFloatPercentAll(ModType.Slay, SourceType.Rat) != 0) { //strip away current % dmg buffs then add with rat %
|
||||||
|
|
||||||
float percent = 1 + ac.getBonuses().getFloatPercentAll(ModType.Slay, SourceType.Rat);
|
float percent = 1 + attacker.getBonuses().getFloatPercentAll(ModType.Slay, SourceType.Rat);
|
||||||
|
|
||||||
minDamage *= percent;
|
minDamage *= percent;
|
||||||
maxDamage *= percent;
|
maxDamage *= percent;
|
||||||
@@ -609,24 +512,24 @@ public enum CombatManager {
|
|||||||
//subtract stamina
|
//subtract stamina
|
||||||
|
|
||||||
if (wb == null)
|
if (wb == null)
|
||||||
ac.modifyStamina(-0.5f, ac, true);
|
attacker.modifyStamina(-0.5f, attacker, true);
|
||||||
else {
|
else {
|
||||||
float stam = wb.getWeight() / 3;
|
float stam = wb.getWeight() / 3;
|
||||||
stam = (stam < 1) ? 1 : stam;
|
stam = (stam < 1) ? 1 : stam;
|
||||||
ac.modifyStamina(-(stam), ac, true);
|
attacker.modifyStamina(-(stam), attacker, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ac.cancelOnAttackSwing();
|
attacker.cancelOnAttackSwing();
|
||||||
|
|
||||||
errorTrack = 2;
|
errorTrack = 2;
|
||||||
|
|
||||||
//set last time this player has attacked something.
|
//set last time this player has attacked something.
|
||||||
|
|
||||||
if (target.getObjectType().equals(GameObjectType.PlayerCharacter) && target.getObjectUUID() != ac.getObjectUUID() && ac.getObjectType() == GameObjectType.PlayerCharacter) {
|
if (target.getObjectType().equals(GameObjectType.PlayerCharacter) && target.getObjectUUID() != attacker.getObjectUUID() && attacker.getObjectType() == GameObjectType.PlayerCharacter) {
|
||||||
ac.setTimeStamp("LastCombatPlayer", System.currentTimeMillis());
|
attacker.setTimeStamp("LastCombatPlayer", System.currentTimeMillis());
|
||||||
((PlayerCharacter) target).setTimeStamp("LastCombatPlayer", System.currentTimeMillis());
|
((PlayerCharacter) target).setTimeStamp("LastCombatPlayer", System.currentTimeMillis());
|
||||||
} else
|
} else
|
||||||
ac.setTimeStamp("LastCombatMob", System.currentTimeMillis());
|
attacker.setTimeStamp("LastCombatMob", System.currentTimeMillis());
|
||||||
|
|
||||||
errorTrack = 3;
|
errorTrack = 3;
|
||||||
|
|
||||||
@@ -637,77 +540,46 @@ public enum CombatManager {
|
|||||||
if (target.getObjectType().equals(GameObjectType.Building)) {
|
if (target.getObjectType().equals(GameObjectType.Building)) {
|
||||||
|
|
||||||
if (BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) {
|
if (BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) {
|
||||||
ac.setCombatTarget(null);
|
attacker.setCombatTarget(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
defense = 0;
|
defense = 0;
|
||||||
|
|
||||||
Building building = (Building) target;
|
|
||||||
|
|
||||||
if (building.getParentZone() != null && building.getParentZone().isPlayerCity()) {
|
|
||||||
|
|
||||||
if (System.currentTimeMillis() > building.getTimeStamp("CallForHelp")) {
|
|
||||||
|
|
||||||
building.getTimestamps().put("CallForHelp", System.currentTimeMillis() + 15000);
|
|
||||||
|
|
||||||
for (Mob mob : building.getParentZone().zoneMobSet) {
|
|
||||||
if (!mob.isPlayerGuard())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (mob.getCombatTarget() != null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (mob.getGuild() != null && building.getGuild() != null)
|
|
||||||
if (!Guild.sameGuild(mob.getGuild().getNation(), building.getGuild().getNation()))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (mob.getLoc().distanceSquared2D(building.getLoc()) > sqr(300))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mob.setCombatTarget(ac);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} 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, attacker); //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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
errorTrack = 4;
|
errorTrack = 4;
|
||||||
|
|
||||||
//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 (attacker.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||||
updateAttackTimers((PlayerCharacter) ac, target, true);
|
updateAttackTimers((PlayerCharacter) attacker, target, true);
|
||||||
|
|
||||||
boolean skipPassives = false;
|
boolean skipPassives = false;
|
||||||
PlayerBonuses bonuses = ac.getBonuses();
|
PlayerBonuses bonuses = attacker.getBonuses();
|
||||||
|
|
||||||
if (bonuses != null && bonuses.getBool(ModType.IgnorePassiveDefense, SourceType.None))
|
if (bonuses != null && bonuses.getBool(ModType.IgnorePassiveDefense, SourceType.None))
|
||||||
skipPassives = true;
|
skipPassives = true;
|
||||||
@@ -722,43 +594,31 @@ public enum CombatManager {
|
|||||||
// Apply Weapon power effect if any. don't try to apply twice if
|
// Apply Weapon power effect if any. don't try to apply twice if
|
||||||
// dual wielding. Perform after passive test for sync purposes.
|
// dual wielding. Perform after passive test for sync purposes.
|
||||||
|
|
||||||
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter) && (mainHand || wb.isTwoHanded())) {
|
if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter) && (mainHand || wb.isTwoHanded())) {
|
||||||
|
|
||||||
dpj = ((PlayerCharacter) ac).getWeaponPower();
|
dpj = ((PlayerCharacter) attacker).getWeaponPower();
|
||||||
|
|
||||||
if (dpj != null) {
|
if (dpj != null) {
|
||||||
|
|
||||||
PlayerBonuses bonus = ac.getBonuses();
|
PlayerBonuses bonus = attacker.getBonuses();
|
||||||
float attackRange = getWeaponRange(wb, bonus);
|
float attackRange = getWeaponRange(wb, bonus);
|
||||||
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) attacker).setWeaponPower(dpj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//check to apply second backstab.
|
//check to apply second backstab.
|
||||||
|
|
||||||
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter) && !mainHand) {
|
if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter) && !mainHand) {
|
||||||
|
|
||||||
dpj = ((PlayerCharacter) ac).getWeaponPower();
|
dpj = ((PlayerCharacter) attacker).getWeaponPower();
|
||||||
|
|
||||||
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(specialCaseHitRoll(dpj.getPowerToken())) {
|
|
||||||
if(hitLanded) {
|
|
||||||
dpj.attack(target, attackRange);
|
dpj.attack(target, attackRange);
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
dpj.attack(target, attackRange);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
errorTrack = 7;
|
errorTrack = 7;
|
||||||
@@ -773,24 +633,24 @@ public enum CombatManager {
|
|||||||
|
|
||||||
//Handle Block passive
|
//Handle Block passive
|
||||||
|
|
||||||
if (testPassive(ac, tarAc, "Block") && canTestBlock(ac, target)) {
|
if (testPassive(attacker, tarAc, "Block") && canTestBlock(attacker, target)) {
|
||||||
|
|
||||||
if (!target.isAlive())
|
if (!target.isAlive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sendPassiveDefenseMessage(ac, wb, target, MBServerStatics.COMBAT_SEND_BLOCK, dpj, mainHand);
|
sendPassiveDefenseMessage(attacker, wb, target, MBServerStatics.COMBAT_SEND_BLOCK, dpj, mainHand);
|
||||||
passiveFired = true;
|
passiveFired = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handle Parry passive
|
//Handle Parry passive
|
||||||
|
|
||||||
if (!passiveFired)
|
if (!passiveFired)
|
||||||
if (canTestParry(ac, target) && testPassive(ac, tarAc, "Parry")) {
|
if (canTestParry(attacker, target) && testPassive(attacker, tarAc, "Parry")) {
|
||||||
|
|
||||||
if (!target.isAlive())
|
if (!target.isAlive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sendPassiveDefenseMessage(ac, wb, target, MBServerStatics.COMBAT_SEND_PARRY, dpj, mainHand);
|
sendPassiveDefenseMessage(attacker, wb, target, MBServerStatics.COMBAT_SEND_PARRY, dpj, mainHand);
|
||||||
passiveFired = true;
|
passiveFired = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -801,12 +661,12 @@ public enum CombatManager {
|
|||||||
//Handle Dodge passive
|
//Handle Dodge passive
|
||||||
|
|
||||||
if (!passiveFired)
|
if (!passiveFired)
|
||||||
if (testPassive(ac, tarAc, "Dodge")) {
|
if (testPassive(attacker, tarAc, "Dodge")) {
|
||||||
|
|
||||||
if (!target.isAlive())
|
if (!target.isAlive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sendPassiveDefenseMessage(ac, wb, target, MBServerStatics.COMBAT_SEND_DODGE, dpj, mainHand);
|
sendPassiveDefenseMessage(attacker, wb, target, MBServerStatics.COMBAT_SEND_DODGE, dpj, mainHand);
|
||||||
passiveFired = true;
|
passiveFired = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -822,7 +682,7 @@ public enum CombatManager {
|
|||||||
//if target is player, set last attack timestamp
|
//if target is player, set last attack timestamp
|
||||||
|
|
||||||
if (target.getObjectType().equals(GameObjectType.PlayerCharacter))
|
if (target.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||||
updateAttackTimers((PlayerCharacter) target, ac, false);
|
updateAttackTimers((PlayerCharacter) target, attacker, false);
|
||||||
|
|
||||||
//Get damage Type
|
//Get damage Type
|
||||||
|
|
||||||
@@ -830,7 +690,7 @@ public enum CombatManager {
|
|||||||
|
|
||||||
if (wb != null)
|
if (wb != null)
|
||||||
damageType = wb.getDamageType();
|
damageType = wb.getDamageType();
|
||||||
else if (ac.getObjectType().equals(GameObjectType.Mob) && ((Mob) ac).isSiege())
|
else if (attacker.getObjectType().equals(GameObjectType.Mob) && ((Mob) attacker).isSiege())
|
||||||
damageType = DamageType.Siege;
|
damageType = DamageType.Siege;
|
||||||
else
|
else
|
||||||
damageType = DamageType.Crush;
|
damageType = DamageType.Crush;
|
||||||
@@ -849,7 +709,7 @@ public enum CombatManager {
|
|||||||
//make sure target is not immune to damage type;
|
//make sure target is not immune to damage type;
|
||||||
|
|
||||||
if (resists != null && resists.immuneTo(damageType)) {
|
if (resists != null && resists.immuneTo(damageType)) {
|
||||||
sendCombatMessage(ac, target, 0f, wb, dpj, mainHand);
|
sendCombatMessage(attacker, target, 0f, wb, dpj, mainHand);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -860,25 +720,9 @@ public enum CombatManager {
|
|||||||
float damage;
|
float damage;
|
||||||
|
|
||||||
if (wb != null)
|
if (wb != null)
|
||||||
damage = calculateDamage(ac, tarAc, minDamage, maxDamage, damageType, resists);
|
damage = calculateDamage(attacker, tarAc, minDamage, maxDamage, damageType, resists);
|
||||||
else
|
else
|
||||||
damage = calculateDamage(ac, tarAc, minDamage, maxDamage, damageType, resists);
|
damage = calculateDamage(attacker, 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.minMod * (mod.getRamp() * eff.getTrains());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(armorPierce > 0){
|
|
||||||
damage *= 1 - armorPierce;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Resists.handleFortitude(tarAc,damageType,damage);
|
|
||||||
|
|
||||||
float d = 0f;
|
float d = 0f;
|
||||||
|
|
||||||
@@ -891,40 +735,35 @@ public enum CombatManager {
|
|||||||
if (tarAc.isSit())
|
if (tarAc.isSit())
|
||||||
damage *= 2.5f; //increase damage if sitting
|
damage *= 2.5f; //increase damage if sitting
|
||||||
|
|
||||||
if (tarAc.getObjectType() == GameObjectType.Mob) {
|
|
||||||
ac.setHateValue(damage * MBServerStatics.PLAYER_COMBAT_HATE_MODIFIER);
|
|
||||||
((Mob) tarAc).handleDirectAggro(ac);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tarAc.getHealth() > 0)
|
if (tarAc.getHealth() > 0)
|
||||||
d = tarAc.modifyHealth(-damage, ac, false);
|
d = tarAc.modifyHealth(-damage, attacker, false);
|
||||||
|
|
||||||
} 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) {
|
||||||
ac.setCombatTarget(null);
|
attacker.setCombatTarget(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target.getHealth() > 0)
|
if (target.getHealth() > 0)
|
||||||
d = ((Building) target).modifyHealth(-damage, ac);
|
d = ((Building) target).modifyHealth(-damage, attacker);
|
||||||
}
|
}
|
||||||
|
|
||||||
errorTrack = 13;
|
errorTrack = 13;
|
||||||
|
|
||||||
//Test to see if any damage needs done to weapon or armor
|
//Test to see if any damage needs done to weapon or armor
|
||||||
|
|
||||||
testItemDamage(ac, target, weapon, wb);
|
testItemDamage(attacker, target, weapon, wb);
|
||||||
|
|
||||||
// if target is dead, we got the killing blow, remove attack timers on our weapons
|
// if target is dead, we got the killing blow, remove attack timers on our weapons
|
||||||
|
|
||||||
if (tarAc != null && !tarAc.isAlive())
|
if (tarAc != null && !tarAc.isAlive())
|
||||||
removeAttackTimers(ac);
|
removeAttackTimers(attacker);
|
||||||
|
|
||||||
//test double death fix
|
//test double death fix
|
||||||
|
|
||||||
if (d != 0)
|
if (d != 0)
|
||||||
sendCombatMessage(ac, target, damage, wb, dpj, mainHand); //send damage message
|
sendCombatMessage(attacker, target, damage, wb, dpj, mainHand); //send damage message
|
||||||
|
|
||||||
errorTrack = 14;
|
errorTrack = 14;
|
||||||
|
|
||||||
@@ -932,18 +771,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(attacker, target);
|
||||||
}catch(Exception e){
|
|
||||||
Logger.error(eff.getName() + " Failed To Cast Proc");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -954,58 +802,52 @@ public enum CombatManager {
|
|||||||
|
|
||||||
//handle damage shields
|
//handle damage shields
|
||||||
|
|
||||||
if (ac.isAlive() && tarAc != null && tarAc.isAlive())
|
if (attacker.isAlive() && tarAc != null && tarAc.isAlive())
|
||||||
handleDamageShields(ac, tarAc, damage);
|
handleDamageShields(attacker, tarAc, damage);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Apply Weapon power effect if any.
|
// Apply Weapon power effect if any.
|
||||||
// don't try to apply twice if dual wielding.
|
// don't try to apply twice if dual wielding.
|
||||||
|
|
||||||
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter) && (mainHand || wb.isTwoHanded())) {
|
if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter) && (mainHand || wb.isTwoHanded())) {
|
||||||
dpj = ((PlayerCharacter) ac).getWeaponPower();
|
dpj = ((PlayerCharacter) attacker).getWeaponPower();
|
||||||
|
|
||||||
if (dpj != null) {
|
if (dpj != null) {
|
||||||
|
|
||||||
PowersBase wp = dpj.getPower();
|
PowersBase wp = dpj.getPower();
|
||||||
|
|
||||||
if (wp.requiresHitRoll() == false) {
|
if (wp.requiresHitRoll() == false) {
|
||||||
PlayerBonuses bonus = ac.getBonuses();
|
PlayerBonuses bonus = attacker.getBonuses();
|
||||||
float attackRange = getWeaponRange(wb, bonus);
|
float attackRange = getWeaponRange(wb, bonus);
|
||||||
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) attacker).setWeaponPower(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target.getObjectType() == GameObjectType.Mob)
|
if (target.getObjectType() == GameObjectType.Mob)
|
||||||
((Mob) target).handleDirectAggro(ac);
|
((Mob) target).handleDirectAggro(attacker);
|
||||||
|
|
||||||
errorTrack = 17;
|
errorTrack = 17;
|
||||||
|
|
||||||
//miss, Send miss message
|
//miss, Send miss message
|
||||||
|
|
||||||
sendCombatMessage(ac, target, 0f, wb, dpj, mainHand);
|
sendCombatMessage(attacker, target, 0f, wb, dpj, mainHand);
|
||||||
|
|
||||||
//if attacker is player, set last attack timestamp
|
//if attacker is player, set last attack timestamp
|
||||||
|
|
||||||
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter))
|
if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||||
updateAttackTimers((PlayerCharacter) ac, target, true);
|
updateAttackTimers((PlayerCharacter) attacker, target, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
errorTrack = 18;
|
errorTrack = 18;
|
||||||
|
|
||||||
//cancel effects that break on attack or attackSwing
|
//cancel effects that break on attack or attackSwing
|
||||||
ac.cancelOnAttack();
|
attacker.cancelOnAttack();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error(ac.getName() + ' ' + errorTrack + ' ' + e);
|
Logger.error(attacker.getName() + ' ' + errorTrack + ' ' + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1085,11 +927,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1119,10 +959,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);
|
||||||
}
|
}
|
||||||
@@ -1244,14 +1080,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)
|
||||||
@@ -1262,7 +1090,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;
|
||||||
|
|
||||||
@@ -1297,7 +1125,7 @@ public enum CombatManager {
|
|||||||
toggleCombat(msg.getToggle(), origin);
|
toggleCombat(msg.getToggle(), origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void toggleCombat(boolean toggle, ClientConnection origin) {
|
public static void toggleCombat(boolean toggle, ClientConnection origin) {
|
||||||
|
|
||||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
|
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
|
||||||
|
|
||||||
@@ -1321,9 +1149,6 @@ public enum CombatManager {
|
|||||||
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();
|
||||||
@@ -1347,68 +1172,69 @@ public enum CombatManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Called when character takes damage.
|
//Called when character takes damage.
|
||||||
public static void handleRetaliate(AbstractCharacter tarAc, AbstractCharacter ac) {
|
public static void handleRetaliate(AbstractCharacter target, AbstractCharacter attacker) {
|
||||||
|
|
||||||
if (ac == null || tarAc == null)
|
if (attacker == null || target == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ac.equals(tarAc))
|
if (attacker.equals(target))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (tarAc.isMoving() && tarAc.getObjectType().equals(GameObjectType.PlayerCharacter))
|
if (target.isMoving() && target.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!tarAc.isAlive() || !ac.isAlive())
|
if (!target.isAlive() || !attacker.isAlive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
boolean isCombat = tarAc.isCombat();
|
boolean isCombat = target.isCombat();
|
||||||
|
|
||||||
//If target in combat and has no target, then attack back
|
//If target in combat and has no target, then attack back
|
||||||
|
|
||||||
AbstractWorldObject awoCombTar = tarAc.getCombatTarget();
|
AbstractWorldObject awoCombTar = target.getCombatTarget();
|
||||||
|
|
||||||
if ((tarAc.isCombat() && awoCombTar == null) || (isCombat && awoCombTar != null && (!awoCombTar.isAlive() || tarAc.isCombat() && NotInRange(tarAc, awoCombTar, tarAc.getRange()))) || (tarAc != null && tarAc.getObjectType() == GameObjectType.Mob && ((Mob) tarAc).isSiege()))
|
if ((target.isCombat() && awoCombTar == null) || (isCombat && awoCombTar != null && (!awoCombTar.isAlive() || target.isCombat() && NotInRange(target, awoCombTar, target.getRange()))) || (target != null && target.getObjectType() == GameObjectType.Mob && ((Mob) target).isSiege()))
|
||||||
if (tarAc.getObjectType().equals(GameObjectType.PlayerCharacter)) { // we are in combat with no valid target
|
if (target.getObjectType().equals(GameObjectType.PlayerCharacter)) { // we are in combat with no valid target
|
||||||
|
|
||||||
PlayerCharacter pc = (PlayerCharacter) tarAc;
|
PlayerCharacter pc = (PlayerCharacter) target;
|
||||||
tarAc.setCombatTarget(ac);
|
target.setCombatTarget(attacker);
|
||||||
pc.setLastTarget(ac.getObjectType(), ac.getObjectUUID());
|
pc.setLastTarget(attacker.getObjectType(), attacker.getObjectUUID());
|
||||||
|
|
||||||
if (tarAc.getTimers() != null)
|
if (target.getTimers() != null)
|
||||||
if (!tarAc.getTimers().containsKey("Attack" + MBServerStatics.SLOT_MAINHAND))
|
if (!target.getTimers().containsKey("Attack" + MBServerStatics.SLOT_MAINHAND))
|
||||||
CombatManager.AttackTarget((PlayerCharacter) tarAc, tarAc.getCombatTarget());
|
CombatManager.AttackTarget((PlayerCharacter) target, target.getCombatTarget());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handle pet retaliate if assist is on and pet doesn't have a target.
|
//Handle pet retaliate if assist is on and pet doesn't have a target.
|
||||||
|
|
||||||
if (tarAc.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
if (target.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
||||||
|
|
||||||
Mob pet = ((PlayerCharacter) tarAc).getPet();
|
Mob pet = ((PlayerCharacter) target).getPet();
|
||||||
|
|
||||||
if (pet != null && pet.assist && pet.getCombatTarget() == null)
|
if (pet != null && pet.assist && pet.getCombatTarget() == null)
|
||||||
pet.setCombatTarget(ac);
|
pet.setCombatTarget(attacker);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handle Mob Retaliate.
|
//Handle Mob Retaliate.
|
||||||
|
|
||||||
if (tarAc.getObjectType() == GameObjectType.Mob) {
|
if (target.getObjectType() == GameObjectType.Mob) {
|
||||||
|
|
||||||
Mob retaliater = (Mob) tarAc;
|
Mob attackedMobile = (Mob) target;
|
||||||
|
|
||||||
if (retaliater.getCombatTarget() != null && !retaliater.isSiege())
|
//handle minion informing his captain of an attack
|
||||||
|
|
||||||
|
if (attackedMobile.agentType.equals(AIAgentType.GUARDMINION) && attackedMobile.guardCaptain != null && attackedMobile.guardCaptain.isAlive()) {
|
||||||
|
|
||||||
|
if (attackedMobile.guardCaptain.combatTarget == null)
|
||||||
|
attackedMobile.guardCaptain.setCombatTarget(attacker);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mobile already has a target; don't switch.
|
||||||
|
|
||||||
|
if (attackedMobile.getCombatTarget() != null && !attackedMobile.isSiege())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ac.getObjectType() == GameObjectType.Mob && retaliater.isSiege())
|
attackedMobile.setCombatTarget(attacker);
|
||||||
return;
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1440,9 +1266,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1525,31 +1351,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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -46,9 +46,11 @@ public enum DevCmdManager {
|
|||||||
DevCmdManager.registerDevCmd(new GetZoneCmd());
|
DevCmdManager.registerDevCmd(new GetZoneCmd());
|
||||||
DevCmdManager.registerDevCmd(new ZoneSetCmd());
|
DevCmdManager.registerDevCmd(new ZoneSetCmd());
|
||||||
DevCmdManager.registerDevCmd(new PrintBankCmd());
|
DevCmdManager.registerDevCmd(new PrintBankCmd());
|
||||||
|
DevCmdManager.registerDevCmd(new PrintEffectsCmd());
|
||||||
DevCmdManager.registerDevCmd(new PrintEquipCmd());
|
DevCmdManager.registerDevCmd(new PrintEquipCmd());
|
||||||
DevCmdManager.registerDevCmd(new PrintInventoryCmd());
|
DevCmdManager.registerDevCmd(new PrintInventoryCmd());
|
||||||
DevCmdManager.registerDevCmd(new PrintVaultCmd());
|
DevCmdManager.registerDevCmd(new PrintVaultCmd());
|
||||||
|
DevCmdManager.registerDevCmd(new PrintRunesCmd());
|
||||||
DevCmdManager.registerDevCmd(new PrintStatsCmd());
|
DevCmdManager.registerDevCmd(new PrintStatsCmd());
|
||||||
DevCmdManager.registerDevCmd(new PrintSkillsCmd());
|
DevCmdManager.registerDevCmd(new PrintSkillsCmd());
|
||||||
DevCmdManager.registerDevCmd(new PrintPowersCmd());
|
DevCmdManager.registerDevCmd(new PrintPowersCmd());
|
||||||
@@ -79,6 +81,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 +105,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
|
||||||
@@ -128,7 +130,6 @@ public enum DevCmdManager {
|
|||||||
DevCmdManager.registerDevCmd(new SetForceRenameCityCmd());
|
DevCmdManager.registerDevCmd(new SetForceRenameCityCmd());
|
||||||
DevCmdManager.registerDevCmd(new GotoObj());
|
DevCmdManager.registerDevCmd(new GotoObj());
|
||||||
DevCmdManager.registerDevCmd(new convertLoc());
|
DevCmdManager.registerDevCmd(new convertLoc());
|
||||||
DevCmdManager.registerDevCmd(new AuditHeightMapCmd());
|
|
||||||
DevCmdManager.registerDevCmd(new UnloadFurnitureCmd());
|
DevCmdManager.registerDevCmd(new UnloadFurnitureCmd());
|
||||||
DevCmdManager.registerDevCmd(new SetNpcEquipSetCmd());
|
DevCmdManager.registerDevCmd(new SetNpcEquipSetCmd());
|
||||||
DevCmdManager.registerDevCmd(new SetBuildingAltitudeCmd());
|
DevCmdManager.registerDevCmd(new SetBuildingAltitudeCmd());
|
||||||
@@ -143,7 +144,7 @@ public enum DevCmdManager {
|
|||||||
DevCmdManager.registerDevCmd(new ApplyBonusCmd());
|
DevCmdManager.registerDevCmd(new ApplyBonusCmd());
|
||||||
DevCmdManager.registerDevCmd(new AuditFailedItemsCmd());
|
DevCmdManager.registerDevCmd(new AuditFailedItemsCmd());
|
||||||
DevCmdManager.registerDevCmd(new SlotTestCmd());
|
DevCmdManager.registerDevCmd(new SlotTestCmd());
|
||||||
|
DevCmdManager.registerDevCmd(new SeaAuditCmd());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerDevCmd(AbstractDevCmd cmd) {
|
private static void registerDevCmd(AbstractDevCmd cmd) {
|
||||||
@@ -177,44 +178,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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,9 +17,7 @@ import engine.objects.*;
|
|||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,12 +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));
|
|
||||||
|
|
||||||
// Drop Rates
|
// Drop Rates
|
||||||
|
|
||||||
public static float NORMAL_DROP_RATE;
|
public static float NORMAL_DROP_RATE;
|
||||||
@@ -76,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()) {
|
||||||
@@ -129,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)
|
||||||
@@ -222,109 +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;
|
|
||||||
|
|
||||||
ItemBase ib = ItemBase.getItemBase(rollRandomItem(RuneTableID));
|
|
||||||
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)
|
||||||
@@ -346,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)
|
||||||
@@ -361,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 {
|
||||||
@@ -395,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,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);
|
||||||
|
|
||||||
@@ -453,7 +248,7 @@ 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);
|
||||||
|
|
||||||
@@ -468,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);
|
||||||
|
|
||||||
@@ -517,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);
|
||||||
@@ -528,61 +315,45 @@ 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())
|
if(mob.behaviourType.equals(Enum.MobBehaviourType.HamletGuard))
|
||||||
return; // no equipment to drop in safezones
|
return; // safehold guards don't drop their equipment
|
||||||
|
|
||||||
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 = 10;
|
|
||||||
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.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -598,11 +369,8 @@ 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 peddleFate(PlayerCharacter playerCharacter, Item gift) {
|
public static void peddleFate(PlayerCharacter playerCharacter, Item gift) {
|
||||||
@@ -626,12 +394,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)
|
||||||
@@ -647,22 +415,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);
|
||||||
@@ -699,224 +457,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, 10);
|
|
||||||
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, 10);
|
|
||||||
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, 10);
|
|
||||||
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, 10);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
@@ -118,8 +116,8 @@ public enum MovementManager {
|
|||||||
|
|
||||||
// if inside a building, convert both locations from the building local reference frame to the world reference frame
|
// if inside a building, convert both locations from the building local reference frame to the world reference frame
|
||||||
|
|
||||||
if (msg.getTargetID() > 0) {
|
if (msg.getInBuildingUUID() > 0) {
|
||||||
Building building = BuildingManager.getBuildingFromCache(msg.getTargetID());
|
Building building = BuildingManager.getBuildingFromCache(msg.getInBuildingUUID());
|
||||||
if (building != null) {
|
if (building != null) {
|
||||||
|
|
||||||
Vector3fImmutable convertLocEnd = new Vector3fImmutable(ZoneManager.convertLocalToWorld(building, endLocation));
|
Vector3fImmutable convertLocEnd = new Vector3fImmutable(ZoneManager.convertLocalToWorld(building, endLocation));
|
||||||
@@ -130,8 +128,8 @@ public enum MovementManager {
|
|||||||
// }
|
// }
|
||||||
// else {
|
// else {
|
||||||
toMove.setInBuilding(msg.getInBuilding());
|
toMove.setInBuilding(msg.getInBuilding());
|
||||||
toMove.setInFloorID(msg.getUnknown01());
|
toMove.setInFloorID(msg.getInBuildingFloor());
|
||||||
toMove.setInBuildingID(msg.getTargetID());
|
toMove.setInBuildingID(msg.getInBuildingUUID());
|
||||||
msg.setStartCoord(ZoneManager.convertWorldToLocal(building, toMove.getLoc()));
|
msg.setStartCoord(ZoneManager.convertWorldToLocal(building, toMove.getLoc()));
|
||||||
|
|
||||||
if (toMove.getObjectType() == GameObjectType.PlayerCharacter) {
|
if (toMove.getObjectType() == GameObjectType.PlayerCharacter) {
|
||||||
@@ -176,9 +174,9 @@ public enum MovementManager {
|
|||||||
msg.setStartCoord(ZoneManager.convertWorldToLocal(Regions.GetBuildingForRegion(toMove.region), toMove.getLoc()));
|
msg.setStartCoord(ZoneManager.convertWorldToLocal(Regions.GetBuildingForRegion(toMove.region), toMove.getLoc()));
|
||||||
msg.setEndCoord(ZoneManager.convertWorldToLocal(regionBuilding, endLocation));
|
msg.setEndCoord(ZoneManager.convertWorldToLocal(regionBuilding, endLocation));
|
||||||
msg.setInBuilding(toMove.region.level);
|
msg.setInBuilding(toMove.region.level);
|
||||||
msg.setUnknown01(toMove.region.room);
|
msg.setInBuildingFloor(toMove.region.room);
|
||||||
msg.setTargetType(GameObjectType.Building.ordinal());
|
msg.setStartLocType(GameObjectType.Building.ordinal());
|
||||||
msg.setTargetID(regionBuilding.getObjectUUID());
|
msg.setInBuildingUUID(regionBuilding.getObjectUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -187,8 +185,8 @@ public enum MovementManager {
|
|||||||
toMove.setInBuilding(-1);
|
toMove.setInBuilding(-1);
|
||||||
msg.setStartCoord(toMove.getLoc());
|
msg.setStartCoord(toMove.getLoc());
|
||||||
msg.setEndCoord(endLocation);
|
msg.setEndCoord(endLocation);
|
||||||
msg.setTargetType(0);
|
msg.setStartLocType(0);
|
||||||
msg.setTargetID(0);
|
msg.setInBuildingUUID(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//checks sync between character and server, if out of sync, teleport player to original position and return.
|
//checks sync between character and server, if out of sync, teleport player to original position and return.
|
||||||
@@ -235,7 +233,7 @@ public enum MovementManager {
|
|||||||
toMove.cancelOnMove();
|
toMove.cancelOnMove();
|
||||||
|
|
||||||
//cancel any attacks for manual move.
|
//cancel any attacks for manual move.
|
||||||
if ((toMove.getObjectType() == GameObjectType.PlayerCharacter) && msg.getUnknown02() == 0)
|
if ((toMove.getObjectType() == GameObjectType.PlayerCharacter) && msg.getInitiatedFromAttack() == 0)
|
||||||
toMove.setCombatTarget(null);
|
toMove.setCombatTarget(null);
|
||||||
|
|
||||||
|
|
||||||
@@ -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
|
||||||
@@ -468,7 +464,7 @@ public enum MovementManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void translocate(AbstractCharacter teleporter, Vector3fImmutable targetLoc, Regions region) {
|
public static void translocate(AbstractCharacter teleporter, Vector3fImmutable targetLoc) {
|
||||||
|
|
||||||
|
|
||||||
if (targetLoc == null)
|
if (targetLoc == null)
|
||||||
@@ -477,7 +473,6 @@ public enum MovementManager {
|
|||||||
Vector3fImmutable oldLoc = new Vector3fImmutable(teleporter.getLoc());
|
Vector3fImmutable oldLoc = new Vector3fImmutable(teleporter.getLoc());
|
||||||
|
|
||||||
teleporter.stopMovement(targetLoc);
|
teleporter.stopMovement(targetLoc);
|
||||||
teleporter.setRegion(region);
|
|
||||||
|
|
||||||
//mobs ignore region sets for now.
|
//mobs ignore region sets for now.
|
||||||
if (teleporter.getObjectType().equals(GameObjectType.Mob)) {
|
if (teleporter.getObjectType().equals(GameObjectType.Mob)) {
|
||||||
|
|||||||
@@ -5,13 +5,17 @@ import engine.InterestManagement.WorldGrid;
|
|||||||
import engine.math.Quaternion;
|
import engine.math.Quaternion;
|
||||||
import engine.math.Vector3f;
|
import engine.math.Vector3f;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
|
import engine.mobileAI.MobAI;
|
||||||
import engine.net.Dispatch;
|
import engine.net.Dispatch;
|
||||||
import engine.net.DispatchMessage;
|
import engine.net.DispatchMessage;
|
||||||
import engine.net.client.msg.PetMsg;
|
import engine.net.client.msg.PetMsg;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
import engine.powers.EffectsBase;
|
import engine.powers.EffectsBase;
|
||||||
|
import engine.powers.PowersBase;
|
||||||
|
import engine.powers.RuneSkillAdjustEntry;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
|
import javax.smartcardio.ATR;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
@@ -23,92 +27,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) {
|
|
||||||
|
|
||||||
// Early exit
|
|
||||||
|
|
||||||
if (mob.runeSet == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//Apply all rune effects.
|
|
||||||
|
|
||||||
if (NPCManager._runeSetMap.get(mob.runeSet).contains(252623)) {
|
|
||||||
mob.isPlayerGuard = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only captains have contracts
|
|
||||||
|
|
||||||
if (mob.contract != null || mob.isPlayerGuard)
|
|
||||||
applyEffectsForRune(mob, 252621);
|
|
||||||
|
|
||||||
|
|
||||||
// Apply effects from RuneSet
|
|
||||||
|
|
||||||
if (mob.runeSet != 0)
|
|
||||||
for (int runeID : _runeSetMap.get(mob.runeSet))
|
|
||||||
applyEffectsForRune(mob, runeID);
|
|
||||||
|
|
||||||
// Not sure why but apply Warrior effects for some reason?
|
|
||||||
|
|
||||||
applyEffectsForRune(mob, 2518);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void applyEffectsForRune(AbstractCharacter character, int runeID) {
|
|
||||||
|
|
||||||
EffectsBase effectsBase;
|
|
||||||
RuneBase sourceRune = RuneBase.getRuneBase(runeID);
|
|
||||||
|
|
||||||
// Race runes are in the runeset but not in runebase for some reason
|
|
||||||
|
|
||||||
if (sourceRune == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (MobBaseEffects mbe : sourceRune.getEffectsList()) {
|
|
||||||
|
|
||||||
effectsBase = PowersManager.getEffectByToken(mbe.getToken());
|
|
||||||
|
|
||||||
if (effectsBase == null) {
|
|
||||||
Logger.info("Mob: " + character.getObjectUUID() + " EffectsBase Null for Token " + mbe.getToken());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//check to upgrade effects if needed.
|
|
||||||
if (character.effects.containsKey(Integer.toString(effectsBase.getUUID()))) {
|
|
||||||
|
|
||||||
if (mbe.getReqLvl() > (int) character.level)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Effect eff = character.effects.get(Integer.toString(effectsBase.getUUID()));
|
|
||||||
|
|
||||||
if (eff == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
//Current effect is a higher rank, dont apply.
|
|
||||||
if (eff.getTrains() > mbe.getRank())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
//new effect is of a higher rank. remove old effect and apply new one.
|
|
||||||
eff.cancelJob();
|
|
||||||
character.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (mbe.getReqLvl() > (int) character.level)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
character.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void dismissNecroPet(Mob necroPet, boolean updateOwner) {
|
public static void dismissNecroPet(Mob necroPet, boolean updateOwner) {
|
||||||
|
|
||||||
necroPet.setCombatTarget(null);
|
necroPet.setCombatTarget(null);
|
||||||
@@ -127,10 +45,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)
|
||||||
@@ -202,78 +122,6 @@ public enum NPCManager {
|
|||||||
playerCharacter.necroPets.clear();
|
playerCharacter.necroPets.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void removeSiegeMinions(Mob mobile) {
|
|
||||||
|
|
||||||
for (Mob toRemove : mobile.siegeMinionMap.keySet()) {
|
|
||||||
|
|
||||||
if (mobile.isMoving()) {
|
|
||||||
|
|
||||||
mobile.stopMovement(mobile.getLoc());
|
|
||||||
|
|
||||||
if (toRemove.parentZone != null)
|
|
||||||
toRemove.parentZone.zoneMobSet.remove(toRemove);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
toRemove.clearEffects();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Logger.error(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (toRemove.parentZone != null)
|
|
||||||
toRemove.parentZone.zoneMobSet.remove(toRemove);
|
|
||||||
|
|
||||||
WorldGrid.RemoveWorldObject(toRemove);
|
|
||||||
WorldGrid.removeObject(toRemove);
|
|
||||||
DbManager.removeFromCache(toRemove);
|
|
||||||
|
|
||||||
PlayerCharacter petOwner = toRemove.getOwner();
|
|
||||||
|
|
||||||
if (petOwner != null) {
|
|
||||||
|
|
||||||
petOwner.setPet(null);
|
|
||||||
toRemove.setOwner(null);
|
|
||||||
|
|
||||||
PetMsg petMsg = new PetMsg(5, null);
|
|
||||||
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean removeMobileFromBuilding(Mob mobile, Building building) {
|
|
||||||
|
|
||||||
// Remove npc from it's building
|
|
||||||
|
|
||||||
try {
|
|
||||||
mobile.clearEffects();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Logger.error(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mobile.parentZone != null)
|
|
||||||
mobile.parentZone.zoneMobSet.remove(mobile);
|
|
||||||
|
|
||||||
if (building != null) {
|
|
||||||
building.getHirelings().remove(mobile);
|
|
||||||
removeSiegeMinions(mobile);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete npc from database
|
|
||||||
|
|
||||||
if (DbManager.MobQueries.DELETE_MOB(mobile) == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Remove npc from the simulation
|
|
||||||
|
|
||||||
mobile.removeFromCache();
|
|
||||||
DbManager.removeFromCache(mobile);
|
|
||||||
WorldGrid.RemoveWorldObject(mobile);
|
|
||||||
WorldGrid.removeObject(mobile);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void loadAllPirateNames() {
|
public static void loadAllPirateNames() {
|
||||||
|
|
||||||
DbManager.NPCQueries.LOAD_PIRATE_NAMES();
|
DbManager.NPCQueries.LOAD_PIRATE_NAMES();
|
||||||
@@ -340,9 +188,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.minions.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 +227,251 @@ public enum NPCManager {
|
|||||||
|
|
||||||
return buildingSlot;
|
return buildingSlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.setLoc(newPatrolPoint);
|
||||||
|
mob.endLoc = newPatrolPoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void applyGuardStanceModifiers(Mob guard){
|
||||||
|
float damageModifier = 1;
|
||||||
|
float attackRatingModifier = 1;
|
||||||
|
float defenseModifier = 1;
|
||||||
|
float attackSpeedModifier = 1;
|
||||||
|
float powerDamageModifier = 1;
|
||||||
|
//handle stance modifiers for guard mob
|
||||||
|
if(guard.agentType.equals(Enum.AIAgentType.GUARDWALLARCHER)){
|
||||||
|
//apply rogue bonuses
|
||||||
|
attackRatingModifier += 0.5f;
|
||||||
|
defenseModifier += 0.5f;
|
||||||
|
damageModifier += 0.5f;
|
||||||
|
attackSpeedModifier -= 0.36f;
|
||||||
|
}else {
|
||||||
|
Integer contractID;
|
||||||
|
if (guard.agentType.equals(Enum.AIAgentType.GUARDMINION)) {
|
||||||
|
contractID = guard.guardCaptain.contract.getContractID();
|
||||||
|
} else{
|
||||||
|
contractID = guard.contract.getContractID();
|
||||||
|
}
|
||||||
|
if (Enum.MinionType.ContractToMinionMap.get(contractID) != null && Enum.MinionType.ContractToMinionMap.get(contractID).isMage()){
|
||||||
|
//apply mage offensive Stance
|
||||||
|
powerDamageModifier += 0.5f;
|
||||||
|
} else{
|
||||||
|
//apply fighter offensive stance
|
||||||
|
damageModifier += 0.5f;
|
||||||
|
attackSpeedModifier -= 0.36f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
guard.minDamageHandOne *= damageModifier;
|
||||||
|
guard.minDamageHandTwo *= damageModifier;
|
||||||
|
guard.maxDamageHandOne *= damageModifier;
|
||||||
|
guard.maxDamageHandTwo *= damageModifier;
|
||||||
|
guard.atrHandOne *= attackRatingModifier;
|
||||||
|
guard.atrHandTwo *= attackRatingModifier;
|
||||||
|
guard.defenseRating *= defenseModifier;
|
||||||
|
guard.speedHandOne *= attackSpeedModifier;
|
||||||
|
guard.speedHandTwo *= attackSpeedModifier;
|
||||||
|
|
||||||
|
//TODO figure out how to apply +50% powerdamage to mage guards
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setDamageAndSpeedForGuard(Mob guard){
|
||||||
|
|
||||||
|
float rankModifier = 1 + (guard.getRank() * 0.1f);
|
||||||
|
int primaryStat = 0;
|
||||||
|
if(guard.equip == null) {
|
||||||
|
guard.minDamageHandOne = (int)((guard.mobBase.getDamageMin()) * rankModifier);
|
||||||
|
guard.maxDamageHandOne = (int)((guard.mobBase.getDamageMax()) * rankModifier);
|
||||||
|
guard.speedHandOne = 30.0f;
|
||||||
|
}else{
|
||||||
|
if(guard.equip.containsKey(1)){
|
||||||
|
//has main hand weapon
|
||||||
|
ItemBase weapon = guard.equip.get(1).getItemBase();
|
||||||
|
if(weapon.isStrBased())
|
||||||
|
primaryStat = guard.getStatStrCurrent();
|
||||||
|
else
|
||||||
|
primaryStat = guard.getStatDexCurrent();
|
||||||
|
guard.minDamageHandOne = (int)((guard.mobBase.getDamageMin() + weapon.getMinDamage()) * rankModifier) + primaryStat;
|
||||||
|
guard.maxDamageHandOne = (int)((guard.mobBase.getDamageMax() + weapon.getMaxDamage()) * rankModifier) + primaryStat;
|
||||||
|
guard.speedHandOne = weapon.getSpeed();
|
||||||
|
guard.rangeHandOne = weapon.getRange();
|
||||||
|
} else if(guard.equip.containsKey(2) && !guard.equip.get(2).getItemBase().isShield()){
|
||||||
|
//has off hand weapon
|
||||||
|
ItemBase weapon = guard.equip.get(2).getItemBase();
|
||||||
|
if(weapon.isStrBased())
|
||||||
|
primaryStat = guard.getStatStrCurrent();
|
||||||
|
else
|
||||||
|
primaryStat = guard.getStatDexCurrent();
|
||||||
|
guard.minDamageHandTwo = (int)((guard.mobBase.getDamageMin() + weapon.getMinDamage()) * rankModifier) + primaryStat;
|
||||||
|
guard.maxDamageHandTwo = (int)((guard.mobBase.getDamageMax() + weapon.getMaxDamage()) * rankModifier) + primaryStat;
|
||||||
|
guard.speedHandTwo = weapon.getSpeed();
|
||||||
|
guard.rangeHandTwo = weapon.getRange();
|
||||||
|
} else {
|
||||||
|
primaryStat = guard.getStatStrCurrent();
|
||||||
|
guard.minDamageHandOne = (int)((guard.mobBase.getDamageMin()) * rankModifier) + primaryStat;
|
||||||
|
guard.maxDamageHandOne = (int)((guard.mobBase.getDamageMax()) * rankModifier) + primaryStat;
|
||||||
|
guard.speedHandOne = 30.0f;
|
||||||
|
guard.rangeHandOne = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setDefenseForGuard(Mob guard){
|
||||||
|
int dexterity = guard.getStatDexCurrent();
|
||||||
|
if(dexterity < 1)
|
||||||
|
dexterity = 1;
|
||||||
|
int baseDef = guard.mobBase.getDefenseRating();
|
||||||
|
int armorDefense = 0;
|
||||||
|
for(MobEquipment equipped : guard.equip.values())
|
||||||
|
if(equipped.getItemBase().isArmor() || equipped.getItemBase().isShield())
|
||||||
|
armorDefense += equipped.getItemBase().getDefense();
|
||||||
|
guard.defenseRating = dexterity + baseDef + armorDefense;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setAttackRatingForGuard(Mob guard) {
|
||||||
|
int strength = guard.getStatStrCurrent();
|
||||||
|
int baseAtr = guard.mobBase.getAttackRating();
|
||||||
|
if (guard.equip.get(1) != null)
|
||||||
|
guard.atrHandOne = baseAtr + (int) ((strength * 0.5f) + (guard.equip.get(1).getItemBase().getPercentRequired() * 4) + (guard.equip.get(1).getItemBase().getPercentRequired() * 3));
|
||||||
|
else if (guard.equip.get(2) != null && !guard.equip.get(2).getItemBase().isShield())
|
||||||
|
guard.atrHandTwo = baseAtr + (int) ((strength * 0.5f) + (guard.equip.get(2).getItemBase().getPercentRequired() * 4) + (guard.equip.get(2).getItemBase().getPercentRequired() * 3));
|
||||||
|
else
|
||||||
|
guard.atrHandOne = baseAtr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setMaxHealthForGuard(Mob guard){
|
||||||
|
//values derived fom reading memory address for health on client when selecting player guards
|
||||||
|
switch(guard.getRank()){
|
||||||
|
default:
|
||||||
|
guard.healthMax = 750; //rank 1
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
guard.healthMax = 2082;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
guard.healthMax = 2740;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
guard.healthMax = 3414;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
guard.healthMax = 4080;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
guard.healthMax = 4746;
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
guard.healthMax = 5412;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void applyMobbaseEffects(Mob mob) {
|
||||||
|
EffectsBase effectsBase;
|
||||||
|
for (MobBaseEffects mbe : mob.mobBase.effectsList) {
|
||||||
|
|
||||||
|
effectsBase = PowersManager.getEffectByToken(mbe.getToken());
|
||||||
|
|
||||||
|
if (effectsBase == null) {
|
||||||
|
Logger.info("Mob: " + mob.getObjectUUID() + " EffectsBase Null for Token " + mbe.getToken());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//check to upgrade effects if needed.
|
||||||
|
if (mob.effects.containsKey(Integer.toString(effectsBase.getUUID()))) {
|
||||||
|
|
||||||
|
if (mbe.getReqLvl() > (int) mob.level)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Effect eff = mob.effects.get(Integer.toString(effectsBase.getUUID()));
|
||||||
|
|
||||||
|
if (eff == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//Current effect is a higher rank, dont apply.
|
||||||
|
if (eff.getTrains() > mbe.getRank())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//new effect is of a higher rank. remove old effect and apply new one.
|
||||||
|
eff.cancelJob();
|
||||||
|
mob.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (mbe.getReqLvl() > (int) mob.level)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
mob.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void applyEquipmentResists(Mob mob){
|
||||||
|
if(mob.equip != null){
|
||||||
|
for(MobEquipment equipped : mob.equip.values()){
|
||||||
|
ItemBase itemBase = equipped.getItemBase();
|
||||||
|
if(itemBase.isHeavyArmor() || itemBase.isLightArmor() || itemBase.isMediumArmor()){
|
||||||
|
mob.resists.setResist(Enum.DamageType.Crush, mob.resists.getResist(Enum.DamageType.Crush,0) + itemBase.getCrushResist());
|
||||||
|
mob.resists.setResist(Enum.DamageType.Slash, mob.resists.getResist(Enum.DamageType.Slash,0) + itemBase.getCrushResist());
|
||||||
|
mob.resists.setResist(Enum.DamageType.Pierce, mob.resists.getResist(Enum.DamageType.Pierce,0) + itemBase.getCrushResist());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void applyMobbaseSkill(Mob mob) {
|
||||||
|
SkillsBase baseSkill = DbManager.SkillsBaseQueries.GET_BASE_BY_TOKEN(mob.mobBase.getMobBaseStats().getBaseSkill());
|
||||||
|
if(baseSkill != null)
|
||||||
|
mob.getSkills().put(baseSkill.getName(),new CharacterSkill(baseSkill,mob,mob.mobBase.getMobBaseStats().getBaseSkillAmount()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void applyRuneSkills(Mob mob, int runeID){
|
||||||
|
//load mob skill adjustments from mobbase rune
|
||||||
|
if(PowersManager._allRuneSkillAdjusts.containsKey(runeID))
|
||||||
|
for(RuneSkillAdjustEntry entry : PowersManager._allRuneSkillAdjusts.get(runeID)) {
|
||||||
|
if(SkillsBase.getFromCache(entry.skill_type) == null)
|
||||||
|
SkillsBase.putInCache(DbManager.SkillsBaseQueries.GET_BASE_BY_NAME(entry.skill_type));
|
||||||
|
SkillsBase skillBase = SkillsBase.getFromCache(entry.skill_type);
|
||||||
|
if(skillBase == null)
|
||||||
|
continue;
|
||||||
|
if (entry.level <= mob.level)
|
||||||
|
if (mob.skills.containsKey(entry.name) == false)
|
||||||
|
mob.skills.put(entry.skill_type, new CharacterSkill(skillBase, mob, entry.rank));
|
||||||
|
else
|
||||||
|
mob.skills.put(entry.skill_type, new CharacterSkill(skillBase, mob, entry.rank + mob.skills.get(entry.skill_type).getNumTrains()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void applyRunesForNPC(NPC npc){
|
||||||
|
npc.runes = new ArrayList<>();
|
||||||
|
RuneBase shopkeeperBase = RuneBase.getRuneBase(252620);
|
||||||
|
CharacterRune shopkeeper = new CharacterRune(shopkeeperBase,npc.getObjectUUID());
|
||||||
|
npc.runes.add(shopkeeper);
|
||||||
|
if(NPCManager._runeSetMap.containsKey(npc.runeSetID)) {
|
||||||
|
for (int runeID : _runeSetMap.get(npc.runeSetID)) {
|
||||||
|
RuneBase rb = RuneBase.getRuneBase(runeID);
|
||||||
|
if(rb != null) {
|
||||||
|
CharacterRune toApply = new CharacterRune(rb, npc.getObjectUUID());
|
||||||
|
npc.runes.add(toApply);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -54,13 +53,10 @@ public enum PowersManager {
|
|||||||
public static HashMap<Integer, AbstractPowerAction> powerActionsByID = new HashMap<>();
|
public static HashMap<Integer, AbstractPowerAction> powerActionsByID = new HashMap<>();
|
||||||
public static HashMap<String, Integer> ActionTokenByIDString = new HashMap<>();
|
public static HashMap<String, Integer> ActionTokenByIDString = new HashMap<>();
|
||||||
public static HashMap<String, Integer> AnimationOverrides = new HashMap<>();
|
public static HashMap<String, Integer> AnimationOverrides = new HashMap<>();
|
||||||
public static HashMap<Integer, ArrayList<MobPowerEntry>> AllMobPowers;
|
public static HashMap<Integer, ArrayList<RunePowerEntry>> _allRunePowers;
|
||||||
|
public static HashMap<Integer, ArrayList<RuneSkillAdjustEntry>> _allRuneSkillAdjusts;
|
||||||
private static JobScheduler js;
|
private static JobScheduler js;
|
||||||
|
|
||||||
private PowersManager() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void initPowersManager(boolean fullPowersLoad) {
|
public static void initPowersManager(boolean fullPowersLoad) {
|
||||||
|
|
||||||
if (fullPowersLoad)
|
if (fullPowersLoad)
|
||||||
@@ -104,6 +100,16 @@ public enum PowersManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ArrayList<RunePowerEntry> getPowersForRune(int rune_id) {
|
||||||
|
|
||||||
|
ArrayList<RunePowerEntry> powerEntries = PowersManager._allRunePowers.get(rune_id);
|
||||||
|
|
||||||
|
if (powerEntries == null)
|
||||||
|
powerEntries = new ArrayList<>();
|
||||||
|
|
||||||
|
return powerEntries;
|
||||||
|
}
|
||||||
|
|
||||||
// This pre-loads all powers and effects
|
// This pre-loads all powers and effects
|
||||||
public static void InitializePowers() {
|
public static void InitializePowers() {
|
||||||
|
|
||||||
@@ -164,22 +170,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);
|
|
||||||
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
|
||||||
|
|
||||||
@@ -188,10 +178,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);
|
||||||
@@ -206,8 +199,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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,48 +212,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(
|
||||||
@@ -298,7 +248,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.");
|
||||||
@@ -310,35 +259,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;
|
||||||
|
|
||||||
@@ -346,7 +266,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) {
|
||||||
@@ -357,7 +276,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();
|
||||||
|
|
||||||
@@ -367,14 +286,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());
|
||||||
@@ -466,20 +377,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))
|
||||||
@@ -510,23 +416,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;
|
||||||
}
|
}
|
||||||
@@ -605,6 +494,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);
|
||||||
@@ -631,7 +521,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);
|
||||||
@@ -639,12 +529,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.
|
||||||
@@ -654,12 +542,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);
|
||||||
@@ -785,11 +674,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.
|
||||||
@@ -825,38 +713,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)
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -958,7 +816,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)) {
|
||||||
|
|
||||||
@@ -967,7 +824,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
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -989,8 +846,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);
|
||||||
@@ -1041,8 +896,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
|
||||||
@@ -1383,7 +1236,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,
|
||||||
@@ -1487,16 +1340,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);
|
||||||
@@ -1622,18 +1465,8 @@ public enum PowersManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create list of characters
|
// create list of characters
|
||||||
HashSet<AbstractCharacter> trackChars;
|
HashSet<AbstractCharacter> trackChars = RangeBasedAwo.getTrackList(
|
||||||
switch(msg.getPowerToken()){
|
allTargets, playerCharacter, maxTargets);
|
||||||
case 431511776:
|
|
||||||
case 429578587:
|
|
||||||
case 429503360:
|
|
||||||
case 44106356:
|
|
||||||
trackChars = getTrackList(playerCharacter);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
trackChars = RangeBasedAwo.getTrackList(allTargets, playerCharacter, maxTargets);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackWindowMsg trackWindowMsg = new TrackWindowMsg(msg);
|
TrackWindowMsg trackWindowMsg = new TrackWindowMsg(msg);
|
||||||
|
|
||||||
@@ -1646,30 +1479,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);
|
||||||
|
|
||||||
@@ -2383,7 +2192,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);
|
||||||
|
|
||||||
@@ -2435,26 +2244,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;
|
||||||
@@ -2466,13 +2277,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;
|
||||||
@@ -2520,12 +2324,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
|
||||||
@@ -2766,9 +2565,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) {
|
||||||
@@ -2914,126 +2711,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:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
package engine.gameManager;
|
package engine.gameManager;
|
||||||
|
|
||||||
import engine.Enum;
|
import engine.Enum;
|
||||||
|
import engine.InterestManagement.HeightMap;
|
||||||
import engine.db.archive.CityRecord;
|
import engine.db.archive.CityRecord;
|
||||||
import engine.db.archive.DataWarehouse;
|
import engine.db.archive.DataWarehouse;
|
||||||
import engine.math.Bounds;
|
import engine.math.Bounds;
|
||||||
@@ -19,12 +20,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 +110,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 +218,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,
|
||||||
@@ -380,4 +454,31 @@ public enum ZoneManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float caclulateWorldAltitude(Zone zone) {
|
||||||
|
|
||||||
|
float worldAlttitude = MBServerStatics.SEA_FLOOR_ALTITUDE;
|
||||||
|
|
||||||
|
// Seafloor
|
||||||
|
|
||||||
|
if (zone.getParent() == null)
|
||||||
|
return worldAlttitude;
|
||||||
|
|
||||||
|
Zone parentZone = zone.getParent();
|
||||||
|
|
||||||
|
// Children of seafloor
|
||||||
|
|
||||||
|
if (parentZone.getParent() == null)
|
||||||
|
return worldAlttitude + zone.getYCoord();
|
||||||
|
|
||||||
|
// return height from heightmap engine at zone location
|
||||||
|
|
||||||
|
worldAlttitude = HeightMap.getWorldHeight(parentZone, zone.getLoc());
|
||||||
|
|
||||||
|
// Add zone offset to value
|
||||||
|
|
||||||
|
worldAlttitude += zone.getYCoord();
|
||||||
|
|
||||||
|
return worldAlttitude;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class ActivateBaneJob extends AbstractScheduleJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doJob() {
|
protected void doJob() {
|
||||||
|
|
||||||
City city;
|
City city;
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class CSessionCleanupJob extends AbstractJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doJob() {
|
protected void doJob() {
|
||||||
SessionManager.cSessionCleanup(secKey);
|
SessionManager.cSessionCleanup(secKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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");
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class DoorCloseJob extends AbstractScheduleJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doJob() {
|
protected void doJob() {
|
||||||
|
|
||||||
int doorNumber;
|
int doorNumber;
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -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!");
|
||||||
@@ -61,8 +61,6 @@ public class FinishSummonsJob extends AbstractScheduleJob {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.source.region != null)
|
|
||||||
this.target.setRegion(this.source.region);
|
|
||||||
//teleport target to source
|
//teleport target to source
|
||||||
target.teleport(source.getLoc());
|
target.teleport(source.getLoc());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class NoTimeJob extends AbstractEffectJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doJob() {
|
protected void doJob() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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()) {
|
||||||
|
|||||||
@@ -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,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
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class UpgradeNPCJob extends AbstractScheduleJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doJob() {
|
protected void doJob() {
|
||||||
|
|
||||||
int newRank;
|
int newRank;
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
+248
-413
File diff suppressed because it is too large
Load Diff
@@ -28,28 +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);
|
||||||
}
|
|
||||||
} 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();
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user