Pārlūkot izejas kodu

Core support for scripted Grandboss Minions. Cleanup to isRaid().
By Kerberos

Sami 16 gadi atpakaļ
vecāks
revīzija
844aafc4e9

+ 1 - 1
L2_GameServer/java/net/sf/l2j/gameserver/ai/L2AttackableAI.java

@@ -520,7 +520,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 		{
 			int offset;
 			
-			if (_actor.isRaid())
+			if (_actor.isRaidMinion())
 				offset = 500; // for Raids - need correction
 			else
 				offset = 200; // for normal minions - need correction :)

+ 14 - 6
L2_GameServer/java/net/sf/l2j/gameserver/model/L2Attackable.java

@@ -1045,7 +1045,7 @@ public class L2Attackable extends L2NpcInstance
                  // We should multiply by the server's drop rate, so we always get a low chance of drop for deep blue mobs.
                  // NOTE: This is valid only for adena drops! Others drops will still obey server's rate
                  deepBlueDrop = 3;
-                 if (drop.getItemId() == 57) deepBlueDrop *= isRaid()? (int)Config.RATE_DROP_ITEMS_BY_RAID : (int)Config.RATE_DROP_ITEMS;
+                 if (drop.getItemId() == 57) deepBlueDrop *= isRaid()&& !isRaidMinion()? (int)Config.RATE_DROP_ITEMS_BY_RAID : (int)Config.RATE_DROP_ITEMS;
              }
          }
 
@@ -1057,7 +1057,7 @@ public class L2Attackable extends L2NpcInstance
          // Applies Drop rates
          if (drop.getItemId() == 57) dropChance *= Config.RATE_DROP_ADENA;
          else if (isSweep) dropChance *= Config.RATE_DROP_SPOIL;
-         else dropChance *= isRaid() ? Config.RATE_DROP_ITEMS_BY_RAID : Config.RATE_DROP_ITEMS;
+         else dropChance *= isRaid()&&!isRaidMinion() ? Config.RATE_DROP_ITEMS_BY_RAID : Config.RATE_DROP_ITEMS;
 
          if (Config.L2JMOD_CHAMPION_ENABLE && isChampion())
 	         dropChance *= Config.L2JMOD_CHAMPION_REWARDS;
@@ -1144,7 +1144,7 @@ public class L2Attackable extends L2NpcInstance
           if (Config.DEEPBLUE_DROP_RULES) categoryDropChance = ((categoryDropChance - ((categoryDropChance * levelModifier)/100)) / deepBlueDrop);
 
           // Applies Drop rates
-          categoryDropChance *= isRaid() ? Config.RATE_DROP_ITEMS_BY_RAID : Config.RATE_DROP_ITEMS;
+          categoryDropChance *= isRaid() && !isRaidMinion() ? Config.RATE_DROP_ITEMS_BY_RAID : Config.RATE_DROP_ITEMS;
           if (Config.L2JMOD_CHAMPION_ENABLE && isChampion())
 			categoryDropChance *= Config.L2JMOD_CHAMPION_REWARDS;
 
@@ -1157,7 +1157,7 @@ public class L2Attackable extends L2NpcInstance
           // Check if an Item from this category must be dropped
           if (Rnd.get(L2DropData.MAX_CHANCE) < categoryDropChance)
           {
-        	  L2DropData drop = categoryDrops.dropOne(isRaid());
+        	  L2DropData drop = categoryDrops.dropOne(isRaid() && !isRaidMinion());
         	  if (drop == null)
         		  return null;
 
@@ -1175,7 +1175,7 @@ public class L2Attackable extends L2NpcInstance
 
         	  int dropChance = drop.getChance();
               if (drop.getItemId() == 57) dropChance *= Config.RATE_DROP_ADENA;
-              else dropChance *= isRaid() ? Config.RATE_DROP_ITEMS_BY_RAID : Config.RATE_DROP_ITEMS;
+              else dropChance *= isRaid() && !isRaidMinion() ? Config.RATE_DROP_ITEMS_BY_RAID : Config.RATE_DROP_ITEMS;
               if (Config.L2JMOD_CHAMPION_ENABLE && isChampion())
 				dropChance *= Config.L2JMOD_CHAMPION_REWARDS;
 
@@ -1360,7 +1360,7 @@ public class L2Attackable extends L2NpcInstance
 					 else dropItem(player, item); // drop the item on the ground
 
 					 // Broadcast message if RaidBoss was defeated
-		             if(isRaid() && !(this instanceof L2MinionInstance))
+		             if(isRaid() && !isRaidMinion())
 		             {
 		                 SystemMessage sm;
 		                 sm = new SystemMessage(SystemMessageId.S1_DIED_DROPPED_S3_S2);
@@ -2339,4 +2339,12 @@ public class L2Attackable extends L2NpcInstance
 			}
 		}
 	}
