Răsfoiți Sursa

BETA: Reworking eject player support.
* onDeath(..) method moved to !InstanceWorld, now can be overridden in instance zone implementations.
* Do not forget to call super.onDeath(..) or eject task won't called.
* Allows you to manage player death inside instances.
* Added system message upon death.
Reported by: UnAfraid

Zoey76 12 ani în urmă
părinte
comite
8d9ca6a69f

+ 12 - 11
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Instance.java

@@ -58,6 +58,7 @@ import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.templates.L2DoorTemplate;
 import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
+import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
 import com.l2jserver.gameserver.network.SystemMessageId;
 import com.l2jserver.gameserver.network.clientpackets.Say2;
 import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
@@ -735,24 +736,24 @@ public final class Instance
 		}
 	}
 	
-	/**
-	 * @param killer the character that killed the {@code victim}
-	 * @param victim the character that was killed by the {@code killer}
-	 */
-	public final void notifyDeath(L2Character killer, L2Character victim)
+	public void addEjectDeadTask(L2PcInstance player)
 	{
-		onDeath(killer, victim);
+		if ((player != null))
+		{
+			_ejectDeadTasks.put(player.getObjectId(), ThreadPoolManager.getInstance().scheduleGeneral(new EjectPlayer(player), _ejectTime));
+		}
 	}
 	
 	/**
-	 * @param killer
-	 * @param victim
+	 * @param killer the character that killed the {@code victim}
+	 * @param victim the character that was killed by the {@code killer}
 	 */
-	protected void onDeath(L2Character killer, L2Character victim)
+	public final void notifyDeath(L2Character killer, L2Character victim)
 	{
-		if ((victim != null) && victim.isPlayer())
+		final InstanceWorld instance = InstanceManager.getInstance().getPlayerWorld(victim.getActingPlayer());
+		if (instance != null)
 		{
-			_ejectDeadTasks.put(victim.getObjectId(), ThreadPoolManager.getInstance().scheduleGeneral(new EjectPlayer(victim.getActingPlayer()), _ejectTime));
+			instance.onDeath(killer, victim);
 		}
 	}
 	

+ 25 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/instancezone/InstanceWorld.java

@@ -22,6 +22,12 @@ import java.util.List;
 
 import javolution.util.FastList;
 
+import com.l2jserver.gameserver.instancemanager.InstanceManager;
+import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.entity.Instance;
+import com.l2jserver.gameserver.network.SystemMessageId;
+import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
+
 /**
  * Basic instance zone data transfer object.
  * @author Zoey76
@@ -87,4 +93,23 @@ public class InstanceWorld
 	{
 		_status++;
 	}
+	
+	/**
+	 * @param killer
+	 * @param victim
+	 */
+	public void onDeath(L2Character killer, L2Character victim)
+	{
+		if ((victim != null) && victim.isPlayer())
+		{
+			final Instance instance = InstanceManager.getInstance().getInstance(getInstanceId());
+			if (instance != null)
+			{
+				final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_WILL_BE_EXPELLED_IN_S1);
+				sm.addNumber(instance.getEjectTime());
+				victim.getActingPlayer().sendPacket(sm);
+				instance.addEjectDeadTask(victim.getActingPlayer());
+			}
+		}
+	}
 }

+ 7 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/network/SystemMessageId.java

@@ -14802,6 +14802,12 @@ public final class SystemMessageId
 	 */
 	public static final SystemMessageId THE_S2_ATTRIBUTE_WAS_SUCCESSFULLY_BESTOWED_ON_S1_RES_TO_S3_INCREASED;
 	
+	/**
+	 * ID: 3147<br>
+	 * Message: If you are not resurrected within $s1 minutes, you will be expelled from the instant zone.
+	 */
+	public static final SystemMessageId YOU_WILL_BE_EXPELLED_IN_S1;
+	
 	/**
 	 * ID: 3150<br>
 	 * Message: You have requested a couple action with $c1.
@@ -17437,6 +17443,7 @@ public final class SystemMessageId
 		PARTY_LOOT_CHANGED_S1 = new SystemMessageId(3138);
 		C1_IS_CURRENTLY_DEAD_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION = new SystemMessageId(3139);
 		THE_S2_ATTRIBUTE_WAS_SUCCESSFULLY_BESTOWED_ON_S1_RES_TO_S3_INCREASED = new SystemMessageId(3144);
+		YOU_WILL_BE_EXPELLED_IN_S1 = new SystemMessageId(3147);
 		YOU_HAVE_REQUESTED_COUPLE_ACTION_C1 = new SystemMessageId(3150);
 		S1_S2_ATTRIBUTE_REMOVED_RESISTANCE_S3_DECREASED = new SystemMessageId(3152);
 		YOU_DO_NOT_HAVE_ENOUGH_FUNDS_TO_CANCEL_ATTRIBUTE = new SystemMessageId(3156);