Skip to content

Interlude Autoshots & Autoarrows + No Consumption

Featured Replies


Code was done by Wyatt, only adapted to aCis.

Testing and working.



### Eclipse Workspace Patch 1.0
#P GameServer_Acis
Index: java/net/sf/l2j/gameserver/handler/itemhandlers/SpiritShot.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/itemhandlers/SpiritShot.java    (revision 26)
+++ java/net/sf/l2j/gameserver/handler/itemhandlers/SpiritShot.java    (working copy)
@@ -14,11 +14,15 @@
  */
 package net.sf.l2j.gameserver.handler.itemhandlers;
 
+import java.util.logging.Level;
+
+import net.sf.l2j.customs.AutoShots.ItemGrade;
 import net.sf.l2j.gameserver.handler.IItemHandler;
 import net.sf.l2j.gameserver.model.L2ItemInstance;
 import net.sf.l2j.gameserver.model.ShotType;
 import net.sf.l2j.gameserver.model.actor.L2Playable;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.holder.SkillHolder;
 import net.sf.l2j.gameserver.network.SystemMessageId;
 import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
 import net.sf.l2j.gameserver.templates.item.L2Weapon;
@@ -44,9 +48,38 @@
         
         final L2PcInstance activeChar = (L2PcInstance) playable;
         final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
+
+        if ((activeChar.getAutoShots() != null))
+        {
+            if (weaponInst != null)
+            {
+                ItemGrade grade = ItemGrade.values()[weaponInst.getItem().getItemGrade()];
+                item = new L2ItemInstance(0, grade.getBlessedSpiritshot());
+            }
+            else if (item == null)
+            {
+                return;
+            }
+        }
+              
         final L2Weapon weaponItem = activeChar.getActiveWeaponItem();
+        final SkillHolder[] skills = item.getItem().getSkills();
         final int itemId = item.getItemId();
         
+        if (skills == null)
+        {
+            _log.log(Level.WARNING, getClass().getSimpleName() + ": is missing skills!");
+            return;
+        }
+        
+        if ((activeChar.getAutoShots() != null) && (weaponInst != null))
+        {
+            activeChar.setChargedShot(ShotType.SPIRITSHOT, true);
+            activeChar.sendPacket(SystemMessageId.ENABLED_SPIRITSHOT);
+            Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, skills[0].getSkillId(), skills[0].getSkillLvl(), 0, 0), 600);
+            return;
+        }
+              
         // Check if sps can be used
         if (weaponInst == null || weaponItem.getSpiritShotCount() == 0)
         {
Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java    (revision 26)
+++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java    (working copy)
@@ -18,6 +18,7 @@
 import java.util.Date;
 
 import net.sf.l2j.Config;
+import net.sf.l2j.customs.AutoShots;
 import net.sf.l2j.gameserver.Announcements;
 import net.sf.l2j.gameserver.GameTimeController;
 import net.sf.l2j.gameserver.SevenSigns;
@@ -172,7 +173,9 @@
         // engage and notify Partner
         if (Config.ALLOW_WEDDING)
             engage(activeChar);
-         
+        
+        new AutoShots(activeChar);
+                      
         final ipCatcher ipc = new ipCatcher();
         if(ipc.isCatched(activeChar))
               activeChar.logout();
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java    (revision 26)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java    (working copy)
@@ -40,6 +40,7 @@
 
 import net.sf.l2j.Config;
 import net.sf.l2j.L2DatabaseFactory;
+import net.sf.l2j.customs.AutoShots;
 import net.sf.l2j.gameserver.Announcements;
 import net.sf.l2j.gameserver.GameTimeController;
 import net.sf.l2j.gameserver.GeoData;
@@ -1891,6 +1892,11 @@
             
             int slot = getInventory().getSlotFromItem(item);
             items = getInventory().unEquipItemInBodySlotAndRecord(slot);
+                                          
+            if (getAutoShots() != null)
+            {
+                _activeSoulShots.clear();
+            }
         }
         else
         {
@@ -1906,7 +1912,15 @@
                 sendPacket(sm);
                 
                 if ((item.getItem().getBodyPart() & L2Item.SLOT_ALLWEAPON) != 0)
+                {
+                    if (getAutoShots() != null)
+                    {
+                        _activeSoulShots.clear();
+                        getAutoShots().updateAutoShots(this);
+                    }
+                
                     rechargeShots(true, true);
+                }
             }
             else
                 sendPacket(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
@@ -7991,8 +8005,18 @@
         for (int itemId : _activeSoulShots)
         {
             L2ItemInstance item = getInventory().getItemByItemId(itemId);
-            if (item != null)
+            if (getAutoShots() != null)
+            {
+                L2ItemInstance shot = new L2ItemInstance(0, ItemTable.getInstance().getTemplate(itemId));
+                IItemHandler handler= ItemHandler.getInstance().getItemHandler(shot.getEtcItem());
+                
+                if (handler != null)
+                {
+                    handler.useItem(this, item, false);
+                }
+            }
+            else if (item != null)
+            {
                 if (magic && item.getItem().getDefaultAction() == L2ActionType.spiritshot)
                 {
                     IItemHandler handler = ItemHandler.getInstance().getItemHandler(item.getEtcItem());
@@ -11347,7 +11371,19 @@
                 player.sendPacket(new RelationChanged(getPet(), getRelation(player), isAutoAttackable(player)));
         }
     }
-    
+    
+    private AutoShots _autoshotss;
+      
+    public AutoShots getAutoShots()
+    {
+        return _autoshotss;
+    }
+      
+    public void setAutoShots(AutoShots _shot)
+    {
+        _autoshotss = _shot;
+    }
+      
     @Override
     public void sendInfo(L2PcInstance activeChar)
     {
Index: java/net/sf/l2j/gameserver/templates/item/L2Item.java
===================================================================
--- java/net/sf/l2j/gameserver/templates/item/L2Item.java    (revision 26)
+++ java/net/sf/l2j/gameserver/templates/item/L2Item.java    (working copy)
@@ -690,6 +690,17 @@
     }
     
     /**
+     * Returns the grade of the item.<BR><BR>
+     * <U><I>Concept :</I></U><BR>
+     * In fact, this fucntion returns the type of crystal of the item.
+     * @return int
+     */
+    public final int getItemGrade()
+    {
+        return getCrystalType();
+    }
+    
+    /**
      * Returns the name of the item
      * @return String
      */
Index: java/net/sf/l2j/gameserver/handler/itemhandlers/SoulShots.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/itemhandlers/SoulShots.java    (revision 26)
+++ java/net/sf/l2j/gameserver/handler/itemhandlers/SoulShots.java    (working copy)
@@ -14,11 +14,15 @@
  */
 package net.sf.l2j.gameserver.handler.itemhandlers;
 
+import java.util.logging.Level;
+
+import net.sf.l2j.customs.AutoShots.ItemGrade;
 import net.sf.l2j.gameserver.handler.IItemHandler;
 import net.sf.l2j.gameserver.model.L2ItemInstance;
 import net.sf.l2j.gameserver.model.ShotType;
 import net.sf.l2j.gameserver.model.actor.L2Playable;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.holder.SkillHolder;
 import net.sf.l2j.gameserver.network.SystemMessageId;
 import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
 import net.sf.l2j.gameserver.templates.item.L2Weapon;
@@ -45,9 +49,38 @@
         
         final L2PcInstance activeChar = (L2PcInstance) playable;
         final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
+                      
+        if (activeChar.getAutoShots() != null)
+        {
+            if (weaponInst != null)
+            {
+                ItemGrade grade = ItemGrade.values()[weaponInst.getItem().getItemGrade()];
+                item = new L2ItemInstance(0, grade.getSoulshot());
+            }
+            else if (item == null)
+            {
+                return;
+            }
+        }
+        
         final L2Weapon weaponItem = activeChar.getActiveWeaponItem();
         final int itemId = item.getItemId();
+        final SkillHolder[] skills = item.getItem().getSkills();
         
+        if (skills == null)
+        {
+            _log.log(Level.WARNING, getClass().getSimpleName() + ": is missing skills!");
+            return;
+        }
+        
+        if ((activeChar.getAutoShots() != null) && (weaponInst != null))
+        {
+            weaponInst.setChargedShot(ShotType.SOULSHOT, true);
+            activeChar.sendPacket(SystemMessageId.ENABLED_SOULSHOT);
+            Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, skills[0].getSkillId(), skills[0].getSkillLvl(), 0, 0), 600);
+            return;
+        }
+              
         // Check if soulshot can be used
         if (weaponInst == null || weaponItem.getSoulShotCount() == 0)
         {
Index: java/net/sf/l2j/customs/AutoShots.java
===================================================================
--- java/net/sf/l2j/customs/AutoShots.java    (revision 0)
+++ java/net/sf/l2j/customs/AutoShots.java    (working copy)
@@ -0,0 +1,64 @@
+package net.sf.l2j.customs;
+
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * @author Wyatt
+ * @Adapted for Interlude BossForever
+ */
+
+public class AutoShots
+{
+       public AutoShots(L2PcInstance activeChar)
+       {
+               updateAutoShots(activeChar);
+               activeChar.setAutoShots(this);
+               activeChar.rechargeShots(true, true);
+       }
+      
+      public void updateAutoShots(L2PcInstance activeChar)
+    {
+        if (getItem(activeChar) != null)
+        {
+            activeChar.addAutoSoulShot(getItem(activeChar).getSoulshot());
+            activeChar.addAutoSoulShot(getItem(activeChar).getBlessedSpiritshot());
+        }
+    }
+    
+    public static ItemGrade getItem(L2PcInstance activeChar)
+    {
+        if (activeChar.getActiveWeaponItem() != null)
+        {
+            return ItemGrade.values()[activeChar.getActiveWeaponItem().getItemGrade()];
+        }
+        return ItemGrade.values()[0];
+    }
+      
+       public enum ItemGrade
+    {
+        NOGRADE(1835, 2509),
+        D(1463, 2510),
+        C(1464, 2511),
+        B(1465, 2512),
+        A(1466, 2513),
+        S(1467, 2514);
+        
+        private int soulshot;
+        private int blessedspiritshot;
+        
+        private ItemGrade(int soulshot_id, int blessedspirit_id)
+        {
+            soulshot = soulshot_id;
+            blessedspiritshot = blessedspirit_id;
+        }    
+        
+        public int getSoulshot()
+        {
+            return soulshot;
+        }
+        
+        public int getBlessedSpiritshot()
+        {
+            return blessedspiritshot;
+        }
+    }
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/model/actor/L2Character.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/L2Character.java    (revision 26)
+++ java/net/sf/l2j/gameserver/model/actor/L2Character.java    (working copy)
@@ -656,7 +656,7 @@
             if (this instanceof L2PcInstance)
             {
                 // Equip arrows needed in left hand and send ItemList to the L2PcINstance then return True
-                if (!checkAndEquipArrows())
+                if ((((L2PcInstance) this).getAutoShots() == null) && !checkAndEquipArrows())
                 {
                     // Cancel the action because the L2PcInstance have no arrow
                     getAI().setIntention(CtrlIntention.IDLE);

Edited by BossAndForever

  • 3 months later...
Would be interesting with ON / OFF in the configs and if activated with a voice command. 

We can improve. ^^

But it is a great code.

  • 2 months later...

After i compile i get error:

      [javac] E:\Documents and Settings\Ffee\Desktop\trunk_328\aCis_gameserver\java\net\sf\l2j\customs\AutoShots.java:15: error: cannot find symbol
    [javac]                activeChar.setAutoShots(this);
    [javac]                          ^
    [javac]   symbol:   method setAutoShots(AutoShots)
    [javac]   location: variable activeChar of type L2PcInstance

------------------------------------------------

    [javac] E:\Documents and Settings\Ffee\Desktop\trunk_328\aCis_gameserver\java\net\sf\l2j\customs\AutoShots.java:32: error: cannot find symbol
    [javac]             return ItemGrade.values()[activeChar.getActiveWeaponItem().getItemGrade()];
    [javac]                                                                       ^
    [javac]   symbol:   method getItemGrade()
    [javac]   location: class Weapon
    [javac] 2 errors

BUILD FAILED

  • 1 year later...

Acis latest free source . What error is this?

 

kt00y.png

Edited by Malossi

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.