+
+    public void returnHome()
+    {
+    	clearAggroList();
+    	
+    	if (hasAI())
+    		getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(getSpawn().getLocx(), getSpawn().getLocy(), getSpawn().getLocz(), 0));
+	}
 }

+ 30 - 3
L2_GameServer/java/net/sf/l2j/gameserver/model/L2Character.java

@@ -203,6 +203,8 @@ public abstract class L2Character extends L2Object
 	
 	private final byte[] _zones = new byte[13];
 	protected byte _zoneValidateCounter = 4;
+
+	private boolean _isRaid = false;
 	
 	/**
 	 * Returns character inventory, default null, overridden in L2Playable types and in L2NPcInstance
@@ -2069,9 +2071,18 @@ public abstract class L2Character extends L2Object
 
 	/** Return True if the L2Character is RaidBoss or his minion. */
 	public boolean isRaid()
-	{
-		return false;
-	}
+    {
+        return _isRaid  ;
+    }
+    
+	/**
+	 * Set this Npc as a Raid instance.<BR><BR>
+	 * @param isRaid
+	 */
+    public void setIsRaid(boolean isRaid)
+    {
+    	_isRaid = isRaid;
+    }
 
 	/** Return a list of L2Character that attacked. */
 	public final List<L2Character> getAttackByList ()
@@ -6363,6 +6374,8 @@ public abstract class L2Character extends L2Object
 
 	private boolean _AIdisabled = false;
 
+	private boolean _isMinion = false;
+
 	public void setPvpFlagLasts(long time)
 	{
 		_pvpFlagLasts = time;
@@ -6694,4 +6707,18 @@ public abstract class L2Character extends L2Object
 			}
 		}
 	}
+	public boolean isRaidMinion()
+    {
+        return _isMinion ;
+    }
+    
+	/**
+	 * Set this Npc as a Minion instance.<BR><BR>
+	 * @param val
+	 */
+    public void setIsRaidMinion(boolean val)
+    {
+    	_isRaid = val;
+    	_isMinion = val;
+    }
 }

+ 1 - 6
L2_GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2GrandBossInstance.java

@@ -48,6 +48,7 @@ public final class L2GrandBossInstance extends L2MonsterInstance
     @Override
 	public void onSpawn()
     {
+    	setIsRaid(true);
     	if (getNpcId() == 29020 || getNpcId() == 29028) // baium and valakas are all the time in passive mode, theirs attack AI handled in AI scripts
     		super.disableCoreAI(true);
     	super.onSpawn();
@@ -63,12 +64,6 @@ public final class L2GrandBossInstance extends L2MonsterInstance
         super.reduceCurrentHp(damage, attacker, awake, isDOT);
     }
 
-    @Override
-	public boolean isRaid()
-    {
-        return true;
-    }
-
     /**
      * 
      * @see net.sf.l2j.gameserver.model.actor.instance.L2MonsterInstance#doDie(net.sf.l2j.gameserver.model.L2Character)

+ 4 - 8
L2_GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2MinionInstance.java

@@ -49,13 +49,6 @@ public final class L2MinionInstance extends L2MonsterInstance
 		super(objectId, template);
 	}
 
-	/** Return True if the L2Character is minion of RaidBoss. */
-	@Override
-	public boolean isRaid()
-	{
-		return (getLeader().isRaid());
-	}
-
 	/**
 	 * Return the master of this L2MinionInstance.<BR><BR>
 	 */
@@ -70,7 +63,10 @@ public final class L2MinionInstance extends L2MonsterInstance
 		super.onSpawn();
 		// Notify Leader that Minion has Spawned
 		getLeader().notifyMinionSpawned(this);
-
+		if (getLeader().isRaid())
+		{
+			setIsRaidMinion(true);
+		}
 		// check the region where this mob is, do not activate the AI if region is inactive.
 		L2WorldRegion region = L2World.getInstance().getRegion(getX(),getY());
 		if ((region !=null) && (!region.isActive()))

+ 2 - 2
L2_GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2MonsterInstance.java

@@ -183,7 +183,7 @@ public class L2MonsterInstance extends L2Attackable
                     // Trigger the aggro condition of the minion
                     if (minion != null && !minion.isDead())
                     {
-                        if(isRaid())
+                        if(isRaid()&&!isRaidMinion())
                         	minion.addDamage(attacker, 100);
                         else minion.addDamage(attacker, 1);
                     }
