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())
 		{

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • Migrating a legacy Interlude server to PostgreSQL while adding real observability is basically forcing 2006 MMO engineering to attend a 2026 infrastructure conference at gunpoint. PS: which revision of aCis? PS: 🧻what was broken during this whatever you call it.    AAC Guard beign asked to adapt to this be like: - Creating bugs since early 2018
    • OH MY LORDDDDDDDDDDDDDDDDDDDDD   FINALLY
    • TG Support: https://t.me/buyingproxysup | Channel: https://t.me/buyingproxycom Discord support: #buyingproxy | Server: Join the BuyingProxy Discord Server!  Create your free account here
    • I came out of my cave as I do once every 5 years. By now, I know nobody really cares about L2, but I still find it fun to experiment. Everything you see here will be free and open source. I have no interest in selling anything.   Long story short, I like to revisit Interlude and apply what I've learned to see how far I can push it. Here's Outerlude, a public fork of aCis for the modern age.   Video demo:   Work that has been done:   Redone the netcode from scratch to be async The NPC AI was completely redone based on Finite State Machines Moved to PostgreSQL and using some of its cool features Lots of config that should be hot reloadable has moved to the database OpenTelemetry instrumentation, where it makes sense, and a Grafana dashboard A built-in REST API for server management A built-in MCP Server for LLMs Nidrah AI, an AI Agent to make managing the server easier Real-time server map view Chat auditing and live snooping A new Fake Players Engine with a Node logic system and a new LLM planner for any behavior Just watch the video   If there is interest in this and I'm happy with it, or I get bored (which I always do), I will open-source it. Let me know what you think and if there is some feature you'd like me to implement.
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..