gt:             chr.gainExp((amount * chr.getExpRate()), true, true);
context: /*
   This file is part of the OdinMS Maple Story Server
   Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
   Matthias Butz <matze@odinms.de>
   Jan Christian Meyer <vimes@odinms.de>
  
   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU Affero General Public License as
   published by the Free Software Foundation version 3 as published by
   the Free Software Foundation. You may not use, modify or distribute
   this program under any other version of the GNU Affero General Public
   License.
  
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU Affero General Public License for more details.
  
   You should have received a copy of the GNU Affero General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
   */
  package scripting;
  
  import client.MapleCharacter;
  import client.MapleClient;
  import client.MapleQuestStatus;
  import client.SkillFactory;
  import client.inventory.Equip;
  import client.inventory.Item;
  import client.inventory.MapleInventory;
  import client.inventory.MapleInventoryType;
  import client.inventory.MaplePet;
  import client.inventory.ModifyInventory;
  import constants.ItemConstants;
  import java.awt.Point;
  import java.util.Arrays;
  import java.util.Collections;
  import java.util.List;
  import net.server.Server;
  import net.server.guild.MapleGuild;
  import net.server.world.MapleParty;
  import scripting.event.EventManager;
  import scripting.npc.NPCScriptManager;
  import server.MapleInventoryManipulator;
  import server.MapleItemInformationProvider;
  import server.life.MapleLifeFactory;
  import server.life.MapleMonster;
  import server.life.MobSkill;
  import server.life.MobSkillFactory;
  import server.maps.MapleMap;
  import server.maps.MapleMapObject;
  import server.maps.MapleMapObjectType;
  import server.partyquest.Pyramid;
  import server.quest.MapleQuest;
  import tools.MaplePacketCreator;
  
  public class AbstractPlayerInteraction {
  
      public MapleClient c;
  
      public AbstractPlayerInteraction(MapleClient c) {
          this.c = c;
      }
  
      public MapleClient getClient() {
          return c;
      }
  
      public MapleCharacter getPlayer() {
          return c.getPlayer();
      }
  
      public void warp(int map) {
          getPlayer().changeMap(getWarpMap(map), getWarpMap(map).getPortal(0));
      }
  
      public void warp(int map, int portal) {
          getPlayer().changeMap(getWarpMap(map), getWarpMap(map).getPortal(portal));
      }
  
      public void warp(int map, String portal) {
          getPlayer().changeMap(getWarpMap(map), getWarpMap(map).getPortal(portal));
      }
  
      public void warpMap(int map) {
          for (MapleCharacter mc : getPlayer().getMap().getCharacters()) {
              mc.changeMap(getWarpMap(map), getWarpMap(map).getPortal(0));
          }
      }
  
      protected MapleMap getWarpMap(int map) {
          MapleMap target;
          if (getPlayer().getEventInstance() == null) {
              target = c.getChannelServer().getMapFactory().getMap(map);
          } else {
              target = getPlayer().getEventInstance().getMapInstance(map);
          }
          return target;
      }
  
      public MapleMap getMap(int map) {
          return getWarpMap(map);
      }
  
      public EventManager getEventManager(String event) {
          return getClient().getChannelServer().getEventSM().getEventManager(event);
      }
  
      public boolean haveItem(int itemid) {
          return haveItem(itemid, 1);
      }
  
      public boolean haveItem(int itemid, int quantity) {
          return getPlayer().getItemQuantity(itemid, false) >= quantity;
      }
  
      public boolean canHold(int itemid) {
          return getPlayer().getInventory(MapleItemInformationProvider.getInstance().getInventoryType(itemid)).getNextFreeSlot() > -1;
      }
  
      public void openNpc(int npcid) {
          NPCScriptManager.getInstance().dispose(c);
          NPCScriptManager.getInstance().start(c, npcid, null, null);
      }
  
      public void updateQuest(int questid, String data) {
          MapleQuestStatus status = c.getPlayer().getQuest(MapleQuest.getInstance(questid));
          status.setStatus(MapleQuestStatus.Status.STARTED);
          status.setProgress(0, data);//override old if exists
          c.getPlayer().updateQuest(status);
      }
  
      public MapleQuestStatus.Status getQuestStatus(int id) {
          return c.getPlayer().getQuest(MapleQuest.getInstance(id)).getStatus();
      }
  
      public boolean isQuestCompleted(int quest) {
          try {
              return getQuestStatus(quest) == MapleQuestStatus.Status.COMPLETED;
          } catch (NullPointerException e) {
              return false;
          }
      }
  
      public boolean isQuestStarted(int quest) {
          try {
              return getQuestStatus(quest) == MapleQuestStatus.Status.STARTED;
          } catch (NullPointerException e) {
              return false;
          }
      }
  
      public int getQuestProgress(int qid) {
          return Integer.parseInt(getPlayer().getQuest(MapleQuest.getInstance(29932)).getProgress().get(0));
      }
  
      public void gainItem(int id, short quantity) {
          gainItem(id, quantity, false, false);
      }
  
      public void gainItem(int id, short quantity, boolean show) {//this will fk randomStats equip :P
          gainItem(id, quantity, false, show);
      }
  
      public void gainItem(int id, boolean show) {
          gainItem(id, (short) 1, false, show);
      }
  
      public void gainItem(int id) {
          gainItem(id, (short) 1, false, false);
      }
  
      public void gainItem(int id, short quantity, boolean randomStats, boolean showMessage) {
          if (id >= 5000000 && id <= 5000100) {
              MapleInventoryManipulator.addById(c, id, (short) 1, null, MaplePet.createPet(id), -1);
          }
          if (quantity >= 0) {
              MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
              Item item = ii.getEquipById(id);
              if (!MapleInventoryManipulator.checkSpace(c, id, quantity, "")) {
                  c.getPlayer().dropMessage(1, "Your inventory is full. Please remove an item from your " + ii.getInventoryType(id).name() + " inventory.");
                  return;
              }
              if (ii.getInventoryType(id).equals(MapleInventoryType.EQUIP) && !ItemConstants.isRechargable(item.getItemId())) {
                  if (randomStats) {
                      MapleInventoryManipulator.addFromDrop(c, ii.randomizeStats((Equip) item), false);
                  } else {
                      MapleInventoryManipulator.addFromDrop(c, (Equip) item, false);
                  }
              } else {
                  MapleInventoryManipulator.addById(c, id, quantity);
              }
          } else {
              MapleInventoryManipulator.removeById(c, MapleItemInformationProvider.getInstance().getInventoryType(id), id, -quantity, true, false);
          }
          if (showMessage) {
              c.announce(MaplePacketCreator.getShowItemGain(id, quantity, true));
          }
      }
  
      public void changeMusic(String songName) {
          getPlayer().getMap().broadcastMessage(MaplePacketCreator.musicChange(songName));
      }
  
      public void playerMessage(int type, String message) {
          c.announce(MaplePacketCreator.serverNotice(type, message));
      }
  
      public void message(String message) {
          getPlayer().message(message);
      }
  
      public void mapMessage(int type, String message) {
          getPlayer().getMap().broadcastMessage(MaplePacketCreator.serverNotice(type, message));
      }
  
      public void mapEffect(String path) {
          c.announce(MaplePacketCreator.mapEffect(path));
      }
  
      public void mapSound(String path) {
          c.announce(MaplePacketCreator.mapSound(path));
      }
  
      public void showIntro(String path) {
          c.announce(MaplePacketCreator.showIntro(path));
      }
  
      public void showInfo(String path) {
          c.announce(MaplePacketCreator.showInfo(path));
          c.announce(MaplePacketCreator.enableActions());
      }
  
      public void guildMessage(int type, String message) {
          if (getGuild() != null) {
              getGuild().guildMessage(MaplePacketCreator.serverNotice(type, message));
          }
      }
  
      public MapleGuild getGuild() {
          try {
              return Server.getInstance().getGuild(getPlayer().getGuildId(), null);
          } catch (Exception e) {
          }
          return null;
      }
  
      public MapleParty getParty() {
          return getPlayer().getParty();
      }
  
      public boolean isLeader() {
          return getParty().getLeader().equals(getPlayer().getMPC());
      }
  
      public void givePartyItems(int id, short quantity, List<MapleCharacter> party) {
          for (MapleCharacter chr : party) {
              MapleClient cl = chr.getClient();
              if (quantity >= 0) {
                  MapleInventoryManipulator.addById(cl, id, quantity);
              } else {
                  MapleInventoryManipulator.removeById(cl, MapleItemInformationProvider.getInstance().getInventoryType(id), id, -quantity, true, false);
              }
              cl.announce(MaplePacketCreator.getShowItemGain(id, quantity, true));
          }
      }
  
      public void givePartyExp(int amount, List<MapleCharacter> party) {
          for (MapleCharacter chr : party) {
  