Browse Source

Life to Soul Skill implementation (thanks ndb)

yellowperil 17 years ago
parent
commit
1cc2ef5bd7

+ 2 - 0
L2_GameServer_T1/java/net/sf/l2j/gameserver/GameServer.java

@@ -177,6 +177,7 @@ import net.sf.l2j.gameserver.handler.skillhandlers.Recall;
 import net.sf.l2j.gameserver.handler.skillhandlers.Resurrect;
 import net.sf.l2j.gameserver.handler.skillhandlers.SiegeFlag;
 import net.sf.l2j.gameserver.handler.skillhandlers.Signets;
+import net.sf.l2j.gameserver.handler.skillhandlers.Soul;
 import net.sf.l2j.gameserver.handler.skillhandlers.Sow;
 import net.sf.l2j.gameserver.handler.skillhandlers.Spoil;
 import net.sf.l2j.gameserver.handler.skillhandlers.StrSiegeAssault;
@@ -528,6 +529,7 @@ public class GameServer
         _skillHandler.registerSkillHandler(new BeastFeed());
         _skillHandler.registerSkillHandler(new DeluxeKey());
         _skillHandler.registerSkillHandler(new Sow());
+        _skillHandler.registerSkillHandler(new Soul());
         _skillHandler.registerSkillHandler(new Harvest());
         _skillHandler.registerSkillHandler(new Signets());
         _skillHandler.registerSkillHandler(new GetPlayer());

+ 75 - 0
L2_GameServer_T1/java/net/sf/l2j/gameserver/handler/skillhandlers/Soul.java

@@ -0,0 +1,75 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package net.sf.l2j.gameserver.handler.skillhandlers; 
+
+import net.sf.l2j.gameserver.datatables.SkillTable;
+import net.sf.l2j.gameserver.handler.ISkillHandler;
+import net.sf.l2j.gameserver.model.L2Character;
+import net.sf.l2j.gameserver.model.L2Object;
+import net.sf.l2j.gameserver.model.L2Skill;
+import net.sf.l2j.gameserver.model.L2Skill.SkillType;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.network.SystemMessageId;
+import net.sf.l2j.gameserver.serverpackets.SystemMessage;
+
+/**
+ * 
+ * @author nBd
+ */
+
+public class Soul implements ISkillHandler
+{
+    private static final SkillType[] SKILL_IDS = { SkillType.CHARGESOUL };
+    
+    public void useSkill(L2Character activeChar, L2Skill skill, @SuppressWarnings("unused") L2Object[] targets)
+    {
+        if (activeChar == null || activeChar.isAlikeDead() || !(activeChar instanceof L2PcInstance))
+            return;
+        
+        L2PcInstance player = (L2PcInstance)activeChar;
+        
+        L2Skill soulmastery = SkillTable.getInstance().getInfo(467, player.getSkillLevel(467));
+        
+        if (soulmastery != null)
+        {
+            if (player.getSouls() < soulmastery.getNumSouls())
+            {
+                int count = 0;
+                
+                if (player.getSouls() + skill.getNumSouls() <= soulmastery.getNumSouls())
+                    count = skill.getNumSouls();
+                else
+                    count = soulmastery.getNumSouls() - player.getSouls();
+                
+                player.increaseSouls(count);
+            }
+            else
+            {
+                SystemMessage sm = new SystemMessage(SystemMessageId.SOUL_CANNOT_BE_INCREASED_ANYMORE);
+                player.sendPacket(sm);
+                return;
+            }
+        }
+    }
+    
+    public SkillType[] getSkillIds() 
+    { 
+        return SKILL_IDS; 
+    }
+}

+ 1 - 1
L2_GameServer_T1/java/net/sf/l2j/gameserver/model/L2Character.java

@@ -5578,7 +5578,7 @@ public abstract class L2Character extends L2Object
             {
                 if (this instanceof L2PcInstance)
                 {
-                    ((L2PcInstance)this).decreaseAbsorbedSouls(skill.getSoulConsumeCount());
+                    ((L2PcInstance)this).decreaseSouls(skill.getSoulConsumeCount());
                     sendPacket(new EtcStatusUpdate((L2PcInstance)this));
                 }
             }

+ 1 - 0
L2_GameServer_T1/java/net/sf/l2j/gameserver/model/L2Skill.java

@@ -232,6 +232,7 @@ public abstract class L2Skill
     	SEED (L2SkillSeed.class),
     	BEAST_FEED,
     	FORCE_BUFF,
+       CHARGESOUL,
         
         // Kamael WeaponChange
         CHANGEWEAPON (L2SkillChangeWeapon.class),

+ 114 - 20
L2_GameServer_T1/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java

@@ -535,8 +535,9 @@ public final class L2PcInstance extends L2PlayableInstance
 	//Death Penalty Buff Level
 	private int _deathPenaltyBuffLevel = 0;
 
-	//Absorbed Souls
-    private int _absorbedSouls = 0;
+	// Absorbed Souls
+    private int _souls = 0;
+    private ScheduledFuture<?> _soulTask = null;
 
 	//GM related variables
 	private boolean _isGm;
@@ -4962,7 +4963,8 @@ public final class L2PcInstance extends L2PlayableInstance
 		stopWaterTask();
 		stopRentPet();
 		stopPvpRegTask();
