Compare commits
480 Commits
a8cd6f4f74
...
f9c0a9c3b5
| Author | SHA1 | Date | |
|---|---|---|---|
| f9c0a9c3b5 | |||
| 71300f189d | |||
| d3fe643223 | |||
| 0cf4b5416d | |||
| a98de7b6fc | |||
| efa7e6a03a | |||
| 407fe9d583 | |||
| 36d8a6bdbd | |||
| cdd746e0df | |||
| 4e1621db99 | |||
| e5622a47c0 | |||
| 46170e3ab7 | |||
| 01533b1056 | |||
| 87e24c16d9 | |||
| 572bff8d6b | |||
| 52d37296a7 | |||
| f682f9a5ae | |||
| 2f3b9e0fb2 | |||
| cfc36c0c27 | |||
| 0e431aa726 | |||
| 25ab3747eb | |||
| 7526cc808c | |||
| 019c254ac1 | |||
| 8cd613c597 | |||
| 5f16289052 | |||
| 2768980f6e | |||
| 3a2b138deb | |||
| 3f1385dd33 | |||
| a70585448f | |||
| d4e38c113b | |||
| d7b18dc457 | |||
| 7b909e1044 | |||
| 4fd1a1a146 | |||
| 9934e60fa4 | |||
| b74105137e | |||
| 301014f06f | |||
| a37825168b | |||
| 093bc5e97e | |||
| f0ac342b1f | |||
| 8997701d8a | |||
| ce403a6bd8 | |||
| bf712accf9 | |||
| 1825035739 | |||
| 5a5fd8155c | |||
| 56bc38ab73 | |||
| 01fd6997a8 | |||
| 41f77364aa | |||
| 1acb74ade1 | |||
| 35ba4bbeec | |||
| a162377685 | |||
| 5a1806d11b | |||
| 80c11db80b | |||
| fbec206389 | |||
| 7b9d9d64bb | |||
| e86097d732 | |||
| a103e7c7cd | |||
| f653376c22 | |||
| 4bc19235a6 | |||
| 06e41d5b94 | |||
| 8083f39ba1 | |||
| 162a049f30 | |||
| 0486fa52e4 | |||
| 0e9390ef53 | |||
| f47a9772d7 | |||
| 08060cf06f | |||
| 25fed51523 | |||
| 8c39ede852 | |||
| 692c6a268c | |||
| 415ec5f5d4 | |||
| 0c1431e60d | |||
| df07c80b1b | |||
| 94253f547d | |||
| 2640927b85 | |||
| fc06ea97bd | |||
| 561b80b1aa | |||
| 230679cef9 | |||
| 8e43f17da0 | |||
| a109e9864f | |||
| 5d367a737c | |||
| 2b7cc2bdd7 | |||
| 60c80ceee8 | |||
| 1cf9831e20 | |||
| 08f0fc1743 | |||
| 2aa9f9c134 | |||
| 3ee0ec1342 | |||
| 85a179ad47 | |||
| 03e6c591ff | |||
| 03c226f76e | |||
| 59bf787581 | |||
| 61bb7be6b1 | |||
| 84c29a1222 | |||
| 02d8bf4f5c | |||
| eba8beb8f5 | |||
| 3dcffa3042 | |||
| 04991c94ba | |||
| ee8e4f8a2e | |||
| 594509e0ad | |||
| d57eb295e9 | |||
| b8a1081544 | |||
| 045b101d7b | |||
| 76ae0f4b59 | |||
| 2cfbd77e2f | |||
| 768e209b2b | |||
| eb621f184d | |||
| ebf7130b63 | |||
| a65ecfeb65 | |||
| 1b384a6d11 | |||
| cde9901bb6 | |||
| 7f452d18bc | |||
| ce7b9ff96f | |||
| 3ff9115052 | |||
| 6c78e7d9fa | |||
| 6514fd8dc3 | |||
| a741bb3482 | |||
| def5ceee46 | |||
| aff2a8fa0e | |||
| 27d869276a | |||
| 7e3a8a7a40 | |||
| c33cd9773f | |||
| 2d246a6773 | |||
| fa5980bc6a | |||
| 17f18b83f4 | |||
| 507ec302e7 | |||
| 5cfbd9998c | |||
| 68ae9c1b97 | |||
| 5397833dea | |||
| 4598709ba1 | |||
| ac92d69914 | |||
| a1f233723f | |||
| 063f3081b5 | |||
| 72ce1e0694 | |||
| 0004215605 | |||
| c0a50544d7 | |||
| a130240339 | |||
| 54cd1c59f7 | |||
| a7ed30130d | |||
| 4e2add4d64 | |||
| 6a62f93cba | |||
| f523e4832e | |||
| 28b0fd6fd4 | |||
| 0f703785f3 | |||
| ded3e16d48 | |||
| 678f5463ea | |||
| 575d21a786 | |||
| 4fa5ccf416 | |||
| eba905b15d | |||
| 14ccb1f80b | |||
| 9d140be510 | |||
| eb78716401 | |||
| 3074b77471 | |||
| 53b7aca0ce | |||
| 083349b75b | |||
| ae3423b99b | |||
| 5439df5653 | |||
| e7e32ca4ef | |||
| e971674465 | |||
| 943d274e5f | |||
| d0bb761344 | |||
| a8ba5ae62b | |||
| 97c0b0bbee | |||
| 67e0766894 | |||
| 3fc5fa71a4 | |||
| 4fc7c90c15 | |||
| e50c519eec | |||
| 57016da1d0 | |||
| 8d1c6cc082 | |||
| 2fb889272b | |||
| 4194aa09d1 | |||
| 0004bb63b0 | |||
| d7eef4c623 | |||
| 0fa042cece | |||
| 6a0599a972 | |||
| cef2a7c188 | |||
| ab2659d01f | |||
| 601ed40eb2 | |||
| 2bb414fc33 | |||
| ecc14fc3af | |||
| ea38c3bef7 | |||
| bf990a886c | |||
| 22d08b51b7 | |||
| 551361e10a | |||
| 99b9444ba8 | |||
| c390ebe0c6 | |||
| 513118d42c | |||
| b0c43a5258 | |||
| eca71fa685 | |||
| f01fb6f848 | |||
| 0f18258d1b | |||
| abc4a227a9 | |||
| 1c368003ae | |||
| ee34f9e8ec | |||
| d511eda713 | |||
| 4b20b0efe3 | |||
| 5c731894b1 | |||
| 6ff26f6a25 | |||
| b041326e23 | |||
| c8d355636b | |||
| fa0dfadc8b | |||
| 8f7208ff34 | |||
| 61c4cb1361 | |||
| 0590ae64e7 | |||
| 7fa8c3bfff | |||
| 82c4e3169e | |||
| 84f9d54ec0 | |||
| 3e71cf4b45 | |||
| 68b9651f94 | |||
| 50171e4600 | |||
| 9d7f2f39fe | |||
| a30c041a17 | |||
| 756e20633f | |||
| 12c1cde069 | |||
| 2e0ffe67fa | |||
| 0c0f0aa54d | |||
| 538e452377 | |||
| 264ce39552 | |||
| b8bd71616b | |||
| b2f3e7a635 | |||
| e38324af63 | |||
| 5db5a26037 | |||
| 9b22287ede | |||
| 98c5b0e9ec | |||
| 0b74537bee | |||
| 5f930b0482 | |||
| aa0afa533d | |||
| e06657e53f | |||
| a960e5ab04 | |||
| 4a9a496a5d | |||
| f3bfdd8a36 | |||
| b76a384e1f | |||
| 3c70a09e12 | |||
| ee9b64285e | |||
| 7848233396 | |||
| 2e05ba243f | |||
| b789c773b4 | |||
| 023fd547fd | |||
| 288c941d69 | |||
| 6b2569873c | |||
| 836c076884 | |||
| e4b0823911 | |||
| 3fdafe176b | |||
| c54b0470fa | |||
| ac2403362e | |||
| 13bf6e6f5a | |||
| 131592090f | |||
| 412fec17a6 | |||
| 995949c1ba | |||
| fce3fa8004 | |||
| bb0803bf19 | |||
| c091026114 | |||
| c90461afe0 | |||
| d9032f750f | |||
| 55058b4ce1 | |||
| 5ff19e58a5 | |||
| e831f447ae | |||
| dd8699ad32 | |||
| 109ddde0a8 | |||
| f78baf229d | |||
| 22f498a6f8 | |||
| ebaf68bca4 | |||
| 8b98a3f2a1 | |||
| d9549c227a | |||
| c5c4c62208 | |||
| 2ceaece7d9 | |||
| b9b04c2b9f | |||
| 789e177d67 | |||
| 3168f12af1 | |||
| e93f84d1c7 | |||
| e323c80fba | |||
| 57122e5b74 | |||
| a1dbb42b4d | |||
| a489aecb86 | |||
| 6ed4faded2 | |||
| f676b14351 | |||
| 97fa583f65 | |||
| 92f53b00b8 | |||
| f2d28fd7af | |||
| 4646d03bdd | |||
| b6eb587a82 | |||
| 9dd2a79be8 | |||
| 2e37bd2472 | |||
| f9797a38b8 | |||
| 20a42ab3e5 | |||
| a7062eff3a | |||
| 6806ae3dc0 | |||
| b665d46dc3 | |||
| 0b68ae3960 | |||
| ef38e93c11 | |||
| 4f7c34aec9 | |||
| 7595f7dfb5 | |||
| 96b4e1c639 | |||
| efab8eefba | |||
| b0f8c758e5 | |||
| 6ee194924c | |||
| 784767dc4e | |||
| 15d2f2b9d8 | |||
| 56b89b7080 | |||
| 32d9322189 | |||
| ca8c4338b2 | |||
| 6a4a550f63 | |||
| 24d5fb2259 | |||
| f3d4a2becc | |||
| e1018a48f0 | |||
| 50d75eecc6 | |||
| 406c864b17 | |||
| f616937236 | |||
| e47bd6fba0 | |||
| 7f830a18cd | |||
| 7bf5279ad3 | |||
| df5c607375 | |||
| 87290baa52 | |||
| 8bf47fb4fe | |||
| b20de1657c | |||
| a5af5d9ec8 | |||
| b3bffed179 | |||
| f349e0dda8 | |||
| 76d723669a | |||
| 5537934f88 | |||
| e2aa7b54a4 | |||
| 6f028ab8c8 | |||
| 658b442b36 | |||
| f6fbc6fecb | |||
| c6f451bce1 | |||
| 3500bf0ede | |||
| 04d9b76938 | |||
| 68088a3399 | |||
| 20cb8ef94d | |||
| caf708bed6 | |||
| 75691aaab9 | |||
| 83e8a8a218 | |||
| a9dc7b1c5b | |||
| d8d017669a | |||
| 7d1d8891ff | |||
| ffdf374cd6 | |||
| 54b7fc2212 | |||
| 5476d238fa | |||
| 8e85136dc5 | |||
| 82daff3b6e | |||
| 642270aacf | |||
| 3048f86f5b | |||
| 84e74c5052 | |||
| 4dc0f52295 | |||
| 58652ee32f | |||
| 1a4d888304 | |||
| f11fcc535a | |||
| 70f331d025 | |||
| 8a1cd316fe | |||
| d7dfab5e74 | |||
| 436d0cec9b | |||
| 266e4214d4 | |||
| 08aa431f5d | |||
| b98e7cda15 | |||
| d05dbef71d | |||
| 5736f0a7a3 | |||
| ec90ef6174 | |||
| fa440e2885 | |||
| 9ea44d7e1c | |||
| 22326802b3 | |||
| 531662e012 | |||
| 8eaaabb4d4 | |||
| 37af60781d | |||
| 29c68110cf | |||
| 1306ea3c5c | |||
| 527acb8e52 | |||
| 744b508fea | |||
| ea97eb56a6 | |||
| 8d91f200e7 | |||
| d9775dbf4e | |||
| 507769c6b6 | |||
| aae9e38f36 | |||
| 2cd3d028a9 | |||
| c5bb051e64 | |||
| 6a33651782 | |||
| 1d2e4bbda7 | |||
| f1a8f6024d | |||
| 0829a60f35 | |||
| f39434a248 | |||
| 808a60c86c | |||
| 22da19085d | |||
| 5304919e2a | |||
| 093fe0f261 | |||
| ab32ad1538 | |||
| 0a39102b08 | |||
| 91247c58a6 | |||
| bcf4aef5a0 | |||
| ffd248cfd4 | |||
| 2d3b74e688 | |||
| db94673256 | |||
| 4d118cf634 | |||
| e464f30445 | |||
| 67e4011c65 | |||
| 839be1f28f | |||
| 8ae4a67635 | |||
| e228ff8715 | |||
| c4a4a8659a | |||
| b26134ec72 | |||
| 8656d6bfb9 | |||
| 2ffd354f38 | |||
| 441b2fe42a | |||
| 2885457ea6 | |||
| 1763266972 | |||
| 2e5fa69942 | |||
| e1e9bc026a | |||
| 74d5ab7fea | |||
| e8e84e00af | |||
| a7b3fba018 | |||
| 5cdf1d5599 | |||
| e6dd2b22d8 | |||
| df6c3addcf | |||
| e9d5c3db0e | |||
| 36f12f9c97 | |||
| 55213c409b | |||
| d9474afa34 | |||
| 9c8b690739 | |||
| d20a2129aa | |||
| 704375099b | |||
| bf9ac7accb | |||
| b2cf15139a | |||
| 4352e95f82 | |||
| fb7a98761f | |||
| 5d0f79892c | |||
| d3f9b53810 | |||
| 7632dc783a | |||
| 61f28a588b | |||
| e448c9a0d3 | |||
| 155bbfbf4e | |||
| cf0b9a0ae0 | |||
| 2b65e23b48 | |||
| d363a9fc1b | |||
| a99b0072e0 | |||
| f940d05d12 | |||
| 8d80e0a46e | |||
| 37fec69462 | |||
| 09a196149e | |||
| bb8e8780bd | |||
| bade2162a6 | |||
| 4e2578f3e0 | |||
| 62e13ade01 | |||
| acea3875a1 | |||
| 354f10ddee | |||
| 5e6d298ca0 | |||
| 9019b0ad29 | |||
| b2112f2b01 | |||
| 9e652761b8 | |||
| fe54085cc6 | |||
| ef05e5c524 | |||
| d11c6988cc | |||
| 39de8439ba | |||
| 15635534b0 | |||
| 5b547611a5 | |||
| 11e6b793d5 | |||
| b9507381ed | |||
| 3bd50a1ad1 | |||
| e6452955b6 | |||
| 14397d1550 | |||
| 8267cbd8f0 | |||
| 1ff2dc6733 | |||
| 04d88d0523 | |||
| 5e8b4e0e61 | |||
| 151230c611 | |||
| 52750e6d6b | |||
| 8ff112b802 | |||
| 88516d2857 | |||
| 9bf7c088cf | |||
| b0542a5bc3 | |||
| ac06e7723f | |||
| 12608d8d32 | |||
| 8018f1323d | |||
| 90874b01a7 | |||
| 6685fc9b02 | |||
| ad52546e0c | |||
| 2518b1421c | |||
| 551418c293 | |||
| 524ebbbdd7 | |||
| 40d0e765fe | |||
| 53b2f476e2 | |||
| d6a952f182 | |||
| 4eff5ad84e | |||
| 0d93850813 | |||
| 129eb1b818 | |||
| 0d8b8504b4 |
+233
-403
@@ -14,10 +14,7 @@ import engine.gameManager.PowersManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.AbstractCharacter;
|
||||
import engine.objects.ItemBase;
|
||||
import engine.objects.Shrine;
|
||||
import engine.objects.Zone;
|
||||
import engine.objects.*;
|
||||
import engine.powers.EffectsBase;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
@@ -156,12 +153,11 @@ public class Enum {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static final HashMap<Integer, RaceType> _raceTypeByID = new HashMap<>();
|
||||
|
||||
int runeID;
|
||||
private final MonsterType monsterType;
|
||||
private final CharacterSex characterSex;
|
||||
private final RunSpeed runSpeed;
|
||||
private final float scaleHeight;
|
||||
int runeID;
|
||||
|
||||
RaceType(int runeID, MonsterType aggroType, RunSpeed runspeed, CharacterSex characterSex, float scaleHeight) {
|
||||
this.runeID = runeID;
|
||||
@@ -561,70 +557,47 @@ public class Enum {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Enum for ItemBase flags
|
||||
// Enum for Item type flags
|
||||
|
||||
public enum ItemType {
|
||||
DECORATION(0),
|
||||
WEAPON(1),
|
||||
ARMOR(2),
|
||||
HAIR(3),
|
||||
GOLD(4),
|
||||
RUNE(5),
|
||||
SCROLL(5),
|
||||
BOOK(6),
|
||||
COMMANDROD(7),
|
||||
POTION(8),
|
||||
TEARS(8),
|
||||
KEY(9),
|
||||
GUILDCHARTER(10),
|
||||
JEWELRY(13),
|
||||
WINE(16),
|
||||
ALEJUG(17),
|
||||
DEED(19),
|
||||
CONTRACT(20),
|
||||
PET(21),
|
||||
FURNITURE(25),
|
||||
BEDROLL(26),
|
||||
FARMABLE(27),
|
||||
WATERBUCKET(30),
|
||||
GIFT(31),
|
||||
OFFERING(33),
|
||||
RESOURCE(34),
|
||||
REALMCHARTER(35);
|
||||
|
||||
private final static HashMap<Integer, ItemType> _typeLookup = new HashMap<>();
|
||||
private final int _value;
|
||||
|
||||
ItemType(int value) {
|
||||
this._value = value;
|
||||
}
|
||||
|
||||
public static ItemType getByValue(int value) {
|
||||
|
||||
ItemType outType = ItemType.DECORATION;
|
||||
|
||||
if (_typeLookup.isEmpty()) {
|
||||
|
||||
for (ItemType itemType : ItemType.values()) {
|
||||
_typeLookup.put(itemType._value, itemType);
|
||||
}
|
||||
}
|
||||
|
||||
if (_typeLookup.containsKey(value))
|
||||
outType = _typeLookup.get(value);
|
||||
|
||||
return outType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _value
|
||||
*/
|
||||
public int getValue() {
|
||||
return _value;
|
||||
}
|
||||
|
||||
DECORATION,
|
||||
WEAPON,
|
||||
ARMOR,
|
||||
BASE,
|
||||
GOLD,
|
||||
SCROLL,
|
||||
BOOK,
|
||||
WAND,
|
||||
POTION,
|
||||
KEY,
|
||||
CHARTER,
|
||||
GUILDTREE,
|
||||
SOUNDSOURCE,
|
||||
JEWELRY,
|
||||
CONTAINER,
|
||||
FOUNTAIN,
|
||||
FOOD,
|
||||
DRINKCONTAINER,
|
||||
MAPMARKER,
|
||||
DEED,
|
||||
EMPLOYMENTCONTRACT,
|
||||
PETTOTEM,
|
||||
SLAVECOLLAR,
|
||||
BLANKKEY,
|
||||
WARRANT,
|
||||
FURNITUREDEED,
|
||||
TENT,
|
||||
REAGENT,
|
||||
DEVICE,
|
||||
FORMULA,
|
||||
BUCKET,
|
||||
TREASURE,
|
||||
RUNE,
|
||||
OFFERING,
|
||||
RESOURCE,
|
||||
REALMCHARTER;
|
||||
}
|
||||
|
||||
// Enum to derive effects for active spires from blueprintUUID
|
||||
|
||||
public enum SpireType {
|
||||
@@ -751,178 +724,118 @@ public class Enum {
|
||||
}
|
||||
}
|
||||
|
||||
public enum DamageType {
|
||||
None,
|
||||
Crush,
|
||||
Slash,
|
||||
Siege,
|
||||
Pierce,
|
||||
Magic,
|
||||
Bleed,
|
||||
Poison,
|
||||
Mental,
|
||||
Holy,
|
||||
Unholy,
|
||||
Lightning,
|
||||
Fire,
|
||||
Cold,
|
||||
Healing,
|
||||
Acid,
|
||||
Disease,
|
||||
Unknown,
|
||||
// these added for immunities
|
||||
Attack,
|
||||
Powers,
|
||||
Combat,
|
||||
Spires,
|
||||
Snare,
|
||||
Stun,
|
||||
Blind,
|
||||
Root,
|
||||
Fear,
|
||||
Charm,
|
||||
PowerBlock,
|
||||
DeBuff,
|
||||
Powerblock,
|
||||
Steel,
|
||||
Drain;
|
||||
|
||||
public static DamageType GetDamageType(String modName) {
|
||||
DamageType damageType;
|
||||
if (modName.isEmpty())
|
||||
return DamageType.None;
|
||||
|
||||
try {
|
||||
damageType = DamageType.valueOf(modName.replace(",", ""));
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
return DamageType.None;
|
||||
}
|
||||
return damageType;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public enum SourceType {
|
||||
None,
|
||||
Abjuration,
|
||||
Acid,
|
||||
AntiSiege,
|
||||
Archery,
|
||||
Axe,
|
||||
Bardsong,
|
||||
Beastcraft,
|
||||
Benediction,
|
||||
BladeWeaving,
|
||||
Bleed,
|
||||
Blind,
|
||||
Block,
|
||||
Bloodcraft,
|
||||
Bow,
|
||||
Buff,
|
||||
Channeling,
|
||||
Charm,
|
||||
Cold,
|
||||
NONE,
|
||||
ABJURATION,
|
||||
ACID,
|
||||
ANTISIEGE,
|
||||
ARCHERY,
|
||||
AXE,
|
||||
BARDSONG,
|
||||
BEASTCRAFT,
|
||||
BENEDICTION,
|
||||
BLADEWEAVING,
|
||||
BLEEDING,
|
||||
BLIND,
|
||||
BLOCK,
|
||||
BLOODCRAFT,
|
||||
BOW,
|
||||
BUFF,
|
||||
CHANNELING,
|
||||
CHARM,
|
||||
COLD,
|
||||
Constitution,
|
||||
Corruption,
|
||||
Crossbow,
|
||||
Crush,
|
||||
Dagger,
|
||||
DaggerMastery,
|
||||
DeBuff,
|
||||
Dexterity,
|
||||
Disease,
|
||||
Dodge,
|
||||
Dragon,
|
||||
Drain,
|
||||
Earth,
|
||||
Effect,
|
||||
Exorcism,
|
||||
Fear,
|
||||
Fire,
|
||||
CONSTITUTION,
|
||||
CORRUPTION,
|
||||
CROSSBOW,
|
||||
CRUSHING,
|
||||
DAGGER,
|
||||
DAGGERMASTERY,
|
||||
DEBUFF,
|
||||
DEXTERITY,
|
||||
DISEASE,
|
||||
DODGE,
|
||||
DRAGON,
|
||||
DRAIN,
|
||||
EARTH,
|
||||
EFFECT,
|
||||
EXORCISM,
|
||||
FEAR,
|
||||
FIRE,
|
||||
Fly,
|
||||
Giant,
|
||||
GreatAxeMastery,
|
||||
GreatSwordMastery,
|
||||
Hammer,
|
||||
Heal,
|
||||
Healing,
|
||||
Holy,
|
||||
FLY,
|
||||
GIANT,
|
||||
GREATAXEMASTERY,
|
||||
GREATSWORDMASTERY,
|
||||
HAMMER,
|
||||
HEALING,
|
||||
HOLY,
|
||||
ImmuneToAttack,
|
||||
ImmuneToPowers,
|
||||
Intelligence,
|
||||
Invisible,
|
||||
Lightning,
|
||||
IMMUNETOATTACK,
|
||||
IMMUNETOPOWERS,
|
||||
INTELLIGENCE,
|
||||
INVISIBLE,
|
||||
LIGHTNING,
|
||||
Liturgy,
|
||||
Magic,
|
||||
LITURGY,
|
||||
MAGIC,
|
||||
Mental,
|
||||
MENTAL,
|
||||
NatureLore,
|
||||
Necromancy,
|
||||
Parry,
|
||||
Pierce,
|
||||
Poison,
|
||||
NATURELORE,
|
||||
NECROMANCY,
|
||||
PARRY,
|
||||
PIERCING,
|
||||
POISON,
|
||||
PoleArm,
|
||||
Powerblock,
|
||||
Rat,
|
||||
ResistDeBuff,
|
||||
Restoration,
|
||||
Root,
|
||||
Shadowmastery,
|
||||
Siege,
|
||||
Slash,
|
||||
Snare,
|
||||
Sorcery,
|
||||
Spear,
|
||||
SpearMastery,
|
||||
Spirit,
|
||||
Staff,
|
||||
Stormcalling,
|
||||
Strength,
|
||||
Stun,
|
||||
Summon,
|
||||
Sword,
|
||||
SwordMastery,
|
||||
Thaumaturgy,
|
||||
Theurgy,
|
||||
Transform,
|
||||
UnarmedCombat,
|
||||
UnarmedCombatMastery,
|
||||
Unholy,
|
||||
POLEARM,
|
||||
POWERBLOCK,
|
||||
RAT,
|
||||
RESISTDEBUFF,
|
||||
RESTORATION,
|
||||
ROOT,
|
||||
SHADOWMASTERY,
|
||||
SIEGE,
|
||||
SLASHING,
|
||||
SNARE,
|
||||
SORCERY,
|
||||
SPEAR,
|
||||
SPEARMASTERY,
|
||||
SPIRIT,
|
||||
STAFF,
|
||||
STEAL,
|
||||
STORMCALLING,
|
||||
STRENGTH,
|
||||
STUN,
|
||||
SUMMON,
|
||||
SWORD,
|
||||
SWORDMASTERY,
|
||||
THAUMATURGY,
|
||||
THEURGY,
|
||||
TRANSFORM,
|
||||
UNARMEDCOMBAT,
|
||||
UNARMEDCOMBATMASTERY,
|
||||
UNHOLY,
|
||||
Unknown,
|
||||
Warding,
|
||||
Warlockry,
|
||||
WayoftheGaana,
|
||||
WearArmorHeavy,
|
||||
WearArmorLight,
|
||||
WearArmorMedium,
|
||||
Wereform,
|
||||
Athletics,
|
||||
AxeMastery,
|
||||
Bargaining,
|
||||
BladeMastery,
|
||||
FlameCalling,
|
||||
GreatHammerMastery,
|
||||
HammerMastery,
|
||||
Leadership,
|
||||
PoleArmMastery,
|
||||
Running,
|
||||
StaffMastery,
|
||||
Throwing,
|
||||
Toughness,
|
||||
WayoftheWolf,
|
||||
WayoftheRat,
|
||||
WayoftheBear,
|
||||
Orthanatos,
|
||||
SunDancing,
|
||||
//Power categories.
|
||||
UNKNOWN,
|
||||
WARDING,
|
||||
WARLOCKRY,
|
||||
WAYOFTHEGAANA,
|
||||
WEARARMORHEAVY,
|
||||
WEARARMORLIGHT,
|
||||
WEARARMORMEDIUM,
|
||||
WEREFORM,
|
||||
ATHLETICS,
|
||||
AXEMASTERY,
|
||||
BARGAINING,
|
||||
BLADEMASTERY,
|
||||
FLAMECALLING,
|
||||
GREATHAMMERMASTERY,
|
||||
HAMMERMASTERY,
|
||||
LEADERSHIP,
|
||||
POLEARMMASTERY,
|
||||
RUNNING,
|
||||
STAFFMASTERY,
|
||||
THROWING,
|
||||
TOUGHNESS,
|
||||
WAYOFTHEWOLF,
|
||||
WAYOFTHERAT,
|
||||
WAYOFTHEBEAR,
|
||||
ORTHANATOS,
|
||||
SUNDANCING,
|
||||
//POWER CATEGORIES.
|
||||
AE,
|
||||
AEDAMAGE,
|
||||
BEHAVIOR,
|
||||
@@ -930,10 +843,8 @@ public class Enum {
|
||||
BOONCLASS,
|
||||
BOONRACE,
|
||||
BREAKFLY,
|
||||
BUFF,
|
||||
CHANT,
|
||||
DAMAGE,
|
||||
DEBUFF,
|
||||
DISPEL,
|
||||
FLIGHT,
|
||||
GROUPBUFF,
|
||||
@@ -946,27 +857,24 @@ public class Enum {
|
||||
SPIREDISABLE,
|
||||
SPIREPROOFTELEPORT,
|
||||
STANCE,
|
||||
STUN,
|
||||
SUMMON,
|
||||
TELEPORT,
|
||||
THIEF,
|
||||
TRACK,
|
||||
TRANSFORM,
|
||||
VAMPDRAIN,
|
||||
WEAPON,
|
||||
Wizardry;
|
||||
WIZARDRY;
|
||||
|
||||
public static SourceType GetSourceType(String modName) {
|
||||
SourceType returnMod;
|
||||
if (modName.isEmpty())
|
||||
return SourceType.None;
|
||||
return SourceType.NONE;
|
||||
|
||||
try {
|
||||
returnMod = SourceType.valueOf(modName.replace(",", ""));
|
||||
returnMod = SourceType.valueOf(modName.replace(",", "").toUpperCase());
|
||||
} catch (Exception e) {
|
||||
Logger.error(modName);
|
||||
Logger.error(e);
|
||||
return SourceType.None;
|
||||
return SourceType.NONE;
|
||||
}
|
||||
return returnMod;
|
||||
}
|
||||
@@ -1365,113 +1273,6 @@ public class Enum {
|
||||
Sanctifier,
|
||||
}
|
||||
|
||||
public enum CharacterSkills {
|
||||
|
||||
Archery((1L << 1), -529201545, 20),
|
||||
Athletics((1L << 2), -327713877, 15),
|
||||
AxeMastery((1L << 3), 1103042709, 20),
|
||||
Axe((1L << 4), 73505, 1),
|
||||
Bardsong((1L << 5), 454246953, 10),
|
||||
Bargaining((1L << 6), 372927577, 10),
|
||||
Beastcraft((1L << 7), 56772766, 10),
|
||||
Benediction((1L << 8), 1464998706, 1),
|
||||
BladeMastery((1L << 9), -59908956, 20),
|
||||
BladeWeaving((1L << 10), -1839362429, 20),
|
||||
Block((1L << 11), 76592546, 3),
|
||||
Bow((1L << 12), 87490, 1),
|
||||
Channeling((1L << 13), -1899060872, 20),
|
||||
Crossbow((1L << 14), 1092138184, 1),
|
||||
DaggerMastery((1L << 15), -1549224741, 20),
|
||||
Dagger((1L << 16), -1603103740, 1),
|
||||
Dodge((1L << 17), 74619332, 5),
|
||||
FlameCalling((1L << 18), -1839578206, 20),
|
||||
GreatAxeMastery((1L << 19), 1427003458, 20),
|
||||
GreatHammerMastery((1L << 20), -309659310, 20),
|
||||
GreatSwordMastery((1L << 21), 2054956946, 20),
|
||||
HammerMastery((1L << 22), -1548903209, 20),
|
||||
Hammer((1L << 23), -1602765816, 1),
|
||||
Leadership((1L << 24), 1618560984, 20),
|
||||
Liturgy((1L << 25), -888415974, 10),
|
||||
NatureLore((1L << 26), -1911171474, 10),
|
||||
Parry((1L << 27), 95961104, 5),
|
||||
PoleArmMastery((1L << 28), -1432303709, 20),
|
||||
PoleArm((1L << 29), -1037845588, 1),
|
||||
Restoration((1L << 30), -504697054, 1),
|
||||
Running((1L << 31), 1488335491, 10),
|
||||
Shadowmastery((1L << 32), 1389222957, 10),
|
||||
Sorcery((1L << 33), -529481275, 1),
|
||||
SpearMastery((1L << 34), -48279755, 20),
|
||||
Spear((1L << 35), 83992115, 1),
|
||||
StaffMastery((1L << 36), -61022283, 20),
|
||||
Staff((1L << 37), 71438003, 1),
|
||||
Stormcalling((1L << 38), -532064061, 10),
|
||||
SwordMastery((1L << 39), -59316267, 20),
|
||||
Sword((1L << 40), 73938643, 1),
|
||||
Thaumaturgy((1L << 41), -2020131447, 10),
|
||||
Theurgy((1L << 42), -888431326, 10),
|
||||
Throwing((1L << 43), 391562015, 20),
|
||||
Toughness((1L << 44), -660435875, 10),
|
||||
UnarmedCombatMastery((1L << 45), 1692733771, 20),
|
||||
UnarmedCombat((1L << 46), -1094332856, 1),
|
||||
Warding((1L << 47), 1488142342, 1),
|
||||
Warlockry((1L << 48), 1121393557, 10),
|
||||
WayoftheGaana((1L << 49), -1954832975, 10),
|
||||
WearArmorHeavy((1L << 50), 1112121635, 15),
|
||||
WearArmorLight((1L << 51), 38031547, 1),
|
||||
WearArmorMedium((1L << 52), 468015203, 5),
|
||||
Wizardry((1L << 53), 218227659, 10),
|
||||
Corruption((1L << 54), -1519268706, 10),
|
||||
Abjuration((1L << 55), -2029900484, 10),
|
||||
WayoftheWolf((1L << 56), 1668913067, 20),
|
||||
WayoftheRat((1L << 57), -2114353637, 20),
|
||||
WayoftheBear((1L << 58), -906390863, 20),
|
||||
Orthanatos((1L << 59), -666929185, 20),
|
||||
Bloodcraft((1L << 60), 40661438, 10),
|
||||
Exorcism((1L << 61), 1444427097, 10),
|
||||
Necromancy((1L << 62), -556571154, 10),
|
||||
SunDancing((1L << 63), 22329752, 20);
|
||||
|
||||
private long flag;
|
||||
private int token;
|
||||
private final int reqLvl;
|
||||
|
||||
CharacterSkills(long flag, int token, int reqLvl) {
|
||||
this.flag = flag;
|
||||
this.token = token;
|
||||
this.reqLvl = reqLvl;
|
||||
}
|
||||
|
||||
public static CharacterSkills GetCharacterSkillByToken(int token) {
|
||||
for (CharacterSkills skill : CharacterSkills.values()) {
|
||||
if (skill.token == token)
|
||||
return skill;
|
||||
}
|
||||
|
||||
Logger.info("Returned No Skill for token " + token + ". Defaulting to Axe");
|
||||
return CharacterSkills.Axe;
|
||||
}
|
||||
|
||||
public long getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void setFlag(long flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public int getReqLvl() {
|
||||
return this.reqLvl;
|
||||
}
|
||||
|
||||
public int getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(int token) {
|
||||
this.token = token;
|
||||
}
|
||||
}
|
||||
|
||||
public enum GuildHistoryType {
|
||||
JOIN(1),
|
||||
LEAVE(4),
|
||||
@@ -1847,7 +1648,6 @@ public class Enum {
|
||||
Mine,
|
||||
Mob,
|
||||
MobBase,
|
||||
MobEquipment,
|
||||
MobLoot,
|
||||
MobType,
|
||||
NPC,
|
||||
@@ -2294,29 +2094,6 @@ public class Enum {
|
||||
ITEM
|
||||
}
|
||||
|
||||
public enum objectMaskType {
|
||||
PLAYER,
|
||||
MOB,
|
||||
PET,
|
||||
CORPSE,
|
||||
BUILDING,
|
||||
UNDEAD,
|
||||
BEAST,
|
||||
HUMANOID,
|
||||
NPC,
|
||||
IAGENT,
|
||||
DRAGON,
|
||||
RAT,
|
||||
SIEGE,
|
||||
CITY,
|
||||
ZONE;
|
||||
|
||||
public static EnumSet<objectMaskType> AGGRO = EnumSet.of(PLAYER, PET);
|
||||
public static EnumSet<objectMaskType> MOBILE = EnumSet.of(PLAYER, MOB, PET);
|
||||
public static EnumSet<objectMaskType> STATIC = EnumSet.of(CORPSE, BUILDING, NPC);
|
||||
|
||||
}
|
||||
|
||||
public enum ItemContainerType {
|
||||
NONE,
|
||||
INVENTORY,
|
||||
@@ -2327,7 +2104,8 @@ public class Enum {
|
||||
WAREHOUSE
|
||||
}
|
||||
|
||||
public enum ItemSlotType implements EnumBitSetHelper<ItemSlotType> {
|
||||
public enum EquipSlotType {
|
||||
NONE,
|
||||
RHELD,
|
||||
LHELD,
|
||||
HELM,
|
||||
@@ -2664,16 +2442,16 @@ public class Enum {
|
||||
this.sexRequired = sexRequired;
|
||||
}
|
||||
|
||||
public static GuildCharterType getGuildTypeFromCharter(ItemBase itemBase) {
|
||||
public static GuildCharterType getGuildTypeFromCharter(Item charter) {
|
||||
|
||||
GuildCharterType charterType;
|
||||
|
||||
// Must be a valid charter object
|
||||
|
||||
if (itemBase.getType().equals(ItemType.GUILDCHARTER) == false)
|
||||
if (charter.template.item_type.equals(ItemType.CHARTER) == false)
|
||||
return GuildCharterType.NONE; //No guild Type
|
||||
|
||||
switch (itemBase.getUUID()) {
|
||||
switch (charter.template.template_id) {
|
||||
|
||||
case 559:
|
||||
charterType = GuildCharterType.CATHEDRAL;
|
||||
@@ -2767,7 +2545,7 @@ public class Enum {
|
||||
return leadershipTypes[i];
|
||||
}
|
||||
|
||||
public boolean canJoin(AbstractCharacter character){
|
||||
public boolean canJoin(AbstractCharacter character) {
|
||||
return this.requiredRaces.contains(character.absRace) && this.requiredClasses.contains(character.absPromotionClass) && this.sexRequired.contains(character.absGender);
|
||||
}
|
||||
}
|
||||
@@ -2881,41 +2659,54 @@ public class Enum {
|
||||
|
||||
public enum ResourceType implements EnumBitSetHelper<ResourceType> {
|
||||
|
||||
STONE(1580000),
|
||||
TRUESTEEL(1580001),
|
||||
IRON(1580002),
|
||||
ADAMANT(1580003),
|
||||
LUMBER(1580004),
|
||||
OAK(1580005),
|
||||
BRONZEWOOD(1580006),
|
||||
MANDRAKE(1580007),
|
||||
COAL(1580008),
|
||||
AGATE(1580009),
|
||||
DIAMOND(1580010),
|
||||
ONYX(1580011),
|
||||
AZOTH(1580012),
|
||||
ORICHALK(1580013),
|
||||
ANTIMONY(1580014),
|
||||
SULFUR(1580015),
|
||||
QUICKSILVER(1580016),
|
||||
GALVOR(1580017),
|
||||
WORMWOOD(1580018),
|
||||
OBSIDIAN(1580019),
|
||||
BLOODSTONE(1580020),
|
||||
MITHRIL(1580021),
|
||||
GOLD(7);
|
||||
GOLD(7, 2308551, 100000000, 10),
|
||||
ADAMANT(1580003, -1741189964, 1000, 10),
|
||||
AGATE(1580009, 75173057, 2000, 10),
|
||||
ANTIMONY(1580014, 452320058, 1000, 10),
|
||||
AZOTH(1580012, 78329697, 2000, 10),
|
||||
BLOODSTONE(1580020, -1569826353, 500, 10),
|
||||
BRONZEWOOD(1580006, 1334770447, 500, 10),
|
||||
COAL(1580008, 2559427, 3000, 10),
|
||||
DIAMOND(1580010, -1730704107, 2000, 10),
|
||||
GALVOR(1580017, -1596311545, 2000, 10),
|
||||
IRON(1580002, 2504297, 2000, 10),
|
||||
LUMBER(1580004, -1603256692, 10000, 10),
|
||||
MANDRAKE(1580007, 1191391799, 1000, 10),
|
||||
MITHRIL(1580021, -1761257186, 500, 10),
|
||||
OAK(1580005, 74767, 3000, 10),
|
||||
OBSIDIAN(1580019, -697973233, 500, 10),
|
||||
ONYX(1580011, 2977263, 1000, 10),
|
||||
ORICHALK(1580013, -2036290524, 3000, 10),
|
||||
QUICKSILVER(1580016, -472884509, 1000, 10),
|
||||
STONE(1580000, 74856115, 10000, 10),
|
||||
SULFUR(1580015, -1586349421, 1000, 10),
|
||||
TRUESTEEL(1580001, -317484979, 2000, 10),
|
||||
WORMWOOD(1580018, 1532478436, 500, 10);
|
||||
|
||||
public static HashMap<Integer, ResourceType> resourceLookup = new HashMap<>();
|
||||
public int itemID;
|
||||
public static HashMap<Integer, ResourceType> hashLookup = new HashMap<>();
|
||||
public int templateID;
|
||||
public ItemTemplate template;
|
||||
public int hash;
|
||||
public int deposit_limit;
|
||||
public int mine_production;
|
||||
|
||||
ResourceType(int itemID) {
|
||||
this.itemID = itemID;
|
||||
ResourceType(int templateID, int hash, int deposit_limit, int mine_production) {
|
||||
this.templateID = templateID;
|
||||
this.template = ItemTemplate.templates.get(this.templateID);
|
||||
this.hash = hash;
|
||||
this.deposit_limit = deposit_limit;
|
||||
this.mine_production = mine_production;
|
||||
}
|
||||
|
||||
public static void InitializeResourceTypes() {
|
||||
|
||||
for (ResourceType resourceType : ResourceType.values())
|
||||
resourceLookup.put(resourceType.itemID, resourceType);
|
||||
for (ResourceType resourceType : ResourceType.values()) {
|
||||
resourceLookup.put(resourceType.templateID, resourceType);
|
||||
hashLookup.put(resourceType.hash, resourceType);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3022,4 +2813,43 @@ public class Enum {
|
||||
CHARMED,
|
||||
SIEGEENGINE
|
||||
}
|
||||
|
||||
public enum ItemFlags {
|
||||
Indestructible,
|
||||
Identified,
|
||||
NoBond,
|
||||
NoQuit,
|
||||
Magic,
|
||||
NoDrop,
|
||||
Rare;
|
||||
}
|
||||
|
||||
public enum ItemUseFlags {
|
||||
USE_SELF,
|
||||
USE_TARGET,
|
||||
EMPTY_DESTROY,
|
||||
EMPTY_NEWITEM;
|
||||
}
|
||||
|
||||
public enum AttributeType {
|
||||
None,
|
||||
Strength,
|
||||
Dexterity,
|
||||
Constitution,
|
||||
Intelligence,
|
||||
Spirit,
|
||||
}
|
||||
|
||||
public enum PassiveType {
|
||||
None(0),
|
||||
Dodge(20),
|
||||
Block(21),
|
||||
Parry(22);
|
||||
|
||||
public int value;
|
||||
|
||||
PassiveType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.db.handlers;
|
||||
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.objects.Boon;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class dbBoonHandler extends dbHandlerBase {
|
||||
|
||||
public dbBoonHandler() {
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<Boon> GET_BOON_AMOUNTS_FOR_ITEMBASE(int itemBaseUUID) {
|
||||
|
||||
ArrayList<Boon> boons = new ArrayList<>();
|
||||
Boon thisBoon;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_boons` WHERE `itemBaseID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, itemBaseUUID);
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
thisBoon = new Boon(rs);
|
||||
boons.add(thisBoon);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
return boons;
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@ package engine.db.handlers;
|
||||
import engine.Enum;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.objects.Contract;
|
||||
import engine.objects.ItemBase;
|
||||
import engine.objects.MobEquipment;
|
||||
import engine.objects.Item;
|
||||
import engine.objects.MobLoot;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -63,33 +63,12 @@ public class dbContractHandler extends dbHandlerBase {
|
||||
|
||||
while (rs.next()) {
|
||||
|
||||
//handle item base
|
||||
int itemBaseID = rs.getInt("itembaseID");
|
||||
int templateID = rs.getInt("templateID");
|
||||
|
||||
ItemBase ib = ItemBase.getItemBase(itemBaseID);
|
||||
Item item = new Item(templateID);
|
||||
item.objectUUID = MobLoot.lastNegativeID.decrementAndGet();
|
||||
contract.getSellInventory().add(item);
|
||||
|
||||
if (ib != null) {
|
||||
|
||||
MobEquipment me = new MobEquipment(ib, 0, 0);
|
||||
contract.getSellInventory().add(me);
|
||||
|
||||
//handle magic effects
|
||||
String prefix = rs.getString("prefix");
|
||||
int pRank = rs.getInt("pRank");
|
||||
String suffix = rs.getString("suffix");
|
||||
int sRank = rs.getInt("sRank");
|
||||
|
||||
if (prefix != null) {
|
||||
me.setPrefix(prefix, pRank);
|
||||
me.setIsID(true);
|
||||
}
|
||||
|
||||
if (suffix != null) {
|
||||
me.setSuffix(suffix, sRank);
|
||||
me.setIsID(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
|
||||
@@ -1,139 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.db.handlers;
|
||||
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.objects.ItemBase;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class dbItemBaseHandler extends dbHandlerBase {
|
||||
|
||||
public dbItemBaseHandler() {
|
||||
|
||||
}
|
||||
|
||||
public void LOAD_BAKEDINSTATS(ItemBase itemBase) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_bakedinstat` WHERE `itemID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, itemBase.getUUID());
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
if (rs.getBoolean("fromUse"))
|
||||
itemBase.getUsedStats().put(rs.getInt("token"), rs.getInt("numTrains"));
|
||||
else
|
||||
itemBase.getBakedInStats().put(rs.getInt("token"), rs.getInt("numTrains"));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void LOAD_ANIMATIONS(ItemBase itemBase) {
|
||||
|
||||
ArrayList<Integer> tempList = new ArrayList<>();
|
||||
ArrayList<Integer> tempListOff = new ArrayList<>();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_itembase_animations` WHERE `itemBaseUUID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, itemBase.getUUID());
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
int animation = rs.getInt("animation");
|
||||
boolean rightHand = rs.getBoolean("rightHand");
|
||||
|
||||
if (rightHand)
|
||||
tempList.add(animation);
|
||||
else
|
||||
tempListOff.add(animation);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
itemBase.setAnimations(tempList);
|
||||
itemBase.setOffHandAnimations(tempListOff);
|
||||
}
|
||||
|
||||
public void LOAD_ALL_ITEMBASES() {
|
||||
|
||||
ItemBase itemBase;
|
||||
int recordsRead = 0;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_itembase")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
recordsRead++;
|
||||
itemBase = new ItemBase(rs);
|
||||
|
||||
ItemBase.addToCache(itemBase);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
Logger.info("read: " + recordsRead + " cached: " + ItemBase.getUUIDCache().size());
|
||||
}
|
||||
|
||||
public HashMap<Integer, ArrayList<Integer>> LOAD_RUNES_FOR_NPC_AND_MOBS() {
|
||||
|
||||
HashMap<Integer, ArrayList<Integer>> runeSets = new HashMap<>();
|
||||
int runeSetID;
|
||||
int runeBaseID;
|
||||
int recordsRead = 0;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_npc_runeSet")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
|
||||
recordsRead++;
|
||||
|
||||
runeSetID = rs.getInt("runeSet");
|
||||
runeBaseID = rs.getInt("runeBase");
|
||||
|
||||
if (runeSets.get(runeSetID) == null) {
|
||||
ArrayList<Integer> runeList = new ArrayList<>();
|
||||
runeList.add(runeBaseID);
|
||||
runeSets.put(runeSetID, runeList);
|
||||
} else {
|
||||
ArrayList<Integer> runeList = runeSets.get(runeSetID);
|
||||
runeList.add(runeSetID);
|
||||
runeSets.put(runeSetID, runeList);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
return runeSets;
|
||||
}
|
||||
|
||||
Logger.info("read: " + recordsRead + " cached: " + runeSets.size());
|
||||
return runeSets;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,12 +9,16 @@
|
||||
|
||||
package engine.db.handlers;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.Enum.ItemContainerType;
|
||||
import engine.Enum.ItemType;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.objects.AbstractCharacter;
|
||||
import engine.objects.CharacterItemManager;
|
||||
import engine.objects.Item;
|
||||
import engine.objects.ItemTemplate;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -52,46 +56,56 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Item ADD_ITEM(Item toAdd) {
|
||||
public Item PERSIST(Item toAdd) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("CALL `item_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?,?);")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("CALL `item_CREATE`(?, ?, ?, ?, ?, ?, ?, ?,?);")) {
|
||||
|
||||
preparedStatement.setInt(1, toAdd.getOwnerID());
|
||||
preparedStatement.setInt(2, toAdd.getItemBaseID());
|
||||
preparedStatement.setInt(3, toAdd.getChargesRemaining());
|
||||
preparedStatement.setInt(4, toAdd.getDurabilityCurrent());
|
||||
preparedStatement.setInt(5, toAdd.getDurabilityMax());
|
||||
preparedStatement.setInt(1, toAdd.ownerID);
|
||||
preparedStatement.setInt(2, toAdd.templateID);
|
||||
preparedStatement.setInt(3, (byte) toAdd.chargesRemaining);
|
||||
preparedStatement.setInt(4, (short) toAdd.combat_health_current);
|
||||
|
||||
if (toAdd.getNumOfItems() < 1)
|
||||
preparedStatement.setInt(6, 1);
|
||||
preparedStatement.setInt(5, 1);
|
||||
else
|
||||
preparedStatement.setInt(6, toAdd.getNumOfItems());
|
||||
preparedStatement.setInt(5, toAdd.getNumOfItems());
|
||||
|
||||
switch (toAdd.containerType) {
|
||||
case INVENTORY:
|
||||
preparedStatement.setString(7, "inventory");
|
||||
preparedStatement.setString(6, "inventory");
|
||||
break;
|
||||
case EQUIPPED:
|
||||
preparedStatement.setString(7, "equip");
|
||||
preparedStatement.setString(6, "equip");
|
||||
break;
|
||||
case BANK:
|
||||
preparedStatement.setString(7, "bank");
|
||||
preparedStatement.setString(6, "bank");
|
||||
break;
|
||||
case VAULT:
|
||||
preparedStatement.setString(7, "vault");
|
||||
preparedStatement.setString(6, "vault");
|
||||
break;
|
||||
case FORGE:
|
||||
preparedStatement.setString(7, "forge");
|
||||
preparedStatement.setString(6, "forge");
|
||||
break;
|
||||
default:
|
||||
preparedStatement.setString(7, "none"); //Shouldn't be here
|
||||
preparedStatement.setString(6, "none"); //Shouldn't be here
|
||||
break;
|
||||
}
|
||||
|
||||
preparedStatement.setByte(8, toAdd.getEquipSlot());
|
||||
preparedStatement.setInt(9, toAdd.getFlags());
|
||||
preparedStatement.setString(10, toAdd.getCustomName());
|
||||
if (toAdd.equipSlot.equals(Enum.EquipSlotType.NONE))
|
||||
preparedStatement.setString(7, "");
|
||||
else
|
||||
preparedStatement.setString(7, toAdd.equipSlot.name());
|
||||
|
||||
String flagString = "";
|
||||
|
||||
for (Enum.ItemFlags itemflag : toAdd.flags)
|
||||
flagString += itemflag.toString() + ";";
|
||||
|
||||
flagString = flagString.replaceAll(";$", "");
|
||||
|
||||
preparedStatement.setString(8, flagString);
|
||||
preparedStatement.setString(9, toAdd.name);
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
@@ -148,7 +162,7 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
ArrayList<Item> itemList;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=? && `obj_item`.`item_container`='equip';")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=? && `obj_item`.`container`='equip';")) {
|
||||
|
||||
preparedStatement.setLong(1, targetId);
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
@@ -163,6 +177,45 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
return itemList;
|
||||
}
|
||||
|
||||
public void LOAD_ITEM_TEMPLATES() {
|
||||
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_templates`;");
|
||||
ResultSet rs = preparedStatement.executeQuery()) {
|
||||
|
||||
while (rs.next()) {
|
||||
int templateID = rs.getInt("id");
|
||||
JSONObject jsonObject = (JSONObject) jsonParser.parse(rs.getString("template"));
|
||||
ItemTemplate itemTemplate = new ItemTemplate(jsonObject);
|
||||
itemTemplate.template_id = templateID;
|
||||
ItemTemplate.templates.put(templateID, itemTemplate);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void LOAD_TEMPLATE_MODTABLES() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_vendor_items`;");
|
||||
ResultSet rs = preparedStatement.executeQuery()) {
|
||||
|
||||
while (rs.next()) {
|
||||
int templateID = rs.getInt("templateID");
|
||||
int modTable = rs.getInt("modTable");
|
||||
ItemTemplate template = ItemTemplate.templates.get(templateID);
|
||||
template.modTable = modTable;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
}
|
||||
public Item GET_ITEM(final int itemUUID) {
|
||||
|
||||
Item item;
|
||||
@@ -242,7 +295,7 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
public boolean MOVE_GOLD(final Item from, final Item to, final int amt) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_numberOfItems` = CASE WHEN `UID`=? THEN ? WHEN `UID`=? THEN ? END WHERE `UID` IN (?, ?);")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `numberOfItems` = CASE WHEN `UID`=? THEN ? WHEN `UID`=? THEN ? END WHERE `UID` IN (?, ?);")) {
|
||||
|
||||
int newFromAmt = from.getNumOfItems() - amt;
|
||||
int newToAmt = to.getNumOfItems() + amt;
|
||||
@@ -268,11 +321,11 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
|
||||
for (Item item : inventory) {
|
||||
|
||||
if (item.getItemBase().getType().equals(ItemType.GOLD))
|
||||
if (item.template.item_type.equals(ItemType.GOLD))
|
||||
continue;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` LEFT JOIN `object` ON `object`.`UID` = `obj_item`.`UID` SET `object`.`parent`=NULL, `obj_item`.`item_container`='none' WHERE `object`.`UID`=?;")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` LEFT JOIN `object` ON `object`.`UID` = `obj_item`.`UID` SET `object`.`parent`=NULL, `obj_item`.`container`='none' WHERE `object`.`UID`=?;")) {
|
||||
|
||||
preparedStatement.setLong(1, item.getObjectUUID());
|
||||
worked = (preparedStatement.executeUpdate() > 0);
|
||||
@@ -288,12 +341,12 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
return worked;
|
||||
}
|
||||
|
||||
public HashSet<Integer> GET_ITEMS_FOR_VENDOR(final int vendorID) {
|
||||
public HashSet<Integer> GET_VENDOR_CAN_ROLL_LIST(final int vendorID) {
|
||||
|
||||
HashSet<Integer> itemSet = new HashSet<>();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT ID FROM static_itembase WHERE vendorType = ?")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT templateID FROM static_vendor_items WHERE vendorType = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, vendorID);
|
||||
|
||||
@@ -311,8 +364,8 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
}
|
||||
|
||||
//Used to transfer a single item between owners or equip or vault or bank or inventory
|
||||
public boolean UPDATE_OWNER(final Item item, int newOwnerID, boolean ownerNPC, boolean ownerPlayer,
|
||||
boolean ownerAccount, ItemContainerType containerType, int slot) {
|
||||
public boolean UPDATE_OWNER(final Item item, int newOwnerID,
|
||||
ItemContainerType containerType, Enum.EquipSlotType slot) {
|
||||
|
||||
boolean worked = false;
|
||||
|
||||
@@ -346,7 +399,12 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
preparedStatement.setString(3, "none"); //Shouldn't be here
|
||||
break;
|
||||
}
|
||||
preparedStatement.setInt(4, slot);
|
||||
|
||||
if (slot.equals(Enum.EquipSlotType.NONE))
|
||||
preparedStatement.setString(4, "");
|
||||
else
|
||||
preparedStatement.setString(4, slot.name());
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
if (rs.next())
|
||||
@@ -362,11 +420,11 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
public boolean SET_DURABILITY(final Item item, int value) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_durabilityCurrent`=? WHERE `UID`=? AND `item_durabilityCurrent`=?")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `combat_health_current`=? WHERE `UID`=? AND `combat_health_current`=?")) {
|
||||
|
||||
preparedStatement.setInt(1, value);
|
||||
preparedStatement.setLong(2, item.getObjectUUID());
|
||||
preparedStatement.setInt(3, item.getDurabilityCurrent());
|
||||
preparedStatement.setInt(3, (short) item.combat_health_current);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
@@ -379,7 +437,7 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
public boolean UPDATE_FORGE_TO_INVENTORY(final Item item) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_container` = ? WHERE `UID` = ? AND `item_container` = 'forge';")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `container` = ? WHERE `UID` = ? AND `container` = 'forge';")) {
|
||||
|
||||
preparedStatement.setString(1, "inventory");
|
||||
preparedStatement.setLong(2, item.getObjectUUID());
|
||||
@@ -412,11 +470,11 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
*/
|
||||
public boolean UPDATE_GOLD(final Item item, int newValue, int oldValue) {
|
||||
|
||||
if (!item.getItemBase().getType().equals(ItemType.GOLD))
|
||||
if (!item.template.item_type.equals(ItemType.GOLD))
|
||||
return false;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_numberOfItems`=? WHERE `UID`=?")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `numberOfItems`=? WHERE `UID`=?")) {
|
||||
|
||||
preparedStatement.setInt(1, newValue);
|
||||
preparedStatement.setLong(2, item.getObjectUUID());
|
||||
@@ -433,9 +491,9 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
public boolean UPDATE_REMAINING_CHARGES(final Item item) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_chargesRemaining` = ? WHERE `UID` = ?")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `chargesRemaining` = ? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, item.getChargesRemaining());
|
||||
preparedStatement.setInt(1, (byte) item.chargesRemaining);
|
||||
preparedStatement.setLong(2, item.getObjectUUID());
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
@@ -453,7 +511,7 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
public boolean ZERO_ITEM_STACK(Item item) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_numberOfItems`=0 WHERE `UID` = ?")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `numberOfItems`=0 WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setLong(1, item.getObjectUUID());
|
||||
|
||||
@@ -468,9 +526,16 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
public boolean UPDATE_FLAGS(Item item) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_flags`=? WHERE `UID` = ?")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `flags`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, item.getFlags());
|
||||
String flagString = "";
|
||||
|
||||
for (Enum.ItemFlags itemflag : item.flags)
|
||||
flagString += itemflag.toString() + ";";
|
||||
|
||||
flagString = flagString.replaceAll(";$", "");
|
||||
|
||||
preparedStatement.setString(1, flagString);
|
||||
preparedStatement.setLong(2, item.getObjectUUID());
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
@@ -483,8 +548,13 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
|
||||
public boolean UPDATE_VALUE(Item item, int value) {
|
||||
|
||||
// Write 0 if we will not modify the value from template
|
||||
|
||||
if (item.value == item.template.item_value)
|
||||
value = 0;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_value`=? WHERE `UID` = ?")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `value`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, value);
|
||||
preparedStatement.setLong(2, item.getObjectUUID());
|
||||
@@ -496,4 +566,25 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean UPDATE_EQUIP_SLOT(Item item) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `equipSlot`=? WHERE `UID` = ?")) {
|
||||
|
||||
if (item.equipSlot.equals(Enum.EquipSlotType.NONE))
|
||||
preparedStatement.setString(1, "");
|
||||
else
|
||||
preparedStatement.setString(1, item.equipSlot.name());
|
||||
|
||||
preparedStatement.setLong(2, item.getObjectUUID());
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import engine.Enum;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.objects.Mine;
|
||||
import engine.objects.MineProduction;
|
||||
import engine.objects.Resource;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -84,7 +83,7 @@ public class dbMineHandler extends dbHandlerBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean CHANGE_RESOURCE(Mine mine, Resource resource) {
|
||||
public boolean CHANGE_RESOURCE(Mine mine, Enum.ResourceType resource) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_mine` SET `mine_resource`=? WHERE `UID`=?")) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class dbNPCHandler extends dbHandlerBase {
|
||||
|
||||
@@ -31,6 +32,45 @@ public class dbNPCHandler extends dbHandlerBase {
|
||||
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
|
||||
}
|
||||
|
||||
public static HashMap<Integer, ArrayList<Integer>> LOAD_RUNES_FOR_NPC_AND_MOBS() {
|
||||
|
||||
HashMap<Integer, ArrayList<Integer>> runeSets = new HashMap<>();
|
||||
int runeSetID;
|
||||
int runeBaseID;
|
||||
int recordsRead = 0;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_npc_runeSet")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
|
||||
recordsRead++;
|
||||
|
||||
runeSetID = rs.getInt("runeSet");
|
||||
runeBaseID = rs.getInt("runeBase");
|
||||
|
||||
if (runeSets.get(runeSetID) == null) {
|
||||
ArrayList<Integer> runeList = new ArrayList<>();
|
||||
runeList.add(runeBaseID);
|
||||
runeSets.put(runeSetID, runeList);
|
||||
} else {
|
||||
ArrayList<Integer> runeList = runeSets.get(runeSetID);
|
||||
runeList.add(runeSetID);
|
||||
runeSets.put(runeSetID, runeList);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
return runeSets;
|
||||
}
|
||||
|
||||
Logger.info("read: " + recordsRead + " cached: " + runeSets.size());
|
||||
return runeSets;
|
||||
}
|
||||
|
||||
public NPC PERSIST(NPC toAdd) {
|
||||
|
||||
NPC npc = null;
|
||||
@@ -305,14 +345,14 @@ public class dbNPCHandler extends dbHandlerBase {
|
||||
+ NPC._pirateNames.size() + " mobBases");
|
||||
}
|
||||
|
||||
public boolean ADD_TO_PRODUCTION_LIST(final long ID, final long npcUID, final long itemBaseID, DateTime dateTime, String prefix, String suffix, String name, boolean isRandom, int playerID) {
|
||||
public boolean ADD_TO_PRODUCTION_LIST(final long ID, final long npcUID, final long templateID, DateTime dateTime, String prefix, String suffix, String name, boolean isRandom, int playerID) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_npc_production` (`ID`,`npcUID`, `itemBaseID`,`dateToUpgrade`, `isRandom`, `prefix`, `suffix`, `name`,`playerID`) VALUES (?,?,?,?,?,?,?,?,?)")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_npc_production` (`ID`,`npcUID`, `templateID`,`dateToUpgrade`, `isRandom`, `prefix`, `suffix`, `name`,`playerID`) VALUES (?,?,?,?,?,?,?,?,?)")) {
|
||||
|
||||
preparedStatement.setLong(1, ID);
|
||||
preparedStatement.setLong(2, npcUID);
|
||||
preparedStatement.setLong(3, itemBaseID);
|
||||
preparedStatement.setLong(3, templateID);
|
||||
preparedStatement.setTimestamp(4, new java.sql.Timestamp(dateTime.getMillis()));
|
||||
preparedStatement.setBoolean(5, isRandom);
|
||||
preparedStatement.setString(6, prefix);
|
||||
|
||||
@@ -11,10 +11,7 @@ package engine.db.handlers;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.objects.AbstractWorldObject;
|
||||
import engine.objects.Heraldry;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.objects.PlayerFriends;
|
||||
import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
@@ -45,8 +42,8 @@ public class dbPlayerCharacterHandler extends dbHandlerBase {
|
||||
preparedStatement.setLong(1, toAdd.getAccount().getObjectUUID());
|
||||
preparedStatement.setString(2, toAdd.getFirstName());
|
||||
preparedStatement.setString(3, toAdd.getLastName());
|
||||
preparedStatement.setInt(4, toAdd.getRace().getRaceRuneID());
|
||||
preparedStatement.setInt(5, toAdd.getBaseClass().getObjectUUID());
|
||||
preparedStatement.setInt(4, toAdd.race.getRaceRuneID());
|
||||
preparedStatement.setInt(5, toAdd.baseClass.getObjectUUID());
|
||||
preparedStatement.setInt(6, toAdd.getStrMod());
|
||||
preparedStatement.setInt(7, toAdd.getDexMod());
|
||||
preparedStatement.setInt(8, toAdd.getConMod());
|
||||
|
||||
@@ -13,10 +13,11 @@ import engine.Enum;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.objects.Mob;
|
||||
import engine.objects.PreparedStatementShared;
|
||||
import engine.powers.EffectsBase;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.HashSet;
|
||||
|
||||
@@ -28,16 +29,17 @@ public class dbPowerHandler extends dbHandlerBase {
|
||||
}
|
||||
|
||||
public static void addAllSourceTypes() {
|
||||
PreparedStatementShared ps = null;
|
||||
try {
|
||||
ps = new PreparedStatementShared("SELECT * FROM static_power_sourcetype");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_power_sourcetype")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
String IDString, source;
|
||||
|
||||
while (rs.next()) {
|
||||
IDString = rs.getString("IDString");
|
||||
int token = DbManager.hasher.SBStringHash(IDString);
|
||||
|
||||
|
||||
source = rs.getString("source").replace("-", "").trim();
|
||||
Enum.EffectSourceType effectSourceType = Enum.EffectSourceType.GetEffectSourceType(source);
|
||||
|
||||
@@ -46,19 +48,18 @@ public class dbPowerHandler extends dbHandlerBase {
|
||||
|
||||
EffectsBase.effectSourceTypeMap.get(token).add(effectSourceType);
|
||||
}
|
||||
rs.close();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
} finally {
|
||||
ps.release();
|
||||
}
|
||||
}
|
||||
|
||||
public static void addAllAnimationOverrides() {
|
||||
PreparedStatementShared ps = null;
|
||||
try {
|
||||
ps = new PreparedStatementShared("SELECT * FROM static_power_animation_override");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_power_animation_override")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
String IDString;
|
||||
int animation;
|
||||
while (rs.next()) {
|
||||
@@ -72,12 +73,10 @@ public class dbPowerHandler extends dbHandlerBase {
|
||||
PowersManager.AnimationOverrides.put(IDString, animation);
|
||||
|
||||
}
|
||||
rs.close();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
} finally {
|
||||
ps.release();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,14 +9,19 @@
|
||||
|
||||
package engine.db.handlers;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.Enum.ProtectionState;
|
||||
import engine.Enum.TransactionType;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
import engine.objects.Building;
|
||||
import engine.objects.City;
|
||||
import engine.objects.Transaction;
|
||||
import engine.objects.Warehouse;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.joda.time.DateTime;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -31,463 +36,10 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
||||
private static final ConcurrentHashMap<Integer, String> columns = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
|
||||
public dbWarehouseHandler() {
|
||||
this.localClass = Warehouse.class;
|
||||
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
|
||||
|
||||
}
|
||||
|
||||
public static void addObject(ArrayList<AbstractGameObject> list, ResultSet rs) throws SQLException {
|
||||
String type = rs.getString("type");
|
||||
switch (type) {
|
||||
case "building":
|
||||
Building building = new Building(rs);
|
||||
DbManager.addToCache(building);
|
||||
list.add(building);
|
||||
break;
|
||||
case "warehouse":
|
||||
Warehouse warehouse = new Warehouse(rs);
|
||||
DbManager.addToCache(warehouse);
|
||||
list.add(warehouse);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<AbstractGameObject> CREATE_WAREHOUSE(int parentZoneID, int OwnerUUID, String name, int meshUUID,
|
||||
Vector3fImmutable location, float meshScale, int currentHP,
|
||||
ProtectionState protectionState, int currentGold, int rank,
|
||||
DateTime upgradeDate, int blueprintUUID, float w, float rotY) {
|
||||
|
||||
ArrayList<AbstractGameObject> warehouseList = new ArrayList<>();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("CALL `WAREHOUSE_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,? ,? ,?, ?);")) {
|
||||
|
||||
preparedStatement.setInt(1, parentZoneID);
|
||||
preparedStatement.setInt(2, OwnerUUID);
|
||||
preparedStatement.setString(3, name);
|
||||
preparedStatement.setInt(4, meshUUID);
|
||||
preparedStatement.setFloat(5, location.x);
|
||||
preparedStatement.setFloat(6, location.y);
|
||||
preparedStatement.setFloat(7, location.z);
|
||||
preparedStatement.setFloat(8, meshScale);
|
||||
preparedStatement.setInt(9, currentHP);
|
||||
preparedStatement.setString(10, protectionState.name());
|
||||
preparedStatement.setInt(11, currentGold);
|
||||
preparedStatement.setInt(12, rank);
|
||||
|
||||
if (upgradeDate != null)
|
||||
preparedStatement.setTimestamp(13, new java.sql.Timestamp(upgradeDate.getMillis()));
|
||||
else
|
||||
preparedStatement.setNull(13, java.sql.Types.DATE);
|
||||
|
||||
preparedStatement.setInt(14, blueprintUUID);
|
||||
preparedStatement.setFloat(15, w);
|
||||
preparedStatement.setFloat(16, rotY);
|
||||
|
||||
preparedStatement.execute();
|
||||
ResultSet rs = preparedStatement.getResultSet();
|
||||
|
||||
while (rs.next())
|
||||
addObject(warehouseList, rs);
|
||||
|
||||
while (preparedStatement.getMoreResults()) {
|
||||
rs = preparedStatement.getResultSet();
|
||||
|
||||
while (rs.next())
|
||||
addObject(warehouseList, rs);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
return warehouseList;
|
||||
}
|
||||
|
||||
public boolean updateLocks(final Warehouse wh, long locks) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_locks`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setLong(1, locks);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateGold(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_gold`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateStone(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_stone`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateTruesteel(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_truesteel`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateIron(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_iron`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateAdamant(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_adamant`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateLumber(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_lumber`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateOak(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_oak`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateBronzewood(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_bronzewood`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateMandrake(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_mandrake`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateCoal(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_coal`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateAgate(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_agate`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateDiamond(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_diamond`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateOnyx(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_onyx`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateAzoth(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_azoth`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateOrichalk(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_orichalk`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateAntimony(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_antimony`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateSulfur(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_sulfur`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateQuicksilver(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_quicksilver`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateGalvor(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_galvor`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateWormwood(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_wormwood`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateObsidian(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_obsidian`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateBloodstone(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_bloodstone`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateMithril(final Warehouse wh, int amount) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_mithril`=? WHERE `UID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, amount);
|
||||
preparedStatement.setInt(2, wh.UID);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean CREATE_TRANSACTION(int warehouseBuildingID, GameObjectType targetType, int targetUUID, TransactionType transactionType, Resource resource, int amount, DateTime date) {
|
||||
public boolean CREATE_TRANSACTION(int warehouseBuildingID, GameObjectType targetType, int targetUUID, TransactionType transactionType, Enum.ResourceType resource, int amount, DateTime date) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_warehouse_transactions` (`warehouseUID`, `targetType`,`targetUID`, `type`,`resource`,`amount`,`date` ) VALUES (?,?,?,?,?,?,?)")) {
|
||||
@@ -532,24 +84,74 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
||||
return transactionsList;
|
||||
}
|
||||
|
||||
public void LOAD_ALL_WAREHOUSES() {
|
||||
|
||||
Warehouse warehouse;
|
||||
|
||||
public void DELETE_WAREHOUSE(Warehouse warehouse) {
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_warehouse`.*, `object`.`parent`, `object`.`type` FROM `object` LEFT JOIN `obj_warehouse` ON `object`.`UID` = `obj_warehouse`.`UID` WHERE `object`.`type` = 'warehouse';")) {
|
||||
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
warehouse = new Warehouse(rs);
|
||||
warehouse.runAfterLoad();
|
||||
Warehouse.loadAllTransactions(warehouse);
|
||||
}
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_warehouse` WHERE `cityUUID` = ?;")) {
|
||||
preparedStatement.setInt(1, warehouse.city.getObjectUUID());
|
||||
preparedStatement.executeUpdate();
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean UPDATE_WAREHOUSE(Warehouse warehouse) {
|
||||
|
||||
JSONObject warehouseJSON = new JSONObject();
|
||||
|
||||
JSONObject resources = new JSONObject(warehouse.resources);
|
||||
warehouseJSON.put("resources", resources);
|
||||
|
||||
JSONArray locks = new JSONArray();
|
||||
|
||||
for (Enum.ResourceType resource : warehouse.locked)
|
||||
locks.add(resource.name());
|
||||
|
||||
warehouseJSON.put("locked", locks);
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_warehouse` (`cityUUID`, `warehouse`) VALUES (?, ?) " +
|
||||
"ON DUPLICATE KEY UPDATE `warehouse` = VALUES(`warehouse`)")) {
|
||||
|
||||
preparedStatement.setInt(1, warehouse.city.getObjectUUID());
|
||||
preparedStatement.setString(2, warehouseJSON.toString());
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void LOAD_WAREHOUSES() {
|
||||
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_warehouse`;");
|
||||
ResultSet rs = preparedStatement.executeQuery()) {
|
||||
|
||||
while (rs.next()) {
|
||||
int cityUID = rs.getInt("cityUUID");
|
||||
JSONObject jsonObject = (JSONObject) jsonParser.parse(rs.getString("warehouse"));
|
||||
City city = City.getCity(cityUID);
|
||||
city.warehouse = new Warehouse(jsonObject);
|
||||
city.warehouse.city = city;
|
||||
|
||||
// Locate warehouse building
|
||||
for (Building building : city.parentZone.zoneBuildingSet) {
|
||||
if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.WAREHOUSE)) {
|
||||
city.warehouse.building = building;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class AddGoldCmd extends AbstractDevCmd {
|
||||
return;
|
||||
}
|
||||
|
||||
Item gold = pc.getCharItemManager().getGoldInventory();
|
||||
Item gold = pc.charItemManager.getGoldInventory();
|
||||
int curAmt;
|
||||
if (gold == null)
|
||||
curAmt = 0;
|
||||
@@ -54,13 +54,13 @@ public class AddGoldCmd extends AbstractDevCmd {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pc.getCharItemManager().addGoldToInventory(amt, true)) {
|
||||
if (!pc.charItemManager.addGoldToInventory(amt, true)) {
|
||||
throwbackError(pc, "Failed to add gold to inventory");
|
||||
return;
|
||||
}
|
||||
|
||||
ChatManager.chatSayInfo(pc, amt + " gold added to inventory");
|
||||
pc.getCharItemManager().updateInventory();
|
||||
pc.charItemManager.updateInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum.ModType;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.net.ItemProductionManager;
|
||||
import engine.objects.*;
|
||||
import engine.powers.effectmodifiers.AbstractEffectModifier;
|
||||
import engine.powers.poweractions.AbstractPowerAction;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
public class AuditFailedItemsCmd extends AbstractDevCmd {
|
||||
|
||||
public AuditFailedItemsCmd() {
|
||||
super("faileditems");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pcSender, String[] words,
|
||||
AbstractGameObject target) {
|
||||
|
||||
|
||||
if (ItemProductionManager.FailedItems.isEmpty())
|
||||
return;
|
||||
|
||||
Logger.info("Auditing Item production Failed Items");
|
||||
|
||||
String newLine = "\r\n";
|
||||
String auditFailedItem = "Failed Item Name | Prefix | Suffix | NPC | Contract | Player | ";
|
||||
|
||||
for (ProducedItem failedItem : ItemProductionManager.FailedItems) {
|
||||
|
||||
String npcName = "";
|
||||
String playerName = "";
|
||||
String contractName = "";
|
||||
|
||||
String prefix = "";
|
||||
String suffix = "";
|
||||
String itemName = "";
|
||||
NPC npc = NPC.getFromCache(failedItem.getNpcUID());
|
||||
|
||||
if (npc == null) {
|
||||
npcName = "null";
|
||||
contractName = "null";
|
||||
} else {
|
||||
npcName = npc.getName();
|
||||
if (npc.getContract() != null)
|
||||
contractName = npc.getContract().getName();
|
||||
}
|
||||
|
||||
PlayerCharacter roller = PlayerCharacter.getFromCache(failedItem.getPlayerID());
|
||||
|
||||
if (roller == null)
|
||||
playerName = "null";
|
||||
else
|
||||
playerName = roller.getName();
|
||||
|
||||
ItemBase ib = ItemBase.getItemBase(failedItem.getItemBaseID());
|
||||
|
||||
if (ib != null) {
|
||||
itemName = ib.getName();
|
||||
}
|
||||
|
||||
if (failedItem.isRandom() == false) {
|
||||
if (failedItem.getPrefix().isEmpty() == false) {
|
||||
AbstractPowerAction pa = PowersManager.getPowerActionByIDString(failedItem.getPrefix());
|
||||
if (pa != null) {
|
||||
for (AbstractEffectModifier aem : pa.getEffectsBase().getModifiers()) {
|
||||
if (aem.modType.equals(ModType.ItemName)) {
|
||||
prefix = aem.getString1();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (failedItem.getSuffix().isEmpty() == false) {
|
||||
AbstractPowerAction pa = PowersManager.getPowerActionByIDString(failedItem.getSuffix());
|
||||
if (pa != null) {
|
||||
for (AbstractEffectModifier aem : pa.getEffectsBase().getModifiers()) {
|
||||
if (aem.modType.equals(ModType.ItemName)) {
|
||||
suffix = aem.getString1();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
prefix = "random";
|
||||
}
|
||||
|
||||
|
||||
auditFailedItem += newLine;
|
||||
auditFailedItem += itemName + " | " + prefix + " | " + suffix + " | " + failedItem.getNpcUID() + ":" + npcName + " | " + contractName + " | " + failedItem.getPlayerID() + ":" + playerName;
|
||||
|
||||
}
|
||||
Logger.info(auditFailedItem);
|
||||
ItemProductionManager.FailedItems.clear();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /bounds'";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Audits all the mobs in a zone.";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// 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 AuditMobsCmd extends AbstractDevCmd {
|
||||
|
||||
public AuditMobsCmd() {
|
||||
super("auditmobs");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pcSender, String[] words,
|
||||
AbstractGameObject target) {
|
||||
if (pcSender == null)
|
||||
return;
|
||||
|
||||
//get Zone to check mobs against
|
||||
|
||||
Zone zone;
|
||||
|
||||
if (words.length == 2) {
|
||||
if (words[0].equals("all")) {
|
||||
int plusplus = 0;
|
||||
int count = Integer.parseInt(words[1]);
|
||||
for (Zone zoneMicro : ZoneManager.getAllZones()) {
|
||||
int size = zoneMicro.zoneMobSet.size();
|
||||
|
||||
if (size >= count) {
|
||||
plusplus++;
|
||||
throwbackInfo(pcSender, zoneMicro.zoneName + " at location " + zoneMicro.getLoc().toString() + " has " + size + " mobs. ");
|
||||
System.out.println(zoneMicro.zoneName + " at location " + zoneMicro.getLoc().toString() + " has " + size + " mobs. ");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
throwbackInfo(pcSender, " there are " + plusplus + " zones with at least " + count + " mobs in each.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (words.length > 1) {
|
||||
this.sendUsage(pcSender);
|
||||
return;
|
||||
} else if (words.length == 1) {
|
||||
int uuid;
|
||||
try {
|
||||
uuid = Integer.parseInt(words[0]);
|
||||
zone = ZoneManager.getZoneByUUID(uuid);
|
||||
} catch (NumberFormatException e) {
|
||||
zone = ZoneManager.findSmallestZone(pcSender.getLoc());
|
||||
}
|
||||
} else
|
||||
zone = ZoneManager.findSmallestZone(pcSender.getLoc());
|
||||
|
||||
if (zone == null) {
|
||||
throwbackError(pcSender, "Unable to find the zone");
|
||||
return;
|
||||
}
|
||||
|
||||
//get list of mobs for zone
|
||||
|
||||
if (zone.zoneMobSet.isEmpty()) {
|
||||
throwbackError(pcSender, "No mobs found for this zone.");
|
||||
return;
|
||||
}
|
||||
|
||||
// ConcurrentHashMap<Integer, Mob> spawnMap = Mob.getSpawnMap();
|
||||
//ConcurrentHashMap<Mob, Long> respawnMap = Mob.getRespawnMap();
|
||||
// ConcurrentHashMap<Mob, Long> despawnMap = Mob.getDespawnMap();
|
||||
|
||||
throwbackInfo(pcSender, zone.zoneName + ", numMobs: " + zone.zoneMobSet.size());
|
||||
throwbackInfo(pcSender, "UUID, dbID, inRespawnMap, isAlive, activeAI, Loc");
|
||||
|
||||
|
||||
//mob not found in spawn map, check respawn
|
||||
boolean inRespawn = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /auditmobs [zone.UUID]'";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Audits all the mobs in a zone.";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.util.MiscUtils;
|
||||
|
||||
public class ChangeNameCmd extends AbstractDevCmd {
|
||||
|
||||
public ChangeNameCmd() {
|
||||
super("changename");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
Vector3fImmutable loc = null;
|
||||
|
||||
// Arg Count Check
|
||||
if (words.length < 2) {
|
||||
this.sendUsage(pc);
|
||||
return;
|
||||
}
|
||||
|
||||
String oldFirst = words[0];
|
||||
String newFirst = words[1];
|
||||
String newLast = "";
|
||||
if (words.length > 2) {
|
||||
newLast = words[2];
|
||||
for (int i = 3; i < words.length; i++)
|
||||
newLast += ' ' + words[i];
|
||||
}
|
||||
|
||||
//verify new name length
|
||||
if (newFirst.length() < 3) {
|
||||
this.throwbackError(pc, "Error: First name is incorrect length. Must be between 3 and 15 characters");
|
||||
return;
|
||||
}
|
||||
|
||||
//verify old name length
|
||||
if (newLast.length() > 50) {
|
||||
this.throwbackError(pc, "Error: Last name is incorrect length. Must be no more than 50 characters");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if firstname is valid
|
||||
if (MiscUtils.checkIfFirstNameInvalid(newFirst)) {
|
||||
this.throwbackError(pc, "Error: First name is not allowed");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//get the world ID we're modifying for
|
||||
|
||||
//test if first name is unique, unless new and old first name are equal.
|
||||
if (!(oldFirst.equals(newFirst))) {
|
||||
if (!DbManager.PlayerCharacterQueries.IS_CHARACTER_NAME_UNIQUE(newFirst)) {
|
||||
this.throwbackError(pc, "Error: First name is not unique.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//tests passed, update name in database
|
||||
if (!DbManager.PlayerCharacterQueries.UPDATE_NAME(oldFirst, newFirst, newLast)) {
|
||||
this.throwbackError(pc, "Error: Database failed to update the name.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Finally update player ingame
|
||||
PlayerCharacter pcTar = null;
|
||||
try {
|
||||
pcTar = SessionManager
|
||||
.getPlayerCharacterByLowerCaseName(words[0]);
|
||||
pcTar.setFirstName(newFirst);
|
||||
pcTar.setLastName(newLast);
|
||||
this.setTarget(pcTar); //for logging
|
||||
|
||||
//specify if last name is ascii characters only
|
||||
String lastAscii = newLast.replaceAll("[^\\p{ASCII}]", "");
|
||||
pcTar.setAsciiLastName(lastAscii.equals(newLast));
|
||||
} catch (Exception e) {
|
||||
this.throwbackError(pc, "Database was updated but ingame character failed to update.");
|
||||
return;
|
||||
}
|
||||
|
||||
String out = oldFirst + " was changed to " + newFirst + (newLast.isEmpty() ? "." : (' ' + newLast + '.'));
|
||||
this.throwbackInfo(pc, out);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Changes the name of a player";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "'./changename oldFirstName newFirstName newLastName'";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.net.client.msg.TargetedActionMsg;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
/**
|
||||
* @author Eighty
|
||||
*/
|
||||
public class CombatMessageCmd extends AbstractDevCmd {
|
||||
|
||||
public CombatMessageCmd() {
|
||||
super("cm");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pcSender, String[] args,
|
||||
AbstractGameObject target) {
|
||||
if (pcSender == null)
|
||||
return;
|
||||
if (args.length != 1) {
|
||||
this.sendUsage(pcSender);
|
||||
return;
|
||||
}
|
||||
int num = 0;
|
||||
try {
|
||||
num = Integer.parseInt(args[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
throwbackError(pcSender, "Supplied message number " + args[0] + " failed to parse to an Integer");
|
||||
return;
|
||||
}
|
||||
TargetedActionMsg.un2cnt = num;
|
||||
throwbackInfo(pcSender, "CombatMessage set to " + num);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /cm [cmNumber]'";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Sets the combat message to the supplied integer value";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,6 @@ package engine.devcmd.cmds;
|
||||
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.ItemBase;
|
||||
import engine.objects.ItemFactory;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
@@ -27,28 +26,20 @@ public class CreateItemCmd extends AbstractDevCmd {
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
|
||||
if (words.length < 2) {
|
||||
this.sendUsage(pc);
|
||||
return;
|
||||
}
|
||||
int id;
|
||||
id = ItemBase.getIDByName(words[0]);
|
||||
|
||||
if (id == 0)
|
||||
id = Integer.parseInt(words[0]);
|
||||
if (id == 7) {
|
||||
this.throwbackInfo(pc, "use /addgold to add gold.....");
|
||||
return;
|
||||
}
|
||||
int templateID = Integer.parseInt(words[0]);
|
||||
|
||||
int size = 1;
|
||||
|
||||
if (words.length < 3) {
|
||||
if (words.length == 2)
|
||||
size = Integer.parseInt(words[1]);
|
||||
}
|
||||
|
||||
ItemFactory.fillInventory(pc, id, size);
|
||||
|
||||
ItemFactory.fillInventory(pc, templateID, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,7 +49,7 @@ public class CreateItemCmd extends AbstractDevCmd {
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /createitem <ItembaseID> <quantity>'";
|
||||
return "' /createitem <templateID> <quantity>'";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.jobs.DebugTimerJob;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
public class DebugCmd extends AbstractDevCmd {
|
||||
|
||||
|
||||
public DebugCmd() {
|
||||
super("debug");
|
||||
// super("debug", MBServerStatics.ACCESS_GROUP_ALL_TEAM, 0, false, false);
|
||||
}
|
||||
|
||||
private static void toggleDebugTimer(PlayerCharacter pc, String name, int num, int duration, boolean toggle) {
|
||||
if (toggle) {
|
||||
DebugTimerJob dtj = new DebugTimerJob(pc, name, num, duration);
|
||||
pc.renewTimer(name, dtj, duration);
|
||||
} else
|
||||
pc.cancelTimer(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
if (words.length < 2) {
|
||||
this.sendUsage(pc);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pc == null)
|
||||
return;
|
||||
|
||||
//pc.setDebug must use bit sizes: 1, 2, 4, 8, 16, 32
|
||||
|
||||
String command = words[0].toLowerCase();
|
||||
boolean toggle = (words[1].toLowerCase().equals("on")) ? true : false;
|
||||
|
||||
switch (command) {
|
||||
case "magictrek":
|
||||
pc.RUN_MAGICTREK = toggle;
|
||||
|
||||
break;
|
||||
case "combat":
|
||||
pc.setDebug(64, toggle);
|
||||
|
||||
break;
|
||||
case "health":
|
||||
toggleDebugTimer(pc, "Debug_Health", 1, 1000, toggle);
|
||||
|
||||
break;
|
||||
case "mana":
|
||||
toggleDebugTimer(pc, "Debug_Mana", 2, 1000, toggle);
|
||||
|
||||
break;
|
||||
case "stamina":
|
||||
toggleDebugTimer(pc, "Debug_Stamina", 3, 500, toggle);
|
||||
|
||||
break;
|
||||
case "spells":
|
||||
pc.setDebug(16, toggle);
|
||||
|
||||
break;
|
||||
case "damageabsorber":
|
||||
pc.setDebug(2, toggle);
|
||||
|
||||
break;
|
||||
case "recast":
|
||||
case "recycle":
|
||||
pc.setDebug(4, toggle);
|
||||
|
||||
break;
|
||||
case "seeinvis":
|
||||
pc.setDebug(8, toggle);
|
||||
|
||||
break;
|
||||
case "movement":
|
||||
pc.setDebug(1, toggle);
|
||||
|
||||
break;
|
||||
case "noaggro":
|
||||
pc.setDebug(32, toggle);
|
||||
|
||||
break;
|
||||
// case "loot":
|
||||
// MBServerStatics.debugLoot = toggle;
|
||||
// break;
|
||||
|
||||
default:
|
||||
String output = "Debug for " + command + " not found.";
|
||||
throwbackError(pc, output);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
setTarget(pc); //for logging
|
||||
|
||||
String output = "Debug for " + command + " turned " + ((toggle) ? "on." : "off.");
|
||||
throwbackInfo(pc, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Runs debug commands";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "'./Debug command on/off'";
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
public class DebugMeleeSyncCmd extends AbstractDevCmd {
|
||||
|
||||
public DebugMeleeSyncCmd() {
|
||||
super("debugmeleesync");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
// Arg Count Check
|
||||
if (words.length != 1) {
|
||||
this.sendUsage(pc);
|
||||
return;
|
||||
}
|
||||
|
||||
String s = words[0].toLowerCase();
|
||||
|
||||
if (s.equals("on")) {
|
||||
pc.setDebug(64, true);
|
||||
ChatManager.chatSayInfo(pc, "Melee Sync Debug ON");
|
||||
} else if (s.equals("off")) {
|
||||
pc.setDebug(64, false);
|
||||
ChatManager.chatSayInfo(pc, "Melee Sync Debug OFF");
|
||||
} else {
|
||||
this.sendUsage(pc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Turns on/off melee sync debugging.";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "'./debugmeleesync on|off'";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class DecachePlayerCmd extends AbstractDevCmd {
|
||||
|
||||
public DecachePlayerCmd() {
|
||||
super("decacheplayer");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
if (words.length < 1) {
|
||||
this.sendUsage(pc);
|
||||
}
|
||||
|
||||
int objectUUID = Integer.parseInt(words[0]);
|
||||
|
||||
if (DbManager.inCache(Enum.GameObjectType.PlayerCharacter, objectUUID)) {
|
||||
this.setTarget(PlayerCharacter.getFromCache(objectUUID)); //for logging
|
||||
PlayerCharacter.getFromCache(objectUUID).removeFromCache();
|
||||
} else {
|
||||
this.sendHelp(pc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "No player found. Please make sure the table ID is correct.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /decacheplayer <UUID>'";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.Mob;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
public class DespawnCmd extends AbstractDevCmd {
|
||||
|
||||
public DespawnCmd() {
|
||||
super("debugmob");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
|
||||
|
||||
if (pc == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Mob mob = null;
|
||||
|
||||
if (target != null && target.getObjectType().equals(GameObjectType.Mob))
|
||||
mob = (Mob) target;
|
||||
|
||||
if (mob == null)
|
||||
mob = Mob.getFromCache(Integer.parseInt(words[1]));
|
||||
|
||||
if (mob == null)
|
||||
return;
|
||||
|
||||
if (words[0].equalsIgnoreCase("respawn")) {
|
||||
mob.respawn();
|
||||
this.throwbackInfo(pc, "Mob with ID " + mob.getObjectUUID() + " Respawned");
|
||||
} else if (words[0].equalsIgnoreCase("despawn")) {
|
||||
mob.despawn();
|
||||
this.throwbackInfo(pc, "Mob with ID " + mob.getObjectUUID() + " Despawned");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Gets distance from a target.";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /distance'";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.AbstractWorldObject;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
public class DistanceCmd extends AbstractDevCmd {
|
||||
|
||||
public DistanceCmd() {
|
||||
super("distance");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
|
||||
|
||||
// Arg Count Check
|
||||
if (words.length != 1) {
|
||||
this.sendUsage(pc);
|
||||
return;
|
||||
}
|
||||
if (pc == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (target == null || !(target instanceof AbstractWorldObject)) {
|
||||
throwbackError(pc, "No target found.");
|
||||
return;
|
||||
}
|
||||
|
||||
AbstractWorldObject awoTarget = (AbstractWorldObject) target;
|
||||
|
||||
Vector3fImmutable pcLoc = pc.getLoc();
|
||||
Vector3fImmutable tarLoc = awoTarget.getLoc();
|
||||
String out = "Distance: " + pcLoc.distance(tarLoc) +
|
||||
"\r\nYour Loc: " + pcLoc.x + 'x' + pcLoc.y + 'x' + pcLoc.z +
|
||||
"\r\nTarget Loc: " + tarLoc.x + 'x' + tarLoc.y + 'x' + tarLoc.z;
|
||||
throwbackInfo(pc, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Gets distance from a target.";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /distance'";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.powers.EffectsBase;
|
||||
|
||||
/**
|
||||
* @author Eighty
|
||||
*/
|
||||
public class EffectCmd extends AbstractDevCmd {
|
||||
|
||||
public EffectCmd() {
|
||||
super("effect");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pcSender, String[] args,
|
||||
AbstractGameObject target) {
|
||||
int ID = 0;
|
||||
int token = 0;
|
||||
|
||||
if (args.length != 2) {
|
||||
this.sendUsage(pcSender);
|
||||
return;
|
||||
}
|
||||
ID = Integer.parseInt(args[0]);
|
||||
token = Integer.parseInt(args[1]);
|
||||
|
||||
EffectsBase eb = PowersManager.setEffectToken(ID, token);
|
||||
if (eb == null) {
|
||||
throwbackError(pcSender, "Unable to find EffectsBase " + ID
|
||||
+ " to modify.");
|
||||
return;
|
||||
}
|
||||
ChatManager.chatSayInfo(pcSender,
|
||||
"EffectsBase with ID " + ID + " changed token to " + token);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /effect EffectsBaseID Token'";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Temporarily places the effect token with the corresponding EffectsBase on the server";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.objects.*;
|
||||
|
||||
public class EnchantCmd extends AbstractDevCmd {
|
||||
|
||||
public EnchantCmd() {
|
||||
super("enchant");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
int rank = 0;
|
||||
if (words.length < 1) {
|
||||
this.sendUsage(pc);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
rank = Integer.parseInt(words[0]);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
Item item;
|
||||
if (target == null || target instanceof Item)
|
||||
item = (Item) target;
|
||||
else {
|
||||
throwbackError(pc, "Must have an item targeted");
|
||||
return;
|
||||
}
|
||||
|
||||
CharacterItemManager cim = pc.getCharItemManager();
|
||||
if (cim == null) {
|
||||
throwbackError(pc, "Unable to find the character item manager for player " + pc.getFirstName() + '.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (words[0].equals("clear")) {
|
||||
item.clearEnchantments();
|
||||
cim.updateInventory();
|
||||
this.setResult(String.valueOf(item.getObjectUUID()));
|
||||
} else {
|
||||
int cnt = words.length;
|
||||
for (int i = 1; i < cnt; i++) {
|
||||
String enchant = words[i];
|
||||
boolean valid = true;
|
||||
for (Effect eff : item.getEffects().values()) {
|
||||
if (eff.getEffectsBase().getIDString().equals(enchant)) {
|
||||
throwbackError(pc, "This item already has that enchantment");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (valid) {
|
||||
item.addPermanentEnchantmentForDev(enchant, rank);
|
||||
this.setResult(String.valueOf(item.getObjectUUID()));
|
||||
} else
|
||||
throwbackError(pc, "Invalid Enchantment. Enchantment must consist of SUF-001 to SUF-328 or PRE-001 to PRE-334. Sent " + enchant + '.');
|
||||
}
|
||||
cim.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Enchants an item with a prefix and suffix";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /enchant clear/Enchant1 Enchant2 Enchant3 ...'";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum.BuildingGroup;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
|
||||
public class GateInfoCmd extends AbstractDevCmd {
|
||||
|
||||
public GateInfoCmd() {
|
||||
super("gateinfo");
|
||||
}
|
||||
|
||||
// AbstractDevCmd Overridden methods
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter player, String[] args,
|
||||
AbstractGameObject target) {
|
||||
|
||||
Building targetBuilding;
|
||||
String outString;
|
||||
Runegate runeGate;
|
||||
Blueprint blueprint;
|
||||
String newline = "\r\n ";
|
||||
targetBuilding = (Building) target;
|
||||
|
||||
if (targetBuilding.getObjectType() != GameObjectType.Building) {
|
||||
throwbackInfo(player, "GateInfo: target must be a Building");
|
||||
throwbackInfo(player, "Found" + targetBuilding.getObjectType().toString());
|
||||
return;
|
||||
}
|
||||
|
||||
blueprint = Blueprint._meshLookup.get(targetBuilding.getMeshUUID());
|
||||
|
||||
if (blueprint == null ||
|
||||
(blueprint.getBuildingGroup() != BuildingGroup.RUNEGATE)) {
|
||||
throwbackInfo(player, "showgate: target must be a Runegate");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
runeGate = Runegate._runegates.get(targetBuilding.getObjectUUID());
|
||||
|
||||
outString = "RungateType: " + runeGate.gateBuilding.getName();
|
||||
outString += newline;
|
||||
|
||||
outString += "Portal State:";
|
||||
outString += newline;
|
||||
|
||||
for (Portal portal : runeGate.getPortals()) {
|
||||
|
||||
outString += "Portal: " + portal.portalType.name();
|
||||
outString += " Active: " + portal.isActive();
|
||||
outString += " Dest: " + portal.targetGate.getName();
|
||||
outString += newline;
|
||||
outString += " Origin: " + portal.getPortalLocation().x + 'x';
|
||||
outString += " " + portal.getPortalLocation().y + 'y';
|
||||
outString += newline;
|
||||
|
||||
Vector3fImmutable offset = portal.getPortalLocation().subtract(targetBuilding.getLoc());
|
||||
outString += " Offset: " + offset.x + "x " + offset.z + 'y';
|
||||
outString += newline;
|
||||
outString += newline;
|
||||
|
||||
}
|
||||
outString += newline;
|
||||
throwbackInfo(player, outString);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Displays a runegate's gate status";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
|
||||
|
||||
return "/gateinfo <target runegate> \n";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.VendorDialogMsg;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
/**
|
||||
* @author Eighty
|
||||
*/
|
||||
public class GetBankCmd extends AbstractDevCmd {
|
||||
|
||||
public GetBankCmd() {
|
||||
super("getbank");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pcSender, String[] args,
|
||||
AbstractGameObject target) {
|
||||
if (pcSender == null)
|
||||
return;
|
||||
|
||||
ClientConnection cc = SessionManager.getClientConnection(pcSender);
|
||||
if (cc == null)
|
||||
return;
|
||||
|
||||
VendorDialogMsg.getBank(pcSender, null, cc);
|
||||
this.setTarget(pcSender); //for logging
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /getbank'";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Opens bank window";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
public class GetMemoryCmd extends AbstractDevCmd {
|
||||
|
||||
public GetMemoryCmd() {
|
||||
super("getmemory");
|
||||
}
|
||||
|
||||
public static String getMemoryOutput(long memory) {
|
||||
String out = "";
|
||||
if (memory > 1073741824)
|
||||
return (memory / 1073741824) + "GB";
|
||||
else if (memory > 1048576)
|
||||
return (memory / 1048576) + "MB";
|
||||
else if (memory > 1024)
|
||||
return (memory / 1048576) + "KB";
|
||||
else
|
||||
return memory + "B";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pcSender, String[] words,
|
||||
AbstractGameObject target) {
|
||||
if (pcSender == null)
|
||||
return;
|
||||
|
||||
String hSize = getMemoryOutput(Runtime.getRuntime().totalMemory());
|
||||
String mhSize = getMemoryOutput(Runtime.getRuntime().maxMemory());
|
||||
String fhSize = getMemoryOutput(Runtime.getRuntime().freeMemory());
|
||||
|
||||
String out = "Heap Size: " + hSize + ", Max Heap Size: " + mhSize + ", Free Heap Size: " + fhSize;
|
||||
throwbackInfo(pcSender, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /getmemory'";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "lists memory usage";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ package engine.devcmd.cmds;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.VendorDialogMsg;
|
||||
import engine.net.client.handlers.VendorDialogMsgHandler;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class GetVaultCmd extends AbstractDevCmd {
|
||||
if (cc == null)
|
||||
return;
|
||||
|
||||
VendorDialogMsg.getVault(pcSender, null, cc);
|
||||
VendorDialogMsgHandler.getVault(pcSender, null, cc);
|
||||
this.setTarget(pcSender); //for logging
|
||||
}
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// 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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GetZoneCmd extends AbstractDevCmd {
|
||||
|
||||
public GetZoneCmd() {
|
||||
super("getzone");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pcSender, String[] words,
|
||||
AbstractGameObject target) {
|
||||
if (pcSender == null)
|
||||
return;
|
||||
|
||||
if (words.length != 1) {
|
||||
this.sendUsage(pcSender);
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<Zone> allIn = new ArrayList<>();
|
||||
switch (words[0].toLowerCase()) {
|
||||
case "all":
|
||||
throwbackInfo(pcSender, "All zones currently in");
|
||||
allIn = ZoneManager.getAllZonesIn(pcSender.getLoc());
|
||||
break;
|
||||
case "smallest":
|
||||
throwbackInfo(pcSender, "Smallest zone currently in");
|
||||
Zone zone = ZoneManager.findSmallestZone(pcSender.getLoc());
|
||||
allIn.add(zone);
|
||||
break;
|
||||
default:
|
||||
this.sendUsage(pcSender);
|
||||
return;
|
||||
}
|
||||
|
||||
for (Zone zone : allIn)
|
||||
throwbackInfo(pcSender, zone.zoneName + "; UUID: " + zone.getObjectUUID() + ", loadNum: " + zone.templateID);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /getzone smallest/all'";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "lists what zones a player is in";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.Building;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
public class GotoBoundsCmd extends AbstractDevCmd {
|
||||
|
||||
public GotoBoundsCmd() {
|
||||
super("gotobounds");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter player, String[] words,
|
||||
AbstractGameObject target) {
|
||||
|
||||
String corner = words[0];
|
||||
Vector3fImmutable targetLoc = Vector3fImmutable.ZERO;
|
||||
|
||||
if (target == null || !target.getObjectType().equals(GameObjectType.Building)) {
|
||||
this.throwbackError(player, "No Building Selected");
|
||||
return;
|
||||
}
|
||||
|
||||
Building building = (Building) target;
|
||||
|
||||
if (building.getBounds() == null) {
|
||||
this.throwbackInfo(player, "No valid Bounds for building UUID " + building.getObjectUUID());
|
||||
return;
|
||||
}
|
||||
float x = building.getBounds().getHalfExtents().x;
|
||||
float z = building.getBounds().getHalfExtents().y;
|
||||
|
||||
if (building.getBlueprint() != null) {
|
||||
x = building.getBlueprint().getExtents().x;
|
||||
z = building.getBlueprint().getExtents().y;
|
||||
}
|
||||
|
||||
float topLeftX = building.getLoc().x - x;
|
||||
float topLeftY = building.getLoc().z - z;
|
||||
|
||||
float topRightX = building.getLoc().x + x;
|
||||
float topRightY = building.getLoc().z - z;
|
||||
|
||||
float bottomLeftX = building.getLoc().x - x;
|
||||
float bottomLeftY = building.getLoc().z + z;
|
||||
|
||||
float bottomRightX = building.getLoc().x + x;
|
||||
float bottomRightY = building.getLoc().z + z;
|
||||
|
||||
|
||||
switch (corner) {
|
||||
case "topleft":
|
||||
targetLoc = new Vector3fImmutable(topLeftX, 0, topLeftY);
|
||||
break;
|
||||
case "topright":
|
||||
targetLoc = new Vector3fImmutable(topRightX, 0, topRightY);
|
||||
break;
|
||||
case "bottomleft":
|
||||
targetLoc = new Vector3fImmutable(bottomLeftX, 0, bottomLeftY);
|
||||
break;
|
||||
case "bottomright":
|
||||
targetLoc = new Vector3fImmutable(bottomRightX, 0, bottomRightY);
|
||||
break;
|
||||
default:
|
||||
this.throwbackInfo(player, "wrong corner name. use topleft , topright , bottomleft , bottomright");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
targetLoc = Vector3fImmutable.transform(building.getLoc(), targetLoc, building.getBounds().getRotationDegrees());
|
||||
|
||||
// Teleport player
|
||||
|
||||
if (targetLoc == Vector3fImmutable.ZERO) {
|
||||
this.throwbackError(player, "Failed to locate UUID");
|
||||
return;
|
||||
}
|
||||
|
||||
player.teleport(targetLoc);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Teleports player to a UUID";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /gotoobj <UID>'";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -253,9 +253,9 @@ public class InfoCmd extends AbstractDevCmd {
|
||||
output += newline;
|
||||
output += "InSession : " + SessionManager.getPlayerCharacterByID(target.getObjectUUID()) != null ? " true " : " false";
|
||||
output += newline;
|
||||
output += "RaceType: " + targetPC.getRace().getRaceType().name();
|
||||
output += "RaceType: " + targetPC.race.getRaceType().name();
|
||||
output += newline;
|
||||
output += "Race: " + targetPC.getRace().getName();
|
||||
output += "Race: " + targetPC.race.getName();
|
||||
output += newline;
|
||||
output += "Safe:" + targetPC.inSafeZone();
|
||||
output += newline;
|
||||
@@ -278,7 +278,7 @@ public class InfoCmd extends AbstractDevCmd {
|
||||
output += "Account ID: UNKNOWN";
|
||||
|
||||
output += newline;
|
||||
output += "Inventory Weight:" + (targetPC.getCharItemManager().getInventoryWeight() + targetPC.getCharItemManager().getEquipWeight());
|
||||
output += "Inventory Weight:" + (targetPC.charItemManager.getInventoryWeight() + targetPC.charItemManager.getEquipWeight());
|
||||
output += newline;
|
||||
output += "Max Inventory Weight:" + ((int) targetPC.statStrBase * 3);
|
||||
output += newline;
|
||||
@@ -291,7 +291,7 @@ public class InfoCmd extends AbstractDevCmd {
|
||||
output += "inFloor :" + targetPC.getInFloorID();
|
||||
output += newline;
|
||||
|
||||
BaseClass baseClass = targetPC.getBaseClass();
|
||||
BaseClass baseClass = targetPC.baseClass;
|
||||
|
||||
if (baseClass != null)
|
||||
output += StringUtils.addWS("Class: " + baseClass.getName(), 20);
|
||||
@@ -494,28 +494,28 @@ public class InfoCmd extends AbstractDevCmd {
|
||||
output += newline;
|
||||
output += "No building found." + newline;
|
||||
}
|
||||
int max = (int)(4.882 * targetMob.level + 121.0);
|
||||
if(max > 321){
|
||||
int max = (int) (4.882 * targetMob.level + 121.0);
|
||||
if (max > 321) {
|
||||
max = 321;
|
||||
}
|
||||
int min = (int)(4.469 * targetMob.level - 3.469);
|
||||
int min = (int) (4.469 * targetMob.level - 3.469);
|
||||
output += "Min Loot Roll = " + min;
|
||||
output += "Max Loot Roll = " + max;
|
||||
break;
|
||||
case Item: //intentional passthrough
|
||||
case MobLoot:
|
||||
Item item = (Item) target;
|
||||
ItemBase itemBase = item.getItemBase();
|
||||
output += StringUtils.addWS("ItemBase: " + itemBase.getUUID(), 20);
|
||||
output += "Weight: " + itemBase.getWeight();
|
||||
ItemTemplate template = ItemTemplate.templates.get(item.templateID);
|
||||
output += StringUtils.addWS("Template: " + template.template_id, 20);
|
||||
output += "Weight: " + template.item_wt;
|
||||
output += newline;
|
||||
DecimalFormat df = new DecimalFormat("###,###,###,###,##0");
|
||||
output += StringUtils.addWS("Qty: "
|
||||
+ df.format(item.getNumOfItems()), 20);
|
||||
output += "Charges: " + item.getChargesRemaining()
|
||||
+ '/' + item.getChargesMax();
|
||||
output += "Charges: " + (byte) item.chargesRemaining
|
||||
+ '/' + item.template.item_initial_charges;
|
||||
output += newline;
|
||||
output += "Name: " + itemBase.getName();
|
||||
output += "Name: " + template.item_base_name;
|
||||
output += newline;
|
||||
output += item.getContainerInfo();
|
||||
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.Enum.BuildingGroup;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.Enum.TargetColor;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
import engine.util.StringUtils;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
/**
|
||||
* @author
|
||||
*/
|
||||
public class ItemInfoCmd extends AbstractDevCmd {
|
||||
|
||||
public ItemInfoCmd() {
|
||||
super("iteminfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,AbstractGameObject target) {
|
||||
if (pc == null) {
|
||||
return;
|
||||
}
|
||||
if(target.getObjectType().equals(GameObjectType.Item) == false){
|
||||
throwbackInfo(pc, "Must Select An Item");
|
||||
return;
|
||||
}
|
||||
Item item = (Item)target;
|
||||
String newline = "\r\n ";
|
||||
String output = "";
|
||||
output += "Required Races:" + newline;
|
||||
for(Enum.MonsterType required : item.getItemBase().requiredRaces)
|
||||
output += " " + required.name() + newline;
|
||||
output += "Restricted Races:" + newline;
|
||||
for(Enum.MonsterType required : item.getItemBase().restrictedRaces)
|
||||
output += " " + required.name() + newline;
|
||||
output += "Required Classes:" + newline;
|
||||
for(Enum.ClassType required : item.getItemBase().requiredClasses)
|
||||
output += " " + required.name() + newline;
|
||||
output += "Restricted Classes:" + newline;
|
||||
for(Enum.ClassType required : item.getItemBase().restrictedClasses)
|
||||
output += " " + required.name() + newline;
|
||||
output += "Required Disciplines:" + newline;
|
||||
for(Enum.DisciplineType required : item.getItemBase().requiredDiscs)
|
||||
output += " " + required.name() + newline;
|
||||
output += "Restricted Disciplines:" + newline;
|
||||
for(Enum.DisciplineType required : item.getItemBase().restrictedDiscs)
|
||||
output += " " + required.name() + newline;
|
||||
throwbackInfo(pc, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Gets information on an Object.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /iteminfo'";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum.ItemContainerType;
|
||||
import engine.Enum.ItemType;
|
||||
import engine.Enum.OwnerType;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
@@ -17,8 +16,6 @@ import engine.gameManager.DbManager;
|
||||
import engine.objects.*;
|
||||
import engine.powers.EffectsBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author Eighty
|
||||
*/
|
||||
@@ -32,48 +29,6 @@ public class MakeItemCmd extends AbstractDevCmd {
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
|
||||
if (words[0].equals("resources")) {
|
||||
for (int ibID : Warehouse.getMaxResources().keySet()) {
|
||||
if (ibID == 7)
|
||||
continue;
|
||||
|
||||
ItemBase ib = ItemBase.getItemBase(ibID);
|
||||
|
||||
short weight = ib.getWeight();
|
||||
if (!pc.getCharItemManager().hasRoomInventory(weight)) {
|
||||
throwbackError(pc, "Not enough room in inventory for any more of this item");
|
||||
|
||||
pc.getCharItemManager().updateInventory();
|
||||
return;
|
||||
}
|
||||
|
||||
boolean worked = false;
|
||||
Item item = new Item(ib, pc.getObjectUUID(),
|
||||
OwnerType.PlayerCharacter, (byte) 0, (byte) 0, (short) ib.getDurability(), (short) ib.getDurability(),
|
||||
true, false, ItemContainerType.INVENTORY, (byte) 0,
|
||||
new ArrayList<>(), "");
|
||||
|
||||
item.setNumOfItems(Warehouse.getMaxResources().get(ibID));
|
||||
|
||||
try {
|
||||
item = DbManager.ItemQueries.ADD_ITEM(item);
|
||||
worked = true;
|
||||
} catch (Exception e) {
|
||||
throwbackError(pc, "DB error 1: Unable to create item. " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (item == null || !worked) {
|
||||
throwbackError(pc, "DB error 2: Unable to create item.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//add item to inventory
|
||||
pc.getCharItemManager().addItemToInventory(item);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (words.length < 3 || words.length > 5) {
|
||||
this.sendUsage(pc);
|
||||
return;
|
||||
@@ -103,16 +58,23 @@ public class MakeItemCmd extends AbstractDevCmd {
|
||||
numItems = (numItems > 5000) ? 5000 : numItems;
|
||||
}
|
||||
|
||||
int itembaseID;
|
||||
int templateID;
|
||||
ItemTemplate template;
|
||||
try {
|
||||
itembaseID = Integer.parseInt(words[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
itembaseID = ItemBase.getIDByName(words[0].toLowerCase());
|
||||
if (itembaseID == 0) {
|
||||
templateID = Integer.parseInt(words[0]);
|
||||
template = ItemTemplate.templates.get(words[0].toLowerCase());
|
||||
|
||||
if (template == null) {
|
||||
throwbackError(pc, "Supplied type " + words[0]
|
||||
+ " failed to parse to an Integer");
|
||||
return;
|
||||
}
|
||||
|
||||
if (template.item_type == ItemType.GOLD) {
|
||||
this.throwbackInfo(pc, "use /addgold to add gold.");
|
||||
return;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throwbackError(pc,
|
||||
"An unknown exception occurred when trying to use createitem command for type "
|
||||
@@ -120,10 +82,6 @@ public class MakeItemCmd extends AbstractDevCmd {
|
||||
return; // NaN
|
||||
}
|
||||
|
||||
if (itembaseID == 7) {
|
||||
this.throwbackInfo(pc, "use /addgold to add gold.");
|
||||
return;
|
||||
}
|
||||
|
||||
String prefix = "";
|
||||
String suffix = "";
|
||||
@@ -174,57 +132,54 @@ public class MakeItemCmd extends AbstractDevCmd {
|
||||
return;
|
||||
}
|
||||
}
|
||||
ItemBase ib = ItemBase.getItemBase(itembaseID);
|
||||
if (ib == null) {
|
||||
throwbackError(pc, "Unable to find itembase of ID " + itembaseID);
|
||||
template = ItemTemplate.templates.get(templateID);
|
||||
|
||||
if (template == null) {
|
||||
throwbackError(pc, "Unable to find template " + templateID);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((numItems > 1)
|
||||
&& (ib.getType().equals(ItemType.RESOURCE) == false)
|
||||
&& (ib.getType().equals(ItemType.OFFERING)) == false)
|
||||
&& (template.item_type.equals(ItemType.RESOURCE) == false)
|
||||
&& (template.item_type.equals(ItemType.OFFERING)) == false)
|
||||
numItems = 1;
|
||||
|
||||
CharacterItemManager cim = pc.getCharItemManager();
|
||||
CharacterItemManager cim = pc.charItemManager;
|
||||
|
||||
if (cim == null) {
|
||||
throwbackError(pc, "Unable to find the character item manager for player " + pc.getFirstName() + '.');
|
||||
return;
|
||||
}
|
||||
|
||||
byte charges = (byte) ib.getNumCharges();
|
||||
short dur = (short) ib.getDurability();
|
||||
|
||||
String result = "";
|
||||
|
||||
for (int i = 0; i < quantity; i++) {
|
||||
short weight = ib.getWeight();
|
||||
|
||||
int weight = template.item_wt;
|
||||
|
||||
if (!cim.hasRoomInventory(weight)) {
|
||||
throwbackError(pc, "Not enough room in inventory for any more of this item. " + i + " produced.");
|
||||
|
||||
if (i > 0)
|
||||
cim.updateInventory();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
boolean worked = false;
|
||||
Item item = new Item(ib, pc.getObjectUUID(),
|
||||
OwnerType.PlayerCharacter, charges, charges, dur, dur,
|
||||
true, false, ItemContainerType.INVENTORY, (byte) 0,
|
||||
new ArrayList<>(), "");
|
||||
Item item = new Item(templateID);
|
||||
item.ownerID = pc.getObjectUUID();
|
||||
item.ownerType = OwnerType.PlayerCharacter;
|
||||
|
||||
if (numItems > 1)
|
||||
item.setNumOfItems(numItems);
|
||||
|
||||
try {
|
||||
item = DbManager.ItemQueries.ADD_ITEM(item);
|
||||
worked = true;
|
||||
item = DbManager.ItemQueries.PERSIST(item);
|
||||
} catch (Exception e) {
|
||||
throwbackError(pc, "DB error 1: Unable to create item. " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (item == null || !worked) {
|
||||
throwbackError(pc, "DB error 2: Unable to create item.");
|
||||
return;
|
||||
}
|
||||
|
||||
//create prefix
|
||||
if (!prefix.isEmpty())
|
||||
item.addPermanentEnchantmentForDev(prefix, 0);
|
||||
@@ -243,12 +198,12 @@ public class MakeItemCmd extends AbstractDevCmd {
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Creates an item of type 'itembaseID' with a prefix and suffix";
|
||||
return "Creates an item of type templateID with a prefix and suffix";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "'./makeitem itembaseID PrefixID SuffixID [quantity] [numResources]'";
|
||||
return "'./makeitem templateID PrefixID SuffixID [quantity] [numResources]'";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,13 +47,17 @@ public class PrintBankCmd extends AbstractDevCmd {
|
||||
}
|
||||
|
||||
|
||||
CharacterItemManager cim = ((AbstractCharacter) tar).getCharItemManager();
|
||||
CharacterItemManager cim = ((AbstractCharacter) tar).charItemManager;
|
||||
ArrayList<Item> list = cim.getBank();
|
||||
throwbackInfo(pc, "Bank for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
||||
|
||||
for (Item item : list) {
|
||||
throwbackInfo(pc, " " + item.getItemBase().getName() + ", count: " + item.getNumOfItems());
|
||||
ItemTemplate template = ItemTemplate.templates.get(item.templateID);
|
||||
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems());
|
||||
}
|
||||
|
||||
Item gold = cim.getGoldBank();
|
||||
|
||||
if (gold != null)
|
||||
throwbackInfo(pc, " Gold, count: " + gold.getNumOfItems());
|
||||
else
|
||||
|
||||
@@ -33,7 +33,8 @@ public class PrintBonusesCmd extends AbstractDevCmd {
|
||||
if (target instanceof Item) {
|
||||
type = "Item";
|
||||
tar = (Item) target;
|
||||
name = ((Item) tar).getItemBase().getName();
|
||||
ItemTemplate template = ItemTemplate.templates.get(((Item) tar).templateID);
|
||||
name = template.item_base_name;
|
||||
} else if (target instanceof AbstractCharacter) {
|
||||
tar = (AbstractCharacter) target;
|
||||
name = ((AbstractCharacter) tar).getFirstName();
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.objects.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import engine.objects.AbstractCharacter;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -25,16 +25,6 @@ public class PrintEffectsCmd extends AbstractDevCmd {
|
||||
// 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) {
|
||||
@@ -47,7 +37,7 @@ public class PrintEffectsCmd extends AbstractDevCmd {
|
||||
String newline = "\r\n ";
|
||||
String output = "Effects For Character: " + tar.getName() + newline;
|
||||
|
||||
for(String effect : tar.effects.keySet()){
|
||||
for (String effect : tar.effects.keySet()) {
|
||||
output += effect + newline;
|
||||
}
|
||||
throwbackInfo(pc, output);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.objects.*;
|
||||
@@ -63,9 +64,9 @@ public class PrintEquipCmd extends AbstractDevCmd {
|
||||
if (tar.getObjectType() == GameObjectType.Mob) {
|
||||
Mob tarMob = (Mob) tar;
|
||||
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
||||
for (int slot : tarMob.getEquip().keySet()) {
|
||||
MobEquipment equip = tarMob.getEquip().get(slot);
|
||||
throwbackInfo(pc, equip.getItemBase().getUUID() + " : " + equip.getItemBase().getName() + ", slot: " + slot);
|
||||
for (Enum.EquipSlotType slot : tarMob.charItemManager.equipped.keySet()) {
|
||||
Item equip = tarMob.charItemManager.equipped.get(slot);
|
||||
throwbackInfo(pc, equip.templateID + " : " + equip.template.item_base_name + ", slot: " + slot);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -73,19 +74,20 @@ public class PrintEquipCmd extends AbstractDevCmd {
|
||||
if (tar.getObjectType() == GameObjectType.NPC) {
|
||||
NPC tarMob = (NPC) tar;
|
||||
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
||||
for (int slot : tarMob.getEquip().keySet()) {
|
||||
MobEquipment equip = tarMob.getEquip().get(slot);
|
||||
throwbackInfo(pc, equip.getItemBase().getUUID() + " : " + equip.getItemBase().getName() + ", slot: " + slot);
|
||||
for (Enum.EquipSlotType slot : tarMob.charItemManager.equipped.keySet()) {
|
||||
Item equip = tarMob.charItemManager.equipped.get(slot);
|
||||
throwbackInfo(pc, equip.templateID + " : " + equip.template.item_base_name + ", slot: " + slot);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
CharacterItemManager cim = ((AbstractCharacter) tar).getCharItemManager();
|
||||
ConcurrentHashMap<Integer, Item> list = cim.getEquipped();
|
||||
CharacterItemManager cim = ((AbstractCharacter) tar).charItemManager;
|
||||
ConcurrentHashMap<Enum.EquipSlotType, Item> list = cim.getEquipped();
|
||||
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
||||
for (Integer slot : list.keySet()) {
|
||||
|
||||
for (Enum.EquipSlotType slot : list.keySet()) {
|
||||
Item item = list.get(slot);
|
||||
throwbackInfo(pc, " " + item.getItemBase().getName() + ", slot: " + slot);
|
||||
throwbackInfo(pc, " " + item.template.item_base_name + ", slot: " + slot);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public class PrintInventoryCmd extends AbstractDevCmd {
|
||||
}
|
||||
}
|
||||
|
||||
CharacterItemManager cim = tar.getCharItemManager();
|
||||
CharacterItemManager cim = tar.charItemManager;
|
||||
inventory = cim.getInventory(); //this list can contain gold when tar is a PC that is dead
|
||||
gold = cim.getGoldInventory();
|
||||
throwbackInfo(pc, " Weight : " + (cim.getInventoryWeight() + cim.getEquipWeight()));
|
||||
@@ -75,14 +75,18 @@ public class PrintInventoryCmd extends AbstractDevCmd {
|
||||
int goldCount = 0;
|
||||
|
||||
for (Item item : inventory) {
|
||||
if (item.getItemBase().getType().equals(ItemType.GOLD) == false) {
|
||||
ItemTemplate template = ItemTemplate.templates.get(item.templateID);
|
||||
|
||||
if (item.template.item_type.equals(ItemType.GOLD) == false) {
|
||||
|
||||
String chargeInfo = "";
|
||||
byte chargeMax = item.getChargesMax();
|
||||
int chargeMax = template.item_initial_charges;
|
||||
|
||||
if (chargeMax > 0) {
|
||||
byte charges = item.getChargesRemaining();
|
||||
int charges = item.chargesRemaining;
|
||||
chargeInfo = " charges: " + charges + '/' + chargeMax;
|
||||
}
|
||||
throwbackInfo(pc, " " + item.getItemBase().getName() + ", count: " + item.getNumOfItems() + chargeInfo);
|
||||
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems() + chargeInfo);
|
||||
} else
|
||||
goldCount += item.getNumOfItems();
|
||||
}
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.objects.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import engine.objects.AbstractCharacter;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.CharacterRune;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -25,16 +26,6 @@ public class PrintRunesCmd extends AbstractDevCmd {
|
||||
// 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) {
|
||||
@@ -47,7 +38,7 @@ public class PrintRunesCmd extends AbstractDevCmd {
|
||||
String newline = "\r\n ";
|
||||
String output = "Applied Runes For Character: " + ((AbstractCharacter) target).getName() + newline;
|
||||
|
||||
for(CharacterRune rune : ((AbstractCharacter)target).runes){
|
||||
for (CharacterRune rune : ((AbstractCharacter) target).runes) {
|
||||
output += rune.getRuneBaseID() + " " + rune.getRuneBase().getName() + newline;
|
||||
}
|
||||
throwbackInfo(pc, output);
|
||||
|
||||
@@ -9,11 +9,10 @@
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.objects.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -22,17 +21,6 @@ public class PrintStatsCmd extends AbstractDevCmd {
|
||||
|
||||
public PrintStatsCmd() {
|
||||
super("printstats");
|
||||
// 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
|
||||
@@ -76,11 +64,12 @@ public class PrintStatsCmd extends AbstractDevCmd {
|
||||
}
|
||||
|
||||
public void printStatsMob(PlayerCharacter pc, Mob tar) {
|
||||
|
||||
MobBase mb = tar.getMobBase();
|
||||
|
||||
if (mb == null)
|
||||
return;
|
||||
|
||||
|
||||
String newline = "\r\n ";
|
||||
String out = "Server stats for Mob " + mb.getFirstName() + newline;
|
||||
out += "Stats Base (Modified)" + newline;
|
||||
@@ -96,27 +85,21 @@ public class PrintStatsCmd extends AbstractDevCmd {
|
||||
out += "Defense: " + tar.getDefenseRating() + newline;
|
||||
|
||||
//get weapons
|
||||
HashMap<Integer, MobEquipment> equip = tar.getEquip();
|
||||
ItemBase main = null;
|
||||
|
||||
if (equip != null)
|
||||
main = getWeaponBase(1, equip);
|
||||
ItemBase off = null;
|
||||
|
||||
if(equip != null){
|
||||
if(equip.get(2) != null && !equip.get(2).getItemBase().isShield()){
|
||||
if (tar.charItemManager.equipped.isEmpty() == false)
|
||||
if (tar.charItemManager.equipped.get(Enum.EquipSlotType.LHELD) != null && !ItemTemplate.isShield(tar.charItemManager.equipped.get(Enum.EquipSlotType.LHELD))) {
|
||||
//off hand weapon
|
||||
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{
|
||||
out += "Attack Rating: " + tar.atrHandOne + newline;
|
||||
out += "Damage: " + tar.minDamageHandOne + " - " + tar.maxDamageHandOne + newline;
|
||||
out += "Range: " + tar.rangeHandOne + newline;
|
||||
out += "Attack Speed: " + tar.speedHandOne + newline;
|
||||
out += "Attack Speed: " + tar.speedHandTwo + newline;
|
||||
} else {
|
||||
out += "Attack Rating: " + tar.atrHandOne + newline;
|
||||
out += "Damage: " + tar.minDamageHandOne + " - " + tar.maxDamageHandOne + newline;
|
||||
out += "Range: " + tar.rangeHandOne + newline;
|
||||
out += "Attack Speed: " + tar.speedHandOne + newline;
|
||||
}
|
||||
}
|
||||
|
||||
out += "isAlive: " + tar.isAlive() + ", Combat: " + tar.isCombat() + newline;
|
||||
|
||||
throwbackInfo(pc, out);
|
||||
|
||||
@@ -46,11 +46,12 @@ public class PrintVaultCmd extends AbstractDevCmd {
|
||||
}
|
||||
|
||||
|
||||
CharacterItemManager cim = ((AbstractCharacter) tar).getCharItemManager();
|
||||
CharacterItemManager cim = ((AbstractCharacter) tar).charItemManager;
|
||||
ArrayList<Item> list = cim.getVault();
|
||||
throwbackInfo(pc, "Vault for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
||||
for (Item item : list) {
|
||||
throwbackInfo(pc, " " + item.getItemBase().getName() + ", count: " + item.getNumOfItems());
|
||||
ItemTemplate template = ItemTemplate.templates.get(item.templateID);
|
||||
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems());
|
||||
}
|
||||
Item gold = cim.getGoldVault();
|
||||
if (gold != null)
|
||||
|
||||
@@ -9,13 +9,10 @@
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.objects.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class RegionCmd extends AbstractDevCmd {
|
||||
|
||||
public RegionCmd() {
|
||||
@@ -31,20 +28,20 @@ public class RegionCmd extends AbstractDevCmd {
|
||||
output = "Target Region Information:" + newline;
|
||||
|
||||
Building building = BuildingManager.getBuildingAtLocation(((AbstractCharacter) target).loc);
|
||||
if(building == null){
|
||||
this.throwbackInfo(pc, "No Building At This Location.") ;
|
||||
if (building == null) {
|
||||
this.throwbackInfo(pc, "No Building At This Location.");
|
||||
}
|
||||
Regions region = ((AbstractCharacter)target).region;
|
||||
Regions region = ((AbstractCharacter) target).region;
|
||||
if (region == null) {
|
||||
this.throwbackInfo(pc, "No Region Found.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(region != null) {
|
||||
if (region != null) {
|
||||
output += "Player Info: " + ((AbstractCharacter) target).getName() + newline;
|
||||
output += "Region Building: " + building.getName() + newline;
|
||||
output += "Region Height: " + region.lerpY((AbstractCharacter)target) + newline;
|
||||
output += "is Stairs: " + region.isStairs() + newline;
|
||||
output += "Region Building: " + building.getName() + newline;
|
||||
output += "Region Height: " + region.lerpY((AbstractCharacter) target) + newline;
|
||||
output += "is Stairs: " + region.isStairs() + newline;
|
||||
output += "is Outside: " + region.isOutside();
|
||||
this.throwbackInfo(pc, output);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,10 @@ import engine.Enum.BuildingGroup;
|
||||
import engine.Enum.DbObjectType;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.*;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
|
||||
@@ -128,10 +131,10 @@ public class RemoveObjectCmd extends AbstractDevCmd {
|
||||
|
||||
if ((building.getBlueprint() != null) && (building.getBlueprint().getBuildingGroup() == BuildingGroup.WAREHOUSE)) {
|
||||
City city = City.getCity(building.getParentZone().playerCityUUID);
|
||||
if (city != null) {
|
||||
city.setWarehouseBuildingID(0);
|
||||
}
|
||||
Warehouse.warehouseByBuildingUUID.remove(building.getObjectUUID());
|
||||
|
||||
DbManager.WarehouseQueries.DELETE_WAREHOUSE(city.warehouse);
|
||||
city.warehouse = null;
|
||||
|
||||
}
|
||||
|
||||
//remove cached shrines.
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
public class ResetLevelCmd extends AbstractDevCmd {
|
||||
|
||||
public ResetLevelCmd() {
|
||||
super("resetlevel");
|
||||
}
|
||||
|
||||
// AbstractDevCmd Overridden methods
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter player, String[] args,
|
||||
AbstractGameObject target) {
|
||||
|
||||
player.ResetLevel(Short.parseShort(args[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Resets character level to `level`. All training points are reset. Player must relog for changes to update.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
|
||||
|
||||
return "/resetlevel <level>";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.gameManager.MaintenanceManager;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.Building;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class SetMaintCmd extends AbstractDevCmd {
|
||||
|
||||
public SetMaintCmd() {
|
||||
super("setMaint");
|
||||
this.addCmdString("setmaint");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter player, String[] words,
|
||||
AbstractGameObject target) {
|
||||
|
||||
if (!target.getObjectType().equals(Enum.GameObjectType.Building)) {
|
||||
ChatManager.chatSayInfo(player, "Target is not a valid building");
|
||||
return;
|
||||
}
|
||||
|
||||
Building targetBuilding = (Building) target;
|
||||
|
||||
if (targetBuilding.getProtectionState().equals(Enum.ProtectionState.NPC)) {
|
||||
ChatManager.chatSayInfo(player, "Target is not a valid building");
|
||||
return;
|
||||
}
|
||||
|
||||
MaintenanceManager.setMaintDateTime(targetBuilding, LocalDateTime.now().minusDays(1).withHour(13).withMinute(0).withSecond(0).withNano(0));
|
||||
ChatManager.chatSayInfo(player, "Maint will run for UUID: " + targetBuilding.getObjectUUID());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Sets the Rank of either the targets object or the object specified by ID.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /setrank ID rank' || ' /setrank rank' || ' /rank ID rank' || ' /rank rank'";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.Building;
|
||||
import engine.objects.Mine;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
/**
|
||||
* @author Eighty
|
||||
*/
|
||||
public class SetMineExpansion extends AbstractDevCmd {
|
||||
|
||||
public SetMineExpansion() {
|
||||
super("setexpansion");
|
||||
this.addCmdString("setexpansion");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pcSender, String[] args,
|
||||
AbstractGameObject target) {
|
||||
|
||||
|
||||
if (target.getObjectType() != GameObjectType.Building)
|
||||
return;
|
||||
Building mineBuilding = BuildingManager.getBuilding(target.getObjectUUID());
|
||||
if (mineBuilding == null)
|
||||
return;
|
||||
Mine mine = Mine.getMineFromTower(mineBuilding.getObjectUUID());
|
||||
if (mine == null)
|
||||
return;
|
||||
int bit = 2;
|
||||
switch (args[0].toUpperCase()) {
|
||||
case "ON":
|
||||
|
||||
bit |= mine.getFlags();
|
||||
if (!DbManager.MineQueries.SET_FLAGS(mine, bit))
|
||||
return;
|
||||
mine.setFlags(bit);
|
||||
ChatManager.chatSystemInfo(pcSender, mine.getZoneName() + "'s " + mine.getMineType().name + " is now an expansion mine.");
|
||||
break;
|
||||
|
||||
case "OFF":
|
||||
bit &= ~mine.getFlags();
|
||||
if (!DbManager.MineQueries.SET_FLAGS(mine, bit))
|
||||
return;
|
||||
mine.setFlags(bit);
|
||||
ChatManager.chatSystemInfo(pcSender, mine.getZoneName() + "'s " + mine.getMineType().name + " is no longer an expansion mine.");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /setmineexpansion on|off";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "enables or disables an expansion type for a mine.";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.objects.*;
|
||||
|
||||
/**
|
||||
* @author Eighty
|
||||
*/
|
||||
public class SetMineTypeCmd extends AbstractDevCmd {
|
||||
|
||||
public SetMineTypeCmd() {
|
||||
super("setminetype");
|
||||
this.addCmdString("setminetype");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pcSender, String[] args,
|
||||
AbstractGameObject target) {
|
||||
|
||||
MineProduction mineType = MineProduction.valueOf(args[0].toUpperCase());
|
||||
if (mineType == null)
|
||||
return;
|
||||
|
||||
if (target.getObjectType() != GameObjectType.Building)
|
||||
return;
|
||||
Building mineBuilding = BuildingManager.getBuilding(target.getObjectUUID());
|
||||
if (mineBuilding == null)
|
||||
return;
|
||||
Mine mine = Mine.getMineFromTower(mineBuilding.getObjectUUID());
|
||||
if (mine == null)
|
||||
return;
|
||||
if (!DbManager.MineQueries.CHANGE_TYPE(mine, mineType))
|
||||
return;
|
||||
mine.setMineType(mineType.name());
|
||||
ChatManager.chatSystemInfo(pcSender, "The mine in " + mine.getZoneName() + " is now a(n) " + mine.getMineType().name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /setminetype gold|ore|magic|lumber";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Changes the mine type of the current mine.";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.MobBase;
|
||||
import engine.objects.NPC;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
public class SetNpcEquipSetCmd extends AbstractDevCmd {
|
||||
|
||||
public static int lastEquipSetID = 0;
|
||||
|
||||
public SetNpcEquipSetCmd() {
|
||||
super("setEquipSet");
|
||||
this.addCmdString("equipset");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
// Arg Count Check
|
||||
if (words.length != 1) {
|
||||
this.sendUsage(pc);
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.getObjectType() != GameObjectType.NPC) {
|
||||
this.sendUsage(pc);
|
||||
return;
|
||||
}
|
||||
|
||||
NPC npc = (NPC) target;
|
||||
|
||||
if (words[0].equalsIgnoreCase("next")) {
|
||||
|
||||
if (SetNpcEquipSetCmd.lastEquipSetID >= 1222)
|
||||
SetNpcEquipSetCmd.lastEquipSetID = 1;
|
||||
else
|
||||
SetNpcEquipSetCmd.lastEquipSetID++;
|
||||
|
||||
boolean complete = false;
|
||||
|
||||
while (complete == false) {
|
||||
complete = NPC.UpdateEquipSetID(npc, SetNpcEquipSetCmd.lastEquipSetID);
|
||||
|
||||
if (!complete) {
|
||||
SetNpcEquipSetCmd.lastEquipSetID++;
|
||||
if (SetNpcEquipSetCmd.lastEquipSetID >= 1222)
|
||||
SetNpcEquipSetCmd.lastEquipSetID = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (complete) {
|
||||
npc.equip = MobBase.loadEquipmentSet(npc.getEquipmentSetID());
|
||||
WorldGrid.updateObject(npc);
|
||||
this.throwbackInfo(pc, "Equipment Set Changed to " + SetNpcEquipSetCmd.lastEquipSetID);
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (words[0].equalsIgnoreCase("last")) {
|
||||
|
||||
if (SetNpcEquipSetCmd.lastEquipSetID <= 1)
|
||||
SetNpcEquipSetCmd.lastEquipSetID = 1222;
|
||||
else
|
||||
SetNpcEquipSetCmd.lastEquipSetID--;
|
||||
|
||||
boolean complete = false;
|
||||
|
||||
while (complete == false) {
|
||||
complete = NPC.UpdateEquipSetID(npc, SetNpcEquipSetCmd.lastEquipSetID);
|
||||
|
||||
if (!complete) {
|
||||
SetNpcEquipSetCmd.lastEquipSetID--;
|
||||
if (SetNpcEquipSetCmd.lastEquipSetID <= 1)
|
||||
SetNpcEquipSetCmd.lastEquipSetID = 1222;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (complete) {
|
||||
this.throwbackInfo(pc, "Equipment Set Changed to " + SetNpcEquipSetCmd.lastEquipSetID);
|
||||
npc.equip = MobBase.loadEquipmentSet(npc.getEquipmentSetID());
|
||||
WorldGrid.updateObject(npc);
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int equipSetID = 0;
|
||||
|
||||
try {
|
||||
equipSetID = Integer.parseInt(words[0]);
|
||||
} catch (Exception e) {
|
||||
this.throwbackError(pc, e.getMessage());
|
||||
}
|
||||
|
||||
if (!NPC.UpdateEquipSetID(npc, equipSetID)) {
|
||||
this.throwbackError(pc, "Unable to find Equipset for ID " + equipSetID);
|
||||
return;
|
||||
}
|
||||
|
||||
SetNpcEquipSetCmd.lastEquipSetID = equipSetID;
|
||||
npc.equip = MobBase.loadEquipmentSet(npc.getEquipmentSetID());
|
||||
WorldGrid.updateObject(npc);
|
||||
|
||||
this.throwbackInfo(pc, "Equipment Set Changed to " + equipSetID);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Sets slot position for an NPC to 'slot'";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /changeslot slot'";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.MobBase;
|
||||
import engine.objects.NPC;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
public class SetNpcMobbaseCmd extends AbstractDevCmd {
|
||||
|
||||
public SetNpcMobbaseCmd() {
|
||||
super("setmobbase");
|
||||
this.addCmdString("npcmobbase");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter player, String[] words,
|
||||
AbstractGameObject target) {
|
||||
|
||||
// Arg Count Check
|
||||
if (words.length != 1) {
|
||||
this.sendUsage(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.getObjectType() != GameObjectType.NPC) {
|
||||
this.sendUsage(player);
|
||||
return;
|
||||
}
|
||||
|
||||
NPC npc = (NPC) target;
|
||||
|
||||
int mobBaseID = Integer.parseInt(words[0]);
|
||||
|
||||
if (MobBase.getMobBase(mobBaseID) == null) {
|
||||
this.throwbackError(player, "Cannot find Mobbase for ID " + mobBaseID);
|
||||
return;
|
||||
}
|
||||
NPC.UpdateRaceID(npc, mobBaseID);
|
||||
|
||||
WorldGrid.updateObject(npc);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Sets mobbase override for an NPC";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /setmobbase mobBaseID'";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -67,119 +67,6 @@ public class SetSubRaceCmd extends AbstractDevCmd {
|
||||
building.removeAllVisualEffects();
|
||||
building.addEffectBit(1 << Integer.parseInt(words[0]));
|
||||
building.updateEffects();
|
||||
//63535 38751
|
||||
// Zone zone = ZoneManager.findSmallestZone(pc.getLoc());
|
||||
// //CityZoneMsg czm = new CityZoneMsg(3, zone.getLoc().x, zone.getLoc().y, zone.getLoc().z, "balls", zone, 0, 0);
|
||||
// pc.getClientConnection().sendMsg(new DeleteItemMsg(zone.getObjectType().ordinal(), zone.getObjectUUID()));
|
||||
|
||||
// UpdateInventoryMsg updateInventoryMsg = new UpdateInventoryMsg(new ArrayList<>(), new ArrayList<>(), null, true);
|
||||
// pc.getClientConnection().sendMsg(updateInventoryMsg);
|
||||
|
||||
//pc.getCharItemManager().updateInventory();
|
||||
|
||||
|
||||
// Mob mob = (Mob)target;
|
||||
//
|
||||
// if (mob == null)
|
||||
// return;
|
||||
//
|
||||
// MobLoot mobLoot = new MobLoot(mob, ItemBase.getItemBase(Integer.parseInt(words[0])), false);
|
||||
//
|
||||
// mob.getCharItemManager().addItemToInventory(mobLoot);
|
||||
|
||||
|
||||
// if (target.getObjectType() != GameObjectType.Building)
|
||||
// return;
|
||||
//
|
||||
// Building warehouseBuilding = (Building)target;
|
||||
//
|
||||
// if (Warehouse.warehouseByBuildingUUID.get(warehouseBuilding.getObjectUUID()) == null)
|
||||
// return;
|
||||
//
|
||||
// Warehouse warehouse = Warehouse.warehouseByBuildingUUID.get(warehouseBuilding.getObjectUUID());
|
||||
//
|
||||
// for (int ibID: Warehouse.getMaxResources().keySet()){
|
||||
// ItemBase ib = ItemBase.getItemBase(ibID);
|
||||
// warehouse.depositFromMine(null, ib, Warehouse.getMaxResources().get(ibID));
|
||||
// }
|
||||
|
||||
|
||||
// int raceID = Integer.parseInt(words[0]);
|
||||
//
|
||||
// UpdateCharOrMobMessage ucm = new UpdateCharOrMobMessage(pc, raceID);
|
||||
//
|
||||
// pc.getClientConnection().sendMsg(ucm);
|
||||
|
||||
// LoadCharacterMsg lcm = new LoadCharacterMsg((AbstractCharacter)null,false);
|
||||
// try {
|
||||
// DispatchMessage.sendToAllInRange(pc, lcm);
|
||||
// } catch (MsgSendException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// ModifyHealthMsg mhm =new ModifyHealthMsg(pc, pc, -50f, 0f, 0f, 0, null, 9999, 0);
|
||||
// mhm.setOmitFromChat(1);
|
||||
// pc.getClientConnection().sendMsg(mhm);
|
||||
//
|
||||
// int temp = 0;
|
||||
// boolean start = false;
|
||||
//
|
||||
// for (EffectsBase eb: EffectsBase.getAllEffectsBase()){
|
||||
//
|
||||
//
|
||||
//
|
||||
// if (!pc.getClientConnection().isConnected()){
|
||||
// Logger.info("", "PLAYER DC!" + eb.getIDString());
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// eb = PowersManager.getEffectByIDString("WLR-018A");
|
||||
//
|
||||
//
|
||||
// NoTimeJob ntj = new NoTimeJob(pc, "NONE", eb, 40);
|
||||
// pc.addEffect(String.valueOf(eb.getUUID()), 1000, ntj, eb, 40);
|
||||
// eb.sendEffectNoPower(ntj, 1000, pc.getClientConnection());
|
||||
//
|
||||
// ThreadUtils.sleep(500);
|
||||
// pc.clearEffects();
|
||||
//
|
||||
// //WorldServer.updateObject((AbstractWorldObject)target, pc);
|
||||
// this.throwbackInfo(pc, eb.getIDString());
|
||||
// break;
|
||||
// //ThreadUtils.sleep(500);
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
// for (EffectsBase eb : EffectsBase.getAllEffectsBase()){
|
||||
// if (eb.getToken() == 0)
|
||||
// continue;
|
||||
// int token = eb.getToken();
|
||||
// ApplyEffectMsg pum = new ApplyEffectMsg();
|
||||
// pum.setEffectID(token);
|
||||
// pum.setSourceType(pc.getObjectType().ordinal());
|
||||
// pum.setSourceID(pc.getObjectUUID());
|
||||
// pum.setStartLocType(pc.getObjectType().ordinal());
|
||||
// pum.setTargetID(pc.getObjectUUID());
|
||||
// pum.setNumTrains(40);
|
||||
// pum.setDuration(-1);
|
||||
//// pum.setDuration((pb.isChant()) ? (int)pb.getChantDuration() : ab.getDurationInSeconds(trains));
|
||||
// pum.setPowerUsedID(0);
|
||||
// // pum.setPowerUsedName("Inflict Poison");
|
||||
// this.throwbackInfo(pc, eb.getName() + "Token = " + eb.getToken());
|
||||
// pc.getClientConnection().sendMsg(pum);
|
||||
// ThreadUtils.sleep(200);
|
||||
// }
|
||||
//
|
||||
|
||||
// UpdateObjectMsg uom = new UpdateObjectMsg(pc, 4);
|
||||
// try {
|
||||
// Location.sendToAllInRange(pc, uom);
|
||||
// } catch (MsgSendException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -33,10 +33,11 @@ public class SimulateBootyCmd extends AbstractDevCmd {
|
||||
|
||||
if (mob.bootySet != 0) {
|
||||
for (BootySetEntry entry : LootManager._bootySetMap.get(mob.bootySet)) {
|
||||
ItemBase item = ItemBase.getItemBase(entry.itemBase);
|
||||
if (item != null) {
|
||||
output += "[" + entry.bootyType + "] " + item.getName() + " [Chance] " + entry.dropChance + newline;
|
||||
}
|
||||
|
||||
ItemTemplate template = ItemTemplate.templates.get(entry.templateID);
|
||||
|
||||
if (template != null)
|
||||
output += "[" + entry.bootyType + "] " + template.item_base_name + " [Chance] " + entry.dropChance + newline;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,9 +56,9 @@ public class SimulateBootyCmd extends AbstractDevCmd {
|
||||
|
||||
try {
|
||||
mob.loadInventory();
|
||||
for (Item lootItem : mob.getCharItemManager().getInventory()) {
|
||||
switch (lootItem.getItemBase().getType()) {
|
||||
case CONTRACT: //CONTRACT
|
||||
for (Item lootItem : mob.charItemManager.getInventory()) {
|
||||
switch (lootItem.template.item_type) {
|
||||
case EMPLOYMENTCONTRACT: //CONTRACT
|
||||
Contracts.add(lootItem);
|
||||
break;
|
||||
case OFFERING: //OFFERING
|
||||
@@ -70,7 +71,7 @@ public class SimulateBootyCmd extends AbstractDevCmd {
|
||||
Runes.add(lootItem);
|
||||
break;
|
||||
case WEAPON: //WEAPON
|
||||
if (lootItem.getItemBase().isGlass())
|
||||
if (lootItem.getName().toUpperCase().contains("GLASS"))
|
||||
GlassItems.add(lootItem);
|
||||
else
|
||||
OtherDrops.add(lootItem);
|
||||
@@ -86,19 +87,19 @@ public class SimulateBootyCmd extends AbstractDevCmd {
|
||||
} catch (Exception ex) {
|
||||
failures++;
|
||||
}
|
||||
if (mob.getEquip() != null) {
|
||||
for (MobEquipment me : mob.getEquip().values()) {
|
||||
if (mob.charItemManager.equipped.isEmpty() == false) {
|
||||
for (Item me : mob.charItemManager.equipped.values()) {
|
||||
|
||||
if (me.getDropChance() == 0)
|
||||
if (me.drop_chance == 0)
|
||||
continue;
|
||||
|
||||
float equipmentRoll = ThreadLocalRandom.current().nextInt(99) + 1;
|
||||
float dropChance = me.getDropChance() * 100;
|
||||
float dropChance = me.drop_chance * 100;
|
||||
|
||||
if (equipmentRoll > (dropChance))
|
||||
continue;
|
||||
|
||||
MobLoot ml = new MobLoot(mob, me.getItemBase(), false);
|
||||
MobLoot ml = new MobLoot(mob, me.template, false);
|
||||
|
||||
if (ml != null)
|
||||
EquipmentDrops.add(ml);
|
||||
|
||||
@@ -13,7 +13,7 @@ import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.net.client.msg.RecvSummonsRequestMsg;
|
||||
import engine.net.client.msg.RecvSummonsMsg;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.objects.Zone;
|
||||
@@ -41,7 +41,7 @@ public class SummonCmd extends AbstractDevCmd {
|
||||
String location = "Somewhere";
|
||||
if (zone != null)
|
||||
location = zone.zoneName;
|
||||
RecvSummonsRequestMsg rsrm = new RecvSummonsRequestMsg(pc.getObjectType().ordinal(), pc.getObjectUUID(), pc.getFirstName(),
|
||||
RecvSummonsMsg rsrm = new RecvSummonsMsg(pc.getObjectType().ordinal(), pc.getObjectUUID(), pc.getFirstName(),
|
||||
location, false);
|
||||
toSummon.getClientConnection().sendMsg(rsrm);
|
||||
|
||||
|
||||
@@ -96,9 +96,9 @@ public class aiInfoCmd extends AbstractDevCmd {
|
||||
output += "Responds To Call For Help: " + mob.behaviourType.respondsToCallForHelp + newline;
|
||||
} else {
|
||||
output += "BehaviourType: NULL" + newline;
|
||||
}
|
||||
output += "Aggro Range: " + mob.getAggroRange() + newline;
|
||||
output += "Player Aggro Map Size: " + mob.playerAgroMap.size() + newline;
|
||||
}
|
||||
output += "Aggro Range: " + mob.getAggroRange() + newline;
|
||||
output += "Player Aggro Map Size: " + mob.playerAgroMap.size() + newline;
|
||||
if (mob.playerAgroMap.size() > 0) {
|
||||
output += "Players Loaded:" + newline;
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public class aiInfoCmd extends AbstractDevCmd {
|
||||
|
||||
if (mob.guardedCity != null)
|
||||
output += "Patrolling: " + mob.guardedCity.getCityName() + newline;
|
||||
output += "See Invis Level: " + mob.mobBase.getSeeInvis() + newline;
|
||||
output += "See Invis Level: " + mob.mobBase.getSeeInvis() + newline;
|
||||
output += "Can Cast: " + MobAI.canCast(mob) + newline;
|
||||
output += "Powers:" + newline;
|
||||
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.Building;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
public class convertLoc extends AbstractDevCmd {
|
||||
|
||||
public convertLoc() {
|
||||
super("convertLoc");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
|
||||
|
||||
if (target == null) {
|
||||
Vector3fImmutable convertLoc = ZoneManager.findSmallestZone(pc.getLoc()).getLoc().subtract(pc.getLoc());
|
||||
ChatManager.chatSystemInfo(pc, Vector3fImmutable.toString(convertLoc));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (target.getObjectType() != GameObjectType.Building)
|
||||
return;
|
||||
Building toConvert = (Building) target;
|
||||
Vector3fImmutable convertedLoc = ZoneManager.convertWorldToLocal(toConvert, pc.getLoc());
|
||||
ChatManager.chatSystemInfo(pc, Vector3fImmutable.toString(convertedLoc));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Temporarily Changes SubRace";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /setBuildingCollidables add/remove 'add creates a collision line.' needs 4 integers. startX, endX, startY, endY";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,10 +19,7 @@ import engine.job.JobScheduler;
|
||||
import engine.jobs.UpgradeBuildingJob;
|
||||
import engine.math.Bounds;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ErrorPopupMsg;
|
||||
import engine.net.client.msg.ManageCityAssetsMsg;
|
||||
import engine.net.client.msg.PlaceAssetMsg;
|
||||
import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
@@ -30,6 +27,7 @@ import org.pmw.tinylog.Logger;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
@@ -44,6 +42,7 @@ public enum BuildingManager {
|
||||
public static HashMap<Integer, ConcurrentHashMap<Integer, BuildingFriends>> _buildingFriends = new HashMap<>();
|
||||
public static HashMap<Integer, ConcurrentHashMap<Integer, Condemned>> _buildingCondemned = new HashMap<>();
|
||||
public static HashMap<Integer, ArrayList<Vector3fImmutable>> _buildingPatrolPoints = new HashMap<>();
|
||||
|
||||
public static int getAvailableSlot(Building building) {
|
||||
|
||||
ArrayList<BuildingLocation> slotLocations = _slotLocations.get(building.meshUUID);
|
||||
@@ -209,41 +208,47 @@ public enum BuildingManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemBase elanIB = ItemBase.getItemBase(1705032);
|
||||
ItemTemplate template = ItemTemplate.templates.get(1705032); // Elan Stone
|
||||
|
||||
if (elanIB == null)
|
||||
if (!player.charItemManager.hasRoomInventory(template.item_wt))
|
||||
return false;
|
||||
|
||||
if (!player.getCharItemManager().hasRoomInventory(elanIB.getWeight()))
|
||||
return false;
|
||||
|
||||
if (!Item.MakeItemForPlayer(elanIB, player, amount))
|
||||
if (!Item.MakeItemForPlayer(template.template_id, player, amount))
|
||||
return false;
|
||||
|
||||
shrine.setFavors(0);
|
||||
break;
|
||||
case WAREHOUSE:
|
||||
|
||||
Warehouse warehouse = Warehouse.warehouseByBuildingUUID.get(building.getObjectUUID());
|
||||
City city = building.getCity();
|
||||
|
||||
if (city == null)
|
||||
return true;
|
||||
|
||||
Warehouse warehouse = city.warehouse;
|
||||
|
||||
if (warehouse == null)
|
||||
return false;
|
||||
|
||||
for (ItemBase resourceBase : ItemBase.getResourceList()) {
|
||||
if (!player.getCharItemManager().hasRoomInventory(resourceBase.getWeight())) {
|
||||
for (Enum.ResourceType resourceType : EnumSet.allOf(Enum.ResourceType.class)) {
|
||||
|
||||
if (!player.charItemManager.hasRoomInventory(resourceType.template.item_wt)) {
|
||||
ChatManager.chatSystemInfo(player, "You can not carry any more of that item.");
|
||||
return false;
|
||||
}
|
||||
if (warehouse.resources.get(resourceBase) == null)
|
||||
|
||||
if (warehouse.resources.get(resourceType) == null)
|
||||
continue;
|
||||
|
||||
int resourceAmount = warehouse.resources.get(resourceBase);
|
||||
int resourceAmount = warehouse.resources.get(resourceType);
|
||||
|
||||
if (resourceAmount <= 0)
|
||||
continue;
|
||||
|
||||
if (Warehouse.loot(warehouse, player, resourceBase, resourceAmount, true))
|
||||
ChatManager.chatInfoInfo(player, "You have looted " + resourceAmount + ' ' + resourceBase.getName());
|
||||
if (Warehouse.loot(warehouse, player, resourceType, resourceAmount, true)) {
|
||||
ChatManager.chatInfoInfo(player, "You have looted " + resourceAmount + ' ' + resourceType.name());
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -569,8 +574,8 @@ public enum BuildingManager {
|
||||
|
||||
String pirateName = NPCManager.getPirateName(contract.getMobbaseID());
|
||||
|
||||
if (item.getChargesRemaining() > 0)
|
||||
rank = item.getChargesRemaining() * 10;
|
||||
if ((byte) item.chargesRemaining > 0)
|
||||
rank = (byte) item.chargesRemaining * 10;
|
||||
else
|
||||
rank = 10;
|
||||
|
||||
@@ -777,83 +782,6 @@ public enum BuildingManager {
|
||||
|
||||
}
|
||||
|
||||
public static void processRedeedNPC(NPC npc, Building building, ClientConnection origin) {
|
||||
|
||||
// Member variable declaration
|
||||
PlayerCharacter player;
|
||||
Contract contract;
|
||||
CharacterItemManager itemMan;
|
||||
ItemBase itemBase;
|
||||
Item item;
|
||||
|
||||
npc.lock.writeLock().lock();
|
||||
|
||||
try {
|
||||
|
||||
|
||||
if (building == null)
|
||||
return;
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
itemMan = player.getCharItemManager();
|
||||
|
||||
contract = npc.getContract();
|
||||
|
||||
if (!player.getCharItemManager().hasRoomInventory((short) 1)) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 21);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!building.getHirelings().containsKey(npc))
|
||||
return;
|
||||
|
||||
if (!npc.remove()) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
return;
|
||||
}
|
||||
|
||||
building.getHirelings().remove(npc);
|
||||
|
||||
itemBase = ItemBase.getItemBase(contract.getContractID());
|
||||
|
||||
if (itemBase == null) {
|
||||
Logger.error("Could not find Contract for npc: " + npc.getObjectUUID());
|
||||
return;
|
||||
}
|
||||
|
||||
boolean itemWorked = false;
|
||||
|
||||
item = new Item(itemBase, player.getObjectUUID(), Enum.OwnerType.PlayerCharacter, (byte) ((byte) npc.getRank() - 1), (byte) ((byte) npc.getRank() - 1),
|
||||
(short) 1, (short) 1, true, false, Enum.ItemContainerType.INVENTORY, (byte) 0,
|
||||
new ArrayList<>(), "");
|
||||
item.setNumOfItems(1);
|
||||
item.containerType = Enum.ItemContainerType.INVENTORY;
|
||||
|
||||
try {
|
||||
item = DbManager.ItemQueries.ADD_ITEM(item);
|
||||
itemWorked = true;
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
if (itemWorked) {
|
||||
itemMan.addItemToInventory(item);
|
||||
itemMan.updateInventory();
|
||||
}
|
||||
|
||||
ManageCityAssetsMsg mca = new ManageCityAssetsMsg();
|
||||
mca.actionType = NPC.SVR_CLOSE_WINDOW;
|
||||
mca.setTargetType(building.getObjectType().ordinal());
|
||||
mca.setTargetID(building.getObjectUUID());
|
||||
origin.sendMsg(mca);
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
} finally {
|
||||
npc.lock.writeLock().unlock();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void rebuildMine(Building mineBuilding) {
|
||||
setRank(mineBuilding, 1);
|
||||
mineBuilding.meshUUID = mineBuilding.getBlueprint().getMeshForRank(mineBuilding.rank);
|
||||
@@ -911,7 +839,7 @@ public enum BuildingManager {
|
||||
// New rank means new mesh
|
||||
newMeshUUID = building.getBlueprint().getMeshForRank(building.rank);
|
||||
|
||||
if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.TOL)&& (building.rank == 8))
|
||||
if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.TOL) && (building.rank == 8))
|
||||
newMeshUUID = Realm.getRealmMesh(building.getCity());
|
||||
|
||||
building.meshUUID = newMeshUUID;
|
||||
|
||||
@@ -20,13 +20,11 @@ import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.MessageDispatcher;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.Protocol;
|
||||
import engine.net.client.handlers.ClientAdminCommandMsgHandler;
|
||||
import engine.net.client.msg.chat.*;
|
||||
import engine.net.client.msg.commands.ClientAdminCommandMsg;
|
||||
import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import engine.server.world.WorldServer;
|
||||
import engine.session.Session;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -42,8 +40,8 @@ public enum ChatManager {
|
||||
// (FLOOD_TIME_THRESHOLD) ms will flag as a flood message
|
||||
// Example, set to 3 & 2000 to flag the 3rd message within 2000 ms.
|
||||
|
||||
private static final int FLOOD_QTY_THRESHOLD = 3;
|
||||
private static final int FLOOD_TIME_THRESHOLD = 2000;
|
||||
public static final int FLOOD_QTY_THRESHOLD = 3;
|
||||
public static final int FLOOD_TIME_THRESHOLD = 2000;
|
||||
private static final String FLOOD_USER_ERROR = "You talk too much!";
|
||||
private static final String SILENCED = "You find yourself mute!";
|
||||
private static final String UNKNOWN_COMMAND = "No such command.";
|
||||
@@ -51,74 +49,6 @@ public enum ChatManager {
|
||||
/**
|
||||
* This method used when handling a ChatMsg received from the network.
|
||||
*/
|
||||
public static void handleChatMsg(Session sender, AbstractChatMsg msg) {
|
||||
|
||||
if (msg == null) {
|
||||
Logger.warn(
|
||||
"null message: ");
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender == null) {
|
||||
Logger.warn(
|
||||
"null sender: ");
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerCharacter pc = sender.getPlayerCharacter();
|
||||
|
||||
if (pc == null) {
|
||||
Logger.warn(
|
||||
"invalid sender: ");
|
||||
return;
|
||||
}
|
||||
|
||||
Protocol protocolMsg = msg.getProtocolMsg();
|
||||
|
||||
// Flood control, implemented per channel
|
||||
|
||||
boolean isFlood = false;
|
||||
long curMsgTime = System.currentTimeMillis();
|
||||
long checkTime = pc.chatFloodTime(protocolMsg.opcode, curMsgTime, FLOOD_QTY_THRESHOLD - 1);
|
||||
|
||||
if ((checkTime > 0L) && (curMsgTime - checkTime < FLOOD_TIME_THRESHOLD))
|
||||
isFlood = true;
|
||||
|
||||
switch (protocolMsg) {
|
||||
case CHATSAY:
|
||||
ChatManager.chatSay(pc, msg.getMessage(), isFlood);
|
||||
return;
|
||||
case CHATCSR:
|
||||
ChatManager.chatCSR(msg);
|
||||
return;
|
||||
case CHATTELL:
|
||||
ChatTellMsg ctm = (ChatTellMsg) msg;
|
||||
ChatManager.chatTell(pc, ctm.getTargetName(), ctm.getMessage(), isFlood);
|
||||
return;
|
||||
case CHATSHOUT:
|
||||
ChatManager.chatShout(pc, msg.getMessage(), isFlood);
|
||||
return;
|
||||
case CHATGUILD:
|
||||
ChatManager.chatGuild(pc, (ChatGuildMsg) msg);
|
||||
return;
|
||||
case CHATGROUP:
|
||||
ChatManager.chatGroup(pc, (ChatGroupMsg) msg);
|
||||
return;
|
||||
case CHATIC:
|
||||
ChatManager.chatIC(pc, (ChatICMsg) msg);
|
||||
return;
|
||||
case LEADERCHANNELMESSAGE:
|
||||
ChatManager.chatGlobal(pc, msg.getMessage(), isFlood);
|
||||
return;
|
||||
case GLOBALCHANNELMESSAGE:
|
||||
case CHATPVP:
|
||||
case CHATCITY:
|
||||
case CHATINFO:
|
||||
case SYSTEMBROADCASTCHANNEL:
|
||||
default:
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Channels
|
||||
@@ -165,7 +95,7 @@ public enum ChatManager {
|
||||
|
||||
PlayerBonuses bonus = pc.getBonuses();
|
||||
|
||||
if (bonus != null && bonus.getBool(ModType.Silenced, SourceType.None)) {
|
||||
if (bonus != null && bonus.getBool(ModType.Silenced, SourceType.NONE)) {
|
||||
ChatManager.chatSayError(pc, SILENCED);
|
||||
return true;
|
||||
}
|
||||
@@ -190,7 +120,7 @@ public enum ChatManager {
|
||||
}
|
||||
|
||||
if (ChatManager.isDevCommand(text) == true) {
|
||||
ChatManager.processDevCommand(player, text);
|
||||
ClientAdminCommandMsgHandler.processDevCommand(player, text);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -275,7 +205,7 @@ public enum ChatManager {
|
||||
PlayerCharacter pcSender = null;
|
||||
|
||||
if (sender.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||
pcSender = (PlayerCharacter) sender;
|
||||
pcSender = sender;
|
||||
|
||||
if (isFlood) {
|
||||
ChatManager.chatSayError(pcSender, FLOOD_USER_ERROR);
|
||||
@@ -412,7 +342,7 @@ public enum ChatManager {
|
||||
chatGuildMsg.setUnknown04(sender.getGuild() != null ? sender.getGuild()
|
||||
.getCharter() : 0); // Charter?
|
||||
chatGuildMsg.setUnknown05(GuildStatusController.getTitle(sender.getGuildStatus())); // Title?
|
||||
chatGuildMsg.setUnknown06(sender.getRace().getRaceType().getCharacterSex().equals(Enum.CharacterSex.MALE) ? 1 : 2); // isMale?, seen 1 and 2
|
||||
chatGuildMsg.setUnknown06(sender.race.getRaceType().getCharacterSex().equals(Enum.CharacterSex.MALE) ? 1 : 2); // isMale?, seen 1 and 2
|
||||
|
||||
// Send dispatch to each player
|
||||
|
||||
@@ -597,7 +527,6 @@ public enum ChatManager {
|
||||
distroList.remove(awo);
|
||||
else if (awo.getObjectUUID() == tar.getObjectUUID())
|
||||
distroList.remove(awo);
|
||||
|
||||
}
|
||||
|
||||
String textToThief = "";
|
||||
@@ -607,20 +536,20 @@ public enum ChatManager {
|
||||
if (item != null) //Steal
|
||||
if (success) {
|
||||
String name = "";
|
||||
if (item.getItemBase() != null)
|
||||
if (item.getItemBase().getUUID() == 7)
|
||||
name = amount + " gold ";
|
||||
else {
|
||||
String vowels = "aeiou";
|
||||
String iName = item.getItemBase().getName();
|
||||
if (iName.length() > 0)
|
||||
if (vowels.indexOf(iName.substring(0, 1).toLowerCase()) >= 0)
|
||||
name = "an " + iName + ' ';
|
||||
else
|
||||
name = "a " + iName + ' ';
|
||||
}
|
||||
if (item.template.item_type.equals(Enum.ItemType.GOLD))
|
||||
name = amount + " gold ";
|
||||
else {
|
||||
String vowels = "aeiou";
|
||||
ItemTemplate template = ItemTemplate.templates.get(item.templateID);
|
||||
String iName = template.item_base_name;
|
||||
if (iName.length() > 0)
|
||||
if (vowels.indexOf(iName.substring(0, 1).toLowerCase()) >= 0)
|
||||
name = "an " + iName + ' ';
|
||||
else
|
||||
name = "a " + iName + ' ';
|
||||
}
|
||||
textToThief = "You have stolen " + name + "from " + tar.getFirstName() + '!';
|
||||
textToVictim = sender.getFirstName() + "is caught with thier hands in your pocket!";
|
||||
textToVictim = sender.getFirstName() + "is caught with their hands in your pocket!";
|
||||
//textToOthers = sender.getFirstName() + " steals " + name + "from " + target.getFirstName() + ".";
|
||||
} else
|
||||
textToThief = "Your attempt at stealing failed..."; //textToVictim = sender.getFirstName() + " fails to steal from you.";
|
||||
@@ -640,6 +569,7 @@ public enum ChatManager {
|
||||
//Send msg to thief
|
||||
HashSet<AbstractWorldObject> senderList = new HashSet<>();
|
||||
senderList.add(sender);
|
||||
|
||||
if (!textToThief.isEmpty())
|
||||
ChatManager.chatSystemSend(senderList, textToThief, 1, 2);
|
||||
|
||||
@@ -673,22 +603,6 @@ public enum ChatManager {
|
||||
sendInfoMsgToPlayer(pc, text, 1);
|
||||
}
|
||||
|
||||
public static void chatCommanderError(PlayerCharacter pc, String text) {
|
||||
sendErrorMsgToPlayer(pc, text, 3);
|
||||
}
|
||||
|
||||
public static void chatNationError(PlayerCharacter pc, String text) {
|
||||
sendErrorMsgToPlayer(pc, text, 5);
|
||||
}
|
||||
|
||||
public static void chatLeaderError(PlayerCharacter pc, String text) {
|
||||
sendErrorMsgToPlayer(pc, text, 6);
|
||||
}
|
||||
|
||||
public static void chatShoutError(PlayerCharacter pc, String text) {
|
||||
sendErrorMsgToPlayer(pc, text, 7);
|
||||
}
|
||||
|
||||
public static void chatInfoError(PlayerCharacter pc, String text) {
|
||||
sendErrorMsgToPlayer(pc, text, 10);
|
||||
}
|
||||
@@ -713,35 +627,16 @@ public enum ChatManager {
|
||||
sendErrorMsgToPlayer(pc, text, 16);
|
||||
}
|
||||
|
||||
public static void chatEmoteError(PlayerCharacter pc, String text) {
|
||||
sendErrorMsgToPlayer(pc, text, 17);
|
||||
}
|
||||
|
||||
public static void chatTellError(PlayerCharacter pc, String text) {
|
||||
sendErrorMsgToPlayer(pc, text, 19);
|
||||
}
|
||||
|
||||
// Send Info Message to channels
|
||||
public static void chatCommanderInfo(PlayerCharacter pc, String text) {
|
||||
chatSystem(pc, text, 3, 2);
|
||||
}
|
||||
|
||||
public static void chatNationInfo(PlayerCharacter pc, String text) {
|
||||
chatSystem(pc, text, 5, 2);
|
||||
}
|
||||
|
||||
public static void chatNationInfo(Guild nation, String text) {
|
||||
chatSystemGuild(nation, text, 5, 2);
|
||||
}
|
||||
|
||||
public static void chatLeaderInfo(PlayerCharacter pc, String text) {
|
||||
chatSystem(pc, text, 6, 2);
|
||||
}
|
||||
|
||||
public static void chatShoutInfo(PlayerCharacter pc, String text) {
|
||||
chatSystem(pc, text, 7, 2);
|
||||
}
|
||||
|
||||
public static void chatInfoInfo(PlayerCharacter pc, String text) {
|
||||
chatSystem(pc, text, 10, 2);
|
||||
}
|
||||
@@ -750,30 +645,14 @@ public enum ChatManager {
|
||||
chatSystem(pc, text, 12, 2);
|
||||
}
|
||||
|
||||
public static void chatICInfo(PlayerCharacter pc, String text) {
|
||||
chatSystem(pc, text, 13, 2);
|
||||
}
|
||||
|
||||
public static void chatGroupInfo(PlayerCharacter pc, String text) {
|
||||
chatSystem(pc, text, 14, 2);
|
||||
}
|
||||
|
||||
public static void chatCityInfo(PlayerCharacter pc, String text) {
|
||||
chatSystem(pc, text, 15, 2);
|
||||
}
|
||||
|
||||
public static void chatSayInfo(PlayerCharacter pc, String text) {
|
||||
chatSystem(pc, text, 16, 2);
|
||||
}
|
||||
|
||||
public static void chatEmoteInfo(PlayerCharacter pc, String text) {
|
||||
chatSystem(pc, text, 17, 2);
|
||||
}
|
||||
|
||||
public static void chatTellInfo(PlayerCharacter pc, String text) {
|
||||
chatSystem(pc, text, 19, 2);
|
||||
}
|
||||
|
||||
public static void chatGroupInfoCanSee(PlayerCharacter pc, String text) {
|
||||
HashSet<AbstractWorldObject> distroList = null;
|
||||
|
||||
@@ -857,11 +736,6 @@ public enum ChatManager {
|
||||
DispatchMessage.dispatchMsgToAll(msg);
|
||||
}
|
||||
|
||||
public static void chatInfo(String text) {
|
||||
HashSet<AbstractWorldObject> distroList = ChatManager.getAllPlayers(null);
|
||||
chatSystemSend(distroList, text, 1, 2);
|
||||
}
|
||||
|
||||
public static ChatSystemMsg CombatInfo(AbstractWorldObject source, AbstractWorldObject target) {
|
||||
String text = "The " + target.getName() + " attacks " + source.getName();
|
||||
ChatSystemMsg msg = new ChatSystemMsg(null, text);
|
||||
@@ -1139,94 +1013,4 @@ public enum ChatManager {
|
||||
return text.equalsIgnoreCase("lua_population()");
|
||||
}
|
||||
|
||||
private static boolean processDevCommand(AbstractWorldObject sender, String text) {
|
||||
|
||||
if (sender.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
||||
|
||||
PlayerCharacter pcSender = (PlayerCharacter) sender;
|
||||
|
||||
// first remove the DEV_CMD_PREFIX
|
||||
String[] words = text.split(MBServerStatics.DEV_CMD_PREFIX, 2);
|
||||
|
||||
if (words[1].length() == 0)
|
||||
return false;
|
||||
|
||||
// next get the command
|
||||
String[] commands = words[1].split(" ", 2);
|
||||
String cmd = commands[0].toLowerCase();
|
||||
String cmdArgument = "";
|
||||
|
||||
if (commands.length > 1)
|
||||
cmdArgument = commands[1].trim();
|
||||
|
||||
AbstractGameObject target = pcSender.getLastTarget();
|
||||
// return DevCmd.processDevCommand(pcSender, cmd, cmdArgument,
|
||||
// target);
|
||||
return DevCmdManager.handleDevCmd(pcSender, cmd,
|
||||
cmdArgument, target);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process an Admin Command, which is a preset command sent from the client
|
||||
*/
|
||||
public static void HandleClientAdminCmd(ClientAdminCommandMsg data,
|
||||
ClientConnection cc) {
|
||||
|
||||
PlayerCharacter pcSender = SessionManager.getPlayerCharacter(cc);
|
||||
|
||||
if (pcSender == null)
|
||||
return;
|
||||
|
||||
Account acct = SessionManager.getAccount(pcSender);
|
||||
|
||||
if (acct == null)
|
||||
return;
|
||||
|
||||
// require minimal access to continue
|
||||
// specific accessLevel checks performed by the DevCmdManager
|
||||
if (acct.status.equals(Enum.AccountStatus.ADMIN) == false) {
|
||||
Logger.warn(pcSender.getFirstName() + " Attempted to use a client admin command");
|
||||
//wtf? ChatManager.chatSystemInfo(pcSender, "CHEATER!!!!!!!!!!!!!");
|
||||
return;
|
||||
}
|
||||
|
||||
// First remove the initial slash
|
||||
String d = data.getMsgCommand();
|
||||
String[] words = d.split("/", 2);
|
||||
|
||||
if (words[1].length() == 0)
|
||||
return;
|
||||
|
||||
// Next get the command
|
||||
String[] commands = words[1].split(" ", 2);
|
||||
String cmd = commands[0].toLowerCase();
|
||||
String cmdArgument = "";
|
||||
|
||||
if (commands.length > 1)
|
||||
cmdArgument = commands[1].trim();
|
||||
|
||||
AbstractGameObject target = data.getTarget();
|
||||
|
||||
// Map to a DevCmd
|
||||
String devCmd = "";
|
||||
|
||||
if (cmd.compareTo("goto") == 0)
|
||||
devCmd = "goto";
|
||||
else if (cmd.compareTo("suspend") == 0)
|
||||
devCmd = "suspend";
|
||||
else if (cmd.compareTo("getinfo") == 0)
|
||||
devCmd = "info";
|
||||
else if (devCmd.isEmpty()) {
|
||||
Logger.info("Unhandled admin command was used: /"
|
||||
+ cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
DevCmdManager.handleDevCmd(pcSender, devCmd, cmdArgument,
|
||||
target);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -48,7 +48,6 @@ public enum DbManager {
|
||||
public static final dbEffectsResourceCostHandler EffectsResourceCostsQueries = new dbEffectsResourceCostHandler();
|
||||
public static final dbGuildHandler GuildQueries = new dbGuildHandler();
|
||||
public static final dbItemHandler ItemQueries = new dbItemHandler();
|
||||
public static final dbItemBaseHandler ItemBaseQueries = new dbItemBaseHandler();
|
||||
public static final dbKitHandler KitQueries = new dbKitHandler();
|
||||
public static final dbLootHandler LootQueries = new dbLootHandler();
|
||||
public static final dbMenuHandler MenuQueries = new dbMenuHandler();
|
||||
@@ -69,7 +68,6 @@ public enum DbManager {
|
||||
public static final dbZoneHandler ZoneQueries = new dbZoneHandler();
|
||||
public static final dbRealmHandler RealmQueries = new dbRealmHandler();
|
||||
public static final dbBlueprintHandler BlueprintQueries = new dbBlueprintHandler();
|
||||
public static final dbBoonHandler BoonQueries = new dbBoonHandler();
|
||||
public static final dbShrineHandler ShrineQueries = new dbShrineHandler();
|
||||
public static final dbRunegateHandler RunegateQueries = new dbRunegateHandler();
|
||||
|
||||
|
||||
@@ -41,9 +41,7 @@ public enum DevCmdManager {
|
||||
private static void registerCommands() {
|
||||
|
||||
// Player
|
||||
DevCmdManager.registerDevCmd(new DistanceCmd());
|
||||
DevCmdManager.registerDevCmd(new HelpCmd());
|
||||
DevCmdManager.registerDevCmd(new GetZoneCmd());
|
||||
DevCmdManager.registerDevCmd(new ZoneSetCmd());
|
||||
DevCmdManager.registerDevCmd(new PrintBankCmd());
|
||||
DevCmdManager.registerDevCmd(new PrintEffectsCmd());
|
||||
@@ -58,7 +56,6 @@ public enum DevCmdManager {
|
||||
DevCmdManager.registerDevCmd(new PrintResistsCmd());
|
||||
DevCmdManager.registerDevCmd(new PrintLocationCmd());
|
||||
DevCmdManager.registerDevCmd(new InfoCmd());
|
||||
DevCmdManager.registerDevCmd(new ItemInfoCmd());
|
||||
DevCmdManager.registerDevCmd(new aiInfoCmd());
|
||||
DevCmdManager.registerDevCmd(new SimulateBootyCmd());
|
||||
DevCmdManager.registerDevCmd(new GetHeightCmd());
|
||||
@@ -75,13 +72,10 @@ public enum DevCmdManager {
|
||||
DevCmdManager.registerDevCmd(new SetLevelCmd());
|
||||
DevCmdManager.registerDevCmd(new SetBaseClassCmd());
|
||||
DevCmdManager.registerDevCmd(new SetPromotionClassCmd());
|
||||
DevCmdManager.registerDevCmd(new EffectCmd());
|
||||
DevCmdManager.registerDevCmd(new SetRuneCmd());
|
||||
DevCmdManager.registerDevCmd(new GetOffsetCmd());
|
||||
DevCmdManager.registerDevCmd(new DebugCmd());
|
||||
DevCmdManager.registerDevCmd(new AddGoldCmd());
|
||||
DevCmdManager.registerDevCmd(new ZoneInfoCmd());
|
||||
DevCmdManager.registerDevCmd(new DebugMeleeSyncCmd());
|
||||
DevCmdManager.registerDevCmd(new HotzoneCmd());
|
||||
DevCmdManager.registerDevCmd(new MineActiveCmd());
|
||||
// Dev
|
||||
@@ -93,12 +87,9 @@ public enum DevCmdManager {
|
||||
DevCmdManager.registerDevCmd(new RotateCmd());
|
||||
DevCmdManager.registerDevCmd(new FlashMsgCmd());
|
||||
DevCmdManager.registerDevCmd(new SysMsgCmd());
|
||||
DevCmdManager.registerDevCmd(new GetBankCmd());
|
||||
DevCmdManager.registerDevCmd(new GetVaultCmd());
|
||||
DevCmdManager.registerDevCmd(new CombatMessageCmd());
|
||||
DevCmdManager.registerDevCmd(new RenameCmd());
|
||||
DevCmdManager.registerDevCmd(new CreateItemCmd());
|
||||
DevCmdManager.registerDevCmd(new GetMemoryCmd());
|
||||
DevCmdManager.registerDevCmd(new SetRankCmd());
|
||||
DevCmdManager.registerDevCmd(new MakeBaneCmd());
|
||||
DevCmdManager.registerDevCmd(new RemoveBaneCmd());
|
||||
@@ -106,14 +97,9 @@ public enum DevCmdManager {
|
||||
DevCmdManager.registerDevCmd(new SetAdminRuneCmd());
|
||||
DevCmdManager.registerDevCmd(new SetInvulCmd());
|
||||
DevCmdManager.registerDevCmd(new MakeItemCmd());
|
||||
DevCmdManager.registerDevCmd(new EnchantCmd());
|
||||
DevCmdManager.registerDevCmd(new SetSubRaceCmd());
|
||||
// Admin
|
||||
DevCmdManager.registerDevCmd(new GetCacheCountCmd());
|
||||
DevCmdManager.registerDevCmd(new GetRuneDropRateCmd());
|
||||
DevCmdManager.registerDevCmd(new DecachePlayerCmd());
|
||||
DevCmdManager.registerDevCmd(new AuditMobsCmd());
|
||||
DevCmdManager.registerDevCmd(new ChangeNameCmd());
|
||||
|
||||
DevCmdManager.registerDevCmd(new SetGuildCmd());
|
||||
DevCmdManager.registerDevCmd(new SetOwnerCmd());
|
||||
DevCmdManager.registerDevCmd(new NetDebugCmd());
|
||||
@@ -122,28 +108,17 @@ public enum DevCmdManager {
|
||||
DevCmdManager.registerDevCmd(new PurgeObjectsCmd());
|
||||
DevCmdManager.registerDevCmd(new SplatMobCmd());
|
||||
DevCmdManager.registerDevCmd(new SlotNpcCmd());
|
||||
DevCmdManager.registerDevCmd(new GateInfoCmd());
|
||||
DevCmdManager.registerDevCmd(new ShowOffsetCmd());
|
||||
DevCmdManager.registerDevCmd(new RealmInfoCmd());
|
||||
DevCmdManager.registerDevCmd(new RebootCmd());
|
||||
DevCmdManager.registerDevCmd(new SetMineTypeCmd());
|
||||
DevCmdManager.registerDevCmd(new SetMineExpansion());
|
||||
DevCmdManager.registerDevCmd(new SetForceRenameCityCmd());
|
||||
DevCmdManager.registerDevCmd(new GotoObj());
|
||||
DevCmdManager.registerDevCmd(new convertLoc());
|
||||
DevCmdManager.registerDevCmd(new UnloadFurnitureCmd());
|
||||
DevCmdManager.registerDevCmd(new SetNpcEquipSetCmd());
|
||||
DevCmdManager.registerDevCmd(new SetBuildingAltitudeCmd());
|
||||
DevCmdManager.registerDevCmd(new ResetLevelCmd());
|
||||
DevCmdManager.registerDevCmd(new SetNpcNameCmd());
|
||||
DevCmdManager.registerDevCmd(new SetNpcMobbaseCmd());
|
||||
DevCmdManager.registerDevCmd(new DespawnCmd());
|
||||
DevCmdManager.registerDevCmd(new BoundsCmd());
|
||||
DevCmdManager.registerDevCmd(new GotoBoundsCmd());
|
||||
DevCmdManager.registerDevCmd(new RegionCmd());
|
||||
DevCmdManager.registerDevCmd(new SetMaintCmd());
|
||||
DevCmdManager.registerDevCmd(new ApplyBonusCmd());
|
||||
DevCmdManager.registerDevCmd(new AuditFailedItemsCmd());
|
||||
DevCmdManager.registerDevCmd(new SlotTestCmd());
|
||||
}
|
||||
|
||||
|
||||
@@ -303,12 +303,13 @@ public enum GroupManager {
|
||||
}
|
||||
|
||||
public static boolean goldSplit(PlayerCharacter pc, Item item, ClientConnection origin, AbstractWorldObject tar) {
|
||||
if (item == null || pc == null || tar == null || item.getItemBase() == null) {
|
||||
|
||||
if (item == null || pc == null || tar == null) {
|
||||
Logger.error("null something");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.getItemBase().getUUID() != 7) //only split goldItem
|
||||
if (!item.template.item_type.equals(Enum.ItemType.GOLD)) //only split goldItem
|
||||
return false;
|
||||
|
||||
Group group = getGroup(pc);
|
||||
@@ -316,7 +317,6 @@ public enum GroupManager {
|
||||
if (group == null || !group.getSplitGold()) //make sure player is grouped and split is on
|
||||
return false;
|
||||
|
||||
|
||||
ArrayList<PlayerCharacter> playersSplit = new ArrayList<>();
|
||||
|
||||
//get group members
|
||||
@@ -331,8 +331,8 @@ public enum GroupManager {
|
||||
playersSplit.add(groupMember);
|
||||
}
|
||||
|
||||
//make sure more than one group member in loot range
|
||||
|
||||
//make sure more then one group member in loot range
|
||||
int size = playersSplit.size();
|
||||
|
||||
if (size < 2)
|
||||
@@ -353,22 +353,21 @@ public enum GroupManager {
|
||||
|
||||
if (item.getObjectType() == Enum.GameObjectType.MobLoot) {
|
||||
if (tar.getObjectType() == Enum.GameObjectType.Mob) {
|
||||
((Mob) tar).getCharItemManager().delete(item);
|
||||
((Mob) tar).charItemManager.delete(item);
|
||||
} else
|
||||
item.setNumOfItems(0);
|
||||
} else
|
||||
item.setNumOfItems(0);
|
||||
for (PlayerCharacter splitPlayer : playersSplit) {
|
||||
|
||||
for (PlayerCharacter splitPlayer : playersSplit) {
|
||||
|
||||
int amt = (group.isGroupLead(splitPlayer)) ? (amount + dif) : amount;
|
||||
if (amt > 0)
|
||||
splitPlayer.getCharItemManager().addGoldToInventory(amt, false);
|
||||
splitPlayer.charItemManager.addGoldToInventory(amt, false);
|
||||
}
|
||||
|
||||
for (PlayerCharacter splitPlayer : playersSplit) {
|
||||
|
||||
|
||||
UpdateGoldMsg ugm = new UpdateGoldMsg(splitPlayer);
|
||||
ugm.configure();
|
||||
|
||||
@@ -380,7 +379,6 @@ public enum GroupManager {
|
||||
updateTargetGold.configure();
|
||||
DispatchMessage.dispatchMsgToInterestArea(tar, updateTargetGold, Enum.DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
|
||||
|
||||
// //TODO send group split message
|
||||
String text = "Group Split: " + amount;
|
||||
ChatManager.chatGroupInfo(pc, text);
|
||||
|
||||
@@ -200,11 +200,12 @@ public enum GuildManager {
|
||||
|
||||
}
|
||||
}
|
||||
public static Boolean meetsLoreRequirements(Guild guild, PlayerCharacter player){
|
||||
|
||||
public static Boolean meetsLoreRequirements(Guild guild, PlayerCharacter player) {
|
||||
Enum.GuildCharterType charter = guild.getGuildType();
|
||||
if(charter.requiredClasses.contains(player.absPromotionClass))
|
||||
if(charter.requiredRaces.contains(player.absRace))
|
||||
if(charter.sexRequired.contains(player.absGender))
|
||||
if (charter.requiredClasses.contains(player.absPromotionClass))
|
||||
if (charter.requiredRaces.contains(player.absRace))
|
||||
if (charter.sexRequired.contains(player.absGender))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
@@ -80,18 +80,22 @@ public enum LootManager {
|
||||
RunBootySet(_bootySetMap.get(mob.bootySet), mob, inHotzone);
|
||||
|
||||
//lastly, check mobs inventory for godly or disc runes to send a server announcement
|
||||
for (Item it : mob.getInventory()) {
|
||||
for (Item it : mob.getInventory()) {
|
||||
|
||||
ItemBase ib = it.getItemBase();
|
||||
if(ib == null)
|
||||
break;
|
||||
if (ib.isDiscRune() || ib.getName().toLowerCase().contains("of the gods")) {
|
||||
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + ib.getName() + ". Are you tough enough to take it?");
|
||||
chatMsg.setMessageType(10);
|
||||
chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID());
|
||||
DispatchMessage.dispatchMsgToAll(chatMsg);
|
||||
}
|
||||
ItemTemplate ib = it.template;
|
||||
|
||||
if (ib == null)
|
||||
break;
|
||||
|
||||
ItemTemplate template = ItemTemplate.templates.get(it.templateID);
|
||||
|
||||
if ((it.templateID > 2499 && it.templateID <= 3050) || template.item_base_name.toLowerCase().contains("of the gods")) {
|
||||
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + template.item_base_name + ". Are you tough enough to take it?");
|
||||
chatMsg.setMessageType(10);
|
||||
chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID());
|
||||
DispatchMessage.dispatchMsgToAll(chatMsg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -142,7 +146,7 @@ public enum LootManager {
|
||||
|
||||
MobLoot outItem;
|
||||
|
||||
int genRoll = ThreadLocalRandom.current().nextInt(1,100 + 1);
|
||||
int genRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1);
|
||||
|
||||
GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll, 1.0f);
|
||||
|
||||
@@ -155,47 +159,47 @@ public enum LootManager {
|
||||
return null;
|
||||
|
||||
//gets the 1-320 roll for this mob
|
||||
|
||||
int itemTableRoll = 0;
|
||||
int objectType = mob.getObjectType().ordinal();
|
||||
if(mob.getObjectType().ordinal() == 52) { //52 = player character
|
||||
itemTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1);
|
||||
} else{
|
||||
|
||||
if (mob.getObjectType().ordinal() == 52) //52 = player character
|
||||
itemTableRoll = ThreadLocalRandom.current().nextInt(1, 320 + 1);
|
||||
else
|
||||
itemTableRoll = TableRoll(mob.level, inHotzone);
|
||||
}
|
||||
|
||||
ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, itemTableRoll);
|
||||
|
||||
if (tableRow == null)
|
||||
return null;
|
||||
|
||||
int itemUUID = tableRow.cacheID;
|
||||
int itemUUID = tableRow.templateID;
|
||||
|
||||
if (itemUUID == 0)
|
||||
return null;
|
||||
|
||||
if (ItemBase.getItemBase(itemUUID).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) {
|
||||
if (ItemTemplate.templates.get(itemUUID).item_type.equals(Enum.ItemType.RESOURCE)) {
|
||||
int amount = ThreadLocalRandom.current().nextInt(tableRow.minSpawn, tableRow.maxSpawn + 1);
|
||||
return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false);
|
||||
return new MobLoot(mob, ItemTemplate.templates.get(itemUUID), amount, false);
|
||||
}
|
||||
|
||||
outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false);
|
||||
Enum.ItemType outType = outItem.getItemBase().getType();
|
||||
outItem = new MobLoot(mob, ItemTemplate.templates.get(itemUUID), false);
|
||||
|
||||
|
||||
if(selectedRow.pModTable != 0){
|
||||
if (selectedRow.pModTable != 0)
|
||||
try {
|
||||
outItem = GeneratePrefix(mob, outItem, genTableID, genRoll, inHotzone);
|
||||
outItem.setIsID(false);
|
||||
outItem.flags.remove(Enum.ItemFlags.Identified);
|
||||
} catch (Exception e) {
|
||||
Logger.error("Failed to GeneratePrefix for item: " + outItem.getName());
|
||||
}
|
||||
}
|
||||
if(selectedRow.sModTable != 0){
|
||||
|
||||
if (selectedRow.sModTable != 0)
|
||||
try {
|
||||
outItem = GenerateSuffix(mob, outItem, genTableID, genRoll, inHotzone);
|
||||
outItem.setIsID(false);
|
||||
outItem.flags.remove(Enum.ItemFlags.Identified);
|
||||
} catch (Exception e) {
|
||||
Logger.error("Failed to GenerateSuffix for item: " + outItem.getName());
|
||||
}
|
||||
}
|
||||
|
||||
return outItem;
|
||||
}
|
||||
|
||||
@@ -212,12 +216,14 @@ public enum LootManager {
|
||||
|
||||
if (prefixTable == null)
|
||||
return inItem;
|
||||
|
||||
int prefixTableRoll = 0;
|
||||
if(mob.getObjectType().ordinal() == 52) {
|
||||
prefixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1);
|
||||
} else{
|
||||
|
||||
if (mob.getObjectType().ordinal() == 52)
|
||||
prefixTableRoll = ThreadLocalRandom.current().nextInt(1, 320 + 1);
|
||||
else
|
||||
prefixTableRoll = TableRoll(mob.level, inHotzone);
|
||||
}
|
||||
|
||||
ModTableEntry prefixMod = ModTableEntry.rollTable(prefixTable.modTableID, prefixTableRoll);
|
||||
|
||||
if (prefixMod == null)
|
||||
@@ -244,12 +250,14 @@ public enum LootManager {
|
||||
|
||||
if (suffixTable == null)
|
||||
return inItem;
|
||||
int suffixTableRoll = 0;
|
||||
if(mob.getObjectType().ordinal() == 52) {
|
||||
suffixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1);
|
||||
} else{
|
||||
|
||||
int suffixTableRoll;
|
||||
|
||||
if (mob.getObjectType().ordinal() == 52)
|
||||
suffixTableRoll = ThreadLocalRandom.current().nextInt(1, 320 + 1);
|
||||
else
|
||||
suffixTableRoll = TableRoll(mob.level, inHotzone);
|
||||
}
|
||||
|
||||
ModTableEntry suffixMod = ModTableEntry.rollTable(suffixTable.modTableID, suffixTableRoll);
|
||||
|
||||
if (suffixMod == null)
|
||||
@@ -308,7 +316,7 @@ public enum LootManager {
|
||||
|
||||
if (gold > 0) {
|
||||
MobLoot goldAmount = new MobLoot(mob, gold);
|
||||
mob.getCharItemManager().addItemToInventory(goldAmount);
|
||||
mob.charItemManager.addItemToInventory(goldAmount);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -320,7 +328,7 @@ public enum LootManager {
|
||||
MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone);
|
||||
|
||||
if (toAdd != null)
|
||||
mob.getCharItemManager().addItemToInventory(toAdd);
|
||||
mob.charItemManager.addItemToInventory(toAdd);
|
||||
|
||||
} catch (Exception e) {
|
||||
//TODO chase down loot generation error, affects roughly 2% of drops
|
||||
@@ -330,28 +338,29 @@ public enum LootManager {
|
||||
|
||||
public static void GenerateEquipmentDrop(Mob mob) {
|
||||
|
||||
if(mob.behaviourType.equals(Enum.MobBehaviourType.HamletGuard))
|
||||
if (mob.behaviourType.equals(Enum.MobBehaviourType.HamletGuard))
|
||||
return; // safehold guards don't drop their equipment
|
||||
//do equipment here
|
||||
int dropCount = 0;
|
||||
if (mob.getEquip() != null)
|
||||
for (MobEquipment me : mob.getEquip().values()) {
|
||||
|
||||
if (me.getDropChance() == 0)
|
||||
if (mob.charItemManager.equipped.isEmpty() == false)
|
||||
for (Item item : mob.charItemManager.equipped.values()) {
|
||||
|
||||
if (item.drop_chance == 0)
|
||||
continue;
|
||||
|
||||
float equipmentRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1);
|
||||
float dropChance = me.getDropChance() * 100;
|
||||
float dropChance = item.drop_chance * 100;
|
||||
|
||||
if (equipmentRoll > dropChance)
|
||||
continue;
|
||||
|
||||
MobLoot ml = new MobLoot(mob, me.getItemBase(), false);
|
||||
MobLoot ml = new MobLoot(mob, item.template, false);
|
||||
|
||||
if (ml != null && dropCount < 1) {
|
||||
ml.setIsID(true);
|
||||
ml.setDurabilityCurrent((short) (ml.getDurabilityCurrent() - ThreadLocalRandom.current().nextInt(5) + 1));
|
||||
mob.getCharItemManager().addItemToInventory(ml);
|
||||
ml.flags.add(Enum.ItemFlags.Identified);
|
||||
ml.setCombat_health_current((short) ((short) ml.combat_health_current - ThreadLocalRandom.current().nextInt(5) + 1));
|
||||
mob.charItemManager.addItemToInventory(ml);
|
||||
dropCount = 1;
|
||||
//break; // Exit on first successful roll.
|
||||
}
|
||||
@@ -367,27 +376,27 @@ public enum LootManager {
|
||||
if (chanceRoll > bse.dropChance)
|
||||
return;
|
||||
|
||||
MobLoot lootItem = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true);
|
||||
MobLoot lootItem = new MobLoot(mob, ItemTemplate.templates.get(bse.templateID), true);
|
||||
|
||||
if (lootItem != null)
|
||||
mob.getCharItemManager().addItemToInventory(lootItem);
|
||||
mob.charItemManager.addItemToInventory(lootItem);
|
||||
}
|
||||
|
||||
public static void peddleFate(PlayerCharacter playerCharacter, Item gift) {
|
||||
|
||||
//get table ID for the itembase ID
|
||||
//get table ID for the itemtemplate
|
||||
|
||||
int tableID = 0;
|
||||
|
||||
if (_bootySetMap.get(gift.getItemBaseID()) != null)
|
||||
tableID = _bootySetMap.get(gift.getItemBaseID()).get(ThreadLocalRandom.current().nextInt(_bootySetMap.get(gift.getItemBaseID()).size())).genTable;
|
||||
if (_bootySetMap.get(gift.templateID) != null)
|
||||
tableID = _bootySetMap.get(gift.templateID).get(ThreadLocalRandom.current().nextInt(_bootySetMap.get(gift.templateID).size())).genTable;
|
||||
|
||||
if (tableID == 0)
|
||||
return;
|
||||
|
||||
//get the character item manager
|
||||
|
||||
CharacterItemManager itemMan = playerCharacter.getCharItemManager();
|
||||
CharacterItemManager itemMan = playerCharacter.charItemManager;
|
||||
|
||||
if (itemMan == null)
|
||||
return;
|
||||
@@ -402,7 +411,7 @@ public enum LootManager {
|
||||
int genRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1);
|
||||
GenTableEntry selectedRow = GenTableEntry.rollTable(tableID, genRoll, LootManager.NORMAL_DROP_RATE);
|
||||
|
||||
if(selectedRow == null)
|
||||
if (selectedRow == null)
|
||||
return;
|
||||
|
||||
//roll 220-320 for the item table selection
|
||||
@@ -415,36 +424,36 @@ public enum LootManager {
|
||||
|
||||
//create the item from the table, quantity is always 1
|
||||
|
||||
MobLoot winnings = new MobLoot(playerCharacter, ItemBase.getItemBase(selectedItem.cacheID), 1, false);
|
||||
MobLoot winnings = new MobLoot(playerCharacter, ItemTemplate.templates.get(selectedItem.templateID), 1, false);
|
||||
|
||||
if (winnings == null)
|
||||
return;
|
||||
|
||||
//early exit if the inventory of the player will not old the item
|
||||
|
||||
if (itemMan.hasRoomInventory(winnings.getItemBase().getWeight()) == false) {
|
||||
if (itemMan.hasRoomInventory(winnings.template.item_wt) == false) {
|
||||
ErrorPopupMsg.sendErrorPopup(playerCharacter, 21);
|
||||
return;
|
||||
}
|
||||
|
||||
//determine if the winning item needs a prefix
|
||||
|
||||
if(selectedRow.pModTable != 0){
|
||||
int prefixRoll = ThreadLocalRandom.current().nextInt(220,320 + 1);
|
||||
if (selectedRow.pModTable != 0) {
|
||||
int prefixRoll = ThreadLocalRandom.current().nextInt(220, 320 + 1);
|
||||
ModTableEntry prefix = ModTableEntry.rollTable(selectedRow.pModTable, prefixRoll);
|
||||
if(prefix != null)
|
||||
if (prefix != null)
|
||||
winnings.addPermanentEnchantment(prefix.action, 0, prefix.level, true);
|
||||
}
|
||||
|
||||
//determine if the winning item needs a suffix
|
||||
|
||||
if(selectedRow.sModTable != 0){
|
||||
int suffixRoll = ThreadLocalRandom.current().nextInt(220,320 + 1);
|
||||
if (selectedRow.sModTable != 0) {
|
||||
int suffixRoll = ThreadLocalRandom.current().nextInt(220, 320 + 1);
|
||||
ModTableEntry suffix = ModTableEntry.rollTable(selectedRow.sModTable, suffixRoll);
|
||||
if (suffix != null)
|
||||
winnings.addPermanentEnchantment(suffix.action, 0, suffix.level, true);
|
||||
}
|
||||
winnings.setIsID(true);
|
||||
winnings.flags.add(Enum.ItemFlags.Identified);
|
||||
|
||||
//remove gift from inventory
|
||||
|
||||
|
||||
@@ -12,11 +12,14 @@ package engine.gameManager;
|
||||
// building maintenance system.
|
||||
|
||||
import engine.Enum;
|
||||
import engine.objects.*;
|
||||
import engine.objects.Building;
|
||||
import engine.objects.City;
|
||||
import engine.objects.Warehouse;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public enum MaintenanceManager {
|
||||
|
||||
@@ -31,16 +34,23 @@ public enum MaintenanceManager {
|
||||
|
||||
public static void processBuildingMaintenance() {
|
||||
|
||||
ArrayList<AbstractGameObject> buildingList;
|
||||
ArrayList<Building> buildingList;
|
||||
ArrayList<Building> maintList;
|
||||
ArrayList<Building> derankList = new ArrayList<>();
|
||||
ArrayList<Building> tolList;
|
||||
ArrayList<Building> structureDerank = new ArrayList<>();
|
||||
ArrayList<Building> tolDerank = new ArrayList<>();
|
||||
|
||||
Logger.info("Starting Maintenance on Player Buildings");
|
||||
|
||||
// Build list of buildings to apply maintenance on.
|
||||
|
||||
buildingList = new ArrayList(DbManager.getList(Enum.GameObjectType.Building));
|
||||
maintList = buildMaintList(buildingList);
|
||||
HashMap<String, ArrayList<Building>> maintMap = new HashMap<>();
|
||||
|
||||
maintMap = buildMaintList(buildingList);
|
||||
|
||||
maintList = maintMap.get("maint");
|
||||
tolList = maintMap.get("tol");
|
||||
|
||||
// Deduct upkeep and build list of buildings
|
||||
// which did not have funds available
|
||||
@@ -48,10 +58,11 @@ public enum MaintenanceManager {
|
||||
try {
|
||||
for (Building building : maintList)
|
||||
if (chargeUpkeep(building) == false)
|
||||
derankList.add(building);
|
||||
structureDerank.add(building);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
// Reset maintenance dates for these buildings
|
||||
|
||||
for (Building building : maintList)
|
||||
@@ -61,25 +72,50 @@ public enum MaintenanceManager {
|
||||
// have funds available.
|
||||
|
||||
try {
|
||||
for (Building building : derankList)
|
||||
for (Building building : structureDerank)
|
||||
building.destroyOrDerank(null);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
Logger.info("Structures: " + buildingList.size() + " Maint: " + maintList.size() + " Derank: " + derankList.size());
|
||||
// Process TOL maintenance
|
||||
|
||||
try {
|
||||
for (Building building : tolList)
|
||||
if (chargeUpkeep(building) == false)
|
||||
tolDerank.add(building);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
// Reset maintenance dates for these buildings
|
||||
|
||||
for (Building building : tolList)
|
||||
setMaintDateTime(building, LocalDateTime.now().plusDays(7));
|
||||
|
||||
// Derak or destroy buildings that did not
|
||||
// have funds available.
|
||||
|
||||
try {
|
||||
for (Building building : tolDerank)
|
||||
building.destroyOrDerank(null);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
Logger.info("Structures: " + structureDerank.size() + "/" + maintList.size() + " TOLS: " + tolDerank.size() + "/" + tolList.size());
|
||||
}
|
||||
|
||||
// Iterate over all buildings in game and apply exclusion rules
|
||||
// returning a list of building for which maintenance is due.
|
||||
|
||||
private static ArrayList<Building> buildMaintList(ArrayList<AbstractGameObject> buildingList) {
|
||||
private static HashMap<String, ArrayList<Building>> buildMaintList(ArrayList<Building> buildingList) {
|
||||
|
||||
HashMap<String, ArrayList<Building>> outMap = new HashMap<>();
|
||||
ArrayList<Building> maintList = new ArrayList<>();
|
||||
ArrayList<Building> tolList = new ArrayList<>();
|
||||
|
||||
for (AbstractGameObject gameObject : buildingList) {
|
||||
|
||||
Building building = (Building) gameObject;
|
||||
for (Building building : buildingList) {
|
||||
|
||||
// No maintenance on NPC owned buildings (Cache loaded)
|
||||
|
||||
@@ -126,16 +162,23 @@ public enum MaintenanceManager {
|
||||
continue;
|
||||
|
||||
|
||||
//no maintenance if day of week doesnt match
|
||||
if (LocalDateTime.now().getDayOfWeek().ordinal() != building.maintDateTime.getDayOfWeek().ordinal()) {
|
||||
//no maintenance if day of week doesn't match
|
||||
|
||||
if (LocalDateTime.now().getDayOfWeek() != building.maintDateTime.getDayOfWeek())
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add building to maintenance queue
|
||||
|
||||
maintList.add(building);
|
||||
if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.TOL))
|
||||
tolList.add(building);
|
||||
else
|
||||
maintList.add(building);
|
||||
}
|
||||
|
||||
return maintList;
|
||||
outMap.put("maint", maintList);
|
||||
outMap.put("tol", tolList);
|
||||
|
||||
return outMap;
|
||||
}
|
||||
|
||||
// Method removes the appropriate amount of gold/resources from
|
||||
@@ -155,7 +198,7 @@ public enum MaintenanceManager {
|
||||
city = building.getCity();
|
||||
|
||||
if (city != null)
|
||||
warehouse = city.getWarehouse();
|
||||
warehouse = city.warehouse;
|
||||
|
||||
// Cache maintenance cost value
|
||||
|
||||
@@ -184,7 +227,7 @@ public enum MaintenanceManager {
|
||||
if ((overDraft > 0))
|
||||
if ((building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.SHRINE) == false) &&
|
||||
(warehouse != null) && building.assetIsProtected() == true &&
|
||||
(warehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) >= overDraft) {
|
||||
(warehouse.resources.get(Enum.ResourceType.GOLD)) >= overDraft) {
|
||||
hasFunds = true;
|
||||
}
|
||||
|
||||
@@ -199,22 +242,22 @@ public enum MaintenanceManager {
|
||||
hasResources = false;
|
||||
else {
|
||||
|
||||
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580000));
|
||||
resourceValue = warehouse.resources.get(Enum.ResourceType.STONE);
|
||||
|
||||
if (resourceValue < 1500)
|
||||
hasResources = false;
|
||||
|
||||
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580004));
|
||||
resourceValue = warehouse.resources.get(Enum.ResourceType.LUMBER);
|
||||
|
||||
if (resourceValue < 1500)
|
||||
hasResources = false;
|
||||
|
||||
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580017));
|
||||
resourceValue = warehouse.resources.get(Enum.ResourceType.GALVOR);
|
||||
|
||||
if (resourceValue < 5)
|
||||
hasResources = false;
|
||||
|
||||
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580018));
|
||||
resourceValue = warehouse.resources.get(Enum.ResourceType.WORMWOOD);
|
||||
|
||||
if (resourceValue < 5)
|
||||
hasResources = false;
|
||||
@@ -247,15 +290,16 @@ public enum MaintenanceManager {
|
||||
|
||||
if (overDraft > 0) {
|
||||
|
||||
resourceValue = warehouse.resources.get(ItemBase.getItemBase(7));
|
||||
resourceValue = warehouse.resources.get(Enum.ResourceType.GOLD);
|
||||
warehouse.resources.put(Enum.ResourceType.GOLD, resourceValue - overDraft);
|
||||
|
||||
if (DbManager.WarehouseQueries.updateGold(warehouse, resourceValue - overDraft) == true) {
|
||||
warehouse.resources.put(ItemBase.getItemBase(7), resourceValue - overDraft);
|
||||
Warehouse.AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.GOLD, overDraft);
|
||||
} else {
|
||||
Logger.error("gold update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||
if (!DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse)) {
|
||||
warehouse.resources.put(Enum.ResourceType.GOLD, resourceValue);
|
||||
Logger.error("gold update failed for warehouse of city:" + warehouse.city.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
Warehouse.AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Enum.ResourceType.GOLD, overDraft);
|
||||
}
|
||||
|
||||
// Early exit as we're done if we're not an R8 tree
|
||||
@@ -267,48 +311,54 @@ public enum MaintenanceManager {
|
||||
|
||||
// Withdraw Stone
|
||||
|
||||
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580000));
|
||||
resourceValue = warehouse.resources.get(Enum.ResourceType.STONE);
|
||||
warehouse.resources.put(Enum.ResourceType.STONE, resourceValue - 1500);
|
||||
|
||||
if (DbManager.WarehouseQueries.updateStone(warehouse, resourceValue - 1500) == true) {
|
||||
warehouse.resources.put(ItemBase.getItemBase(1580000), resourceValue - 1500);
|
||||
Warehouse.AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.STONE, 1500);
|
||||
} else {
|
||||
Logger.error("stone update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||
if (!DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse)) {
|
||||
warehouse.resources.put(Enum.ResourceType.STONE, resourceValue);
|
||||
Logger.error("stone update failed for warehouse of city:" + warehouse.city.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
Warehouse.AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Enum.ResourceType.STONE, 1500);
|
||||
|
||||
// Withdraw Lumber
|
||||
|
||||
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580004));
|
||||
resourceValue = warehouse.resources.get(Enum.ResourceType.LUMBER);
|
||||
warehouse.resources.put(Enum.ResourceType.LUMBER, resourceValue - 1500);
|
||||
|
||||
if (DbManager.WarehouseQueries.updateLumber(warehouse, resourceValue - 1500) == true) {
|
||||
warehouse.resources.put(ItemBase.getItemBase(1580004), resourceValue - 1500);
|
||||
Warehouse.AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.LUMBER, 1500);
|
||||
} else {
|
||||
Logger.error("lumber update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||
if (!DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse)) {
|
||||
warehouse.resources.put(Enum.ResourceType.STONE, resourceValue);
|
||||
Logger.error("lumber update failed for warehouse of city:" + warehouse.city.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
Warehouse.AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Enum.ResourceType.LUMBER, 1500);
|
||||
|
||||
// Withdraw Galvor
|
||||
|
||||
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580017));
|
||||
resourceValue = warehouse.resources.get(Enum.ResourceType.GALVOR);
|
||||
warehouse.resources.put(Enum.ResourceType.GALVOR, resourceValue - 5);
|
||||
|
||||
if (DbManager.WarehouseQueries.updateGalvor(warehouse, resourceValue - 5) == true) {
|
||||
warehouse.resources.put(ItemBase.getItemBase(1580017), resourceValue - 5);
|
||||
Warehouse.AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.GALVOR, 5);
|
||||
} else {
|
||||
Logger.error("galvor update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||
if (!DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse)) {
|
||||
warehouse.resources.put(Enum.ResourceType.GALVOR, resourceValue);
|
||||
Logger.error("GALVOR update failed for warehouse of city:" + warehouse.city.getName());
|
||||
return true;
|
||||
}
|
||||
Warehouse.AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Enum.ResourceType.GALVOR, 5);
|
||||
|
||||
// Withdraw GWORMWOOD
|
||||
|
||||
resourceValue = warehouse.resources.get(Enum.ResourceType.WORMWOOD);
|
||||
warehouse.resources.put(Enum.ResourceType.WORMWOOD, resourceValue - 5);
|
||||
|
||||
if (!DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse)) {
|
||||
warehouse.resources.put(Enum.ResourceType.GALVOR, resourceValue);
|
||||
Logger.error("wyrmwood update failed for warehouse of city:" + warehouse.city.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580018));
|
||||
|
||||
if (DbManager.WarehouseQueries.updateWormwood(warehouse, resourceValue - 5) == true) {
|
||||
warehouse.resources.put(ItemBase.getItemBase(1580018), resourceValue - 5);
|
||||
Warehouse.AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.WORMWOOD, 5);
|
||||
} else {
|
||||
Logger.error("wyrmwood update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||
}
|
||||
Warehouse.AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Enum.ResourceType.WORMWOOD, 5);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public enum MovementManager {
|
||||
toMove.setIsCasting(false);
|
||||
toMove.setItemCasting(false);
|
||||
|
||||
if (toMove.getBonuses().getBool(ModType.Stunned, SourceType.None) || toMove.getBonuses().getBool(ModType.CannotMove, SourceType.None)) {
|
||||
if (toMove.getBonuses().getBool(ModType.Stunned, SourceType.NONE) || toMove.getBonuses().getBool(ModType.CannotMove, SourceType.NONE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -312,17 +312,6 @@ public enum MovementManager {
|
||||
else
|
||||
Logger.debug("Movement sync is good - desyncDist = " + desyncDist);
|
||||
|
||||
if (ac.getDebug(1) && ac.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||
if (desyncDist > MBServerStatics.MOVEMENT_DESYNC_TOLERANCE * MBServerStatics.MOVEMENT_DESYNC_TOLERANCE) {
|
||||
PlayerCharacter pc = (PlayerCharacter) ac;
|
||||
ChatManager.chatSystemInfo(pc,
|
||||
"Movement out of sync for " + ac.getFirstName()
|
||||
+ ", Server Loc: " + serverLoc.getX() + ' ' + serverLoc.getZ()
|
||||
+ " , Client loc: " + clientLoc.getX() + ' ' + clientLoc.getZ()
|
||||
+ " desync distance " + desyncDist
|
||||
+ " moving=" + ac.isMoving());
|
||||
}
|
||||
|
||||
// return indicator that the two are in sync or not
|
||||
return (desyncDist < 100f * 100f);
|
||||
|
||||
@@ -347,9 +336,6 @@ public enum MovementManager {
|
||||
+ " moving=" + ac.isMoving()
|
||||
+ " and current location is " + curLoc.getX() + ' ' + curLoc.getZ());
|
||||
|
||||
if (ac.getDebug(1) && ac.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||
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
|
||||
ac.update();
|
||||
ac.stopMovement(ac.getLoc());
|
||||
@@ -405,7 +391,7 @@ public enum MovementManager {
|
||||
|
||||
//don't move if player is stunned or rooted
|
||||
PlayerBonuses bonus = member.getBonuses();
|
||||
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;
|
||||
|
||||
member.update();
|
||||
@@ -483,4 +469,5 @@ public enum MovementManager {
|
||||
private static void syncLoc(AbstractCharacter ac, Vector3fImmutable clientLoc, boolean useClientLoc) {
|
||||
ac.teleport(ac.getLoc());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,17 +5,17 @@ import engine.InterestManagement.WorldGrid;
|
||||
import engine.math.Quaternion;
|
||||
import engine.math.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.mobileAI.MobAI;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ErrorPopupMsg;
|
||||
import engine.net.client.msg.PetMsg;
|
||||
import engine.objects.*;
|
||||
import engine.powers.EffectsBase;
|
||||
import engine.powers.PowersBase;
|
||||
import engine.powers.RuneSkillAdjustEntry;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import javax.smartcardio.ATR;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
@@ -250,30 +250,30 @@ public enum NPCManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyGuardStanceModifiers(Mob guard){
|
||||
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)){
|
||||
if (guard.agentType.equals(Enum.AIAgentType.GUARDWALLARCHER)) {
|
||||
//apply rogue bonuses
|
||||
attackRatingModifier += 0.5f;
|
||||
defenseModifier += 0.5f;
|
||||
damageModifier += 0.5f;
|
||||
attackSpeedModifier -= 0.36f;
|
||||
}else {
|
||||
} else {
|
||||
Integer contractID;
|
||||
if (guard.agentType.equals(Enum.AIAgentType.GUARDMINION)) {
|
||||
contractID = guard.guardCaptain.contract.getContractID();
|
||||
} else{
|
||||
} else {
|
||||
contractID = guard.contract.getContractID();
|
||||
}
|
||||
if (Enum.MinionType.ContractToMinionMap.get(contractID) != null && Enum.MinionType.ContractToMinionMap.get(contractID).isMage()){
|
||||
if (Enum.MinionType.ContractToMinionMap.get(contractID) != null && Enum.MinionType.ContractToMinionMap.get(contractID).isMage()) {
|
||||
//apply mage offensive Stance
|
||||
powerDamageModifier += 0.5f;
|
||||
} else{
|
||||
} else {
|
||||
//apply fighter offensive stance
|
||||
damageModifier += 0.5f;
|
||||
attackSpeedModifier -= 0.36f;
|
||||
@@ -292,95 +292,98 @@ public enum NPCManager {
|
||||
//TODO figure out how to apply +50% powerdamage to mage guards
|
||||
}
|
||||
|
||||
public static void setDamageAndSpeedForGuard(Mob guard){
|
||||
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);
|
||||
if (guard.charItemManager.equipped.isEmpty()) {
|
||||
guard.minDamageHandOne = (int) ((guard.mobBase.getDamageMin()) * rankModifier);
|
||||
guard.maxDamageHandOne = (int) ((guard.mobBase.getDamageMax()) * rankModifier);
|
||||
guard.speedHandOne = 30.0f;
|
||||
}else{
|
||||
if(guard.equip.containsKey(1)){
|
||||
} else {
|
||||
if (guard.charItemManager.equipped.containsKey(Enum.EquipSlotType.RHELD)) {
|
||||
//has main hand weapon
|
||||
ItemBase weapon = guard.equip.get(1).getItemBase();
|
||||
if(weapon.isStrBased())
|
||||
Item weapon = guard.charItemManager.equipped.get(Enum.EquipSlotType.RHELD);
|
||||
|
||||
if (weapon.template.item_primary_attr.equals(Enum.AttributeType.Strength))
|
||||
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()){
|
||||
|
||||
guard.minDamageHandOne = (int) ((guard.mobBase.getDamageMin() + weapon.template.item_weapon_damage.values().iterator().next()[0]) * rankModifier) + primaryStat;
|
||||
guard.maxDamageHandOne = (int) ((guard.mobBase.getDamageMax() + weapon.template.item_weapon_damage.values().iterator().next()[1]) * rankModifier) + primaryStat;
|
||||
guard.speedHandOne = weapon.template.item_weapon_wepspeed;
|
||||
guard.rangeHandOne = weapon.template.item_weapon_max_range;
|
||||
} else if (guard.charItemManager.equipped.containsKey(Enum.EquipSlotType.LHELD) && !ItemTemplate.isShield(guard.charItemManager.equipped.get(Enum.EquipSlotType.LHELD).template)) {
|
||||
//has off hand weapon
|
||||
ItemBase weapon = guard.equip.get(2).getItemBase();
|
||||
if(weapon.isStrBased())
|
||||
Item weapon = guard.charItemManager.equipped.get(Enum.EquipSlotType.LHELD);
|
||||
if (weapon.template.item_primary_attr.equals(Enum.AttributeType.Strength))
|
||||
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();
|
||||
guard.minDamageHandOne = (int) ((guard.mobBase.getDamageMin() + weapon.template.item_weapon_damage.values().iterator().next()[0]) * rankModifier) + primaryStat;
|
||||
guard.maxDamageHandOne = (int) ((guard.mobBase.getDamageMax() + weapon.template.item_weapon_damage.values().iterator().next()[1]) * rankModifier) + primaryStat;
|
||||
guard.speedHandOne = weapon.template.item_weapon_wepspeed;
|
||||
guard.rangeHandOne = weapon.template.item_weapon_max_range;
|
||||
} else {
|
||||
primaryStat = guard.getStatStrCurrent();
|
||||
guard.minDamageHandOne = (int)((guard.mobBase.getDamageMin()) * rankModifier) + primaryStat;
|
||||
guard.maxDamageHandOne = (int)((guard.mobBase.getDamageMax()) * rankModifier) + primaryStat;
|
||||
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){
|
||||
public static void setDefenseForGuard(Mob guard) {
|
||||
int dexterity = guard.getStatDexCurrent();
|
||||
if(dexterity < 1)
|
||||
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();
|
||||
for (Item equipped : guard.charItemManager.equipped.values())
|
||||
if (equipped.template.item_type.equals(Enum.ItemType.ARMOR) || ItemTemplate.isShield(equipped.template))
|
||||
armorDefense += equipped.template.item_defense_rating;
|
||||
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));
|
||||
if (guard.charItemManager.equipped.get(Enum.EquipSlotType.RHELD) != null)
|
||||
guard.atrHandOne = baseAtr + (int) ((strength * 0.5f) + ((int)guard.charItemManager.equipped.get(Enum.EquipSlotType.RHELD).template.item_skill_required.values().toArray()[0] * 4) + ((int)guard.charItemManager.equipped.get(Enum.EquipSlotType.RHELD).template.item_skill_required.values().toArray()[0] * 3));
|
||||
else if (guard.charItemManager.equipped.get(Enum.EquipSlotType.LHELD) != null && !ItemTemplate.isShield(guard.charItemManager.equipped.get(Enum.EquipSlotType.LHELD).template))
|
||||
guard.atrHandTwo = baseAtr + (int) ((strength * 0.5f) + ((int)guard.charItemManager.equipped.get(Enum.EquipSlotType.LHELD).template.item_skill_required.values().toArray()[0] * 4) + ((int)guard.charItemManager.equipped.get(Enum.EquipSlotType.LHELD).template.item_skill_required.values().toArray()[0] * 3));
|
||||
else
|
||||
guard.atrHandOne = baseAtr;
|
||||
}
|
||||
|
||||
public static void setMaxHealthForGuard(Mob guard){
|
||||
public static void setMaxHealthForGuard(Mob guard) {
|
||||
//values derived fom reading memory address for health on client when selecting player guards
|
||||
switch(guard.getRank()){
|
||||
switch (guard.getRank()) {
|
||||
default:
|
||||
guard.healthMax = 750; //rank 1
|
||||
break;
|
||||
case 2:
|
||||
guard.healthMax = 2082;
|
||||
guard.healthMax = 2082;
|
||||
break;
|
||||
case 3:
|
||||
guard.healthMax = 2740;
|
||||
guard.healthMax = 2740;
|
||||
break;
|
||||
case 4:
|
||||
guard.healthMax = 3414;
|
||||
guard.healthMax = 3414;
|
||||
break;
|
||||
case 5:
|
||||
guard.healthMax = 4080;
|
||||
guard.healthMax = 4080;
|
||||
break;
|
||||
case 6:
|
||||
guard.healthMax = 4746;
|
||||
guard.healthMax = 4746;
|
||||
break;
|
||||
case 7:
|
||||
guard.healthMax = 5412;
|
||||
guard.healthMax = 5412;
|
||||
break;
|
||||
}
|
||||
guard.setHealth(guard.healthMax);
|
||||
}
|
||||
|
||||
public static void applyMobbaseEffects(Mob mob) {
|
||||
@@ -423,33 +426,34 @@ public enum NPCManager {
|
||||
}
|
||||
}
|
||||
|
||||
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 applyEquipmentResists(Mob mob) {
|
||||
|
||||
if (mob.charItemManager.equipped.isEmpty())
|
||||
return;
|
||||
|
||||
for (Item equipped : mob.charItemManager.equipped.values()) {
|
||||
if (equipped.template.item_type.equals(Enum.ItemType.ARMOR)) {
|
||||
mob.resists.setResist(Enum.SourceType.SLASHING, mob.resists.getResist(Enum.SourceType.SLASHING, 0) + equipped.template.combat_attack_resist.get("SLASHING"));
|
||||
mob.resists.setResist(Enum.SourceType.CRUSHING, mob.resists.getResist(Enum.SourceType.CRUSHING, 0) + equipped.template.combat_attack_resist.get("CRUSHING"));
|
||||
mob.resists.setResist(Enum.SourceType.PIERCING, mob.resists.getResist(Enum.SourceType.PIERCING, 0) + equipped.template.combat_attack_resist.get("PIERCING"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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()));
|
||||
if (baseSkill != null)
|
||||
mob.getSkills().put(baseSkill.getName(), new CharacterSkill(baseSkill, mob, mob.mobBase.getMobBaseStats().getBaseSkillAmount()));
|
||||
}
|
||||
|
||||
public static void applyRuneSkills(Mob mob, int runeID){
|
||||
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)
|
||||
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)
|
||||
if (skillBase == null)
|
||||
continue;
|
||||
if (entry.level <= mob.level)
|
||||
if (mob.skills.containsKey(entry.name) == false)
|
||||
@@ -459,19 +463,49 @@ public enum NPCManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyRunesForNPC(NPC npc){
|
||||
public static void applyRunesForNPC(NPC npc) {
|
||||
npc.runes = new ArrayList<>();
|
||||
RuneBase shopkeeperBase = RuneBase.getRuneBase(252620);
|
||||
CharacterRune shopkeeper = new CharacterRune(shopkeeperBase,npc.getObjectUUID());
|
||||
CharacterRune shopkeeper = new CharacterRune(shopkeeperBase, npc.getObjectUUID());
|
||||
npc.runes.add(shopkeeper);
|
||||
if(NPCManager._runeSetMap.containsKey(npc.runeSetID)) {
|
||||
if (NPCManager._runeSetMap.containsKey(npc.runeSetID)) {
|
||||
for (int runeID : _runeSetMap.get(npc.runeSetID)) {
|
||||
RuneBase rb = RuneBase.getRuneBase(runeID);
|
||||
if(rb != null) {
|
||||
if (rb != null) {
|
||||
CharacterRune toApply = new CharacterRune(rb, npc.getObjectUUID());
|
||||
npc.runes.add(toApply);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Boolean NPCVaultBankRangeCheck(PlayerCharacter pc, ClientConnection origin, String bankorvault) {
|
||||
|
||||
if (pc == null)
|
||||
return false;
|
||||
|
||||
NPC npc = pc.getLastNPCDialog();
|
||||
|
||||
if (npc == null)
|
||||
return false;
|
||||
|
||||
// System.out.println(npc.getContract().getName());
|
||||
// last npc must be either a banker or vault keeper
|
||||
|
||||
if (bankorvault.equals("vault")) {
|
||||
if (npc.getContract().getContractID() != 861)
|
||||
return false;
|
||||
} else
|
||||
// assuming banker
|
||||
|
||||
if (!npc.getContract().getName().equals("Bursar"))
|
||||
return false;
|
||||
|
||||
if (pc.getLoc().distanceSquared2D(npc.getLoc()) > MBServerStatics.NPC_TALK_RANGE * MBServerStatics.NPC_TALK_RANGE) {
|
||||
ErrorPopupMsg.sendErrorPopup(pc, 14);
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,10 @@ import engine.job.AbstractJob;
|
||||
import engine.job.AbstractScheduleJob;
|
||||
import engine.job.JobContainer;
|
||||
import engine.job.JobScheduler;
|
||||
import engine.jobs.*;
|
||||
import engine.jobs.AbstractEffectJob;
|
||||
import engine.jobs.FinishRecycleTimeJob;
|
||||
import engine.jobs.UseItemJob;
|
||||
import engine.jobs.UsePowerJob;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.net.ByteBufferWriter;
|
||||
import engine.net.Dispatch;
|
||||
@@ -28,7 +31,6 @@ import engine.net.client.msg.*;
|
||||
import engine.objects.*;
|
||||
import engine.powers.*;
|
||||
import engine.powers.poweractions.AbstractPowerAction;
|
||||
import engine.powers.poweractions.TrackPowerAction;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
@@ -170,11 +172,11 @@ public enum PowersManager {
|
||||
public static void usePower(final PerformActionMsg msg, ClientConnection origin,
|
||||
boolean sendCastToSelf) {
|
||||
|
||||
if(ConfigManager.MB_RULESET.getValue() == "LORE") {
|
||||
if (ConfigManager.MB_RULESET.getValue() == "LORE") {
|
||||
PowersBase pb = PowersManager.powersBaseByToken.get(msg.getPowerUsedID());
|
||||
PlayerCharacter caster = origin.getPlayerCharacter();
|
||||
PlayerCharacter target = PlayerCharacter.getFromCache(msg.getTargetID());
|
||||
if(pb != null && pb.isHarmful == false) {
|
||||
if (pb != null && pb.isHarmful == false) {
|
||||
if (caster.guild.equals(Guild.getErrantGuild()))
|
||||
return;
|
||||
|
||||
@@ -330,7 +332,7 @@ public enum PowersManager {
|
||||
// verify player is not stunned or prohibited from casting
|
||||
PlayerBonuses bonus = playerCharacter.getBonuses();
|
||||
SourceType sourceType = SourceType.GetSourceType(pb.getCategory());
|
||||
if (bonus != null && (bonus.getBool(ModType.Stunned, SourceType.None) || bonus.getBool(ModType.CannotCast, SourceType.None) || bonus.getBool(ModType.BlockedPowerType, sourceType)))
|
||||
if (bonus != null && (bonus.getBool(ModType.Stunned, SourceType.NONE) || bonus.getBool(ModType.CannotCast, SourceType.NONE) || bonus.getBool(ModType.BlockedPowerType, sourceType)))
|
||||
return true;
|
||||
|
||||
// if moving make sure spell valid for movement
|
||||
@@ -440,7 +442,7 @@ public enum PowersManager {
|
||||
|
||||
for (PowerPrereq pp : pb.getEquipPrereqs()) {
|
||||
|
||||
int slot = pp.mainHand() ? MBServerStatics.SLOT_MAINHAND : MBServerStatics.SLOT_OFFHAND;
|
||||
EquipSlotType slot = pp.mainHand() ? EquipSlotType.RHELD : EquipSlotType.LHELD;
|
||||
|
||||
if (playerCharacter.validEquip(slot, pp.getMessage())) {
|
||||
passed = true; //should have item in slot
|
||||
@@ -466,7 +468,7 @@ public enum PowersManager {
|
||||
cost = 0;
|
||||
|
||||
if (bonus != null)
|
||||
cost *= (1 + bonus.getFloatPercentAll(ModType.PowerCost, SourceType.None));
|
||||
cost *= (1 + bonus.getFloatPercentAll(ModType.PowerCost, SourceType.NONE));
|
||||
|
||||
if (playerCharacter.getAltitude() > 0)
|
||||
cost *= 1.5f;
|
||||
@@ -613,7 +615,7 @@ public enum PowersManager {
|
||||
// verify player is not stunned or prohibited from casting
|
||||
PlayerBonuses bonus = caster.getBonuses();
|
||||
SourceType sourceType = SourceType.GetSourceType(pb.getCategory());
|
||||
if (bonus != null && (bonus.getBool(ModType.Stunned, SourceType.None) || bonus.getBool(ModType.CannotCast, SourceType.None) || bonus.getBool(ModType.BlockedPowerType, sourceType)))
|
||||
if (bonus != null && (bonus.getBool(ModType.Stunned, SourceType.NONE) || bonus.getBool(ModType.CannotCast, SourceType.NONE) || bonus.getBool(ModType.BlockedPowerType, sourceType)))
|
||||
return true;
|
||||
|
||||
// if moving make sure spell valid for movement
|
||||
@@ -773,7 +775,7 @@ public enum PowersManager {
|
||||
PlayerBonuses bonus = playerCharacter.getBonuses();
|
||||
|
||||
if (bonus != null) {
|
||||
if (bonus.getBool(ModType.Stunned, SourceType.None))
|
||||
if (bonus.getBool(ModType.Stunned, SourceType.NONE))
|
||||
return;
|
||||
|
||||
SourceType sourceType = SourceType.GetSourceType(pb.getCategory());
|
||||
@@ -1051,7 +1053,7 @@ public enum PowersManager {
|
||||
// verify player is not stunned or power type is blocked
|
||||
PlayerBonuses bonus = caster.getBonuses();
|
||||
if (bonus != null) {
|
||||
if (bonus.getBool(ModType.Stunned, SourceType.None))
|
||||
if (bonus.getBool(ModType.Stunned, SourceType.NONE))
|
||||
return;
|
||||
SourceType sourceType = SourceType.GetSourceType(pb.getCategory());
|
||||
if (bonus.getBool(ModType.BlockedPowerType, sourceType))
|
||||
@@ -1188,8 +1190,8 @@ public enum PowersManager {
|
||||
PlayerCharacter pc = (PlayerCharacter) target;
|
||||
int raceID = 0;
|
||||
|
||||
if (pc.getRace() != null)
|
||||
raceID = pc.getRace().getRaceRuneID();
|
||||
if (pc.race != null)
|
||||
raceID = pc.race.getRaceRuneID();
|
||||
|
||||
switch (mtp) {
|
||||
case "Shade":
|
||||
@@ -1241,264 +1243,7 @@ public enum PowersManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void summon(SendSummonsRequestMsg msg, ClientConnection origin) {
|
||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(
|
||||
origin);
|
||||
if (pc == null)
|
||||
return;
|
||||
|
||||
PlayerCharacter target = SessionManager
|
||||
.getPlayerCharacterByLowerCaseName(msg.getTargetName());
|
||||
if (target == null || target.equals(pc) || target.isCombat()) {
|
||||
|
||||
if (target == null) // Player not found. Send not found message
|
||||
ChatManager.chatInfoError(pc,
|
||||
"Cannot find that player to summon.");
|
||||
else if (target.isCombat())
|
||||
ChatManager.chatInfoError(pc,
|
||||
"Cannot summon player in combat.");
|
||||
// else trying to summon self, just fail
|
||||
|
||||
// recycle summon
|
||||
sendRecyclePower(msg.getPowerToken(), origin);
|
||||
|
||||
// TODO: client already subtracted 200 mana.. need to correct it
|
||||
// end cast
|
||||
PerformActionMsg pam = new PerformActionMsg(msg.getPowerToken(),
|
||||
msg.getTrains(), msg.getSourceType(), msg.getSourceID(), 0,
|
||||
0, 0f, 0f, 0f, 1, 0);
|
||||
sendPowerMsg(pc, 2, pam);
|
||||
|
||||
return;
|
||||
}
|
||||
if(ConfigManager.MB_RULESET.getValue() == "LORE") {
|
||||
if (pc.guild.getGuildType().equals(target.guild.getGuildType()) == false) {
|
||||
ChatManager.chatInfoError(pc,
|
||||
"Cannot summon player outside your charter.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
PerformActionMsg pam = new PerformActionMsg(msg.getPowerToken(), msg
|
||||
.getTrains(), msg.getSourceType(), msg.getSourceID(), target
|
||||
.getObjectType().ordinal(), target.getObjectUUID(), 0f, 0f, 0f, 1, 0);
|
||||
|
||||
// Client removes 200 mana on summon use.. so don't send message to self
|
||||
target.addSummoner(pc.getObjectUUID(), System.currentTimeMillis() + MBServerStatics.FOURTYFIVE_SECONDS);
|
||||
usePower(pam, origin, false);
|
||||
}
|
||||
|
||||
public static void recvSummon(RecvSummonsRequestMsg msg, ClientConnection origin) {
|
||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
|
||||
if (pc == null)
|
||||
return;
|
||||
|
||||
PlayerCharacter source = PlayerCharacter.getFromCache(msg.getSourceID());
|
||||
if (source == null)
|
||||
return;
|
||||
|
||||
long tooLate = pc.getSummoner(source.getObjectUUID());
|
||||
if (tooLate < System.currentTimeMillis()) {
|
||||
ChatManager.chatInfoError(pc, "You waited too long to " + (msg.accepted() ? "accept" : "decline") + " the summons.");
|
||||
pc.removeSummoner(source.getObjectUUID());
|
||||
return;
|
||||
}
|
||||
|
||||
if (pc.getBonuses() != null && pc.getBonuses().getBool(ModType.BlockedPowerType, SourceType.SUMMON)) {
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "You have been blocked from receiving summons!");
|
||||
ErrorPopupMsg.sendErrorMsg(source, "Target is blocked from receiving summons!");
|
||||
pc.removeSummoner(source.getObjectUUID());
|
||||
return;
|
||||
}
|
||||
pc.removeSummoner(source.getObjectUUID());
|
||||
|
||||
// Handle Accepting or Denying a summons.
|
||||
// set timer based on summon type.
|
||||
boolean wentThrough = false;
|
||||
if (msg.accepted())
|
||||
// summons accepted, let's move the player if within time
|
||||
if (source.isAlive()) {
|
||||
|
||||
// //make sure summons handled in time
|
||||
ConcurrentHashMap<String, JobContainer> timers = source.getTimers();
|
||||
// if (timers == null || !timers.containsKey("SummonSend")) {
|
||||
// ChatManager.chatInfoError(pc, "You waited too long to " + (msg.accepted() ? "accept" : "decline") + " the summons.");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // clear last summons accept timer
|
||||
// timers.get("SummonSend").cancelJob();
|
||||
//timers.remove("SummonSend");
|
||||
// cancel any other summons waiting
|
||||
timers = pc.getTimers();
|
||||
if (timers != null && timers.containsKey("Summon"))
|
||||
timers.get("Summon").cancelJob();
|
||||
|
||||
// get time to wait before summons goes through
|
||||
BaseClass base = source.getBaseClass();
|
||||
PromotionClass promo = source.getPromotionClass();
|
||||
int duration;
|
||||
|
||||
|
||||
//determine if in combat with another player
|
||||
|
||||
|
||||
//comment out this block to disable combat timer
|
||||
// if (lastAttacked < 60000) {
|
||||
// if (pc.inSafeZone()) //player in safe zone, no need for combat timer
|
||||
// combat = false;
|
||||
// else if (source.inSafeZone()) //summoner in safe zone, apply combat timer
|
||||
// combat = true;
|
||||
// else if ((source.getLoc().distance2D(pc.getLoc())) > 6144f)
|
||||
// combat = true; //more than 1.5x width of zone, not tactical summons
|
||||
// }
|
||||
|
||||
if (promo != null && promo.getObjectUUID() == 2519)
|
||||
duration = 10000; // Priest summons, 10 seconds
|
||||
else if (base != null && base.getObjectUUID() == 2501)
|
||||
duration = 15000; // Healer Summons, 15 seconds
|
||||
else
|
||||
duration = 45000; // Belgosh Summons, 45 seconds
|
||||
|
||||
|
||||
// Teleport to summoners location
|
||||
FinishSummonsJob fsj = new FinishSummonsJob(source, pc);
|
||||
JobContainer jc = JobScheduler.getInstance().scheduleJob(fsj,
|
||||
duration);
|
||||
if (timers != null)
|
||||
timers.put("Summon", jc);
|
||||
wentThrough = true;
|
||||
}
|
||||
|
||||
// Summons failed
|
||||
if (!wentThrough)
|
||||
// summons refused. Let's be nice and reset recycle timer
|
||||
if (source != null) {
|
||||
|
||||
// Send summons refused Message
|
||||
ErrorPopupMsg.sendErrorPopup(source, 29);
|
||||
|
||||
// recycle summons power
|
||||
//finishRecycleTime(428523680, source, true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void trackWindow(TrackWindowMsg msg, ClientConnection origin) {
|
||||
|
||||
PlayerCharacter playerCharacter = SessionManager.getPlayerCharacter(
|
||||
origin);
|
||||
|
||||
if (playerCharacter == null)
|
||||
return;
|
||||
|
||||
if (MBServerStatics.POWERS_DEBUG) {
|
||||
ChatManager.chatSayInfo(
|
||||
playerCharacter,
|
||||
"Using Power: " + Integer.toHexString(msg.getPowerToken())
|
||||
+ " (" + msg.getPowerToken() + ')');
|
||||
Logger.info("Using Power: "
|
||||
+ Integer.toHexString(msg.getPowerToken()) + " ("
|
||||
+ msg.getPowerToken() + ')');
|
||||
}
|
||||
|
||||
// get track power used
|
||||
PowersBase pb = PowersManager.powersBaseByToken.get(msg.getPowerToken());
|
||||
|
||||
if (pb == null || !pb.isTrack())
|
||||
return;
|
||||
|
||||
//check track threshold timer to prevent spam
|
||||
long currentTime = System.currentTimeMillis();
|
||||
long timestamp = playerCharacter.getTimeStamp("trackWindow");
|
||||
long dif = currentTime - timestamp;
|
||||
if (dif < MBServerStatics.TRACK_WINDOW_THRESHOLD)
|
||||
return;
|
||||
playerCharacter.setTimeStamp("trackWindow", currentTime);
|
||||
|
||||
ArrayList<ActionsBase> ablist = pb.getActions();
|
||||
if (ablist == null)
|
||||
return;
|
||||
|
||||
TrackPowerAction tpa = null;
|
||||
for (ActionsBase ab : ablist) {
|
||||
AbstractPowerAction apa = ab.getPowerAction();
|
||||
if (apa != null && apa instanceof TrackPowerAction)
|
||||
tpa = (TrackPowerAction) apa;
|
||||
}
|
||||
if (tpa == null)
|
||||
return;
|
||||
|
||||
// Check powers for normal users
|
||||
if (playerCharacter.getPowers() == null || !playerCharacter.getPowers().containsKey(msg.getPowerToken()))
|
||||
if (!playerCharacter.isCSR())
|
||||
if (!MBServerStatics.POWERS_DEBUG) {
|
||||
// ChatManager.chatSayInfo(pc, "You may not cast that spell!");
|
||||
// this.logEXPLOIT("usePowerA(): Cheat attempted? '" + msg.getPowerToken() + "' was not associated with " + pc.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
// Get search mask for track
|
||||
int mask = 0;
|
||||
if (pb.targetPlayer())
|
||||
if (tpa.trackVampire()) // track vampires
|
||||
mask = MBServerStatics.MASK_PLAYER | MBServerStatics.MASK_UNDEAD;
|
||||
else
|
||||
// track all players
|
||||
mask = MBServerStatics.MASK_PLAYER;
|
||||
else if (pb.targetCorpse()) // track corpses
|
||||
mask = MBServerStatics.MASK_CORPSE;
|
||||
else if (tpa.trackNPC()) // Track NPCs
|
||||
mask = MBServerStatics.MASK_NPC;
|
||||
else if (tpa.trackUndead()) // Track Undead
|
||||
mask = MBServerStatics.MASK_MOB | MBServerStatics.MASK_UNDEAD;
|
||||
else
|
||||
// Track All
|
||||
mask = MBServerStatics.MASK_MOB | MBServerStatics.MASK_NPC;
|
||||
|
||||
// Find characters in range
|
||||
HashSet<AbstractWorldObject> allTargets;
|
||||
allTargets = WorldGrid.getObjectsInRangeContains(playerCharacter.getLoc(),
|
||||
pb.getRange(), mask);
|
||||
|
||||
//remove anyone who can't be tracked
|
||||
Iterator<AbstractWorldObject> it = allTargets.iterator();
|
||||
while (it.hasNext()) {
|
||||
AbstractWorldObject awo = it.next();
|
||||
if (awo == null)
|
||||
continue;
|
||||
else if (!awo.isAlive())
|
||||
it.remove();
|
||||
else if (awo.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
||||
PlayerBonuses bonus = ((PlayerCharacter) awo).getBonuses();
|
||||
if (bonus != null && bonus.getBool(ModType.CannotTrack, SourceType.None))
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
// get max charcters for window
|
||||
int maxTargets = 20;
|
||||
PromotionClass promo = playerCharacter.getPromotionClass();
|
||||
if (promo != null) {
|
||||
int tableID = promo.getObjectUUID();
|
||||
if (tableID == 2512 || tableID == 2514 || tableID == 2515)
|
||||
maxTargets = 40;
|
||||
}
|
||||
|
||||
// create list of characters
|
||||
HashSet<AbstractCharacter> trackChars = RangeBasedAwo.getTrackList(
|
||||
allTargets, playerCharacter, maxTargets);
|
||||
|
||||
TrackWindowMsg trackWindowMsg = new TrackWindowMsg(msg);
|
||||
|
||||
// send track window
|
||||
trackWindowMsg.setSource(playerCharacter);
|
||||
trackWindowMsg.setCharacters(trackChars);
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(playerCharacter, trackWindowMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
}
|
||||
|
||||
private static void sendRecyclePower(int token, ClientConnection origin) {
|
||||
public static void sendRecyclePower(int token, ClientConnection origin) {
|
||||
RecyclePowerMsg recyclePowerMsg = new RecyclePowerMsg(token);
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(origin.getPlayerCharacter(), recyclePowerMsg);
|
||||
@@ -1520,7 +1265,7 @@ public enum PowersManager {
|
||||
|
||||
if (owner.getObjectType().equals(GameObjectType.PlayerCharacter) || owner.getObjectType().equals(GameObjectType.Mob)) {
|
||||
AbstractCharacter acOwner = (AbstractCharacter) owner;
|
||||
CharacterItemManager itemMan = acOwner.getCharItemManager();
|
||||
CharacterItemManager itemMan = acOwner.charItemManager;
|
||||
if (itemMan == null)
|
||||
return true;
|
||||
if (itemMan.inventoryContains(item)) {
|
||||
@@ -1943,7 +1688,7 @@ public enum PowersManager {
|
||||
PlayerCharacter pcc = (PlayerCharacter) awo;
|
||||
PlayerBonuses bonuses = pcc.getBonuses();
|
||||
|
||||
if (bonuses != null && bonuses.getBool(ModType.ImmuneToPowers, SourceType.None)) {
|
||||
if (bonuses != null && bonuses.getBool(ModType.ImmuneToPowers, SourceType.NONE)) {
|
||||
awolist.remove();
|
||||
continue;
|
||||
}
|
||||
@@ -2093,7 +1838,7 @@ public enum PowersManager {
|
||||
// Remove players who are in safe mode
|
||||
PlayerCharacter pcc = (PlayerCharacter) awo;
|
||||
PlayerBonuses bonuses = pcc.getBonuses();
|
||||
if (bonuses != null && bonuses.getBool(ModType.ImmuneToPowers, SourceType.None)) {
|
||||
if (bonuses != null && bonuses.getBool(ModType.ImmuneToPowers, SourceType.NONE)) {
|
||||
awolist.remove();
|
||||
continue;
|
||||
}
|
||||
@@ -2261,12 +2006,8 @@ public enum PowersManager {
|
||||
defense = tar.getDefenseRating();
|
||||
} else
|
||||
defense = 0f;
|
||||
// Get hit chance
|
||||
|
||||
if (pc.getDebug(16)) {
|
||||
String smsg = "ATR: " + atr + ", Defense: " + defense;
|
||||
ChatManager.chatSystemInfo(pc, smsg);
|
||||
}
|
||||
// Get hit chance
|
||||
|
||||
int chance;
|
||||
|
||||
@@ -2502,12 +2243,12 @@ public enum PowersManager {
|
||||
if (pb.targetItem())
|
||||
return true;
|
||||
// TODO add these checks later
|
||||
else if (pb.targetArmor() && item.getItemBase().getType().equals(ItemType.ARMOR))
|
||||
else if (pb.targetArmor() && item.template.item_type.equals(ItemType.ARMOR))
|
||||
return true;
|
||||
else if (pb.targetJewelry() && item.getItemBase().getType().equals(ItemType.JEWELRY))
|
||||
else if (pb.targetJewelry() && item.template.item_type.equals(ItemType.JEWELRY))
|
||||
return true;
|
||||
else
|
||||
return pb.targetWeapon() && item.getItemBase().getType().equals(ItemType.WEAPON);
|
||||
return pb.targetWeapon() && item.template.item_type.equals(ItemType.WEAPON);
|
||||
} // How did we get here? all valid targets have been covered
|
||||
else
|
||||
return false;
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.gameManager;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.*;
|
||||
import engine.objects.CharacterItemManager;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
public enum TradeManager {
|
||||
|
||||
TRADEMANAGER;
|
||||
|
||||
public static void tradeRequest(TradeRequestMsg msg, ClientConnection origin) {
|
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter();
|
||||
|
||||
if (source == null)
|
||||
return;
|
||||
|
||||
source.getCharItemManager().tradeRequest(msg);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void acceptTradeRequest(AcceptTradeRequestMsg msg, ClientConnection origin) {
|
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter();
|
||||
|
||||
if (source == null)
|
||||
return;
|
||||
|
||||
try {
|
||||
source.getCharItemManager().acceptTradeRequest(msg);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
// TODO Auto-generated catch block
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void rejectTradeRequest(RejectTradeRequestMsg msg, ClientConnection origin) {
|
||||
// TODO Do nothing? If so, delete this method & case above
|
||||
}
|
||||
|
||||
public static void addItemToTradeWindow(AddItemToTradeWindowMsg msg, ClientConnection origin) {
|
||||
|
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter();
|
||||
if (source == null || !source.isAlive())
|
||||
return;
|
||||
try {
|
||||
source.getCharItemManager().addItemToTradeWindow(msg);
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void addGoldToTradeWindow(AddGoldToTradeWindowMsg msg, ClientConnection origin) {
|
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter();
|
||||
|
||||
if (source == null || !source.isAlive())
|
||||
return;
|
||||
|
||||
|
||||
CharacterItemManager sourceItemMan = source.getCharItemManager();
|
||||
|
||||
if (sourceItemMan == null)
|
||||
return;
|
||||
|
||||
try {
|
||||
sourceItemMan.addGoldToTradeWindow(msg);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void commitToTrade(CommitToTradeMsg msg, ClientConnection origin) {
|
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter();
|
||||
|
||||
if (source == null || !source.isAlive())
|
||||
return;
|
||||
|
||||
CharacterItemManager sourceItemMan = source.getCharItemManager();
|
||||
|
||||
if (sourceItemMan == null)
|
||||
return;
|
||||
|
||||
try {
|
||||
sourceItemMan.commitToTrade(msg);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void uncommitToTrade(UncommitToTradeMsg msg, ClientConnection origin) {
|
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter();
|
||||
|
||||
if (source == null || !source.isAlive())
|
||||
return;
|
||||
|
||||
CharacterItemManager sourceItemMan = source.getCharItemManager();
|
||||
|
||||
if (sourceItemMan == null)
|
||||
return;
|
||||
|
||||
try {
|
||||
sourceItemMan.uncommitToTrade(msg);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void closeTradeWindow(CloseTradeWindowMsg msg, ClientConnection origin) {
|
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter();
|
||||
|
||||
if (source == null)
|
||||
return;
|
||||
|
||||
CharacterItemManager sourceItemMan = source.getCharItemManager();
|
||||
|
||||
if (sourceItemMan == null)
|
||||
return;
|
||||
|
||||
try {
|
||||
sourceItemMan.closeTradeWindow(msg, true);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void invalidTradeRequest(InvalidTradeRequestMsg msg) {
|
||||
PlayerCharacter requester = PlayerCharacter.getFromCache(msg.getRequesterID());
|
||||
Dispatch dispatch;
|
||||
|
||||
dispatch = Dispatch.borrow(requester, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public class AttackJob extends AbstractJob {
|
||||
|
||||
@Override
|
||||
protected void doJob() {
|
||||
CombatManager.doCombat(this.source, slot);
|
||||
CombatManager.combatCycle(this.source, this.source.combatTarget);
|
||||
}
|
||||
|
||||
public boolean success() {
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ChantJob extends AbstractEffectJob {
|
||||
PowersManager.finishEffectTime(this.source, this.target, this.action, this.trains);
|
||||
if (AbstractWorldObject.IsAbstractCharacter(source))
|
||||
((AbstractCharacter) source).cancelLastChant();
|
||||
} else if (bonuses != null && bonuses.getBool(ModType.Silenced, SourceType.None)) {
|
||||
} else if (bonuses != null && bonuses.getBool(ModType.Silenced, SourceType.NONE)) {
|
||||
PowersManager.finishEffectTime(this.source, this.target, this.action, this.trains);
|
||||
if (AbstractWorldObject.IsAbstractCharacter(source))
|
||||
((AbstractCharacter) source).cancelLastChant();
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
package engine.jobs;
|
||||
|
||||
import engine.gameManager.CombatManager;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.AbstractCharacter;
|
||||
@@ -77,10 +76,12 @@ public class DeferredPowerJob extends AbstractEffectJob {
|
||||
// Wtf? Method returns TRUE if rage test fails? Seriously?
|
||||
|
||||
//DO valid range check ONLY for weapon powers with range less than attack range.
|
||||
if (attackRange > powerRange)
|
||||
if (CombatManager.NotInRange((AbstractCharacter) this.source, tar, powerRange))
|
||||
if (attackRange > powerRange) {
|
||||
float rangeSquared = this.source.loc.distanceSquared(tar.loc);
|
||||
if (rangeSquared > powerRange * powerRange) {
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
//Range check passed, apply power and clear weapon power.
|
||||
((PlayerCharacter) this.source).setWeaponPower(null);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class BootySetEntry {
|
||||
public String bootyType;
|
||||
public int lowGold;
|
||||
public int highGold;
|
||||
public int itemBase;
|
||||
public int templateID;
|
||||
public int genTable;
|
||||
public float dropChance;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class BootySetEntry {
|
||||
this.bootyType = (rs.getString("bootyType"));
|
||||
this.lowGold = (rs.getInt("lowGold"));
|
||||
this.highGold = (rs.getInt("highGold"));
|
||||
this.itemBase = (rs.getInt("itemBase"));
|
||||
this.templateID = (rs.getInt("templateID"));
|
||||
this.genTable = (rs.getInt("genTable"));
|
||||
this.dropChance = (rs.getFloat("dropChance"));
|
||||
}
|
||||
|
||||
@@ -17,14 +17,14 @@ import java.util.List;
|
||||
public class ItemTableEntry {
|
||||
public int minRoll;
|
||||
public int maxRoll;
|
||||
public int cacheID;
|
||||
public int templateID;
|
||||
public int minSpawn;
|
||||
public int maxSpawn;
|
||||
|
||||
public ItemTableEntry(ResultSet rs) throws SQLException {
|
||||
this.minRoll = rs.getInt("minRoll");
|
||||
this.maxRoll = rs.getInt("maxRoll");
|
||||
this.cacheID = rs.getInt("itemBaseUUID");
|
||||
this.templateID = rs.getInt("templateID");
|
||||
this.minSpawn = rs.getInt("minSpawn");
|
||||
this.maxSpawn = rs.getInt("maxSpawn");
|
||||
}
|
||||
|
||||
+46
-112
@@ -16,7 +16,6 @@ import engine.math.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.mobileAI.Threads.MobAIThread;
|
||||
import engine.mobileAI.Threads.Respawner;
|
||||
import engine.mobileAI.utilities.CombatUtilities;
|
||||
import engine.mobileAI.utilities.MovementUtilities;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.msg.PerformActionMsg;
|
||||
@@ -66,7 +65,7 @@ public class MobAI {
|
||||
|
||||
}
|
||||
|
||||
if (!CombatUtilities.inRangeToAttack(mob, target))
|
||||
if (mob.getRange() * mob.getRange() < mob.loc.distanceSquared(target.loc))
|
||||
return;
|
||||
|
||||
switch (target.getObjectType()) {
|
||||
@@ -108,42 +107,15 @@ public class MobAI {
|
||||
return;
|
||||
}
|
||||
|
||||
if (CombatUtilities.inRange2D(mob, target, mob.getRange())) {
|
||||
if (mob.getRange() * mob.getRange() >= mob.loc.distanceSquared(target.loc)) {
|
||||
|
||||
//no weapons, default mob attack speed 3 seconds.
|
||||
|
||||
if (System.currentTimeMillis() < mob.getLastAttackTime())
|
||||
return;
|
||||
|
||||
// ranged mobs cant attack while running. skip until they finally stop.
|
||||
|
||||
if (mob.isMoving() && mob.getRange() > 20)
|
||||
return;
|
||||
|
||||
// add timer for last attack.
|
||||
|
||||
ItemBase mainHand = mob.getWeaponItemBase(true);
|
||||
ItemBase offHand = mob.getWeaponItemBase(false);
|
||||
|
||||
if (mainHand == null && offHand == null) {
|
||||
CombatUtilities.combatCycle(mob, target, true, null);
|
||||
int delay = 3000;
|
||||
if (mob.isSiege())
|
||||
delay = 11000;
|
||||
mob.setLastAttackTime(System.currentTimeMillis() + delay);
|
||||
} else if (mob.getWeaponItemBase(true) != null) {
|
||||
int delay = 3000;
|
||||
if (mob.isSiege())
|
||||
delay = 11000;
|
||||
CombatUtilities.combatCycle(mob, target, true, mob.getWeaponItemBase(true));
|
||||
mob.setLastAttackTime(System.currentTimeMillis() + delay);
|
||||
} else if (mob.getWeaponItemBase(false) != null) {
|
||||
int attackDelay = 3000;
|
||||
if (mob.isSiege())
|
||||
attackDelay = 11000;
|
||||
CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false));
|
||||
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
|
||||
}
|
||||
CombatManager.combatCycle(mob,mob.combatTarget);
|
||||
}
|
||||
|
||||
if (target.getPet() != null)
|
||||
@@ -176,28 +148,8 @@ public class MobAI {
|
||||
if (mob.isSiege())
|
||||
MovementManager.sendRWSSMsg(mob);
|
||||
|
||||
ItemBase mainHand = mob.getWeaponItemBase(true);
|
||||
ItemBase offHand = mob.getWeaponItemBase(false);
|
||||
|
||||
if (mainHand == null && offHand == null) {
|
||||
CombatUtilities.combatCycle(mob, target, true, null);
|
||||
int delay = 3000;
|
||||
if (mob.isSiege())
|
||||
delay = 15000;
|
||||
mob.setLastAttackTime(System.currentTimeMillis() + delay);
|
||||
} else if (mob.getWeaponItemBase(true) != null) {
|
||||
int attackDelay = 3000;
|
||||
if (mob.isSiege())
|
||||
attackDelay = 15000;
|
||||
CombatUtilities.combatCycle(mob, target, true, mob.getWeaponItemBase(true));
|
||||
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
|
||||
} else if (mob.getWeaponItemBase(false) != null) {
|
||||
int attackDelay = 3000;
|
||||
if (mob.isSiege())
|
||||
attackDelay = 15000;
|
||||
CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false));
|
||||
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
|
||||
}
|
||||
CombatManager.combatCycle(mob, target);
|
||||
|
||||
if (mob.isSiege()) {
|
||||
PowerProjectileMsg ppm = new PowerProjectileMsg(mob, target);
|
||||
@@ -219,31 +171,9 @@ public class MobAI {
|
||||
|
||||
//no weapons, default mob attack speed 3 seconds.
|
||||
|
||||
ItemBase mainHand = mob.getWeaponItemBase(true);
|
||||
ItemBase offHand = mob.getWeaponItemBase(false);
|
||||
|
||||
if (mainHand == null && offHand == null) {
|
||||
CombatUtilities.combatCycle(mob, target, true, null);
|
||||
int delay = 3000;
|
||||
if (mob.isSiege())
|
||||
delay = 11000;
|
||||
mob.setLastAttackTime(System.currentTimeMillis() + delay);
|
||||
} else if (mob.getWeaponItemBase(true) != null) {
|
||||
int attackDelay = 3000;
|
||||
if (mob.isSiege())
|
||||
attackDelay = 11000;
|
||||
CombatUtilities.combatCycle(mob, target, true, mob.getWeaponItemBase(true));
|
||||
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
|
||||
} else if (mob.getWeaponItemBase(false) != null) {
|
||||
int attackDelay = 3000;
|
||||
if (mob.isSiege())
|
||||
attackDelay = 11000;
|
||||
CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false));
|
||||
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
|
||||
if (target.getCombatTarget() == null) {
|
||||
target.setCombatTarget(mob);
|
||||
}
|
||||
}
|
||||
CombatManager.combatCycle(mob, target);
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackMob" + " " + e.getMessage());
|
||||
}
|
||||
@@ -324,7 +254,7 @@ public class MobAI {
|
||||
|
||||
if (mob.isPlayerGuard() == true) {
|
||||
|
||||
if(mob.agentType.equals(Enum.AIAgentType.GUARDWALLARCHER))
|
||||
if (mob.agentType.equals(Enum.AIAgentType.GUARDWALLARCHER))
|
||||
return false; //wall archers don't cast
|
||||
if (mob.agentType.equals(Enum.AIAgentType.GUARDMINION))
|
||||
contractID = mob.guardCaptain.contract.getContractID();
|
||||
@@ -423,15 +353,9 @@ public class MobAI {
|
||||
if (mob.isPlayerGuard())
|
||||
powerRank = getGuardPowerRank(mob);
|
||||
|
||||
//check for hit-roll
|
||||
|
||||
if (mobPower.requiresHitRoll)
|
||||
if (CombatUtilities.triggerDefense(mob, mob.getCombatTarget()))
|
||||
return false;
|
||||
|
||||
// Cast the spell
|
||||
|
||||
if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mobPower.getRange())) {
|
||||
if (mob.getRange() * mob.getRange() >= mob.loc.distanceSquared(target.loc)) {
|
||||
|
||||
PerformActionMsg msg;
|
||||
|
||||
@@ -581,10 +505,10 @@ public class MobAI {
|
||||
|
||||
//no players loaded, no need to proceed unless it's a player guard
|
||||
boolean bypassLoadedPlayerCheck = false;
|
||||
if(mob.isPlayerGuard() || mob.isSiege()) {
|
||||
if (mob.isPlayerGuard() || mob.isSiege()) {
|
||||
bypassLoadedPlayerCheck = true;
|
||||
if(mob.combatTarget != null && mob.combatTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
|
||||
if(mob.combatTarget.loc.distanceSquared(mob.loc) > 10000)
|
||||
if (mob.combatTarget != null && mob.combatTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
|
||||
if (mob.combatTarget.loc.distanceSquared(mob.loc) > 10000)
|
||||
mob.setCombatTarget(null);
|
||||
}
|
||||
|
||||
@@ -681,12 +605,12 @@ public class MobAI {
|
||||
|
||||
// No aggro for this race type
|
||||
|
||||
if (aiAgent.notEnemy.size() > 0 && aiAgent.notEnemy.contains(loadedPlayer.getRace().getRaceType().getMonsterType()) == true)
|
||||
if (aiAgent.notEnemy.size() > 0 && aiAgent.notEnemy.contains(loadedPlayer.race.getRaceType().getMonsterType()) == true)
|
||||
continue;
|
||||
|
||||
//mob has enemies and this player race is not it
|
||||
|
||||
if (aiAgent.enemy.size() > 0 && aiAgent.enemy.contains(loadedPlayer.getRace().getRaceType().getMonsterType()) == false)
|
||||
if (aiAgent.enemy.size() > 0 && aiAgent.enemy.contains(loadedPlayer.race.getRaceType().getMonsterType()) == false)
|
||||
continue;
|
||||
|
||||
if (MovementUtilities.inRangeToAggro(aiAgent, loadedPlayer)) {
|
||||
@@ -745,7 +669,7 @@ public class MobAI {
|
||||
|
||||
//move back to owner
|
||||
|
||||
if (CombatUtilities.inRange2D(mob, mob.guardCaptain, 6))
|
||||
if (mob.getRange() * mob.getRange() >= mob.loc.distanceSquared(mob.guardCaptain.loc))
|
||||
return;
|
||||
|
||||
mob.destination = mob.guardCaptain.getLoc();
|
||||
@@ -790,7 +714,7 @@ public class MobAI {
|
||||
|
||||
if (!aiAgent.despawned) {
|
||||
|
||||
if (aiAgent.getCharItemManager().getInventoryCount() > 0) {
|
||||
if (aiAgent.charItemManager.getInventoryCount() > 0) {
|
||||
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_WITH_LOOT) {
|
||||
aiAgent.despawn();
|
||||
aiAgent.deathTime = System.currentTimeMillis();
|
||||
@@ -840,9 +764,19 @@ public class MobAI {
|
||||
mob.setCombatTarget(null);
|
||||
return;
|
||||
}
|
||||
if (System.currentTimeMillis() > mob.getLastAttackTime())
|
||||
AttackTarget(mob, mob.getCombatTarget());
|
||||
if (System.currentTimeMillis() > mob.getNextAttackTime()) {
|
||||
int delay = 3000;
|
||||
if (mob.charItemManager.getEquipped().get(Enum.EquipSlotType.RHELD) != null) {
|
||||
delay = (int) (mob.charItemManager.getEquipped().get(Enum.EquipSlotType.RHELD).template.item_weapon_wepspeed * 100);
|
||||
}
|
||||
if (mob.charItemManager.getEquipped().get(Enum.EquipSlotType.LHELD) != null && mob.charItemManager.getEquipped().get(Enum.EquipSlotType.LHELD).template.item_type.equals(Enum.ItemType.WEAPON)) {
|
||||
delay += (int) (mob.charItemManager.getEquipped().get(Enum.EquipSlotType.LHELD).template.item_weapon_wepspeed * 100);
|
||||
}
|
||||
|
||||
|
||||
mob.nextAttackTime = System.currentTimeMillis() + delay;
|
||||
AttackTarget(mob, mob.getCombatTarget());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckForAttack" + " " + e.getMessage());
|
||||
}
|
||||
@@ -852,7 +786,7 @@ public class MobAI {
|
||||
|
||||
try {
|
||||
|
||||
if (mob.getCombatTarget() != null && CombatUtilities.inRange2D(mob, mob.getCombatTarget(), MobAIThread.AI_BASE_AGGRO_RANGE * 0.5f))
|
||||
if (mob.getCombatTarget() != null && mob.getRange() * mob.getRange() >= MobAIThread.AI_BASE_AGGRO_RANGE * 0.5f)
|
||||
return;
|
||||
|
||||
if (mob.isPlayerGuard() && !mob.despawned) {
|
||||
@@ -895,14 +829,14 @@ public class MobAI {
|
||||
|
||||
try {
|
||||
|
||||
if(mob.getTimestamps().containsKey("lastChase") == false)
|
||||
mob.getTimestamps().put("lastChase",System.currentTimeMillis());
|
||||
else if(System.currentTimeMillis() < mob.getTimestamps().get("lastChase").longValue() + (750 + ThreadLocalRandom.current().nextInt(0,500)))
|
||||
return;
|
||||
if (mob.getTimestamps().containsKey("lastChase") == false)
|
||||
mob.getTimestamps().put("lastChase", System.currentTimeMillis());
|
||||
else if (System.currentTimeMillis() < mob.getTimestamps().get("lastChase").longValue() + (750 + ThreadLocalRandom.current().nextInt(0, 500)))
|
||||
return;
|
||||
|
||||
mob.getTimestamps().put("lastChase",System.currentTimeMillis());
|
||||
mob.getTimestamps().put("lastChase", System.currentTimeMillis());
|
||||
|
||||
if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) {
|
||||
if (mob.getRange() * mob.getRange() <= mob.loc.distanceSquared(mob.combatTarget.loc)) {
|
||||
if (mob.getRange() > 15) {
|
||||
mob.destination = mob.getCombatTarget().getLoc();
|
||||
MovementUtilities.moveToLocation(mob, mob.destination, 0, false);
|
||||
@@ -981,10 +915,10 @@ public class MobAI {
|
||||
}
|
||||
}
|
||||
|
||||
if(mob.behaviourType.canRoam)
|
||||
if (mob.behaviourType.canRoam)
|
||||
CheckMobMovement(mob);//all guards that can move check to move
|
||||
|
||||
if(mob.combatTarget != null)
|
||||
if (mob.combatTarget != null)
|
||||
CheckForAttack(mob); //only check to attack if combat target is not null
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -1013,7 +947,7 @@ public class MobAI {
|
||||
if (mob.isSit() && mob.getTimeStamp("HEALTHRECOVERED") < System.currentTimeMillis() + 3000)
|
||||
if (mob.getHealth() < mob.getHealthMax()) {
|
||||
|
||||
float recoveredHealth = mob.getHealthMax() * ((1 + mob.getBonuses().getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None)) * 0.01f);
|
||||
float recoveredHealth = mob.getHealthMax() * ((1 + mob.getBonuses().getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.NONE)) * 0.01f);
|
||||
mob.setHealth(mob.getHealth() + recoveredHealth);
|
||||
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
|
||||
|
||||
@@ -1135,21 +1069,21 @@ public class MobAI {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (mob.getCombatTarget() == null) {
|
||||
if (mob.getCombatTarget() == null) {
|
||||
|
||||
//look for siege equipment to aggro if no players found to aggro
|
||||
//look for siege equipment to aggro if no players found to aggro
|
||||
|
||||
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(mob, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_SIEGE);
|
||||
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(mob, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_SIEGE);
|
||||
|
||||
for (AbstractWorldObject awoMob : awoList) {
|
||||
for (AbstractWorldObject awoMob : awoList) {
|
||||
|
||||
|
||||
Mob aggroMob = (Mob) awoMob;
|
||||
if(GuardCanAggro(mob,aggroMob)) {
|
||||
mob.setCombatTarget(aggroMob);
|
||||
return;
|
||||
}
|
||||
Mob aggroMob = (Mob) awoMob;
|
||||
if (GuardCanAggro(mob, aggroMob)) {
|
||||
mob.setCombatTarget(aggroMob);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package engine.mobileAI.Threads;
|
||||
|
||||
import engine.gameManager.ConfigManager;
|
||||
import engine.mobileAI.MobAI;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.mobileAI.MobAI;
|
||||
import engine.objects.Mob;
|
||||
import engine.objects.Zone;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
public class MobAIThread implements Runnable{
|
||||
public class MobAIThread implements Runnable {
|
||||
public static int AI_BASE_AGGRO_RANGE = 60;
|
||||
public static int AI_DROP_AGGRO_RANGE = 60;
|
||||
public static int AI_PULSE_MOB_THRESHOLD = 200;
|
||||
@@ -25,7 +24,7 @@ public class MobAIThread implements Runnable{
|
||||
public void run() {
|
||||
//cache config value for mobile casting delay
|
||||
AI_CAST_FREQUENCY = Float.parseFloat(ConfigManager.MB_AI_CAST_FREQUENCY.getValue());
|
||||
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) {
|
||||
for (Zone zone : ZoneManager.getAllZones()) {
|
||||
|
||||
@@ -42,6 +41,7 @@ public class MobAIThread implements Runnable{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void startAIThread() {
|
||||
Thread aiThread;
|
||||
aiThread = new Thread(new MobAIThread());
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
|
||||
package engine.mobileAI.Threads;
|
||||
|
||||
import engine.objects.Mob;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
|
||||
@@ -1,353 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.mobileAI.utilities;
|
||||
|
||||
import engine.Enum.*;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.gameManager.CombatManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.msg.TargetedActionMsg;
|
||||
import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import static engine.math.FastMath.sqr;
|
||||
import static java.lang.Math.pow;
|
||||
|
||||
public class CombatUtilities {
|
||||
|
||||
public static boolean inRangeToAttack(Mob agent, AbstractWorldObject target) {
|
||||
|
||||
if (Float.isNaN(agent.getLoc().x))
|
||||
return false;
|
||||
|
||||
try {
|
||||
Vector3fImmutable sl = agent.getLoc();
|
||||
Vector3fImmutable tl = target.getLoc();
|
||||
|
||||
//add Hitbox's to range.
|
||||
float range = agent.getRange();
|
||||
range += CombatManager.calcHitBox(target) + CombatManager.calcHitBox(agent);
|
||||
|
||||
return !(sl.distanceSquared(tl) > sqr(range));
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.toString());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean inRange2D(AbstractWorldObject entity1, AbstractWorldObject entity2, double range) {
|
||||
return entity1.getLoc().distanceSquared2D(entity2.getLoc()) < range * range;
|
||||
}
|
||||
|
||||
public static void swingIsBlock(Mob agent, AbstractWorldObject target, int animation) {
|
||||
|
||||
if (!target.isAlive())
|
||||
return;
|
||||
|
||||
TargetedActionMsg msg = new TargetedActionMsg(agent, animation, target, MBServerStatics.COMBAT_SEND_BLOCK);
|
||||
|
||||
if (target.getObjectType() == GameObjectType.PlayerCharacter)
|
||||
DispatchMessage.dispatchMsgToInterestArea(target, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
else
|
||||
DispatchMessage.sendToAllInRange(agent, msg);
|
||||
|
||||
}
|
||||
|
||||
public static void swingIsParry(Mob agent, AbstractWorldObject target, int animation) {
|
||||
|
||||
if (!target.isAlive())
|
||||
return;
|
||||
|
||||
TargetedActionMsg msg = new TargetedActionMsg(agent, animation, target, MBServerStatics.COMBAT_SEND_PARRY);
|
||||
|
||||
if (target.getObjectType() == GameObjectType.PlayerCharacter)
|
||||
DispatchMessage.dispatchMsgToInterestArea(target, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
else
|
||||
DispatchMessage.sendToAllInRange(agent, msg);
|
||||
|
||||
}
|
||||
|
||||
public static void swingIsDodge(Mob agent, AbstractWorldObject target, int animation) {
|
||||
|
||||
if (!target.isAlive())
|
||||
return;
|
||||
|
||||
TargetedActionMsg msg = new TargetedActionMsg(agent, animation, target, MBServerStatics.COMBAT_SEND_DODGE);
|
||||
|
||||
if (target.getObjectType() == GameObjectType.PlayerCharacter)
|
||||
DispatchMessage.dispatchMsgToInterestArea(target, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
else
|
||||
DispatchMessage.sendToAllInRange(agent, msg);
|
||||
}
|
||||
|
||||
public static void swingIsDamage(Mob agent, AbstractWorldObject target, float damage, int animation) {
|
||||
if (agent.isSiege() == true) {
|
||||
damage = ThreadLocalRandom.current().nextInt(1000) + 1500;
|
||||
}
|
||||
float trueDamage = damage;
|
||||
|
||||
if (!target.isAlive())
|
||||
return;
|
||||
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target))
|
||||
trueDamage = ((AbstractCharacter) target).modifyHealth(-damage, agent, false);
|
||||
else if (target.getObjectType() == GameObjectType.Building)
|
||||
trueDamage = ((Building) target).modifyHealth(-damage, agent);
|
||||
|
||||
//Don't send 0 damage kay thanx.
|
||||
|
||||
if (trueDamage == 0)
|
||||
return;
|
||||
|
||||
TargetedActionMsg msg = new TargetedActionMsg(agent, target, damage, animation);
|
||||
|
||||
if (target.getObjectType() == GameObjectType.PlayerCharacter)
|
||||
DispatchMessage.dispatchMsgToInterestArea(target, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
else
|
||||
DispatchMessage.sendToAllInRange(agent, msg);
|
||||
|
||||
//check damage shields
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target) && target.isAlive() && target.getObjectType() != GameObjectType.Mob)
|
||||
CombatManager.handleDamageShields(agent, (AbstractCharacter) target, damage);
|
||||
}
|
||||
|
||||
public static boolean canSwing(Mob agent) {
|
||||
return (agent.isAlive() && !agent.getBonuses().getBool(ModType.Stunned, SourceType.None));
|
||||
}
|
||||
|
||||
public static void swingIsMiss(Mob agent, AbstractWorldObject target, int animation) {
|
||||
|
||||
TargetedActionMsg msg = new TargetedActionMsg(agent, target, 0f, animation);
|
||||
|
||||
if (target.getObjectType() == GameObjectType.PlayerCharacter)
|
||||
DispatchMessage.dispatchMsgToInterestArea(target, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
else
|
||||
DispatchMessage.sendToAllInRange(agent, msg);
|
||||
|
||||
}
|
||||
|
||||
public static boolean triggerDefense(Mob agent, AbstractWorldObject target) {
|
||||
int defenseScore = 0;
|
||||
int attackScore = agent.getAtrHandOne();
|
||||
switch (target.getObjectType()) {
|
||||
case PlayerCharacter:
|
||||
defenseScore = ((AbstractCharacter) target).getDefenseRating();
|
||||
break;
|
||||
case Mob:
|
||||
|
||||
Mob mob = (Mob) target;
|
||||
if (mob.isSiege())
|
||||
defenseScore = attackScore;
|
||||
break;
|
||||
case Building:
|
||||
return false;
|
||||
}
|
||||
|
||||
int hitChance;
|
||||
if (attackScore > defenseScore || defenseScore == 0)
|
||||
hitChance = 94;
|
||||
else if (attackScore == defenseScore && target.getObjectType() == GameObjectType.Mob)
|
||||
hitChance = 10;
|
||||
else {
|
||||
float dif = attackScore / defenseScore;
|
||||
if (dif <= 0.8f)
|
||||
hitChance = 4;
|
||||
else
|
||||
hitChance = ((int) (450 * (dif - 0.8f)) + 4);
|
||||
if (target.getObjectType() == GameObjectType.Building)
|
||||
hitChance = 100;
|
||||
}
|
||||
return ThreadLocalRandom.current().nextInt(100) > hitChance;
|
||||
}
|
||||
|
||||
public static boolean triggerBlock(Mob agent, AbstractWorldObject ac) {
|
||||
return triggerPassive(agent, ac, "Block");
|
||||
}
|
||||
|
||||
public static boolean triggerParry(Mob agent, AbstractWorldObject ac) {
|
||||
return triggerPassive(agent, ac, "Parry");
|
||||
}
|
||||
|
||||
public static boolean triggerDodge(Mob agent, AbstractWorldObject ac) {
|
||||
return triggerPassive(agent, ac, "Dodge");
|
||||
}
|
||||
|
||||
public static boolean triggerPassive(Mob agent, AbstractWorldObject ac, String type) {
|
||||
float chance = 0;
|
||||
if (AbstractWorldObject.IsAbstractCharacter(ac))
|
||||
chance = ((AbstractCharacter) ac).getPassiveChance(type, agent.getLevel(), true);
|
||||
|
||||
if (chance > 75f)
|
||||
chance = 75f;
|
||||
if (agent.isSiege() && AbstractWorldObject.IsAbstractCharacter(ac))
|
||||
chance = 100;
|
||||
|
||||
return ThreadLocalRandom.current().nextInt(100) < chance;
|
||||
}
|
||||
|
||||
public static void combatCycle(Mob agent, AbstractWorldObject target, boolean mainHand, ItemBase wb) {
|
||||
|
||||
if (!agent.isAlive() || !target.isAlive())
|
||||
return;
|
||||
|
||||
if (target.getObjectType() == GameObjectType.PlayerCharacter)
|
||||
if (!((PlayerCharacter) target).isActive())
|
||||
return;
|
||||
|
||||
int anim = 75;
|
||||
float speed;
|
||||
|
||||
if (mainHand)
|
||||
speed = agent.getSpeedHandOne();
|
||||
else
|
||||
speed = agent.getSpeedHandTwo();
|
||||
|
||||
DamageType dt = DamageType.Crush;
|
||||
|
||||
if (agent.isSiege())
|
||||
dt = DamageType.Siege;
|
||||
if (wb != null) {
|
||||
anim = CombatManager.getSwingAnimation(wb, null, mainHand);
|
||||
dt = wb.getDamageType();
|
||||
} else if (!mainHand)
|
||||
return;
|
||||
|
||||
Resists res = null;
|
||||
PlayerBonuses bonus = null;
|
||||
|
||||
switch (target.getObjectType()) {
|
||||
case Building:
|
||||
res = ((Building) target).getResists();
|
||||
break;
|
||||
case PlayerCharacter:
|
||||
res = ((PlayerCharacter) target).getResists();
|
||||
bonus = ((PlayerCharacter) target).getBonuses();
|
||||
break;
|
||||
case Mob:
|
||||
Mob mob = (Mob) target;
|
||||
res = mob.getResists();
|
||||
bonus = ((Mob) target).getBonuses();
|
||||
break;
|
||||
}
|
||||
|
||||
//must not be immune to all or immune to attack
|
||||
|
||||
if (bonus != null && !bonus.getBool(ModType.NoMod, SourceType.ImmuneToAttack))
|
||||
if (res != null && (res.immuneToAll() || res.immuneToAttacks() || res.immuneTo(dt)))
|
||||
return;
|
||||
|
||||
int passiveAnim = CombatManager.getSwingAnimation(wb, null, mainHand);
|
||||
if (canSwing(agent)) {
|
||||
if (triggerDefense(agent, target)) {
|
||||
swingIsMiss(agent, target, passiveAnim);
|
||||
return;
|
||||
} else if (triggerDodge(agent, target)) {
|
||||
swingIsDodge(agent, target, passiveAnim);
|
||||
return;
|
||||
} else if (triggerParry(agent, target)) {
|
||||
swingIsParry(agent, target, passiveAnim);
|
||||
|
||||
return;
|
||||
} else if (triggerBlock(agent, target)) {
|
||||
swingIsBlock(agent, target, passiveAnim);
|
||||
return;
|
||||
}
|
||||
|
||||
swingIsDamage(agent, target, determineDamage(agent), anim);
|
||||
|
||||
|
||||
if (agent.getWeaponPower() != null)
|
||||
agent.getWeaponPower().attack(target, MBServerStatics.ONE_MINUTE);
|
||||
}
|
||||
|
||||
if (target.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
||||
PlayerCharacter player = (PlayerCharacter) target;
|
||||
|
||||
if (player.getDebug(64))
|
||||
ChatManager.chatSayInfo(player, "Debug Combat: Mob UUID " + agent.getObjectUUID() + " || Building ID = " + agent.getBuildingID() + " || Floor = " + agent.getInFloorID() + " || Level = " + agent.getInBuilding());//combat debug
|
||||
}
|
||||
|
||||
//SIEGE MONSTERS DO NOT ATTACK GUARDSs
|
||||
if (target.getObjectType() == GameObjectType.Mob)
|
||||
if (((Mob) target).isSiege())
|
||||
return;
|
||||
|
||||
//handle the retaliate
|
||||
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target))
|
||||
CombatManager.handleRetaliate((AbstractCharacter) target, agent);
|
||||
|
||||
if (target.getObjectType() == GameObjectType.Mob) {
|
||||
Mob targetMob = (Mob) target;
|
||||
if (targetMob.isSiege())
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static float determineDamage(Mob agent) {
|
||||
|
||||
//early exit for null
|
||||
|
||||
if (agent == null)
|
||||
return 0;
|
||||
|
||||
AbstractWorldObject target = agent.getCombatTarget();
|
||||
|
||||
if (target == null)
|
||||
return 0;
|
||||
|
||||
int damage = 0;
|
||||
|
||||
DamageType dt = getDamageType(agent);
|
||||
damage = ThreadLocalRandom.current().nextInt((int)getMinDmg(agent), (int)getMaxDmg(agent) + 1);
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target)) {
|
||||
if (((AbstractCharacter) target).isSit()) {
|
||||
damage *= 2.5f; //increase damage if sitting
|
||||
}
|
||||
return (int) (((AbstractCharacter) target).getResists().getResistedDamage(agent, (AbstractCharacter) target, dt, damage, 0));
|
||||
}
|
||||
if (target.getObjectType() == GameObjectType.Building) {
|
||||
Building building = (Building) target;
|
||||
Resists resists = building.getResists();
|
||||
return (int) ((damage * (1 - (resists.getResist(dt, 0) / 100))));
|
||||
}
|
||||
return damage;
|
||||
}
|
||||
|
||||
public static DamageType getDamageType(Mob agent) {
|
||||
DamageType dt = DamageType.Crush;
|
||||
if (agent.getEquip().get(1) != null) {
|
||||
return agent.getEquip().get(1).getItemBase().getDamageType();
|
||||
}
|
||||
if (agent.getEquip().get(2) != null && agent.getEquip().get(2).getItemBase().isShield() == false) {
|
||||
return agent.getEquip().get(2).getItemBase().getDamageType();
|
||||
}
|
||||
return dt;
|
||||
}
|
||||
|
||||
public static double getMinDmg(Mob agent) {
|
||||
if(agent.equip.get(2) != null && !agent.equip.get(2).getItemBase().isShield())
|
||||
return agent.minDamageHandTwo;
|
||||
else return agent.minDamageHandOne;
|
||||
}
|
||||
|
||||
public static double getMaxDmg(Mob agent) {
|
||||
if(agent.equip.get(2) != null && !agent.equip.get(2).getItemBase().isShield())
|
||||
return agent.maxDamageHandTwo;
|
||||
else return agent.maxDamageHandOne;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class MovementUtilities {
|
||||
if (agent.getMobBase() != null && Enum.MobFlagType.SENTINEL.elementOf(agent.getMobBase().getFlags()))
|
||||
return false;
|
||||
|
||||
return (agent.isAlive() && !agent.getBonuses().getBool(ModType.Stunned, SourceType.None) && !agent.getBonuses().getBool(ModType.CannotMove, SourceType.None));
|
||||
return (agent.isAlive() && !agent.getBonuses().getBool(ModType.Stunned, SourceType.NONE) && !agent.getBonuses().getBool(ModType.CannotMove, SourceType.NONE));
|
||||
}
|
||||
|
||||
public static Vector3fImmutable randomPatrolLocation(Mob agent, Vector3fImmutable center, float radius) {
|
||||
|
||||
@@ -278,7 +278,7 @@ public class ClientConnection extends AbstractConnection {
|
||||
// case ClientOpcodes.ToggleSitStand:
|
||||
// case ClientOpcodes.SocialChannel:
|
||||
// case ClientOpcodes.OpenFriendsCondemnList:
|
||||
case SELLOBJECT:
|
||||
case SELLTONPC:
|
||||
this.setLastMsgTime();
|
||||
break;
|
||||
case MOVETOPOINT:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,16 +20,15 @@ import java.util.HashMap;
|
||||
|
||||
public enum Protocol {
|
||||
|
||||
|
||||
NONE(0x0, null, null),
|
||||
ABANDONASSET(0xFDDBB233, AbandonAssetMsg.class, AbandonAssetMsgHandler.class), // AbandonAsset
|
||||
ACTIVATECHARTER(0x296C0B22, UseCharterMsg.class, null),// Use Guild Charter
|
||||
USECHARTER(0x296C0B22, UseCharterMsg.class, UseCharterMsgHandler.class),// Use Guild Charter
|
||||
ACTIVATENPC(0xC9AAE81E, ActivateNPCMessage.class, ActivateNPCMsgHandler.class),
|
||||
ACTIVATEPLEDGE(0x5A694DC0, SwearInMsg.class, SwearInHandler.class), // Swear In
|
||||
ADDFRIEND(0xCFA1C787, AddFriendMessage.class, null),
|
||||
ALLIANCECHANGE(0x0E7D0B57, AllianceChangeMsg.class, AllianceChangeMsgHandler.class), // Remove From Allies/Enemies List
|
||||
ALLYENEMYLIST(0xAEA443FD, AllyEnemyListMsg.class, AllyEnemyListMsgHandler.class),
|
||||
ARCCOMBATMODEATTACKING(0xD8B10579, SetCombatModeMsg.class, null), // Attack From Outside Combat Mode
|
||||
ARCCOMBATMODEATTACKING(0xD8B10579, SetCombatModeMsg.class, SetCombatModeMsgHandler.class), // Attack From Outside Combat Mode
|
||||
ARCHOTZONECHANGE(0xDCFF196F, null, null), //change hotzone
|
||||
ARCIGNORELISTUPDATE(0x4B1B17C2, IgnoreListMsg.class, null), //req/show ignore list
|
||||
ARCLOGINNOTIFY(0x010FED87, ArcLoginNotifyMsg.class, ArcLoginNotifyMsgHandler.class), //Client Confirms entering world
|
||||
@@ -38,39 +37,39 @@ public enum Protocol {
|
||||
ARCMINEWINDOWAVAILABLETIME(0x6C909DE7, ArcMineWindowAvailableTimeMsg.class, ArcMineWindowAvailableTimeHandler.class),
|
||||
ARCMINEWINDOWCHANGE(0x92B2148A, ArcMineWindowChangeMsg.class, MineWindowChangeHandler.class),
|
||||
ARCOWNEDMINESLIST(0x59184455, ArcOwnedMinesListMsg.class, ArcOwnedMinesListHandler.class),
|
||||
ARCPETATTACK(0x18CD61AD, PetAttackMsg.class, null), // Pet Attack
|
||||
ARCPETCMD(0x4E80E001, PetCmdMsg.class, null), // Stop ArcPetAttack, Toggle Assist, Toggle Rest
|
||||
ARCPETATTACK(0x18CD61AD, PetAttackMsg.class, PetAttackMsgHandler.class), // Pet Attack
|
||||
ARCPETCMD(0x4E80E001, PetCmdMsg.class, PetCmdMsgHandler.class), // Stop ArcPetAttack, Toggle Assist, Toggle Rest
|
||||
ARCPOWERPROJECTILE(0xA2312D3B, null, null),
|
||||
ARCPROMPTRECALL(0xE3196B6E, PromptRecallMsg.class, null), //Recall Prompt
|
||||
ARCREQUESTTRADEBUSY(0xD4BAB4DF, InvalidTradeRequestMsg.class, null), // Attempt trade with someone who is already trading
|
||||
ARCPROMPTRECALL(0xE3196B6E, PromptRecallMsg.class, PromptRecallMsgHandler.class), //Recall Prompt
|
||||
ARCREQUESTTRADEBUSY(0xD4BAB4DF, InvalidTradeRequestMsg.class, InvalidTradeRequestMsgHandler.class), // Attempt trade with someone who is already trading
|
||||
ARCSERVERSTATUS(0x87BA4462, null, null), //Update Server Status
|
||||
ARCSIEGESPIRE(0x36A49BC6, ArcSiegeSpireMsg.class, ArcSiegeSpireMsgHandler.class), // Activate/Deactivate Spires
|
||||
ARCSUMMON(0xFD816A0A, RecvSummonsRequestMsg.class, null), // Suspect Recv Summons Request
|
||||
ARCTRACKINGLIST(0xC89CF08B, TrackWindowMsg.class, null), //Request/Send Track window
|
||||
ARCSUMMON(0xFD816A0A, RecvSummonsMsg.class, RecvSummonsMsgHandler.class), // Suspect Recv Summons Request
|
||||
ARCTRACKINGLIST(0xC89CF08B, TrackWindowMsg.class, TrackWindowMsgHandler.class), //Request/Send Track window
|
||||
ARCTRACKOBJECT(0x609B6BA2, TrackArrowMsg.class, null), //Send Track Arrow
|
||||
ARCUNTRAINABILITY(0x548DBF83, RefineMsg.class, null), //Refine
|
||||
ARCUNTRAINLIST(0x38879E90, RefinerScreenMsg.class, null), //Refiner screen
|
||||
ARCUNTRAINABILITY(0x548DBF83, RefineMsg.class, RefineMsgHandler.class), //Refine
|
||||
ARCUNTRAINLIST(0x38879E90, RefinerScreenMsg.class, RefinerScreenMsgHandler.class), //Refiner screen
|
||||
ARCVIEWASSETTRANSACTIONS(0xBFA476E4, ArcViewAssetTransactionsMsg.class, ArcViewAssetTransactionsMsgHandler.class),
|
||||
ASSETSUPPORT(0xc481f89D, AssetSupportMsg.class, AssetSupportMsgHandler.class),
|
||||
BANISHMEMBER(0x31AA3368, BanishUnbanishMsg.class, BanishUnbanishHandler.class), // Banish/Unbanish
|
||||
BANKINVENTORY(0x32F3F503, ShowBankInventoryMsg.class, null), // ShowCombatInfo Bank Inventory
|
||||
BREAKFEALTY(0x479A4C19, BreakFealtyMsg.class, BreakFealtyHandler.class),
|
||||
BUYFROMNPC(0xA2B8DFA5, BuyFromNPCMsg.class, null), // Buy Item From NPC
|
||||
BUYFROMNPC(0xA2B8DFA5, VendorBuyMsg.class, VendorBuyMsgHandler.class), // Buy Item From NPC
|
||||
CANCELGUILDCREATION(0x385EA922, GuildCreationCloseMsg.class, GuildCreationCloseHandler.class), //Close the window
|
||||
CHANGEALTITUDE(0x624F08BA, ChangeAltitudeMsg.class, ChangeAltitudeHandler.class), //Change Altitude
|
||||
CHANGEGUILDLEADER(0xE40BC95D, ChangeGuildLeaderMsg.class, ChangeGuildLeaderHandler.class),
|
||||
CHANNELMUTE(0xC1BDC53A, ChatFilterMsg.class, ChannelMuteMsgHandler.class), //Chat Channels that are turned on
|
||||
CHARSELECTSCREEN(0x682C935D, null, null), // Character Selection Screen
|
||||
CHATCITY(0x9D402901, ChatCityMsg.class, null), // Chat Channel: /City
|
||||
CHATCSR(0x14EBA1C3, ChatCSRMsg.class, null), //Chat Channel: CSR
|
||||
CHATGROUP(0xA895B634, ChatGroupMsg.class, null), // Chat Channel: /group
|
||||
CHATGUILD(0xA9D92ED4, ChatGuildMsg.class, null), // Chat Channel: /guild
|
||||
CHATIC(0x00A75F35, ChatICMsg.class, null), // Chat Channel: /IC
|
||||
CHATINFO(0x9D4B61EB, ChatInfoMsg.class, null), // Chat Channel: /Info
|
||||
CHATPVP(0x14EBA570, ChatPvPMsg.class, null), // Chat Channel: PVP
|
||||
CHATSAY(0x14EA0393, ChatSayMsg.class, null), // Chat Channel: /say
|
||||
CHATSHOUT(0xA8D5B560, ChatShoutMsg.class, null), // Chat Channel: /shout
|
||||
CHATTELL(0x9D4AC896, ChatTellMsg.class, null), // Chat Channel: /tell
|
||||
CHATCITY(0x9D402901, ChatCityMsg.class, AbstractChatMsgHandler.class), // Chat Channel: /City
|
||||
CHATCSR(0x14EBA1C3, ChatCSRMsg.class, AbstractChatMsgHandler.class), //Chat Channel: CSR
|
||||
CHATGROUP(0xA895B634, ChatGroupMsg.class, AbstractChatMsgHandler.class), // Chat Channel: /group
|
||||
CHATGUILD(0xA9D92ED4, ChatGuildMsg.class, AbstractChatMsgHandler.class), // Chat Channel: /guild
|
||||
CHATIC(0x00A75F35, ChatICMsg.class, AbstractChatMsgHandler.class), // Chat Channel: /IC
|
||||
CHATINFO(0x9D4B61EB, ChatInfoMsg.class, AbstractChatMsgHandler.class), // Chat Channel: /Info
|
||||
CHATPVP(0x14EBA570, ChatPvPMsg.class, AbstractChatMsgHandler.class), // Chat Channel: PVP
|
||||
CHATSAY(0x14EA0393, ChatSayMsg.class, AbstractChatMsgHandler.class), // Chat Channel: /say
|
||||
CHATSHOUT(0xA8D5B560, ChatShoutMsg.class, AbstractChatMsgHandler.class), // Chat Channel: /shout
|
||||
CHATTELL(0x9D4AC896, ChatTellMsg.class, AbstractChatMsgHandler.class), // Chat Channel: /tell
|
||||
CHECKUNIQUEGUILD(0x689097D7, GuildCreationOptionsMsg.class, GuildCreationOptionsHandler.class), // Set Guild Name/Motto in Use Guild Charter
|
||||
CITYASSET(0x7cae1678, CityAssetMsg.class, null),
|
||||
CITYCHOICE(0x406610BB, CityChoiceMsg.class, CityChoiceMsgHandler.class),
|
||||
@@ -78,29 +77,30 @@ public enum Protocol {
|
||||
CITYZONE(0x254947F2, CityZoneMsg.class, null), //For Creating City Object Clientside(Terraform)/Rename City.
|
||||
CLAIMASSET(0x948C62CC, ClaimAssetMsg.class, ClaimAssetMsgHandler.class), // ClaimAsset
|
||||
CLAIMGUILDTREE(0xFD1C6442, ClaimGuildTreeMsg.class, ClaimGuildTreeMsgHandler.class),
|
||||
CLIENTADMINCOMMAND(0x624EAB5F, ClientAdminCommandMsg.class, null), //Admin Command
|
||||
CLIENTADMINCOMMAND(0x624EAB5F, ClientAdminCommandMsg.class, ClientAdminCommandMsgHandler.class), //Admin Command
|
||||
CLIENTUPDATEVAULT(0x66EDBECD, UpdateVaultMsg.class, null),
|
||||
COMBATMODE(0xFE4BF353, ToggleCombatMsg.class, null), //Toggle Combat mode
|
||||
COMBATMODE(0xFE4BF353, ToggleCombatMsg.class, ToggleCombatMsgHandler.class), //Toggle Combat mode
|
||||
CONFIRMPROMOTE(0x153BB5F9, ConfirmPromoteMsg.class, null),
|
||||
COSTTOOPENBANK(0x135BE5E8, AckBankWindowOpenedMsg.class, null), // ACK Bank Window Opened
|
||||
COSTTOOPENBANK(0x135BE5E8, CostOpenBankMsg.class, null), // ACK Bank Window Opened
|
||||
CREATECHAR(0x5D18B5C8, CommitNewCharacterMsg.class, null), // Commit New Character,
|
||||
CREATEPETITION(0xD489CFED, GuildCreationFinalizeMsg.class, GuildCreationFinalizeHandler.class), //Confirm guild creation
|
||||
CUSTOMERPETITION(0x7F9D7D6D, PetitionReceivedMsg.class, PetitionReceivedMsgHandler.class),
|
||||
DELETEOBJECT(0x57F069D8, DeleteItemMsg.class, null), //Delete Item from Inventory
|
||||
DELETEOBJECT(0x57F069D8, DeleteItemMsg.class, DeleteItemMsgHandler.class), //Delete Item from Inventory
|
||||
DESTROYBUILDING(0x3CB6FAD3, DestroyBuildingMsg.class, DestroyBuildingHandler.class), // Destroy Building
|
||||
DISBANDGUILD(0x77AABD64, DisbandGuildMsg.class, DisbandGuildHandler.class), //Disband Guild
|
||||
DISMISSGUILD(0x8D2D3D61, DismissGuildMsg.class, DismissGuildHandler.class),
|
||||
DOORTRYOPEN(0xA83DD8C8, DoorTryOpenMsg.class, DoorTryOpenMsgHandler.class), // Open/Close Door
|
||||
ENTERWORLD(0xB9783F85, RequestEnterWorldMsg.class, RequestEnterWorldHandler.class), // Request Enter World
|
||||
EQUIP(0x3CB1AF8C, TransferItemFromInventoryToEquipMsg.class, null), // Transfer Item from Inventory to Equip
|
||||
EQUIP(0x3CB1AF8C, TransferItemFromInventoryToEquipMsg.class, TransferItemFromInventoryToEquipHandler.class), // Transfer Item from Inventory to Equip
|
||||
EXPERIENCE(0xC57802A7, GrantExperienceMsg.class, null), //TODO rename once identified
|
||||
FORGETOBJECTS(0xE307A0E1, UnloadObjectsMsg.class, null), // Unload Objects
|
||||
FRIENDACCEPT(0xCA297870, AcceptFriendMsg.class, FriendAcceptHandler.class),
|
||||
FRIENDDECLINE(0xF08FC279, DeclineFriendMsg.class, FriendDeclineHandler.class),
|
||||
FURNITURE(0xCE7FA503, FurnitureMsg.class, FurnitureHandler.class),
|
||||
GAMESERVERIPRESPONSE(0x6C95CF87, GameServerIPResponseMsg.class, null), // Game Server IP Response
|
||||
GLOBALCHANNELMESSAGE(0x2bf03fd2, null, null),
|
||||
GOLDTOVAULT(0x3ABAEE49, TransferGoldFromInventoryToVaultMsg.class, null), // Transfer Gold from Inventory to Vault
|
||||
GLOBALCHANNELMESSAGE(0x2bf03fd2, ChatGlobalMsg.class, AbstractChatMsgHandler.class),
|
||||
GOLDFROMVAULT(0x011D0123, GoldFromVaultMsg.class, GoldFromVaultMsgHandler.class), // Transfer Gold from Vault to Inventory
|
||||
GOLDTOVAULT(0x3ABAEE49, GoldToVaultMsg.class, GoldToVaultMsgHandler.class), // Transfer Gold from Inventory to Vault
|
||||
GROUPDISBAND(0xE2B85AA4, DisbandGroupMsg.class, DisbandGroupHandler.class), //Disband Group
|
||||
GROUPFOLLOW(0xC61B0476, FormationFollowMsg.class, FormationFollowHandler.class), //Toggle Follow, set Formation
|
||||
GROUPLEADERAPPOINT(0xEF778DD3, AppointGroupLeaderMsg.class, AppointGroupLeaderHandler.class), //Appoint new group leader
|
||||
@@ -108,26 +108,27 @@ public enum Protocol {
|
||||
GROUPTREASURE(0x01041C66, ToggleGroupSplitMsg.class, ToggleGroupSplitHandler.class), // Toggle Group Split
|
||||
GUILDMEMBERONLINE(0x7B79EB3A, GuildEnterWorldMsg.class, null), // Send Enter World Message to Guild
|
||||
GUILDRANKCHANGE(0x0DEFB21F, ChangeRankMsg.class, ChangeRankHandler.class), // Change Rank
|
||||
GUILDTREESTATUS(0x4B95FB85, GuildTreeStatusMsg.class, null),
|
||||
GUILDTREESTATUS(0x4B95FB85, GuildTreeStatusMsg.class, GuildTreeStatusMsgHandler.class),
|
||||
HIRELINGSERVICE(0xD3D93322, HirelingServiceMsg.class, HirelingServiceMsgHandler.class),
|
||||
IGNORE(0xBD8881EE, IgnoreMsg.class, null), //client sent /ignore command
|
||||
IGNORE(0xBD8881EE, IgnoreMsg.class, IgnoreMsgHandler.class), //client sent /ignore command
|
||||
INITIATETRADEHUDS(0x667D29D8, OpenTradeWindowMsg.class, null), // Open Trade Window
|
||||
INVITEGROUP(0x004A2012, GroupInviteMsg.class, GroupInviteHandler.class), // Send/Receive/Deny Group Invite
|
||||
INVITEGUILDFEALTY(0x0274D612, InviteToSubMsg.class, InviteToSubHandler.class), // Invite Guild to Swear
|
||||
INVITETOGUILD(0x6819062A, InviteToGuildMsg.class, InviteToGuildHandler.class), // Invite player to guild, refuse guild invite
|
||||
ITEMHEALTHUPDATE(0xB635F55E, ItemHealthUpdateMsg.class, null), //Update Durability of item
|
||||
ITEMPRODUCTION(0x3CCE8E30, ItemProductionMsg.class, ItemProductionMsgHandler.class),
|
||||
ITEMTOVAULT(0x3ABE4927, TransferItemFromInventoryToVaultMsg.class, null), // Transfer Item to Vault
|
||||
ITEMTOVAULT(0x3ABE4927, ItemToVaultMsg.class, ItemToVaultMsgHandler.class), // Transfer Item to Vault
|
||||
ITEMFROMVAULT(0x0119A64D, ItemFromVaultMsg.class, ItemFromVaultMsgHandler.class), // Transfer Item from Vault to Inventory
|
||||
JOINFORPROVINCE(0x1FB369CD, AcceptSubInviteMsg.class, AcceptSubInviteHandler.class), //Response to invite to swear?
|
||||
JOINFORSWORN(0xF6A4170F, null, null),
|
||||
JOINGROUP(0x7EC5E636, GroupInviteResponseMsg.class, GroupInviteResponseHandler.class), // Accept Group Invite
|
||||
JOINGUILD(0xF0C5F2FF, AcceptInviteToGuildMsg.class, AcceptInviteToGuildHandler.class), // Accept guild invite
|
||||
KEEPALIVESERVERCLIENT(0x49EE129C, KeepAliveServerClientMsg.class, KeepAliveServerClientHandler.class), // Keep Alive
|
||||
LEADERBOARD(0x6F0C1386, LeaderboardMessage.class, null),
|
||||
LEADERCHANNELMESSAGE(0x17b306f9, ChatGlobalMsg.class, null),
|
||||
LEADERCHANNELMESSAGE(0x17b306f9, ChatLeaderMsg.class, AbstractChatMsgHandler.class),
|
||||
LEAVEGROUP(0xD8037303, LeaveGroupMsg.class, LeaveGroupHandler.class), //Leave Group
|
||||
LEAVEGUILD(0x1801EA32, LeaveGuildMsg.class, LeaveGuildHandler.class), // Leave Guild
|
||||
LEAVEREQUEST(0xC79D775C, LeaveWorldMsg.class, null), //Client Request Leave World
|
||||
LEAVEREQUEST(0xC79D775C, LeaveWorldMsg.class, LeaveWorldMsgHandler.class), //Client Request Leave World
|
||||
LEAVEWORLD(0xB801EAEC, null, null), //Response to client for Request Leave World
|
||||
LOADCHARACTER(0x5756BC53, null, null), // Load Player/NPC/Mob, other then self
|
||||
LOADSTRUCTURE(0xB8A3A654, LoadStructureMsg.class, null), //Load Buildings and World Detail Objects
|
||||
@@ -139,10 +140,10 @@ public enum Protocol {
|
||||
MANAGENPC(0x43A273FA, null, null), // Open Hireling Management Page
|
||||
MERCHANT(0x3E645EF4, MerchantMsg.class, MerchantMsgHandler.class), // Open Teleport List, Teleport, Open Shrine, Request Boon, open/manage warehouse window
|
||||
MINIONTRAINING(0xD355F528, MinionTrainingMessage.class, MinionTrainingMsgHandler.class),
|
||||
MODIFYGUILDSTATE(0x38936FEA, ToggleLfgRecruitingMsg.class, null), //Toggle LFGroup/LFGuild/Recruiting
|
||||
MODIFYGUILDSTATE(0x38936FEA, ToggleLfgRecruitingMsg.class, ToggleLfgRecruitingMsgHandler.class), //Toggle LFGroup/LFGuild/Recruiting
|
||||
MOTD(0xEC841E8D, MOTDMsg.class, MOTDEditHandler.class), //Send/Rec Guild/Nation/IC MOTD Message
|
||||
MOVECORRECTION(0x47FAD1E3, null, null), //Force move to point?
|
||||
MOVEOBJECTTOCONTAINER(0xD1639F7C, LootMsg.class, null), //Send/Recv MoveObjectToContainer Msg
|
||||
MOVEOBJECTTOCONTAINER(0xD1639F7C, LootMsg.class, LootMsgHandler.class), //Send/Recv MoveObjectToContainer Msg
|
||||
MOVETOPOINT(0x49EF7241, MoveToPointMsg.class, MoveToPointHandler.class), // Move to point
|
||||
NAMEVERIFY(0x1B3BF0B1, null, null), // Invalid Name in Character Creation
|
||||
NEWWORLD(0x982E4A77, WorldDataMsg.class, null), // World Data
|
||||
@@ -156,13 +157,13 @@ public enum Protocol {
|
||||
PLACEASSET(0x940962DF, PlaceAssetMsg.class, PlaceAssetMsgHandler.class),
|
||||
PLAYERDATA(0xB206D352, SendOwnPlayerMsg.class, null), //Enter World, Own Player Data
|
||||
PLAYERFRIENDS(0xDDEF9E7D, FriendRequestMsg.class, FriendRequestHandler.class),
|
||||
POWER(0x3C97A459, PerformActionMsg.class, null), // REQ / CMD Perform Action
|
||||
POWER(0x3C97A459, PerformActionMsg.class, PerformActionMsgHandler.class), // REQ / CMD Perform Action
|
||||
POWERACTION(0xA0B27EEB, ApplyEffectMsg.class, null), // Apply Effect, add to effects icons
|
||||
POWERACTIONDD(0xD43052F8, ModifyHealthMsg.class, null), //Modify Health/Mana/Stamina using power
|
||||
POWERACTIONDDDIE(0xC27D446B, null, null), //Modify Health/Mana/Stamina using power and kill target
|
||||
POWERTARGNAME(0x5A807CCE, SendSummonsRequestMsg.class, null), // Send Summons Request
|
||||
RAISEATTR(0x5EEB65E0, ModifyStatMsg.class, null), // Modify Stat
|
||||
RANDOM(0xAC5D0135, RandomMsg.class, null), //RequestSend random roll
|
||||
POWERTARGNAME(0x5A807CCE, SendSummonsMsg.class, SendSummonsMsgHandler.class), // Send Summons Request
|
||||
RAISEATTR(0x5EEB65E0, ModifyStatMsg.class, ModifyStatMsgHandler.class), // Modify Stat
|
||||
RANDOM(0xAC5D0135, RandomMsg.class, RandomMsgHandler.class), //RequestSend random roll
|
||||
READYTOENTER(0x490E4FE0, EnterWorldReceivedMsg.class, null), //Client Ack Receive Enter World
|
||||
REALMDATA(0x2399B775, null, null), //Realm Data - Optional(?)
|
||||
RECOMMENDNATION(0x6D4579E9, RecommendNationMsg.class, RecommendNationMsgHandler.class), // Recommend as Ally/Enemy, error
|
||||
@@ -170,23 +171,23 @@ public enum Protocol {
|
||||
REMOVECHAR(0x5D3F9739, DeleteCharacterMsg.class, null), // Delete Character
|
||||
REMOVEFRIEND(0xE0D5DB42, RemoveFriendMessage.class, RemoveFriendHandler.class),
|
||||
REPAIRBUILDING(0xAF8C2560, RepairBuildingMsg.class, RepairBuildingMsgHandler.class),
|
||||
REPAIROBJECT(0x782219CE, RepairMsg.class, null), //Repair Window Req/Ack, RepairObject item Req/Ack
|
||||
REQUESTCONTENTS(0xA786B0A2, LootWindowRequestMsg.class, null), // MoveObjectToContainer Window Request
|
||||
REPAIROBJECT(0x782219CE, RepairMsg.class, RepairMsgHandler.class), //Repair Window Req/Ack, RepairObject item Req/Ack
|
||||
REQUESTCONTENTS(0xA786B0A2, LootWindowRequestMsg.class, LootWindowRequestMsgHandler.class), // MoveObjectToContainer Window Request
|
||||
REQUESTGUILDLIST(0x85DCC6D7, ReqGuildListMsg.class, RequestGuildListHandler.class),
|
||||
REQUESTMELEEATTACK(0x98C71545, AttackCmdMsg.class, AttackCmdMsgHandler.class), // Attack
|
||||
REQUESTMEMBERLIST(0x3235E5EA, GuildControlMsg.class, GuildControlHandler.class), // Part of Promote/Demote, Also Player History
|
||||
REQUESTTOOPENBANK(0xF26E453F, null, null), // RequestToOpenBankMsg
|
||||
REQUESTTOTRADE(0x4D84259B, TradeRequestMsg.class, null), // Trade Request
|
||||
REQUESTTOTRADE(0x4D84259B, TradeRequestMsg.class, TradeRequestMsgHandler.class), // Trade Request
|
||||
REQUESTTRADECANCEL(0xCB0C5735, RejectTradeRequestMsg.class, null), // Reject RequestToTrade
|
||||
REQUESTTRADEOK(0xFFD29841, AcceptTradeRequestMsg.class, null), // Accept Trade Request
|
||||
RESETAFTERDEATH(0xFDCBB98F, RespawnMsg.class, null), //Respawn Request/Response
|
||||
REQUESTTRADEOK(0xFFD29841, AcceptTradeRequestMsg.class, AcceptTradeRequestMsgHandler.class), // Accept Trade Request
|
||||
RESETAFTERDEATH(0xFDCBB98F, RespawnMsg.class, RespawnMsgHandler.class), //Respawn Request/Response
|
||||
ROTATEMSG(0x57F2088E, RotateObjectMsg.class, null),
|
||||
SAFEMODE(0x9CF3922A, SafeModeMsg.class, null), //Tell client they're in safe mode
|
||||
SCALEOBJECT(0xE2B392D9, null, null), // Adjust scale of object
|
||||
SELECTCHAR(0x7E6A9338, GameServerIPRequestMsg.class, null), // Game Server IP Request
|
||||
SELECTCITY(0x7E6BE630, null, null),
|
||||
SELECTSERVER(0x440D28B7, ServerInfoMsg.class, null), // Server Info Request/Response
|
||||
SELLOBJECT(0x57111C67, SellToNPCMsg.class, null), //Sell to NPC
|
||||
SELLTONPC(0x57111C67, VendorSellMsg.class, VendorSellMsgHandler.class), //Sell to NPC
|
||||
SENDCITYENTRY(0xBC3B5E72, null, null), //Send Teleport/Repledge List
|
||||
SENDGUILDENTRY(0x6D5EF164, null, null),
|
||||
SENDMEMBERENTRY(0x6949C720, GuildListMsg.class, GuildListHandler.class), // ShowCombatInfo guild members list, I think
|
||||
@@ -194,14 +195,12 @@ public enum Protocol {
|
||||
SETMOTD(0xFD21FC7C, MOTDCommitMsg.class, MOTDCommitHandler.class), //Commit Guild/Nation/IC MOTD Message
|
||||
SETOBJVAL(0x08A50FD1, null, null),
|
||||
SETRUNE(0x888E7C64, ApplyRuneMsg.class, null), //Apply Promotion, Stat Rune (maybe disc also)
|
||||
SETSELECTEDOBECT(0x64E10938, TargetObjectMsg.class, null), // Target an object
|
||||
SHOPINFO(0x267DAB90, SellToNPCWindowMsg.class, null), //open Sell to NPC Window
|
||||
SHOPLIST(0x682DAB4D, BuyFromNPCWindowMsg.class, null), // Open Buy From NPC Window
|
||||
SHOWCOMBATINFO(0x9BF1E5EA, ShowMsg.class, null), // Request/Response /show
|
||||
TARGETOBJECT(0x64E10938, TargetObjectMsg.class, TargetObjectMsgHandler.class), // Target an object
|
||||
SHOWCOMBATINFO(0x9BF1E5EA, ShowMsg.class, ShowMsgHandler.class), // Request/Response /show
|
||||
SHOWVAULTINVENTORY(0xD1FB4842, null, null), // Show Vault Inventory
|
||||
SOCIALCHANNEL(0x2BF58FA6, SocialMsg.class, null), // Socials
|
||||
SOCIALCHANNEL(0x2BF58FA6, SocialMsg.class, SocialMsgHandler.class), // Socials
|
||||
STANDARDALERT(0xFA0A24BB, ErrorPopupMsg.class, null), //Popup messages
|
||||
STUCK(0x3D04AF3A, StuckCommandMsg.class, null), // /Stuck Command
|
||||
STUCK(0x3D04AF3A, StuckMsg.class, StuckMsgHandler.class), // /Stuck Command
|
||||
SWEARINGUILD(0x389B66B1, SwearInGuildMsg.class, SwearInGuildHandler.class),
|
||||
SYNC(0x49ec109f, null, null), //Client/Server loc sync
|
||||
SYSTEMBROADCASTCHANNEL(0x2FAD89D1, ChatSystemMsg.class, null), // Chat Channel: System Message
|
||||
@@ -211,22 +210,20 @@ public enum Protocol {
|
||||
TAXRESOURCES(0x4AD458AF, TaxResourcesMsg.class, TaxResourcesMsgHandler.class),
|
||||
TELEPORT(0x23E726EA, TeleportToPointMsg.class, null), // Teleport to point
|
||||
TERRITORYCHANGE(0x6B388C8C, TerritoryChangeMessage.class, null), //Hey rich, look what I found? :)
|
||||
TOGGLESITSTAND(0x624F3C0F, ToggleSitStandMsg.class, null), //Toggle Sit/Stand
|
||||
TRADEADDGOLD(0x654ACB45, AddGoldToTradeWindowMsg.class, null), // Add Gold to Trade Window
|
||||
TRADEADDOBJECT(0x55D363E9, AddItemToTradeWindowMsg.class, null), // Add an Item to the Trade Window
|
||||
TRADECLOSE(0x5008D7FC, CloseTradeWindowMsg.class, null), // Cancel trade/ACK trade complete
|
||||
TRADECONFIRM(0x6911E65E, CommitToTradeMsg.class, null), // Commit to trade
|
||||
TOGGLESITSTAND(0x624F3C0F, ToggleSitStandMsg.class, ToggleSitStandMsgHandler.class), //Toggle Sit/Stand
|
||||
TRADEADDGOLD(0x654ACB45, AddGoldToTradeWindowMsg.class, AddGoldToTradeWindowMsgHandler.class), // Add Gold to Trade Window
|
||||
TRADEADDOBJECT(0x55D363E9, AddItemToTradeWindowMsg.class, AddItemToTradeWindowMsgHandler.class), // Add an Item to the Trade Window
|
||||
TRADECLOSE(0x5008D7FC, CloseTradeWindowMsg.class, CloseTradeWindowMsgHandler.class), // Cancel trade/ACK trade complete
|
||||
TRADECONFIRM(0x6911E65E, CommitToTradeMsg.class, CommitToTradeMsgHandler.class), // Commit to trade
|
||||
TRADECONFIRMSTATUS(0x9F85DAFC, null, null), // Other player commit/uncommit/add item
|
||||
TRADEUNCONFIRM(0xEBE280E0, UncommitToTradeMsg.class, null), // Uncommit to trade
|
||||
TRAINERLIST(0x41FABA62, TrainerInfoMsg.class, null), //Req/Send Trainer Info/Pricing
|
||||
TRAINSKILL(0xB0BF68CD, TrainMsg.class, null), //Train skills/powers
|
||||
TRADEUNCONFIRM(0xEBE280E0, UncommitToTradeMsg.class, UncommitToTradeMsgHandler.class), // Uncommit to trade
|
||||
TRAINERLIST(0x41FABA62, TrainerInfoMsg.class, TrainerInfoMsgHandler.class), //Req/Send Trainer Info/Pricing
|
||||
TRAINSKILL(0xB0BF68CD, TrainMsg.class, TrainMsgHandler.class), //Train skills/powers
|
||||
TRANSFERASSET(0x3EA1C4C9, TransferAssetMsg.class, TransferAssetMsgHandler.class), // Transfer Building
|
||||
TRANSFERGOLDFROMVAULTTOINVENTORY(0x011D0123, TransferGoldFromVaultToInventoryMsg.class, null), // Transfer Gold from Vault to Inventory
|
||||
TRANSFERGOLDTOFROMBUILDING(0x1B1AC8C7, TransferGoldToFromBuildingMsg.class, TransferGoldToFromBuildingMsgHandler.class), // Transfer Gold to/From Building, Transfer Error
|
||||
TRANSFERITEMFROMBANK(0x9D04977B, TransferItemFromBankToInventoryMsg.class, null), // Transfer Item from Bank to Inventory
|
||||
TRANSFERITEMFROMVAULTTOINVENTORY(0x0119A64D, TransferItemFromVaultToInventoryMsg.class, null), // Transfer Item from Vault to Inventory
|
||||
TRANSFERITEMTOBANK(0xD48C46FA, TransferItemFromInventoryToBankMsg.class, null), // Transfer Item from Inventory to Bank
|
||||
UNEQUIP(0xC6BFB907, TransferItemFromEquipToInventoryMsg.class, null), // Transfer Item from Equip to Inventory
|
||||
TRANSFERITEMFROMBANK(0x9D04977B, TransferItemFromBankMsg.class, TransferItemFromBankMsgHandler.class), // Transfer Item from Bank to Inventory
|
||||
TRANSFERITEMTOBANK(0xD48C46FA, TransferItemToBankMsg.class, TransferItemToBankMsgHandler.class), // Transfer Item from Inventory to Bank
|
||||
UNEQUIP(0xC6BFB907, TransferItemFromEquipToInventoryMsg.class, TransferItemFromEquipToInventoryHandler.class), // Transfer Item from Equip to Inventory
|
||||
UNKNOWN(0x238C9259, UnknownMsg.class, null),
|
||||
UPDATECHARORMOB(0xB6D78961, null, null),
|
||||
UPDATECLIENTALLIANCES(0xF3FEB5D4, null, GuildUnknownHandler.class), //AlliancesMsg
|
||||
@@ -237,15 +234,17 @@ public enum Protocol {
|
||||
UPDATEGROUP(0x004E6BCE, GroupUpdateMsg.class, GroupUpdateHandler.class), // Update Group Info
|
||||
UPDATEGUILD(0x001D4DF6, GuildInfoMsg.class, GuildInfoHandler.class), // REQ / CMD Promote/Demote Screen
|
||||
UPDATEOBJECT(0x1A724739, null, null),
|
||||
UPDATESTATE(0x001A45FB, UpdateStateMsg.class, null), // REQ / CMD Toggle Run/Walk Sit/Stand :: UpdateStateMessage
|
||||
UPDATESTATE(0x001A45FB, UpdateStateMsg.class, UpdateStateMsgHandler.class), // REQ / CMD Toggle Run/Walk Sit/Stand :: UpdateStateMessage
|
||||
UPDATETRADEWINDOW(0x406EBDE6, UpdateTradeWindowMsg.class, null), // Trade Complete
|
||||
UPGRADEASSET(0x2B85A865, UpgradeAssetMessage.class, UpgradeAssetMsgHandler.class),
|
||||
VENDORDIALOG(0x98ACD594, VendorDialogMsg.class, null), // Send/Recv Vendor Dialog
|
||||
VENDORDIALOG(0x98ACD594, VendorDialogMsg.class, VendorDialogMsgHandler.class), // Send/Recv Vendor Dialog
|
||||
VENDORSELLWINDOW(0x267DAB90, VendorSellWindowMsg.class, VendorSellWindowMsgHandler.class), //open Sell to NPC Window
|
||||
VENDORBUYWINDOW(0x682DAB4D, VendorBuyWindowMsg.class, VendorBuyWindowMsgHandler.class), // Open Buy From NPC Window
|
||||
VERSIONINFO(0x4B7EE463, VersionInfoMsg.class, null), // Version Information
|
||||
VIEWRESOURCES(0xCEFD0346, ViewResourcesMessage.class, null),
|
||||
VIEWRESOURCES(0xCEFD0346, ViewResourcesMsg.class, ViewResourcesMsgHandler.class),
|
||||
VISUALUPDATE(0x33402fd2, null, null),
|
||||
WEIGHTINVENTORY(0xF1B6A85C, LootWindowResponseMsg.class, null), // MoveObjectToContainer Window Response
|
||||
WHOREQUEST(0xF431CCE9, WhoRequestMsg.class, null), // Request /who
|
||||
WHOREQUEST(0xF431CCE9, WhoRequestMsg.class, WhoRequestMsgHandler.class), // Request /who
|
||||
WHORESPONSE(0xD7C36568, WhoResponseMsg.class, null), // Response /who
|
||||
REQUESTBALLLIST(0xE366FF64, RequestBallListMessage.class, RequestBallListHandler.class),
|
||||
SENDBALLENTRY(0xAC2B5EDC, SendBallEntryMessage.class, SendBallEntryHandler.class),
|
||||
@@ -287,6 +286,35 @@ public enum Protocol {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean handleClientMsg(ClientNetMsg msg) {
|
||||
|
||||
if (msg == null)
|
||||
return false;
|
||||
|
||||
try {
|
||||
|
||||
Protocol protocol = msg.getProtocolMsg();
|
||||
|
||||
// Unhandled opcode
|
||||
|
||||
if (protocol == null)
|
||||
return true;
|
||||
|
||||
AbstractClientMsgHandler msgHandler = protocol.handler;
|
||||
|
||||
// Eat this message; no or empty handler
|
||||
|
||||
if (msgHandler == null)
|
||||
return true;
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error("handler for " + msg.getProtocolMsg() + " failed: " + e);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Protocol getByOpcode(int opcode) {
|
||||
|
||||
Protocol protocol = _protocolMsgByOpcode.get(opcode);
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers;
|
||||
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.Protocol;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.net.client.msg.chat.*;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
import static engine.gameManager.ChatManager.FLOOD_QTY_THRESHOLD;
|
||||
import static engine.gameManager.ChatManager.FLOOD_TIME_THRESHOLD;
|
||||
|
||||
public class AbstractChatMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public AbstractChatMsgHandler() {
|
||||
super(AbstractChatMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
AbstractChatMsg msg;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (AbstractChatMsg) baseMsg;
|
||||
|
||||
if (msg == null)
|
||||
return true;
|
||||
|
||||
if (playerCharacter == null)
|
||||
return true;
|
||||
|
||||
Protocol protocolMsg = msg.getProtocolMsg();
|
||||
|
||||
// Flood control, implemented per channel
|
||||
|
||||
boolean isFlood = false;
|
||||
long curMsgTime = System.currentTimeMillis();
|
||||
long checkTime = playerCharacter.chatFloodTime(protocolMsg.opcode, curMsgTime, FLOOD_QTY_THRESHOLD - 1);
|
||||
|
||||
if ((checkTime > 0L) && (curMsgTime - checkTime < FLOOD_TIME_THRESHOLD))
|
||||
isFlood = true;
|
||||
|
||||
switch (protocolMsg) {
|
||||
case CHATSAY:
|
||||
ChatManager.chatSay(playerCharacter, msg.getMessage(), isFlood);
|
||||
return true;
|
||||
case CHATCSR:
|
||||
ChatManager.chatCSR(msg);
|
||||
return true;
|
||||
case CHATTELL:
|
||||
ChatTellMsg ctm = (ChatTellMsg) msg;
|
||||
ChatManager.chatTell(playerCharacter, ctm.getTargetName(), ctm.getMessage(), isFlood);
|
||||
return true;
|
||||
case CHATSHOUT:
|
||||
ChatManager.chatShout(playerCharacter, msg.getMessage(), isFlood);
|
||||
return true;
|
||||
case CHATGUILD:
|
||||
ChatManager.chatGuild(playerCharacter, (ChatGuildMsg) msg);
|
||||
return true;
|
||||
case CHATGROUP:
|
||||
ChatManager.chatGroup(playerCharacter, (ChatGroupMsg) msg);
|
||||
return true;
|
||||
case CHATIC:
|
||||
ChatManager.chatIC(playerCharacter, (ChatICMsg) msg);
|
||||
return true;
|
||||
case LEADERCHANNELMESSAGE:
|
||||
case GLOBALCHANNELMESSAGE:
|
||||
ChatManager.chatGlobal(playerCharacter, msg.getMessage(), isFlood);
|
||||
return true;
|
||||
case CHATPVP:
|
||||
case CHATCITY:
|
||||
case CHATINFO:
|
||||
case SYSTEMBROADCASTCHANNEL:
|
||||
default:
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.AcceptTradeRequestMsg;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.net.client.msg.OpenTradeWindowMsg;
|
||||
import engine.net.client.msg.UpdateVaultMsg;
|
||||
import engine.objects.Account;
|
||||
import engine.objects.CharacterItemManager;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.server.MBServerStatics;
|
||||
|
||||
import static engine.math.FastMath.sqr;
|
||||
import static engine.objects.CharacterItemManager.canTrade;
|
||||
|
||||
public class AcceptTradeRequestMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public AcceptTradeRequestMsgHandler() {
|
||||
super(AcceptTradeRequestMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
AcceptTradeRequestMsg msg;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (AcceptTradeRequestMsg) baseMsg;
|
||||
|
||||
PlayerCharacter source = (PlayerCharacter) origin.getPlayerCharacter();
|
||||
PlayerCharacter target = PlayerCharacter.getFromCache(msg.getTargetID());
|
||||
|
||||
Dispatch dispatch;
|
||||
|
||||
if (source == null || !source.isAlive())
|
||||
return false;
|
||||
|
||||
if (target == null || !target.isAlive())
|
||||
return false;
|
||||
|
||||
if (source.charItemManager.tradingWith != null)
|
||||
return false;
|
||||
|
||||
if (!canTrade(source, target))
|
||||
return false;
|
||||
|
||||
// verify characterTarget is in range
|
||||
if (source.getLoc().distanceSquared2D(target.getLoc()) > sqr(MBServerStatics.TRADE_RANGE))
|
||||
return false;
|
||||
|
||||
// TODO uncomment this block after we determine when we
|
||||
// setBankOpen(false) and setVaultOpen(false)
|
||||
/*
|
||||
* CharacterItemManager cim1 = source.getCharItemManager();
|
||||
* CharacterItemManager cim2 = characterTarget.getCharItemManager(); if (cim1 ==
|
||||
* null) return false; if (cim2 == null) return false; if (cim1.isBankOpen())
|
||||
* return false; if (cim2.isVaultOpen()) return false;
|
||||
*/
|
||||
ClientConnection sourceConn = origin;
|
||||
ClientConnection targetConn = target.getClientConnection();
|
||||
|
||||
if (sourceConn == null)
|
||||
return false;
|
||||
|
||||
if (targetConn == null)
|
||||
return false;
|
||||
|
||||
CharacterItemManager toTradeWith = target.charItemManager;
|
||||
|
||||
if (toTradeWith == null)
|
||||
return false;
|
||||
|
||||
Account sourceAccount = source.getAccount();
|
||||
Account targetAccount = target.getAccount();
|
||||
|
||||
UpdateVaultMsg uvmSource = new UpdateVaultMsg(sourceAccount);
|
||||
UpdateVaultMsg uvmTarget = new UpdateVaultMsg(targetAccount);
|
||||
|
||||
dispatch = Dispatch.borrow(source, uvmSource);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
||||
|
||||
dispatch = Dispatch.borrow(target, uvmTarget);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
||||
|
||||
source.charItemManager.setVaultOpen(false);
|
||||
toTradeWith.setVaultOpen(false);
|
||||
source.charItemManager.setBankOpen(false);
|
||||
toTradeWith.setBankOpen(false);
|
||||
|
||||
OpenTradeWindowMsg otwm = new OpenTradeWindowMsg(msg.getUnknown01(), source, target);
|
||||
|
||||
// Only start trade if both players aren't already trading with
|
||||
// someone
|
||||
|
||||
if (source.charItemManager.tradingWith != null || toTradeWith.getTradingWith() != null)
|
||||
return false;
|
||||
|
||||
source.charItemManager.initializeTrade();
|
||||
toTradeWith.initializeTrade();
|
||||
source.charItemManager.setTradingWith(targetConn);
|
||||
toTradeWith.setTradingWith(sourceConn);
|
||||
source.charItemManager.tradeID = msg.getUnknown01();
|
||||
toTradeWith.tradeID = msg.getUnknown01();
|
||||
|
||||
dispatch = Dispatch.borrow(source, otwm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
||||
|
||||
dispatch = Dispatch.borrow(target, otwm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -48,9 +48,9 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
// Filter hirelings by slot type
|
||||
|
||||
for (Item hirelings : player.getInventory()) {
|
||||
if (hirelings.getItemBase().getType().equals(ItemType.CONTRACT)) {
|
||||
if (hirelings.template.item_type.equals(ItemType.EMPLOYMENTCONTRACT)) {
|
||||
|
||||
contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.getItemBase().getUUID());
|
||||
contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.templateID);
|
||||
|
||||
if (contract == null)
|
||||
continue;
|
||||
@@ -86,19 +86,19 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
if (contractItem == null)
|
||||
return false;
|
||||
|
||||
if (!player.getCharItemManager().doesCharOwnThisItem(contractItem.getObjectUUID())) {
|
||||
if (!player.charItemManager.doesCharOwnThisItem(contractItem.getObjectUUID())) {
|
||||
Logger.error(player.getName() + "has attempted to place Hireling : " + contractItem.getName() + "without a valid contract!");
|
||||
return false;
|
||||
}
|
||||
|
||||
itemMan = player.getCharItemManager();
|
||||
itemMan = player.charItemManager;
|
||||
|
||||
zone = ZoneManager.findSmallestZone(building.getLoc());
|
||||
|
||||
if (zone == null)
|
||||
return false;
|
||||
|
||||
contract = DbManager.ContractQueries.GET_CONTRACT(contractItem.getItemBase().getUUID());
|
||||
contract = DbManager.ContractQueries.GET_CONTRACT(contractItem.templateID);
|
||||
|
||||
if (contract == null)
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.AddGoldToTradeWindowMsg;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.net.client.msg.UpdateGoldMsg;
|
||||
import engine.net.client.msg.UpdateTradeWindowMsg;
|
||||
import engine.objects.CharacterItemManager;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import static engine.objects.CharacterItemManager.canTrade;
|
||||
|
||||
public class AddGoldToTradeWindowMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public AddGoldToTradeWindowMsgHandler() {
|
||||
super(AddGoldToTradeWindowMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter();
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
AddGoldToTradeWindowMsg msg;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (AddGoldToTradeWindowMsg) baseMsg;
|
||||
Dispatch dispatch;
|
||||
|
||||
if (source == null || !source.isAlive())
|
||||
return false;
|
||||
|
||||
ClientConnection ccOther = source.charItemManager.tradingWith;
|
||||
|
||||
if (ccOther == null)
|
||||
return false;
|
||||
|
||||
PlayerCharacter other = ccOther.getPlayerCharacter();
|
||||
|
||||
if (other == null || !other.isAlive())
|
||||
return false;
|
||||
|
||||
CharacterItemManager tradingWith = other.charItemManager;
|
||||
|
||||
if (tradingWith == null)
|
||||
return false;
|
||||
|
||||
UpdateTradeWindowMsg utwm = new UpdateTradeWindowMsg(other, source);
|
||||
UpdateTradeWindowMsg utwmOther = new UpdateTradeWindowMsg(source, other);
|
||||
|
||||
if (!canTrade(source, other))
|
||||
return false;
|
||||
|
||||
source.charItemManager.setTradeCommitted((byte) 0);
|
||||
tradingWith.setTradeCommitted((byte) 0);
|
||||
|
||||
int amt = msg.getAmount();
|
||||
|
||||
if (amt <= 0) {
|
||||
Logger.info(source.getFirstName() + " added negative gold to trade window. Dupe attempt FAILED!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (amt > MBServerStatics.PLAYER_GOLD_LIMIT)
|
||||
return false;
|
||||
|
||||
if (source.charItemManager.getGoldInventory().getNumOfItems() - amt < 0)
|
||||
return false;
|
||||
|
||||
source.charItemManager.addGoldToTrade(amt);
|
||||
|
||||
// BONUS CODE BELOW: Thanks some unknown retard!
|
||||
// sourceItemMan.updateInventory(sourceItemMan.getInventory(), true);
|
||||
|
||||
UpdateGoldMsg ugm = new UpdateGoldMsg(source);
|
||||
ugm.configure();
|
||||
|
||||
source.charItemManager.modifyCommitToTrade();
|
||||
|
||||
dispatch = Dispatch.borrow(source, utwm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
dispatch = Dispatch.borrow(source, ugm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
dispatch = Dispatch.borrow(other, utwmOther);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.AddItemToTradeWindowMsg;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.net.client.msg.UpdateTradeWindowMsg;
|
||||
import engine.objects.CharacterItemManager;
|
||||
import engine.objects.Item;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
import static engine.objects.CharacterItemManager.canTrade;
|
||||
|
||||
public class AddItemToTradeWindowMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public AddItemToTradeWindowMsgHandler() {
|
||||
super(AddItemToTradeWindowMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
AddItemToTradeWindowMsg msg;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (AddItemToTradeWindowMsg) baseMsg;
|
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter();
|
||||
Dispatch dispatch;
|
||||
|
||||
if (source == null || !source.isAlive())
|
||||
return false;
|
||||
|
||||
ClientConnection ccOther = source.charItemManager.tradingWith;
|
||||
|
||||
if (ccOther == null)
|
||||
return false;
|
||||
|
||||
PlayerCharacter other = ccOther.getPlayerCharacter();
|
||||
|
||||
if (other == null || !other.isAlive())
|
||||
return false;
|
||||
|
||||
CharacterItemManager tradingWith = other.charItemManager;
|
||||
|
||||
if (tradingWith == null)
|
||||
return false;
|
||||
|
||||
if (!canTrade(source, other))
|
||||
return false;
|
||||
|
||||
Item item = Item.getFromCache(msg.getItemID());
|
||||
|
||||
if (item == null)
|
||||
return false;
|
||||
|
||||
if (!source.charItemManager.doesCharOwnThisItem(item.getObjectUUID()))
|
||||
return false;
|
||||
|
||||
//can't add item to trade window twice
|
||||
if (source.charItemManager.tradingContains(item))
|
||||
return false;
|
||||
|
||||
//dupe check
|
||||
if (!item.validForInventory(source.getClientConnection(), source, source.charItemManager))
|
||||
return false;
|
||||
|
||||
if (!tradingWith.hasRoomTrade(item.template.item_wt)) {
|
||||
dispatch = Dispatch.borrow(source, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
||||
return false;
|
||||
}
|
||||
|
||||
UpdateTradeWindowMsg utwm = new UpdateTradeWindowMsg(source, other);
|
||||
|
||||
source.charItemManager.setTradeCommitted((byte) 0);
|
||||
tradingWith.setTradeCommitted((byte) 0);
|
||||
|
||||
source.charItemManager.addItemToTrade(item);
|
||||
|
||||
dispatch = Dispatch.borrow(other, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
||||
|
||||
source.charItemManager.modifyCommitToTrade();
|
||||
|
||||
dispatch = Dispatch.borrow(other, utwm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,10 +12,7 @@ import engine.net.client.msg.ArcLoginNotifyMsg;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.net.client.msg.HotzoneChangeMsg;
|
||||
import engine.net.client.msg.PetMsg;
|
||||
import engine.objects.Account;
|
||||
import engine.objects.Guild;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.objects.PlayerFriends;
|
||||
import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import engine.session.Session;
|
||||
import org.pmw.tinylog.Logger;
|
||||
@@ -73,7 +70,7 @@ public class ArcLoginNotifyMsgHandler extends AbstractClientMsgHandler {
|
||||
ChatManager.sendSystemMessage(player, ConfigManager.currentRepoBranch);
|
||||
|
||||
// Set player mask for QT
|
||||
if (player.getRace() != null && player.getRace().getToken() == -524731385)
|
||||
if (player.race != null && player.race.getToken() == -524731385)
|
||||
player.setObjectTypeMask(MBServerStatics.MASK_PLAYER | MBServerStatics.MASK_UNDEAD);
|
||||
else
|
||||
player.setObjectTypeMask(MBServerStatics.MASK_PLAYER);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package engine.net.client.handlers;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.Enum.DispatchChannel;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.net.Dispatch;
|
||||
@@ -10,7 +11,6 @@ import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.objects.GuildStatusController;
|
||||
import engine.objects.Mine;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.objects.Resource;
|
||||
|
||||
/*
|
||||
* @Author:
|
||||
@@ -51,7 +51,7 @@ public class ArcMineChangeProductionMsgHandler extends AbstractClientMsgHandler
|
||||
|
||||
//make sure valid resource
|
||||
|
||||
Resource resource = Resource.resourceByHash.get(changeProductionMsg.getResourceHash());
|
||||
Enum.ResourceType resource = Enum.ResourceType.hashLookup.get(changeProductionMsg.getResourceHash());
|
||||
|
||||
if (resource == null)
|
||||
return true;
|
||||
|
||||
@@ -2,12 +2,15 @@ package engine.net.client.handlers;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ArcViewAssetTransactionsMsg;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.objects.Building;
|
||||
import engine.objects.City;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.objects.Warehouse;
|
||||
|
||||
@@ -37,7 +40,13 @@ public class ArcViewAssetTransactionsMsgHandler extends AbstractClientMsgHandler
|
||||
|
||||
msg = (ArcViewAssetTransactionsMsg) baseMsg;
|
||||
|
||||
Warehouse warehouse = Warehouse.warehouseByBuildingUUID.get(msg.getWarehouseID());
|
||||
Building warehouseBuilding = BuildingManager.getBuilding(msg.getWarehouseID());
|
||||
City city = warehouseBuilding.getCity();
|
||||
|
||||
if (city == null)
|
||||
return true;
|
||||
|
||||
Warehouse warehouse = city.warehouse;
|
||||
|
||||
if (warehouse == null)
|
||||
return true;
|
||||
|
||||
@@ -8,7 +8,10 @@ import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.AttackCmdMsg;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.net.client.msg.TargetedActionMsg;
|
||||
import engine.objects.*;
|
||||
import engine.objects.AbstractWorldObject;
|
||||
import engine.objects.Mob;
|
||||
import engine.objects.NPC;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
/*
|
||||
* @Author:
|
||||
@@ -46,7 +49,7 @@ public class AttackCmdMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
targetType = Enum.GameObjectType.values()[msg.getTargetType()];
|
||||
|
||||
switch(targetType){
|
||||
switch (targetType) {
|
||||
case Mob:
|
||||
target = Mob.getMob(msg.getTargetID());
|
||||
break;
|
||||
@@ -60,7 +63,7 @@ public class AttackCmdMsgHandler extends AbstractClientMsgHandler {
|
||||
target = NPC.getNPC(msg.getTargetID());
|
||||
break;
|
||||
}
|
||||
if(target == null) {
|
||||
if (target == null) {
|
||||
playerCharacter.setCombatTarget(null);
|
||||
return true; // cannot attack a null target
|
||||
}
|
||||
@@ -70,15 +73,16 @@ public class AttackCmdMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
//put in combat if not already
|
||||
|
||||
if (!playerCharacter.isCombat())
|
||||
if (!playerCharacter.isCombat()) {
|
||||
//CombatManager.toggleCombat(true, origin);
|
||||
CombatManager.toggleCombat(true, origin);
|
||||
|
||||
}
|
||||
//make character stand if sitting
|
||||
|
||||
if (playerCharacter.isSit())
|
||||
CombatManager.toggleSit(false, origin);
|
||||
|
||||
CombatManager.AttackTarget(playerCharacter, target);
|
||||
CombatManager.combatCycle(playerCharacter, target);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class ChangeRankHandler extends AbstractClientMsgHandler {
|
||||
targetPlayer.setGuildTitle(msg.getNewRank());
|
||||
|
||||
targetName = targetPlayer.getFirstName();
|
||||
isMale = targetPlayer.getRace().getRaceType().getCharacterSex().equals(Enum.CharacterSex.MALE);
|
||||
isMale = targetPlayer.race.getRaceType().getCharacterSex().equals(Enum.CharacterSex.MALE);
|
||||
} else {
|
||||
DbManager.GuildQueries.UPDATE_GUILD_RANK_OFFLINE(msg.getPlayerUUID(), msg.getNewRank(), sourcePlayer.getGuild().getObjectUUID());
|
||||
|
||||
|
||||
@@ -8,7 +8,10 @@ import engine.gameManager.ZoneManager;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.*;
|
||||
import engine.net.client.msg.CityDataMsg;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.net.client.msg.HotzoneChangeMsg;
|
||||
import engine.net.client.msg.WorldRealmMsg;
|
||||
import engine.objects.City;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.session.Session;
|
||||
@@ -22,7 +25,7 @@ import engine.session.Session;
|
||||
public class CityDataHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public CityDataHandler() {
|
||||
super(KeepAliveServerClientMsg.class);
|
||||
super(CityDataMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.gameManager.DevCmdManager;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.net.client.msg.commands.ClientAdminCommandMsg;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.AbstractWorldObject;
|
||||
import engine.objects.Account;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
public class ClientAdminCommandMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public ClientAdminCommandMsgHandler() {
|
||||
super(ClientAdminCommandMsg.class);
|
||||
}
|
||||
|
||||
public static boolean processDevCommand(AbstractWorldObject sender, String text) {
|
||||
|
||||
if (sender.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
|
||||
|
||||
PlayerCharacter pcSender = (PlayerCharacter) sender;
|
||||
|
||||
// first remove the DEV_CMD_PREFIX
|
||||
String[] words = text.split(MBServerStatics.DEV_CMD_PREFIX, 2);
|
||||
|
||||
if (words[1].length() == 0)
|
||||
return false;
|
||||
|
||||
// next get the command
|
||||
String[] commands = words[1].split(" ", 2);
|
||||
String cmd = commands[0].toLowerCase();
|
||||
String cmdArgument = "";
|
||||
|
||||
if (commands.length > 1)
|
||||
cmdArgument = commands[1].trim();
|
||||
|
||||
AbstractGameObject target = pcSender.getLastTarget();
|
||||
// return DevCmd.processDevCommand(pcSender, cmd, cmdArgument,
|
||||
// target);
|
||||
return DevCmdManager.handleDevCmd(pcSender, cmd,
|
||||
cmdArgument, target);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
ClientAdminCommandMsg msg;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (ClientAdminCommandMsg) baseMsg;
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
Account acct = SessionManager.getAccount(player);
|
||||
|
||||
if (acct == null)
|
||||
return true;
|
||||
|
||||
// require minimal access to continue
|
||||
// specific accessLevel checks performed by the DevCmdManager
|
||||
if (acct.status.equals(Enum.AccountStatus.ADMIN) == false) {
|
||||
Logger.warn(player.getFirstName() + " Attempted to use a client admin command");
|
||||
//wtf? ChatManager.chatSystemInfo(pcSender, "CHEATER!!!!!!!!!!!!!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// First remove the initial slash
|
||||
String d = msg.getMsgCommand();
|
||||
String[] words = d.split("/", 2);
|
||||
|
||||
if (words[1].length() == 0)
|
||||
return true;
|
||||
|
||||
// Next get the command
|
||||
String[] commands = words[1].split(" ", 2);
|
||||
String cmd = commands[0].toLowerCase();
|
||||
String cmdArgument = "";
|
||||
|
||||
if (commands.length > 1)
|
||||
cmdArgument = commands[1].trim();
|
||||
|
||||
AbstractGameObject target = msg.getTarget();
|
||||
|
||||
// Map to a DevCmd
|
||||
String devCmd = "";
|
||||
|
||||
if (cmd.compareTo("goto") == 0)
|
||||
devCmd = "goto";
|
||||
else if (cmd.compareTo("suspend") == 0)
|
||||
devCmd = "suspend";
|
||||
else if (cmd.compareTo("getinfo") == 0)
|
||||
devCmd = "info";
|
||||
else if (devCmd.isEmpty()) {
|
||||
Logger.info("Unhandled admin command was used: /"
|
||||
+ cmd);
|
||||
return true;
|
||||
}
|
||||
|
||||
DevCmdManager.handleDevCmd(player, devCmd, cmdArgument,
|
||||
target);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.net.client.msg.CloseTradeWindowMsg;
|
||||
import engine.objects.CharacterItemManager;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
public class CloseTradeWindowMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public CloseTradeWindowMsgHandler() {
|
||||
super(CloseTradeWindowMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter();
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
CloseTradeWindowMsg msg;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (CloseTradeWindowMsg) baseMsg;
|
||||
|
||||
Dispatch dispatch;
|
||||
|
||||
if (source == null)
|
||||
return false;
|
||||
|
||||
CharacterItemManager sourceItemMan = source.charItemManager;
|
||||
|
||||
if (sourceItemMan == null)
|
||||
return false;
|
||||
|
||||
int tradeID = source.charItemManager.tradeID;
|
||||
CloseTradeWindowMsg closeMsg = new CloseTradeWindowMsg(source, tradeID);
|
||||
|
||||
dispatch = Dispatch.borrow(source, closeMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
ClientConnection cc2 = sourceItemMan.getTradingWith();
|
||||
|
||||
if (cc2 == null || cc2.getPlayerCharacter() == null) {
|
||||
sourceItemMan.endTrade();
|
||||
return true;
|
||||
}
|
||||
|
||||
sourceItemMan.endTrade();
|
||||
cc2.getPlayerCharacter().charItemManager.closeTradeWindow(msg, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers;
|
||||
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.net.client.msg.CloseTradeWindowMsg;
|
||||
import engine.net.client.msg.CommitToTradeMsg;
|
||||
import engine.objects.CharacterItemManager;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
import static engine.objects.CharacterItemManager.canTrade;
|
||||
|
||||
public class CommitToTradeMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public CommitToTradeMsgHandler() {
|
||||
super(CommitToTradeMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter();
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
CommitToTradeMsg msg;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (CommitToTradeMsg) baseMsg;
|
||||
|
||||
if (source == null || !source.isAlive())
|
||||
return false;
|
||||
|
||||
source.charItemManager.setTradeCommitted((byte) 1);
|
||||
|
||||
ClientConnection ccOther = source.charItemManager.tradingWith;
|
||||
|
||||
if (ccOther == null)
|
||||
return false;
|
||||
|
||||
PlayerCharacter other = ccOther.getPlayerCharacter();
|
||||
|
||||
if (other == null || !other.isAlive())
|
||||
return false;
|
||||
|
||||
CharacterItemManager tradingWith = other.charItemManager;
|
||||
|
||||
if (tradingWith == null)
|
||||
return false;
|
||||
|
||||
if (!canTrade(source, other))
|
||||
return false;
|
||||
|
||||
source.charItemManager.modifyCommitToTrade();
|
||||
|
||||
if (source.charItemManager.getTradeCommitted() == (byte) 1 && tradingWith.getTradeCommitted() == (byte) 1) {
|
||||
int tradeID = source.charItemManager.tradeID;
|
||||
CloseTradeWindowMsg ctwm1 = new CloseTradeWindowMsg(source, tradeID);
|
||||
CloseTradeWindowMsg ctwm2 = new CloseTradeWindowMsg(other, tradeID);
|
||||
source.charItemManager.commitTrade();
|
||||
source.charItemManager.closeTradeWindow(ctwm1, false);
|
||||
other.charItemManager.closeTradeWindow(ctwm2, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers;
|
||||
|
||||
import engine.Enum.DispatchChannel;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.net.client.msg.DeleteItemMsg;
|
||||
import engine.objects.CharacterItemManager;
|
||||
import engine.objects.Item;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
public class DeleteItemMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public DeleteItemMsgHandler() {
|
||||
super(DeleteItemMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
DeleteItemMsg msg;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (DeleteItemMsg) baseMsg;
|
||||
CharacterItemManager itemManager = origin.getPlayerCharacter().charItemManager;
|
||||
int uuid = msg.getUUID();
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
if (!player.isAlive())
|
||||
return true;
|
||||
|
||||
Item item = Item.getFromCache(msg.getUUID());
|
||||
|
||||
if (item == null)
|
||||
return true;
|
||||
|
||||
if (!itemManager.doesCharOwnThisItem(item.getObjectUUID()))
|
||||
return true;
|
||||
|
||||
if (!itemManager.inventoryContains(item))
|
||||
return true;
|
||||
|
||||
if (item.isCanDestroy())
|
||||
if (itemManager.delete(item) == true) {
|
||||
Dispatch dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers;
|
||||
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.net.client.msg.GoldFromVaultMsg;
|
||||
import engine.objects.Account;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
public class GoldFromVaultMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public GoldFromVaultMsgHandler() {
|
||||
super(GoldFromVaultMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
GoldFromVaultMsg msg = (GoldFromVaultMsg) baseMsg;
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
Account account = player.getAccount();
|
||||
|
||||
if (account == null)
|
||||
return true;
|
||||
|
||||
account.transferGoldFromVaultToInventory(msg, origin);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers;
|
||||
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.net.client.msg.GoldToVaultMsg;
|
||||
import engine.objects.Account;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
public class GoldToVaultMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public GoldToVaultMsgHandler() {
|
||||
super(GoldToVaultMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
GoldToVaultMsg msg = (GoldToVaultMsg) baseMsg;
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
Account account = player.getAccount();
|
||||
|
||||
if (account == null)
|
||||
return true;
|
||||
|
||||
account.transferGoldFromInventoryToVault(msg, origin);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,6 @@ import engine.Enum.GameObjectType;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.gameManager.ConfigManager;
|
||||
import engine.gameManager.GroupManager;
|
||||
import engine.gameManager.GuildManager;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
@@ -106,8 +105,8 @@ public class GroupInviteHandler extends AbstractClientMsgHandler {
|
||||
if (target.isIgnoringPlayer(source))
|
||||
return false;
|
||||
|
||||
if(ConfigManager.MB_RULESET.getValue() == "LORE") {
|
||||
if(source.guild.equals(Guild.getErrantGuild()))
|
||||
if (ConfigManager.MB_RULESET.getValue() == "LORE") {
|
||||
if (source.guild.equals(Guild.getErrantGuild()))
|
||||
return false;
|
||||
|
||||
if (source.guild.getGuildType() != null) {
|
||||
|
||||
@@ -28,7 +28,6 @@ import engine.net.client.msg.guild.GuildCreationFinalizeMsg;
|
||||
import engine.net.client.msg.guild.GuildInfoMsg;
|
||||
import engine.objects.Guild;
|
||||
import engine.objects.Item;
|
||||
import engine.objects.ItemBase;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.util.StringUtils;
|
||||
|
||||
@@ -46,7 +45,7 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler {
|
||||
Enum.GuildCharterType charterType;
|
||||
Guild newGuild;
|
||||
Guild playerGuild;
|
||||
ItemBase itemBase;
|
||||
|
||||
Item charter;
|
||||
Dispatch dispatch;
|
||||
|
||||
@@ -64,21 +63,19 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler {
|
||||
|
||||
charter = msg.getCharter();
|
||||
|
||||
if (charter == null || charter.getOwnerType() != OwnerType.PlayerCharacter || charter.getOwnerID() != player.getObjectUUID()) {
|
||||
if (charter == null || charter.ownerType != OwnerType.PlayerCharacter || charter.getOwnerID() != player.getObjectUUID()) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
itemBase = charter.getItemBase();
|
||||
|
||||
// Item must be a valid charterType (type 10 in db)
|
||||
|
||||
if (itemBase == null || (itemBase.getType().equals(ItemType.GUILDCHARTER) == false)) {
|
||||
if (charter == null || (charter.template.item_type.equals(ItemType.CHARTER) == false)) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
charterType = Enum.GuildCharterType.getGuildTypeFromCharter(itemBase);
|
||||
charterType = Enum.GuildCharterType.getGuildTypeFromCharter(charter);
|
||||
|
||||
if (charterType == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
||||
@@ -134,8 +131,8 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler {
|
||||
player.setInnerCouncil(true);
|
||||
player.setFullMember(true);
|
||||
player.setGuildTitle(charterType.getNumberOfRanks() - 1);
|
||||
player.getCharItemManager().delete(charter);
|
||||
player.getCharItemManager().updateInventory();
|
||||
player.charItemManager.delete(charter);
|
||||
player.charItemManager.updateInventory();
|
||||
player.incVer();
|
||||
|
||||
DispatchMessage.sendToAllInRange(player, new GuildInfoMsg(player, newGuild, 2));
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers;
|
||||
|
||||
import engine.Enum.DispatchChannel;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.net.client.msg.GuildTreeStatusMsg;
|
||||
import engine.objects.Building;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
public class GuildTreeStatusMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public GuildTreeStatusMsgHandler() {
|
||||
super(GuildTreeStatusMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
GuildTreeStatusMsg msg = (GuildTreeStatusMsg) baseMsg;
|
||||
|
||||
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
Dispatch dispatch;
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
if (origin.guildtreespam > System.currentTimeMillis())
|
||||
return true;
|
||||
|
||||
origin.guildtreespam = System.currentTimeMillis() + 5000;
|
||||
|
||||
Building building = BuildingManager.getBuildingFromCache(msg.getTargetID());
|
||||
|
||||
if (building == null)
|
||||
return true;
|
||||
|
||||
GuildTreeStatusMsg guildTreeStatusMsg = new GuildTreeStatusMsg(building, player);
|
||||
guildTreeStatusMsg.configure();
|
||||
|
||||
dispatch = Dispatch.borrow(player, guildTreeStatusMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers;
|
||||
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.net.client.msg.IgnoreMsg;
|
||||
import engine.objects.Account;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
public class IgnoreMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public IgnoreMsgHandler() {
|
||||
super(IgnoreMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
IgnoreMsg msg;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (IgnoreMsg) baseMsg;
|
||||
|
||||
if (msg.nameToIgnore.isEmpty()) { // list ignored players
|
||||
String[] ignoredPlayers = playerCharacter.getIgnoredPlayerNames();
|
||||
String crlf = "\r\n";
|
||||
String out = "Ignored players (" + ignoredPlayers.length + "):";
|
||||
|
||||
for (String name : ignoredPlayers)
|
||||
out += crlf + name;
|
||||
|
||||
ChatManager.chatSystemInfo(playerCharacter, out);
|
||||
return true;
|
||||
}
|
||||
|
||||
//FIX THIS, USE OUR CACHE!
|
||||
PlayerCharacter pcToIgnore = PlayerCharacter.getByFirstName(msg.nameToIgnore);
|
||||
|
||||
if (playerCharacter == null)
|
||||
return true;
|
||||
|
||||
|
||||
if (pcToIgnore == null || pcToIgnore.getAccount() == null) {
|
||||
ChatManager.chatSystemError(playerCharacter, "Character name " + msg.nameToIgnore + " does not exist and cannot be ignored.");
|
||||
return true;
|
||||
}
|
||||
if (pcToIgnore.getObjectUUID() == playerCharacter.getObjectUUID()) {
|
||||
ChatManager.chatSystemError(playerCharacter, "Try as you might, you are unable to ignore yourself!");
|
||||
return true;
|
||||
}
|
||||
String firstName = pcToIgnore.getFirstName();
|
||||
|
||||
Account account = playerCharacter.getAccount();
|
||||
|
||||
if (account == null)
|
||||
return true;
|
||||
|
||||
if (playerCharacter.isIgnoringPlayer(pcToIgnore)) {
|
||||
|
||||
if (account != null) {
|
||||
if (!DbManager.PlayerCharacterQueries.SET_IGNORE_LIST(account.getObjectUUID(), pcToIgnore.getObjectUUID(), false, pcToIgnore.getFirstName())) {
|
||||
ChatManager.chatSystemError(playerCharacter, "Unable to update database ignore list.");
|
||||
}
|
||||
} else {
|
||||
ChatManager.chatSystemError(playerCharacter, "Unable to update database ignore list.");
|
||||
}
|
||||
|
||||
playerCharacter.removeIgnoredPlayer(pcToIgnore.getAccount());
|
||||
ChatManager.chatSystemInfo(playerCharacter, "Character " + firstName + " is no longer ignored.");
|
||||
} else {
|
||||
|
||||
if (!PlayerCharacter.isIgnorable()) {
|
||||
ChatManager.chatSystemError(playerCharacter, "This character cannot be ignored.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PlayerCharacter.isIgnoreListFull()) {
|
||||
ChatManager.chatSystemError(playerCharacter, "Your ignore list is already full.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (account != null) {
|
||||
if (!DbManager.PlayerCharacterQueries.SET_IGNORE_LIST(account.getObjectUUID(), pcToIgnore.getObjectUUID(), true, pcToIgnore.getFirstName())) {
|
||||
ChatManager.chatSystemError(playerCharacter, "Unable to update database ignore list. This ignore will not persist past server down.");
|
||||
}
|
||||
} else {
|
||||
ChatManager.chatSystemError(playerCharacter, "Unable to update database ignore list.");
|
||||
}
|
||||
|
||||
playerCharacter.addIgnoredPlayer(pcToIgnore.getAccount(), pcToIgnore.getFirstName());
|
||||
ChatManager.chatSystemInfo(playerCharacter, "Character " + firstName + " is now being ignored.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user