Jump to content
  • 0

restriction for TVT aCis


Question

Posted

Hello, I would like help because I do not understand very well, I made a restriction so that players of the same team do not kill themselves more players who do not participate can kill the participants.

 

diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java
index 70589d9..ba98048 100644
--- a/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java
+++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java
@@ -133,6 +133,7 @@
 import net.sf.l2j.gameserver.model.entity.Castle;
 import net.sf.l2j.gameserver.model.entity.Duel.DuelState;
 import net.sf.l2j.gameserver.model.entity.events.Event;
+import net.sf.l2j.gameserver.model.entity.events.TvTEvent;
 import net.sf.l2j.gameserver.model.entity.Siege;
 import net.sf.l2j.gameserver.model.group.CommandChannel;
 import net.sf.l2j.gameserver.model.group.Party;
@@ -2899,6 +2900,12 @@
 	@Override
 	public void onAction(Player player)
 	{	
+		if (!TvTEvent.getInstance().canTarget(this, player))
+		{
+			player.sendPacket(ActionFailed.STATIC_PACKET);
+			return;
+		}
+		
 		// Set the target of the player
 		if (player.getTarget() != this)
 			player.setTarget(this);
  diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/model/entity/events/TvTEvent.java b/aCis_gameserver/java/net/sf/l2j/gameserver/model/entity/events/TvTEvent.java
index 017c0d5..70c66e4 100644
--- a/aCis_gameserver/java/net/sf/l2j/gameserver/model/entity/events/TvTEvent.java
+++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/entity/events/TvTEvent.java
@@ -523,6 +523,18 @@
 	}
 	
 	@Override