-        stopJailTask(true);
+		stopJailTask(true);
+		stopSoulTask();
 	}
 
 	/**
@@ -7402,7 +7404,7 @@ public final class L2PcInstance extends L2PlayableInstance
         // Check if spell consumes a Soul
         if (skill.getSoulConsumeCount() > 0)
         {
-            if (getAbsorbedSouls() < skill.getSoulConsumeCount())
+            if (getSouls() < skill.getSoulConsumeCount())
             {
                 sendPacket(new SystemMessage(SystemMessageId.THERE_IS_NOT_ENOUGH_SOUL));
                 return;
@@ -10311,39 +10313,131 @@ public final class L2PcInstance extends L2PlayableInstance
 		sendPacket(new EtcStatusUpdate(this));
 	}
 
-	public int getAbsorbedSouls()
-	{
-        return _absorbedSouls;
+    /**
+     * Returns the Number of Souls this L2PcInstance got.
+     * @return
+     */
+    public int getSouls()
+    {
+        return _souls;
     }
-    
-    public void absorbSoul(L2Skill skill, L2NpcInstance target)
+
+    /**
+     * Absorbs a Soul from a Npc.
+     * @param skill
+     * @param target
+     */
+    public void absorbSoul(L2Skill skill, L2NpcInstance npc)
     {
-        if (_absorbedSouls >= skill.getNumSouls())
+        if (_souls >= skill.getNumSouls())
         {
             SystemMessage sm = new SystemMessage(SystemMessageId.SOUL_CANNOT_BE_INCREASED_ANYMORE);
             sendPacket(sm);
             return;
         }
-        
-        _absorbedSouls++;
-        
-        sendPacket(new ExSpawnEmitter(getObjectId(),target.getObjectId()));
-        sendPacket(new EtcStatusUpdate(this));
+
+        increaseSouls(1);
+
+        if (npc != null)
+            sendPacket(new ExSpawnEmitter(this, npc));
+    }
+    
+    /**
+     * Increase Souls
+     * @param count
+     */
+    public void increaseSouls(int count)
+    {
+        if (count < 0 || count > 45)
+            return;
+
+        _souls += count;
+
+        if (getSouls() > 45)
+            _souls = 45;
+
         SystemMessage sm = new SystemMessage(SystemMessageId.YOUR_SOUL_HAS_INCREASED_BY_S1_SO_IT_IS_NOW_AT_S2);
-        sm.addNumber(1);
-        sm.addNumber(_absorbedSouls);
+        sm.addNumber(count);
+        sm.addNumber(_souls);
         sendPacket(sm);
+
+        restartSoulTask();
+
+        sendPacket(new EtcStatusUpdate(this));
     }
 
-    public void decreaseAbsorbedSouls(int count)
+    /**
+     * Decreases existing Souls.
+     * @param count
+     */
+    public void decreaseSouls(int count)
     {
-        if (getAbsorbedSouls() <= 0 || (getAbsorbedSouls() - count) < 0)
+        if (getSouls() <= 0)
             return;
 
-        _absorbedSouls -= count;
+        _souls -= count;
+
+        if (getSouls() < 0)
+            _souls = 0;
+
+        if (getSouls() == 0)
+            stopSoulTask();
+        else
+            restartSoulTask();
+
         sendPacket(new EtcStatusUpdate(this));
     }
 
+    /**
+     * Clear out all Souls from this L2PcInstance
+     */
+    public void clearSouls()
+    {
+        _souls = 0;
+        stopSoulTask();
+        sendPacket(new EtcStatusUpdate(this));
+    }
+
+    /**
+     * Starts/Restarts the SoulTask to Clear Souls after 10 Mins.
+     */
+    private void restartSoulTask()
+    {
+        if (_soulTask != null)
+        {
+            _soulTask.cancel(false);
+            _soulTask = null;
+        }
+        _soulTask = ThreadPoolManager.getInstance().scheduleGeneral(new SoulTask(this), 600000);
+    }
+
+    /**
+     * Stops the Clearing Task.
+     */
+    public void stopSoulTask()
+    {
+        if (_soulTask != null)
+        {
+            _soulTask.cancel(false);
+            _soulTask = null;
+        }
+    }
+
+    private class SoulTask implements Runnable
+    {
+        L2PcInstance _player;
+        
+        protected SoulTask(L2PcInstance player)
+        {
+            _player = player;
+        }
+        
+        public void run()
+        {
+            _player.clearSouls();
+        }
+    }
+
     public int getDeathPenaltyBuffLevel()
     {
     	  return _deathPenaltyBuffLevel;

+ 1 - 1
L2_GameServer_T1/java/net/sf/l2j/gameserver/serverpackets/EtcStatusUpdate.java

@@ -57,7 +57,7 @@ public class EtcStatusUpdate extends L2GameServerPacket
 		writeD(Math.min(_activeChar.getExpertisePenalty(),1)); // 1 = grade penalty 
 		writeD(_activeChar.getCharmOfCourage() ? 1 : 0); // 1 = charm of courage (no xp loss in siege..)
 		writeD(_activeChar.getDeathPenaltyBuffLevel()); // 1-15 death penalty, lvl (combat ability decreased due to death)
-        writeD(_activeChar.getAbsorbedSouls());
+        	writeD(_activeChar.getSouls());
         
 	}