Gladicek

L2j Change Sex

May 2nd, 2012
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.59 KB | None | 0 0
  1. /*
  2.  * This program is free software: you can redistribute it and/or modify it under
  3.  * the terms of the GNU General Public License as published by the Free Software
  4.  * Foundation, either version 3 of the License, or (at your option) any later
  5.  * version.
  6.  *
  7.  * This program is distributed in the hope that it will be useful, but WITHOUT
  8.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9.  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10.  * details.
  11.  *
  12.  * You should have received a copy of the GNU General Public License along with
  13.  * this program. If not, see <http://www.gnu.org/licenses/>.
  14.  */
  15. package custom.ChangeSex;
  16.  
  17. import com.l2jserver.gameserver.model.actor.L2Npc;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. import com.l2jserver.gameserver.model.quest.Quest;
  20. import com.l2jserver.gameserver.model.quest.QuestState;
  21. import com.l2jserver.gameserver.instancemanager.QuestManager;
  22.  
  23. /******************************
  24.  * @author Gladicek           *
  25.  * Custom Npc 'Change Sex'    *
  26.  *****************************/
  27.  
  28.  public class ChangeSex extends Quest
  29.  {
  30.   // Npc
  31.     private static final int NpcId = 49297; // Custom Npc
  32.   // Item
  33.   private static final int ItemId = 6673; // Festival Adena
  34.  
  35.     public ChangeSex(int questId, String name, String descr)
  36.     {
  37.         super(questId, name, descr);
  38.         addStartNpc(NpcId);
  39.     addFirstTalkId(NpcId);
  40.     addTalkId(NpcId);
  41.     }
  42.                
  43.     @Override
  44.     public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  45.     {
  46.         String htmltext = event;
  47.         final QuestState st = player.getQuestState(getName());  
  48.  
  49.         if (event.equalsIgnoreCase("change_sex"))
  50.         {
  51.      if(st.getQuestItemsCount(ItemId) >= 1)
  52.      {
  53.        st.takeItems(ItemId,1);    
  54.          player.getAppearance().setSex(player.getAppearance().getSex() ? false : true);
  55.              player.sendMessage("Your gender has been changed!");
  56.              player.broadcastUserInfo();
  57.              player.decayMe();
  58.            player.spawnMe(player.getX(), player.getY(), player.getZ());
  59.        return null;
  60.      }
  61.      else
  62.       return "49297-no.htm";      
  63.     }
  64.    return htmltext;
  65.     }
  66.  
  67.     @Override
  68.     public String onFirstTalk(L2Npc npc, L2PcInstance player)
  69.     {
  70.         QuestState st = player.getQuestState(getName());
  71.         if (st == null)
  72.         {
  73.             Quest q = QuestManager.getInstance().getQuest(getName());
  74.             st = q.newQuestState(player);
  75.     }  
  76.         return "49297.htm";
  77.     }
  78.  
  79.     public static void main(String[] args)
  80.     {
  81.         new ChangeSex(-1, "ChangeSex", "custom");
  82.     _log.info("ChangeSex: Loaded (Created by Gladicek)");
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment