예제 #1
0
  @Override
  public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    List<Pair<MapleStat, Integer>> statupdate = new ArrayList<Pair<MapleStat, Integer>>(2);
    c.getSession().write(MaplePacketCreator.updatePlayerStats(statupdate, true));
    slea.readInt(); // whatever

    int update = slea.readInt();
    if (c.getPlayer().getRemainingAp() > 0) {
      switch (update) {
        case 64: // str
          if (c.getPlayer().getStr() >= 32767) {
            return;
          }
          c.getPlayer().setStr(c.getPlayer().getStr() + 1);
          statupdate.add(new Pair<MapleStat, Integer>(MapleStat.STR, c.getPlayer().getStr()));
          break;
        case 128: // dex
          if (c.getPlayer().getDex() >= 32767) {
            return;
          }
          c.getPlayer().setDex(c.getPlayer().getDex() + 1);
          statupdate.add(new Pair<MapleStat, Integer>(MapleStat.DEX, c.getPlayer().getDex()));
          break;
        case 256: // int
          if (c.getPlayer().getInt() >= 32767) {
            return;
          }
          c.getPlayer().setInt(c.getPlayer().getInt() + 1);
          statupdate.add(new Pair<MapleStat, Integer>(MapleStat.INT, c.getPlayer().getInt()));
          break;
        case 512: // luk
          if (c.getPlayer().getLuk() >= 32767) {
            return;
          }
          c.getPlayer().setLuk(c.getPlayer().getLuk() + 1);
          statupdate.add(new Pair<MapleStat, Integer>(MapleStat.LUK, c.getPlayer().getLuk()));
          break;
        case 2048: // hp
        case 8192: // mp
          c.showMessage("You cannot add Ap to HP or MP in NinjaMS. :)");
          return;
        default:
          c.getSession()
              .write(
                  MaplePacketCreator.updatePlayerStats(MaplePacketCreator.EMPTY_STATUPDATE, true));
          return;
      }
      c.getPlayer().setRemainingAp(c.getPlayer().getRemainingAp() - 1);
      statupdate.add(
          new Pair<MapleStat, Integer>(MapleStat.AVAILABLEAP, c.getPlayer().getRemainingAp()));
      c.getSession().write(MaplePacketCreator.updatePlayerStats(statupdate, true));
    } else {
      // AutobanManager.getInstance().addPoints(c, 334, 120000, "Trying to distribute AP to " +
      // update + " that are not availables");
      // log.info("[h4x] Player {} is distributing ap to {} without having any",
      // c.getPlayer().getName(), Integer.valueOf(update));
    }
  }
예제 #2
0
 @Override
 public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
   int emote = slea.readInt();
   if (emote < 0) {
     return;
   }
   if (emote > 7) {
     int emoteid = 5159992 + emote;
     if (c.getPlayer()
             .getInventory(MapleItemInformationProvider.getInstance().getInventoryType(emoteid))
             .findById(emoteid)
         == null) {
       return;
     }
   }
   if (c.getPlayer().getAndroid() != null) {
     c.getPlayer()
         .getMap()
         .broadcastMessage(MaplePacketCreator.showAndroidEmotion(c.getPlayer().getId(), emote));
   }
   c.getPlayer()
       .getMap()
       .broadcastMessage(
           c.getPlayer(), MaplePacketCreator.facialExpression(c.getPlayer(), emote), false);
 }
예제 #3
0
 public static final void partySearchRegister(SeekableLittleEndianAccessor slea, MapleClient c) {
   MapleCharacter chr = c.getPlayer();
   int min = slea.readInt();
   int max = slea.readInt();
   if (chr.getLevel() < min
       || chr.getLevel() > max
       || (max - min) > 30
       || min > max) { // Client editing
     return;
   }
 }
