Fixed Horntail command + minor EXP gain issue fix
Now Horntail can be spawned properly by a command. Fixed a rase case where an extremely high value of EXP gain would cause integer overflow, potentially crashing one's client.
This commit is contained in:
@@ -210,6 +210,7 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
int trueDamage = Math.min(hp, damage); // since magic happens otherwise B^)
|
||||
|
||||
if(ServerConstants.USE_DEBUG == true && from != null) from.dropMessage(5, "Hitted MOB " + this.getId());
|
||||
dispatchMonsterDamaged(from, trueDamage);
|
||||
|
||||
hp -= damage;
|
||||
if (takenDamage.containsKey(from.getId())) {
|
||||
@@ -368,16 +369,14 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
personalExp *= (stati.get(MonsterStatus.SHOWDOWN).getStati().get(MonsterStatus.SHOWDOWN).doubleValue() / 100.0 + 1.0);
|
||||
}
|
||||
}
|
||||
if (exp < 0) {//O.O ><
|
||||
personalExp = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
attacker.gainExp(personalExp, partyExp, true, false, isKiller);
|
||||
attacker.mobKilled(getId());
|
||||
attacker.increaseEquipExp(personalExp);//better place
|
||||
}
|
||||
}
|
||||
|
||||
public MapleCharacter killBy(MapleCharacter killer) {
|
||||
public MapleCharacter killBy(final MapleCharacter killer) {
|
||||
distributeExperience(killer != null ? killer.getId() : 0);
|
||||
|
||||
if (getController() != null) { // this can/should only happen when a hidden gm attacks the monster
|
||||
@@ -424,11 +423,16 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
mob.disableDrops();
|
||||
}
|
||||
reviveMap.spawnMonster(mob);
|
||||
|
||||
if(mob.getId() >= 8810010 && mob.getId() <= 8810017 && reviveMap.isHorntailDefeated()) {
|
||||
for(int i = 8810018; i >= 8810010; i--)
|
||||
reviveMap.killMonster(reviveMap.getMonsterById(i), killer, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, getAnimationTime("die1"));
|
||||
}
|
||||
else {
|
||||
else { // is this even necessary?
|
||||
System.out.println("[CRITICAL LOSS] toSpawn is null for " + this.getName());
|
||||
}
|
||||
|
||||
@@ -447,6 +451,12 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
listener.monsterKilled(getAnimationTime("die1"));
|
||||
}
|
||||
}
|
||||
|
||||
public void dispatchMonsterDamaged(MapleCharacter from, int trueDmg) {
|
||||
for (MonsterListener listener : listeners.toArray(new MonsterListener[listeners.size()])) {
|
||||
listener.monsterDamaged(from, trueDmg);
|
||||
}
|
||||
}
|
||||
|
||||
// should only really be used to determine drop owner
|
||||
private int getHighestDamagerId() {
|
||||
@@ -992,7 +1002,7 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
return(1.0f);
|
||||
}
|
||||
|
||||
private final void changeLevelByDifficulty(final int difficulty, boolean pqMob) {
|
||||
private void changeLevelByDifficulty(final int difficulty, boolean pqMob) {
|
||||
changeLevel((int)(this.getLevel() * getDifficultyRate(difficulty)), pqMob);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package server.life;
|
||||
import client.MapleCharacter;
|
||||
|
||||
public interface MonsterListener {
|
||||
|
||||
public void monsterKilled(int aniTime);
|
||||
public void monsterDamaged(MapleCharacter from, int trueDmg);
|
||||
}
|
||||
|
||||
@@ -91,6 +91,9 @@ public class SpawnPoint {
|
||||
}
|
||||
spawnedMonsters.decrementAndGet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void monsterDamaged(MapleCharacter from, int trueDmg) {}
|
||||
});
|
||||
if (mobTime == 0) {
|
||||
nextPossibleSpawn = System.currentTimeMillis() + mobInterval;
|
||||
|
||||
@@ -77,6 +77,7 @@ import server.partyquest.MonsterCarnival;
|
||||
import server.partyquest.MonsterCarnivalParty;
|
||||
import server.partyquest.Pyramid;
|
||||
import scripting.event.EventInstanceManager;
|
||||
import server.life.MonsterListener;
|
||||
import tools.FilePrinter;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.Pair;
|
||||
@@ -611,7 +612,7 @@ public class MapleMap {
|
||||
}
|
||||
if (monster.getStats().selfDestruction() != null && monster.getStats().selfDestruction().getHp() > -1) {// should work ;p
|
||||
if (monster.getHp() <= monster.getStats().selfDestruction().getHp()) {
|
||||
killMonster(monster, chr, true, false, monster.getStats().selfDestruction().getAction());
|
||||
killMonster(monster, chr, true, monster.getStats().selfDestruction().getAction());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -632,20 +633,12 @@ public class MapleMap {
|
||||
}
|
||||
|
||||
public void killMonster(final MapleMonster monster, final MapleCharacter chr, final boolean withDrops) {
|
||||
killMonster(monster, chr, withDrops, false, 1);
|
||||
killMonster(monster, chr, withDrops, 1);
|
||||
}
|
||||
|
||||
public void killMonster(final MapleMonster monster, final MapleCharacter chr, final boolean withDrops, final boolean secondTime, int animation) {
|
||||
if (monster.getId() == 8810018 && !secondTime) {
|
||||
TimerManager.getInstance().schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
killMonster(monster, chr, withDrops, true, 1);
|
||||
killAllMonsters();
|
||||
}
|
||||
}, 3000);
|
||||
return;
|
||||
}
|
||||
public void killMonster(final MapleMonster monster, final MapleCharacter chr, final boolean withDrops, int animation) {
|
||||
if(monster == null) return;
|
||||
|
||||
if (chr == null) {
|
||||
spawnedMonstersOnMap.decrementAndGet();
|
||||
monster.setHp(0);
|
||||
@@ -780,7 +773,7 @@ public class MapleMap {
|
||||
continue;
|
||||
}
|
||||
|
||||
killMonster(monster, null, false, false, 1);
|
||||
killMonster(monster, null, false, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -792,7 +785,7 @@ public class MapleMap {
|
||||
for (MapleMapObject monstermo : getMapObjectsInRange(new Point(0, 0), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.MONSTER))) {
|
||||
MapleMonster monster = (MapleMonster) monstermo;
|
||||
|
||||
killMonster(monster, null, false, false, 1);
|
||||
killMonster(monster, null, false, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1174,7 +1167,7 @@ public class MapleMap {
|
||||
TimerManager.getInstance().schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
killMonster(monster, null, false, false, selfDestruction.getAction());
|
||||
killMonster(monster, null, false, selfDestruction.getAction());
|
||||
}
|
||||
}, selfDestruction.removeAfter() * 1000);
|
||||
}
|
||||
@@ -2666,4 +2659,40 @@ public class MapleMap {
|
||||
public boolean isDojoMap() {
|
||||
return mapid >= 925020000 && mapid < 925040000;
|
||||
}
|
||||
|
||||
public boolean isHorntailDefeated() { // all parts of dead horntail can be found here?
|
||||
for(int i = 8810010; i <= 8810017; i++) {
|
||||
if(getMonsterById(i) == null) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void spawnHorntailOnGroundBelow(final Point targetPoint) { // ayy lmao
|
||||
spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8810026), targetPoint);
|
||||
TimerManager.getInstance().schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (int x = 8810002; x <= 8810009; x++) {
|
||||
spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(x), targetPoint);
|
||||
}
|
||||
|
||||
spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8810018), targetPoint);
|
||||
|
||||
final MapleMonster ht = getMonsterById(8810018);
|
||||
for(int mobId = 8810002; mobId <= 8810009; mobId++) {
|
||||
getMonsterById(mobId).addListener(new MonsterListener() {
|
||||
@Override
|
||||
public void monsterKilled(int aniTime) {}
|
||||
|
||||
@Override
|
||||
public void monsterDamaged(MapleCharacter from, int trueDmg) {
|
||||
ht.damage(from, trueDmg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}, 5 * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user