Advertisement
Nik

FAN/SQUARE SKill target types [DP]

Nik
Oct 7th, 2011
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 8.81 KB | None | 0 0
  1. Index: dist/game/data/scripts/handlers/MasterHandler.java
  2. ===================================================================
  3. --- dist/game/data/scripts/handlers/MasterHandler.java  (revision 259)
  4. +++ dist/game/data/scripts/handlers/MasterHandler.java  (working copy)
  5. @@ -234,6 +234,8 @@
  6.  import handlers.targethandlers.TargetAlly;
  7.  import handlers.targethandlers.TargetArea;
  8.  import handlers.targethandlers.TargetAreaCorpseMob;
  9. +import handlers.targethandlers.TargetAreaFan;
  10. +import handlers.targethandlers.TargetAreaSquare;
  11.  import handlers.targethandlers.TargetAreaSummon;
  12.  import handlers.targethandlers.TargetAreaUndead;
  13.  import handlers.targethandlers.TargetAura;
  14. @@ -617,6 +619,8 @@
  15.     {
  16.         TARGET.registerSkillTargetType(new TargetAlly());
  17.         TARGET.registerSkillTargetType(new TargetArea());
  18. +       TARGET.registerSkillTargetType(new TargetAreaFan());
  19. +       TARGET.registerSkillTargetType(new TargetAreaSquare());
  20.         TARGET.registerSkillTargetType(new TargetAreaCorpseMob());
  21.         TARGET.registerSkillTargetType(new TargetAreaSummon());
  22.         TARGET.registerSkillTargetType(new TargetAreaUndead());
  23. Index: dist/game/data/scripts/handlers/targethandlers/TargetAreaFan.java
  24. ===================================================================
  25. --- dist/game/data/scripts/handlers/targethandlers/TargetAreaFan.java   (revision 0)
  26. +++ dist/game/data/scripts/handlers/targethandlers/TargetAreaFan.java   (revision 0)
  27. @@ -0,0 +1,99 @@
  28. +/*
  29. + * This program is free software: you can redistribute it and/or modify it under
  30. + * the terms of the GNU General Public License as published by the Free Software
  31. + * Foundation, either version 3 of the License, or (at your option) any later
  32. + * version.
  33. + *
  34. + * This program is distributed in the hope that it will be useful, but WITHOUT
  35. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  36. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  37. + * details.
  38. + *
  39. + * You should have received a copy of the GNU General Public License along with
  40. + * this program. If not, see <http://www.gnu.org/licenses/>.
  41. + */
  42. +package handlers.targethandlers;
  43. +
  44. +import java.util.Collection;
  45. +import java.util.List;
  46. +
  47. +import javolution.util.FastList;
  48. +
  49. +import com.l2jserver.gameserver.handler.ISkillTargetTypeHandler;
  50. +import com.l2jserver.gameserver.model.L2Object;
  51. +import com.l2jserver.gameserver.model.L2Skill;
  52. +import com.l2jserver.gameserver.model.L2Skill.SkillTargetType;
  53. +import com.l2jserver.gameserver.model.actor.L2Attackable;
  54. +import com.l2jserver.gameserver.model.actor.L2Character;
  55. +import com.l2jserver.gameserver.model.actor.L2Playable;
  56. +import com.l2jserver.gameserver.network.SystemMessageId;
  57. +import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  58. +import com.l2jserver.gameserver.util.Util;
  59. +
  60. +/**
  61. + * @author UnAfraid
  62. + */
  63. +public class TargetAreaFan implements ISkillTargetTypeHandler
  64. +{
  65. +   @Override
  66. +   public L2Object[] getTargetList(L2Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
  67. +   {
  68. +       List<L2Character> targetList = new FastList<L2Character>();
  69. +       if (((target == null || target == activeChar || target.isAlikeDead()) && skill.getCastRange() >= 0) || (!(target instanceof L2Attackable || target instanceof L2Playable)))
  70. +       {
  71. +           activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  72. +           return _emptyTargetList;
  73. +       }
  74. +      
  75. +       final L2Character origin;
  76. +       final boolean srcInArena = (activeChar.isInsideZone(L2Character.ZONE_PVP) && !activeChar.isInsideZone(L2Character.ZONE_SIEGE));
  77. +      
  78. +       if (skill.getCastRange() >= 0)
  79. +       {
  80. +           if (!L2Skill.checkForAreaOffensiveSkills(activeChar, target, skill, srcInArena))
  81. +               return _emptyTargetList;
  82. +          
  83. +           if (onlyFirst)
  84. +               return new L2Character[] { target };
  85. +          
  86. +           origin = target;
  87. +           targetList.add(origin); // Add target to target list
  88. +       }
  89. +       else
  90. +           origin = activeChar;
  91. +      
  92. +       activeChar.setHeading(Util.calculateHeadingFrom(activeChar.getX(), activeChar.getY(), target.getX(), target.getY()));
  93. +      
  94. +       final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharacters();
  95. +       for (L2Character obj : objs)
  96. +       {
  97. +           if (!(obj instanceof L2Attackable || obj instanceof L2Playable))
  98. +               continue;
  99. +          
  100. +           if (obj == origin)
  101. +               continue;
  102. +          
  103. +           if (Util.checkIfInFanRange(skill.getAreaParams()[0], skill.getAreaParams()[1], skill.getAreaParams()[2], skill.getAreaParams()[3], activeChar, obj))
  104. +           {
  105. +               if (!L2Skill.checkForAreaOffensiveSkills(activeChar, obj, skill, srcInArena))
  106. +                   continue;
  107. +              
  108. +               if (skill.getMaxTargets() > -1 && targetList.size() >= skill.getMaxTargets())
  109. +                   break;
  110. +              
  111. +               targetList.add(obj);
  112. +           }
  113. +       }
  114. +      
  115. +       if (targetList.isEmpty())
  116. +           return _emptyTargetList;
  117. +      
  118. +       return targetList.toArray(new L2Character[targetList.size()]);
  119. +   }
  120. +  
  121. +   @Override
  122. +   public Enum<SkillTargetType> getTargetType()
  123. +   {
  124. +       return SkillTargetType.TARGET_AREA_FAN;
  125. +   }
  126. +}
  127. Index: dist/game/data/scripts/handlers/targethandlers/TargetAreaSquare.java
  128. ===================================================================
  129. --- dist/game/data/scripts/handlers/targethandlers/TargetAreaSquare.java    (revision 0)
  130. +++ dist/game/data/scripts/handlers/targethandlers/TargetAreaSquare.java    (revision 0)
  131. @@ -0,0 +1,99 @@
  132. +/*
  133. + * This program is free software: you can redistribute it and/or modify it under
  134. + * the terms of the GNU General Public License as published by the Free Software
  135. + * Foundation, either version 3 of the License, or (at your option) any later
  136. + * version.
  137. + *
  138. + * This program is distributed in the hope that it will be useful, but WITHOUT
  139. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  140. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  141. + * details.
  142. + *
  143. + * You should have received a copy of the GNU General Public License along with
  144. + * this program. If not, see <http://www.gnu.org/licenses/>.
  145. + */
  146. +package handlers.targethandlers;
  147. +
  148. +import java.util.Collection;
  149. +import java.util.List;
  150. +
  151. +import javolution.util.FastList;
  152. +
  153. +import com.l2jserver.gameserver.handler.ISkillTargetTypeHandler;
  154. +import com.l2jserver.gameserver.model.L2Object;
  155. +import com.l2jserver.gameserver.model.L2Skill;
  156. +import com.l2jserver.gameserver.model.L2Skill.SkillTargetType;
  157. +import com.l2jserver.gameserver.model.actor.L2Attackable;
  158. +import com.l2jserver.gameserver.model.actor.L2Character;
  159. +import com.l2jserver.gameserver.model.actor.L2Playable;
  160. +import com.l2jserver.gameserver.network.SystemMessageId;
  161. +import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  162. +import com.l2jserver.gameserver.util.Util;
  163. +
  164. +/**
  165. + * @author UnAfraid
  166. + */
  167. +public class TargetAreaSquare implements ISkillTargetTypeHandler
  168. +{
  169. +   @Override
  170. +   public L2Object[] getTargetList(L2Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
  171. +   {
  172. +       List<L2Character> targetList = new FastList<L2Character>();
  173. +       if (((target == null || target == activeChar || target.isAlikeDead()) && skill.getCastRange() >= 0) || (!(target instanceof L2Attackable || target instanceof L2Playable)))
  174. +       {
  175. +           activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  176. +           return _emptyTargetList;
  177. +       }
  178. +      
  179. +       final L2Character origin;
  180. +       final boolean srcInArena = (activeChar.isInsideZone(L2Character.ZONE_PVP) && !activeChar.isInsideZone(L2Character.ZONE_SIEGE));
  181. +      
  182. +       if (skill.getCastRange() >= 0)
  183. +       {
  184. +           if (!L2Skill.checkForAreaOffensiveSkills(activeChar, target, skill, srcInArena))
  185. +               return _emptyTargetList;
  186. +          
  187. +           if (onlyFirst)
  188. +               return new L2Character[] { target };
  189. +          
  190. +           origin = target;
  191. +           targetList.add(origin); // Add target to target list
  192. +       }
  193. +       else
  194. +           origin = activeChar;
  195. +      
  196. +       activeChar.setHeading(Util.calculateHeadingFrom(activeChar.getX(), activeChar.getY(), target.getX(), target.getY()));
  197. +      
  198. +       final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharacters();
  199. +       for (L2Character obj : objs)
  200. +       {
  201. +           if (!(obj instanceof L2Attackable || obj instanceof L2Playable))
  202. +               continue;
  203. +          
  204. +           if (obj == origin)
  205. +               continue;
  206. +          
  207. +           if (Util.checkIfInSquareRange(skill.getAreaParams()[0], skill.getAreaParams()[1], skill.getAreaParams()[2], skill.getAreaParams()[3], activeChar, obj))
  208. +           {
  209. +               if (!L2Skill.checkForAreaOffensiveSkills(activeChar, obj, skill, srcInArena))
  210. +                   continue;
  211. +              
  212. +               if (skill.getMaxTargets() > -1 && targetList.size() >= skill.getMaxTargets())
  213. +                   break;
  214. +              
  215. +               targetList.add(obj);
  216. +           }
  217. +       }
  218. +      
  219. +       if (targetList.isEmpty())
  220. +           return _emptyTargetList;
  221. +      
  222. +       return targetList.toArray(new L2Character[targetList.size()]);
  223. +   }
  224. +  
  225. +   @Override
  226. +   public Enum<SkillTargetType> getTargetType()
  227. +   {
  228. +       return SkillTargetType.TARGET_AREA_SQUARE;
  229. +   }
  230. +}
  231.  
  232.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement