actual freya branch

This commit is contained in:
2026-09-12 15:39:57 +00:00
parent 9fa534b20e
commit 8049e0a882
18540 changed files with 1228200 additions and 0 deletions
@@ -0,0 +1,114 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.handler.SkillHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* This class ...
*
* @author earendil
*
* @version $Revision: 1.1.2.2.2.4 $ $Date: 2005/04/06 16:13:48 $
*/
public class BalanceLife implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.BALANCE_LIFE
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
// L2Character activeChar = activeChar;
// check for other effects
ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(L2SkillType.BUFF);
if (handler != null)
handler.useSkill(activeChar, skill, targets);
L2PcInstance player = null;
if (activeChar instanceof L2PcInstance)
player = (L2PcInstance) activeChar;
double fullHP = 0;
double currentHPs = 0;
for (L2Character target: (L2Character[]) targets)
{
// We should not heal if char is dead/
if (target == null || target.isDead())
continue;
// Player holding a cursed weapon can't be healed and can't heal
if (target != activeChar)
{
if (target instanceof L2PcInstance && ((L2PcInstance) target).isCursedWeaponEquipped())
continue;
else if (player != null && player.isCursedWeaponEquipped())
continue;
}
fullHP += target.getMaxHp();
currentHPs += target.getCurrentHp();
}
double percentHP = currentHPs / fullHP;
for (L2Character target: (L2Character[]) targets)
{
if (target == null || target.isDead())
continue;
// Player holding a cursed weapon can't be healed and can't heal
if (target != activeChar)
{
if (target instanceof L2PcInstance && ((L2PcInstance) target).isCursedWeaponEquipped())
continue;
else if (player != null && player.isCursedWeaponEquipped())
continue;
}
double newHP = target.getMaxHp() * percentHP;
target.setCurrentHp(newHP);
StatusUpdate su = new StatusUpdate(target);
su.addAttribute(StatusUpdate.CUR_HP, (int) target.getCurrentHp());
target.sendPacket(su);
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,62 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2FortBallistaInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
import com.l2jserver.util.Rnd;
public class BallistaBomb implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.BALLISTA
};
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (!(activeChar instanceof L2PcInstance))
return;
L2Object[] targetList = skill.getTargetList(activeChar);
if (targetList == null || targetList.length == 0)
{
return;
}
L2Character target = (L2Character) targetList[0];
if (target instanceof L2FortBallistaInstance)
{
if (Rnd.get(3) == 0)
{
target.setIsInvul(false);
target.reduceCurrentHp(target.getMaxHp() + 1, activeChar, skill);
}
}
}
/**
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,87 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2TamedBeastInstance;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* @author _drunk_
*
*/
public class BeastSkills implements ISkillHandler
{
// private static Logger _log = Logger.getLogger(BeastSkills.class.getName());
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.BEAST_FEED,
L2SkillType.BEAST_RELEASE,
L2SkillType.BEAST_RELEASE_ALL,
L2SkillType.BEAST_SKILL,
L2SkillType.BEAST_ACCOMPANY
};
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (!(activeChar instanceof L2PcInstance))
return;
L2SkillType type = skill.getSkillType();
L2PcInstance player = activeChar.getActingPlayer();
L2Object target = player.getTarget();
switch(type)
{
case BEAST_FEED:
L2Object[] targetList = skill.getTargetList(activeChar);
if (targetList == null)
{
return;
}
// This is just a dummy skill handler for the golden food and crystal food skills,
// since the AI responce onSkillUse handles the rest.
break;
case BEAST_RELEASE:
if (target != null && target instanceof L2TamedBeastInstance)
((L2TamedBeastInstance)target).deleteMe();
break;
case BEAST_RELEASE_ALL:
if (player.getTrainedBeasts() != null)
for(L2TamedBeastInstance beast : player.getTrainedBeasts())
beast.deleteMe();
break;
case BEAST_ACCOMPANY:
// Unknown effect now
break;
case BEAST_SKILL:
if (target != null && target instanceof L2TamedBeastInstance)
((L2TamedBeastInstance)target).castBeastSkills();
break;
}
}
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,221 @@
/*
* 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 handlers.skillhandlers;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Effect;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.skills.BaseStats;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.skills.Formulas;
import com.l2jserver.gameserver.templates.item.L2WeaponType;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
*
* @author Steuf
*/
public class Blow implements ISkillHandler
{
private static final Logger _logDamage = Logger.getLogger("damage");
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.BLOW
};
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (activeChar.isAlikeDead())
return;
for (L2Character target: (L2Character[]) targets)
{
if (target.isAlikeDead())
continue;
// Check firstly if target dodges skill
final boolean skillIsEvaded = Formulas.calcPhysicalSkillEvasion(target, skill);
if (!skillIsEvaded && Formulas.calcBlowSuccess(activeChar, target, skill))
{
final byte reflect = Formulas.calcSkillReflect(target, skill);
if (skill.hasEffects())
{
if (reflect == Formulas.SKILL_REFLECT_SUCCEED)
{
activeChar.stopSkillEffects(skill.getId());
skill.getEffects(target, activeChar);
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
sm.addSkillName(skill);
activeChar.sendPacket(sm);
}
else
{
final byte shld = Formulas.calcShldUse(activeChar, target, skill);
target.stopSkillEffects(skill.getId());
if (Formulas.calcSkillSuccess(activeChar, target, skill, shld, false, false, true))
{
skill.getEffects(activeChar, target, new Env(shld, false, false, false));
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
sm.addSkillName(skill);
target.sendPacket(sm);
}
else
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_RESISTED_YOUR_S2);
sm.addCharName(target);
sm.addSkillName(skill);
activeChar.sendPacket(sm);
}
}
}
L2ItemInstance weapon = activeChar.getActiveWeaponInstance();
boolean soul = (weapon != null && weapon.getChargedSoulshot() == L2ItemInstance.CHARGED_SOULSHOT && (weapon.getItemType() == L2WeaponType.DAGGER || weapon.getItemType() == L2WeaponType.DUALDAGGER || weapon.getItemType() == L2WeaponType.RAPIER));
byte shld = Formulas.calcShldUse(activeChar, target, skill);
double damage = (int) Formulas.calcBlowDamage(activeChar, target, skill, shld, soul);
if (skill.getMaxSoulConsumeCount() > 0 && activeChar instanceof L2PcInstance)
{
switch (((L2PcInstance) activeChar).getSouls())
{
case 0:
break;
case 1:
damage *= 1.10;
break;
case 2:
damage *= 1.12;
break;
case 3:
damage *= 1.15;
break;
case 4:
damage *= 1.18;
break;
default:
damage *= 1.20;
break;
}
}
// Crit rate base crit rate for skill, modified with STR bonus
if (Formulas.calcCrit(skill.getBaseCritRate() * 10 * BaseStats.STR.calcBonus(activeChar), target))
damage *= 2;
if (soul)
weapon.setChargedSoulshot(L2ItemInstance.CHARGED_NONE);
if (Config.LOG_GAME_DAMAGE
&& activeChar instanceof L2Playable
&& damage > Config.LOG_GAME_DAMAGE_THRESHOLD)
{
LogRecord record = new LogRecord(Level.INFO, "");
record.setParameters(new Object[]{activeChar, " did damage ", (int)damage, skill, " to ", target});
record.setLoggerName("pdam");
_logDamage.log(record);
}
target.reduceCurrentHp(damage, activeChar, skill);
// vengeance reflected damage
if ((reflect & Formulas.SKILL_REFLECT_VENGEANCE) != 0)
{
if (target instanceof L2PcInstance)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.COUNTERED_C1_ATTACK);
sm.addCharName(activeChar);
target.sendPacket(sm);
}
if (activeChar instanceof L2PcInstance)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_PERFORMING_COUNTERATTACK);
sm.addCharName(target);
activeChar.sendPacket(sm);
}
// Formula from Diego post, 700 from rpg tests
double vegdamage = (700 * target.getPAtk(activeChar) / activeChar.getPDef(target));
activeChar.reduceCurrentHp(vegdamage, target, skill);
}
// Manage attack or cast break of the target (calculating rate, sending message...)
if (!target.isRaid() && Formulas.calcAtkBreak(target, damage))
{
target.breakAttack();
target.breakCast();
}
if(activeChar instanceof L2PcInstance)
{
L2PcInstance activePlayer = (L2PcInstance) activeChar;
activePlayer.sendDamageMessage(target, (int)damage, false, true, false);
}
}
// Sending system messages
if (skillIsEvaded)
{
if (activeChar instanceof L2PcInstance)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DODGES_ATTACK);
sm.addString(target.getName());
((L2PcInstance) activeChar).sendPacket(sm);
}
if (target instanceof L2PcInstance)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.AVOIDED_C1_ATTACK);
sm.addString(activeChar.getName());
((L2PcInstance) target).sendPacket(sm);
}
}
//Possibility of a lethal strike
Formulas.calcLethalHit(activeChar, target, skill);
//Self Effect
if (skill.hasSelfEffects())
{
final L2Effect effect = activeChar.getFirstEffect(skill.getId());
if (effect != null && effect.isSelfEffect())
effect.exit();
skill.getEffectsSelf(activeChar);
}
}
}
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,259 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.Config;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Effect;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.skills.Formulas;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
import com.l2jserver.util.Rnd;
import com.l2jserver.util.StringUtil;
/**
*
* @author DS
*
*/
public class Cancel implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.CANCEL,
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
if (weaponInst != null)
{
if (skill.isMagic())
{
if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
else if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_SPIRITSHOT)
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
}
}
else if (activeChar instanceof L2Summon)
{
final L2Summon activeSummon = (L2Summon) activeChar;
if (skill.isMagic())
{
if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
else if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_SPIRITSHOT)
activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
}
}
else if (activeChar instanceof L2Npc)
{
((L2Npc)activeChar)._soulshotcharged = false;
((L2Npc)activeChar)._spiritshotcharged = false;
}
L2Character target;
L2Effect effect;
final int cancelLvl, minRate, maxRate;
cancelLvl = skill.getMagicLevel();
minRate = 25;
maxRate = 80;
for (L2Object obj : targets)
{
if (!(obj instanceof L2Character))
continue;
target = (L2Character)obj;
if (target.isDead())
continue;
int lastCanceledSkillId = 0;
int count = skill.getMaxNegatedEffects();
double rate = skill.getPower();
final double vulnModifier = Formulas.calcSkillTypeVulnerability(0, target, skill.getSkillType());
final double profModifier = Formulas.calcSkillTypeProficiency(0, activeChar, target, skill.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 (activeChar.isDebug())
{
final StringBuilder stat = new StringBuilder(100);
StringUtil.append(stat,
skill.getName(),
" power:", String.valueOf((int)skill.getPower()),
" 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 (activeChar.isDebug())
activeChar.sendDebugMessage(result);
if (Config.DEVELOPER)
_log.info(result);
}
final L2Effect[] effects = target.getAllEffects();
if (skill.getNegateAbnormals() != null) // Cancel for abnormals
{
for (L2Effect eff : effects)
{
if (eff == null)
continue;
for (String negateAbnormalType : skill.getNegateAbnormals().keySet())
{
if (negateAbnormalType.equalsIgnoreCase(eff.getAbnormalType()) && skill.getNegateAbnormals().get(negateAbnormalType) >= eff.getAbnormalLvl())
{
if (calcCancelSuccess(eff, cancelLvl, (int)rate, minRate, maxRate))
eff.exit();
}
}
}
}
else
{
for (int i = effects.length; --i >= 0;)
{
effect = effects[i];
if (effect == null)
continue;
if (!effect.canBeStolen())
{
effects[i] = null;
continue;
}
// first pass - dances/songs only
if (!effect.getSkill().isDance())
continue;
if (effect.getSkill().getId() == lastCanceledSkillId)
{
effect.exit(); // this skill already canceled
continue;
}
if (!calcCancelSuccess(effect, cancelLvl, (int)rate, minRate, maxRate))
continue;
lastCanceledSkillId = effect.getSkill().getId();
effect.exit();
count--;
if (count == 0)
break;
}
if (count != 0)
{
lastCanceledSkillId = 0;
for (int i = effects.length; --i >= 0;)
{
effect = effects[i];
if (effect == null)
continue;
// second pass - all except dances/songs
if (effect.getSkill().isDance())
continue;
if (effect.getSkill().getId() == lastCanceledSkillId)
{
effect.exit(); // this skill already canceled
continue;
}
if (!calcCancelSuccess(effect, cancelLvl, (int)rate, minRate, maxRate))
continue;
lastCanceledSkillId = effect.getSkill().getId();
effect.exit();
count--;
if (count == 0)
break;
}
}
}
//Possibility of a lethal strike
Formulas.calcLethalHit(activeChar, target, skill);
}
// Applying self-effects
if (skill.hasSelfEffects())
{
effect = activeChar.getFirstEffect(skill.getId());
if (effect != null && effect.isSelfEffect())
{
//Replace old effect with new one.
effect.exit();
}
skill.getEffectsSelf(activeChar);
}
}
private boolean calcCancelSuccess(L2Effect effect, int cancelLvl, int baseRate, int minRate, int maxRate)
{
int rate = 2 * (cancelLvl - effect.getSkill().getMagicLevel());
rate += effect.getAbnormalTime()/120;
rate += baseRate;
if (rate < minRate)
rate = minRate;
else if (rate > maxRate)
rate = maxRate;
return Rnd.get(100) < rate;
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,71 @@
/*
* 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 handlers.skillhandlers;
import java.util.logging.Logger;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Effect;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* This class ...
*
* @version $Revision: 1.1.2.2.2.9 $ $Date: 2005/04/04 19:08:01 $
*/
public class Charge implements ISkillHandler
{
static Logger _log = Logger.getLogger(Charge.class.getName());
/* (non-Javadoc)
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.L2PcInstance, com.l2jserver.gameserver.model.L2ItemInstance)
*/
private static final L2SkillType[] SKILL_IDS =
{/*L2SkillType.CHARGE*/};
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
for (L2Object target: targets)
{
if (!(target instanceof L2PcInstance))
continue;
skill.getEffects(activeChar, (L2PcInstance) target);
}
// self Effect :]
if (skill.hasSelfEffects())
{
final L2Effect effect = activeChar.getFirstEffect(skill.getId());
if (effect != null && effect.isSelfEffect())
{
//Replace old effect with new one.
effect.exit();
}
skill.getEffectsSelf(activeChar);
}
}
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,76 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.handler.SkillHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* This class ...
*
* @version $Revision: 1.1.2.2.2.1 $ $Date: 2005/03/02 15:38:36 $
*/
public class CombatPointHeal implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.COMBATPOINTHEAL
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character actChar, L2Skill skill, L2Object[] targets)
{
//check for other effects
ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(L2SkillType.BUFF);
if (handler != null)
handler.useSkill(actChar, skill, targets);
for (L2Character target: (L2Character[]) targets)
{
if (target.isInvul())
continue;
double cp = skill.getPower();
if ((target.getCurrentCp() + cp) >= target.getMaxCp())
cp = target.getMaxCp() - target.getCurrentCp();
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CP_WILL_BE_RESTORED);
sm.addNumber((int) cp);
target.sendPacket(sm);
target.setCurrentCp(cp + target.getCurrentCp());
StatusUpdate sump = new StatusUpdate(target);
sump.addAttribute(StatusUpdate.CUR_CP, (int) target.getCurrentCp());
target.sendPacket(sump);
}
}
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,274 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.ai.CtrlEvent;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.datatables.SkillTable;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.instancemanager.DuelManager;
import com.l2jserver.gameserver.model.L2Effect;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Attackable;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.actor.instance.L2ClanHallManagerInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2SummonInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.skills.Formulas;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* This class ...
*
* @version $Revision: 1.1.2.2.2.9 $ $Date: 2005/04/03 15:55:04 $
*/
public class Continuous implements ISkillHandler
{
//private static Logger _log = Logger.getLogger(Continuous.class.getName());
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.BUFF,
L2SkillType.DEBUFF,
L2SkillType.DOT,
L2SkillType.MDOT,
L2SkillType.POISON,
L2SkillType.BLEED,
L2SkillType.HOT,
L2SkillType.CPHOT,
L2SkillType.MPHOT,
L2SkillType.FEAR,
L2SkillType.CONT,
L2SkillType.UNDEAD_DEFENSE,
L2SkillType.AGGDEBUFF,
L2SkillType.FUSION
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
boolean acted = true;
L2PcInstance player = null;
if (activeChar instanceof L2PcInstance)
player = (L2PcInstance) activeChar;
if (skill.getEffectId() != 0)
{
L2Skill sk = SkillTable.getInstance().getInfo(skill.getEffectId(), skill.getEffectLvl() == 0 ? 1 : skill.getEffectLvl());
if (sk != null)
skill = sk;
}
for (L2Character target: (L2Character[]) targets)
{
boolean ss = false;
boolean sps = false;
boolean bss = false;
byte shld = 0;
if (Formulas.calcSkillReflect(target, skill) == Formulas.SKILL_REFLECT_SUCCEED)
target = activeChar;
// Player holding a cursed weapon can't be buffed and can't buff
if (skill.getSkillType() == L2SkillType.BUFF && !(activeChar instanceof L2ClanHallManagerInstance))
{
if (target != activeChar)
{
if (target instanceof L2PcInstance)
{
L2PcInstance trg = (L2PcInstance)target;
if(trg.isCursedWeaponEquipped())
continue;
// Avoiding block checker players get buffed from outside
else if(trg.getBlockCheckerArena() != -1)
continue;
}
else if (player != null && player.isCursedWeaponEquipped())
continue;
}
}
switch (skill.getSkillType())
{
case HOT:
case CPHOT:
case MPHOT:
if (activeChar.isInvul())
continue;
break;
}
if (skill.isOffensive() || skill.isDebuff())
{
L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
if (weaponInst != null)
{
if (skill.isMagic())
{
if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
{
bss = true;
if (skill.getId() != 1020) // vitalize
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
}
else if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_SPIRITSHOT)
{
sps = true;
if (skill.getId() != 1020) // vitalize
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
}
}
else if (weaponInst.getChargedSoulshot() == L2ItemInstance.CHARGED_SOULSHOT)
{
ss = true;
if (skill.getId() != 1020) // vitalize
weaponInst.setChargedSoulshot(L2ItemInstance.CHARGED_NONE);
}
}
else if (activeChar instanceof L2Summon)
{
L2Summon activeSummon = (L2Summon) activeChar;
if (skill.isMagic())
{
if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
{
bss = true;
activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
}
else if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_SPIRITSHOT)
{
sps = true;
activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
}
}
else if (activeSummon.getChargedSoulShot() == L2ItemInstance.CHARGED_SOULSHOT)
{
ss = true;
activeSummon.setChargedSoulShot(L2ItemInstance.CHARGED_NONE);
}
}
else if (activeChar instanceof L2Npc)
{
ss = ((L2Npc) activeChar)._soulshotcharged;
((L2Npc) activeChar)._soulshotcharged = false;
bss = ((L2Npc) activeChar)._spiritshotcharged;
((L2Npc) activeChar)._spiritshotcharged = false;
}
shld = Formulas.calcShldUse(activeChar, target, skill);
acted = Formulas.calcSkillSuccess(activeChar, target, skill, shld, ss, sps, bss);
}
if (acted)
{
if (skill.isToggle())
{
L2Effect[] effects = target.getAllEffects();
if (effects != null)
{
for (L2Effect e : effects)
{
if (e != null)
{
if (e.getSkill().getId() == skill.getId())
{
e.exit();
return;
}
}
}
}
}
// if this is a debuff let the duel manager know about it
// so the debuff can be removed after the duel
// (player & target must be in the same duel)
if (target instanceof L2PcInstance && ((L2PcInstance) target).isInDuel() && (skill.getSkillType() == L2SkillType.DEBUFF || skill.getSkillType() == L2SkillType.BUFF) && player != null
&& player.getDuelId() == ((L2PcInstance) target).getDuelId())
{
DuelManager dm = DuelManager.getInstance();
for (L2Effect buff : skill.getEffects(activeChar, target, new Env(shld, ss, sps, bss)))
if (buff != null)
dm.onBuff(((L2PcInstance) target), buff);
}
else
{
L2Effect[] effects = skill.getEffects(activeChar, target, new Env(shld, ss, sps, bss));
L2Summon summon = target.getPet();
if (summon != null && summon != activeChar && summon instanceof L2SummonInstance && effects.length > 0)
{
if (effects[0].canBeStolen())
skill.getEffects(activeChar, target.getPet(), new Env(shld, ss, sps, bss));
}
}
if (skill.getSkillType() == L2SkillType.AGGDEBUFF)
{
if (target instanceof L2Attackable)
target.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, activeChar, (int) skill.getPower());
else if (target instanceof L2Playable)
{
if (target.getTarget() == activeChar)
target.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, activeChar);
else
target.setTarget(activeChar);
}
}
}
else
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ATTACK_FAILED));
}
// Possibility of a lethal strike
Formulas.calcLethalHit(activeChar, target, skill);
}
// self Effect :]
if (skill.hasSelfEffects())
{
final L2Effect effect = activeChar.getFirstEffect(skill.getId());
if (effect != null && effect.isSelfEffect())
{
//Replace old effect with new one.
effect.exit();
}
skill.getEffectsSelf(activeChar);
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,132 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.L2Summon;
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.skills.L2SkillType;
/*
* Just a quick draft to support Wrath skill. Missing angle based calculation etc.
*/
public class CpDam implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.CPDAM
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (activeChar.isAlikeDead())
return;
boolean ss = false;
boolean sps = false;
boolean bss = false;
L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
if (weaponInst != null)
{
if (skill.isMagic())
{
if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
{
bss = true;
}
else if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_SPIRITSHOT)
{
sps = true;
}
}
else if (weaponInst.getChargedSoulshot() == L2ItemInstance.CHARGED_SOULSHOT)
{
ss = true;
}
}
// If there is no weapon equipped, check for an active summon.
else if (activeChar instanceof L2Summon)
{
L2Summon activeSummon = (L2Summon) activeChar;
if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
{
bss = true;
activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
}
else if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_SPIRITSHOT)
{
ss = true;
activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
}
}
else if (activeChar instanceof L2Npc)
{
ss = ((L2Npc) activeChar)._soulshotcharged;
((L2Npc) activeChar)._soulshotcharged = false;
bss = ((L2Npc) activeChar)._spiritshotcharged;
((L2Npc) activeChar)._spiritshotcharged = false;
}
for (L2Character target: (L2Character[]) targets)
{
if (activeChar instanceof L2PcInstance && target instanceof L2PcInstance && ((L2PcInstance)target).isFakeDeath())
{
target.stopFakeDeath(true);
}
else if (target.isDead() || target.isInvul())
{
continue;
}
byte shld = Formulas.calcShldUse(activeChar, target, skill);
int damage = (int) (target.getCurrentCp() - (target.getCurrentCp() - skill.getPower()));
// Manage attack or cast break of the target (calculating rate, sending message...)
if (!target.isRaid() && Formulas.calcAtkBreak(target, damage))
{
target.breakAttack();
target.breakCast();
}
skill.getEffects(activeChar, target, new Env(shld, ss, sps, bss));
activeChar.sendDamageMessage(target, damage, false, false, false);
target.setCurrentCp(target.getCurrentCp() - damage);
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,132 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.L2Summon;
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.skills.L2SkillType;
/*
* Just a quick draft to support Wrath skill. Missing angle based calculation etc.
*/
public class CpDamPercent implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.CPDAMPERCENT
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (activeChar.isAlikeDead())
return;
boolean ss = false;
boolean sps = false;
boolean bss = false;
L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
if (weaponInst != null)
{
if (skill.isMagic())
{
if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
{
bss = true;
}
else if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_SPIRITSHOT)
{
sps = true;
}
}
else if (weaponInst.getChargedSoulshot() == L2ItemInstance.CHARGED_SOULSHOT)
{
ss = true;
}
}
// If there is no weapon equipped, check for an active summon.
else if (activeChar instanceof L2Summon)
{
L2Summon activeSummon = (L2Summon) activeChar;
if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
{
bss = true;
activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
}
else if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_SPIRITSHOT)
{
ss = true;
activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
}
}
else if (activeChar instanceof L2Npc)
{
ss = ((L2Npc) activeChar)._soulshotcharged;
((L2Npc) activeChar)._soulshotcharged = false;
bss = ((L2Npc) activeChar)._spiritshotcharged;
((L2Npc) activeChar)._spiritshotcharged = false;
}
for (L2Character target: (L2Character[]) targets)
{
if (activeChar instanceof L2PcInstance && target instanceof L2PcInstance && ((L2PcInstance)target).isFakeDeath())
{
target.stopFakeDeath(true);
}
else if (target.isDead() || target.isInvul())
{
continue;
}
byte shld = Formulas.calcShldUse(activeChar, target, skill);
int damage = (int) (target.getCurrentCp() * (skill.getPower() / 100));
// Manage attack or cast break of the target (calculating rate, sending message...)
if (!target.isRaid() && Formulas.calcAtkBreak(target, damage))
{
target.breakAttack();
target.breakCast();
}
skill.getEffects(activeChar, target, new Env(shld, ss, sps, bss));
activeChar.sendDamageMessage(target, damage, false, false, false);
target.setCurrentCp(target.getCurrentCp() - damage);
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,68 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.RecipeController;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* This class ...
*
* @version $Revision: 1.1.2.2.2.4 $ $Date: 2005/04/06 16:13:48 $
*/
public class Craft implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.COMMON_CRAFT,
L2SkillType.DWARVEN_CRAFT
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (!(activeChar instanceof L2PcInstance))
return;
L2PcInstance player = (L2PcInstance) activeChar;
if (player.getPrivateStoreType() != 0)
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_CREATED_WHILE_ENGAGED_IN_TRADING));
return;
}
RecipeController.getInstance().requestBookOpen(player, (skill.getSkillType() == L2SkillType.DWARVEN_CRAFT) ? true : false);
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,71 @@
/*
* 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 handlers.skillhandlers;
import java.util.logging.Logger;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
*
* @author Julian
*/
public class DeluxeKey implements ISkillHandler
{
private static Logger _log = Logger.getLogger(DeluxeKey.class.getName());
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.DELUXE_KEY_UNLOCK
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (!(activeChar instanceof L2PcInstance))
return;
L2Object[] targetList = skill.getTargetList(activeChar);
if (targetList == null)
{
return;
}
_log.fine("Delux key casting succeded.");
// This is just a dummy skill handler for the golden food and crystal food skills,
// since the AI responce onSkillUse handles the rest.
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,78 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Effect;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.templates.skills.L2EffectType;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* @author ZaKax
*/
public class Detection implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.DETECTION
};
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
final boolean hasParty;
final boolean hasClan;
final boolean hasAlly;
final L2PcInstance player = activeChar.getActingPlayer();
if (player != null)
{
hasParty = player.isInParty();
hasClan = player.getClanId() > 0;
hasAlly = player.getAllyId() > 0;
}
else
{
hasParty = false;
hasClan = false;
hasAlly = false;
}
for (L2PcInstance target : activeChar.getKnownList().getKnownPlayersInRadius(skill.getSkillRadius()))
{
if (target != null && target.getAppearance().getInvisible())
{
if (hasParty && target.getParty() != null && player.getParty().getPartyLeaderOID() == target.getParty().getPartyLeaderOID())
continue;
if (hasClan && player.getClanId() == target.getClanId())
continue;
if (hasAlly && player.getAllyId() == target.getAllyId())
continue;
L2Effect eHide = target.getFirstEffect(L2EffectType.HIDE);
if (eHide != null)
eHide.exit();
}
}
}
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,717 @@
/*
* 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 handlers.skillhandlers;
import java.util.logging.Logger;
import com.l2jserver.gameserver.ai.CtrlEvent;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.ai.L2AttackableAI;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.handler.SkillHandler;
import com.l2jserver.gameserver.model.L2Effect;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Attackable;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2SiegeSummonInstance;
import com.l2jserver.gameserver.model.base.Experience;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.skills.Formulas;
import com.l2jserver.gameserver.skills.Stats;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
import com.l2jserver.util.Rnd;
/**
* This Handles Disabler skills
* @author _drunk_
*/
public class Disablers implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.STUN,
L2SkillType.ROOT,
L2SkillType.SLEEP,
L2SkillType.CONFUSION,
L2SkillType.AGGDAMAGE,
L2SkillType.AGGREDUCE,
L2SkillType.AGGREDUCE_CHAR,
L2SkillType.AGGREMOVE,
L2SkillType.MUTE,
L2SkillType.FAKE_DEATH,
L2SkillType.CONFUSE_MOB_ONLY,
L2SkillType.NEGATE,
L2SkillType.CANCEL_DEBUFF,
L2SkillType.PARALYZE,
L2SkillType.ERASE,
L2SkillType.BETRAY,
L2SkillType.DISARM
};
protected static final Logger _log = Logger.getLogger(L2Skill.class.getName());
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
L2SkillType type = skill.getSkillType();
byte shld = 0;
boolean ss = false;
boolean sps = false;
boolean bss = false;
L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
if (weaponInst != null)
{
if (skill.isMagic())
{
if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
{
bss = true;
if (skill.getId() != 1020) // vitalize
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
}
else if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_SPIRITSHOT)
{
sps = true;
if (skill.getId() != 1020) // vitalize
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
}
}
else
ss = true;
}
// If there is no weapon equipped, check for an active summon.
else if (activeChar instanceof L2Summon)
{
L2Summon activeSummon = (L2Summon) activeChar;
if (skill.isMagic())
{
if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
{
bss = true;
activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
}
else if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_SPIRITSHOT)
{
sps = true;
activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
}
}
else
ss = true;
}
else if (activeChar instanceof L2Npc)
{
ss = ((L2Npc) activeChar)._soulshotcharged;
((L2Npc) activeChar)._soulshotcharged = false;
bss = ((L2Npc) activeChar)._spiritshotcharged;
((L2Npc) activeChar)._spiritshotcharged = false;
}
for (L2Object obj: targets)
{
if (!(obj instanceof L2Character))
continue;
L2Character target = (L2Character) obj;
if (target.isDead() || ((target.isInvul() && type != L2SkillType.NEGATE) && !target.isParalyzed())) // bypass if target is null, dead or invul (excluding invul from Petrification)
continue;
shld = Formulas.calcShldUse(activeChar, target, skill);
switch (type)
{
case BETRAY:
{
if (Formulas.calcSkillSuccess(activeChar, target, skill, shld, ss, sps, bss))
skill.getEffects(activeChar, target, new Env(shld, ss, sps, bss));
else
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_RESISTED_YOUR_S2);
sm.addCharName(target);
sm.addSkillName(skill);
activeChar.sendPacket(sm);
}
break;
}
case FAKE_DEATH:
{
// stun/fakedeath is not mdef dependant, it depends on lvl difference, target CON and power of stun
skill.getEffects(activeChar, target, new Env(shld, ss, sps, bss));
break;
}
case ROOT:
case DISARM:
case STUN:
{
if (Formulas.calcSkillReflect(target, skill) == Formulas.SKILL_REFLECT_SUCCEED)
target = activeChar;
if (Formulas.calcSkillSuccess(activeChar, target, skill, shld, ss, sps, bss))
skill.getEffects(activeChar, target, new Env(shld, ss, sps, bss));
else
{
if (activeChar instanceof L2PcInstance)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_RESISTED_YOUR_S2);
sm.addCharName(target);
sm.addSkillName(skill);
activeChar.sendPacket(sm);
}
}
break;
}
case SLEEP:
case PARALYZE: //use same as root for now
{
if (Formulas.calcSkillReflect(target, skill) == Formulas.SKILL_REFLECT_SUCCEED)
target = activeChar;
if (Formulas.calcSkillSuccess(activeChar, target, skill, shld, ss, sps, bss))
skill.getEffects(activeChar, target, new Env(shld, ss, sps, bss));
else
{
if (activeChar instanceof L2PcInstance)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_RESISTED_YOUR_S2);
sm.addCharName(target);
sm.addSkillName(skill);
activeChar.sendPacket(sm);
}
}
break;
}
case CONFUSION:
case MUTE:
{
if (Formulas.calcSkillReflect(target, skill) == Formulas.SKILL_REFLECT_SUCCEED)
target = activeChar;
if (Formulas.calcSkillSuccess(activeChar, target, skill, shld, ss, sps, bss))
{
// stop same type effect if available
L2Effect[] effects = target.getAllEffects();
for (L2Effect e : effects)
{
if (e.getSkill().getSkillType() == type)
e.exit();
}
skill.getEffects(activeChar, target, new Env(shld, ss, sps, bss));
}
else
{
if (activeChar instanceof L2PcInstance)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_RESISTED_YOUR_S2);
sm.addCharName(target);
sm.addSkillName(skill);
activeChar.sendPacket(sm);
}
}
break;
}
case CONFUSE_MOB_ONLY:
{
// do nothing if not on mob
if (target instanceof L2Attackable)
{
if (Formulas.calcSkillSuccess(activeChar, target, skill, shld, ss, sps, bss))
{
L2Effect[] effects = target.getAllEffects();
for (L2Effect e : effects)
{
if (e.getSkill().getSkillType() == type)
e.exit();
}
skill.getEffects(activeChar, target, new Env(shld, ss, sps, bss));
}
else
{
if (activeChar instanceof L2PcInstance)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_RESISTED_YOUR_S2);
sm.addCharName(target);
sm.addSkillName(skill);
activeChar.sendPacket(sm);
}
}
}
else
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
break;
}
case AGGDAMAGE:
{
if (target instanceof L2Attackable)
target.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, activeChar, (int) ((150 * skill.getPower()) / (target.getLevel() + 7)));
// TODO [Nemesiss] should this have 100% chance?
skill.getEffects(activeChar, target, new Env(shld, ss, sps, bss));
break;
}
case AGGREDUCE:
{
// these skills needs to be rechecked
if (target instanceof L2Attackable)
{
skill.getEffects(activeChar, target, new Env(shld, ss, sps, bss));
double aggdiff = ((L2Attackable) target).getHating(activeChar) - target.calcStat(Stats.AGGRESSION, ((L2Attackable) target).getHating(activeChar), target, skill);
if (skill.getPower() > 0)
((L2Attackable) target).reduceHate(null, (int) skill.getPower());
else if (aggdiff > 0)
((L2Attackable) target).reduceHate(null, (int) aggdiff);
}
// when fail, target.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, activeChar);
break;
}
case AGGREDUCE_CHAR:
{
// these skills needs to be rechecked
if (Formulas.calcSkillSuccess(activeChar, target, skill, shld, ss, sps, bss))
{
if (target instanceof L2Attackable)
{
L2Attackable targ = (L2Attackable) target;
targ.stopHating(activeChar);
if (targ.getMostHated() == null && targ.hasAI() && targ.getAI() instanceof L2AttackableAI)
{
((L2AttackableAI) targ.getAI()).setGlobalAggro(-25);
targ.clearAggroList();
targ.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
targ.setWalking();
}
}
skill.getEffects(activeChar, target, new Env(shld, ss, sps, bss));
}
else
{
if (activeChar instanceof L2PcInstance)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_RESISTED_YOUR_S2);
sm.addCharName(target);
sm.addSkillName(skill);
activeChar.sendPacket(sm);
}
target.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, activeChar);
}
break;
}
case AGGREMOVE:
{
// these skills needs to be rechecked
if (target instanceof L2Attackable && !target.isRaid())
{
if (Formulas.calcSkillSuccess(activeChar, target, skill, shld, ss, sps, bss))
{
if (skill.getTargetType() == L2Skill.SkillTargetType.TARGET_UNDEAD)
{
if (target.isUndead())
((L2Attackable) target).reduceHate(null, ((L2Attackable) target).getHating(((L2Attackable) target).getMostHated()));
}
else
((L2Attackable) target).reduceHate(null, ((L2Attackable) target).getHating(((L2Attackable) target).getMostHated()));
}
else
{
if (activeChar instanceof L2PcInstance)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_RESISTED_YOUR_S2);
sm.addCharName(target);
sm.addSkillName(skill);
activeChar.sendPacket(sm);
}
target.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, activeChar);
}
}
else
target.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, activeChar);
break;
}
case ERASE:
{
if (Formulas.calcSkillSuccess(activeChar, target, skill, shld, ss, sps, bss)
// doesn't affect siege golem or wild hog cannon
&& !(target instanceof L2SiegeSummonInstance))
{
L2PcInstance summonOwner = null;
L2Summon summonPet = null;
summonOwner = ((L2Summon) target).getOwner();
summonPet = summonOwner.getPet();
if (summonPet != null)
{
summonPet.unSummon(summonOwner);
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOUR_SERVITOR_HAS_VANISHED);
summonOwner.sendPacket(sm);
}
}
else
{
if (activeChar instanceof L2PcInstance)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_RESISTED_YOUR_S2);
sm.addCharName(target);
sm.addSkillName(skill);
activeChar.sendPacket(sm);
}
}
break;
}
case CANCEL_DEBUFF:
{
L2Effect[] effects = target.getAllEffects();
if (effects == null || effects.length == 0)
break;
int count = (skill.getMaxNegatedEffects() > 0) ? 0 : -2;
for (L2Effect e : effects)
{
if (e == null
|| !e.getSkill().isDebuff()
|| !e.getSkill().canBeDispeled())
continue;
e.exit();
if (count > -1)
{
count++;
if (count >= skill.getMaxNegatedEffects())
break;
}
}
break;
}
case CANCEL_STATS: // same than CANCEL but
{
if (Formulas.calcSkillReflect(target, skill) == Formulas.SKILL_REFLECT_SUCCEED)
target = activeChar;
if (Formulas.calcSkillSuccess(activeChar, target, skill, shld, ss, sps, bss))
{
L2Effect[] effects = target.getAllEffects();
int max = skill.getMaxNegatedEffects();
if (max == 0)
max = Integer.MAX_VALUE; //this is for RBcancells and stuff...
if (effects.length >= max)
effects = SortEffects(effects);
//for(int i = 0; i < effects.length;i++)
// activeChar.sendMessage(Integer.toString(effects[i].getSkill().getMagicLevel()));
int count = 1;
for (L2Effect e : effects)
{
// do not delete signet effects!
switch (e.getEffectType())
{
case SIGNET_GROUND:
case SIGNET_EFFECT:
continue;
}
switch(e.getSkill().getId())
{
case 4082:
case 4215:
case 4515:
case 5182:
case 110:
case 111:
case 1323:
case 1325:
continue;
}
switch (e.getSkill().getSkillType())
{
case BUFF:
case HEAL_PERCENT:
case COMBATPOINTHEAL:
break;
default:
continue;
}
double rate = 1 - (count / max);
if (rate < 0.33)
rate = 0.33;
else if (rate > 0.95)
rate = 0.95;
if (Rnd.get(1000) < (rate * 1000))
{
boolean exit = false;
for (L2SkillType skillType : skill.getNegateStats())
{
if (skillType == e.getSkillType())
{
exit = true;
break;
}
}
if (exit)
{
e.exit();
if (count == max)
break;
count++;
}
}
}
}
else
{
if (activeChar instanceof L2PcInstance)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_RESISTED_YOUR_S2);
sm.addCharName(target);
sm.addSkillName(skill);
activeChar.sendPacket(sm);
}
}
break;
}
case NEGATE:
{
if (Formulas.calcSkillReflect(target, skill) == Formulas.SKILL_REFLECT_SUCCEED)
target = activeChar;
if (skill.getNegateId().length != 0)
{
for (int i = 0; i < skill.getNegateId().length; i++)
{
if (skill.getNegateId()[i] != 0)
target.stopSkillEffects(skill.getNegateId()[i]);
}
}
else if (skill.getNegateAbnormals() != null)
{
for (L2Effect effect : target.getAllEffects())
{
if (effect == null)
continue;
for (String negateAbnormalType : skill.getNegateAbnormals().keySet())
{
if (negateAbnormalType.equalsIgnoreCase(effect.getAbnormalType()) && skill.getNegateAbnormals().get(negateAbnormalType) >= effect.getAbnormalLvl())
effect.exit();
}
}
}
else // all others negate type skills
{
int removedBuffs = (skill.getMaxNegatedEffects() > 0) ? 0 : -2;
for (L2SkillType skillType : skill.getNegateStats())
{
if (removedBuffs > skill.getMaxNegatedEffects())
break;
switch(skillType)
{
case BUFF:
int lvlmodifier = 52 + skill.getMagicLevel() * 2;
if (skill.getMagicLevel() == 12)
lvlmodifier = (Experience.MAX_LEVEL - 1);
int landrate = 90;
if ((target.getLevel() - lvlmodifier) > 0)
landrate = 90 - 4 * (target.getLevel() - lvlmodifier);
landrate = (int) activeChar.calcStat(Stats.CANCEL_VULN, landrate, target, null);
if (Rnd.get(100) < landrate)
removedBuffs += negateEffect(target, L2SkillType.BUFF, -1, skill.getMaxNegatedEffects());
break;
case HEAL:
ISkillHandler Healhandler = SkillHandler.getInstance().getSkillHandler(L2SkillType.HEAL);
if (Healhandler == null)
{
_log.severe("Couldn't find skill handler for HEAL.");
continue;
}
L2Character tgts[] = new L2Character[]{target};
Healhandler.useSkill(activeChar, skill, tgts);
break;
default:
removedBuffs += negateEffect(target, skillType, skill.getNegateLvl(), skill.getMaxNegatedEffects());
break;
}//end switch
}//end for
}//end else
if (Formulas.calcSkillSuccess(activeChar, target, skill, shld, ss, sps, bss))
{
skill.getEffects(activeChar, target, new Env(shld, ss, sps, bss));
}
}// end case
}//end switch
//Possibility of a lethal strike
Formulas.calcLethalHit(activeChar, target, skill);
}//end for
// self Effect :]
if (skill.hasSelfEffects())
{
final L2Effect effect = activeChar.getFirstEffect(skill.getId());
if (effect != null && effect.isSelfEffect())
{
//Replace old effect with new one.
effect.exit();
}
skill.getEffectsSelf(activeChar);
}
} //end void
/**
*
* @param target
* @param type
* @param power
* @param maxRemoved
* @return
*/
private int negateEffect(L2Character target, L2SkillType type, int negateLvl, int maxRemoved)
{
return negateEffect(target, type, negateLvl, 0, maxRemoved);
}
/**
*
* @param target
* @param type
* @param power
* @param skillId
* @param maxRemoved
* @return
*/
private int negateEffect(L2Character target, L2SkillType type, int negateLvl, int skillId, int maxRemoved)
{
L2Effect[] effects = target.getAllEffects();
int count = (maxRemoved <= 0) ? -2 : 0;
for (L2Effect e : effects)
{
if (negateLvl == -1) // if power is -1 the effect is always removed without power/lvl check ^^
{
if (e.getSkill().getSkillType() == type || (e.getSkill().getEffectType() != null && e.getSkill().getEffectType() == type))
{
if (skillId != 0)
{
if (skillId == e.getSkill().getId() && count < maxRemoved)
{
e.exit();
if (count > -1)
count++;
}
}
else if (count < maxRemoved)
{
e.exit();
if (count > -1)
count++;
}
}
}
else
{
boolean cancel = false;
if (e.getSkill().getEffectType() != null && e.getSkill().getEffectAbnormalLvl() >= 0)
{
if (e.getSkill().getEffectType() == type && e.getSkill().getEffectAbnormalLvl() <= negateLvl)
cancel = true;
}
else if (e.getSkill().getSkillType() == type && e.getSkill().getAbnormalLvl() <= negateLvl)
cancel = true;
if (cancel)
{
if (skillId != 0)
{
if (skillId == e.getSkill().getId() && count < maxRemoved)
{
e.exit();
if (count > -1)
count++;
}
}
else if (count < maxRemoved)
{
e.exit();
if (count > -1)
count++;
}
}
}
}
return (maxRemoved <= 0) ? count + 2 : count;
}
private L2Effect[] SortEffects(L2Effect[] initial)
{
//this is just classic insert sort
//If u can find better sort for max 20-30 units, rewrite this... :)
int min, index = 0;
L2Effect pom;
for (int i = 0; i < initial.length; i++)
{
min = initial[i].getSkill().getMagicLevel();
for (int j = i; j < initial.length; j++)
{
if (initial[j].getSkill().getMagicLevel() <= min)
{
min = initial[j].getSkill().getMagicLevel();
index = j;
}
}
pom = initial[i];
initial[i] = initial[index];
initial[index] = pom;
}
return initial;
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,92 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.instancemanager.HandysBlockCheckerManager;
import com.l2jserver.gameserver.instancemanager.HandysBlockCheckerManager.ArenaParticipantsHolder;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2BlockInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* This class ...
*
* @version $Revision: 1.1.2.5.2.4 $ $Date: 2005/04/03 15:55:03 $
*/
public class Dummy implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.DUMMY
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (!(activeChar instanceof L2PcInstance))
return;
switch(skill.getId())
{
case 5852:
case 5853:
{
final L2Object obj = targets[0];
if(obj != null)
useBlockCheckerSkill((L2PcInstance)activeChar, skill, obj);
break;
}
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
private final void useBlockCheckerSkill(L2PcInstance activeChar, L2Skill skill, L2Object target)
{
if(!(target instanceof L2BlockInstance))
return;
L2BlockInstance block = (L2BlockInstance)target;
final int arena = activeChar.getBlockCheckerArena();
if(arena != -1)
{
final ArenaParticipantsHolder holder = HandysBlockCheckerManager.getInstance().getHolder(arena);
if(holder == null) return;
final int team = holder.getPlayerTeam(activeChar);
final int color = block.getColorEffect();
if(team == 0 && color == 0x00)
block.changeColor(activeChar, holder, team);
else if(team == 1 && color == 0x53)
block.changeColor(activeChar, holder, team);
}
}
}
@@ -0,0 +1,171 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2ExtractableProductItem;
import com.l2jserver.gameserver.model.L2ExtractableSkill;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
import com.l2jserver.gameserver.util.Util;
import com.l2jserver.util.Rnd;
/**
* @author Zoey76, based on previous version.
*/
public class Extractable implements ISkillHandler
{
//FIXME: Remove this once skill reuse will be global for main/subclass.
private static final int[] protectedSkillIds = { 323, 324, 419, 519, 520, 620, 1324, 1387 };
private static final L2SkillType[] SKILL_TYPES =
{
L2SkillType.EXTRACTABLE,
L2SkillType.EXTRACTABLE_FISH
};
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (!(activeChar instanceof L2PcInstance))
{
return;
}
L2ExtractableSkill exItem = skill.getExtractableSkill();
if (exItem == null)
{
return;
}
if (exItem.getProductItemsArray().isEmpty())
{
_log.warning("Extractable Item Skill with no data, probably wrong/empty table with Skill Id: " + skill.getId());
return;
}
final double rndNum = 100 * Rnd.nextDouble();
double chance = 0;
double chanceFrom = 0;
int[] createItemID = new int[20];
int[] createAmount = new int[20];
//Explanation for future changes:
//You get one chance for the current skill, then you can fall into
//one of the "areas" like in a roulette.
//Example: for an item like Id1,A1,30;Id2,A2,50;Id3,A3,20;
//#---#-----#--#
//0 30 80 100
//If you get chance equal 45% you fall into the second zone 30-80.
//Meaning you get the second production list.
//Calculate extraction
for (L2ExtractableProductItem expi : exItem.getProductItemsArray())
{
chance = expi.getChance();
if ((rndNum >= chanceFrom) && (rndNum <= (chance + chanceFrom)))
{
for (int i = 0; i < expi.getId().length; i++)
{
createItemID[i] = expi.getId()[i];
if (skill.getSkillType() == L2SkillType.EXTRACTABLE_FISH)
{
createAmount[i] = (int) (expi.getAmmount()[i] * Config.RATE_EXTR_FISH);
}
else
{
createAmount[i] = expi.getAmmount()[i];
}
}
break;
}
chanceFrom += chance;
}
L2PcInstance player = (L2PcInstance) activeChar;
//FIXME: Remove this once skill reuse will be global for main/subclass.
if (player.isSubClassActive() && (skill.getReuseDelay() > 0) && !Util.contains(protectedSkillIds, skill.getId()))
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.MAIN_CLASS_SKILL_ONLY));
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED).addSkillName(skill));
return;
}
if (createItemID[0] <= 0)
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOTHING_INSIDE_THAT));
return;
}
else
{
for (int i = 0; i < createItemID.length; i++)
{
if (createItemID[i] <= 0)
{
continue;
}
if (ItemTable.getInstance().createDummyItem(createItemID[i]) == null)
{
_log.warning("Extractable Item Skill Id:" + skill.getId() + " createItemID " + createItemID[i] + " doesn't have a template!");
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOTHING_INSIDE_THAT));
return;
}
if (ItemTable.getInstance().createDummyItem(createItemID[i]).isStackable())
{
player.addItem("Extract", createItemID[i], createAmount[i], targets[0], false);
}
else
{
for (int j = 0; j < createAmount[i]; j++)
{
player.addItem("Extract", createItemID[i], 1, targets[0], false);
}
}
if (createItemID[i] == 57)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S1_ADENA);;
sm.addNumber(createAmount[i]);
player.sendPacket(sm);
}
else
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);;
sm.addItemName(createItemID[i]);
if (createAmount[i] > 1)
{
sm.addNumber(createAmount[i]);
}
player.sendPacket(sm);
}
}
}
}
public L2SkillType[] getSkillIds()
{
return SKILL_TYPES;
}
}
@@ -0,0 +1,221 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.Config;
import com.l2jserver.gameserver.GeoData;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.instancemanager.ZoneManager;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.type.L2FishingZone;
import com.l2jserver.gameserver.model.zone.type.L2WaterZone;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jserver.gameserver.templates.item.L2Weapon;
import com.l2jserver.gameserver.templates.item.L2WeaponType;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
import com.l2jserver.gameserver.util.Util;
import com.l2jserver.util.Rnd;
public class Fishing implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.FISHING
};
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (!(activeChar instanceof L2PcInstance))
return;
final L2PcInstance player = activeChar.getActingPlayer();
/*
* If fishing is disabled, there isn't much point in doing anything
* else, unless you are GM. so this got moved up here, before anything else.
*/
if (!Config.ALLOWFISHING && !player.isGM())
{
player.sendMessage("Fishing server is currently offline");
return;
}
if (player.isFishing())
{
if (player.getFishCombat() != null)
player.getFishCombat().doDie(false);
else
player.endFishing(false);
// Cancels fishing
player.sendPacket(SystemMessageId.FISHING_ATTEMPT_CANCELLED);
return;
}
L2Weapon weaponItem = player.getActiveWeaponItem();
if ((weaponItem == null || weaponItem.getItemType() != L2WeaponType.FISHINGROD))
{
// Fishing poles are not installed
player.sendPacket(SystemMessageId.FISHING_POLE_NOT_EQUIPPED);
return;
}
L2ItemInstance lure = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND);
if (lure == null)
{
// Bait not equiped.
player.sendPacket(SystemMessageId.BAIT_ON_HOOK_BEFORE_FISHING);
return;
}
player.setLure(lure);
L2ItemInstance lure2 = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND);
if (lure2 == null || lure2.getCount() < 1) // Not enough bait.
{
player.sendPacket(SystemMessageId.NOT_ENOUGH_BAIT);
return;
}
if (!player.isGM())
{
if (player.isInBoat())
{
// You can't fish while you are on boat
player.sendPacket(SystemMessageId.CANNOT_FISH_ON_BOAT);
return;
}
if (player.isInCraftMode() || player.isInStoreMode())
{
player.sendPacket(SystemMessageId.CANNOT_FISH_WHILE_USING_RECIPE_BOOK);
return;
}
if (player.isInsideZone(L2Character.ZONE_WATER))
{
// You can't fish in water
player.sendPacket(SystemMessageId.CANNOT_FISH_UNDER_WATER);
return;
}
if (player.isInsideZone(L2Character.ZONE_PEACE))
{
// You can't fish here.
player.sendPacket(SystemMessageId.CANNOT_FISH_HERE);
return;
}
}
/*
* If fishing is enabled, here is the code that was striped from
* startFishing() in L2PcInstance. Decide now where will the hook be cast...
*/
int rnd = Rnd.get(150) + 50;
double angle = Util.convertHeadingToDegree(player.getHeading());
double radian = Math.toRadians(angle);
double sin = Math.sin(radian);
double cos = Math.cos(radian);
int x = player.getX() + (int) (cos * rnd);
int y = player.getY() + (int) (sin * rnd);
int z = player.getZ() + 50;
/*
* ...and if the spot is in a fishing zone. If it is, it will then
* position the hook on the water surface. If not, you have to be GM to
* proceed past here... in that case, the hook will be positioned using
* the old Z lookup method.
*/
L2FishingZone aimingTo = null;
L2WaterZone water = null;
boolean canFish = false;
for (L2ZoneType zone : ZoneManager.getInstance().getZones(x, y))
{
if (zone instanceof L2FishingZone)
{
aimingTo = (L2FishingZone)zone;
continue;
}
if (zone instanceof L2WaterZone)
{
water = (L2WaterZone)zone;
}
}
if (aimingTo != null)
{
// fishing zone found, we can fish here
if (Config.GEODATA > 0)
{
// geodata enabled, checking if we can see end of the pole
if (GeoData.getInstance().canSeeTarget(player.getX(), player.getY(), z, x, y, z))
{
// finding z level for hook
if (water != null)
{
// water zone exist
if (GeoData.getInstance().getHeight(x, y, z) < water.getWaterZ())
{
// water Z is higher than geo Z
z = water.getWaterZ() + 10;
canFish = true;
}
}
else
{
// no water zone, using fishing zone
if (GeoData.getInstance().getHeight(x, y, z) < aimingTo.getWaterZ())
{
// fishing Z is higher than geo Z
z = aimingTo.getWaterZ() + 10;
canFish = true;
}
}
}
}
else
{
// geodata disabled
// if water zone exist using it, if not - using fishing zone
if (water != null)
z = water.getWaterZ() + 10;
else
z = aimingTo.getWaterZ() + 10;
canFish = true;
}
}
if (!canFish)
{
// You can't fish here
player.sendPacket(SystemMessageId.CANNOT_FISH_HERE);
if (!player.isGM())
return;
}
// Has enough bait, consume 1 and update inventory. Start fishing
// follows.
lure2 = player.getInventory().destroyItem("Consume", player.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_LHAND), 1, player, null);
InventoryUpdate iu = new InventoryUpdate();
iu.addModifiedItem(lure2);
player.sendPacket(iu);
// If everything else checks out, actually cast the hook and start
// fishing... :P
player.startFishing(x, y, z);
}
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,107 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Fishing;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.item.L2Weapon;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
public class FishingSkill implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.PUMPING,
L2SkillType.REELING
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (!(activeChar instanceof L2PcInstance))
return;
L2PcInstance player = (L2PcInstance) activeChar;
L2Fishing fish = player.getFishCombat();
if (fish == null)
{
if (skill.getSkillType() == L2SkillType.PUMPING)
{
//Pumping skill is available only while fishing
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CAN_USE_PUMPING_ONLY_WHILE_FISHING));
}
else if (skill.getSkillType() == L2SkillType.REELING)
{
//Reeling skill is available only while fishing
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CAN_USE_REELING_ONLY_WHILE_FISHING));
}
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
L2Weapon weaponItem = player.getActiveWeaponItem();
L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
if (weaponInst == null || weaponItem == null)
return;
int SS = 1;
int pen = 0;
if (weaponInst.getChargedFishshot())
SS = 2;
double gradebonus = 1 + weaponItem.getCrystalType() * 0.1;
int dmg = (int) (skill.getPower() * gradebonus * SS);
if (player.getSkillLevel(1315) <= skill.getLevel() - 2) //1315 - Fish Expertise
{//Penalty
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.REELING_PUMPING_3_LEVELS_HIGHER_THAN_FISHING_PENALTY));
pen = 50;
int penatlydmg = dmg - pen;
if (player.isGM())
player.sendMessage("Dmg w/o penalty = " + dmg);
dmg = penatlydmg;
}
if (SS > 1)
{
weaponInst.setChargedFishshot(false);
}
if (skill.getSkillType() == L2SkillType.REELING)//Realing
{
fish.useRealing(dmg, pen);
}
else
//Pumping
{
fish.usePomping(dmg, pen);
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,67 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.ValidateLocation;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
import com.l2jserver.util.Rnd;
/*
* Mobs can teleport players to them
*/
public class GetPlayer implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.GET_PLAYER
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (activeChar.isAlikeDead())
return;
for (L2Object target : targets)
{
if (target instanceof L2PcInstance)
{
L2PcInstance trg = (L2PcInstance) target;
if (trg.isAlikeDead())
continue;
//trg.teleToLocation(activeChar.getX(), activeChar.getY(), activeChar.getZ(), true);
trg.setXYZ(activeChar.getX() + Rnd.get(-10, 10), activeChar.getY() + Rnd.get(-10, 10), activeChar.getZ());
trg.sendPacket(new ValidateLocation(trg));
}
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,81 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExVoteSystemInfo;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.network.serverpackets.UserInfo;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* @author Gnacik
*/
public class GiveReco implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.GIVE_RECO
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
for (L2Object obj : targets)
{
if (obj instanceof L2PcInstance)
{
L2PcInstance target = (L2PcInstance) obj;
int power = (int)skill.getPower();
int reco = target.getRecomHave();
if(reco + power >= 255)
power = 255-reco;
if(power > 0)
{
target.setRecomHave(reco+power);
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_OBTAINED_S1_RECOMMENDATIONS);
sm.addNumber(power);
target.sendPacket(sm);
target.sendPacket(new UserInfo(target));
target.sendPacket(new ExVoteSystemInfo(target));
}
else
target.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOTHING_HAPPENED));
}
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,60 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* @author Forsaiken
*/
public class GiveSp implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.GIVE_SP
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
for (L2Object obj : targets)
{
L2Character target = (L2Character) obj;
if (target != null)
{
int spToAdd = (int) skill.getPower();
target.addExpAndSp(0, spToAdd);
}
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,58 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.network.serverpackets.UserInfo;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
public class GiveVitality implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.GIVE_VITALITY
};
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
for (L2Object target : targets)
{
if (target instanceof L2PcInstance)
{
if (skill.hasEffects())
{
((L2PcInstance) target).stopSkillEffects(skill.getId());
skill.getEffects(activeChar, ((L2PcInstance)target));
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
sm.addSkillName(skill);
target.sendPacket(sm);
}
((L2PcInstance) target).updateVitalityPoints((float)skill.getPower(), false, false);
((L2PcInstance) target).sendPacket(new UserInfo((L2PcInstance)target));
}
}
}
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,173 @@
/*
* 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 handlers.skillhandlers;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Attackable;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jserver.gameserver.network.serverpackets.ItemList;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
import com.l2jserver.util.Rnd;
/**
* @author l3x
*/
public class Harvest implements ISkillHandler
{
private static Logger _log = Logger.getLogger(Harvest.class.getName());
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.HARVEST
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (!(activeChar instanceof L2PcInstance))
return;
final L2Object[] targetList = skill.getTargetList(activeChar);
if (targetList == null || targetList.length == 0)
return;
if (Config.DEBUG)
_log.info("Casting harvest");
L2MonsterInstance target;
InventoryUpdate iu = Config.FORCE_INVENTORY_UPDATE ? null : new InventoryUpdate();
for (L2Object tgt: targetList)
{
if (!(tgt instanceof L2MonsterInstance))
continue;
target = (L2MonsterInstance) tgt;
if (activeChar.getObjectId() != target.getSeederId())
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_HARVEST);
activeChar.sendPacket(sm);
continue;
}
boolean send = false;
int total = 0;
int cropId = 0;
// TODO: check items and amount of items player harvest
if (target.isSeeded())
{
if (calcSuccess(activeChar, target))
{
L2Attackable.RewardItem[] items = target.takeHarvest();
if (items != null && items.length > 0)
{
for (L2Attackable.RewardItem ritem : items)
{
cropId = ritem.getItemId(); // always got 1 type of crop as reward
if (activeChar.isInParty())
activeChar.getParty().distributeItem((L2PcInstance)activeChar, ritem, true, target);
else
{
L2ItemInstance item = activeChar.getInventory().addItem("Manor", ritem.getItemId(), ritem.getCount(), (L2PcInstance)activeChar, target);
if (iu != null)
iu.addItem(item);
send = true;
total += ritem.getCount();
}
}
if (send)
{
SystemMessage smsg = SystemMessage.getSystemMessage(SystemMessageId.YOU_PICKED_UP_S1_S2);
smsg.addNumber(total);
smsg.addItemName(cropId);
activeChar.sendPacket(smsg);
if (activeChar.getParty() != null)
{
smsg = SystemMessage.getSystemMessage(SystemMessageId.C1_HARVESTED_S3_S2S);
smsg.addString(activeChar.getName());
smsg.addNumber(total);
smsg.addItemName(cropId);
activeChar.getParty().broadcastToPartyMembers((L2PcInstance)activeChar, smsg);
}
if (iu != null)
activeChar.sendPacket(iu);
else
activeChar.sendPacket(new ItemList((L2PcInstance)activeChar, false));
}
}
}
else
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_HARVEST_HAS_FAILED));
}
else
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_HARVEST_FAILED_BECAUSE_THE_SEED_WAS_NOT_SOWN));
}
}
/**
*
* @return
*/
private boolean calcSuccess(L2Character activeChar, L2Character target)
{
int basicSuccess = 100;
final int levelPlayer = activeChar.getLevel();
final int levelTarget = target.getLevel();
int diff = (levelPlayer - levelTarget);
if (diff < 0)
diff = -diff;
// apply penalty, target <=> player levels
// 5% penalty for each level
if (diff > 5)
basicSuccess -= (diff - 5) * 5;
// success rate cant be less than 1%
if (basicSuccess < 1)
basicSuccess = 1;
return Rnd.nextInt(99) < basicSuccess;
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,223 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.handler.SkillHandler;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2SiegeFlagInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.skills.Formulas;
import com.l2jserver.gameserver.skills.Stats;
import com.l2jserver.gameserver.templates.item.L2Item;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* This class ...
*
* @version $Revision: 1.1.2.2.2.4 $ $Date: 2005/04/06 16:13:48 $
*/
public class Heal implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.HEAL,
L2SkillType.HEAL_STATIC
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
//check for other effects
ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(L2SkillType.BUFF);
if (handler != null)
handler.useSkill(activeChar, skill, targets);
double power = skill.getPower();
switch (skill.getSkillType())
{
case HEAL_STATIC:
break;
default:
final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
double staticShotBonus = 0;
int mAtkMul = 1; // mAtk multiplier
if (weaponInst != null
&& weaponInst.getChargedSpiritshot() != L2ItemInstance.CHARGED_NONE)
{
if (activeChar instanceof L2PcInstance && ((L2PcInstance)activeChar).isMageClass())
{
staticShotBonus = skill.getMpConsume(); // static bonus for spiritshots
if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
{
mAtkMul = 4;
staticShotBonus *= 2.4; // static bonus for blessed spiritshots
}
else
mAtkMul = 2;
}
else
{
// no static bonus
// grade dynamic bonus
switch (weaponInst.getItem().getItemGrade())
{
case L2Item.CRYSTAL_S84:
mAtkMul = 4;
break;
case L2Item.CRYSTAL_S80:
mAtkMul = 2;
break;
}
// shot dynamic bonus
if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
mAtkMul *= 4; // 16x/8x/4x s84/s80/other
else
mAtkMul += 1; // 5x/3x/1x s84/s80/other
}
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
}
// If there is no weapon equipped, check for an active summon.
else if (activeChar instanceof L2Summon
&& ((L2Summon)activeChar).getChargedSpiritShot() != L2ItemInstance.CHARGED_NONE)
{
staticShotBonus = skill.getMpConsume(); // static bonus for spiritshots
if (((L2Summon)activeChar).getChargedSpiritShot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
{
staticShotBonus *= 2.4; // static bonus for blessed spiritshots
mAtkMul = 4;
}
else
mAtkMul = 2;
((L2Summon)activeChar).setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
}
else if (activeChar instanceof L2Npc && ((L2Npc)activeChar)._spiritshotcharged)
{
staticShotBonus = 2.4 * skill.getMpConsume(); // always blessed spiritshots
mAtkMul = 4;
((L2Npc)activeChar)._spiritshotcharged = false;
}
power += staticShotBonus + Math.sqrt(mAtkMul * activeChar.getMAtk(activeChar, null));
}
double hp;
for (L2Character target: (L2Character[]) targets)
{
// We should not heal if char is dead/invul
if (target == null || target.isDead() || target.isInvul())
continue;
if (target instanceof L2DoorInstance || target instanceof L2SiegeFlagInstance)
continue;
// Player holding a cursed weapon can't be healed and can't heal
if (target != activeChar)
{
if (target instanceof L2PcInstance && ((L2PcInstance) target).isCursedWeaponEquipped())
continue;
else if (activeChar instanceof L2PcInstance && ((L2PcInstance)activeChar).isCursedWeaponEquipped())
continue;
}
switch (skill.getSkillType())
{
case HEAL_PERCENT:
hp = target.getMaxHp() * power / 100.0;
break;
default:
hp = power;
hp *= target.calcStat(Stats.HEAL_EFFECTIVNESS, 100, null, null) / 100;
}
// Healer proficiency (since CT1)
hp *= activeChar.calcStat(Stats.HEAL_PROFICIENCY, 100, null, null) / 100;
// Extra bonus (since CT1.5)
if (!skill.isPotion())
hp += target.calcStat(Stats.HEAL_STATIC_BONUS, 0, null, null);
// Heal critic, since CT2.3 Gracia Final
if(skill.getSkillType() == L2SkillType.HEAL && !skill.isPotion()
&& Formulas.calcMCrit(activeChar.getMCriticalHit(target, skill)))
hp *= 3;
//from CT2 u will receive exact HP, u can't go over it, if u have full HP and u get HP buff, u will receive 0HP restored message
if ((target.getCurrentHp() + hp) >= target.getMaxHp())
hp = target.getMaxHp() - target.getCurrentHp();
if (hp < 0)
hp = 0;
target.setCurrentHp(hp + target.getCurrentHp());
StatusUpdate su = new StatusUpdate(target);
su.addAttribute(StatusUpdate.CUR_HP, (int) target.getCurrentHp());
target.sendPacket(su);
if (target instanceof L2PcInstance)
{
if (skill.getId() == 4051)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.REJUVENATING_HP);
target.sendPacket(sm);
}
else
{
if (activeChar instanceof L2PcInstance && activeChar != target)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S2_HP_RESTORED_BY_C1);
sm.addString(activeChar.getName());
sm.addNumber((int) hp);
target.sendPacket(sm);
}
else
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HP_RESTORED);
sm.addNumber((int) hp);
target.sendPacket(sm);
}
}
}
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,192 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.handler.SkillHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2SiegeFlagInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
public class HealPercent implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.HEAL_PERCENT,
L2SkillType.MANAHEAL_PERCENT,
L2SkillType.CPHEAL_PERCENT,
L2SkillType.HPMPHEAL_PERCENT,
L2SkillType.HPMPCPHEAL_PERCENT,
L2SkillType.HPCPHEAL_PERCENT
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
//check for other effects
ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(L2SkillType.BUFF);
if (handler != null)
handler.useSkill(activeChar, skill, targets);
boolean cp = false;
boolean hp = false;
boolean mp = false;
switch (skill.getSkillType())
{
case CPHEAL_PERCENT:
cp = true;
break;
case HEAL_PERCENT:
hp = true;
break;
case MANAHEAL_PERCENT:
mp = true;
break;
case HPMPHEAL_PERCENT:
mp = true;
hp = true;
break;
case HPMPCPHEAL_PERCENT:
cp = true;
hp = true;
mp = true;
break;
case HPCPHEAL_PERCENT:
hp = true;
cp = true;
}
StatusUpdate su = null;
SystemMessage sm;
double amount = 0;
boolean full = skill.getPower() == 100.0;
boolean targetPlayer = false;
for (L2Character target: (L2Character[]) targets)
{
//1505 - sublime self sacrifice
if ((target == null || target.isDead() || target.isInvul()) && skill.getId() != 1505)
continue;
targetPlayer = target instanceof L2PcInstance;
// Cursed weapon owner can't heal or be healed
if (target != activeChar)
{
if (activeChar instanceof L2PcInstance && ((L2PcInstance)activeChar).isCursedWeaponEquipped())
continue;
if (targetPlayer && ((L2PcInstance)target).isCursedWeaponEquipped())
continue;
}
// Doors and flags can't be healed in any way
if (hp && (target instanceof L2DoorInstance || target instanceof L2SiegeFlagInstance))
continue;
if (targetPlayer)
su = new StatusUpdate(target);
// Only players have CP
if (cp && targetPlayer)
{
if (full)
amount = target.getMaxCp();
else
amount = target.getMaxCp() * skill.getPower() / 100.0;
amount = Math.min(amount, target.getMaxCp() - target.getCurrentCp());
target.setCurrentCp(amount + target.getCurrentCp());
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CP_WILL_BE_RESTORED);
sm.addNumber((int)amount);
target.sendPacket(sm);
su.addAttribute(StatusUpdate.CUR_CP, (int) target.getCurrentCp());
}
if (hp)
{
if (full)
amount = target.getMaxHp();
else
amount = target.getMaxHp() * skill.getPower() / 100.0;
amount = Math.min(amount, target.getMaxHp() - target.getCurrentHp());
target.setCurrentHp(amount + target.getCurrentHp());
if (targetPlayer)
{
if (activeChar != target)
{
sm = SystemMessage.getSystemMessage(SystemMessageId.S2_HP_RESTORED_BY_C1);
sm.addCharName(activeChar);
}
else
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HP_RESTORED);
sm.addNumber((int)amount);
target.sendPacket(sm);
su.addAttribute(StatusUpdate.CUR_HP, (int) target.getCurrentHp());
}
}
if (mp)
{
if (full)
amount = target.getMaxMp();
else
amount = target.getMaxMp() * skill.getPower() / 100.0;
amount = Math.min(amount, target.getMaxMp() - target.getCurrentMp());
target.setCurrentMp(amount + target.getCurrentMp());
if (targetPlayer)
{
if (activeChar != target)
{
sm = SystemMessage.getSystemMessage(SystemMessageId.S2_MP_RESTORED_BY_C1);
sm.addCharName(activeChar);
}
else
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_MP_RESTORED);
sm.addNumber((int)amount);
target.sendPacket(sm);
su.addAttribute(StatusUpdate.CUR_MP, (int) target.getCurrentMp());
}
}
if (targetPlayer)
target.sendPacket(su);
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,128 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.Config;
import com.l2jserver.gameserver.GeoData;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.FlyToLocation;
import com.l2jserver.gameserver.network.serverpackets.FlyToLocation.FlyType;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.network.serverpackets.ValidateLocation;
import com.l2jserver.gameserver.skills.Formulas;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
import com.l2jserver.gameserver.util.Util;
/**
*
* @author Didldak
* Some parts taken from EffectWarp, which cannot be used for this case.
*/
public class InstantJump implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.INSTANT_JUMP
};
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
L2Character target = (L2Character) targets[0];
if (Formulas.calcPhysicalSkillEvasion(target, skill))
{
if (activeChar instanceof L2PcInstance)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DODGES_ATTACK);
sm.addString(target.getName());
((L2PcInstance) activeChar).sendPacket(sm);
}
if (target instanceof L2PcInstance)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.AVOIDED_C1_ATTACK);
sm.addString(activeChar.getName());
((L2PcInstance) target).sendPacket(sm);
}
return;
}
int x = 0, y = 0, z = 0;
int px = target.getX();
int py = target.getY();
double ph = Util.convertHeadingToDegree(target.getHeading());
ph += 180;
if (ph > 360)
ph -= 360;
ph = (Math.PI * ph) / 180;
x = (int) (px + (25 * Math.cos(ph)));
y = (int) (py + (25 * Math.sin(ph)));
z = target.getZ();
Location loc = new Location(x, y, z);
if (Config.GEODATA > 0)
loc = GeoData.getInstance().moveCheck(activeChar.getX(), activeChar.getY(), activeChar.getZ(), x, y, z, activeChar.getInstanceId());
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
activeChar.broadcastPacket(new FlyToLocation(activeChar, loc.getX(), loc.getY(), loc.getZ(), FlyType.DUMMY));
activeChar.abortAttack();
activeChar.abortCast();
activeChar.setXYZ(loc.getX(), loc.getY(), loc.getZ());
activeChar.broadcastPacket(new ValidateLocation(activeChar));
if (skill.hasEffects())
{
if (Formulas.calcSkillReflect(target, skill) == Formulas.SKILL_REFLECT_SUCCEED)
{
activeChar.stopSkillEffects(skill.getId());
skill.getEffects(target, activeChar);
//SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
//sm.addSkillName(skill);
//activeChar.sendPacket(sm);
}
else
{
// activate attacked effects, if any
target.stopSkillEffects(skill.getId());
skill.getEffects(activeChar, target);
}
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,112 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Effect;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.skills.Stats;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* This class ...
*
* @version $Revision: 1.1.2.2.2.1 $ $Date: 2005/03/02 15:38:36 $
*/
public class ManaHeal implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.MANAHEAL,
L2SkillType.MANARECHARGE
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character actChar, L2Skill skill, L2Object[] targets)
{
for (L2Character target: (L2Character[]) targets)
{
if (target.isInvul())
continue;
double mp = skill.getPower();
mp = (skill.getSkillType() == L2SkillType.MANARECHARGE) ? target.calcStat(Stats.RECHARGE_MP_RATE, mp, null, null) : mp;
//from CT2 u will receive exact MP, u can't go over it, if u have full MP and u get MP buff, u will receive 0MP restored message
if ((target.getCurrentMp() + mp) >= target.getMaxMp())
mp = target.getMaxMp() - target.getCurrentMp();
target.setCurrentMp(mp + target.getCurrentMp());
StatusUpdate sump = new StatusUpdate(target);
sump.addAttribute(StatusUpdate.CUR_MP, (int) target.getCurrentMp());
target.sendPacket(sump);
SystemMessage sm;
if (actChar instanceof L2PcInstance && actChar != target)
{
sm = SystemMessage.getSystemMessage(SystemMessageId.S2_MP_RESTORED_BY_C1);
sm.addString(actChar.getName());
sm.addNumber((int) mp);
target.sendPacket(sm);
}
else
{
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_MP_RESTORED);
sm.addNumber((int) mp);
target.sendPacket(sm);
}
if (skill.hasEffects())
{
target.stopSkillEffects(skill.getId());
skill.getEffects(actChar, target);
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
sm.addSkillName(skill);
target.sendPacket(sm);
}
}
if (skill.hasSelfEffects())
{
L2Effect effect = actChar.getFirstEffect(skill.getId());
if (effect != null && effect.isSelfEffect())
{
//Replace old effect with new one.
effect.exit();
}
// cast self effect if any
skill.getEffectsSelf(actChar);
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,171 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Effect;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.skills.Formulas;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* Class handling the Mana damage skill
*
* @author slyce
*/
public class Manadam implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.MANADAM
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (activeChar.isAlikeDead())
return;
boolean ss = false;
boolean bss = false;
L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
if (weaponInst != null)
{
if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
{
bss = true;
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
}
else if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_SPIRITSHOT)
{
ss = true;
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
}
}
// If there is no weapon equipped, check for an active summon.
else if (activeChar instanceof L2Summon)
{
L2Summon activeSummon = (L2Summon) activeChar;
if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
{
bss = true;
activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
}
else if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_SPIRITSHOT)
{
ss = true;
activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
}
}
for (L2Character target: (L2Character[]) targets)
{
if (Formulas.calcSkillReflect(target, skill) == Formulas.SKILL_REFLECT_SUCCEED)
target = activeChar;
boolean acted = Formulas.calcMagicAffected(activeChar, target, skill);
if (target.isInvul() || !acted)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.MISSED_TARGET));
}
else
{
if (skill.hasEffects())
{
byte shld = Formulas.calcShldUse(activeChar, target, skill);
target.stopSkillEffects(skill.getId());
if (Formulas.calcSkillSuccess(activeChar, target, skill, shld, false, ss, bss))
skill.getEffects(activeChar, target, new Env(shld, ss, false, bss));
else
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_RESISTED_YOUR_S2);
sm.addCharName(target);
sm.addSkillName(skill);
activeChar.sendPacket(sm);
}
}
double damage = Formulas.calcManaDam(activeChar, target, skill, ss, bss);
if (Formulas.calcMCrit(activeChar.getMCriticalHit(target, skill)))
{
damage *= 3.;
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CRITICAL_HIT_MAGIC));
}
double mp = (damage > target.getCurrentMp() ? target.getCurrentMp() : damage);
target.reduceCurrentMp(mp);
if (damage > 0)
target.stopEffectsOnDamage(true);
if (target instanceof L2PcInstance)
{
StatusUpdate sump = new StatusUpdate(target);
sump.addAttribute(StatusUpdate.CUR_MP, (int) target.getCurrentMp());
// [L2J_JP EDIT START - TSL]
target.sendPacket(sump);
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S2_MP_HAS_BEEN_DRAINED_BY_C1);
sm.addCharName(activeChar);
sm.addNumber((int) mp);
target.sendPacket(sm);
}
if (activeChar instanceof L2PcInstance)
{
SystemMessage sm2 = SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENTS_MP_WAS_REDUCED_BY_S1);
sm2.addNumber((int) mp);
activeChar.sendPacket(sm2);
}
// [L2J_JP EDIT END - TSL]
}
}
if (skill.hasSelfEffects())
{
L2Effect effect = activeChar.getFirstEffect(skill.getId());
if (effect != null && effect.isSelfEffect())
{
//Replace old effect with new one.
effect.exit();
}
// cast self effect if any
skill.getEffectsSelf(activeChar);
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,228 @@
/*
* 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 handlers.skillhandlers;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Effect;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.skills.Formulas;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* This class ...
*
* @version $Revision: 1.1.2.8.2.9 $ $Date: 2005/04/05 19:41:23 $
*/
public class Mdam implements ISkillHandler
{
protected static final Logger _log = Logger.getLogger(Mdam.class.getName());
private static final Logger _logDamage = Logger.getLogger("damage");
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.MDAM,
L2SkillType.DEATHLINK
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (activeChar.isAlikeDead())
return;
boolean ss = false;
boolean bss = false;
L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
if (weaponInst != null)
{
if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
{
bss = true;
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
}
else if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_SPIRITSHOT)
{
ss = true;
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
}
}
// If there is no weapon equipped, check for an active summon.
else if (activeChar instanceof L2Summon)
{
L2Summon activeSummon = (L2Summon) activeChar;
if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
{
bss = true;
activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
}
else if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_SPIRITSHOT)
{
ss = true;
activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
}
}
for (L2Character target: (L2Character[]) targets)
{
if (activeChar instanceof L2PcInstance && target instanceof L2PcInstance && ((L2PcInstance)target).isFakeDeath())
{
target.stopFakeDeath(true);
}
else if (target.isDead())
{
continue;
}
final boolean mcrit = Formulas.calcMCrit(activeChar.getMCriticalHit(target, skill));
final byte shld = Formulas.calcShldUse(activeChar, target, skill);
final byte reflect = Formulas.calcSkillReflect(target, skill);
int damage = (int) Formulas.calcMagicDam(activeChar, target, skill, shld, ss, bss, mcrit);
if (skill.getDependOnTargetBuff() != 0)
damage += (int) (damage * target.getBuffCount() * skill.getDependOnTargetBuff());
if (skill.getMaxSoulConsumeCount() > 0 && activeChar instanceof L2PcInstance)
{
switch (((L2PcInstance) activeChar).getSouls())
{
case 0:
break;
case 1:
damage *= 1.10;
break;
case 2:
damage *= 1.12;
break;
case 3:
damage *= 1.15;
break;
case 4:
damage *= 1.18;
break;
default:
damage *= 1.20;
break;
}
}
// Possibility of a lethal strike
Formulas.calcLethalHit(activeChar, target, skill);
if (damage > 0)
{
// Manage attack or cast break of the target (calculating rate, sending message...)
if (!target.isRaid() && Formulas.calcAtkBreak(target, damage))
{
target.breakAttack();
target.breakCast();
}
// vengeance reflected damage
// DS: because only skill using vengeanceMdam is Shield Deflect Magic
// and for this skill no damage should pass to target, just hardcode it for now
if ((reflect & Formulas.SKILL_REFLECT_VENGEANCE) != 0)
activeChar.reduceCurrentHp(damage, target, skill);
else
{
activeChar.sendDamageMessage(target, damage, mcrit, false, false);
target.reduceCurrentHp(damage, activeChar, skill);
}
if (skill.hasEffects())
{
if ((reflect & Formulas.SKILL_REFLECT_SUCCEED) != 0) // reflect skill effects
{
activeChar.stopSkillEffects(skill.getId());
skill.getEffects(target, activeChar);
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
sm.addSkillName(skill);
activeChar.sendPacket(sm);
}
else
{
// activate attacked effects, if any
target.stopSkillEffects(skill.getId());
if (Formulas.calcSkillSuccess(activeChar, target, skill, shld, false, ss, bss))
skill.getEffects(activeChar, target, new Env(shld, ss, false, bss));
else
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_RESISTED_YOUR_S2);
sm.addCharName(target);
sm.addSkillName(skill);
activeChar.sendPacket(sm);
}
}
}
// Logging damage
if (Config.LOG_GAME_DAMAGE
&& activeChar instanceof L2Playable
&& damage > Config.LOG_GAME_DAMAGE_THRESHOLD)
{
LogRecord record = new LogRecord(Level.INFO, "");
record.setParameters(new Object[]{activeChar, " did damage ", damage, skill, " to ", target});
record.setLoggerName("mdam");
_logDamage.log(record);
}
}
}
// self Effect :]
if (skill.hasSelfEffects())
{
final L2Effect effect = activeChar.getFirstEffect(skill.getId());
if (effect != null && effect.isSelfEffect())
{
//Replace old effect with new one.
effect.exit();
}
skill.getEffectsSelf(activeChar);
}
if (skill.isSuicideAttack())
activeChar.doDie(activeChar);
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,74 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.instancemanager.InstanceManager;
import com.l2jserver.gameserver.instancemanager.InstanceManager.InstanceWorld;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
public class NornilsPower implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.NORNILS_POWER
};
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (!(activeChar instanceof L2PcInstance))
return;
InstanceWorld world = null;
final int instanceId = activeChar.getInstanceId();
if (instanceId > 0)
world = InstanceManager.getInstance().getPlayerWorld((L2PcInstance)activeChar);
if (world != null && world.instanceId == instanceId && world.templateId == 11)
{
if(activeChar.isInsideRadius(-107393, 83677, 100, true))
{
activeChar.destroyItemByItemId("NornilsPower", 9713, 1, activeChar, true);
L2DoorInstance door = InstanceManager.getInstance().getInstance(world.instanceId).getDoor(16200010);
if (door != null)
{
door.setMeshIndex(1);
door.setTargetable(true);
door.broadcastStatusUpdate();
}
}
else
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
sm.addSkillName(skill);
activeChar.sendPacket(sm);
}
}
else
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOTHING_HAPPENED));
}
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,285 @@
/*
* 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 handlers.skillhandlers;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.SkillTable;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Effect;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.skills.BaseStats;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.skills.Formulas;
import com.l2jserver.gameserver.templates.item.L2WeaponType;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* This class ...
*
* @version $Revision: 1.1.2.7.2.16 $ $Date: 2005/04/06 16:13:49 $
*/
public class Pdam implements ISkillHandler
{
private static final Logger _log = Logger.getLogger(Pdam.class.getName());
private static final Logger _logDamage = Logger.getLogger("damage");
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.PDAM, L2SkillType.FATAL
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (activeChar.isAlikeDead())
return;
int damage = 0;
if (Config.DEBUG)
{
_log.fine("Begin Skill processing in Pdam.java " + skill.getSkillType());
}
L2ItemInstance weapon = activeChar.getActiveWeaponInstance();
boolean soul = (weapon != null && weapon.getChargedSoulshot() == L2ItemInstance.CHARGED_SOULSHOT && weapon.getItemType() != L2WeaponType.DAGGER);
// If there is no weapon equipped, check for an active summon.
if (weapon == null && activeChar instanceof L2Summon)
{
L2Summon activeSummon = (L2Summon) activeChar;
if (activeSummon.getChargedSoulShot() == L2ItemInstance.CHARGED_SOULSHOT)
{
soul = true;
activeSummon.setChargedSoulShot(L2ItemInstance.CHARGED_NONE);
}
}
for (L2Character target: (L2Character[]) targets)
{
if (activeChar instanceof L2PcInstance && target instanceof L2PcInstance && ((L2PcInstance)target).isFakeDeath())
{
target.stopFakeDeath(true);
}
else if (target.isDead())
continue;
final boolean dual = activeChar.isUsingDualWeapon();
final byte shld = Formulas.calcShldUse(activeChar, target, skill);
// PDAM critical chance not affected by buffs, only by STR. Only some skills are meant to crit.
boolean crit = false;
if (skill.getBaseCritRate() > 0)
crit = Formulas.calcCrit(skill.getBaseCritRate() * 10 * BaseStats.STR.calcBonus(activeChar), target);
if (!crit && (skill.getCondition() & L2Skill.COND_CRIT) != 0)
damage = 0;
else
damage = (int) Formulas.calcPhysDam(activeChar, target, skill, shld, false, dual, soul);
if (skill.getMaxSoulConsumeCount() > 0 && activeChar instanceof L2PcInstance)
{
switch (((L2PcInstance) activeChar).getSouls())
{
case 0:
break;
case 1:
damage *= 1.10;
break;
case 2:
damage *= 1.12;
break;
case 3:
damage *= 1.15;
break;
case 4:
damage *= 1.18;
break;
default:
damage *= 1.20;
break;
}
}
if (crit)
damage *= 2; // PDAM Critical damage always 2x and not affected by buffs
final boolean skillIsEvaded = Formulas.calcPhysicalSkillEvasion(target, skill);
final byte reflect = Formulas.calcSkillReflect(target, skill);
if (!skillIsEvaded)
{
if (skill.hasEffects())
{
L2Effect[] effects;
if ((reflect & Formulas.SKILL_REFLECT_SUCCEED) != 0)
{
activeChar.stopSkillEffects(skill.getId());
effects = skill.getEffects(target, activeChar);
if (effects != null && effects.length > 0)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
sm.addSkillName(skill);
activeChar.sendPacket(sm);
}
}
else
{
// activate attacked effects, if any
target.stopSkillEffects(skill.getId());
effects = skill.getEffects(activeChar, target, new Env(shld, false, false, false));
if (effects != null && effects.length > 0)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
sm.addSkillName(skill);
target.sendPacket(sm);
}
}
}
if (damage > 0)
{
activeChar.sendDamageMessage(target, damage, false, crit, false);
if (Config.LOG_GAME_DAMAGE
&& activeChar instanceof L2Playable
&& damage > Config.LOG_GAME_DAMAGE_THRESHOLD)
{
LogRecord record = new LogRecord(Level.INFO, "");
record.setParameters(new Object[]{activeChar, " did damage ", damage, skill, " to ", target});
record.setLoggerName("pdam");
_logDamage.log(record);
}
// Possibility of a lethal strike
Formulas.calcLethalHit(activeChar, target, skill);
target.reduceCurrentHp(damage, activeChar, skill);
// vengeance reflected damage
if ((reflect & Formulas.SKILL_REFLECT_VENGEANCE) != 0)
{
if (target instanceof L2PcInstance)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.COUNTERED_C1_ATTACK);
sm.addCharName(activeChar);
target.sendPacket(sm);
}
if (activeChar instanceof L2PcInstance)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_PERFORMING_COUNTERATTACK);
sm.addCharName(target);
activeChar.sendPacket(sm);
}
// Formula from Diego post, 700 from rpg tests
double vegdamage = (700 * target.getPAtk(activeChar) / activeChar.getPDef(target));
activeChar.reduceCurrentHp(vegdamage, target, skill);
}
}
else // No damage
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ATTACK_FAILED));
}
else
{
if (activeChar instanceof L2PcInstance)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DODGES_ATTACK);
sm.addString(target.getName());
((L2PcInstance) activeChar).sendPacket(sm);
}
if (target instanceof L2PcInstance)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.AVOIDED_C1_ATTACK);
sm.addString(activeChar.getName());
((L2PcInstance) target).sendPacket(sm);
}
// Possibility of a lethal strike despite skill is evaded
Formulas.calcLethalHit(activeChar, target, skill);
}
if (activeChar instanceof L2PcInstance)
{
int soulMasteryLevel = activeChar.getSkillLevel(467);
if (soulMasteryLevel > 0)
{
L2Skill soulmastery = SkillTable.getInstance().getInfo(467, soulMasteryLevel);
if (soulmastery != null)
{
if (((L2PcInstance) activeChar).getSouls() < soulmastery.getNumSouls())
{
int count = 0;
if (((L2PcInstance) activeChar).getSouls() + skill.getNumSouls() <= soulmastery.getNumSouls())
count = skill.getNumSouls();
else
count = soulmastery.getNumSouls() - ((L2PcInstance) activeChar).getSouls();
((L2PcInstance) activeChar).increaseSouls(count);
}
else
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.SOUL_CANNOT_BE_INCREASED_ANYMORE);
((L2PcInstance) activeChar).sendPacket(sm);
}
}
}
}
}
//self Effect :]
if (skill.hasSelfEffects())
{
final L2Effect effect = activeChar.getFirstEffect(skill.getId());
if (effect != null && effect.isSelfEffect())
{
//Replace old effect with new one.
effect.exit();
}
skill.getEffectsSelf(activeChar);
}
if (soul && weapon != null)
weapon.setChargedSoulshot(L2ItemInstance.CHARGED_NONE);
if (skill.isSuicideAttack())
activeChar.doDie(activeChar);
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,60 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2AirShipInstance;
import com.l2jserver.gameserver.model.actor.instance.L2ControllableAirShipInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
public class RefuelAirShip implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.REFUEL
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (!(activeChar instanceof L2PcInstance))
return;
final L2AirShipInstance ship = ((L2PcInstance)activeChar).getAirShip();
if (ship == null
|| !(ship instanceof L2ControllableAirShipInstance)
|| ship.getFuel() >= ship.getMaxFuel())
return;
ship.setFuel(ship.getFuel() + (int)skill.getPower());
ship.updateAbnormalEffect(); // broadcast new fuel
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,104 @@
/*
* 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 handlers.skillhandlers;
import java.util.List;
import javolution.util.FastList;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.L2Skill.SkillTargetType;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
import com.l2jserver.gameserver.skills.Formulas;
import com.l2jserver.gameserver.taskmanager.DecayTaskManager;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* This class ...
*
* @version $Revision: 1.1.2.5.2.4 $ $Date: 2005/04/03 15:55:03 $
*/
public class Resurrect implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.RESURRECT
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
L2PcInstance player = null;
if (activeChar instanceof L2PcInstance)
player = (L2PcInstance) activeChar;
L2PcInstance targetPlayer;
List<L2Character> targetToRes = new FastList<L2Character>();
for (L2Character target: (L2Character[]) targets)
{
if (target instanceof L2PcInstance)
{
targetPlayer = (L2PcInstance) target;
// Check for same party or for same clan, if target is for clan.
if (skill.getTargetType() == SkillTargetType.TARGET_CORPSE_CLAN)
{
if (player.getClanId() != targetPlayer.getClanId())
continue;
}
}
if (target.isVisible())
targetToRes.add(target);
}
if (targetToRes.isEmpty())
{
activeChar.abortCast();
return;
}
for (L2Character cha : targetToRes)
if (activeChar instanceof L2PcInstance)
{
if (cha instanceof L2PcInstance)
((L2PcInstance) cha).reviveRequest((L2PcInstance) activeChar, skill, false);
else if (cha instanceof L2PetInstance)
((L2PetInstance) cha).getOwner().reviveRequest((L2PcInstance) activeChar, skill, true);
}
else
{
DecayTaskManager.getInstance().cancelDecayTask(cha);
cha.doRevive(Formulas.calculateSkillResurrectRestorePercent(skill.getPower(), activeChar));
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,64 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Attackable;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
public class ShiftTarget implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.SHIFT_TARGET
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (targets == null)
return;
L2Character target = (L2Character) targets[0];
if (activeChar.isAlikeDead() || target == null)
return;
for (L2Character obj : activeChar.getKnownList().getKnownCharactersInRadius(skill.getSkillRadius()))
{
if (!(obj instanceof L2Attackable) || obj.isDead())
continue;
L2Attackable hater = ((L2Attackable) obj);
if (hater.getHating(activeChar) == 0)
continue;
hater.addDamageHate(target, 0, hater.getHating(activeChar));
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,86 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.datatables.SkillTable;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
*
* @author nBd
*/
public class Soul implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.CHARGESOUL
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (!(activeChar instanceof L2PcInstance) || activeChar.isAlikeDead())
return;
L2PcInstance player = (L2PcInstance) activeChar;
int level = player.getSkillLevel(467);
if (level > 0)
{
L2Skill soulmastery = SkillTable.getInstance().getInfo(467, level);
if (soulmastery != null)
{
if (player.getSouls() < soulmastery.getNumSouls())
{
int count = 0;
if (player.getSouls() + skill.getNumSouls() <= soulmastery.getNumSouls())
count = skill.getNumSouls();
else
count = soulmastery.getNumSouls() - player.getSouls();
player.increaseSouls(count);
}
else
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.SOUL_CANNOT_BE_INCREASED_ANYMORE);
player.sendPacket(sm);
return;
}
}
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,152 @@
/*
* 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 handlers.skillhandlers;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Manor;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.PlaySound;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
import com.l2jserver.util.Rnd;
/**
* @author l3x
*/
public class Sow implements ISkillHandler
{
private static Logger _log = Logger.getLogger(Sow.class.getName());
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.SOW
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (!(activeChar instanceof L2PcInstance))
return;
final L2Object[] targetList = skill.getTargetList(activeChar);
if (targetList == null || targetList.length == 0)
return;
if (Config.DEBUG)
_log.info("Casting sow");
L2MonsterInstance target;
for (L2Object tgt: targetList)
{
if (!(tgt instanceof L2MonsterInstance))
continue;
target = (L2MonsterInstance) tgt;
if (target.isDead()
|| target.isSeeded()
|| target.getSeederId() != activeChar.getObjectId())
{
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
continue;
}
final int seedId = target.getSeedType();
if (seedId == 0)
{
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
continue;
}
//Consuming used seed
if (!activeChar.destroyItemByItemId("Consume", seedId, 1, target, false))
{
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
SystemMessage sm;
if (calcSuccess(activeChar, target, seedId))
{
activeChar.sendPacket(new PlaySound("Itemsound.quest_itemget"));
target.setSeeded((L2PcInstance)activeChar);
sm = SystemMessage.getSystemMessage(SystemMessageId.THE_SEED_WAS_SUCCESSFULLY_SOWN);
}
else
sm = SystemMessage.getSystemMessage(SystemMessageId.THE_SEED_WAS_NOT_SOWN);
if (activeChar.getParty() == null)
activeChar.sendPacket(sm);
else
activeChar.getParty().broadcastToPartyMembers(sm);
//TODO: Mob should not aggro on player, this way doesn't work really nice
target.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
}
}
private boolean calcSuccess(L2Character activeChar, L2Character target, int seedId)
{
// TODO: check all the chances
int basicSuccess = (L2Manor.getInstance().isAlternative(seedId) ? 20 : 90);
final int minlevelSeed = L2Manor.getInstance().getSeedMinLevel(seedId);
final int maxlevelSeed = L2Manor.getInstance().getSeedMaxLevel(seedId);
final int levelPlayer = activeChar.getLevel(); // Attacker Level
final int levelTarget = target.getLevel(); // target Level
// seed level
if (levelTarget < minlevelSeed)
basicSuccess -= 5 * (minlevelSeed - levelTarget);
if (levelTarget > maxlevelSeed)
basicSuccess -= 5 * (levelTarget - maxlevelSeed);
// 5% decrease in chance if player level
// is more than +/- 5 levels to _target's_ level
int diff = (levelPlayer - levelTarget);
if (diff < 0)
diff = -diff;
if (diff > 5)
basicSuccess -= 5 * (diff - 5);
//chance can't be less than 1%
if (basicSuccess < 1)
basicSuccess = 1;
return Rnd.nextInt(99) < basicSuccess;
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,97 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.ai.CtrlEvent;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.skills.Formulas;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* @author _drunk_
*
*/
public class Spoil implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.SPOIL
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (!(activeChar instanceof L2PcInstance))
return;
if (targets == null)
return;
for (L2Object tgt: targets)
{
if (!(tgt instanceof L2MonsterInstance))
continue;
L2MonsterInstance target = (L2MonsterInstance) tgt;
if (target.isSpoil())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ALREADY_SPOILED));
continue;
}
// SPOIL SYSTEM by Lbaldi
boolean spoil = false;
if (target.isDead() == false)
{
spoil = Formulas.calcMagicSuccess(activeChar, (L2Character) tgt, skill);
if (spoil)
{
target.setSpoil(true);
target.setIsSpoiledBy(activeChar.getObjectId());
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SPOIL_SUCCESS));
}
else
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_RESISTED_YOUR_S2);
sm.addCharName(target);
sm.addSkillName(skill);
activeChar.sendPacket(sm);
}
target.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, activeChar);
}
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,214 @@
/*
* 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 handlers.skillhandlers;
import java.util.ArrayList;
import java.util.logging.Level;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Effect;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.skills.Formulas;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
public class StealBuffs implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.STEAL_BUFF
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
// discharge shots
final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
if (weaponInst != null)
{
if (skill.isMagic())
{
if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
else if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_SPIRITSHOT)
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
}
}
else if (activeChar instanceof L2Summon)
{
final L2Summon activeSummon = (L2Summon) activeChar;
if (skill.isMagic())
{
if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
else if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_SPIRITSHOT)
activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
}
}
else if (activeChar instanceof L2Npc)
((L2Npc) activeChar)._spiritshotcharged = false;
L2Character target;
L2Effect effect;
int count = (int)skill.getPower();
for (L2Object obj: targets)
{
if (!(obj instanceof L2Character))
continue;
target = (L2Character)obj;
if (target.isDead())
continue;
if (!(target instanceof L2PcInstance))
continue;
Env env;
int lastSkillId = 0;
final L2Effect[] effects = target.getAllEffects();
final ArrayList<L2Effect> toSteal = new ArrayList<L2Effect>(count);
for (int i = effects.length; --i >= 0;) // reverse order
{
effect = effects[i];
if (effect == null)
continue;
if (!effect.canBeStolen()) // remove effect if can't be stolen
{
effects[i] = null;
continue;
}
// if eff time is smaller than 5 sec, will not be stolen, just to save CPU,
// avoid synchronization(?) problems and NPEs
if (effect.getAbnormalTime() - effect.getTime() < 5)
{
effects[i] = null;
continue;
}
// first pass - only dances/songs
if (!effect.getSkill().isDance())
continue;
if (effect.getSkill().getId() != lastSkillId)
{
lastSkillId = effect.getSkill().getId();
count--;
}
toSteal.add(effect);
if (count == 0)
break;
}
if (count > 0) // second pass
{
lastSkillId = 0;
for (int i = effects.length; --i >= 0;)
{
effect = effects[i];
if (effect == null)
continue;
// second pass - all except dances/songs
if (effect.getSkill().isDance())
continue;
if (effect.getSkill().getId() != lastSkillId)
{
lastSkillId = effect.getSkill().getId();
count--;
}
toSteal.add(effect);
if (count == 0)
break;
}
}
if (toSteal.size() == 0)
continue;
// stealing effects
for (L2Effect eff : toSteal)
{
env = new Env();
env.player = target;
env.target = activeChar;
env.skill = eff.getSkill();
try
{
effect = eff.getEffectTemplate().getStolenEffect(env, eff);
if (effect != null)
{
effect.scheduleEffect();
if (effect.getShowIcon() && activeChar instanceof L2PcInstance)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
sm.addSkillName(effect);
activeChar.sendPacket(sm);
}
}
// Finishing stolen effect
eff.exit();
}
catch (RuntimeException e)
{
_log.log(Level.WARNING, "Cannot steal effect: " + eff + " Stealer: " + activeChar + " Stolen: " + target, e);
}
}
//Possibility of a lethal strike
Formulas.calcLethalHit(activeChar, target, skill);
}
if (skill.hasSelfEffects())
{
// Applying self-effects
effect = activeChar.getFirstEffect(skill.getId());
if (effect != null && effect.isSelfEffect())
{
//Replace old effect with new one.
effect.exit();
}
skill.getEffectsSelf(activeChar);
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,135 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.instancemanager.FortManager;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Castle;
import com.l2jserver.gameserver.model.entity.Fort;
import com.l2jserver.gameserver.skills.Formulas;
import com.l2jserver.gameserver.templates.item.L2WeaponType;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* @author _tomciaaa_
*
*/
public class StrSiegeAssault implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.STRSIEGEASSAULT
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (!(activeChar instanceof L2PcInstance))
return;
L2PcInstance player = (L2PcInstance) activeChar;
if (!player.isRidingStrider())
return;
if (!(player.getTarget() instanceof L2DoorInstance))
return;
Castle castle = CastleManager.getInstance().getCastle(player);
Fort fort = FortManager.getInstance().getFort(player);
if ((castle == null) && (fort == null))
return;
if (castle != null)
{
if (!player.checkIfOkToUseStriderSiegeAssault(castle))
return;
}
else
{
if (!player.checkIfOkToUseStriderSiegeAssault(fort))
return;
}
try
{
// damage calculation
int damage = 0;
for (L2Character target: (L2Character[]) targets)
{
L2ItemInstance weapon = activeChar.getActiveWeaponInstance();
if (activeChar instanceof L2PcInstance && target instanceof L2PcInstance && ((L2PcInstance)target).isFakeDeath())
{
target.stopFakeDeath(true);
}
else if (target.isDead())
continue;
boolean dual = activeChar.isUsingDualWeapon();
byte shld = Formulas.calcShldUse(activeChar, target, skill);
boolean crit = Formulas.calcCrit(activeChar.getCriticalHit(target, skill), target);
boolean soul = (weapon != null && weapon.getChargedSoulshot() == L2ItemInstance.CHARGED_SOULSHOT && weapon.getItemType() != L2WeaponType.DAGGER);
if (!crit && (skill.getCondition() & L2Skill.COND_CRIT) != 0)
damage = 0;
else
damage = (int) Formulas.calcPhysDam(activeChar, target, skill, shld, crit, dual, soul);
if (damage > 0)
{
target.reduceCurrentHp(damage, activeChar, skill);
if (soul && weapon != null)
weapon.setChargedSoulshot(L2ItemInstance.CHARGED_NONE);
activeChar.sendDamageMessage(target, damage, false, false, false);
}
else
activeChar.sendMessage(skill.getName() + " failed.");
}
}
catch (Exception e)
{
player.sendMessage("Error using siege assault:" + e);
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
public static void main(String[] args)
{
new StrSiegeAssault();
}
}
@@ -0,0 +1,112 @@
/*
* 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 handlers.skillhandlers;
import java.util.logging.Level;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ConfirmDlg;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
import com.l2jserver.gameserver.util.Util;
/**
* @authors BiTi, Sami
*
*/
public class SummonFriend implements ISkillHandler
{
//private static Logger _log = Logger.getLogger(SummonFriend.class.getName());
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.SUMMON_FRIEND
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (!(activeChar instanceof L2PcInstance))
return; // currently not implemented for others
L2PcInstance activePlayer = (L2PcInstance) activeChar;
if (!L2PcInstance.checkSummonerStatus(activePlayer))
return;
try
{
for (L2Character target: (L2Character[]) targets)
{
if (activeChar == target)
continue;
if (target instanceof L2PcInstance)
{
L2PcInstance targetPlayer = (L2PcInstance) target;
if (!L2PcInstance.checkSummonTargetStatus(targetPlayer, activePlayer))
continue;
if (!Util.checkIfInRange(0, activeChar, target, false))
{
if(!targetPlayer.teleportRequest(activePlayer, skill))
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_ALREADY_SUMMONED);
sm.addString(target.getName());
activePlayer.sendPacket(sm);
continue;
}
if (skill.getId() == 1403) //summon friend
{
// Send message
ConfirmDlg confirm = new ConfirmDlg(SystemMessageId.C1_WISHES_TO_SUMMON_YOU_FROM_S2_DO_YOU_ACCEPT.getId());
confirm.addCharName(activeChar);
confirm.addZoneName(activeChar.getX(), activeChar.getY(), activeChar.getZ());
confirm.addTime(30000);
confirm.addRequesterId(activePlayer.getObjectId());
target.sendPacket(confirm);
}
else
{
L2PcInstance.teleToTarget(targetPlayer, activePlayer, skill);
targetPlayer.teleportRequest(null, null);
}
}
}
}
}
catch (Exception e)
{
_log.log(Level.SEVERE, "", e);
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,165 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.Config;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Attackable;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jserver.gameserver.network.serverpackets.ItemList;
import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.skills.l2skills.L2SkillSweeper;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* @author _drunk_
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class Sweep implements ISkillHandler
{
//private static Logger _log = Logger.getLogger(Sweep.class.getName());
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.SWEEP
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (!(activeChar instanceof L2PcInstance))
{
return;
}
L2PcInstance player = (L2PcInstance) activeChar;
InventoryUpdate iu = Config.FORCE_INVENTORY_UPDATE ? null : new InventoryUpdate();
boolean send = false;
for (L2Object tgt: targets)
{
if (!(tgt instanceof L2Attackable))
continue;
L2Attackable target = (L2Attackable) tgt;
L2Attackable.RewardItem[] items = null;
boolean isSweeping = false;
synchronized (target)
{
if (target.isSweepActive())
{
items = target.takeSweep();
isSweeping = true;
}
}
if (isSweeping)
{
if (items == null || items.length == 0)
continue;
for (L2Attackable.RewardItem ritem : items)
{
if (player.isInParty())
player.getParty().distributeItem(player, ritem, true, target);
else
{
L2ItemInstance item = player.getInventory().addItem("Sweep", ritem.getItemId(), ritem.getCount(), player, target);
if (iu != null)
iu.addItem(item);
send = true;
SystemMessage smsg;
if (ritem.getCount() > 1)
{
smsg = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S); // earned $s2$s1
smsg.addItemName(ritem.getItemId());
smsg.addNumber(ritem.getCount());
}
else
{
smsg = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1); // earned $s1
smsg.addItemName(ritem.getItemId());
}
player.sendPacket(smsg);
}
}
}
target.endDecayTask();
if (send)
{
if (iu != null)
player.sendPacket(iu);
else
player.sendPacket(new ItemList(player, false));
}
L2SkillSweeper sweep = (L2SkillSweeper) skill;
if (sweep.getAbsorbAbs() != -1)
{
if (sweep.isAbsorbHp())
{
int hpAdd = sweep.getAbsorbAbs();
double hp = ((activeChar.getCurrentHp() + hpAdd) > activeChar.getMaxHp() ? activeChar.getMaxHp() : (activeChar.getCurrentHp() + hpAdd));
int restored = (int) (hp - activeChar.getCurrentHp());
activeChar.setCurrentHp(hp);
StatusUpdate suhp = new StatusUpdate(activeChar);
suhp.addAttribute(StatusUpdate.CUR_HP, (int)hp);
activeChar.sendPacket(suhp);
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HP_RESTORED);
sm.addNumber(restored);
activeChar.sendPacket(sm);
}
else
{
int mpAdd = sweep.getAbsorbAbs();
double mp = ((activeChar.getCurrentMp() + mpAdd) > activeChar.getMaxMp() ? activeChar.getMaxMp() : (activeChar.getCurrentMp() + mpAdd));
int restored = (int) (mp - activeChar.getCurrentMp());
activeChar.setCurrentMp(mp);
StatusUpdate suhp = new StatusUpdate(activeChar);
suhp.addAttribute(StatusUpdate.CUR_MP, (int)mp);
activeChar.sendPacket(suhp);
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_MP_RESTORED);
sm.addNumber(restored);
activeChar.sendPacket(sm);
}
}
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,80 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Castle;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* @author _drunk_
*
*/
public class TakeCastle implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.TAKECASTLE
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (!(activeChar instanceof L2PcInstance))
return;
L2PcInstance player = (L2PcInstance) activeChar;
if (player.getClan() == null || player.getClan().getLeaderId() != player.getObjectId())
return;
Castle castle = CastleManager.getInstance().getCastle(player);
if (castle == null || !player.checkIfOkToCastSealOfRule(castle, true, skill))
return;
try
{
castle.engrave(player.getClan(), targets[0]);
}
catch (Exception e)
{
e.printStackTrace();
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
public static void main(String[] args)
{
new TakeCastle();
}
}
@@ -0,0 +1,78 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.instancemanager.FortManager;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Fort;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* @author _drunk_
*
*/
public class TakeFort implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.TAKEFORT
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (!(activeChar instanceof L2PcInstance))
return;
L2PcInstance player = (L2PcInstance) activeChar;
if (player.getClan() == null)
return;
Fort fort = FortManager.getInstance().getFort(player);
if (fort == null || !player.checkIfOkToCastFlagDisplay(fort, true, skill))
return;
try
{
fort.endOfSiege(player.getClan());
}
catch (Exception e)
{
e.printStackTrace();
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
public static void main(String[] args)
{
new TakeFort();
}
}
@@ -0,0 +1,70 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* @author Ahmed
*/
public class TransformDispel implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.TRANSFORMDISPEL
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (activeChar.isAlikeDead())
return;
if (!(activeChar instanceof L2PcInstance))
return;
L2PcInstance pc = (L2PcInstance) activeChar;
if (pc.isAlikeDead() || pc.isCursedWeaponEquipped())
return;
if (pc.isTransformed() || pc.isInStance())
{
if (pc.isFlyingMounted() && !pc.isInsideZone(L2Character.ZONE_LANDING))
pc.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.BOARD_OR_CANCEL_NOT_POSSIBLE_HERE));
else
pc.stopTransformation(true);
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,107 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Trap;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.model.quest.Quest.TrapAction;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
public class Trap implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.DETECT_TRAP,
L2SkillType.REMOVE_TRAP
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (activeChar == null || skill == null)
return;
switch (skill.getSkillType())
{
case DETECT_TRAP:
{
for (L2Character target: activeChar.getKnownList().getKnownCharactersInRadius(skill.getSkillRadius()))
{
if (!(target instanceof L2Trap))
continue;
if (target.isAlikeDead())
continue;
final L2Trap trap = (L2Trap)target;
if (trap.getLevel() <= skill.getPower())
trap.setDetected(activeChar);
}
break;
}
case REMOVE_TRAP:
{
for (L2Character target: (L2Character[]) targets)
{
if (!(target instanceof L2Trap))
continue;
if (target.isAlikeDead())
continue;
final L2Trap trap = (L2Trap)target;
if (!trap.canSee(activeChar))
{
if (activeChar instanceof L2PcInstance)
((L2PcInstance) activeChar).sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
continue;
}
if (trap.getLevel() > skill.getPower())
continue;
if (trap.getTemplate().getEventQuests(Quest.QuestEventType.ON_TRAP_ACTION) != null)
for (Quest quest : trap.getTemplate().getEventQuests(Quest.QuestEventType.ON_TRAP_ACTION))
quest.notifyTrapAction(trap, activeChar, TrapAction.TRAP_DISARMED);
trap.unSummon();
if (activeChar instanceof L2PcInstance)
((L2PcInstance) activeChar).sendPacket(SystemMessage.getSystemMessage(SystemMessageId.A_TRAP_DEVICE_HAS_BEEN_STOPPED));
}
}
}
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}
@@ -0,0 +1,212 @@
/*
* 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 handlers.skillhandlers;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.instancemanager.InstanceManager;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2ChestInstance;
import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jserver.gameserver.model.entity.Instance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.SocialAction;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
import com.l2jserver.util.Rnd;
public class Unlock implements ISkillHandler
{
private static final L2SkillType[] SKILL_IDS =
{
L2SkillType.UNLOCK,
L2SkillType.UNLOCK_SPECIAL
};
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
L2Object[] targetList = skill.getTargetList(activeChar);
if (targetList == null)
return;
for (L2Object target: targets)
{
if (target instanceof L2DoorInstance)
{
L2DoorInstance door = (L2DoorInstance) target;
// Check if door in the different instance
if (activeChar.getInstanceId() != door.getInstanceId())
{
// Search for the instance
final Instance inst = InstanceManager.getInstance().getInstance(activeChar.getInstanceId());
if (inst == null)
{
// Instance not found
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
for (L2DoorInstance instanceDoor : inst.getDoors())
{
if (instanceDoor.getDoorId() == door.getDoorId())
{
// Door found
door = instanceDoor;
break;
}
}
// Checking instance again
if (activeChar.getInstanceId() != door.getInstanceId())
{
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
if ((!door.isUnlockable() && skill.getSkillType() != L2SkillType.UNLOCK_SPECIAL)
|| door.getFort() != null)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.UNABLE_TO_UNLOCK_DOOR));
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (doorUnlock(skill) && (!door.getOpen()))
{
door.openMe();
if(skill.getAfterEffectId() == 0)
door.onOpen();
}
else
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.FAILED_TO_UNLOCK_DOOR));
}
else if (target instanceof L2ChestInstance)
{
L2ChestInstance chest = (L2ChestInstance) target;
if (chest.getCurrentHp() <= 0
|| chest.isInteracted()
|| activeChar.getInstanceId() != chest.getInstanceId())
{
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
else
{
chest.setInteracted();
if (chestUnlock(skill, chest))
{
activeChar.broadcastPacket(new SocialAction(activeChar, 3));
chest.setSpecialDrop();
chest.setMustRewardExpSp(false);
chest.reduceCurrentHp(99999999, activeChar, skill);
}
else
{
activeChar.broadcastPacket(new SocialAction(activeChar, 13));
chest.addDamageHate(activeChar, 0, 1);
chest.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, activeChar);
if (chestTrap(chest))
chest.chestTrap(activeChar);
}
}
}
}
}
private static final boolean doorUnlock(L2Skill skill)
{
if (skill.getSkillType() == L2SkillType.UNLOCK_SPECIAL)
return Rnd.get(100) < skill.getPower();
switch (skill.getLevel())
{
case 0:
return false;
case 1:
return Rnd.get(120) < 30;
case 2:
return Rnd.get(120) < 50;
case 3:
return Rnd.get(120) < 75;
default:
return Rnd.get(120) < 100;
}
}
private static final boolean chestUnlock(L2Skill skill, L2Character chest)
{
int chance = 0;
if (chest.getLevel() > 60)
{
if (skill.getLevel() < 10)
return false;
chance = (skill.getLevel() - 10) * 5 + 30;
}
else if (chest.getLevel() > 40)
{
if (skill.getLevel() < 6)
return false;
chance = (skill.getLevel() - 6) * 5 + 10;
}
else if (chest.getLevel() > 30)
{
if (skill.getLevel() < 3)
return false;
if (skill.getLevel() > 12)
return true;
chance = (skill.getLevel() - 3) * 5 + 30;
}
else
{
if (skill.getLevel() > 10)
return true;
chance = skill.getLevel() * 5 + 35;
}
chance = Math.min(chance, 50);
return Rnd.get(100) < chance;
}
private static final boolean chestTrap(L2Character chest)
{
if (chest.getLevel() > 60)
return Rnd.get(100) < 80;
if (chest.getLevel() > 40)
return Rnd.get(100) < 50;
if (chest.getLevel() > 30)
return Rnd.get(100) < 30;
return Rnd.get(100) < 10;
}
/**
*
* @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
*/
public L2SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}