Jump to content
  • 0

[Help]Remove skills


Question

Posted

Hallo guys i have problem with remove buffs/dance/songs i had set it to TRUE At the cfg but still in game not working

how i can fix it i tryed to find the jar for cancel buff but ifound only this

* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
* 
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
* 
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.skills.effects;

import java.util.logging.Logger;

import com.l2jserver.Config;
import com.l2jserver.gameserver.model.L2Effect;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.skills.Formulas;
import com.l2jserver.gameserver.templates.effects.EffectTemplate;
import com.l2jserver.gameserver.templates.skills.L2EffectType;
import com.l2jserver.util.Rnd;
import com.l2jserver.util.StringUtil;

/**
* 
* @author DS
*
*/
public class EffectCancel extends L2Effect
{
protected static final Logger _log = Logger.getLogger(EffectCancel.class.getName());

public EffectCancel(Env env, EffectTemplate template)
{
	super(env, template);
}

/**
 * 
 * @see com.l2jserver.gameserver.model.L2Effect#getEffectType()
 */
@Override
public L2EffectType getEffectType()
{
	return L2EffectType.CANCEL;
}

/**
 * 
 * @see com.l2jserver.gameserver.model.L2Effect#onStart()
 */
@Override
public boolean onStart()
{
	return cancel(getEffector(), getEffected(), this);
}

/**
 * 
 * @see com.l2jserver.gameserver.model.L2Effect#onActionTime()
 */
@Override
public boolean onActionTime()
{
	return false;
}

private static boolean cancel(L2Character caster, L2Character target, L2Effect effect)
{
	if (!(target instanceof L2PcInstance)|| target.isDead())
		return false;

	final int cancelLvl = effect.getSkill().getMagicLevel();
	int count = effect.getSkill().getMaxNegatedEffects();

	double rate = effect.getEffectPower();
	final double vulnModifier = Formulas.calcSkillTypeVulnerability(0, target, effect.getSkillType());
	final double profModifier = Formulas.calcSkillTypeProficiency(0, caster, target, effect.getSkillType());
	double res = vulnModifier + profModifier;
	double resMod = 1;
	if (res != 0)
	{
		if (res < 0)
		{
			resMod = 1 - 0.075 * res;
			resMod = 1 / resMod;
		}
		else
			resMod = 1 + 0.02 * res;

		rate *= resMod;
	}

	if (caster.isDebug())
	{
		final StringBuilder stat = new StringBuilder(100);
		StringUtil.append(stat,
				effect.getSkill().getName(),
				" power:", String.valueOf((int)effect.getEffectPower()),
				" lvl:", String.valueOf(cancelLvl),
				" res:", String.format("%1.2f", resMod), "(",
				String.format("%1.2f", profModifier), "/",
				String.format("%1.2f", vulnModifier),
				") total:", String.valueOf(rate)
		);
		final String result = stat.toString();
		if (caster.isDebug())
			caster.sendDebugMessage(result);
		if (Config.DEVELOPER)
			_log.info(result);
	}

	final L2Effect[] effects = target.getAllEffects();

	if (effect.getSkill().getNegateAbnormals() != null) // Cancel for abnormals
	{
		for (L2Effect eff : effects)
		{
			if (eff == null)
				continue;

			for (String negateAbnormalType : effect.getSkill().getNegateAbnormals().keySet())
			{
				if (negateAbnormalType.equalsIgnoreCase(eff.getAbnormalType()) && effect.getSkill().getNegateAbnormals().get(negateAbnormalType) >= eff.getAbnormalLvl())
				{
					if (calcCancelSuccess(eff, cancelLvl, (int)rate))
						eff.exit();
				}
			}
		}
	}
	else
	{
		L2Effect eff;
		int lastCanceledSkillId = 0;

		for (int i = effects.length; --i >= 0;)
		{
			eff = effects[i];
			if (eff == null)
				continue;

			if (!eff.canBeStolen())
			{
				effects[i] = null;
				continue;
			}

			// first pass - dances/songs only
			if (!eff.getSkill().isDance())
				continue;

			if (eff.getSkill().getId() == lastCanceledSkillId)
			{
				eff.exit(); // this skill already canceled
				continue;
			}

			if (!calcCancelSuccess(eff, cancelLvl, (int)rate))
				continue;

			lastCanceledSkillId = eff.getSkill().getId();

			eff.exit();
			count--;

			if (count == 0)
				break;
		}

		if (count != 0)
		{
			lastCanceledSkillId = 0;
			for (int i = effects.length; --i >= 0;)
			{
				eff = effects[i];
				if (eff == null)
					continue;

				// second pass - all except dances/songs
				if (eff.getSkill().isDance())
					continue;

				if (eff.getSkill().getId() == lastCanceledSkillId)
				{
					eff.exit(); // this skill already canceled
					continue;
				}

				if (!calcCancelSuccess(eff, cancelLvl, (int)rate))
					continue;

				lastCanceledSkillId = eff.getSkill().getId();
				eff.exit();
				count--;

				if (count == 0)
					break;
			}
		}
	}

	return true;
}

private static boolean calcCancelSuccess(L2Effect effect, int cancelLvl, int baseRate)
{
	int rate = 2 * (cancelLvl - effect.getSkill().getMagicLevel());
	rate += effect.getAbnormalTime()/120;
	rate += baseRate;

	if (rate < 25)
		rate = 25;
	else if (rate > 75)
		rate = 75;

	return Rnd.get(100) < rate;
}
}

