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.



  • Posts

    • hello everyone! I am wanting to save the files (Ini. - Data - ) of the EP5 Client: Salvation... But they generate the error "corrupt files"... I tried several versions of L2FileEditor without good results. I need help! Thank you!
    • Opening December 6th at 19:00 (GMT +3)! Open Beta Test from November 30th!   https://l2soe.com/   🌟 Introducing L2 Saga of Eternia: A Revolution in Lineage 2 High Five! 🌟   Dear Lineage 2 enthusiasts, Prepare to witness the future of private servers! L2 Saga of Eternia is not just another High Five project—it’s a game-changing experience designed to compete with the giants of the Lineage 2 private server scene. Built for the community, by the community, we’re here to raise the bar in quality, innovation, and longevity. What Sets Us Apart? 💎 No Wipes, Ever Say goodbye to the fear of losing your progress. Our server is built to last and will never close. Stability and consistency are our promises to you. ⚔️ Weekly New Content Our dedicated development team ensures fresh challenges, events, and updates every week. From custom quests to exclusive features, there will always be something exciting to explore. 💰 No Pay-to-Win Skill and strategy matter most here. Enjoy a balanced gameplay environment where your achievements come from effort, not your wallet. 🌍 A Massive Community With 2000+ players expected, join a vibrant and active community of like-minded adventurers ready to conquer the world of Aden. 🏆 Fair and Competitive Gameplay Our systems are designed to promote healthy competition while avoiding abusive mechanics and exploits. 🔧 Professional Development From advanced bug fixes to carefully curated content, we pride ourselves on smooth performance, no lag, and unparalleled server quality. Key Features Chronicle: High Five with unique interface Rate: Dynamic x10 rates Class Balance: Carefully fine-tuned for a fair experience PvP Focused: PvP Ranking & aura display effect for 3 Top PvPers every week Custom Events: Seasonal and permanent events to keep you engaged Additional Features:   Custom Endgame Content: Introduce unique dungeons, raids, or zones unavailable in other servers. Player-Driven Economy: Implement a strong market system and avoid overinflated drops or rewards. Epic Siege Battles: Announce special large-scale sieges and PvP events. Incentives for Streamers and Clans: Attract influencers and big clans to boost server publicity. Roadmap Transparency: Share a public roadmap of planned updates to build trust and excitemen   Here you can read all the features: https://l2soe.com/features   Video preview: Join the Revolution! This is your chance to be part of something legendary. L2 Saga of Eternia is not just a server; it’s a movement to redefine what Lineage 2 can be. Whether you’re a seasoned veteran or a newcomer to the world of Aden, we invite you to experience Lineage 2 at its finest.   Official Launch Date: December 6th 2024 Website: https://l2soe.com/ Facebook: https://www.facebook.com/l2soe Discord: https://discord.com/invite/l2eternia   Let’s build the ultimate Lineage 2 experience together. See you in-game! 🎮
    • That's like a tutorial on how to run l2 on MacOS Xd but good job for the investigation. 
    • small update: dc robe set sold   wts adena 1kk = 1.5$ 
    • DISCORD : utchiha_market telegram : https://t.me/utchiha_market SELLIX STORE : https://utchihamkt.mysellix.io/ Join our server for more products : https://discord.gg/hood-services https://campsite.bio/utchihaamkt
  • Topics

×
×
  • Create New...