Advertisement
Guest User

Untitled

a guest
Sep 7th, 2013
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.69 KB | None | 0 0
  1. Index: java/com/l2jserver/gameserver/model/actor/instance/L2ChestInstance.java
  2. ===================================================================
  3. --- java/com/l2jserver/gameserver/model/actor/instance/L2ChestInstance.java (revision 480)
  4. +++ java/com/l2jserver/gameserver/model/actor/instance/L2ChestInstance.java (working copy)
  5. @@ -18,14 +18,9 @@
  6.   */
  7.  package com.l2jserver.gameserver.model.actor.instance;
  8.  
  9. -import com.l2jserver.gameserver.datatables.NpcTable;
  10. -import com.l2jserver.gameserver.datatables.SkillTable;
  11.  import com.l2jserver.gameserver.enums.InstanceType;
  12.  import com.l2jserver.gameserver.model.actor.L2Character;
  13.  import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
  14. -import com.l2jserver.gameserver.model.skills.L2Skill;
  15. -import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
  16. -import com.l2jserver.util.Rnd;
  17.  
  18.  /**
  19.   * This class manages all chest.
  20. @@ -33,8 +28,8 @@
  21.   */
  22.  public final class L2ChestInstance extends L2MonsterInstance
  23.  {
  24. -   private volatile boolean _isInteracted;
  25. -   private volatile boolean _specialDrop;
  26. +   private boolean _isInteracted;
  27. +   private boolean _itemDropEnabled;
  28.    
  29.     public L2ChestInstance(int objectId, L2NpcTemplate template)
  30.     {
  31. @@ -42,208 +37,50 @@
  32.         setInstanceType(InstanceType.L2ChestInstance);
  33.         setIsNoRndWalk(true);
  34.         _isInteracted = false;
  35. -       _specialDrop = false;
  36. +       _itemDropEnabled = false;
  37.     }
  38.    
  39. -   @Override
  40. -   public void onSpawn()
  41. +   public synchronized boolean chestInteraction()
  42.     {
  43. -       super.onSpawn();
  44. -       _isInteracted = false;
  45. -       _specialDrop = false;
  46. -       setMustRewardExpSp(true);
  47. +       if (_isInteracted)
  48. +       {
  49. +           return false;
  50. +       }
  51. +      
  52. +       return _isInteracted = true;
  53.     }
  54.    
  55. -   public synchronized boolean isInteracted()
  56. +   public void enableItemDrop()
  57.     {
  58. -       return _isInteracted;
  59. +       _itemDropEnabled = true;
  60.     }
  61.    
  62. -   public synchronized void setInteracted()
  63. +   @Override
  64. +   public void onSpawn()
  65.     {
  66. -       _isInteracted = true;
  67. +       super.onSpawn();
  68. +       _isInteracted = false;
  69. +       _itemDropEnabled = false;
  70.     }
  71.    
  72. -   public synchronized boolean isSpecialDrop()
  73. -   {
  74. -       return _specialDrop;
  75. -   }
  76. -  
  77. -   public synchronized void setSpecialDrop()
  78. -   {
  79. -       _specialDrop = true;
  80. -   }
  81. -  
  82.     @Override
  83. -   public void doItemDrop(L2NpcTemplate npcTemplate, L2Character lastAttacker)
  84. +   public void doItemDrop(L2NpcTemplate npcTemplate, L2Character mainDamageDealer)
  85.     {
  86. -       int id = getTemplate().getId();
  87. -      
  88. -       if (!_specialDrop)
  89. +       if (_itemDropEnabled)
  90.         {
  91. -           if ((id >= 18265) && (id <= 18286))
  92. -           {
  93. -               id += 3536;
  94. -           }
  95. -           else if ((id == 18287) || (id == 18288))
  96. -           {
  97. -               id = 21671;
  98. -           }
  99. -           else if ((id == 18289) || (id == 18290))
  100. -           {
  101. -               id = 21694;
  102. -           }
  103. -           else if ((id == 18291) || (id == 18292))
  104. -           {
  105. -               id = 21717;
  106. -           }
  107. -           else if ((id == 18293) || (id == 18294))
  108. -           {
  109. -               id = 21740;
  110. -           }
  111. -           else if ((id == 18295) || (id == 18296))
  112. -           {
  113. -               id = 21763;
  114. -           }
  115. -           else if ((id == 18297) || (id == 18298))
  116. -           {
  117. -               id = 21786;
  118. -           }
  119. +           super.doItemDrop(npcTemplate, mainDamageDealer);
  120.         }
  121. -      
  122. -       super.doItemDrop(NpcTable.getInstance().getTemplate(id), lastAttacker);
  123.     }
  124.    
  125. -   // cast - trap chest
  126. -   public void chestTrap(L2Character player)
  127. +   @Override
  128. +   public boolean isCoreAIDisabled()
  129.     {
  130. -       int trapSkillId = 0;
  131. -       int rnd = Rnd.get(120);
  132. -      
  133. -       if (getTemplate().getLevel() >= 61)
  134. -       {
  135. -           if (rnd >= 90)
  136. -           {
  137. -               trapSkillId = 4139;// explosion
  138. -           }
  139. -           else if (rnd >= 50)
  140. -           {
  141. -               trapSkillId = 4118;// area paralysys
  142. -           }
  143. -           else if (rnd >= 20)
  144. -           {
  145. -               trapSkillId = 1167;// poison cloud
  146. -           }
  147. -           else
  148. -           {
  149. -               trapSkillId = 223;// sting
  150. -           }
  151. -       }
  152. -       else if (getTemplate().getLevel() >= 41)
  153. -       {
  154. -           if (rnd >= 90)
  155. -           {
  156. -               trapSkillId = 4139;// explosion
  157. -           }
  158. -           else if (rnd >= 60)
  159. -           {
  160. -               trapSkillId = 96;// bleed
  161. -           }
  162. -           else if (rnd >= 20)
  163. -           {
  164. -               trapSkillId = 1167;// poison cloud
  165. -           }
  166. -           else
  167. -           {
  168. -               trapSkillId = 4118;// area paralysys
  169. -           }
  170. -       }
  171. -       else if (getTemplate().getLevel() >= 21)
  172. -       {
  173. -           if (rnd >= 80)
  174. -           {
  175. -               trapSkillId = 4139;// explosion
  176. -           }
  177. -           else if (rnd >= 50)
  178. -           {
  179. -               trapSkillId = 96;// bleed
  180. -           }
  181. -           else if (rnd >= 20)
  182. -           {
  183. -               trapSkillId = 1167;// poison cloud
  184. -           }
  185. -           else
  186. -           {
  187. -               trapSkillId = 129;// poison
  188. -           }
  189. -       }
  190. -       else
  191. -       {
  192. -           if (rnd >= 80)
  193. -           {
  194. -               trapSkillId = 4139;// explosion
  195. -           }
  196. -           else if (rnd >= 50)
  197. -           {
  198. -               trapSkillId = 96;// bleed
  199. -           }
  200. -           else
  201. -           {
  202. -               trapSkillId = 129;// poison
  203. -           }
  204. -       }
  205. -      
  206. -       player.sendMessage("There was a trap!");
  207. -       handleCast(player, trapSkillId);
  208. +       return true;
  209.     }
  210.    
  211. -   // <--
  212. -   // cast casse
  213. -   // <--
  214. -   private boolean handleCast(L2Character player, int skillId)
  215. -   {
  216. -       int skillLevel = 1;
  217. -       byte lvl = getTemplate().getLevel();
  218. -       if ((lvl > 20) && (lvl <= 40))
  219. -       {
  220. -           skillLevel = 3;
  221. -       }
  222. -       else if ((lvl > 40) && (lvl <= 60))
  223. -       {
  224. -           skillLevel = 5;
  225. -       }
  226. -       else if (lvl > 60)
  227. -       {
  228. -           skillLevel = 6;
  229. -       }
  230. -      
  231. -       if (player.isDead() || !player.isVisible() || !player.isInsideRadius(this, getDistanceToWatchObject(player), false, false))
  232. -       {
  233. -           return false;
  234. -       }
  235. -      
  236. -       L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLevel);
  237. -      
  238. -       if (player.getFirstEffect(skill) == null)
  239. -       {
  240. -           skill.getEffects(this, player);
  241. -           broadcastPacket(new MagicSkillUse(this, player, skill.getId(), skillLevel, skill.getHitTime(), 0));
  242. -           return true;
  243. -       }
  244. -       return false;
  245. -   }
  246. -  
  247.     @Override
  248.     public boolean isMovementDisabled()
  249.     {
  250. -       if (super.isMovementDisabled())
  251. -       {
  252. -           return true;
  253. -       }
  254. -       if (isInteracted())
  255. -       {
  256. -           return false;
  257. -       }
  258.         return true;
  259.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement