Noticias:

No tienes permiso para ver los enlaces. Para poder verlos Registrate o Conectate.

Menú Principal

SS activados automaticamente al loguear

Iniciado por Zoey76, Jul 25, 2025, 12:26 AM

Tema anterior - Siguiente tema

Zoey76

### Automatic Soulshot/Spirishot activation by Zoey76
#P L2J_Server
Index: java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java	(revision 4496)
+++ java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java	(working copy)
@@ -64,6 +64,7 @@
 import com.l2jserver.gameserver.network.communityserver.writepackets.WorldInfo;
 import com.l2jserver.gameserver.network.serverpackets.Die;
 import com.l2jserver.gameserver.network.serverpackets.EtcStatusUpdate;
+import com.l2jserver.gameserver.network.serverpackets.ExAutoSoulShot;
 import com.l2jserver.gameserver.network.serverpackets.ExBasicActionList;
 import com.l2jserver.gameserver.network.serverpackets.ExBirthdayPopup;
 import com.l2jserver.gameserver.network.serverpackets.ExGetBookMarkInfoPacket;
@@ -84,6 +85,7 @@
 import com.l2jserver.gameserver.network.serverpackets.ShortCutInit;
 import com.l2jserver.gameserver.network.serverpackets.SkillCoolTime;
 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
+import com.l2jserver.gameserver.templates.item.L2Item;
 
 
 /**
@@ -490,6 +492,9 @@
 		
 		if(!activeChar.getPremiumItemList().isEmpty())
 			activeChar.sendPacket(new ExNotifyPremiumItem());
+		
+		if (Config.AUTO_ACTIVATE_SHOTS)
+			verifyAndLoadShots(activeChar);
 	}
 	
 	/**
@@ -616,6 +621,90 @@
 			qs.getQuest().notifyEvent("UC", null, player);
 	}
 	
+	/**
+	 * This method will get the correct soulshot/spirishot and activate it for the current weapon if it's over the minimum.
+	 * @param activeChar
+	 * @author Zoey76
+	 */
+	private void verifyAndLoadShots(L2PcInstance activeChar)
+	{
+		int soulId = -1;
+		int spiritId = -1;
+		int bspiritId = -1;
+		
+		if (!activeChar.isDead() && activeChar.getActiveWeaponItem() != null)
+		{
+			switch (activeChar.getActiveWeaponItem().getCrystalType())
+			{
+				case L2Item.CRYSTAL_NONE:
+					soulId = 1835;
+					spiritId = 2509;
+					bspiritId = 3947;
+					break;
+				case L2Item.CRYSTAL_D:
+					soulId = 1463;
+					spiritId = 2510;
+					bspiritId = 3948;
+					break;
+				case L2Item.CRYSTAL_C:
+					soulId = 1464;
+					spiritId = 2511;
+					bspiritId = 3949;
+					break;
+				case L2Item.CRYSTAL_B:
+					soulId = 1465;
+					spiritId = 2512;
+					bspiritId = 3950;
+					break;
+				case L2Item.CRYSTAL_A:
+					soulId = 1466;
+					spiritId = 2513;
+					bspiritId = 3951;
+					break;
+				case L2Item.CRYSTAL_S:
+				case L2Item.CRYSTAL_S80:
+				case L2Item.CRYSTAL_S84:
+					soulId = 1467;
+					spiritId = 2514;
+					bspiritId = 3952;
+					break;
+			}
+			
+			//Soulshots.
+			if ((soulId > -1) && activeChar.getInventory().getInventoryItemCount(soulId, -1) > Config.AUTO_ACTIVATE_SHOTS_MIN)
+			{
+				activeChar.addAutoSoulShot(soulId);
+				activeChar.sendPacket(new ExAutoSoulShot(soulId, 1));
+				//Message
+				SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.USE_OF_S1_WILL_BE_AUTO);
+				sm.addItemName(activeChar.getInventory().getItemByItemId(soulId));
+				activeChar.sendPacket(sm);
+			}
+			
+			//Blessed Spirishots first, then Spirishots.
+			if ((bspiritId > -1) && activeChar.getInventory().getInventoryItemCount(bspiritId, -1) > Config.AUTO_ACTIVATE_SHOTS_MIN)
+			{
+				activeChar.addAutoSoulShot(bspiritId);
+				activeChar.sendPacket(new ExAutoSoulShot(bspiritId, 1));
+				//Message
+				SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.USE_OF_S1_WILL_BE_AUTO);
+				sm.addItemName(activeChar.getInventory().getItemByItemId(bspiritId));
+				activeChar.sendPacket(sm);
+			}
+			else if ((spiritId > -1) && activeChar.getInventory().getInventoryItemCount(spiritId, -1) > Config.AUTO_ACTIVATE_SHOTS_MIN)
+			{
+				activeChar.addAutoSoulShot(spiritId);
+				activeChar.sendPacket(new ExAutoSoulShot(spiritId, 1));
+				//Message
+				SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.USE_OF_S1_WILL_BE_AUTO);
+				sm.addItemName(activeChar.getInventory().getItemByItemId(spiritId));
+				activeChar.sendPacket(sm);
+			}
+			
+			activeChar.rechargeAutoSoulShot(true, true, false);
+		}
+	}
+	
 	/* (non-Javadoc)
 	 * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
 	 */
Index: java/com/l2jserver/Config.java
===================================================================
--- java/com/l2jserver/Config.java	(revision 4496)
+++ java/com/l2jserver/Config.java	(working copy)
@@ -720,6 +720,8 @@
 	public static int L2JMOD_DUALBOX_CHECK_MAX_PLAYERS_PER_IP;
 	public static int L2JMOD_DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP;
 	public static TIntIntHashMap L2JMOD_DUALBOX_CHECK_WHITELIST;
+	public static boolean AUTO_ACTIVATE_SHOTS;
+	public static int AUTO_ACTIVATE_SHOTS_MIN;
 	
 	//--------------------------------------------------
 	// NPC Settings
@@ -2475,6 +2477,9 @@
 							}
 						}
 					}
+					
+					AUTO_ACTIVATE_SHOTS = Boolean.parseBoolean(L2JModSettings.getProperty("AutoActivateShotsEnabled", "False"));;
+					AUTO_ACTIVATE_SHOTS_MIN = Integer.parseInt(L2JModSettings.getProperty("AutoActivateShotsMin", "200"));
 				}
 				catch (Exception e)
 				{
Index: java/config/l2jmods.properties
===================================================================
--- java/config/l2jmods.properties	(revision 4496)
+++ java/config/l2jmods.properties	(working copy)
@@ -386,7 +386,6 @@
 # Default: 
 MultiLangSystemMessageAllowed = 
 
-
 # ---------------------------------------------------------------------------
 # Walker/Bot protection
 # ---------------------------------------------------------------------------
@@ -426,3 +425,11 @@
 # will be 1+2=3. Use 0 or negative value for unlimited number of connections.
 # Default: 127.0.0.1,0 (no limits from localhost)
 DualboxCheckWhitelist = 127.0.0.1,0
+
+# Automatic activation of soulshots/spiritshots on player log in.
+# Default: False
+AutoActivateShotsEnabled = True
+
+# Minimum shots needed to activate (make it over 100)
+# Default: 200
+AutoActivateShotsMin = 200