Advertisement
crymxz

Agathion Interlude aCis 401 Core v2

Jul 13th, 2023
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 21.76 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis
  3. diff --git aCis_game/config/npcs.properties aCis_game/config/npcs.properties
  4. index c05f8a9..2eea0f1 100644
  5. --- aCis_game/config/npcs.properties
  6. +++ aCis_game/config/npcs.properties
  7. @@ -201,4 +201,19 @@
  8.  MinNPCAnimation = 20
  9.  MaxNPCAnimation = 40
  10.  MinMonsterAnimation = 10
  11. -MaxMonsterAnimation = 40
  12. \ No newline at end of file
  13. +MaxMonsterAnimation = 40
  14. +
  15. +# id of the skill to cast when the summon item is used, the standard skill is 2046 of all pets
  16. +SkillIdUseCastAgathion = 2046
  17. +
  18. +# It just follows the owner without doing any random social actions or movements.
  19. +AgathionOnlyFollow = False
  20. +
  21. +# Allow social action if the npc has any, every 1s has a 10% chance to perform a social action
  22. +AgathionAllowSocial = True
  23. +
  24. +# Heal the owner, only heal when he is not in certain conditions, pvp, with karma, oly, duel, pvp zone.
  25. +AgathionHealOwner = False
  26. +
  27. +# Percentage of health for when it will start healing the owner. 0.25 = 25%
  28. +AgathionPercentToHeal = 0.25
  29. \ No newline at end of file
  30. diff --git aCis_game/java/net/sf/l2j/Config.java aCis_game/java/net/sf/l2j/Config.java
  31. index 65daaa6..c0b79d0 100644
  32. --- aCis_game/java/net/sf/l2j/Config.java
  33. +++ aCis_game/java/net/sf/l2j/Config.java
  34. @@ -326,6 +326,13 @@
  35.     public static int MIN_MONSTER_ANIMATION;
  36.     public static int MAX_MONSTER_ANIMATION;
  37.    
  38. +   /** Agathion */
  39. +   public static int SKILL_ID_AGATHION;
  40. +   public static boolean AGATHION_ONLY_FOLLOW;
  41. +   public static boolean AGATHION_ALLOW_SOCIAL;
  42. +   public static boolean AGATHION_HEAL_OWNER;
  43. +   public static double AGATHION_PERCENT_TO_HEAL;
  44. +  
  45.     // --------------------------------------------------
  46.     // Players
  47.     // --------------------------------------------------
  48. @@ -949,6 +956,12 @@
  49.         MAX_NPC_ANIMATION = npcs.getProperty("MaxNPCAnimation", 40);
  50.         MIN_MONSTER_ANIMATION = npcs.getProperty("MinMonsterAnimation", 10);
  51.         MAX_MONSTER_ANIMATION = npcs.getProperty("MaxMonsterAnimation", 40);
  52. +      
  53. +       SKILL_ID_AGATHION = npcs.getProperty("SkillIdUseCastAgathion", 2046);
  54. +       AGATHION_ONLY_FOLLOW = npcs.getProperty("AgathionOnlyFollow", false);
  55. +       AGATHION_ALLOW_SOCIAL = npcs.getProperty("AgathionAllowSocial", true);
  56. +       AGATHION_HEAL_OWNER = npcs.getProperty("AgathionHealOwner", false);
  57. +       AGATHION_PERCENT_TO_HEAL = npcs.getProperty("AgathionPercentToHeal", 0.25);
  58.     }
  59.    
  60.     /**
  61. diff --git aCis_game/java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java aCis_game/java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
  62. index 1792260..268ba86 100644
  63. --- aCis_game/java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
  64. +++ aCis_game/java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
  65. @@ -2,6 +2,7 @@
  66.  
  67.  import java.util.List;
  68.  
  69. +import net.sf.l2j.Config;
  70.  import net.sf.l2j.gameserver.data.SkillTable;
  71.  import net.sf.l2j.gameserver.data.xml.NpcData;
  72.  import net.sf.l2j.gameserver.data.xml.SummonItemData;
  73. @@ -41,6 +42,25 @@
  74.        
  75.         final IntIntHolder sitem = SummonItemData.getInstance().getSummonItem(item.getItemId());
  76.        
  77. +       final NpcTemplate npcTemplate = NpcData.getInstance().getTemplate(sitem.getId());
  78. +       if (npcTemplate == null)
  79. +           return;
  80. +      
  81. +       if (npcTemplate.getType().equalsIgnoreCase("Agathion"))
  82. +       {
  83. +           if (player.getAgathion() != null)
  84. +           {
  85. +               player.getAgathion().unSummon(player);
  86. +               item.setAgathion(player, false);
  87. +               player.sendMessage("Agathion has been unsummoned");
  88. +               return;
  89. +           }
  90. +           item.setAgathion(player, true);
  91. +           item.checkProtected(player);
  92. +           player.getAI().tryToCast(player, SkillTable.getInstance().getInfo(Config.SKILL_ID_AGATHION, 1), false, false, item.getObjectId());
  93. +           return;
  94. +       }
  95. +      
  96.         if ((player.getSummon() != null || player.isMounted()) && sitem.getValue() > 0)
  97.         {
  98.             player.sendPacket(SystemMessageId.SUMMON_ONLY_ONE);
  99. @@ -53,10 +73,6 @@
  100.             return;
  101.         }
  102.        
  103. -       final NpcTemplate npcTemplate = NpcData.getInstance().getTemplate(sitem.getId());
  104. -       if (npcTemplate == null)
  105. -           return;
  106. -      
  107.         switch (sitem.getValue())
  108.         {
  109.             case 0: // static summons (like Christmas tree)
  110. diff --git aCis_game/java/net/sf/l2j/gameserver/handler/skillhandlers/SummonCreature.java aCis_game/java/net/sf/l2j/gameserver/handler/skillhandlers/SummonCreature.java
  111. index 30cc469..3881cd3 100644
  112. --- aCis_game/java/net/sf/l2j/gameserver/handler/skillhandlers/SummonCreature.java
  113. +++ aCis_game/java/net/sf/l2j/gameserver/handler/skillhandlers/SummonCreature.java
  114. @@ -6,10 +6,12 @@
  115.  import net.sf.l2j.gameserver.enums.skills.SkillType;
  116.  import net.sf.l2j.gameserver.geoengine.GeoEngine;
  117.  import net.sf.l2j.gameserver.handler.ISkillHandler;
  118. +import net.sf.l2j.gameserver.idfactory.IdFactory;
  119.  import net.sf.l2j.gameserver.model.World;
  120.  import net.sf.l2j.gameserver.model.WorldObject;
  121.  import net.sf.l2j.gameserver.model.actor.Creature;
  122.  import net.sf.l2j.gameserver.model.actor.Player;
  123. +import net.sf.l2j.gameserver.model.actor.instance.Agathion;
  124.  import net.sf.l2j.gameserver.model.actor.instance.Pet;
  125.  import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  126.  import net.sf.l2j.gameserver.model.holder.IntIntHolder;
  127. @@ -41,10 +43,6 @@
  128.         if (item.getOwnerId() != player.getObjectId() || item.getLocation() != ItemLocation.INVENTORY)
  129.             return;
  130.        
  131. -       // Owner has a pet listed in world.
  132. -       if (World.getInstance().getPet(player.getObjectId()) != null)
  133. -           return;
  134. -      
  135.         // Check summon item validity.
  136.         final IntIntHolder summonItem = SummonItemData.getInstance().getSummonItem(item.getItemId());
  137.         if (summonItem == null)
  138. @@ -55,6 +53,34 @@
  139.         if (npcTemplate == null)
  140.             return;
  141.        
  142. +       if (npcTemplate.getType().equalsIgnoreCase("Agathion"))
  143. +       {
  144. +           if (player.getAgathion() != null)
  145. +               player.getAgathion().unSummon(player);
  146. +          
  147. +           Agathion summon;
  148. +           summon = new Agathion(IdFactory.getInstance().getNextId(), npcTemplate, player);
  149. +           player.setAgathion(summon);
  150. +          
  151. +           summon.getStatus().setMaxHpMp();
  152. +           summon.forceRunStance();
  153. +          
  154. +           final SpawnLocation spawnLoc = activeChar.getPosition().clone();
  155. +           spawnLoc.addStrictOffset(40);
  156. +           spawnLoc.setHeadingTo(activeChar.getPosition());
  157. +           spawnLoc.set(GeoEngine.getInstance().getValidLocation(activeChar, spawnLoc));
  158. +          
  159. +           summon.spawnMe(spawnLoc);
  160. +           summon.setInvul(true);
  161. +           summon.getAI().setFollowStatus(true);
  162. +           item.setAgathionItem(player);
  163. +           return;
  164. +       }
  165. +      
  166. +       // Owner has a pet listed in world.
  167. +       if (World.getInstance().getPet(player.getObjectId()) != null)
  168. +           return;
  169. +      
  170.         // Add the pet instance to world.
  171.         final Pet pet = Pet.restore(item, npcTemplate, player);
  172.         if (pet == null)
  173. diff --git aCis_game/java/net/sf/l2j/gameserver/model/actor/Player.java aCis_game/java/net/sf/l2j/gameserver/model/actor/Player.java
  174. index 023516a..64c28dd 100644
  175. --- aCis_game/java/net/sf/l2j/gameserver/model/actor/Player.java
  176. +++ aCis_game/java/net/sf/l2j/gameserver/model/actor/Player.java
  177. @@ -107,6 +107,7 @@
  178.  import net.sf.l2j.gameserver.model.actor.container.player.Request;
  179.  import net.sf.l2j.gameserver.model.actor.container.player.ShortcutList;
  180.  import net.sf.l2j.gameserver.model.actor.container.player.SubClass;
  181. +import net.sf.l2j.gameserver.model.actor.instance.Agathion;
  182.  import net.sf.l2j.gameserver.model.actor.instance.Door;
  183.  import net.sf.l2j.gameserver.model.actor.instance.FestivalMonster;
  184.  import net.sf.l2j.gameserver.model.actor.instance.Folk;
  185. @@ -373,6 +374,7 @@
  186.     private final QuestList _questList = new QuestList(this);
  187.    
  188.     private Summon _summon;
  189. +   private Agathion aga;
  190.     private TamedBeast _tamedBeast;
  191.    
  192.     private int _partyRoom;
  193. @@ -6489,6 +6491,9 @@
  194.             else if (_summon != null)
  195.                 _summon.unSummon(this);
  196.            
  197. +           if (getAgathion() != null)
  198. +               aga.unSummon(this);
  199. +          
  200.             // Stop all scheduled tasks.
  201.             stopChargeTask();
  202.            
  203. @@ -7407,4 +7412,14 @@
  204.        
  205.         return gms;
  206.     }
  207. +  
  208. +   public void setAgathion(Agathion aga)
  209. +   {
  210. +       this.aga = aga;
  211. +   }
  212. +  
  213. +   public Agathion getAgathion()
  214. +   {
  215. +       return aga;
  216. +   }
  217.  }
  218. \ No newline at end of file
  219. diff --git aCis_game/java/net/sf/l2j/gameserver/model/actor/cast/PlayerCast.java aCis_game/java/net/sf/l2j/gameserver/model/actor/cast/PlayerCast.java
  220. index f666547..778fc12 100644
  221. --- aCis_game/java/net/sf/l2j/gameserver/model/actor/cast/PlayerCast.java
  222. +++ aCis_game/java/net/sf/l2j/gameserver/model/actor/cast/PlayerCast.java
  223. @@ -273,7 +273,7 @@
  224.         switch (skill.getSkillType())
  225.         {
  226.             case SUMMON:
  227. -               if (!((L2SkillSummon) skill).isCubic() && (_actor.getSummon() != null || _actor.isMounted()))
  228. +               if (!((L2SkillSummon) skill).isAgathion() && !((L2SkillSummon) skill).isCubic() && (_actor.getSummon() != null || _actor.isMounted()))
  229.                 {
  230.                     _actor.sendPacket(SystemMessageId.SUMMON_ONLY_ONE);
  231.                     return false;
  232. diff --git aCis_game/java/net/sf/l2j/gameserver/model/actor/instance/Agathion.java aCis_game/java/net/sf/l2j/gameserver/model/actor/instance/Agathion.java
  233. new file mode 100644
  234. index 0000000..584ac24
  235. --- /dev/null
  236. +++ aCis_game/java/net/sf/l2j/gameserver/model/actor/instance/Agathion.java
  237. @@ -0,0 +1,133 @@
  238. +package net.sf.l2j.gameserver.model.actor.instance;
  239. +
  240. +import java.util.concurrent.Future;
  241. +
  242. +import net.sf.l2j.commons.math.MathUtil;
  243. +import net.sf.l2j.commons.pool.ThreadPool;
  244. +import net.sf.l2j.commons.random.Rnd;
  245. +
  246. +import net.sf.l2j.Config;
  247. +import net.sf.l2j.gameserver.enums.ZoneId;
  248. +import net.sf.l2j.gameserver.model.actor.Npc;
  249. +import net.sf.l2j.gameserver.model.actor.Player;
  250. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  251. +import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
  252. +import net.sf.l2j.gameserver.model.location.Location;
  253. +import net.sf.l2j.gameserver.model.location.SpawnLocation;
  254. +import net.sf.l2j.gameserver.network.serverpackets.PetDelete;
  255. +import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
  256. +
  257. +/**
  258. + * @author maxi5
  259. + *
  260. + */
  261. +public class Agathion extends Npc
  262. +{
  263. +   private Player _owner;
  264. +   private Future<?> _followTask;
  265. +  
  266. +   private ItemInstance item;
  267. +  
  268. +   public Agathion(int objectId, NpcTemplate template, Player owner)
  269. +   {
  270. +       super(objectId, template);
  271. +      
  272. +        // Set the magical circle animation.
  273. +       setShowSummonAnimation(true);
  274. +      
  275. +       // Set the Player owner.
  276. +       _owner = owner;
  277. +   }
  278. +  
  279. +   @Override
  280. +   public void onSpawn()
  281. +   {
  282. +       followToOwner();
  283. +       super.onSpawn();
  284. +   }
  285. +  
  286. +   public void unSummon(Player owner)
  287. +   {
  288. +       // Abort attack, cast and move.
  289. +       abortAll(true);
  290. +      
  291. +       if (item != null)
  292. +           item.setAgathion(owner, false);
  293. +      
  294. +       owner.sendPacket(new PetDelete(2, getObjectId()));
  295. +       owner.setAgathion(null);
  296. +      
  297. +       if (owner.getSummon() != null)
  298. +           owner.getSummon().sendInfo(owner);
  299. +       owner.broadcastUserInfo();
  300. +      
  301. +       if (_followTask != null)
  302. +           _followTask.cancel(true);
  303. +      
  304. +       decayMe();
  305. +       deleteMe();
  306. +      
  307. +       super.deleteMe();
  308. +   }
  309. +  
  310. +   public void followToOwner()
  311. +   {
  312. +       if (_followTask == null)
  313. +           _followTask = ThreadPool.scheduleAtFixedRate(new Follow(this), 1000, 1000);
  314. +      
  315. +       SpawnLocation loc = _owner.getPosition();
  316. +       final int rnd = Rnd.get(-30, +30);
  317. +       final boolean action = Rnd.get(100) < 15;
  318. +
  319. +       if (!checkIfInRange(2000, this, _owner))
  320. +           teleportTo(_owner.getPosition(), 30);
  321. +       else if (!checkIfInRange(1000, this, _owner))
  322. +           instantTeleportTo(_owner.getPosition(), 30);
  323. +      
  324. +       if (_owner.isMoving())
  325. +           getAI().tryToFollow(_owner, false);
  326. +       else
  327. +       {
  328. +           if (checkIfInRange(30, this, _owner))
  329. +               getAI().tryToIdle();
  330. +           if (!Config.AGATHION_ONLY_FOLLOW && (!checkIfInRange(75, this, _owner) || action))
  331. +               getAI().tryToMoveTo(new Location(loc.getX()+rnd, loc.getY()+rnd, loc.getZ()), null);
  332. +           if (Config.AGATHION_HEAL_OWNER && !action && !getCast().isCastingNow())
  333. +           {
  334. +               if (_owner.isInOlympiadMode() || _owner.isInDuel() || _owner.getPvpFlag() != 0 || _owner.isInsideZone(ZoneId.PVP) || _owner.getKarma() != 0)
  335. +                   return;
  336. +              
  337. +               if ((_owner.getStatus().getHpRatio() < Config.AGATHION_PERCENT_TO_HEAL))
  338. +                   getAI().tryToCast(_owner, 1011, 18);
  339. +           }
  340. +           else if (!Config.AGATHION_ONLY_FOLLOW && Config.AGATHION_ALLOW_SOCIAL && !isMoving() && action && !getCast().isCastingNow())
  341. +               broadcastPacket(new SocialAction(this, 1));
  342. +       }
  343. +   }
  344. +
  345. +   private static class Follow implements Runnable
  346. +   {
  347. +       private final Agathion agathion;
  348. +      
  349. +       protected Follow(Agathion aga)
  350. +       {
  351. +           agathion = aga;
  352. +       }
  353. +      
  354. +       @Override
  355. +       public void run()
  356. +       {
  357. +           agathion.followToOwner();
  358. +       }  
  359. +   }
  360. +  
  361. +   public static boolean checkIfInRange(int range, Npc npc, Player player)
  362. +   {
  363. +       return MathUtil.checkIfInRange((int) (range + npc.getCollisionRadius()), npc, player, true);
  364. +   }
  365. +  
  366. +   public void setAgathionItem(ItemInstance item)
  367. +   {
  368. +       this.item = item;
  369. +   }
  370. +}
  371. \ No newline at end of file
  372. diff --git aCis_game/java/net/sf/l2j/gameserver/model/item/instance/ItemInstance.java aCis_game/java/net/sf/l2j/gameserver/model/item/instance/ItemInstance.java
  373. index 8429f78..940e74b 100644
  374. --- aCis_game/java/net/sf/l2j/gameserver/model/item/instance/ItemInstance.java
  375. +++ aCis_game/java/net/sf/l2j/gameserver/model/item/instance/ItemInstance.java
  376. @@ -4,6 +4,7 @@
  377.  import java.sql.PreparedStatement;
  378.  import java.sql.ResultSet;
  379.  import java.util.List;
  380. +import java.util.concurrent.Future;
  381.  import java.util.concurrent.ScheduledFuture;
  382.  import java.util.concurrent.locks.ReentrantLock;
  383.  import java.util.logging.Level;
  384. @@ -104,6 +105,9 @@
  385.    
  386.     private int _shotsMask = 0;
  387.    
  388. +   private boolean isAgathion;
  389. +   private Future<?> _protectedTask;
  390. +  
  391.     /**
  392.      * Constructor of the ItemInstance from the objectId and the itemId.
  393.      * @param objectId : int designating the ID of the object in the world
  394. @@ -487,7 +491,7 @@
  395.      */
  396.     public boolean isDropable()
  397.     {
  398. -       return isAugmented() ? false : _item.isDropable();
  399. +       return isAgathion || isAugmented() ? false : _item.isDropable();
  400.     }
  401.    
  402.     /**
  403. @@ -495,7 +499,7 @@
  404.      */
  405.     public boolean isDestroyable()
  406.     {
  407. -       return isQuestItem() ? false : _item.isDestroyable();
  408. +       return isAgathion || isQuestItem() ? false : _item.isDestroyable();
  409.     }
  410.    
  411.     /**
  412. @@ -503,7 +507,7 @@
  413.      */
  414.     public boolean isTradable()
  415.     {
  416. -       return isAugmented() ? false : _item.isTradable();
  417. +       return isAgathion || isAugmented() ? false : _item.isTradable();
  418.     }
  419.    
  420.     /**
  421. @@ -521,7 +525,7 @@
  422.     public boolean isDepositable(boolean isPrivateWareHouse)
  423.     {
  424.         // equipped, hero and quest items
  425. -       if (isEquipped() || !_item.isDepositable())
  426. +       if (isEquipped() || !_item.isDepositable() || isAgathion)
  427.             return false;
  428.        
  429.         if (!isPrivateWareHouse)
  430. @@ -1275,4 +1279,47 @@
  431.        
  432.         return Integer.compare(item.getObjectId(), getObjectId());
  433.     }
  434. +  
  435. +   public void setAgathion(Player player, boolean isAgathion)
  436. +   {
  437. +       this.isAgathion = isAgathion;
  438. +   }
  439. +  
  440. +   public void checkProtected(Player player)
  441. +   {
  442. +       if (_protectedTask != null)
  443. +           _protectedTask.cancel(true);
  444. +       _protectedTask = ThreadPool.schedule(new Protected(player), 5500);
  445. +   }
  446. +
  447. +   public boolean isAgathion()
  448. +   {
  449. +       return isAgathion;
  450. +   }
  451. +  
  452. +   public void setAgathionItem(Player player)
  453. +   {
  454. +       player.getAgathion().setAgathionItem(this);
  455. +   }  
  456. +
  457. +   private class Protected implements Runnable
  458. +   {
  459. +       private final Player player;
  460. +      
  461. +       protected Protected(Player player)
  462. +       {
  463. +           this.player = player;
  464. +       }
  465. +      
  466. +       @Override
  467. +       public void run()
  468. +       {
  469. +           if (player.getAgathion() != null)
  470. +               isAgathion = true;
  471. +           else
  472. +               isAgathion = false;
  473. +           if (_protectedTask != null)
  474. +               _protectedTask.cancel(true);
  475. +       }
  476. +   }
  477.  }
  478. \ No newline at end of file
  479. diff --git aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/Action.java aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/Action.java
  480. index e963ca2..781a634 100644
  481. --- aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/Action.java
  482. +++ aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/Action.java
  483. @@ -3,6 +3,7 @@
  484.  import net.sf.l2j.gameserver.model.World;
  485.  import net.sf.l2j.gameserver.model.WorldObject;
  486.  import net.sf.l2j.gameserver.model.actor.Player;
  487. +import net.sf.l2j.gameserver.model.actor.instance.Agathion;
  488.  import net.sf.l2j.gameserver.model.entity.Duel.DuelState;
  489.  import net.sf.l2j.gameserver.network.SystemMessageId;
  490.  import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  491. @@ -57,6 +58,12 @@
  492.             return;
  493.         }
  494.        
  495. +       if (target instanceof Agathion)
  496. +       {
  497. +           player.sendPacket(ActionFailed.STATIC_PACKET);
  498. +           return;
  499. +       }
  500. +      
  501.         target.onAction(player, false, _isShiftAction);
  502.     }
  503.    
  504. diff --git aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/AttackRequest.java aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/AttackRequest.java
  505. index 5bbd7e8..e091a24 100644
  506. --- aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/AttackRequest.java
  507. +++ aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/AttackRequest.java
  508. @@ -3,6 +3,7 @@
  509.  import net.sf.l2j.gameserver.model.World;
  510.  import net.sf.l2j.gameserver.model.WorldObject;
  511.  import net.sf.l2j.gameserver.model.actor.Player;
  512. +import net.sf.l2j.gameserver.model.actor.instance.Agathion;
  513.  import net.sf.l2j.gameserver.network.SystemMessageId;
  514.  import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  515.  
  516. @@ -54,6 +55,12 @@
  517.             return;
  518.         }
  519.        
  520. +       if (target instanceof Agathion)
  521. +       {
  522. +           player.sendPacket(ActionFailed.STATIC_PACKET);
  523. +           return;
  524. +       }
  525. +      
  526.         // (player.getTarget() == target) -> This happens when you control + click a target without having had it selected beforehand. Behaves as the Action packet and will NOT trigger an attack.
  527.         target.onAction(player, (player.getTarget() == target), _isShiftAction);
  528.     }
  529. diff --git aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/RequestDestroyItem.java aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/RequestDestroyItem.java
  530. index b9c239f..b603b41 100644
  531. --- aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/RequestDestroyItem.java
  532. +++ aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/RequestDestroyItem.java
  533. @@ -58,6 +58,12 @@
  534.             return;
  535.         }
  536.        
  537. +       if (itemToRemove.isAgathion())
  538. +       {
  539. +           player.sendPacket(SystemMessageId.CANNOT_DISCARD_THIS_ITEM);
  540. +           return;
  541. +       }
  542. +      
  543.         if (itemToRemove.isEquipped() && (!itemToRemove.isStackable() || (itemToRemove.isStackable() && _count >= itemToRemove.getCount())))
  544.         {
  545.             final ItemInstance[] unequipped = player.getInventory().unequipItemInSlotAndRecord(itemToRemove.getLocationSlot());
  546. diff --git aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/RequestDropItem.java aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/RequestDropItem.java
  547. index 6fc1ab5..1f91749 100644
  548. --- aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/RequestDropItem.java
  549. +++ aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/RequestDropItem.java
  550. @@ -48,7 +48,7 @@
  551.         if (item.isQuestItem())
  552.             return;
  553.        
  554. -       if (_count > item.getCount())
  555. +       if (_count > item.getCount() || item.isAgathion())
  556.         {
  557.             player.sendPacket(SystemMessageId.CANNOT_DISCARD_THIS_ITEM);
  558.             return;
  559. diff --git aCis_game/java/net/sf/l2j/gameserver/skills/l2skills/L2SkillSummon.java aCis_game/java/net/sf/l2j/gameserver/skills/l2skills/L2SkillSummon.java
  560. index cf1d5e5..d0942ad 100644
  561. --- aCis_game/java/net/sf/l2j/gameserver/skills/l2skills/L2SkillSummon.java
  562. +++ aCis_game/java/net/sf/l2j/gameserver/skills/l2skills/L2SkillSummon.java
  563. @@ -13,6 +13,7 @@
  564.  import net.sf.l2j.gameserver.model.actor.Creature;
  565.  import net.sf.l2j.gameserver.model.actor.Player;
  566.  import net.sf.l2j.gameserver.model.actor.Summon;
  567. +import net.sf.l2j.gameserver.model.actor.instance.Agathion;
  568.  import net.sf.l2j.gameserver.model.actor.instance.Servitor;
  569.  import net.sf.l2j.gameserver.model.actor.instance.SiegeSummon;
  570.  import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  571. @@ -25,6 +26,7 @@
  572.     private final int _npcId;
  573.     private final float _expPenalty;
  574.     private final boolean _isCubic;
  575. +   private final boolean _isAgathion;
  576.    
  577.     private final int _activationTime;
  578.     private final int _activationChance;
  579. @@ -47,6 +49,7 @@
  580.         _npcId = set.getInteger("npcId", 0); // default for undescribed skills
  581.         _expPenalty = set.getFloat("expPenalty", 0.f);
  582.         _isCubic = set.getBool("isCubic", false);
  583. +       _isAgathion = set.getBool("isAgathion", false);
  584.        
  585.         _activationTime = set.getInteger("activationtime", 8);
  586.         _activationChance = set.getInteger("activationchance", 30);
  587. @@ -84,7 +87,7 @@
  588.                 if (player.isInObserverMode())
  589.                     return false;
  590.                
  591. -               if (player.getSummon() != null)
  592. +               if (!_isAgathion && player.getSummon() != null)
  593.                 {
  594.                     player.sendPacket(SystemMessageId.SUMMON_ONLY_ONE);
  595.                     return false;
  596. @@ -130,6 +133,34 @@
  597.         }
  598.         else
  599.         {
  600. +           if (_isAgathion)
  601. +           {
  602. +               NpcTemplate summonTemplate = NpcData.getInstance().getTemplate(_npcId);
  603. +
  604. +               if (summonTemplate == null)
  605. +               {
  606. +                   LOGGER.warn("Couldn't properly spawn with id {} ; the template is missing.", _npcId);
  607. +                   return;
  608. +               }
  609. +               if (activeChar.getAgathion() != null)
  610. +                   activeChar.getAgathion().unSummon(activeChar);
  611. +               Agathion summon;
  612. +               summon = new Agathion(IdFactory.getInstance().getNextId(), summonTemplate, activeChar);
  613. +               activeChar.setAgathion(summon);
  614. +               summon.getStatus().setMaxHpMp();
  615. +               summon.forceRunStance();
  616. +              
  617. +               final SpawnLocation spawnLoc = activeChar.getPosition().clone();
  618. +               spawnLoc.addStrictOffset(40);
  619. +               spawnLoc.setHeadingTo(activeChar.getPosition());
  620. +               spawnLoc.set(GeoEngine.getInstance().getValidLocation(activeChar, spawnLoc));
  621. +              
  622. +               summon.spawnMe(spawnLoc);
  623. +               summon.setInvul(true);
  624. +               summon.getAI().setFollowStatus(true);
  625. +               return;
  626. +           }
  627. +          
  628.             if (activeChar.getSummon() != null || activeChar.isMounted())
  629.                 return;
  630.            
  631. @@ -174,6 +205,11 @@
  632.         return _isCubic;
  633.     }
  634.    
  635. +   public final boolean isAgathion()
  636. +   {
  637. +       return _isAgathion;
  638. +   }
  639. +  
  640.     public final int getTotalLifeTime()
  641.     {
  642.         return _summonTotalLifeTime;
  643.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement