public void broadcastVoteMsg() { for (ChannelServer lol : ChannelServer.getAllInstances()) { lol.broadcastPacket( MaplePacketCreator.serverNotice( 6, "[Vote Reminder] Please do not forget to vote for us every 12 hrs. There are rewards for voting which you can claim from Charles at henesys. http://ninjams,org/vote")); } }
public final void broadcastPlayerMsg(final int type, final String msg) { mutex.lock(); try { for (final MapleCharacter chr : chars) { chr.getClient().getSession().write(MaplePacketCreator.serverNotice(type, msg)); } } finally { mutex.unlock(); } }
@Override public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) { // damage from map object // 26 00 EB F2 2B 01 FE 25 00 00 00 00 00 // damage from monster // 26 00 0F 60 4C 00 FF 48 01 00 00 B5 89 5D 00 CC CC CC CC 00 00 00 00 /* Damagefrom: -2 = map attack * -1 = walk over monster * 0 = spell * 1 = seems to be a spell too... * * Damage: -1 = none taken? * > 0 = normal damage */ MapleCharacter player = c.getPlayer(); slea.readInt(); int damagefrom = slea.readByte(); slea.readByte(); int damage = slea.readInt(); int oid = 0; int monsteridfrom = 0; int pgmr = 0; int direction = 0; int pos_x = 0; int pos_y = 0; int fake = 0; boolean is_pgmr = false; boolean is_pg = true; int mpattack = 0; MapleMonster attacker = null; if (damagefrom == -2) { int debuffLevel = slea.readByte(); int debuffId = slea.readByte(); if (debuffId == 125) { debuffLevel = debuffLevel - 1; } MobSkill skill = MobSkillFactory.getMobSkill(debuffId, debuffLevel); if (skill != null) { skill.applyEffect(player, attacker, false); } } else { monsteridfrom = slea.readInt(); oid = slea.readInt(); if (monsteridfrom != 0 && damage != -1) { attacker = (MapleMonster) player.getMap().getMapObject(monsteridfrom); } else { attacker = (MapleMonster) player.getMap().getMapObject(oid); } direction = slea.readByte(); } if (damagefrom != -1 && damagefrom != -2 && attacker != null) { MobAttackInfo attackInfo = MobAttackInfoFactory.getMobAttackInfo(attacker, damagefrom); if (damage != -1) { if (attackInfo.isDeadlyAttack()) { mpattack = player.getMp() - 1; } else { mpattack += attackInfo.getMpBurn(); } if (mpattack - player.getMp() < 0) { mpattack = player.getMp(); } } MobSkill skill = MobSkillFactory.getMobSkill(attackInfo.getDiseaseSkill(), attackInfo.getDiseaseLevel()); if (skill != null && damage > 0) { skill.applyEffect(player, attacker, false); } if (attacker != null) { attacker.setMp(attacker.getMp() - attackInfo.getMpCon()); } } try { for (MapleMapObject mmo : player.getMap().getMapObjects()) { if (mmo instanceof MapleMist) { MapleMist mist = (MapleMist) mmo; if (mist.getSourceSkill().getId() == 4221006) { // Smokescreen for (MapleMapObject mmoplayer : player .getMap() .getMapObjectsInRect( mist.getBox(), Collections.singletonList(MapleMapObjectType.PLAYER))) { if (player == (MapleCharacter) mmoplayer) { damage = -1; } } } } } } catch (Exception e) { log.warn("Unable to handle smokescreen...", e); } if (damage == -1) { int job = (int) (player.getJob().getId() / 10 - 40); fake = 4020002 + (job * 100000); if (damagefrom == -1 && damagefrom != -2 && player.getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -10) != null) { int[] guardianSkillId = {1120005, 1220006}; for (int guardian : guardianSkillId) { ISkill guardianSkill = SkillFactory.getSkill(guardian); if (player.getSkillLevel(guardianSkill) > 0 && attacker != null) { MonsterStatusEffect monsterStatusEffect = new MonsterStatusEffect( Collections.singletonMap(MonsterStatus.STUN, 1), guardianSkill, false); attacker.applyStatus(player, monsterStatusEffect, false, 2 * 1000); } } } } if (damage < -1 || damage > 100000) { AutobanManager.getInstance() .autoban(player.getClient(), player.getName() + " took " + damage + " of damage."); } else if (damage > 60000) { log.warn(player.getName() + " receive " + damage + " of abnormal amount of damage."); c.disconnect(); return; } player.getCheatTracker().checkTakeDamage(); if (damage > 0) { player.getCheatTracker().setAttacksWithoutHit(0); player.getCheatTracker().resetHPRegen(); if (!player.isHidden() && player.isAlive()) { if (MapleLifeFactory.getMonster(monsteridfrom) != null) { if (player.getBuffedValue(MapleBuffStat.MORPH) != null) { player.cancelMorphs(); } if (attacker != null && !attacker.isBoss()) { if (damagefrom == -1 && player.getBuffedValue(MapleBuffStat.POWERGUARD) != null) { int bouncedamage = (int) (damage * (player.getBuffedValue(MapleBuffStat.POWERGUARD).doubleValue() / 100)); bouncedamage = Math.min(bouncedamage, attacker.getMaxHp() / 10); player.getMap().damageMonster(player, attacker, bouncedamage); damage -= bouncedamage; player .getMap() .broadcastMessage( player, MaplePacketCreator.damageMonster(oid, bouncedamage), false, true); player.checkMonsterAggro(attacker); } if ((damagefrom == 0 || damagefrom == 1) && player.getBuffedValue(MapleBuffStat.MANA_REFLECTION) != null) { int[] manaReflectSkillId = {2121002, 2221002, 2321002}; for (int manaReflect : manaReflectSkillId) { ISkill manaReflectSkill = SkillFactory.getSkill(manaReflect); if (player.isBuffFrom(MapleBuffStat.MANA_REFLECTION, manaReflectSkill) && player.getSkillLevel(manaReflectSkill) > 0 && manaReflectSkill .getEffect(player.getSkillLevel(manaReflectSkill)) .makeChanceResult()) { int bouncedamage = (int) (damage * (manaReflectSkill .getEffect(player.getSkillLevel(manaReflectSkill)) .getX() / 100)); if (bouncedamage > attacker.getMaxHp() * .2) { bouncedamage = (int) (attacker.getMaxHp() * .2); } player.getMap().damageMonster(player, attacker, bouncedamage); player .getMap() .broadcastMessage( player, MaplePacketCreator.damageMonster(oid, bouncedamage), true); player .getClient() .getSession() .write(MaplePacketCreator.showOwnBuffEffect(manaReflect, 5)); player .getMap() .broadcastMessage( player, MaplePacketCreator.showBuffeffect( player.getId(), manaReflect, 5, (byte) 3), false); break; } } } } if (damagefrom == -1) { try { int[] achillesSkillId = {1120004, 1220005, 1320005}; for (int achilles : achillesSkillId) { ISkill achillesSkill = SkillFactory.getSkill(achilles); if (player.getSkillLevel(achillesSkill) > 0) { double multiplier = achillesSkill.getEffect(player.getSkillLevel(achillesSkill)).getX() / 1000.0; int newdamage = (int) (multiplier * damage); damage = newdamage; break; } } } catch (Exception e) { log.warn("Failed to handle achilles..", e); } } if (player.getBuffedValue(MapleBuffStat.MAGIC_GUARD) != null && mpattack == 0) { int mploss = (int) (damage * (player.getBuffedValue(MapleBuffStat.MAGIC_GUARD).doubleValue() / 100.0)); int hploss = damage - mploss; if (mploss > player.getMp()) { hploss += mploss - player.getMp(); mploss = player.getMp(); } player.addMPHP(-hploss, -mploss); } else if (player.getBuffedValue(MapleBuffStat.MESOGUARD) != null) { damage = (damage % 2 == 0) ? damage / 2 : (damage / 2) + 1; int mesoloss = (int) (damage * (player.getBuffedValue(MapleBuffStat.MESOGUARD).doubleValue() / 100.0)); if (player.getMeso() < mesoloss) { player.gainMeso(-player.getMeso(), false); player.cancelBuffStats(MapleBuffStat.MESOGUARD); } else { player.gainMeso(-mesoloss, false); } player.addMPHP(-damage, -mpattack); } else { player.addMPHP(-damage, -mpattack); } if (c.getPlayer().getMap().getId() == 980010101) { if (monsteridfrom == 9300166) { player.setBombPoints(player.getBombPoints() - 1); if (player.getBombPoints() < 1) { player.setHp(0); player.updateSingleStat(MapleStat.HP, 0); player.setBombPoints(10); c.getPlayer() .dropMessage( "[" + c.getChannelServer().getServerName() + "] You have died in Battle at the Bomberman Arena."); c.getPlayer() .getMap() .broadcastMessage( MaplePacketCreator.serverNotice( 1, "[" + c.getChannelServer().getServerName() + "] The person " + player.getName() + " has died in Bomberman PvP.")); return; } else { c.getPlayer() .getMap() .broadcastMessage( MaplePacketCreator.serverNotice( 1, "[" + c.getChannelServer().getServerName() + "] The player " + player.getName() + " now has " + player.getBombPoints() + " points left in Bomberman PvP.")); return; } } } else { player .getMap() .broadcastMessage( player, MaplePacketCreator.damagePlayer( damagefrom, monsteridfrom, player.getId(), damage, fake, direction, is_pgmr, pgmr, is_pg, oid, pos_x, pos_y), false); } } else { player.dropMessage( 1, "You have been suspected of Packet Editing. A GM will be notified."); } } } }
@Override public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) { c.getPlayer().resetAfkTime(); if (!MapleGuild.ENABLE_BBS) { c.getSession() .write( MaplePacketCreator.serverNotice( 1, "Your server administrator has currently disabled Guild BBS.")); return; } if (c.getPlayer().getGuildId() <= 0) { return; // expelled while viewing bbs or hax } byte mode = slea.readByte(); int localthreadid = 0; switch (mode) { case 0: // start a new post boolean bEdit = slea.readByte() == 1 ? true : false; if (bEdit) { localthreadid = slea.readInt(); } boolean bNotice = slea.readByte() == 1 ? true : false; String title = correctLength(slea.readMapleAsciiString(), 25); String text = correctLength(slea.readMapleAsciiString(), 600); int icon = slea.readInt(); if (icon >= 0x64 && icon <= 0x6a) { if (!c.getPlayer().haveItem(5290000 + icon - 0x64, 1, false, true)) { return; // hax, using an nx icon that s/he doesn't have } } else if (!(icon >= 0 && icon <= 2)) { return; // hax, using an invalid icon } if (!bEdit) { newBBSThread(c, title, text, icon, bNotice); } else { editBBSThread(c, title, text, icon, localthreadid); } break; case 1: // delete a thread localthreadid = slea.readInt(); deleteBBSThread(c, localthreadid); break; case 2: int start = slea.readInt(); // list threads listBBSThreads(c, start * 10); break; case 3: // list thread + reply, followed by id (int) localthreadid = slea.readInt(); displayThread(c, localthreadid); break; case 4: // reply localthreadid = slea.readInt(); text = correctLength(slea.readMapleAsciiString(), 25); newBBSReply(c, localthreadid, text); break; case 5: // delete reply localthreadid = slea.readInt(); // we don't use this int replyid = slea.readInt(); deleteBBSReply(c, replyid); break; default: log.warn("Unhandled BBS mode: " + mode); } }