예제 #4
0
 public static final void partySearchStart(SeekableLittleEndianAccessor slea, MapleClient c) {
   int min = slea.readInt();
   int max = slea.readInt();
   slea.readInt(); // members
   int jobs = slea.readInt();
   MapleCharacter chr = c.getPlayer();
   MapleMap map = chr.getMap();
   Collection<MapleMapObject> mapobjs = map.getAllPlayer();
   for (MapleMapObject mapobj : mapobjs) {
     if (chr.getParty().getMembers().size() > 5) {
       break;
     }
     if (mapobj instanceof MapleCharacter) {
       MapleCharacter tchar = (MapleCharacter) mapobj;
       int charlvl = tchar.getLevel();
       if (charlvl >= min && charlvl <= max && isValidJob(tchar.getJob(), jobs)) {
         if (c.getPlayer().getParty() == null) {
           try {
             WorldChannelInterface wci = c.getChannelServer().getWorldInterface();
             MapleParty party = c.getPlayer().getParty();
             int partyid = party.getId();
             party = wci.getParty(partyid);
             if (party != null) {
               if (party.getMembers().size() < 6) {
                 MaplePartyCharacter partyplayer = new MaplePartyCharacter(tchar);
                 wci.updateParty(party.getId(), PartyOperation.JOIN, partyplayer);
                 c.getPlayer().receivePartyMemberHP();
                 c.getPlayer().updatePartyMemberHP();
               } else {
                 c.getSession().write(MaplePacketCreator.partyStatusMessage(17));
               }
             }
           } catch (Exception e) {
             c.getChannelServer().reconnectWorld();
           }
         }
       }
     }
   }
 }
예제 #5
0
 public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
   int oid = slea.readInt();
   @SuppressWarnings("unused")
   byte mode = slea.readByte(); // specifies if backwarp or not, but currently we do not care
   for (MapleMapObject obj : c.getPlayer().getMap().getMapObjects()) {
     if (obj instanceof MapleDoor) {
       MapleDoor door = (MapleDoor) obj;
       if (door.getOwner().getId() == oid) {
         door.warp(c.getPlayer());
         return;
       }
     }
   }
 }
 @Override
 public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
   c.getPlayer().resetAfkTime();
   if (c.getPlayer().getNoPets() == 0) {
     return;
   }
   int slot = 0;
   MaplePet[] pets = c.getPlayer().getPets();
   for (int i = 0; i < 3; i++) {
     if (pets[i] != null) {
       if (pets[i].getFullness() < 100) {
         slot = i;
       }
     } else {
       break;
     }
   }
   MaplePet pet = c.getPlayer().getPet(slot);
   slea.readInt();
   slea.readShort();
   int itemId = slea.readInt();
   if (c.getPlayer().haveItem(itemId, 1, false, true)) {
     boolean gainCloseness = new Random().nextInt(101) <= 50;
     int newFullness = pet.getFullness() + 30;
     if (pet.getFullness() < 100) {
       if (newFullness > 100) {
         newFullness = 100;
       }
       pet.setFullness(newFullness);
       if (gainCloseness && pet.getCloseness() < 30000) {
         int newCloseness = pet.getCloseness() + (1 * c.getChannelServer().getPetExpRate());
         if (newCloseness > 30000) {
           newCloseness = 30000;
         }
         pet.setCloseness(newCloseness);
         if (newCloseness >= ExpTable.getClosenessNeededForLevel(pet.getLevel() + 1)) {
           pet.setLevel(pet.getLevel() + 1);
           c.getSession()
               .write(MaplePacketCreator.showOwnPetLevelUp(c.getPlayer().getPetIndex(pet)));
           c.getPlayer()
               .getMap()
               .broadcastMessage(
                   MaplePacketCreator.showPetLevelUp(
                       c.getPlayer(), c.getPlayer().getPetIndex(pet)));
         }
       }
     } else {
       if (gainCloseness) {
         int newCloseness = pet.getCloseness() - (1 * c.getChannelServer().getPetExpRate());
         if (newCloseness < 0) {
           newCloseness = 0;
         }
         pet.setCloseness(newCloseness);
         if (newCloseness < ExpTable.getClosenessNeededForLevel(pet.getLevel())) {
           pet.setLevel(pet.getLevel() - 1);
         }
       }
     }
     c.getSession().write(MaplePacketCreator.updatePet(pet, true));
     c.getPlayer()
         .getMap()
         .broadcastMessage(
             c.getPlayer(),
             MaplePacketCreator.commandResponse(c.getPlayer().getId(), (byte) 1, slot, true, true),
             true);
     MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, itemId, 1, true, false);
   }
 }