@@ -201,7 +201,7 @@ public class L2MonsterInstance extends L2Attackable
     	if (_minionMaintainTask != null)
             _minionMaintainTask.cancel(true); // doesn't do it?
 
-        if (isRaid() && !(this instanceof L2MinionInstance))
+        if (isRaid() && !isRaidMinion())
         	deleteSpawnedMinions();
         return true;
     }

+ 3 - 3
L2_GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2RaidBossInstance.java

@@ -54,11 +54,11 @@ public final class L2RaidBossInstance extends L2MonsterInstance
 	}
 
     @Override
-    public boolean isRaid()
+	public void onSpawn()
     {
-        return true;
+    	setIsRaid(true);
+    	super.onSpawn();
     }
-
     @Override
     protected int getMaintenanceInterval() { return RAIDBOSS_MAINTENANCE_INTERVAL; }
 

+ 6 - 15
L2_GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2SepulcherMonsterInstance.java

@@ -104,6 +104,12 @@ public class L2SepulcherMonsterInstance extends L2MonsterInstance
 				break;
 			case 18256:
 				break;
+			case 25339:
+			case 25342:
+			case 25346:
+			case 25349:
+				setIsRaid(true);
+				break;
 		}
 	}
 	
@@ -249,21 +255,6 @@ public class L2SepulcherMonsterInstance extends L2MonsterInstance
 		super.deleteMe();
 	}
 	
-	@Override
-	public boolean isRaid()
-	{
-		switch (getNpcId())
-		{
-			case 25339:
-			case 25342:
-			case 25346:
-			case 25349:
-				return true;
-			default:
-				return false;
-		}
-	}
-	
 	private void giveCup(L2PcInstance player)
 	{
 		String questId = "620_FourGoblets";

+ 36 - 0
L2_GameServer/java/net/sf/l2j/gameserver/model/zone/type/L2BossZone.java

@@ -17,8 +17,10 @@ package net.sf.l2j.gameserver.model.zone.type;
 import javolution.util.FastMap;
 import net.sf.l2j.gameserver.GameServer;
 import net.sf.l2j.gameserver.datatables.MapRegionTable;
+import net.sf.l2j.gameserver.model.L2Attackable;
 import net.sf.l2j.gameserver.model.L2Character;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance;
 import net.sf.l2j.gameserver.model.zone.L2ZoneType;
 import net.sf.l2j.util.L2FastList;
 
@@ -45,6 +47,7 @@ public class L2BossZone extends L2ZoneType
 	{
 		0, 0, 0
 	};
+	protected L2FastList<L2Character> _raidList= new L2FastList<L2Character>();
 	
 	public L2BossZone(int id)
 	{
@@ -177,6 +180,39 @@ public class L2BossZone extends L2ZoneType
 					_playerAllowedReEntryTimes.put(character.getObjectId(), System.currentTimeMillis() + _timeInvade);
 				}
 			}
+			if (character instanceof L2PlayableInstance)
+			{
+				if (getCharactersInside() != null && getCharactersInside().size() > 0)
+				{
+					_raidList.clear();
+					int count = 0;
+					for (L2Character obj : getCharactersInside().values())
+					{
+						if (obj == null)
+							continue;
+						if (obj instanceof L2PlayableInstance)
+							count++;
+						else if (obj instanceof L2Attackable && obj.isRaid())
+						{
+							_raidList.add(obj);
+						}
+					}
+					// if inside zone isnt any player, force all boss instance return to its spawn points
+					if (count == 0 && !_raidList.isEmpty())
+					{
+						for (int i = 0; i < _raidList.size(); i++)
+						{
+							L2Attackable raid = (L2Attackable) _raidList.get(i);
+							if (!raid.isInsideRadius(raid.getSpawn().getLocx(), raid.getSpawn().getLocy(), 150, false))
+								raid.returnHome();
+						}
+					}
+				}
+			}
+			if (character instanceof L2Attackable && character.isRaid())
+			{
+				((L2Attackable) character).returnHome();
+			}
 		}
 	}
 	

+ 1 - 1
L2_GameServer/java/net/sf/l2j/gameserver/taskmanager/DecayTaskManager.java

@@ -86,7 +86,7 @@ public class DecayTaskManager
 				if (_decayTasks != null)
 					for (L2Character actor : _decayTasks.keySet())
 					{
-						if (actor.isRaid())
+						if (actor.isRaid()&& !actor.isRaidMinion())
 							delay = RAID_BOSS_DECAY_TIME;
 						else
 							delay = ATTACKABLE_DECAY_TIME;