use of server.life.MapleMonster in project HeavenMS by ronancpl.
the class AdminCommandHandler method handlePacket.
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
if (!c.getPlayer().isGM()) {
return;
}
byte mode = slea.readByte();
String victim;
MapleCharacter target;
switch(mode) {
case // Level1~Level8 & Package1~Package2
0x00:
int[][] toSpawn = MapleItemInformationProvider.getInstance().getSummonMobs(slea.readInt());
for (int z = 0; z < toSpawn.length; z++) {
int[] toSpawnChild = toSpawn[z];
if (Randomizer.nextInt(101) <= toSpawnChild[1]) {
c.getPlayer().getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(toSpawnChild[0]), c.getPlayer().getPosition());
}
}
c.announce(MaplePacketCreator.enableActions());
break;
case 0x01:
{
// /d (inv)
byte type = slea.readByte();
MapleInventory in = c.getPlayer().getInventory(MapleInventoryType.getByType(type));
for (short i = 1; i <= in.getSlotLimit(); i++) {
// TODO What is the point of this loop?
if (in.getItem(i) != null) {
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.getByType(type), i, in.getItem(i).getQuantity(), false);
}
return;
}
break;
}
case // Exp
0x02:
c.getPlayer().setExp(slea.readInt());
break;
case // /ban <name>
0x03:
c.getPlayer().yellowMessage("Please use !ban <IGN> <Reason>");
break;
case // /block <name> <duration (in days)> <HACK/BOT/AD/HARASS/CURSE/SCAM/MISCONDUCT/SELL/ICASH/TEMP/GM/IPROGRAM/MEGAPHONE>
0x04:
victim = slea.readMapleAsciiString();
// reason
int type = slea.readByte();
int duration = slea.readInt();
String description = slea.readMapleAsciiString();
String reason = c.getPlayer().getName() + " used /ban to ban";
target = c.getChannelServer().getPlayerStorage().getCharacterByName(victim);
if (target != null) {
String readableTargetName = MapleCharacter.makeMapleReadable(target.getName());
String ip = target.getClient().getSession().getRemoteAddress().toString().split(":")[0];
reason += readableTargetName + " (IP: " + ip + ")";
if (duration == -1) {
target.ban(description + " " + reason);
} else {
target.block(type, duration, description);
target.sendPolice(duration, reason, 6000);
}
c.announce(MaplePacketCreator.getGMEffect(4, (byte) 0));
} else if (MapleCharacter.ban(victim, reason, false)) {
c.announce(MaplePacketCreator.getGMEffect(4, (byte) 0));
} else {
c.announce(MaplePacketCreator.getGMEffect(6, (byte) 1));
}
break;
case // /h, information by vana (and tele mode f1) ... hide ofcourse
0x10:
c.getPlayer().Hide(slea.readByte() == 1);
break;
case // Entering a map
0x11:
switch(slea.readByte()) {
case // /u
0:
StringBuilder sb = new StringBuilder("USERS ON THIS MAP: ");
for (MapleCharacter mc : c.getPlayer().getMap().getCharacters()) {
sb.append(mc.getName());
sb.append(" ");
}
c.getPlayer().message(sb.toString());
break;
case // /uclip and entering a map
12:
break;
}
break;
case // Send
0x12:
victim = slea.readMapleAsciiString();
int mapId = slea.readInt();
c.getChannelServer().getPlayerStorage().getCharacterByName(victim).changeMap(c.getChannelServer().getMapFactory().getMap(mapId));
break;
case // Kill
0x15:
int mobToKill = slea.readInt();
int amount = slea.readInt();
List<MapleMapObject> monsterx = c.getPlayer().getMap().getMapObjectsInRange(c.getPlayer().getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.MONSTER));
for (int x = 0; x < amount; x++) {
MapleMonster monster = (MapleMonster) monsterx.get(x);
if (monster.getId() == mobToKill) {
c.getPlayer().getMap().killMonster(monster, c.getPlayer(), true);
monster.giveExpToCharacter(c.getPlayer(), monster.getExp(), true, 1);
}
}
break;
case // Questreset
0x16:
MapleQuest.getInstance(slea.readShort()).reset(c.getPlayer());
break;
case // Summon
0x17:
int mobId = slea.readInt();
int quantity = slea.readInt();
for (int i = 0; i < quantity; i++) {
c.getPlayer().getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), c.getPlayer().getPosition());
}
break;
case // Maple & Mobhp
0x18:
int mobHp = slea.readInt();
c.getPlayer().dropMessage("Monsters HP");
List<MapleMapObject> monsters = c.getPlayer().getMap().getMapObjectsInRange(c.getPlayer().getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.MONSTER));
for (MapleMapObject mobs : monsters) {
MapleMonster monster = (MapleMonster) mobs;
if (monster.getId() == mobHp) {
c.getPlayer().dropMessage(monster.getName() + ": " + monster.getHp());
}
}
break;
case // Warn
0x1E:
victim = slea.readMapleAsciiString();
String message = slea.readMapleAsciiString();
target = c.getChannelServer().getPlayerStorage().getCharacterByName(victim);
if (target != null) {
target.getClient().announce(MaplePacketCreator.serverNotice(1, message));
c.announce(MaplePacketCreator.getGMEffect(0x1E, (byte) 1));
} else {
c.announce(MaplePacketCreator.getGMEffect(0x1E, (byte) 0));
}
break;
case // /Artifact Ranking
0x24:
break;
case // Testing purpose
0x77:
if (slea.available() == 4) {
System.out.println(slea.readInt());
} else if (slea.available() == 2) {
System.out.println(slea.readShort());
}
break;
default:
System.out.println("New GM packet encountered (MODE : " + mode + ": " + slea.toString());
break;
}
}
use of server.life.MapleMonster in project HeavenMS by ronancpl.
the class AutoAggroHandler method handlePacket.
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
if (c.getPlayer().isHidden())
// Don't auto aggro GM's in hide...
return;
MapleMap map = c.getPlayer().getMap();
int oid = slea.readInt();
MapleMonster monster = map.getMonsterByOid(oid);
if (monster != null && monster.getController() != null) {
if (!monster.isControllerHasAggro()) {
if (map.getCharacterById(monster.getController().getId()) == null) {
monster.switchController(c.getPlayer(), true);
} else {
monster.switchController(monster.getController(), true);
}
} else if (map.getCharacterById(monster.getController().getId()) == null) {
monster.switchController(c.getPlayer(), true);
}
} else if (monster != null && monster.getController() == null) {
monster.switchController(c.getPlayer(), true);
}
}
use of server.life.MapleMonster in project HeavenMS by ronancpl.
the class MonsterBombHandler method handlePacket.
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
int oid = slea.readInt();
MapleMonster monster = c.getPlayer().getMap().getMonsterByOid(oid);
if (!c.getPlayer().isAlive() || monster == null) {
return;
}
if (monster.getId() == 8500003 || monster.getId() == 8500004) {
monster.getMap().broadcastMessage(MaplePacketCreator.killMonster(monster.getObjectId(), 4));
c.getPlayer().getMap().removeMapObject(oid);
}
}
use of server.life.MapleMonster in project HeavenMS by ronancpl.
the class SpecialMoveHandler method handlePacket.
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
MapleCharacter chr = c.getPlayer();
chr.getAutobanManager().setTimestamp(4, slea.readInt(), 3);
int skillid = slea.readInt();
/*
if ((!GameConstants.isPqSkillMap(chr.getMapId()) && GameConstants.isPqSkill(skillid)) || (!chr.isGM() && GameConstants.isGMSkills(skillid)) || (!GameConstants.isInJobTree(skillid, chr.getJob().getId()) && !chr.isGM())) {
AutobanFactory.PACKET_EDIT.alert(chr, chr.getName() + " tried to packet edit skills.");
FilePrinter.printError(FilePrinter.EXPLOITS + chr.getName() + ".txt", chr.getName() + " tried to use skill " + skillid + " without it being in their job.\r\n");
c.disconnect(true, false);
return;
}
*/
Point pos = null;
int __skillLevel = slea.readByte();
Skill skill = SkillFactory.getSkill(skillid);
int skillLevel = chr.getSkillLevel(skill);
if (skillid % 10000000 == 1010 || skillid % 10000000 == 1011) {
if (chr.getDojoEnergy() < 10000) {
// PE hacking or maybe just lagging
return;
}
skillLevel = 1;
chr.setDojoEnergy(0);
c.announce(MaplePacketCreator.getEnergy("energy", chr.getDojoEnergy()));
c.announce(MaplePacketCreator.serverNotice(5, "As you used the secret skill, your energy bar has been reset."));
}
if (skillLevel == 0 || skillLevel != __skillLevel)
return;
MapleStatEffect effect = skill.getEffect(skillLevel);
if (effect.getCooldown() > 0) {
if (chr.skillIsCooling(skillid)) {
return;
} else if (skillid != Corsair.BATTLE_SHIP) {
c.announce(MaplePacketCreator.skillCooldown(skillid, effect.getCooldown()));
chr.addCooldown(skillid, System.currentTimeMillis(), effect.getCooldown() * 1000);
}
}
if (skillid == Hero.MONSTER_MAGNET || skillid == Paladin.MONSTER_MAGNET || skillid == DarkKnight.MONSTER_MAGNET) {
// Monster Magnet
int num = slea.readInt();
int mobId;
byte success;
for (int i = 0; i < num; i++) {
mobId = slea.readInt();
success = slea.readByte();
chr.getMap().broadcastMessage(chr, MaplePacketCreator.showMagnet(mobId, success), false);
MapleMonster monster = chr.getMap().getMonsterByOid(mobId);
if (monster != null) {
if (!monster.isBoss()) {
monster.switchController(chr, monster.isControllerHasAggro());
}
}
}
byte direction = slea.readByte();
chr.getMap().broadcastMessage(chr, MaplePacketCreator.showBuffeffect(chr.getId(), skillid, chr.getSkillLevel(skillid), direction), false);
c.announce(MaplePacketCreator.enableActions());
return;
} else if (skillid == Brawler.MP_RECOVERY) {
// MP Recovery
Skill s = SkillFactory.getSkill(skillid);
MapleStatEffect ef = s.getEffect(chr.getSkillLevel(s));
int lose = chr.getMaxHp() / ef.getX();
chr.setHp(chr.getHp() - lose);
chr.updateSingleStat(MapleStat.HP, chr.getHp());
int gain = lose * (ef.getY() / 100);
chr.setMp(chr.getMp() + gain);
chr.updateSingleStat(MapleStat.MP, chr.getMp());
} else if (skillid == Priest.DISPEL || skillid == SuperGM.HEAL_PLUS_DISPEL) {
slea.skip((skillid == Priest.DISPEL) ? 10 : 11);
chr.getMap().broadcastMessage(chr, MaplePacketCreator.showBuffeffect(chr.getId(), skillid, chr.getSkillLevel(skillid)), false);
} else if (skillid % 10000000 == 1004) {
slea.readShort();
}
if (slea.available() == 5) {
pos = new Point(slea.readShort(), slea.readShort());
}
if (chr.isAlive()) {
if (skill.getId() != Priest.MYSTIC_DOOR) {
skill.getEffect(skillLevel).applyTo(chr, pos);
} else if (chr.canDoor()) {
// update door lists
chr.cancelMagicDoor();
skill.getEffect(skillLevel).applyTo(chr, pos);
} else {
chr.message("Please wait 5 seconds before casting Mystic Door again.");
c.announce(MaplePacketCreator.enableActions());
}
} else {
c.announce(MaplePacketCreator.enableActions());
}
}
use of server.life.MapleMonster in project HeavenMS by ronancpl.
the class SummonDamageHandler method handlePacket.
@Override
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
int oid = slea.readInt();
MapleCharacter player = c.getPlayer();
if (!player.isAlive()) {
return;
}
MapleSummon summon = null;
for (MapleSummon sum : player.getSummonsValues()) {
if (sum.getObjectId() == oid) {
summon = sum;
}
}
if (summon == null) {
return;
}
Skill summonSkill = SkillFactory.getSkill(summon.getSkill());
MapleStatEffect summonEffect = summonSkill.getEffect(summon.getSkillLevel());
slea.skip(4);
List<SummonAttackEntry> allDamage = new ArrayList<>();
byte direction = slea.readByte();
int numAttacked = slea.readByte();
// Thanks Gerald :D, I failed lol (mob x,y and summon x,y)
slea.skip(8);
for (int x = 0; x < numAttacked; x++) {
// attacked oid
int monsterOid = slea.readInt();
slea.skip(18);
int damage = slea.readInt();
allDamage.add(new SummonAttackEntry(monsterOid, damage));
}
player.getMap().broadcastMessage(player, MaplePacketCreator.summonAttack(player.getId(), summon.getObjectId(), direction, allDamage), summon.getPosition());
for (SummonAttackEntry attackEntry : allDamage) {
int damage = attackEntry.getDamage();
MapleMonster target = player.getMap().getMonsterByOid(attackEntry.getMonsterOid());
if (target != null) {
if (damage > 0 && summonEffect.getMonsterStati().size() > 0) {
if (summonEffect.makeChanceResult()) {
target.applyStatus(player, new MonsterStatusEffect(summonEffect.getMonsterStati(), summonSkill, null, false), summonEffect.isPoison(), 4000);
}
}
player.getMap().damageMonster(player, target, damage);
}
}
}
Aggregations