예제 #7
0
  @Override
  public void handlePacket(SeekableLittleEndianAccessor slea, final MapleClient c) {
    int skillId = slea.readInt(); // 技能ID
    int level = slea.readByte(); // 等级
    byte flags = slea.readByte(); // 80
    int speed = slea.readByte(); // 武器攻击速度 && skillId != 23121000
    int op = slea.readByte();
    ISkill skill = SkillFactory.getSkill(skillId);
    /*
     * if (skill != null && skill.hasCharge()) {
     * c.getPlayer().getMap().broadcastMessage(c.getPlayer(),
     * MaplePacketCreator.skillEffect(c.getPlayer(), skillId, level, flags,
     * speed, op), false); }
     */

    if (skillId == 33101005) {
      c.getPlayer().设置吞噬的怪id(slea.readInt());
    }
    // 暴风箭雨 金属风暴 磁石
    if ((skillId == 3121004
            || skillId == 5221004
            || skillId == 1121001
            || skillId == 1221001
            || skillId == 1321001
            || skillId == 2121001
            || skillId == 2221001
            || skillId == 2321001
            || skillId == 2111002
            || skillId == 4211001
            || skillId == 3221001
            || skillId == 5101004
            || skillId == 15101003
            || skillId == 5201002
            || skillId == 14111006
            || skillId == 13111002
            || skillId == 22121000 // 冰点寒气
            || skillId == 22151001 // 火焰喷射
            || skillId == 4341002 // 终极斩
            || skillId == 4341003 // 怪物炸弹
            || skillId == 33101005 // 弩骑 吞噬
            || skillId == 33121009 // 弩骑 狂野射击
            || skillId == 35001001 // 火焰喷射器
            || skillId == 35101009 // 强化火焰喷射器
            || skillId == 23121000 // 伊师塔之环
            || skillId == 31101000 // 灵魂吞噬
            || skillId == 31001000
            || skillId == 31101002
            || skillId == 31111005
            || skillId == 5311002
            || skillId == 5721001
            || skillId == 24121000
            || skillId == 24121005
            || skillId == 60011216
            || skillId == 65121003
            || skillId == 27101202
            || skillId == 36121000
            || skillId == 36101001)
        && level >= 1) {
      c.getPlayer()
          .getMap()
          .broadcastMessage(
              c.getPlayer(),
              MaplePacketCreator.skillEffect(c.getPlayer(), skillId, level, flags, speed, op),
              false);
    } else {
      log.info("未登记技能效果挂断连接:" + skillId);
    }
  }
  /*	TODO:
   *	1. Move the equpping into a function.
   */
  @Override
  public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    c.getPlayer().resetAfkTime();
    slea.readInt();
    byte slot = slea.readByte();
    slea.readByte();
    boolean lead = slea.readByte() == 1;
    MapleCharacter player = c.getPlayer();
    IItem item = player.getInventory(MapleInventoryType.CASH).getItem(slot);

    if (item.getItemId() == 5000028 || item.getItemId() == 5000047) {
      boolean done = false;
      int petno;
      int[] pet;
      int[] dragon = {5000029, 5000030, 5000031, 5000032, 5000033};
      int[] robot = {5000048, 5000049, 5000050, 5000051, 5000052, 5000053};

      pet = item.getItemId() == 5000028 ? dragon : robot;
      Random egg = new Random();
      for (int i = 0; i < pet.length && !done; i++) {
        petno = egg.nextInt(pet.length);
        if (!player.haveItem(pet[petno], 1, true, true)) {
          MapleInventoryManipulator.removeFromSlot(
              c, MapleInventoryType.CASH, item.getPosition(), (short) 1, true, false);
          MapleInventoryManipulator.addById(
              c, pet[petno], (short) 1, null, MaplePet.createPet(pet[petno]));
          done = true;
        }
      }
      if (!done) {
        player.dropMessage(1, "You currently have all the dragons or robots.");
        return;
      }
    }
    // New instance of MaplePet - using the item ID and unique pet ID
    MaplePet pet =
        MaplePet.loadFromDb(
            player.getInventory(MapleInventoryType.CASH).getItem(slot).getItemId(),
            slot,
            player.getInventory(MapleInventoryType.CASH).getItem(slot).getPetId());

    if (pet == null) {
      MapleInventoryManipulator.removeById(
          c, MapleInventoryType.CASH, item.getItemId(), (short) item.getQuantity(), false, false);
      c.getSession().write(MaplePacketCreator.enableActions());
      return;
    }
    // Assign the pet to the player, set stats
    if (player.getPetIndex(pet) != -1) {
      player.unequipPet(pet, true);
    } else {
      if (player.getSkillLevel(SkillFactory.getSkill(8)) == 0 && player.getPet(0) != null) {
        player.unequipPet(player.getPet(0), false);
      }
      if (lead) {
        player.shiftPetsRight();
      }
      Point pos = player.getPosition();
      pos.y -= 12;
      pet.setPos(pos);
      pet.setFh(player.getMap().getFootholds().findBelow(pet.getPos()).getId());
      pet.setStance(0);

      player.addPet(pet);
      // Broadcast packet to the map...
      player
          .getMap()
          .broadcastMessage(player, MaplePacketCreator.showPet(player, pet, false), true);
      // Find the pet's unique ID
      int uniqueid = pet.getUniqueId();
      // Make a new List for the stat update
      List<Pair<MapleStat, Integer>> stats = new ArrayList<Pair<MapleStat, Integer>>();
      stats.add(new Pair<MapleStat, Integer>(MapleStat.PET, Integer.valueOf(uniqueid)));
      // Write the stat update to the player...
      c.getSession().write(MaplePacketCreator.petStatUpdate(player));
      c.getSession().write(MaplePacketCreator.enableActions());
      // Get the data
      int hunger = PetDataFactory.getHunger(pet.getItemId());
      // Start the fullness schedule
      player.startFullnessSchedule(hunger, pet, player.getPetIndex(pet));
    }
  }
예제 #9
0
  public static final void PartyOperatopn(
      final SeekableLittleEndianAccessor slea, final MapleClient c) {
    final int operation = slea.readByte();
    final WorldChannelInterface wci = ChannelServer.getInstance(c.getChannel()).getWorldInterface();
    MapleParty party = c.getPlayer().getParty();
    MaplePartyCharacter partyplayer = new MaplePartyCharacter(c.getPlayer());

    switch (operation) {
      case 1: // create
        if (c.getPlayer().getParty() == null) {
          try {
            party = wci.createParty(partyplayer);
            c.getPlayer().setParty(party);
          } catch (RemoteException e) {
            c.getChannelServer().reconnectWorld();
          }
          c.getSession().write(MaplePacketCreator.partyCreated());
        } else {
          c.getPlayer().dropMessage(5, "You can't create a party as you are already in one");
        }
        break;
      case 2: // leave
        if (party != null) { // are we in a party? o.O"
          try {
            if (partyplayer.equals(party.getLeader())) { // disband
              wci.updateParty(party.getId(), PartyOperation.DISBAND, partyplayer);
              if (c.getPlayer().getEventInstance() != null) {
                c.getPlayer().getEventInstance().disbandParty();
              }
            } else {
              wci.updateParty(party.getId(), PartyOperation.LEAVE, partyplayer);
              if (c.getPlayer().getEventInstance() != null) {
                c.getPlayer().getEventInstance().leftParty(c.getPlayer());
              }
            }
          } catch (RemoteException e) {
            c.getChannelServer().reconnectWorld();
          }
          c.getPlayer().setParty(null);
        }
        break;
      case 3: // accept invitation
        final int partyid = slea.readInt();
        if (c.getPlayer().getParty() == null) {
          try {
            party = wci.getParty(partyid);
            if (party != null) {
              if (party.getMembers().size() < 6) {
                wci.updateParty(party.getId(), PartyOperation.JOIN, partyplayer);
                c.getPlayer().receivePartyMemberHP();
                c.getPlayer().updatePartyMemberHP();
              } else {
                c.getSession().write(MaplePacketCreator.partyStatusMessage(17));
              }
            } else {
              c.getPlayer().dropMessage(5, "The party you are trying to join does not exist");
            }
          } catch (RemoteException e) {
            c.getChannelServer().reconnectWorld();
          }
        } else {
          c.getPlayer().dropMessage(5, "You can't join the party as you are already in one");
        }
        break;
      case 4: // invite
        // TODO store pending invitations and check against them
        final MapleCharacter invited =
            c.getChannelServer().getPlayerStorage().getCharacterByName(slea.readMapleAsciiString());
        if (invited != null && c.getPlayer().canFuck(invited)) {
          if (invited.getParty() == null) {
            if (party.getMembers().size() < 6) {
              invited.getClient().getSession().write(MaplePacketCreator.partyInvite(c.getPlayer()));
            } else {
              c.getSession().write(MaplePacketCreator.partyStatusMessage(16));
            }
          } else {
            c.getSession().write(MaplePacketCreator.partyStatusMessage(17));
          }
        } else {
          c.getSession().write(MaplePacketCreator.partyStatusMessage(19));
        }
        break;
      case 5: // expel
        if (partyplayer.equals(party.getLeader())) {
          final MaplePartyCharacter expelled = party.getMemberById(slea.readInt());
          if (expelled != null) {
            try {
              wci.updateParty(party.getId(), PartyOperation.EXPEL, expelled);
              if (c.getPlayer().getEventInstance() != null) {
                /*if leader wants to boot someone, then the whole party gets expelled
                TODO: Find an easier way to get the character behind a MaplePartyCharacter
                possibly remove just the expellee.*/
                if (expelled.isOnline()) {
                  c.getPlayer().getEventInstance().disbandParty();
                }
              }

            } catch (RemoteException e) {
              c.getChannelServer().reconnectWorld();
            }
          }
        }
        break;
      case 6: // change leader
        final MaplePartyCharacter newleader = party.getMemberById(slea.readInt());
        try {
          wci.updateParty(party.getId(), PartyOperation.CHANGE_LEADER, newleader);
        } catch (RemoteException e) {
          c.getChannelServer().reconnectWorld();
        }
        break;
      default:
        System.out.println("Unhandled Party function." + operation + "");
        break;
    }
  }
  @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);
    }
  }
예제 #12
0
  public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    slea.readByte();
    slea.readInt(); // ?
    slea.readInt(); // position, but we dont need it o.o
    int oid = slea.readInt();
    MapleMapObject ob = c.getPlayer().getMap().getMapObject(oid);
    if (ob == null) {
      c.getSession().write(MaplePacketCreator.getInventoryFull());
      c.getSession().write(MaplePacketCreator.getShowInventoryFull());
      return;
    }
    if (ob instanceof MapleMapItem) {
      MapleMapItem mapitem = (MapleMapItem) ob;
      synchronized (mapitem) {
        if (mapitem.isPickedUp()) {
          c.getSession().write(MaplePacketCreator.getInventoryFull());
          c.getSession().write(MaplePacketCreator.getShowInventoryFull());
          return;
        }
        double distance = c.getPlayer().getPosition().distanceSq(mapitem.getPosition());
        c.getPlayer().getCheatTracker().checkPickupAgain();
        if (distance > 90000.0) { // 300^2, 550 is approximatly the range of ultis
          // AutobanManager.getInstance().addPoints(c, 100, 300000, "Itemvac");
          c.getPlayer().getCheatTracker().registerOffense(CheatingOffense.ITEMVAC);
          // Double.valueOf(Math.sqrt(distance))
        } else if (distance > 30000.0) {
          // log.warn("[h4x] Player {} is picking up an item that's fairly far away: {}",
          // c.getPlayer().getName(), Double.valueOf(Math.sqrt(distance)));
          c.getPlayer().getCheatTracker().registerOffense(CheatingOffense.SHORT_ITEMVAC);
        }

        if (mapitem.getMeso() > 0) {
          if (c.getPlayer().getParty() != null) {
            ChannelServer cserv = c.getChannelServer();
            int mesoAmm = mapitem.getMeso();
            int partyNum = 0;
            Collection<MaplePartyCharacter> partyMembers = c.getPlayer().getParty().getMembers();
            for (MaplePartyCharacter partyMember : partyMembers) {
              if (partyMember.getMapid() == c.getPlayer().getMapId()) {
                partyNum++;
              }
            }
            int mesoGain = mesoAmm / partyNum;
            for (MaplePartyCharacter partyMember : partyMembers) {
              if (partyMember.getMapid() == c.getPlayer().getMapId()) {
                cserv
                    .getPlayerStorage()
                    .getCharacterById(partyMember.getId())
                    .gainMeso(mesoGain, true, true);
              }
            }
          } else {
            c.getPlayer().gainMeso(mapitem.getMeso(), true, true);
          }
          c.getPlayer()
              .getMap()
              .broadcastMessage(
                  MaplePacketCreator.removeItemFromMap(
                      mapitem.getObjectId(), 2, c.getPlayer().getId()),
                  mapitem.getPosition());
          c.getPlayer().getCheatTracker().pickupComplete();
          c.getPlayer().getMap().removeMapObject(ob);
        } else {
          StringBuilder logInfo = new StringBuilder("Picked up by ");
          logInfo.append(c.getPlayer().getName());
          if (mapitem.getItem().getItemId() >= 5000000
              && mapitem.getItem().getItemId() <= 5000100) {
            int petId = MaplePet.createPet(mapitem.getItem().getItemId());
            if (petId == -1) {
              return;
            }
            MapleInventoryManipulator.addById(
                c,
                mapitem.getItem().getItemId(),
                mapitem.getItem().getQuantity(),
                "Cash Item was purchased.",
                null,
                petId);
            c.getPlayer()
                .getMap()
                .broadcastMessage(
                    MaplePacketCreator.removeItemFromMap(
                        mapitem.getObjectId(), 2, c.getPlayer().getId()),
                    mapitem.getPosition());
            c.getPlayer().getCheatTracker().pickupComplete();
            c.getPlayer().getMap().removeMapObject(ob);
          } else {
            if (MapleInventoryManipulator.addFromDrop(c, mapitem.getItem(), logInfo.toString())) {
              c.getPlayer()
                  .getMap()
                  .broadcastMessage(
                      MaplePacketCreator.removeItemFromMap(
                          mapitem.getObjectId(), 2, c.getPlayer().getId()),
                      mapitem.getPosition());
              c.getPlayer().getCheatTracker().pickupComplete();
              c.getPlayer().getMap().removeMapObject(ob);
            } else {
              c.getPlayer().getCheatTracker().pickupComplete();
              return;
            }
            if (mapitem.getItem().getItemId() == 1002357) {
              c.getPlayer().finishAchievement(13);
            }
          }
        }
        mapitem.setPickedUp(true);
      }
    }
    c.getSession().write(MaplePacketCreator.enableActions());
  }
