Advertisement
VANPER

aCis Random Zone

Feb 9th, 2020
1,782
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.99 KB | None | 0 0
  1. Index: net.sf.l2j.gameserver.network.serverpackets/die.java
  2. ===================================================================
  3. --- net.sf.l2j.gameserver.network.serverpackets/die.java    (revision 84)
  4. +++ net.sf.l2j.gameserver.network.serverpackets/die.java    (working copy)
  5. @@ -1281,6 +1281,10 @@
  6.  
  7. +   import net.sf.l2j.gameserver.model.zone.type.MultiZone;
  8.  
  9. +   private boolean _inZone;
  10.  
  11.  
  12.     @Override
  13.     protected final void writeImpl()
  14.     {
  15. +       if (_inZone)
  16.             return;
  17.            
  18.            
  19.            
  20.  
  21.         if (creature instanceof Player)
  22.         {
  23.             Player player = (Player) creature;
  24.             _allowFixedRes = player.getAccessLevel().allowFixedRes();
  25.             _clan = player.getClan();
  26.  
  27. +           // multi zonas
  28. +           final MultiZone zone = ZoneManager.getInstance().getZone(player, MultiZone.class);
  29. +           _inZone = zone != null && zone.getRevive() > 0;
  30.            
  31.         }
  32.  
  33. Index: net.sf.l2j.gameserver.model.zone.type/MultiZone.java
  34. ===================================================================
  35. --- net.sf.l2j.gameserver.model.zone.type/MultiZone.java    (revision 84)
  36. +++ net.sf.l2j.gameserver.model.zone.type/MultiZone.java    (working copy)
  37. @@ -1281,6 +1281,10 @@
  38.        
  39. +   package net.sf.l2j.gameserver.model.zone.type;
  40. +  
  41. +   import java.util.ArrayList;
  42. +   import java.util.Arrays;
  43. +   import java.util.List;
  44. +  
  45. +   import net.sf.l2j.commons.concurrent.ThreadPool;
  46. +  
  47. +   import net.sf.l2j.gameserver.enums.SpawnType;
  48. +   import net.sf.l2j.gameserver.enums.ZoneId;
  49. +   import net.sf.l2j.gameserver.model.actor.Creature;
  50. +   import net.sf.l2j.gameserver.model.actor.Player;
  51. +   import net.sf.l2j.gameserver.model.actor.Summon;
  52. +   import net.sf.l2j.gameserver.model.actor.instance.Pet;
  53. +   import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
  54. +   import net.sf.l2j.gameserver.model.zone.type.subtype.SpawnZoneType;
  55. +   import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
  56. +   import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
  57. +   import net.sf.l2j.gameserver.taskmanager.ZoneTaskManager;
  58. +  
  59. +   /**
  60. +    * @author Juvenil Amaro
  61. +    *
  62. +    */
  63. +   public class MultiZone extends SpawnZoneType
  64. +   {
  65. +       private String _zoneName;
  66. +       private boolean _isNoStore;
  67. +       private boolean _isNoSummonFriend;
  68. +       private static boolean _isFlagEnabled;
  69. +       private boolean _isHealEnabled;
  70. +       private int _duration;
  71. +       private int _reviveDelay;
  72. +       private static List<Integer> _restrictedItems = new ArrayList<>();
  73. +      
  74. +       public MultiZone(int id)
  75. +       {
  76. +           super(id);
  77. +       }
  78. +      
  79. +       @Override
  80. +       public void setParameter(String name, String value)
  81. +       {
  82. +           if (name.equals("name"))
  83. +               _zoneName = value;
  84. +           else if (name.equals("isNoStore"))
  85. +               _isNoStore = Boolean.parseBoolean(value);
  86. +           else if (name.equals("isNoSummonFriend"))
  87. +               _isNoSummonFriend = Boolean.parseBoolean(value);
  88. +           else if (name.equals("isFlagEnabled"))
  89. +               _isFlagEnabled = Boolean.parseBoolean(value);
  90. +           else if (name.equals("isHealEnabled"))
  91. +               _isHealEnabled = Boolean.parseBoolean(value);
  92. +           else if (name.equals("duration"))
  93. +               _duration = Integer.parseInt(value);
  94. +           else if (name.equals("reviveDelay"))
  95. +               _reviveDelay = Integer.parseInt(value);
  96. +           else if (name.equals("restrictedItems"))
  97. +               _restrictedItems = parseIntegers(value);
  98. +           else
  99. +               super.setParameter(name, value);
  100. +       }
  101. +  
  102. +       @Override
  103. +       protected void onEnter(Creature character)
  104. +       {
  105. +           character.setInsideZone(ZoneId.MULTI, true);
  106. +          
  107. +           if (_isNoStore)
  108. +               character.setInsideZone(ZoneId.NO_STORE, true);
  109. +          
  110. +           if (_isNoSummonFriend)
  111. +               character.setInsideZone(ZoneId.NO_SUMMON_FRIEND, true);
  112. +          
  113. +           if (character instanceof Player || character instanceof Pet)
  114. +           {
  115. +               final Player player = (Player) character;
  116. +               player.sendPacket(new ExShowScreenMessage("You have entered a multi zone.", 5000));
  117. +              
  118. +               if (_isFlagEnabled)
  119. +                   player.updatePvPFlag(1);
  120. +              
  121. +               checkItemRestriction(player);
  122. +           }
  123. +       }
  124. +      
  125. +       @Override
  126. +       protected void onExit(Creature character)
  127. +       {
  128. +           character.setInsideZone(ZoneId.MULTI, false);
  129. +          
  130. +           if (_isNoStore)
  131. +               character.setInsideZone(ZoneId.NO_STORE, false);
  132. +          
  133. +           if (_isNoSummonFriend)
  134. +               character.setInsideZone(ZoneId.NO_SUMMON_FRIEND, false);
  135. +          
  136. +           if (character instanceof Player)
  137. +           {
  138. +               final Player player = (Player) character;
  139. +               player.sendPacket(new ExShowScreenMessage("You have left a multi zone.", 5000));
  140. +              
  141. +               if (_isFlagEnabled)
  142. +                   player.updatePvPFlag(0);
  143. +           }
  144. +       }
  145. +      
  146. +       public void onDie(Creature character)
  147. +       {
  148. +           if (character instanceof Player && _reviveDelay > 0)
  149. +           {
  150. +               ThreadPool.schedule(() -> respawnCharacter(((Player) character)), _reviveDelay * 1000);
  151. +               character.sendPacket(new ExShowScreenMessage("You will be revived in " + _reviveDelay + " second(s).", 5000));
  152. +           }
  153. +       }
  154. +  
  155. +       private final void respawnCharacter(Player player)
  156. +       {
  157. +           if (player == null || !player.isDead())
  158. +               return;
  159. +          
  160. +           player.doRevive();
  161. +           player.teleportTo(getRndSpawn(SpawnType.NORMAL), 0);
  162. +       }
  163. +      
  164. +       public void onRevive(Creature character)
  165. +       {
  166. +           if (character instanceof Player && _isHealEnabled)
  167. +           {
  168. +               final Summon pet = character.getSummon();
  169. +               if (pet != null)
  170. +                   pet.setCurrentHpMp(pet.getMaxHp(), pet.getMaxMp());
  171. +              
  172. +               character.setCurrentCp(character.getMaxCp());
  173. +               character.setCurrentHpMp(character.getMaxHp(), character.getMaxMp());
  174. +           }
  175. +       }
  176. +      
  177. +       private final static void checkItemRestriction(Player player)
  178. +       {
  179. +           for (ItemInstance item : player.getInventory().getPaperdollItems())
  180. +           {
  181. +               if (item == null || !isRestrictedItem(item.getItemId()))
  182. +                   continue;
  183. +              
  184. +               player.getInventory().unEquipItemInSlot(item.getLocationSlot());
  185. +               InventoryUpdate iu = new InventoryUpdate();
  186. +               iu.addModifiedItem(item);
  187. +               player.sendPacket(iu);
  188. +           }
  189. +       }
  190. +  
  191. +       public List<Integer> parseIntegers(String line)
  192. +       {
  193. +           final List<Integer> value = new ArrayList<>();
  194. +           Arrays.asList(line.split(";")).forEach(id -> value.add(Integer.parseInt(id)));
  195. +          
  196. +           return value;
  197. +       }
  198. +      
  199. +       public boolean isActive()
  200. +       {
  201. +           return ZoneTaskManager.getInstance().getCurrentZoneId() == getId();
  202. +       }
  203. +      
  204. +       public String getZoneName()
  205. +       {
  206. +           return _zoneName;
  207. +       }
  208. +      
  209. +       public int getTime()
  210. +       {
  211. +           return _duration;
  212. +       }
  213. +      
  214. +       public int getRevive()
  215. +       {
  216. +           return _reviveDelay;
  217. +       }
  218. +      
  219. +       public static boolean isFlagEnabled()
  220. +       {
  221. +           return _isFlagEnabled;
  222. +       }
  223. +      
  224. +       public static boolean isRestrictedItem(int itemId)
  225. +       {
  226. +           return _restrictedItems.contains(itemId);
  227. +       }
  228. +   }
  229.  
  230. Index: data/xml/zones/MultiZone.xml
  231. ===================================================================
  232. --- data/xml/zones/MultiZone.xml    (revision 84)
  233. +++ data/xml/zones/MultiZone.xml    (working copy)
  234. @@ -1281,6 +1281,10 @@
  235.  
  236.  
  237. +   <?xml version="1.0" encoding="UTF-8"?>
  238. +   <list>
  239. +      <zone id="1" shape="Cuboid" minZ="-3850" maxZ="-350"> <!-- giran_pvp_battle -->
  240. +           <node x="72493" y="142263" />
  241. +           <node x="73493" y="143261" />
  242. +           <stat name="name" val="Giran Arena" />
  243. +           <stat name="isNoStore" val="false" />
  244. +           <stat name="isNoSummonFriend" val="false" />
  245. +           <stat name="isFlagEnabled" val="false" />
  246. +           <stat name="isHealEnabled" val="false" />
  247. +           <stat name="duration" val="0" /> <!-- minutes -->
  248. +           <stat name="reviveDelay" val="5" /> <!-- seconds -->
  249. +           <stat name="restrictedItems" val="6611;6612" />
  250. +           <spawn x="73890" y="142656" z="-3778" />
  251. +       </zone>
  252. +       <zone id="2" shape="Cuboid" minZ="-3752" maxZ="-352"> <!-- gludin_pvp -->
  253. +           <node x="-88411" y="141732" />
  254. +           <node x="-87429" y="142708" />
  255. +           <stat name="name" val="Gludin Arena" />
  256. +           <stat name="isNoStore" val="false" />
  257. +           <stat name="isNoSummonFriend" val="false" />
  258. +           <stat name="isFlagEnabled" val="true" />
  259. +           <stat name="isHealEnabled" val="true" />
  260. +           <stat name="duration" val="0" /> <!-- minutes -->
  261. +           <stat name="reviveDelay" val="5" /> <!-- seconds -->
  262. +           <stat name="restrictedItems" val="6611;6612" />
  263. +           <spawn x="-86979" y="142402" z="-3643" />
  264. +       </zone>
  265. +   </list>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement