Turn item id magic numbers into constants

This commit is contained in:
P0nk
2021-11-07 11:38:32 +01:00
parent a4c079c2e8
commit 4efd356cbf
50 changed files with 790 additions and 346 deletions

View File

@@ -23,6 +23,7 @@ package server;
import client.inventory.*;
import config.YamlConfig;
import constants.id.ItemId;
import constants.inventory.ItemConstants;
import net.server.Server;
import net.server.audit.locks.MonitoredLockType;
@@ -103,13 +104,13 @@ public class CashShop {
if (ItemConstants.EXPIRING_ITEMS) {
if (period == 1) {
if (itemId == 5211048 || itemId == 5360042) { // 4 Hour 2X coupons, the period is 1, but we don't want them to last a day.
if (itemId == ItemId.EXP_COUPON_2X_4H || itemId == ItemId.DROP_COUPON_2X_4H) { // 4 Hour 2X coupons, the period is 1, but we don't want them to last a day.
item.setExpiration(Server.getInstance().getCurrentTime() + HOURS.toMillis(4));
/*
} else if(itemId == 5211047 || itemId == 5360014) { // 3 Hour 2X coupons, unused as of now
item.setExpiration(Server.getInstance().getCurrentTime() + HOURS.toMillis(3));
*/
} else if (itemId == 5211060) { // 2 Hour 3X coupons.
} else if (itemId == ItemId.EXP_COUPON_3X_2H) { // 2 Hour 3X coupons.
item.setExpiration(Server.getInstance().getCurrentTime() + HOURS.toMillis(2));
} else {
item.setExpiration(Server.getInstance().getCurrentTime() + DAYS.toMillis(1));
@@ -525,7 +526,7 @@ public class CashShop {
}
public synchronized Pair<Item, Item> openCashShopSurprise() {
Item css = getCashShopItemByItemid(5222000);
Item css = getCashShopItemByItemid(ItemId.CASH_SHOP_SURPRISE);
if (css != null) {
CashItem cItem = CashItemFactory.getRandomCashItem();

View File

@@ -26,6 +26,7 @@ import client.*;
import client.autoban.AutobanFactory;
import client.inventory.*;
import config.YamlConfig;
import constants.id.ItemId;
import constants.inventory.EquipSlot;
import constants.inventory.ItemConstants;
import constants.skills.Assassin;
@@ -1037,17 +1038,17 @@ public class ItemInformationProvider {
double prop = (double) stats.get("success");
switch (vegaItemId) {
case 5610000:
case ItemId.VEGAS_SPELL_10:
if (prop == 10.0f) {
prop = 30.0f;
}
break;
case 5610001:
case ItemId.VEGAS_SPELL_60:
if (prop == 60.0f) {
prop = 90.0f;
}
break;
case 2049100:
case ItemId.CHAOS_SCROll_60:
prop = 100.0f;
break;
}
@@ -1055,25 +1056,25 @@ public class ItemInformationProvider {
if (assertGM || rollSuccessChance(prop)) {
short flag = nEquip.getFlag();
switch (scrollId) {
case 2040727:
case ItemId.SPIKES_SCROLL:
flag |= ItemConstants.SPIKES;
nEquip.setFlag((byte) flag);
break;
case 2041058:
case ItemId.COLD_PROTECTION_SCROLl:
flag |= ItemConstants.COLD;
nEquip.setFlag((byte) flag);
break;
case 2049000:
case 2049001:
case 2049002:
case 2049003:
case ItemId.CLEAN_SLATE_1:
case ItemId.CLEAN_SLATE_3:
case ItemId.CLEAN_SLATE_5:
case ItemId.CLEAN_SLATE_20:
if (canUseCleanSlate(nEquip)) {
nEquip.setUpgradeSlots((byte) (nEquip.getUpgradeSlots() + 1));
}
break;
case 2049100:
case 2049101:
case 2049102:
case ItemId.CHAOS_SCROll_60:
case ItemId.LIAR_TREE_SAP:
case ItemId.MAPLE_SYRUP:
scrollEquipWithChaos(nEquip, YamlConfig.config.server.CHSCROLL_STAT_RANGE);
break;
@@ -1787,7 +1788,7 @@ public class ItemInformationProvider {
public boolean canWearEquipment(Character chr, Equip equip, int dst) {
int id = equip.getItemId();
if (ItemConstants.isWeddingRing(id) && chr.hasJustMarried()) {
if (ItemId.isWeddingRing(id) && chr.hasJustMarried()) {
chr.dropMessage(5, "The Wedding Ring cannot be equipped on this map."); // will dc everyone due to doubled couple effect
return false;
}
@@ -1966,32 +1967,19 @@ public class ItemInformationProvider {
int range = (level - 1) / 10;
if (range < 5) {
return 4260000;
return ItemId.BASIC_MONSTER_CRYSTAL_1;
} else if (range > 11) {
return 4260008;
return ItemId.ADVANCED_MONSTER_CRYSTAL_3;
} else {
switch (range) {
case 5:
return 4260001;
case 6:
return 4260002;
case 7:
return 4260003;
case 8:
return 4260004;
case 9:
return 4260005;
case 10:
return 4260006;
default:
return 4260007;
}
return switch (range) {
case 5 -> ItemId.BASIC_MONSTER_CRYSTAL_2;
case 6 -> ItemId.BASIC_MONSTER_CRYSTAL_3;
case 7 -> ItemId.INTERMEDIATE_MONSTER_CRYSTAL_1;
case 8 -> ItemId.INTERMEDIATE_MONSTER_CRYSTAL_2;
case 9 -> ItemId.INTERMEDIATE_MONSTER_CRYSTAL_3;
case 10 -> ItemId.ADVANCED_MONSTER_CRYSTAL_1;
default -> ItemId.ADVANCED_MONSTER_CRYSTAL_2;
};
}
}

View File

@@ -26,6 +26,7 @@ import client.inventory.InventoryType;
import client.inventory.Item;
import client.inventory.Pet;
import client.inventory.manipulator.InventoryManipulator;
import constants.id.ItemId;
import constants.inventory.ItemConstants;
import tools.DatabaseConnection;
import tools.PacketCreator;
@@ -48,18 +49,18 @@ public class Shop {
private final int npcId;
private final List<ShopItem> items;
private final int tokenvalue = 1000000000;
private final int token = 4000313;
private final int token = ItemId.GOLDEN_MAPLE_LEAF;
static {
for (int i = 2070000; i < 2070017; i++) {
rechargeableItems.add(i);
for (int throwingStarId : ItemId.allThrowingStarIds()) {
rechargeableItems.add(throwingStarId);
}
rechargeableItems.add(2331000);//Blaze Capsule
rechargeableItems.add(2332000);//Glaze Capsule
rechargeableItems.add(2070018);
rechargeableItems.remove(2070014); // doesn't exist
for (int i = 2330000; i <= 2330005; i++) {
rechargeableItems.add(i);
rechargeableItems.add(ItemId.BLAZE_CAPSULE);
rechargeableItems.add(ItemId.GLAZE_CAPSULE);
rechargeableItems.add(ItemId.BALANCED_FURY);
rechargeableItems.remove(ItemId.DEVIL_RAIN_THROWING_STAR); // doesn't exist
for (int bulletId : ItemId.allBulletIds()) {
rechargeableItems.add(bulletId);
}
}
@@ -114,16 +115,16 @@ public class Shop {
} else if (item.getPitch() > 0) {
int amount = (int) Math.min((float) item.getPitch() * quantity, Integer.MAX_VALUE);
if (c.getPlayer().getInventory(InventoryType.ETC).countById(4310000) >= amount) {
if (c.getPlayer().getInventory(InventoryType.ETC).countById(ItemId.PERFECT_PITCH) >= amount) {
if (InventoryManipulator.checkSpace(c, itemId, quantity, "")) {
if (!ItemConstants.isRechargeable(itemId)) {
InventoryManipulator.addById(c, itemId, quantity, "", -1);
InventoryManipulator.removeById(c, InventoryType.ETC, 4310000, amount, false, false);
InventoryManipulator.removeById(c, InventoryType.ETC, ItemId.PERFECT_PITCH, amount, false, false);
} else {
short slotMax = ii.getSlotMax(c, item.getItemId());
quantity = slotMax;
InventoryManipulator.addById(c, itemId, quantity, "", -1);
InventoryManipulator.removeById(c, InventoryType.ETC, 4310000, amount, false, false);
InventoryManipulator.removeById(c, InventoryType.ETC, ItemId.PERFECT_PITCH, amount, false, false);
}
c.sendPacket(PacketCreator.shopTransaction((byte) 0));
} else {

View File

@@ -30,6 +30,7 @@ import client.inventory.manipulator.InventoryManipulator;
import client.status.MonsterStatus;
import client.status.MonsterStatusEffect;
import config.YamlConfig;
import constants.id.ItemId;
import constants.inventory.ItemConstants;
import constants.skills.*;
import net.packet.Packet;
@@ -158,9 +159,9 @@ public class StatEffect {
}
private static byte mapProtection(int sourceid) {
if (sourceid == 2022001 || sourceid == 2022186) {
if (sourceid == ItemId.RED_BEAN_PORRIDGE || sourceid == ItemId.SOFT_WHITE_BUN) {
return 1; //elnath cold
} else if (sourceid == 2022040) {
} else if (sourceid == ItemId.AIR_BUBBLE) {
return 2; //aqua road underwater
} else {
return 0;
@@ -252,14 +253,14 @@ public class StatEffect {
if (ret.overTime && ret.getSummonMovementType() == null) {
if (!skill) {
if (isPyramidBuff(sourceid)) {
if (ItemId.isPyramidBuff(sourceid)) {
ret.berserk = DataTool.getInt("berserk", source, 0);
ret.booster = DataTool.getInt("booster", source, 0);
addBuffStatPairToListIfNotZero(statups, BuffStat.BERSERK, ret.berserk);
addBuffStatPairToListIfNotZero(statups, BuffStat.BOOSTER, ret.booster);
} else if (isDojoBuff(sourceid) || isHpMpRecovery(sourceid)) {
} else if (ItemId.isDojoBuff(sourceid) || isHpMpRecovery(sourceid)) {
ret.mhpR = (byte) DataTool.getInt("mhpR", source, 0);
ret.mhpRRate = (short) (DataTool.getInt("mhpRRate", source, 0) * 100);
ret.mmpR = (byte) DataTool.getInt("mmpR", source, 0);
@@ -268,7 +269,7 @@ public class StatEffect {
addBuffStatPairToListIfNotZero(statups, BuffStat.HPREC, (int) ret.mhpR);
addBuffStatPairToListIfNotZero(statups, BuffStat.MPREC, (int) ret.mmpR);
} else if (isRateCoupon(sourceid)) {
} else if (ItemId.isRateCoupon(sourceid)) {
switch (DataTool.getInt("expR", source, 0)) {
case 1:
addBuffStatPairToListIfNotZero(statups, BuffStat.COUPON_EXP1, 1);
@@ -300,7 +301,7 @@ public class StatEffect {
addBuffStatPairToListIfNotZero(statups, BuffStat.COUPON_DRP3, 1);
break;
}
} else if (isMonsterCard(sourceid)) {
} else if (ItemId.isMonsterCard(sourceid)) {
int prob = 0, itemupCode = Integer.MAX_VALUE;
List<Pair<Integer, Integer>> areas = null;
boolean inParty = false;
@@ -370,7 +371,7 @@ public class StatEffect {
}
ret.cardStats = new CardItemupStats(itemupCode, prob, areas, inParty);
} else if (isExpIncrease(sourceid)) {
} else if (ItemId.isExpIncrease(sourceid)) {
addBuffStatPairToListIfNotZero(statups, BuffStat.EXP_INCREASE, DataTool.getInt("expinc", source, 0));
}
} else {
@@ -908,7 +909,7 @@ public class StatEffect {
Portal pt;
if (moveTo == 999999999) {
if (sourceid != 2030100) {
if (sourceid != ItemId.ANTI_BANISH_SCROLL) {
target = applyto.getMap().getReturnMap();
pt = target.getRandomPlayerSpawnpoint();
} else {
@@ -1012,7 +1013,7 @@ public class StatEffect {
door.getTarget().spawnDoor(door.getAreaDoor());
door.getTown().spawnDoor(door.getTownDoor());
} else {
InventoryManipulator.addFromDrop(applyto.getClient(), new Item(4006000, (short) 0, (short) 1), false);
InventoryManipulator.addFromDrop(applyto.getClient(), new Item(ItemId.MAGIC_ROCK, (short) 0, (short) 1), false);
if (door.getOwnerId() == -3) {
applyto.dropMessage(5, "Mystic Door cannot be cast far from a spawn point. Nearest one is at " + door.getDoorStatus().getRight() + "pts " + door.getDoorStatus().getLeft());
@@ -1229,7 +1230,7 @@ public class StatEffect {
}
if (sourceid == Corsair.BATTLE_SHIP) {
ridingMountId = 1932000;
ridingMountId = ItemId.BATTLESHIP;
} else if (sourceid == Beginner.SPACESHIP || sourceid == Noblesse.SPACESHIP) {
ridingMountId = 1932000 + applyto.getSkillLevel(sourceid);
} else if (sourceid == Beginner.YETI_MOUNT1 || sourceid == Noblesse.YETI_MOUNT1 || sourceid == Legend.YETI_MOUNT1) {
@@ -1523,38 +1524,12 @@ public class StatEffect {
return sourceid == Beginner.MAP_CHAIR || sourceid == Noblesse.MAP_CHAIR || sourceid == Legend.MAP_CHAIR;
}
public boolean isDojoBuff() {
return sourceid >= 2022359 && sourceid <= 2022421;
}
public static boolean isDojoBuff(int sourceid) {
return sourceid >= 2022359 && sourceid <= 2022421;
}
public static boolean isHpMpRecovery(int sourceid) {
return sourceid == 2022198 || sourceid == 2022337;
}
public static boolean isPyramidBuff(int sourceid) {
return sourceid >= 2022585 && sourceid <= 2022617;
}
public static boolean isRateCoupon(int sourceid) {
int itemType = sourceid / 1000;
return itemType == 5211 || itemType == 5360;
}
public static boolean isExpIncrease(int sourceid) {
return sourceid >= 2022450 && sourceid <= 2022452;
return sourceid == ItemId.RUSSELLONS_PILLS || sourceid == ItemId.SORCERERS_POTION;
}
public static boolean isAriantShield(int sourceid) {
return sourceid == 2022269;
}
public static boolean isMonsterCard(int sourceid) {
int itemType = sourceid / 10000;
return itemType == 238;
return sourceid == ItemId.ARPQ_SHIELD;
}
private boolean isDs() {
@@ -1586,7 +1561,7 @@ public class StatEffect {
}
private boolean isCouponBuff() {
return isRateCoupon(sourceid);
return ItemId.isRateCoupon(sourceid);
}
private boolean isAriantShield() {
@@ -1649,7 +1624,7 @@ public class StatEffect {
if (skill) {
return isHerosWill(sourceid);
} else {
return sourceid == 2022544;
return sourceid == ItemId.WHITE_ELIXIR;
}
}

View File

@@ -1,5 +1,7 @@
package server.gachapon;
import constants.id.ItemId;
/**
* @author Alan (SharpAceX)
* @author Ronan - added ores and reworked global loots
@@ -15,7 +17,7 @@ public class Global extends GachaponItems {
/* Ores */
4004000, 4004001, 4004002, 4004003, 4004004,
4006000, 4006001,
ItemId.MAGIC_ROCK, 4006001,
4010000, 4010001, 4010002, 4010003, 4010004, 4010005, 4010006, 4010007,
4020000, 4020001, 4020002, 4020003, 4020004, 4020005, 4020006, 4020007, 4020008
};

View File

@@ -1,5 +1,7 @@
package server.gachapon;
import constants.id.ItemId;
/**
* @author Ronan - parsed MapleSEA loots
* <p>
@@ -16,7 +18,7 @@ public class Ludibrium extends GachaponItems {
2048000, 2040601, 2041019, 2041007, 2041016, 2041022, 2041001, 2041010, 2041013, 2041004, 2044701, 2043301, 2040301, 2048004, 2048001, 2040901, 2040701, 2040704, 2040707, 2040602, 2041020, 2041008, 2041017, 2041023, 2041002, 2041011, 2041014, 2041005, 2044702, 2043302, 2040302, 2040002, 2044402, 2048005, 2048002, 2040702, 2040705, 2040708, 2044302, 2043802, 2040402, 2043702, 2044811,
/* Useable drop */
2000004, 2000005, 4006000, 4006001,
2000004, 2000005, ItemId.MAGIC_ROCK, 4006001,
/* Common equipment */
1032003, 1432009, 1302022, 1302029, 1102014, 1102018, 1312014, 1302026, 1102015, 1032011, 1312013, 1032008, 1032019, 1032007, 1332030, 1032020, 1032004, 1302027, 1032022, 1312012, 1032021, 1032006, 1302028, 1322003, 1032016, 1032015, 1302024, 1092008, 1032018, 1302021, 1032014, 1332021, 1322012, 1032005, 1032013, 1102012, 1302025, 1302013, 1032002, 1032001, 1032012, 1302017, 1032010, 1402014, 1102017, 1102013, 1442021, 1032009,

View File

@@ -19,6 +19,7 @@
*/
package server.life;
import constants.id.ItemId;
import net.server.Server;
import provider.Data;
import provider.DataProvider;
@@ -114,12 +115,12 @@ public class PlayerNPCFactory {
int FH = 4, RX0 = -143, RX1 = -243, CX = -193, CY = 117, scriptId = 9977777;
Map<Short, Integer> equips = new HashMap<>();
equips.put((short) -1, 1002067);
equips.put((short) -11, 1402046);
equips.put((short) -8, 1082140);
equips.put((short) -6, 1060091);
equips.put((short) -7, 1072154);
equips.put((short) -5, 1040103);
equips.put((short) -1, ItemId.GREEN_HEADBAND);
equips.put((short) -11, ItemId.TIMELESS_NIBLEHEIM);
equips.put((short) -8, ItemId.BLUE_KORBEN);
equips.put((short) -6, ItemId.MITHRIL_PLATINE_PANTS);
equips.put((short) -7, ItemId.BLUE_CARZEN_BOOTS);
equips.put((short) -5, ItemId.MITHRIL_PLATINE);
List<PlayerNPC> dnpcSet = dnpcMaps.get(mapid);
if (dnpcSet == null) {

View File

@@ -3,6 +3,7 @@ package server.minigame;
import client.Client;
import client.inventory.Item;
import client.inventory.manipulator.InventoryManipulator;
import constants.id.ItemId;
import tools.PacketCreator;
import tools.Randomizer;
@@ -71,7 +72,7 @@ public class RockPaperScissor {
public final void reward(final Client c) {
if (win) {
InventoryManipulator.addFromDrop(c, new Item(4031332 + round, (short) 0, (short) 1), true);
InventoryManipulator.addFromDrop(c, new Item(ItemId.RPS_CERTIFICATE_BASE + round, (short) 0, (short) 1), true);
}
c.getPlayer().setRPS(null);
}

View File

@@ -21,6 +21,7 @@ package server.partyquest;
import client.Character;
import constants.game.GameConstants;
import constants.id.ItemId;
import server.TimerManager;
import server.expeditions.Expedition;
import server.expeditions.ExpeditionType;
@@ -180,8 +181,8 @@ public class AriantColiseum {
}
chr.setAriantColiseum(null);
int shards = chr.countItem(4031868);
chr.getAbstractPlayerInteraction().removeAll(4031868);
int shards = chr.countItem(ItemId.ARPQ_SPIRIT_JEWEL);
chr.getAbstractPlayerInteraction().removeAll(ItemId.ARPQ_SPIRIT_JEWEL);
chr.updateAriantScore(shards);
}
}
@@ -241,7 +242,7 @@ public class AriantColiseum {
}
runnerups.remove(firstTop);
if (isUnfairMatch(firstTop, secondTop, map.getDroppedItemsCountById(4031868) + lostShards, runnerups)) {
if (isUnfairMatch(firstTop, secondTop, map.getDroppedItemsCountById(ItemId.ARPQ_SPIRIT_JEWEL) + lostShards, runnerups)) {
rewardTier.put(winner, 1);
}
}

View File

@@ -23,6 +23,7 @@
package server.partyquest;
import client.Character;
import constants.id.ItemId;
import net.server.world.Party;
import server.ItemInformationProvider;
import server.TimerManager;
@@ -186,7 +187,7 @@ public class Pyramid extends PartyQuest {
buffcount++;
ItemInformationProvider ii = ItemInformationProvider.getInstance();
for (Character chr : getParticipants()) {
ii.getItemEffect(2022585).applyTo(chr);
ii.getItemEffect(ItemId.PHARAOHS_BLESSING_1).applyTo(chr);
}
} else if (buffcount == 1 && total >= 500) {
@@ -195,7 +196,7 @@ public class Pyramid extends PartyQuest {
ItemInformationProvider ii = ItemInformationProvider.getInstance();
for (Character chr : getParticipants()) {
chr.sendPacket(PacketCreator.getEnergy("massacre_skill", skill));
ii.getItemEffect(2022586).applyTo(chr);
ii.getItemEffect(ItemId.PHARAOHS_BLESSING_2).applyTo(chr);
}
} else if (buffcount == 2 && total >= 1000) {
buffcount++;
@@ -203,7 +204,7 @@ public class Pyramid extends PartyQuest {
ItemInformationProvider ii = ItemInformationProvider.getInstance();
for (Character chr : getParticipants()) {
chr.sendPacket(PacketCreator.getEnergy("massacre_skill", skill));
ii.getItemEffect(2022587).applyTo(chr);
ii.getItemEffect(ItemId.PHARAOHS_BLESSING_3).applyTo(chr);
}
} else if (buffcount == 3 && total >= 1500) {
skill++;
@@ -214,7 +215,7 @@ public class Pyramid extends PartyQuest {
ItemInformationProvider ii = ItemInformationProvider.getInstance();
for (Character chr : getParticipants()) {
chr.sendPacket(PacketCreator.getEnergy("massacre_skill", skill));
ii.getItemEffect(2022588).applyTo(chr);
ii.getItemEffect(ItemId.PHARAOHS_BLESSING_4).applyTo(chr);
}
} else if (buffcount == 5 && total >= 2500) {
skill++;