예제 #13
0
  @Override
  public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    // System.out.println("SummonDamage 封包: "+slea.toString());

    int oid = slea.readInt();
    slea.skip(5);
    MapleCharacter player = c.getPlayer();
    if (!player.isAlive()) {
      return;
    }
    MapleSummon summon = null;
    boolean is磁场 = false;
    boolean is磁场攻击 = false;
    // System.out.println("接收到的召唤兽的oid"+oid);
    /*
     * for (List<MapleSummon> sums : c.getPlayer().getSummons().values()) {
     * for (MapleSummon sum : sums) {
     * //System.out.println("召唤兽的oid"+sum.getObjectId()); if
     * (sum.getObjectId() == oid) { summon = sum; break; } } }
     */
    Object obj = c.getPlayer().getMap().getMapObject(oid);
    if (obj instanceof MapleSummon) {
      summon = (MapleSummon) obj;
    }
    if (summon == null) {
      // System.out.println("召唤兽伤害被拦截");
      return;
    }
    int skillid;
    int skilllevel;
    Point pos;
    skillid = summon.getSkill();
    skilllevel = summon.getSkillLevel();
    pos = summon.getPosition();
    ISkill summonSkill = SkillFactory.getSkill(skillid);
    MapleStatEffect summonEffect = summonSkill.getEffect(skilllevel);
    List<SummonAttackEntry> allDamage = new ArrayList<SummonAttackEntry>();
    int numAttacked = changeNumAttacked(slea.readByte(), skillid); // 这里还读了一个byte
    int numAccackMonster = numAttacked >> 4;
    int numAccackMonsterCount = numAttacked & 0xf;
    // System.out.println("攻击怪的个数: " + numAttacked);
    player.getCheatTracker().checkSummonAttack();
    int oid1 = slea.readInt(); // 第一个磁场的oid
    if (skillid == 机械师.磁场) {
      // is磁场 = true;
      for (List<MapleSummon> sums : c.getPlayer().getSummons().values()) {
        for (MapleSummon sum : sums) {
          if (sum.getObjectId() == oid1) {
            is磁场攻击 = true;
            oid = oid1;
            break;
          }
        }
      }
      if (is磁场攻击) {
        slea.skip(4); // 第二个磁场的oid
        slea.skip(4); // 第三个磁场的oid
        slea.skip(4); // 没用的
      }
    }
    slea.skip(4);
    slea.skip(4); // 00
    for (int x = 0; x < numAccackMonster; x++) {
      int monsterOid = slea.readInt(); // attacked oid
      slea.skip(4); // mobid 对应的怪物在WZ里的id
      slea.skip(19);
      int damage = slea.readInt();

      for (int i = 0; i < numAccackMonsterCount; i++) {} // 以后召唤兽可能会多重攻击

      slea.skip(8);
      // System.out.println("mobid: " + monsterOid);
      // System.out.println("打怪伤害: " + damage);
      allDamage.add(new SummonAttackEntry(monsterOid, damage));
    }
    if (!player.isAlive()) {
      player.getCheatTracker().registerOffense(CheatingOffense.ATTACKING_WHILE_DEAD);
      return;
    }
    player
        .getMap()
        .broadcastMessage(
            player, MaplePacketCreator.summonAttack(player, oid, 4, allDamage, numAttacked), pos);
    for (SummonAttackEntry attackEntry : allDamage) {
      int damage = attackEntry.getDamage();
      // System.out.println("遍历回来的伤害:"+damage);
      MapleMonster target = player.getMap().getMonsterByOid(attackEntry.getMonsterOid());
      if (target != null) {
        if (damage > 0 && summonEffect.getMonsterStati().size() > 0) {
          if (summonEffect.makeChanceResult()) {
            MonsterStatusEffect monsterStatusEffect =
                new MonsterStatusEffect(summonEffect.getMonsterStati(), summonSkill, false);
            target.applyStatus(player, monsterStatusEffect, summonEffect.isPoison(), 4000);
          }
        }
        if (damage > 30000) {
          damage = 30000;
        }
        player.getMap().damageMonster(player, target, damage);
        player.checkMonsterAggro(target);
        // System.out.println("target == null");
      }
    }
    if (是自爆召唤兽(skillid) || is磁场 && !is磁场攻击) {
      // System.out.println("机械召唤兽的removeSpecialMapObject特殊处理");
      player.getMap().broadcastMessage(MaplePacketCreator.removeSpecialMapObject(summon, true));
      player.getMap().removeMapObject(summon);
      player.removeVisibleMapObject(summon);
      // player.getSummons().remove(skillid);
      player.removeSummon(skillid);
    }
  }