+	public boolean canTarget(Player player, Player target)
+	{
+		if (player.getTeam() == TeamType.BLUE && target.getTeam() == TeamType.BLUE)
+			return false;
+
+		if (player.getTeam() == TeamType.RED && target.getTeam() == TeamType.RED)
+			return false;
+		
+		return true;
+	}
+	
+	@Override
 	public void onRevive(Creature killer)
 	{
 		if (killer == null)

 

I define my teams by TeamType, BLUE and RED

 

I added this check for players without a team it works, unregistered players can't kill registered players and RED and Azul team players can't kill themselves what did I do wrong?

 

  


    @Override
    public boolean canTarget(Player player, Player target)
    {
  +      if (player.getTeam().getId() > 0 && player.getTeam() == target.getTeam())
  +         return false;
  +      
        if (player.getTeam() == TeamType.BLUE && target.getTeam() == TeamType.BLUE)
            return false;

        if (player.getTeam() == TeamType.RED && target.getTeam() == TeamType.RED)
            return false;
        
        return true;
    }
    

4 answers to this question

Recommended Posts

  • 0
Posted (edited)
	
public boolean canTarget(Player player, Player target)
{
	// if they are not registered on the event they can kill each other
	if (player.getTeam() == TeamType.NONE && target.getTeam() == TeamType.NONE)
		return true; 
	
	// kill each other only if the teams are not the same.
	return player.getTeam() != target.getTeam();
}

 

Edited by melron
  • 0
Posted (edited)

 

24 minutes ago, melron said:

	
public boolean canTarget(Player player, Player target)
{
	// if they are not registered on the event they can kill each other
	if (player.getTeam() == TeamType.NONE && target.getTeam() == TeamType.NONE)
		return true; 
	
	// kill each other only if the teams are not the same.
	return player.getTeam() != target.getTeam();
}

 

 

already tried it does not work

Edited by Williams
  • 0
Posted (edited)

Why you mess with canTarget and onAction methods, lul. That's stupid way and will avoid heal of team mates. That's just plain wrong. Just avoid hitting.

Edited by SweeTs
  • 0
Posted
On 3/14/2020 at 3:32 PM, SweeTs said:

Why you mess with canTarget and onAction methods, lul. That's stupid way and will avoid heal of team mates. That's just plain wrong. Just avoid hitting.

 

You are right, I did as you say more, the players use the CTRL to attack the same team. And yet non-participating players attack participating players.

 

what you told me to do ?

diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/model/L2Skill.java b/aCis_gameserver/java/net/sf/l2j/gameserver/model/L2Skill.java
index 224fed7..747e01d 100644
--- a/aCis_gameserver/java/net/sf/l2j/gameserver/model/L2Skill.java
+++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/L2Skill.java
@@ -1633,12 +1633,6 @@
 						if ((obj.getAllyId() == 0 || obj.getAllyId() != player.getAllyId()) && (obj.getClan() == null || obj.getClanId() != player.getClanId()))
 							continue;
 
+						if (obj.getTeam().getId() > 0)
+						{
+							if (player.getTeam() != obj.getTeam())
+								continue;
+						}
+
 						if (player.isInDuel())
 						{
 							if (player.getDuelId() != obj.getDuelId())
@@ -1744,12 +1738,6 @@
 							if (obj == null || obj == player)
 								continue;
 
-							if (obj	.getTeam().getId() > 0)
-							{
-								if (player.getTeam() != obj.getTeam())
-									continue;
-							}
-
 							if (player.isInDuel())
 							{
 								if (player.getDuelId() != obj.getDuelId())
@@ -2068,12 +2056,6 @@
 				if (player.getParty().getCommandChannel() != null && player.getParty().getCommandChannel() == targetPlayer.getParty().getCommandChannel())
 					return false;
 			}
+
+			if (player.getTeam().getId() > 0)
+			{
+				if (player.getTeam() == targetPlayer.getTeam())
+					return false;
+			}
 			
 			if (!sourceInArena && !(targetPlayer.isInsideZone(ZoneId.PVP) && !targetPlayer.isInsideZone(ZoneId.SIEGE)))
 			{
diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java
index fc8ae4e..b061496 100644
--- a/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java
+++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java
@@ -6241,15 +6241,6 @@
 				return false;
 			}
 			
+			// Check if attacker is in event
+			if (cha.getEvent() != null && cha.getEvent() == getEvent())
+			{
+				if (cha.getTeam().getId() > 0 && cha.getTeam() == getTeam())
+					return false;
+				
+				return true;
+			}
+			
 			// is AutoAttackable if both players are in the same duel and the duel is still going on
 			if (getDuelState() == DuelState.DUELLING && getDuelId() == cha.getDuelId())
 				return true;
@@ -2901,12 +2901,6 @@
 	@Override
 	public void onAction(Player player)
 	{	
-		if (!TvTEvent.getInstance().canTarget(this, player))
-		{
-			player.sendPacket(ActionFailed.STATIC_PACKET);
-			return;
-		}
-		
 		// Set the target of the player
 		if (player.getTarget() != this)
 			player.setTarget(this);
@@ -2949,12 +2943,6 @@
 	@Override
 	public void onActionShift(Player player)
 	{
-		if (!TvTEvent.getInstance().canTarget(this, player))
-		{
-			player.sendPacket(ActionFailed.STATIC_PACKET);
-			return;
-		}
-		
 		if (player.isGM())
 			AdminEditChar.showCharacterInfo(player, this);
diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/Cubic.java b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/Cubic.java
index 524e44a..f3bcb7f 100644
--- a/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/Cubic.java
+++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/Cubic.java
@@ -23,7 +23,6 @@
 import net.sf.l2j.gameserver.model.actor.Playable;
 import net.sf.l2j.gameserver.model.actor.Player;
 import net.sf.l2j.gameserver.model.actor.Summon;
-import net.sf.l2j.gameserver.model.entity.events.Event;
 import net.sf.l2j.gameserver.model.group.Party;
 import net.sf.l2j.gameserver.network.SystemMessageId;
 import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
@@ -257,21 +256,6 @@
 			return;
 		}
 
+		// Events
+		Event event = _owner.getEvent();
+		if (event != null && event.isStarted())
+		{
+			final Player target = ownerTarget.getActingPlayer();
+			if (target != null && target.getEvent() == event && (_owner.getTeam().getId() == 0 || _owner.getTeam() != target.getTeam()))
+			{
+				_target = (Creature)ownerTarget;
+				// Dead target
+				if (_target.isDead())
+					_target = null;
+			}
+			return;
+		}
+
 		// Olympiad targeting
 		if (_owner.isInOlympiadMode())
 		{

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...