iam really newbiew at java coding

 

l2jfreya PACK

4 answers to this question

Recommended Posts

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

    • 10-17-2025 - OUR TOPIC IS RELEVANT! CONTACT US BY THE CONTACTS BELOW
    • Tell a Škoda 1.4 driver that a Škoda 1.8 is faster — and suddenly, you’re riding a mini race car. On the way, they might share random stories — gas prices, the perfect BBQ recipe, or how passengers once called them “just for a minute.” Maybe even how someone left a suitcase full of money in their car once.     The important part? You’ll get there on time, no delays.     Vibe SMS works just as fast — messages fly like that driver who just heard their 1.8 isn’t the fastest.     🌐 https://vibe-sms.net/ 📲 https://t.me/vibe_sms  
    • ⚔️ The Grand Opening Has Arrived! ⚔️ In just a few hours the gate to the eternal battlefield will be open and the war between Order and Chaos will be set once again ! Its time to claim your destiny 🔥 👉 Register now and join the fight today! 🌐 https://l2ovc.com register now : https://l2ovc.com The gates are open the war between Order and Chaos has officially started! 🔥 Join the battlefield NOW and claim your destiny in Order vs Chaos! 💥 Don’t fall behind your faction needs you. ➡️ https://l2ovc.com  
    • Don’t miss the new Telegram gifts with our Telegram Stars purchasing bot! A great opportunity to invest in a stable digital asset at an early stage while the market is still forming. Buy other existing gifts in the official store using Telegram Stars, pay for subscriptions, donate to games and projects, pay for Premium subscriptions, and react to messages in channels! Low prices, multiple payment options, and other cool unique features! ⚡ Try it today — SOCNET STARS BOT ⚡ Active links to SOCNET stores: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store via Telegram messenger. ⭐ Telegram Stars Purchase Bot: Go – fast and profitable way to buy stars in Telegram. SMM Panel: Go – promote your social media accounts. We present to you the current list of promotions and special offers for purchasing our products and services: 1️⃣ Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, bot) in October! You can also use the promo code SOCNET (15% discount) for your first purchase. 2️⃣ Get $1 on your store balance or a 10–20% discount — just write your username after registration on our website using the template: "SEND ME BONUS, MY USERNAME IS..." — post it in our forum thread! 3️⃣ Get $1 for your first SMM Panel trial — simply open a ticket titled “Get Trial Bonus” on our website (Support). 4️⃣ Weekly ⭐ Telegram Stars giveaways in our Telegram channel and in our Telegram Stars bot! News: ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ WhatsApp Channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord Server: https://discord.gg/y9AStFFsrh Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
  • 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