Jump to content

Recommended Posts

Posted (edited)

Some time ago i helped someone with disabling shot spells. So, the next code it's more elegant solution than my previous guide. Example of course will for aCis but adapt for any other pack not a problem, i guess.

 

For broadcasting all shot spells except soulshot uses broadcastPacketInRadius method into Creature.java. So, then we changing him.

 

	public void broadcastPacketInRadius(GameServerPacket packet, int radius)
	{
		if (radius < 0)
			radius = 600;
		
		// Check if packet is MagicSkillUse.
		final boolean isMagicSkillUse = (packet instanceof MagicSkillUse);
		for (final Player player : getKnownTypeInRadius(Player.class, radius))
		{
			// Check if magicSkillUse contains Shot's skill and check if player disabled shot spells.
			if (isMagicSkillUse && SkillTable.isShotSkill(((MagicSkillUse) packet).getSkillId()) && player.getGameSettings().isBlockedShotEffect())
				continue;
			
			player.sendPacket(packet);
		}
	}

 

Next one step we add fix for soulshot spells broadcasting via broadcastPacket() method.

 

	public void broadcastPacket(GameServerPacket packet, boolean selfToo)
	{
		final boolean isAttackWithShots = (packet instanceof Attack) && ((Attack) packet).soulshot;
		
		Attack attackPacket = null;
		if (isAttackWithShots)
		{
			attackPacket = new Attack(((Attack) packet).getAttacker(), false, 0);
			final HitHolder[] holder = ((Attack) packet).getHits();
			final HitHolder[] newHolder = new HitHolder[holder.length];
			
			// This magic need for cleanup FLAG bit mask from SS usage.
			for (int i = 0; i < newHolder.length; i++)
				newHolder[i] = new HitHolder(holder[i]._target, holder[i]._damage, holder[i]._crit, holder[i]._miss, holder[i]._shld);
			
			// Generating FLAG bit mast anew.
			attackPacket.processHits(newHolder);
		}
		
		for (final Player player : getKnownType(Player.class))
		{
			if (isAttackWithShots && player.getGameSettings().isBlockedShotEffect() && attackPacket != null)
			{
				player.sendPacket(attackPacket);
				continue;
			}
			
			player.sendPacket(packet);
		}
	}

 

Next one step we add return methods for some fields in Attack packet. Don't forget change field INT to Creature for storing attaker as object, and not object ID. And add changes into constuct method also.

 

	public Creature getAttacker()
	{
		return _attacker;
	}
	
	public HitHolder[] getHits()
	{
		return _hits;
	}

 

Next one step add method inside MagicSkillUse packet for getting skill id of sendable skill.

 

	public int getSkillId()
	{
		return _skillId;
	}

 

Next one step add into SkillTable array with shot's skill IDs and method for checking them.

 

	private static final int[] _shotSkillsId =
	{
		2008,
		2009,
		2033,
		2039,
		2047,
		2061,
		2150,
		2151,
		2152,
		2153,
		2154,
		2155,
		2156,
		2157,
		2158,
		2159,
		2160,
		2161,
		2162,
		2163,
		2164,
		2181,
		2182,
		2183,
		2184,
		2185,
		2186
	};
	
	public static boolean isShotSkill(int skillId)
	{
		for (int id : _shotSkillsId)
			if (id == skillId)
				return true;
			
		return false;
	}

 

Next one step is addition trigger option for store player configuration as i'm uses (player.getGameSettings().isBlockedShotEffect()). I uses separated GameSetting instance for all player's settings. You can make directly the new field inside Player.java and use like player.isBlockedShotEffect().

 

That's all what you need. This code disable all spells (SoulShot, SpritShot, Blessed SpiritShot, Beats Shot, Fishing Shot) from other objects except your spells. If you need add own servitor spell seeing then just add new return method in MagicSkillUse for get caster object IOD and thek him with your servitor object ID.

 

 

Edited by Rootware
Added SoulShot usage fix.
Posted
2 hours ago, Rootware said:

Some time ago i helped someone with disabling shot spells. So, the next code it's more elegant solution than my previous guide. Example of course will for aCis but adapt for any other pack not a problem, i guess.

 

AFor broadcasting shot spelss uses broadcastPacketInRadius method into Creature.java. So, then we changing him.

 


	public void broadcastPacketInRadius(GameServerPacket packet, int radius)
	{
		if (radius < 0)
			radius = 600;
		
		// Check if packet is MagicSkillUse.
		final boolean isMagicSkillUse = (packet instanceof MagicSkillUse);
		for (final Player player : getKnownTypeInRadius(Player.class, radius))
		{
			// Check if magicSkillUse contains Shot's skill and check if player disabled shot spells.
			if (isMagicSkillUse && SkillTable.isShotSkill(((MagicSkillUse) packet).getSkillId()) && player.getGameSettings().isBlockedShotEffect())
				continue;
			
			player.sendPacket(packet);
		}
	}

 

Next one step add method inside MagicSkillUse packet for getting skill id of sendable skill.

 


	public int getSkillId()
	{
		return _skillId;
	}

 

Next one step add into SkillTable array with shot's skill IDs and method for checking them.

 


	private static final int[] _shotSkillsId =
	{
		2008,
		2009,
		2033,
		2039,
		2047,
		2061,
		2150,
		2151,
		2152,
		2153,
		2154,
		2155,
		2156,
		2157,
		2158,
		2159,
		2160,
		2161,
		2162,
		2163,
		2164,
		2181,
		2182,
		2183,
		2184,
		2185,
		2186
	};
	
	public static boolean isShotSkill(int skillId)
	{
		for (int id : _shotSkillsId)
			if (id == skillId)
				return true;
			
		return false;
	}

 

Next one step is addition trigger option for store player configuration as i'm uses (player.getGameSettings().isBlockedShotEffect()). I uses separated GameSetting instance for all player's settings. You can make directly the new field inside Player.java and use like player.isBlockedShotEffect().

 

That's all what you need. This code disable all spells (SoulShot, SpritShot, Blessed SpiritShot, Beats Shot, Fishing Shot) from other objects except your spells. If you need add own servitor spell seeing then just add new return method in MagicSkillUse for get caster object IOD and thek him with your servitor object ID.

 

 

 

I created this diff to facilitate instead of creating a new variable to block I added it to the Block List, disregard if it doesn't help.

 

Block Effect - Pastebin.com

Posted
6 minutes ago, Williams said:

 

I created this diff to facilitate instead of creating a new variable to block I added it to the Block List, disregard if it doesn't help.

 

Block Effect - Pastebin.com

Your diff is outdated. Was added soulshot fix in Attack packet.

Posted (edited)
5 minutes ago, Rootware said:

Seu diferencial está desatualizado. Foi adicionado soulshot fix no pacote de ataque.

sorry I didn't see all the code I will redo the diff

Edited by Williams
Posted
2 minutes ago, Williams said:

sorry I didn't see all the code I will redo the diff

I think that pointles to make diff because not all parts of code completed. I meant the trigger for skipping spells.

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
Reply to this topic...

×   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, I'm working with custom Icons and noticed that you can use 64x64 icons and the client will handle them without problems in the Inventory and when you Drag them, they look HD so it's really cool, the problem starts when you move them to the shortcut bar, when they're placed there instead of rescaling the icon it just show the upper left corner (so it's 32x32 but showing only the part that fits in that space). I tried checking interface.u but can't find the line where the size for the icons in the shortcut bar are handled.   When in Inventory the item shows in a 32x32 size, if I use a 64x64 icon it re-scales so the icon looks great When dragging the item the image becomes 64x64 which looks pretty big, but it works good When placing the item in the shortcut bar only the top left of the icon is visible   Is there a way I can adjust the shortcut bar so that it re-scales the icon?
    • If you want to edit a large amount of entries in the L2 File-edit I recommend using excel, since both work with columns you can copy the entire file or just a few lines and paste it in excel and it will copy without problems, after you're done with editing you just select the cells and paste them in the .dat file making sure you're formatting correctly. I'm currently doing a massive edit on all gear and that's how i'm handling the .dat work
    • the logic is the "stacking" that is a filter if you use it then the item cannot co-exist (stack)
    • [Exclusive L2Gold Weekend Server] Available ONLY on Saturdays & Sundays – nowhere else, no other time ! Custom Armors (Dynasty, Apella) Custom Weapons (L2Gold Weapons) Custom Jewelry (L2Gold Jewelry) Custom Teleport System Custom AIO Buffer Custom Zones & NPCs Custom Raidboss … and much more waiting for you every weekend! This is not just another private server – it’s a limited-time battleground. When the weekend comes, everyone gathers in one place for the ultimate L2 experience. 👉 Online: Saturday–Sunday only 👉 Contact / Info: [https://www.facebook.com/profile.php?id=61578869175323]
    • ⏳ The price drops like sand slipping down in an hourglass.   📉 USA numbers are already at the lowest 💸 🌍 Next in line: Europe, Asia, and dozens of other countries.     All next week we’ll be actively working on lowering prices. The process has already started  soon costs will be much cheaper. 🔥 Get ready: the price drop will affect every country!   Website link — https://vibe-sms.net/ Our Telegram channel — https://t.me/vibe_sms
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock