Răsfoiți Sursa

Support for Cubics maxcount by nik (If cubic maxcount is reached, the cubic should go idle until its lifetime ends. Use -1 to disable this feature).

MELERIX 14 ani în urmă
părinte
comite
de67d59d64

+ 17 - 1
L2J_Server/java/com/l2jserver/gameserver/model/actor/instance/L2CubicInstance.java

@@ -79,6 +79,8 @@ public class L2CubicInstance
 	protected int _matk;
 	protected int _activationtime;
 	protected int _activationchance;
+	protected int _maxcount;
+	protected int _currentcount;
 	protected boolean _active;
 	private boolean _givenByOther;
 	
@@ -88,13 +90,15 @@ public class L2CubicInstance
 	private Future<?> _actionTask;
 	
 	public L2CubicInstance(L2PcInstance owner, int id, int level, int mAtk, int activationtime,
-			int activationchance, int totallifetime, boolean givenByOther)
+			int activationchance, int maxcount, int totallifetime, boolean givenByOther)
 	{
 		_owner = owner;
 		_id = id;
 		_matk = mAtk;
 		_activationtime = activationtime * 1000;
 		_activationchance = activationchance;
+		_maxcount = maxcount;
+		_currentcount = 0;
 		_active = false;
 		_givenByOther = givenByOther;
 		
@@ -498,6 +502,12 @@ public class L2CubicInstance
 						return;
 					}
 				}
+				// The cubic has already reached its limit and it will stay idle until its lifetime ends.
+				if (_maxcount > -1 && _currentcount >= _maxcount)
+				{
+					stopAction();
+					return;
+				}
 				// Smart Cubic debuff cancel is 100%
 				boolean UseCubicCure = false;
 				L2Skill skill = null;
@@ -522,6 +532,9 @@ public class L2CubicInstance
 					// activation period
 					MagicSkillUse msu = new MagicSkillUse(_owner, _owner, SKILL_CUBIC_CURE, 1, 0, 0);
 					_owner.broadcastPacket(msu);
+					
+					// The cubic has done an action, increase the currentcount
+					_currentcount++;
 				}
 				else if (Rnd.get(1, 100) < _chance)
 				{
@@ -594,6 +607,9 @@ public class L2CubicInstance
 								if (Config.DEBUG)
 									_log.info("L2CubicInstance: Action.run(); other handler");
 							}
+							
+							// The cubic has done an action, increase the currentcount
+							_currentcount++;
 						}
 					}
 				}

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -9586,11 +9586,11 @@ public final class L2PcInstance extends L2Playable
 	/**
 	 * Add a L2CubicInstance to the L2PcInstance _cubics.<BR><BR>
 	 */
-	public void addCubic(int id, int level, double matk, int activationtime, int activationchance, int totalLifetime, boolean givenByOther)
+	public void addCubic(int id, int level, double matk, int activationtime, int activationchance, int maxcount, int totalLifetime, boolean givenByOther)
 	{
 		if (Config.DEBUG)
 			_log.info("L2PcInstance(" + getName() + "): addCubic(" + id + "|" + level + "|" + matk + ")");
-		L2CubicInstance cubic = new L2CubicInstance(this, id, level, (int) matk, activationtime, activationchance, totalLifetime, givenByOther);
+		L2CubicInstance cubic = new L2CubicInstance(this, id, level, (int) matk, activationtime, activationchance, maxcount, totalLifetime, givenByOther);
 		
 		_cubics.put(id, cubic);
 	}

+ 6 - 3
L2J_Server/java/com/l2jserver/gameserver/skills/l2skills/L2SkillSummon.java

@@ -44,6 +44,8 @@ public class L2SkillSummon extends L2Skill
 	private final int _activationtime;
 	// Activation chance for a cubic.
 	private final int _activationchance;
+	// Maximum casts made by the cubic until it goes idle.
+	private final int _maxcount;
 	
 	// What is the total lifetime of summons (in millisecs)
 	private final int _summonTotalLifeTime;
@@ -71,6 +73,7 @@ public class L2SkillSummon extends L2Skill
 		
 		_activationtime= set.getInteger("activationtime", 8);
 		_activationchance= set.getInteger("activationchance", 30);
+		_maxcount= set.getInteger("maxcount", -1);
 		
 		_summonTotalLifeTime= set.getInteger("summonTotalLifeTime", 1200000);  // 20 minutes default
 		_summonTimeLostIdle= set.getInteger("summonTimeLostIdle", 0);
@@ -175,9 +178,9 @@ public class L2SkillSummon extends L2Skill
 					}
 					if (player.getCubics().size() > mastery) continue;
 					if (player == activeChar)
-						player.addCubic(_npcId, _cubicSkillLevel, getPower(), _activationtime, _activationchance, _summonTotalLifeTime, false);
+						player.addCubic(_npcId, _cubicSkillLevel, getPower(), _activationtime, _activationchance, _maxcount, _summonTotalLifeTime, false);
 					else // given by other player
-						player.addCubic(_npcId, _cubicSkillLevel, getPower(), _activationtime, _activationchance, _summonTotalLifeTime, true);
+						player.addCubic(_npcId, _cubicSkillLevel, getPower(), _activationtime, _activationchance, _maxcount, _summonTotalLifeTime, true);
 					player.broadcastUserInfo();
 				}
 				return;
@@ -200,7 +203,7 @@ public class L2SkillSummon extends L2Skill
 					activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CUBIC_SUMMONING_FAILED));
 					return;
 				}
-				activeChar.addCubic(_npcId, _cubicSkillLevel, getPower(), _activationtime, _activationchance, _summonTotalLifeTime, false);
+				activeChar.addCubic(_npcId, _cubicSkillLevel, getPower(), _activationtime, _activationchance, _maxcount, _summonTotalLifeTime, false);
 				activeChar.broadcastUserInfo();
 				return;
 			}