Turn mob id magic numbers into constants

This commit is contained in:
P0nk
2021-11-07 12:15:36 +01:00
parent 4efd356cbf
commit 8d10e3d1b0
18 changed files with 205 additions and 90 deletions

View File

@@ -23,6 +23,7 @@
package server.expeditions;
import client.Character;
import constants.id.MobId;
import net.packet.Packet;
import net.server.PlayerStorage;
import net.server.Server;
@@ -51,35 +52,35 @@ import static java.util.concurrent.TimeUnit.MINUTES;
public class Expedition {
private static final int[] EXPEDITION_BOSSES = {
8800000,// - Zakum's first body
8800001,// - Zakum's second body
8800002,// - Zakum's third body
8800003,// - Zakum's Arm 1
8800004,// - Zakum's Arm 2
8800005,// - Zakum's Arm 3
8800006,// - Zakum's Arm 4
8800007,// - Zakum's Arm 5
8800008,// - Zakum's Arm 6
8800009,// - Zakum's Arm 7
8800010,// - Zakum's Arm 8
8810000,// - Horntail's Left Head
8810001,// - Horntail's Right Head
8810002,// - Horntail's Head A
8810003,// - Horntail's Head B
8810004,// - Horntail's Head C
8810005,// - Horntail's Left Hand
8810006,// - Horntail's Right Hand
8810007,// - Horntail's Wings
8810008,// - Horntail's Legs
8810009,// - Horntail's Tails
9420546,// - Scarlion Boss
9420547,// - Scarlion Boss
9420548,// - Angry Scarlion Boss
9420549,// - Furious Scarlion Boss
9420541,// - Targa
9420542,// - Targa
9420543,// - Angry Targa
9420544,// - Furious Targa
MobId.ZAKUM_1,
MobId.ZAKUM_2,
MobId.ZAKUM_3,
MobId.ZAKUM_ARM_1,
MobId.ZAKUM_ARM_2,
MobId.ZAKUM_ARM_3,
MobId.ZAKUM_ARM_4,
MobId.ZAKUM_ARM_5,
MobId.ZAKUM_ARM_6,
MobId.ZAKUM_ARM_7,
MobId.ZAKUM_ARM_8,
MobId.HORNTAIL_PREHEAD_LEFT,
MobId.HORNTAIL_PREHEAD_RIGHT,
MobId.HORNTAIL_HEAD_A,
MobId.HORNTAIL_HEAD_B,
MobId.HORNTAIL_HEAD_C,
MobId.HORNTAIL_HAND_LEFT,
MobId.HORNTAIL_HAND_RIGHT,
MobId.HORNTAIL_WINGS,
MobId.HORNTAIL_LEGS,
MobId.HORNTAIL_TAIL,
MobId.SCARLION_STATUE,
MobId.SCARLION,
MobId.ANGRY_SCARLION,
MobId.FURIOUS_SCARLION,
MobId.TARGA_STATUE,
MobId.TARGA,
MobId.ANGRY_TARGA,
MobId.FURIOUS_TARGA,
};
private final Character leader;

View File

@@ -25,6 +25,7 @@ import client.Character;
import client.Disease;
import client.status.MonsterStatus;
import constants.game.GameConstants;
import constants.id.MobId;
import net.server.services.task.channel.OverallService;
import net.server.services.type.ChannelServices;
import server.maps.MapObject;
@@ -265,17 +266,17 @@ public class MobSkill {
xpos = (int) monster.getPosition().getX();
ypos = (int) monster.getPosition().getY();
switch (mobId) {
case 8500003: // Pap bomb high
case MobId.HIGH_DARKSTAR: // Pap bomb high
toSpawn.setFh((int) Math.ceil(Math.random() * 19.0));
ypos = -590;
break;
case 8500004: // Pap bomb
case MobId.LOW_DARKSTAR: // Pap bomb
xpos = (int) (monster.getPosition().getX() + Randomizer.nextInt(1000) - 500);
if (ypos != -590) {
ypos = (int) monster.getPosition().getY();
}
break;
case 8510100: //Pianus bomb
case MobId.BLOODY_BOOM: //Pianus bomb
if (Math.ceil(Math.random() * 5) == 1) {
ypos = 78;
xpos = Randomizer.nextInt(5) + (Randomizer.nextInt(2) == 1 ? 180 : 0);
@@ -301,7 +302,7 @@ public class MobSkill {
break;
}
toSpawn.setPosition(new Point(xpos, ypos));
if (toSpawn.getId() == 8500004) {
if (toSpawn.getId() == MobId.LOW_DARKSTAR) {
map.spawnFakeMonster(toSpawn);
} else {
map.spawnMonsterWithEffect(toSpawn, getSpawnEffect(), toSpawn.getPosition());

View File

@@ -26,6 +26,7 @@ import client.*;
import client.status.MonsterStatus;
import client.status.MonsterStatusEffect;
import config.YamlConfig;
import constants.id.MobId;
import constants.skills.*;
import net.packet.Packet;
import net.server.audit.LockCollector;
@@ -761,7 +762,7 @@ public class Monster extends AbstractLoadedLife {
final List<Integer> toSpawn = this.getRevives();
if (toSpawn != null) {
final MapleMap reviveMap = map;
if (toSpawn.contains(9300216) && reviveMap.getId() > 925000000 && reviveMap.getId() < 926000000) {
if (toSpawn.contains(MobId.TRANSPARENT_ITEM) && reviveMap.getId() > 925000000 && reviveMap.getId() < 926000000) {
reviveMap.broadcastMessage(PacketCreator.playSound("Dojang/clear"));
reviveMap.broadcastMessage(PacketCreator.showEffect("dojang/end/clear"));
}
@@ -790,9 +791,9 @@ public class Monster extends AbstractLoadedLife {
}
reviveMap.spawnMonster(mob);
if (mob.getId() >= 8810010 && mob.getId() <= 8810017 && reviveMap.isHorntailDefeated()) {
if (MobId.isDeadHorntailPart(mob.getId()) && reviveMap.isHorntailDefeated()) {
boolean htKilled = false;
Monster ht = reviveMap.getMonsterById(8810018);
Monster ht = reviveMap.getMonsterById(MobId.HORNTAIL);
if (ht != null) {
ht.lockMonster();
@@ -808,7 +809,7 @@ public class Monster extends AbstractLoadedLife {
}
}
for (int i = 8810017; i >= 8810010; i--) {
for (int i = MobId.DEAD_HORNTAIL_MAX; i >= MobId.DEAD_HORNTAIL_MIN; i--) {
reviveMap.killMonster(reviveMap.getMonsterById(i), killer, true);
}
} else if (controller != null) {

View File

@@ -33,6 +33,7 @@ import client.status.MonsterStatus;
import client.status.MonsterStatusEffect;
import config.YamlConfig;
import constants.game.GameConstants;
import constants.id.MobId;
import constants.inventory.ItemConstants;
import net.packet.Packet;
import net.server.Server;
@@ -1301,11 +1302,11 @@ public class MapleMap {
}
public boolean damageMonster(final Character chr, final Monster monster, final int damage) {
if (monster.getId() == 8800000) {
if (monster.getId() == MobId.ZAKUM_1) {
for (MapObject object : chr.getMap().getMapObjects()) {
Monster mons = chr.getMap().getMonsterByOid(object.getObjectId());
if (mons != null) {
if (mons.getId() >= 8800003 && mons.getId() <= 8800010) {
if (mons.getId() >= MobId.ZAKUM_ARM_1 && mons.getId() <= MobId.ZAKUM_ARM_8) {
return true;
}
}
@@ -1412,13 +1413,13 @@ public class MapleMap {
}
}
if (monster.getId() >= 8800003 && monster.getId() <= 8800010) {
if (MobId.isZakumArm(monster.getId())) {
boolean makeZakReal = true;
Collection<MapObject> objects = getMapObjects();
for (MapObject object : objects) {
Monster mons = getMonsterByOid(object.getObjectId());
if (mons != null) {
if (mons.getId() >= 8800003 && mons.getId() <= 8800010) {
if (MobId.isZakumArm(mons.getId())) {
makeZakReal = false;
break;
}
@@ -1430,7 +1431,7 @@ public class MapleMap {
for (MapObject object : objects) {
Monster mons = map.getMonsterByOid(object.getObjectId());
if (mons != null) {
if (mons.getId() == 8800000) {
if (mons.getId() == MobId.ZAKUM_1) {
makeMonsterReal(mons);
break;
}
@@ -1974,13 +1975,13 @@ public class MapleMap {
}
if (monster.getDropPeriodTime() > 0) { //9300102 - Watchhog, 9300061 - Moon Bunny (HPQ), 9300093 - Tylus
if (monster.getId() == 9300102) {
if (monster.getId() == MobId.WATCH_HOG) {
monsterItemDrop(monster, monster.getDropPeriodTime());
} else if (monster.getId() == 9300061) {
} else if (monster.getId() == MobId.MOON_BUNNY) {
monsterItemDrop(monster, monster.getDropPeriodTime() / 3);
} else if (monster.getId() == 9300093) {
} else if (monster.getId() == MobId.TYLUS) {
monsterItemDrop(monster, monster.getDropPeriodTime());
} else if (monster.getId() == 9400326 || monster.getId() == 9400331 || monster.getId() == 9400336) {
} else if (monster.getId() == MobId.GIANT_SNOWMAN_LV5_EASY || monster.getId() == MobId.GIANT_SNOWMAN_LV5_MEDIUM || monster.getId() == MobId.GIANT_SNOWMAN_LV5_HARD) {
monsterItemDrop(monster, monster.getDropPeriodTime());
} else {
FilePrinter.printError(FilePrinter.UNHANDLED_EVENT, "UNCODED TIMED MOB DETECTED: " + monster.getId());
@@ -4033,7 +4034,7 @@ public class MapleMap {
}
public boolean isHorntailDefeated() { // all parts of dead horntail can be found here?
for (int i = 8810010; i <= 8810017; i++) {
for (int i = MobId.DEAD_HORNTAIL_MIN; i <= MobId.DEAD_HORNTAIL_MAX; i++) {
if (getMonsterById(i) == null) {
return false;
}
@@ -4043,10 +4044,10 @@ public class MapleMap {
}
public void spawnHorntailOnGroundBelow(final Point targetPoint) { // ayy lmao
Monster htIntro = LifeFactory.getMonster(8810026);
Monster htIntro = LifeFactory.getMonster(MobId.SUMMON_HORNTAIL);
spawnMonsterOnGroundBelow(htIntro, targetPoint); // htintro spawn animation converting into horntail detected thanks to Arnah
final Monster ht = LifeFactory.getMonster(8810018);
final Monster ht = LifeFactory.getMonster(MobId.HORNTAIL);
ht.setParentMobOid(htIntro.getObjectId());
ht.addListener(new MonsterListener() {
@Override
@@ -4064,8 +4065,8 @@ public class MapleMap {
});
spawnMonsterOnGroundBelow(ht, targetPoint);
for (int x = 8810002; x <= 8810009; x++) {
Monster m = LifeFactory.getMonster(x);
for (int mobId = MobId.HORNTAIL_HEAD_A; mobId <= MobId.HORNTAIL_TAIL; mobId++) {
Monster m = LifeFactory.getMonster(mobId);
m.setParentMobOid(htIntro.getObjectId());
m.addListener(new MonsterListener() {