actual freya branch
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.l2skills;
|
||||
|
||||
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.StatsSet;
|
||||
|
||||
public class L2SkillAgathion extends L2Skill
|
||||
{
|
||||
private final int _npcId;
|
||||
|
||||
public L2SkillAgathion(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
_npcId = set.getInteger("npcId", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character caster, L2Object[] targets)
|
||||
{
|
||||
if (caster.isAlikeDead() || !(caster instanceof L2PcInstance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2PcInstance activeChar = (L2PcInstance) caster;
|
||||
|
||||
if (activeChar.isInOlympiadMode())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_SKILL_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT));
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.setAgathionId(_npcId);
|
||||
activeChar.broadcastUserInfo();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.l2skills;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
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.StatsSet;
|
||||
|
||||
public class L2SkillAppearance extends L2Skill
|
||||
{
|
||||
private final int _faceId;
|
||||
private final int _hairColorId;
|
||||
private final int _hairStyleId;
|
||||
|
||||
public L2SkillAppearance(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
|
||||
_faceId = set.getInteger("faceId", -1);
|
||||
_hairColorId = set.getInteger("hairColorId", -1);
|
||||
_hairStyleId = set.getInteger("hairStyleId", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character caster, L2Object[] targets)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (L2Object target : targets)
|
||||
{
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
L2PcInstance targetPlayer = (L2PcInstance) target;
|
||||
if (_faceId >= 0)
|
||||
{
|
||||
targetPlayer.getAppearance().setFace(_faceId);
|
||||
}
|
||||
if (_hairColorId >= 0)
|
||||
{
|
||||
targetPlayer.getAppearance().setHairColor(_hairColorId);
|
||||
}
|
||||
if (_hairStyleId >= 0)
|
||||
{
|
||||
targetPlayer.getAppearance().setHairStyle(_hairStyleId);
|
||||
}
|
||||
|
||||
targetPlayer.broadcastUserInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.l2skills;
|
||||
|
||||
import com.l2jserver.gameserver.model.Elementals;
|
||||
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.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.templates.StatsSet;
|
||||
import com.l2jserver.gameserver.templates.item.L2Weapon;
|
||||
|
||||
/**
|
||||
* @author nBd
|
||||
*/
|
||||
public class L2SkillChangeWeapon extends L2Skill
|
||||
{
|
||||
|
||||
/**
|
||||
* @param set
|
||||
*/
|
||||
public L2SkillChangeWeapon(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.model.L2Skill#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Object[])
|
||||
*/
|
||||
@Override
|
||||
public void useSkill(L2Character caster, L2Object[] targets)
|
||||
{
|
||||
if (caster.isAlikeDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(caster instanceof L2PcInstance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2PcInstance player = (L2PcInstance) caster;
|
||||
|
||||
if (player.isEnchanting())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2Weapon weaponItem = player.getActiveWeaponItem();
|
||||
|
||||
if (weaponItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2ItemInstance wpn = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
|
||||
if (wpn == null)
|
||||
{
|
||||
wpn = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
|
||||
}
|
||||
|
||||
if (wpn != null)
|
||||
{
|
||||
if (wpn.isAugmented())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int newItemId = 0;
|
||||
int enchantLevel = 0;
|
||||
Elementals elementals = null;
|
||||
|
||||
if (weaponItem.getChangeWeaponId() != 0)
|
||||
{
|
||||
newItemId = weaponItem.getChangeWeaponId();
|
||||
enchantLevel = wpn.getEnchantLevel();
|
||||
elementals = wpn.getElementals() == null ? null : wpn.getElementals()[0];
|
||||
|
||||
if (newItemId == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
|
||||
InventoryUpdate iu = new InventoryUpdate();
|
||||
for (L2ItemInstance item : unequiped)
|
||||
{
|
||||
iu.addModifiedItem(item);
|
||||
}
|
||||
|
||||
player.sendPacket(iu);
|
||||
|
||||
if (unequiped.length > 0)
|
||||
{
|
||||
byte count = 0;
|
||||
|
||||
for (L2ItemInstance item : unequiped)
|
||||
{
|
||||
if (!(item.getItem() instanceof L2Weapon))
|
||||
{
|
||||
count++;
|
||||
continue;
|
||||
}
|
||||
|
||||
SystemMessage sm = null;
|
||||
if (item.getEnchantLevel() > 0)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.EQUIPMENT_S1_S2_REMOVED);
|
||||
sm.addNumber(item.getEnchantLevel());
|
||||
sm.addItemName(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DISARMED);
|
||||
sm.addItemName(item);
|
||||
}
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
|
||||
if (count == unequiped.length)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2ItemInstance destroyItem = player.getInventory().destroyItem("ChangeWeapon", wpn, player, null);
|
||||
|
||||
if (destroyItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2ItemInstance newItem = player.getInventory().addItem("ChangeWeapon", newItemId, 1, player, destroyItem);
|
||||
|
||||
if (newItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((elementals != null) && (elementals.getElement() != -1) && (elementals.getValue() != -1))
|
||||
{
|
||||
newItem.setElementAttr(elementals.getElement(), elementals.getValue());
|
||||
}
|
||||
newItem.setEnchantLevel(enchantLevel);
|
||||
player.getInventory().equipItem(newItem);
|
||||
|
||||
SystemMessage msg = null;
|
||||
|
||||
if (newItem.getEnchantLevel() > 0)
|
||||
{
|
||||
msg = SystemMessage.getSystemMessage(SystemMessageId.S1_S2_EQUIPPED);
|
||||
msg.addNumber(newItem.getEnchantLevel());
|
||||
msg.addItemName(newItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = SystemMessage.getSystemMessage(SystemMessageId.S1_EQUIPPED);
|
||||
msg.addItemName(newItem);
|
||||
}
|
||||
player.sendPacket(msg);
|
||||
|
||||
InventoryUpdate u = new InventoryUpdate();
|
||||
u.addRemovedItem(destroyItem);
|
||||
u.addItem(newItem);
|
||||
player.sendPacket(u);
|
||||
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.l2skills;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
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.StatsSet;
|
||||
import com.l2jserver.gameserver.templates.item.L2WeaponType;
|
||||
|
||||
public class L2SkillChargeDmg extends L2Skill
|
||||
{
|
||||
private static final Logger _logDamage = Logger.getLogger("damage");
|
||||
|
||||
public L2SkillChargeDmg(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character caster, L2Object[] targets)
|
||||
{
|
||||
if (caster.isAlikeDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
double modifier = 0;
|
||||
if (caster instanceof L2PcInstance)
|
||||
{
|
||||
// thanks Diego Vargas of L2Guru: 70*((0.8+0.201*No.Charges) * (PATK+POWER)) / PDEF
|
||||
modifier = 0.8 + (0.201 * (getNumCharges() + ((L2PcInstance) caster).getCharges()));
|
||||
}
|
||||
L2ItemInstance weapon = caster.getActiveWeaponInstance();
|
||||
boolean soul = ((weapon != null) && (weapon.getChargedSoulshot() == L2ItemInstance.CHARGED_SOULSHOT) && (weapon.getItemType() != L2WeaponType.DAGGER));
|
||||
|
||||
for (L2Character target : (L2Character[]) targets)
|
||||
{
|
||||
if (target.isAlikeDead())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Calculate skill evasion
|
||||
boolean skillIsEvaded = Formulas.calcPhysicalSkillEvasion(target, this);
|
||||
if (skillIsEvaded)
|
||||
{
|
||||
if (caster instanceof L2PcInstance)
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DODGES_ATTACK);
|
||||
sm.addString(target.getName());
|
||||
((L2PcInstance) caster).sendPacket(sm);
|
||||
}
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.AVOIDED_C1_ATTACK2);
|
||||
sm.addString(caster.getName());
|
||||
((L2PcInstance) target).sendPacket(sm);
|
||||
}
|
||||
|
||||
// no futher calculations needed.
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO: should we use dual or not?
|
||||
// because if so, damage are lowered but we don't do anything special with dual then
|
||||
// like in doAttackHitByDual which in fact does the calcPhysDam call twice
|
||||
// boolean dual = caster.isUsingDualWeapon();
|
||||
byte shld = Formulas.calcShldUse(caster, target, this);
|
||||
boolean crit = false;
|
||||
if (getBaseCritRate() > 0)
|
||||
{
|
||||
crit = Formulas.calcCrit(getBaseCritRate() * 10 * BaseStats.STR.calcBonus(caster), target);
|
||||
}
|
||||
// damage calculation, crit is static 2x
|
||||
double damage = Formulas.calcPhysDam(caster, target, this, shld, false, false, soul);
|
||||
if (crit)
|
||||
{
|
||||
damage *= 2;
|
||||
}
|
||||
|
||||
if (damage > 0)
|
||||
{
|
||||
byte reflect = Formulas.calcSkillReflect(target, this);
|
||||
if (hasEffects())
|
||||
{
|
||||
if ((reflect & Formulas.SKILL_REFLECT_SUCCEED) != 0)
|
||||
{
|
||||
caster.stopSkillEffects(getId());
|
||||
getEffects(target, caster);
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
|
||||
sm.addSkillName(this);
|
||||
caster.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
// activate attacked effects, if any
|
||||
target.stopSkillEffects(getId());
|
||||
if (Formulas.calcSkillSuccess(caster, target, this, shld, false, false, true))
|
||||
{
|
||||
getEffects(caster, target, new Env(shld, false, false, false));
|
||||
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
|
||||
sm.addSkillName(this);
|
||||
target.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_RESISTED_YOUR_S2);
|
||||
sm.addCharName(target);
|
||||
sm.addSkillName(this);
|
||||
caster.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double finalDamage = damage * modifier;
|
||||
|
||||
if (Config.LOG_GAME_DAMAGE && (caster instanceof L2Playable) && (damage > Config.LOG_GAME_DAMAGE_THRESHOLD))
|
||||
{
|
||||
LogRecord record = new LogRecord(Level.INFO, "");
|
||||
record.setParameters(new Object[]
|
||||
{
|
||||
caster,
|
||||
" did damage ",
|
||||
(int) damage,
|
||||
this,
|
||||
" to ",
|
||||
target
|
||||
});
|
||||
record.setLoggerName("pdam");
|
||||
_logDamage.log(record);
|
||||
}
|
||||
|
||||
target.reduceCurrentHp(finalDamage, caster, this);
|
||||
|
||||
// vengeance reflected damage
|
||||
if ((reflect & Formulas.SKILL_REFLECT_VENGEANCE) != 0)
|
||||
{
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.COUNTERED_C1_ATTACK);
|
||||
sm.addCharName(caster);
|
||||
target.sendPacket(sm);
|
||||
}
|
||||
if (caster instanceof L2PcInstance)
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_PERFORMING_COUNTERATTACK);
|
||||
sm.addCharName(target);
|
||||
caster.sendPacket(sm);
|
||||
}
|
||||
// Formula from Diego post, 700 from rpg tests
|
||||
double vegdamage = ((700 * target.getPAtk(caster)) / caster.getPDef(target));
|
||||
caster.reduceCurrentHp(vegdamage, target, this);
|
||||
}
|
||||
|
||||
caster.sendDamageMessage(target, (int) finalDamage, false, crit, false);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
caster.sendDamageMessage(target, 0, false, false, true);
|
||||
}
|
||||
}
|
||||
if (soul && (weapon != null))
|
||||
{
|
||||
weapon.setChargedSoulshot(L2ItemInstance.CHARGED_NONE);
|
||||
}
|
||||
|
||||
// effect self :]
|
||||
if (hasSelfEffects())
|
||||
{
|
||||
L2Effect effect = caster.getFirstEffect(getId());
|
||||
if ((effect != null) && effect.isSelfEffect())
|
||||
{
|
||||
// Replace old effect with new one.
|
||||
effect.exit();
|
||||
}
|
||||
// cast self effect if any
|
||||
getEffectsSelf(caster);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 com.l2jserver.gameserver.skills.l2skills;
|
||||
|
||||
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.model.actor.instance.L2PetInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.PetItemList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.templates.StatsSet;
|
||||
import com.l2jserver.util.Rnd;
|
||||
|
||||
/**
|
||||
* @author Nemesiss
|
||||
*/
|
||||
public class L2SkillCreateItem extends L2Skill
|
||||
{
|
||||
private final int[] _createItemId;
|
||||
private final int _createItemCount;
|
||||
private final int _randomCount;
|
||||
|
||||
public L2SkillCreateItem(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
_createItemId = set.getIntegerArray("create_item_id");
|
||||
_createItemCount = set.getInteger("create_item_count", 0);
|
||||
_randomCount = set.getInteger("random_count", 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.model.L2Skill#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Object[])
|
||||
*/
|
||||
@Override
|
||||
public void useSkill(L2Character activeChar, L2Object[] targets)
|
||||
{
|
||||
L2PcInstance player = activeChar.getActingPlayer();
|
||||
if (activeChar.isAlikeDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (activeChar instanceof L2Playable)
|
||||
{
|
||||
if ((_createItemId == null) || (_createItemCount == 0))
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_PREPARED_FOR_REUSE);
|
||||
sm.addSkillName(this);
|
||||
player.sendPacket(sm);
|
||||
return;
|
||||
}
|
||||
|
||||
int count = _createItemCount + Rnd.nextInt(_randomCount);
|
||||
int rndid = Rnd.nextInt(_createItemId.length);
|
||||
if (activeChar instanceof L2PcInstance)
|
||||
{
|
||||
player.addItem("Skill", _createItemId[rndid], count, activeChar, true);
|
||||
}
|
||||
else if (activeChar instanceof L2PetInstance)
|
||||
{
|
||||
activeChar.getInventory().addItem("Skill", _createItemId[rndid], count, player, activeChar);
|
||||
player.sendPacket(new PetItemList((L2PetInstance) activeChar));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 com.l2jserver.gameserver.skills.l2skills;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.NpcTable;
|
||||
import com.l2jserver.gameserver.idfactory.IdFactory;
|
||||
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.L2DecoyInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.templates.StatsSet;
|
||||
import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;
|
||||
|
||||
public class L2SkillDecoy extends L2Skill
|
||||
{
|
||||
private final int _npcId;
|
||||
private final int _summonTotalLifeTime;
|
||||
|
||||
public L2SkillDecoy(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
_npcId = set.getInteger("npcId", 0);
|
||||
_summonTotalLifeTime = set.getInteger("summonTotalLifeTime", 20000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character caster, L2Object[] targets)
|
||||
{
|
||||
if (caster.isAlikeDead() || !(caster instanceof L2PcInstance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_npcId == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance activeChar = (L2PcInstance) caster;
|
||||
|
||||
if (activeChar.inObserverMode())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((activeChar.getPet() != null) || activeChar.isMounted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2NpcTemplate DecoyTemplate = NpcTable.getInstance().getTemplate(_npcId);
|
||||
final L2DecoyInstance Decoy = new L2DecoyInstance(IdFactory.getInstance().getNextId(), DecoyTemplate, activeChar, this);
|
||||
Decoy.setCurrentHp(Decoy.getMaxHp());
|
||||
Decoy.setCurrentMp(Decoy.getMaxMp());
|
||||
Decoy.setHeading(activeChar.getHeading());
|
||||
activeChar.setDecoy(Decoy);
|
||||
// L2World.getInstance().storeObject(Decoy);
|
||||
Decoy.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
|
||||
}
|
||||
|
||||
public final int getTotalLifeTime()
|
||||
{
|
||||
return _summonTotalLifeTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.l2skills;
|
||||
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Skill;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jserver.gameserver.templates.StatsSet;
|
||||
|
||||
public class L2SkillDefault extends L2Skill
|
||||
{
|
||||
|
||||
public L2SkillDefault(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character caster, L2Object[] targets)
|
||||
{
|
||||
caster.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
caster.sendMessage("Skill not implemented. Skill ID: " + getId() + " " + getSkillType());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.l2skills;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
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.L2Playable;
|
||||
import com.l2jserver.gameserver.model.actor.L2Summon;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2CubicInstance;
|
||||
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.Formulas;
|
||||
import com.l2jserver.gameserver.templates.StatsSet;
|
||||
|
||||
public class L2SkillDrain extends L2Skill
|
||||
{
|
||||
private static final Logger _logDamage = Logger.getLogger("damage");
|
||||
|
||||
private final float _absorbPart;
|
||||
private final int _absorbAbs;
|
||||
|
||||
public L2SkillDrain(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
|
||||
_absorbPart = set.getFloat("absorbPart", 0.f);
|
||||
_absorbAbs = set.getInteger("absorbAbs", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character activeChar, L2Object[] targets)
|
||||
{
|
||||
if (activeChar.isAlikeDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
boolean ss = false;
|
||||
boolean bss = false;
|
||||
|
||||
for (L2Character target : (L2Character[]) targets)
|
||||
{
|
||||
if (target.isAlikeDead() && (getTargetType() != SkillTargetType.TARGET_CORPSE_MOB))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((activeChar != target) && target.isInvul())
|
||||
{
|
||||
continue; // No effect on invulnerable chars unless they cast it themselves.
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
boolean mcrit = Formulas.calcMCrit(activeChar.getMCriticalHit(target, this));
|
||||
byte shld = Formulas.calcShldUse(activeChar, target, this);
|
||||
int damage = (int) Formulas.calcMagicDam(activeChar, target, this, shld, ss, bss, mcrit);
|
||||
|
||||
int _drain = 0;
|
||||
int _cp = (int) target.getCurrentCp();
|
||||
int _hp = (int) target.getCurrentHp();
|
||||
|
||||
if (_cp > 0)
|
||||
{
|
||||
if (damage < _cp)
|
||||
{
|
||||
_drain = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_drain = damage - _cp;
|
||||
}
|
||||
}
|
||||
else if (damage > _hp)
|
||||
{
|
||||
_drain = _hp;
|
||||
}
|
||||
else
|
||||
{
|
||||
_drain = damage;
|
||||
}
|
||||
|
||||
double hpAdd = _absorbAbs + (_absorbPart * _drain);
|
||||
double hp = ((activeChar.getCurrentHp() + hpAdd) > activeChar.getMaxHp() ? activeChar.getMaxHp() : (activeChar.getCurrentHp() + hpAdd));
|
||||
|
||||
activeChar.setCurrentHp(hp);
|
||||
|
||||
StatusUpdate suhp = new StatusUpdate(activeChar);
|
||||
suhp.addAttribute(StatusUpdate.CUR_HP, (int) hp);
|
||||
activeChar.sendPacket(suhp);
|
||||
|
||||
// Check to see if we should damage the target
|
||||
if ((damage > 0) && (!target.isDead() || (getTargetType() != SkillTargetType.TARGET_CORPSE_MOB)))
|
||||
{
|
||||
// Manage attack or cast break of the target (calculating rate, sending message...)
|
||||
if (!target.isRaid() && Formulas.calcAtkBreak(target, damage))
|
||||
{
|
||||
target.breakAttack();
|
||||
target.breakCast();
|
||||
}
|
||||
|
||||
activeChar.sendDamageMessage(target, damage, mcrit, false, 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 ",
|
||||
(int) damage,
|
||||
this,
|
||||
" to ",
|
||||
target
|
||||
});
|
||||
record.setLoggerName("mdam");
|
||||
_logDamage.log(record);
|
||||
}
|
||||
|
||||
if (hasEffects() && (getTargetType() != SkillTargetType.TARGET_CORPSE_MOB))
|
||||
{
|
||||
// ignoring vengance-like reflections
|
||||
if ((Formulas.calcSkillReflect(target, this) & Formulas.SKILL_REFLECT_SUCCEED) > 0)
|
||||
{
|
||||
activeChar.stopSkillEffects(getId());
|
||||
getEffects(target, activeChar);
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
|
||||
sm.addSkillName(getId());
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
// activate attacked effects, if any
|
||||
target.stopSkillEffects(getId());
|
||||
if (Formulas.calcSkillSuccess(activeChar, target, this, shld, false, ss, bss))
|
||||
{
|
||||
getEffects(activeChar, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_RESISTED_YOUR_S2);
|
||||
sm.addCharName(target);
|
||||
sm.addSkillName(this);
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
target.reduceCurrentHp(damage, activeChar, this);
|
||||
}
|
||||
|
||||
// Check to see if we should do the decay right after the cast
|
||||
if (target.isDead() && (getTargetType() == SkillTargetType.TARGET_CORPSE_MOB) && (target instanceof L2Npc))
|
||||
{
|
||||
((L2Npc) target).endDecayTask();
|
||||
}
|
||||
}
|
||||
// effect self :]
|
||||
L2Effect effect = activeChar.getFirstEffect(getId());
|
||||
if ((effect != null) && effect.isSelfEffect())
|
||||
{
|
||||
// Replace old effect with new one.
|
||||
effect.exit();
|
||||
}
|
||||
// cast self effect if any
|
||||
getEffectsSelf(activeChar);
|
||||
}
|
||||
|
||||
public void useCubicSkill(L2CubicInstance activeCubic, L2Object[] targets)
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.info("L2SkillDrain: useCubicSkill()");
|
||||
}
|
||||
|
||||
for (L2Character target : (L2Character[]) targets)
|
||||
{
|
||||
if (target.isAlikeDead() && (getTargetType() != SkillTargetType.TARGET_CORPSE_MOB))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean mcrit = Formulas.calcMCrit(activeCubic.getMCriticalHit(target, this));
|
||||
byte shld = Formulas.calcShldUse(activeCubic.getOwner(), target, this);
|
||||
|
||||
int damage = (int) Formulas.calcMagicDam(activeCubic, target, this, mcrit, shld);
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.info("L2SkillDrain: useCubicSkill() -> damage = " + damage);
|
||||
}
|
||||
|
||||
double hpAdd = _absorbAbs + (_absorbPart * damage);
|
||||
L2PcInstance owner = activeCubic.getOwner();
|
||||
double hp = ((owner.getCurrentHp() + hpAdd) > owner.getMaxHp() ? owner.getMaxHp() : (owner.getCurrentHp() + hpAdd));
|
||||
|
||||
owner.setCurrentHp(hp);
|
||||
|
||||
StatusUpdate suhp = new StatusUpdate(owner);
|
||||
suhp.addAttribute(StatusUpdate.CUR_HP, (int) hp);
|
||||
owner.sendPacket(suhp);
|
||||
|
||||
// Check to see if we should damage the target
|
||||
if ((damage > 0) && (!target.isDead() || (getTargetType() != SkillTargetType.TARGET_CORPSE_MOB)))
|
||||
{
|
||||
target.reduceCurrentHp(damage, activeCubic.getOwner(), this);
|
||||
|
||||
// Manage attack or cast break of the target (calculating rate, sending message...)
|
||||
if (!target.isRaid() && Formulas.calcAtkBreak(target, damage))
|
||||
{
|
||||
target.breakAttack();
|
||||
target.breakCast();
|
||||
}
|
||||
owner.sendDamageMessage(target, damage, mcrit, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.l2skills;
|
||||
|
||||
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.skills.Env;
|
||||
import com.l2jserver.gameserver.skills.Formulas;
|
||||
import com.l2jserver.gameserver.templates.StatsSet;
|
||||
|
||||
public class L2SkillElemental extends L2Skill
|
||||
{
|
||||
|
||||
private final int[] _seeds;
|
||||
private final boolean _seedAny;
|
||||
|
||||
public L2SkillElemental(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
|
||||
_seeds = new int[3];
|
||||
_seeds[0] = set.getInteger("seed1", 0);
|
||||
_seeds[1] = set.getInteger("seed2", 0);
|
||||
_seeds[2] = set.getInteger("seed3", 0);
|
||||
|
||||
if (set.getInteger("seed_any", 0) == 1)
|
||||
{
|
||||
_seedAny = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_seedAny = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character activeChar, L2Object[] targets)
|
||||
{
|
||||
if (activeChar.isAlikeDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
boolean ss = false;
|
||||
boolean bss = false;
|
||||
|
||||
L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
|
||||
|
||||
if (activeChar instanceof L2PcInstance)
|
||||
{
|
||||
if (weaponInst == null)
|
||||
{
|
||||
activeChar.sendMessage("You must equip your weapon before casting a spell.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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 (target.isAlikeDead())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean charged = true;
|
||||
if (!_seedAny)
|
||||
{
|
||||
for (int _seed : _seeds)
|
||||
{
|
||||
if (_seed != 0)
|
||||
{
|
||||
L2Effect e = target.getFirstEffect(_seed);
|
||||
if ((e == null) || !e.getInUse())
|
||||
{
|
||||
charged = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
charged = false;
|
||||
for (int _seed : _seeds)
|
||||
{
|
||||
if (_seed != 0)
|
||||
{
|
||||
L2Effect e = target.getFirstEffect(_seed);
|
||||
if ((e != null) && e.getInUse())
|
||||
{
|
||||
charged = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!charged)
|
||||
{
|
||||
activeChar.sendMessage("Target is not charged by elements.");
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean mcrit = Formulas.calcMCrit(activeChar.getMCriticalHit(target, this));
|
||||
byte shld = Formulas.calcShldUse(activeChar, target, this);
|
||||
|
||||
int damage = (int) Formulas.calcMagicDam(activeChar, target, this, shld, ss, bss, mcrit);
|
||||
|
||||
if (damage > 0)
|
||||
{
|
||||
target.reduceCurrentHp(damage, activeChar, this);
|
||||
|
||||
// Manage attack or cast break of the target (calculating rate, sending message...)
|
||||
if (!target.isRaid() && Formulas.calcAtkBreak(target, damage))
|
||||
{
|
||||
target.breakAttack();
|
||||
target.breakCast();
|
||||
}
|
||||
|
||||
activeChar.sendDamageMessage(target, damage, false, false, false);
|
||||
|
||||
}
|
||||
|
||||
// activate attacked effects, if any
|
||||
target.stopSkillEffects(getId());
|
||||
getEffects(activeChar, target, new Env(shld, ss, false, bss));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.l2skills;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.SkillTable;
|
||||
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.StatsSet;
|
||||
|
||||
public class L2SkillLearnSkill extends L2Skill
|
||||
{
|
||||
private final int[] _learnSkillId;
|
||||
private final int[] _learnSkillLvl;
|
||||
|
||||
public L2SkillLearnSkill(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
|
||||
String[] ar = set.getString("learnSkillId", "0").split(",");
|
||||
int[] ar2 = new int[ar.length];
|
||||
|
||||
for (int i = 0; i < ar.length; i++)
|
||||
{
|
||||
ar2[i] = Integer.parseInt(ar[i]);
|
||||
}
|
||||
|
||||
_learnSkillId = ar2;
|
||||
|
||||
ar = set.getString("learnSkillLvl", "1").split(",");
|
||||
ar2 = new int[_learnSkillId.length];
|
||||
|
||||
for (int i = 0; i < _learnSkillId.length; i++)
|
||||
{
|
||||
ar2[i] = 1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < ar.length; i++)
|
||||
{
|
||||
ar2[i] = Integer.parseInt(ar[i]);
|
||||
}
|
||||
|
||||
_learnSkillLvl = ar2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character activeChar, L2Object[] targets)
|
||||
{
|
||||
if (!(activeChar instanceof L2PcInstance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance player = ((L2PcInstance) activeChar);
|
||||
L2Skill newSkill;
|
||||
|
||||
for (int i = 0; i < _learnSkillId.length; i++)
|
||||
{
|
||||
if ((player.getSkillLevel(_learnSkillId[i]) < _learnSkillLvl[i]) && (_learnSkillId[i] != 0))
|
||||
{
|
||||
newSkill = SkillTable.getInstance().getInfo(_learnSkillId[i], _learnSkillLvl[i]);
|
||||
if (newSkill != null)
|
||||
{
|
||||
player.addSkill(newSkill, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.l2skills;
|
||||
|
||||
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.TvTEvent;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.templates.StatsSet;
|
||||
|
||||
public class L2SkillMount extends L2Skill
|
||||
{
|
||||
private final int _npcId;
|
||||
private final int _itemId;
|
||||
|
||||
public L2SkillMount(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
_npcId = set.getInteger("npcId", 0);
|
||||
_itemId = set.getInteger("itemId", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character caster, L2Object[] targets)
|
||||
{
|
||||
if (!(caster instanceof L2PcInstance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TvTEvent.onItemSummon(caster.getObjectId()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2PcInstance activePlayer = (L2PcInstance) caster;
|
||||
|
||||
if (!activePlayer.getFloodProtectors().getItemPetSummon().tryPerformAction("mount"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Dismount Action
|
||||
if (_npcId == 0)
|
||||
{
|
||||
activePlayer.dismount();
|
||||
return;
|
||||
}
|
||||
|
||||
if (activePlayer.isSitting())
|
||||
{
|
||||
activePlayer.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANT_MOVE_SITTING));
|
||||
return;
|
||||
}
|
||||
|
||||
if (activePlayer.inObserverMode())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (activePlayer.isInOlympiadMode())
|
||||
{
|
||||
activePlayer.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((activePlayer.getPet() != null) || activePlayer.isMounted())
|
||||
{
|
||||
activePlayer.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_ALREADY_HAVE_A_PET));
|
||||
return;
|
||||
}
|
||||
|
||||
if (activePlayer.isAttackingNow() || activePlayer.isCursedWeaponEquipped())
|
||||
{
|
||||
activePlayer.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CANNOT_SUMMON_IN_COMBAT));
|
||||
return;
|
||||
}
|
||||
|
||||
activePlayer.mount(_npcId, _itemId, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.l2skills;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.NpcTable;
|
||||
import com.l2jserver.gameserver.idfactory.IdFactory;
|
||||
import com.l2jserver.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jserver.gameserver.instancemanager.FortManager;
|
||||
import com.l2jserver.gameserver.instancemanager.FortSiegeManager;
|
||||
import com.l2jserver.gameserver.instancemanager.SiegeManager;
|
||||
import com.l2jserver.gameserver.instancemanager.TerritoryWarManager;
|
||||
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.L2SiegeFlagInstance;
|
||||
import com.l2jserver.gameserver.model.entity.Castle;
|
||||
import com.l2jserver.gameserver.model.entity.Fort;
|
||||
import com.l2jserver.gameserver.templates.StatsSet;
|
||||
|
||||
public class L2SkillSiegeFlag extends L2Skill
|
||||
{
|
||||
private final boolean _isAdvanced;
|
||||
private final boolean _isOutpost;
|
||||
|
||||
public L2SkillSiegeFlag(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
_isAdvanced = set.getBool("isAdvanced", false);
|
||||
_isOutpost = set.getBool("isOutpost", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.model.L2Skill#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Object[])
|
||||
*/
|
||||
@Override
|
||||
public void useSkill(L2Character activeChar, L2Object[] targets)
|
||||
{
|
||||
if (!(activeChar instanceof L2PcInstance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2PcInstance player = (L2PcInstance) activeChar;
|
||||
|
||||
if ((player.getClan() == null) || (player.getClan().getLeaderId() != player.getObjectId()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!checkIfOkToPlaceFlag(player, true, _isOutpost))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Territory War
|
||||
if (TerritoryWarManager.getInstance().isTWInProgress())
|
||||
{
|
||||
try
|
||||
{
|
||||
// Spawn a new flag
|
||||
L2SiegeFlagInstance flag = new L2SiegeFlagInstance(player, IdFactory.getInstance().getNextId(), NpcTable.getInstance().getTemplate((_isOutpost ? 36590 : 35062)), _isAdvanced, _isOutpost);
|
||||
flag.setTitle(player.getClan().getName());
|
||||
flag.setCurrentHpMp(flag.getMaxHp(), flag.getMaxMp());
|
||||
flag.setHeading(player.getHeading());
|
||||
flag.spawnMe(player.getX(), player.getY(), player.getZ() + 50);
|
||||
if (_isOutpost)
|
||||
{
|
||||
TerritoryWarManager.getInstance().setHQForClan(player.getClan(), flag);
|
||||
}
|
||||
else
|
||||
{
|
||||
TerritoryWarManager.getInstance().addClanFlag(player.getClan(), flag);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
player.sendMessage("Error placing flag: " + e);
|
||||
_log.log(Level.WARNING, "Error placing flag: " + e.getMessage(), e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Fortress/Castle siege
|
||||
try
|
||||
{
|
||||
// Spawn a new flag
|
||||
L2SiegeFlagInstance flag = new L2SiegeFlagInstance(player, IdFactory.getInstance().getNextId(), NpcTable.getInstance().getTemplate(35062), _isAdvanced, false);
|
||||
flag.setTitle(player.getClan().getName());
|
||||
flag.setCurrentHpMp(flag.getMaxHp(), flag.getMaxMp());
|
||||
flag.setHeading(player.getHeading());
|
||||
flag.spawnMe(player.getX(), player.getY(), player.getZ() + 50);
|
||||
Castle castle = CastleManager.getInstance().getCastle(activeChar);
|
||||
Fort fort = FortManager.getInstance().getFort(activeChar);
|
||||
if (castle != null)
|
||||
{
|
||||
castle.getSiege().getFlag(player.getClan()).add(flag);
|
||||
}
|
||||
else
|
||||
{
|
||||
fort.getSiege().getFlag(player.getClan()).add(flag);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
player.sendMessage("Error placing flag:" + e);
|
||||
_log.log(Level.WARNING, "Error placing flag: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if character clan place a flag<BR>
|
||||
* <BR>
|
||||
* @param activeChar The L2Character of the character placing the flag
|
||||
* @param isCheckOnly if false, it will send a notification to the player telling him why it failed
|
||||
*/
|
||||
public static boolean checkIfOkToPlaceFlag(L2Character activeChar, boolean isCheckOnly, boolean isOutPost)
|
||||
{
|
||||
if (TerritoryWarManager.getInstance().isTWInProgress())
|
||||
{
|
||||
return checkIfOkToPlaceHQ(activeChar, isCheckOnly, isOutPost);
|
||||
}
|
||||
else if (isOutPost)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Castle castle = CastleManager.getInstance().getCastle(activeChar);
|
||||
Fort fort = FortManager.getInstance().getFort(activeChar);
|
||||
|
||||
if ((castle == null) && (fort == null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (castle != null)
|
||||
{
|
||||
return checkIfOkToPlaceFlag(activeChar, castle, isCheckOnly);
|
||||
}
|
||||
return checkIfOkToPlaceFlag(activeChar, fort, isCheckOnly);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
* @param castle
|
||||
* @param isCheckOnly
|
||||
* @return
|
||||
*/
|
||||
public static boolean checkIfOkToPlaceFlag(L2Character activeChar, Castle castle, boolean isCheckOnly)
|
||||
{
|
||||
if (!(activeChar instanceof L2PcInstance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String text = "";
|
||||
L2PcInstance player = (L2PcInstance) activeChar;
|
||||
|
||||
if ((castle == null) || (castle.getCastleId() <= 0))
|
||||
{
|
||||
text = "You must be on castle ground to place a flag.";
|
||||
}
|
||||
else if (!castle.getSiege().getIsInProgress())
|
||||
{
|
||||
text = "You can only place a flag during a siege.";
|
||||
}
|
||||
else if (castle.getSiege().getAttackerClan(player.getClan()) == null)
|
||||
{
|
||||
text = "You must be an attacker to place a flag.";
|
||||
}
|
||||
else if (!player.isClanLeader())
|
||||
{
|
||||
text = "You must be a clan leader to place a flag.";
|
||||
}
|
||||
else if (castle.getSiege().getAttackerClan(player.getClan()).getNumFlags() >= SiegeManager.getInstance().getFlagMaxCount())
|
||||
{
|
||||
text = "You have already placed the maximum number of flags possible.";
|
||||
}
|
||||
else if (player.isInsideZone(L2Character.ZONE_NOHQ))
|
||||
{
|
||||
text = "You cannot place flag here.";
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isCheckOnly)
|
||||
{
|
||||
player.sendMessage(text);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
* @param fort
|
||||
* @param isCheckOnly
|
||||
* @return
|
||||
*/
|
||||
public static boolean checkIfOkToPlaceFlag(L2Character activeChar, Fort fort, boolean isCheckOnly)
|
||||
{
|
||||
if (!(activeChar instanceof L2PcInstance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String text = "";
|
||||
L2PcInstance player = (L2PcInstance) activeChar;
|
||||
|
||||
if ((fort == null) || (fort.getFortId() <= 0))
|
||||
{
|
||||
text = "You must be on fort ground to place a flag.";
|
||||
}
|
||||
else if (!fort.getSiege().getIsInProgress())
|
||||
{
|
||||
text = "You can only place a flag during a siege.";
|
||||
}
|
||||
else if (fort.getSiege().getAttackerClan(player.getClan()) == null)
|
||||
{
|
||||
text = "You must be an attacker to place a flag.";
|
||||
}
|
||||
else if (!player.isClanLeader())
|
||||
{
|
||||
text = "You must be a clan leader to place a flag.";
|
||||
}
|
||||
else if (fort.getSiege().getAttackerClan(player.getClan()).getNumFlags() >= FortSiegeManager.getInstance().getFlagMaxCount())
|
||||
{
|
||||
text = "You have already placed the maximum number of flags possible.";
|
||||
}
|
||||
else if (player.isInsideZone(L2Character.ZONE_NOHQ))
|
||||
{
|
||||
text = "You cannot place flag here.";
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isCheckOnly)
|
||||
{
|
||||
player.sendMessage(text);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if character clan place a flag<BR>
|
||||
* <BR>
|
||||
* @param activeChar The L2Character of the character placing the flag
|
||||
* @param isCheckOnly if false, it will send a notification to the player telling him why it failed
|
||||
*/
|
||||
public static boolean checkIfOkToPlaceHQ(L2Character activeChar, boolean isCheckOnly, boolean isOutPost)
|
||||
{
|
||||
Castle castle = CastleManager.getInstance().getCastle(activeChar);
|
||||
Fort fort = FortManager.getInstance().getFort(activeChar);
|
||||
|
||||
if ((castle == null) && (fort == null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String text = "";
|
||||
L2PcInstance player = (L2PcInstance) activeChar;
|
||||
|
||||
if (((fort != null) && (fort.getFortId() == 0)) || ((castle != null) && (castle.getCastleId() == 0)))
|
||||
{
|
||||
text = "You must be on fort or castle ground to construct an outpost or flag.";
|
||||
}
|
||||
else if (((fort != null) && !fort.getZone().isActive()) || ((castle != null) && !castle.getZone().isActive()))
|
||||
{
|
||||
text = "You can only construct an outpost or flag on siege field.";
|
||||
}
|
||||
else if (!player.isClanLeader())
|
||||
{
|
||||
text = "You must be a clan leader to construct an outpost or flag.";
|
||||
}
|
||||
else if ((TerritoryWarManager.getInstance().getHQForClan(player.getClan()) != null) && isOutPost)
|
||||
{
|
||||
text = "You can have only one outpost.";
|
||||
}
|
||||
else if ((TerritoryWarManager.getInstance().getFlagForClan(player.getClan()) != null) && !isOutPost)
|
||||
{
|
||||
text = "You can have only one flag.";
|
||||
}
|
||||
else if (player.isInsideZone(L2Character.ZONE_NOHQ))
|
||||
{
|
||||
text = "You cannot construct outpost or flag here.";
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isCheckOnly)
|
||||
{
|
||||
player.sendMessage(text);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author Forsaiken
|
||||
*/
|
||||
|
||||
package com.l2jserver.gameserver.skills.l2skills;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.NpcTable;
|
||||
import com.l2jserver.gameserver.idfactory.IdFactory;
|
||||
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.L2EffectPointInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.templates.StatsSet;
|
||||
import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;
|
||||
import com.l2jserver.util.Point3D;
|
||||
|
||||
public final class L2SkillSignet extends L2Skill
|
||||
{
|
||||
private final int _effectNpcId;
|
||||
public int effectId;
|
||||
|
||||
public L2SkillSignet(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
_effectNpcId = set.getInteger("effectNpcId", -1);
|
||||
effectId = set.getInteger("effectId", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character caster, L2Object[] targets)
|
||||
{
|
||||
if (caster.isAlikeDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2NpcTemplate template = NpcTable.getInstance().getTemplate(_effectNpcId);
|
||||
L2EffectPointInstance effectPoint = new L2EffectPointInstance(IdFactory.getInstance().getNextId(), template, caster);
|
||||
effectPoint.setCurrentHp(effectPoint.getMaxHp());
|
||||
effectPoint.setCurrentMp(effectPoint.getMaxMp());
|
||||
// L2World.getInstance().storeObject(effectPoint);
|
||||
|
||||
int x = caster.getX();
|
||||
int y = caster.getY();
|
||||
int z = caster.getZ();
|
||||
|
||||
if ((caster instanceof L2PcInstance) && (getTargetType() == L2Skill.SkillTargetType.TARGET_GROUND))
|
||||
{
|
||||
Point3D wordPosition = ((L2PcInstance) caster).getCurrentSkillWorldPosition();
|
||||
|
||||
if (wordPosition != null)
|
||||
{
|
||||
x = wordPosition.getX();
|
||||
y = wordPosition.getY();
|
||||
z = wordPosition.getZ();
|
||||
}
|
||||
}
|
||||
getEffects(caster, effectPoint);
|
||||
|
||||
effectPoint.setIsInvul(true);
|
||||
effectPoint.spawnMe(x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author Forsaiken
|
||||
*/
|
||||
|
||||
package com.l2jserver.gameserver.skills.l2skills;
|
||||
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Skill;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.templates.StatsSet;
|
||||
|
||||
public final class L2SkillSignetCasttime extends L2Skill
|
||||
{
|
||||
public int _effectNpcId;
|
||||
public int effectId;
|
||||
|
||||
public L2SkillSignetCasttime(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
_effectNpcId = set.getInteger("effectNpcId", -1);
|
||||
effectId = set.getInteger("effectId", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character caster, L2Object[] targets)
|
||||
{
|
||||
if (caster.isAlikeDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
getEffectsSelf(caster);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.l2skills;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.NpcTable;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Skill;
|
||||
import com.l2jserver.gameserver.model.L2Spawn;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.templates.StatsSet;
|
||||
import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;
|
||||
import com.l2jserver.util.Rnd;
|
||||
|
||||
public class L2SkillSpawn extends L2Skill
|
||||
{
|
||||
private final int _npcId;
|
||||
private final int _despawnDelay;
|
||||
private final boolean _summonSpawn;
|
||||
private final boolean _randomOffset;
|
||||
|
||||
public L2SkillSpawn(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
_npcId = set.getInteger("npcId", 0);
|
||||
_despawnDelay = set.getInteger("despawnDelay", 0);
|
||||
_summonSpawn = set.getBool("isSummonSpawn", false);
|
||||
_randomOffset = set.getBool("randomOffset", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character caster, L2Object[] targets)
|
||||
{
|
||||
if (caster.isAlikeDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_npcId == 0)
|
||||
{
|
||||
_log.warning("NPC ID not defined for skill ID:" + getId());
|
||||
return;
|
||||
}
|
||||
|
||||
final L2NpcTemplate template = NpcTable.getInstance().getTemplate(_npcId);
|
||||
if (template == null)
|
||||
{
|
||||
_log.warning("Spawn of the nonexisting NPC ID:" + _npcId + ", skill ID:" + getId());
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final L2Spawn spawn = new L2Spawn(template);
|
||||
spawn.setInstanceId(caster.getInstanceId());
|
||||
spawn.setHeading(-1);
|
||||
|
||||
if (_randomOffset)
|
||||
{
|
||||
spawn.setLocx(caster.getX() + (Rnd.nextBoolean() ? Rnd.get(20, 50) : Rnd.get(-50, -20)));
|
||||
spawn.setLocy(caster.getY() + (Rnd.nextBoolean() ? Rnd.get(20, 50) : Rnd.get(-50, -20)));
|
||||
}
|
||||
else
|
||||
{
|
||||
spawn.setLocx(caster.getX());
|
||||
spawn.setLocy(caster.getY());
|
||||
}
|
||||
spawn.setLocz(caster.getZ() + 20);
|
||||
|
||||
spawn.stopRespawn();
|
||||
L2Npc npc = spawn.spawnOne(_summonSpawn);
|
||||
if (_despawnDelay > 0)
|
||||
{
|
||||
npc.scheduleDespawn(_despawnDelay);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception while spawning NPC ID: " + _npcId + ", skill ID: " + getId() + ", exception: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,334 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.l2skills;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.NpcTable;
|
||||
import com.l2jserver.gameserver.idfactory.IdFactory;
|
||||
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.L2CubicInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2MerchantSummonInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2SiegeSummonInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2SummonInstance;
|
||||
import com.l2jserver.gameserver.model.base.Experience;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.templates.StatsSet;
|
||||
import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;
|
||||
|
||||
public class L2SkillSummon extends L2Skill
|
||||
{
|
||||
public static final int SKILL_CUBIC_MASTERY = 143;
|
||||
|
||||
private final int _npcId;
|
||||
private final float _expPenalty;
|
||||
private final boolean _isCubic;
|
||||
|
||||
// cubic AI
|
||||
// Activation time for a cubic
|
||||
private final int _activationtime;
|
||||
// Activation chance for a cubic.
|
||||
private final int _activationchance;
|
||||
// Maximum casts made by the cubic until it goes idle.
|
||||
private final int _maxcount;
|
||||
|
||||
// What is the total lifetime of summons (in millisecs)
|
||||
private final int _summonTotalLifeTime;
|
||||
// How much lifetime is lost per second of idleness (non-fighting)
|
||||
private final int _summonTimeLostIdle;
|
||||
// How much time is lost per second of activity (fighting)
|
||||
private final int _summonTimeLostActive;
|
||||
|
||||
// item consume time in milliseconds
|
||||
private final int _itemConsumeTime;
|
||||
// item consume count over time
|
||||
private final int _itemConsumeOT;
|
||||
// item consume id over time
|
||||
private final int _itemConsumeIdOT;
|
||||
// how many times to consume an item
|
||||
private final int _itemConsumeSteps;
|
||||
|
||||
public L2SkillSummon(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
|
||||
_npcId = set.getInteger("npcId", 0); // default for undescribed skills
|
||||
_expPenalty = set.getFloat("expPenalty", 0.f);
|
||||
_isCubic = set.getBool("isCubic", false);
|
||||
|
||||
_activationtime = set.getInteger("activationtime", 8);
|
||||
_activationchance = set.getInteger("activationchance", 30);
|
||||
_maxcount = set.getInteger("maxcount", -1);
|
||||
|
||||
_summonTotalLifeTime = set.getInteger("summonTotalLifeTime", 1200000); // 20 minutes default
|
||||
_summonTimeLostIdle = set.getInteger("summonTimeLostIdle", 0);
|
||||
_summonTimeLostActive = set.getInteger("summonTimeLostActive", 0);
|
||||
|
||||
_itemConsumeOT = set.getInteger("itemConsumeCountOT", 0);
|
||||
_itemConsumeIdOT = set.getInteger("itemConsumeIdOT", 0);
|
||||
_itemConsumeTime = set.getInteger("itemConsumeTime", 0);
|
||||
_itemConsumeSteps = set.getInteger("itemConsumeSteps", 0);
|
||||
}
|
||||
|
||||
public boolean checkCondition(L2Character activeChar)
|
||||
{
|
||||
if (activeChar instanceof L2PcInstance)
|
||||
{
|
||||
L2PcInstance player = (L2PcInstance) activeChar;
|
||||
|
||||
if (isCubic())
|
||||
{
|
||||
if (getTargetType() != L2Skill.SkillTargetType.TARGET_SELF)
|
||||
{
|
||||
return true; // Player is always able to cast mass cubic skill
|
||||
}
|
||||
int mastery = player.getSkillLevel(SKILL_CUBIC_MASTERY);
|
||||
if (mastery < 0)
|
||||
{
|
||||
mastery = 0;
|
||||
}
|
||||
int count = player.getCubics().size();
|
||||
if (count > mastery)
|
||||
{
|
||||
activeChar.sendMessage("You already have " + count + " cubic(s).");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player.inObserverMode())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (player.getPet() != null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_ALREADY_HAVE_A_PET));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.checkCondition(activeChar, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character caster, L2Object[] targets)
|
||||
{
|
||||
if (caster.isAlikeDead() || !(caster instanceof L2PcInstance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2PcInstance activeChar = (L2PcInstance) caster;
|
||||
|
||||
if (_npcId == 0)
|
||||
{
|
||||
activeChar.sendMessage("Summon skill " + getId() + " not described yet");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_isCubic)
|
||||
{
|
||||
// Gnacik :
|
||||
// If skill is enchanted calculate cubic skill level based on enchant
|
||||
// 8 at 101 (+1 Power)
|
||||
// 12 at 130 (+30 Power)
|
||||
// Because 12 is max 5115-5117 skills
|
||||
// TODO: make better method of calculation, dunno how its calculated on offi
|
||||
int _cubicSkillLevel = getLevel();
|
||||
if (_cubicSkillLevel > 100)
|
||||
{
|
||||
_cubicSkillLevel = Math.round(((getLevel() - 100) / 7) + 8);
|
||||
}
|
||||
|
||||
if (targets.length > 1) // Mass cubic skill
|
||||
{
|
||||
for (L2Object obj : targets)
|
||||
{
|
||||
if (!(obj instanceof L2PcInstance))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
L2PcInstance player = ((L2PcInstance) obj);
|
||||
int mastery = player.getSkillLevel(SKILL_CUBIC_MASTERY);
|
||||
if (mastery < 0)
|
||||
{
|
||||
mastery = 0;
|
||||
}
|
||||
if ((mastery == 0) && !player.getCubics().isEmpty())
|
||||
{
|
||||
// Player can have only 1 cubic - we shuld replace old cubic with new one
|
||||
for (L2CubicInstance c : player.getCubics().values())
|
||||
{
|
||||
c.stopAction();
|
||||
c = null;
|
||||
}
|
||||
player.getCubics().clear();
|
||||
}
|
||||
// TODO: Should remove first cubic summoned and replace with new cubic
|
||||
if (player.getCubics().containsKey(_npcId))
|
||||
{
|
||||
L2CubicInstance cubic = player.getCubic(_npcId);
|
||||
cubic.stopAction();
|
||||
cubic.cancelDisappear();
|
||||
player.delCubic(_npcId);
|
||||
}
|
||||
if (player.getCubics().size() > mastery)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (player == activeChar)
|
||||
{
|
||||
player.addCubic(_npcId, _cubicSkillLevel, getPower(), _activationtime, _activationchance, _maxcount, _summonTotalLifeTime, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.addCubic(_npcId, _cubicSkillLevel, getPower(), _activationtime, _activationchance, _maxcount, _summonTotalLifeTime, true);
|
||||
}
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
return;
|
||||
}
|
||||
int mastery = activeChar.getSkillLevel(SKILL_CUBIC_MASTERY);
|
||||
if (mastery < 0)
|
||||
{
|
||||
mastery = 0;
|
||||
}
|
||||
if (activeChar.getCubics().containsKey(_npcId))
|
||||
{
|
||||
L2CubicInstance cubic = activeChar.getCubic(_npcId);
|
||||
cubic.stopAction();
|
||||
cubic.cancelDisappear();
|
||||
activeChar.delCubic(_npcId);
|
||||
}
|
||||
if (activeChar.getCubics().size() > mastery)
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("player can't summon any more cubics. ignore summon skill");
|
||||
}
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CUBIC_SUMMONING_FAILED));
|
||||
return;
|
||||
}
|
||||
activeChar.addCubic(_npcId, _cubicSkillLevel, getPower(), _activationtime, _activationchance, _maxcount, _summonTotalLifeTime, false);
|
||||
activeChar.broadcastUserInfo();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((activeChar.getPet() != null) || activeChar.isMounted())
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("player has a pet already. ignore summon skill");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
L2SummonInstance summon;
|
||||
L2NpcTemplate summonTemplate = NpcTable.getInstance().getTemplate(_npcId);
|
||||
if (summonTemplate == null)
|
||||
{
|
||||
_log.warning("Summon attempt for nonexisting NPC ID:" + _npcId + ", skill ID:" + getId());
|
||||
return; // npcID doesn't exist
|
||||
}
|
||||
if (summonTemplate.type.equalsIgnoreCase("L2SiegeSummon"))
|
||||
{
|
||||
summon = new L2SiegeSummonInstance(IdFactory.getInstance().getNextId(), summonTemplate, activeChar, this);
|
||||
}
|
||||
else if (summonTemplate.type.equalsIgnoreCase("L2MerchantSummon"))
|
||||
{
|
||||
summon = new L2MerchantSummonInstance(IdFactory.getInstance().getNextId(), summonTemplate, activeChar, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
summon = new L2SummonInstance(IdFactory.getInstance().getNextId(), summonTemplate, activeChar, this);
|
||||
}
|
||||
|
||||
summon.setName(summonTemplate.name);
|
||||
summon.setTitle(activeChar.getName());
|
||||
summon.setExpPenalty(_expPenalty);
|
||||
if (summon.getLevel() >= Experience.LEVEL.length)
|
||||
{
|
||||
summon.getStat().setExp(Experience.LEVEL[Experience.LEVEL.length - 1]);
|
||||
_log.warning("Summon (" + summon.getName() + ") NpcID: " + summon.getNpcId() + " has a level above 75. Please rectify.");
|
||||
}
|
||||
else
|
||||
{
|
||||
summon.getStat().setExp(Experience.LEVEL[(summon.getLevel() % Experience.LEVEL.length)]);
|
||||
}
|
||||
summon.setCurrentHp(summon.getMaxHp());
|
||||
summon.setCurrentMp(summon.getMaxMp());
|
||||
summon.setHeading(activeChar.getHeading());
|
||||
summon.setRunning();
|
||||
if (!(summon instanceof L2MerchantSummonInstance))
|
||||
{
|
||||
activeChar.setPet(summon);
|
||||
}
|
||||
|
||||
// L2World.getInstance().storeObject(summon);
|
||||
summon.spawnMe(activeChar.getX() + 20, activeChar.getY() + 20, activeChar.getZ());
|
||||
}
|
||||
|
||||
public final boolean isCubic()
|
||||
{
|
||||
return _isCubic;
|
||||
}
|
||||
|
||||
public final int getTotalLifeTime()
|
||||
{
|
||||
return _summonTotalLifeTime;
|
||||
}
|
||||
|
||||
public final int getTimeLostIdle()
|
||||
{
|
||||
return _summonTimeLostIdle;
|
||||
}
|
||||
|
||||
public final int getTimeLostActive()
|
||||
{
|
||||
return _summonTimeLostActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the itemConsume count over time.
|
||||
*/
|
||||
public final int getItemConsumeOT()
|
||||
{
|
||||
return _itemConsumeOT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the itemConsumeId over time.
|
||||
*/
|
||||
public final int getItemConsumeIdOT()
|
||||
{
|
||||
return _itemConsumeIdOT;
|
||||
}
|
||||
|
||||
public final int getItemConsumeSteps()
|
||||
{
|
||||
return _itemConsumeSteps;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the itemConsume time in milliseconds.
|
||||
*/
|
||||
public final int getItemConsumeTime()
|
||||
{
|
||||
return _itemConsumeTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.l2skills;
|
||||
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Skill;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.templates.StatsSet;
|
||||
|
||||
/**
|
||||
* @author JIV
|
||||
*/
|
||||
public class L2SkillSweeper extends L2Skill
|
||||
{
|
||||
private final boolean _absorbHp;
|
||||
private final int _absorbAbs;
|
||||
|
||||
/**
|
||||
* @param set
|
||||
*/
|
||||
public L2SkillSweeper(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
_absorbHp = set.getBool("absorbHp", true);
|
||||
_absorbAbs = set.getInteger("absorbAbs", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character caster, L2Object[] targets)
|
||||
{
|
||||
// not used
|
||||
}
|
||||
|
||||
public boolean isAbsorbHp()
|
||||
{
|
||||
return _absorbHp;
|
||||
}
|
||||
|
||||
public int getAbsorbAbs()
|
||||
{
|
||||
return _absorbAbs;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 com.l2jserver.gameserver.skills.l2skills;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.MapRegionTable;
|
||||
import com.l2jserver.gameserver.instancemanager.GrandBossManager;
|
||||
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.model.entity.TvTEvent;
|
||||
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.StatsSet;
|
||||
import com.l2jserver.gameserver.templates.skills.L2SkillType;
|
||||
|
||||
public class L2SkillTeleport extends L2Skill
|
||||
{
|
||||
private final String _recallType;
|
||||
private final Location _loc;
|
||||
|
||||
public L2SkillTeleport(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
|
||||
_recallType = set.getString("recallType", "");
|
||||
String coords = set.getString("teleCoords", null);
|
||||
if (coords != null)
|
||||
{
|
||||
String[] valuesSplit = coords.split(",");
|
||||
_loc = new Location(Integer.parseInt(valuesSplit[0]), Integer.parseInt(valuesSplit[1]), Integer.parseInt(valuesSplit[2]));
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character activeChar, L2Object[] targets)
|
||||
{
|
||||
if (activeChar instanceof L2PcInstance)
|
||||
{
|
||||
// Thanks nbd
|
||||
if (!TvTEvent.onEscapeUse(((L2PcInstance) activeChar).getObjectId()))
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.isAfraid())
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (((L2PcInstance) activeChar).isCombatFlagEquipped())
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (((L2PcInstance) activeChar).isInOlympiadMode())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((GrandBossManager.getInstance().getZone(activeChar) != null) && !activeChar.isGM())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_MAY_NOT_SUMMON_FROM_YOUR_CURRENT_LOCATION));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
for (L2Character target : (L2Character[]) targets)
|
||||
{
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
L2PcInstance targetChar = (L2PcInstance) target;
|
||||
|
||||
// Check to see if the current player target is in a festival.
|
||||
if (targetChar.isFestivalParticipant())
|
||||
{
|
||||
targetChar.sendMessage("You may not use an escape skill in a festival.");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check to see if player is in jail
|
||||
if (targetChar.isInJail())
|
||||
{
|
||||
targetChar.sendMessage("You can not escape from jail.");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check to see if player is in a duel
|
||||
if (targetChar.isInDuel())
|
||||
{
|
||||
targetChar.sendMessage("You cannot use escape skills during a duel.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (targetChar != activeChar)
|
||||
{
|
||||
if (!TvTEvent.onEscapeUse(targetChar.getObjectId()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (targetChar.isInOlympiadMode())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (GrandBossManager.getInstance().getZone(targetChar) != null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (targetChar.isCombatFlagEquipped())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
Location loc = null;
|
||||
if (getSkillType() == L2SkillType.TELEPORT)
|
||||
{
|
||||
if (_loc != null)
|
||||
{
|
||||
// target is not player OR player is not flying or flymounted
|
||||
// TODO: add check for gracia continent coords
|
||||
if (!(target instanceof L2PcInstance) || !(target.isFlying() || ((L2PcInstance) target).isFlyingMounted()))
|
||||
{
|
||||
loc = _loc;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_recallType.equalsIgnoreCase("Castle"))
|
||||
{
|
||||
loc = MapRegionTable.getInstance().getTeleToLocation(target, MapRegionTable.TeleportWhereType.Castle);
|
||||
}
|
||||
else if (_recallType.equalsIgnoreCase("ClanHall"))
|
||||
{
|
||||
loc = MapRegionTable.getInstance().getTeleToLocation(target, MapRegionTable.TeleportWhereType.ClanHall);
|
||||
}
|
||||
else if (_recallType.equalsIgnoreCase("Fortress"))
|
||||
{
|
||||
loc = MapRegionTable.getInstance().getTeleToLocation(target, MapRegionTable.TeleportWhereType.Fortress);
|
||||
}
|
||||
else
|
||||
{
|
||||
loc = MapRegionTable.getInstance().getTeleToLocation(target, MapRegionTable.TeleportWhereType.Town);
|
||||
}
|
||||
}
|
||||
if (loc != null)
|
||||
{
|
||||
target.setInstanceId(0);
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
((L2PcInstance) target).setIsIn7sDungeon(false);
|
||||
}
|
||||
target.teleToLocation(loc, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.l2skills;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.NpcTable;
|
||||
import com.l2jserver.gameserver.datatables.SkillTable;
|
||||
import com.l2jserver.gameserver.idfactory.IdFactory;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Skill;
|
||||
import com.l2jserver.gameserver.model.L2Spawn;
|
||||
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.actor.instance.L2TrapInstance;
|
||||
import com.l2jserver.gameserver.templates.StatsSet;
|
||||
import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;
|
||||
|
||||
public class L2SkillTrap extends L2SkillSummon
|
||||
{
|
||||
private int _triggerSkillId = 0;
|
||||
private int _triggerSkillLvl = 0;
|
||||
private int _trapNpcId = 0;
|
||||
protected L2Spawn _trapSpawn;
|
||||
|
||||
/**
|
||||
* @param set
|
||||
*/
|
||||
public L2SkillTrap(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
_triggerSkillId = set.getInteger("triggerSkillId");
|
||||
_triggerSkillLvl = set.getInteger("triggerSkillLvl");
|
||||
_trapNpcId = set.getInteger("trapNpcId");
|
||||
}
|
||||
|
||||
public int getTriggerSkillId()
|
||||
{
|
||||
return _triggerSkillId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.model.L2Skill#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Object[])
|
||||
*/
|
||||
@Override
|
||||
public void useSkill(L2Character caster, L2Object[] targets)
|
||||
{
|
||||
if (caster.isAlikeDead() || !(caster instanceof L2PcInstance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_trapNpcId == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2PcInstance activeChar = (L2PcInstance) caster;
|
||||
|
||||
if (activeChar.inObserverMode())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.isMounted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_triggerSkillId == 0) || (_triggerSkillLvl == 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2Trap trap = activeChar.getTrap();
|
||||
if (trap != null)
|
||||
{
|
||||
trap.unSummon();
|
||||
}
|
||||
|
||||
L2Skill skill = SkillTable.getInstance().getInfo(_triggerSkillId, _triggerSkillLvl);
|
||||
|
||||
if (skill == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2NpcTemplate TrapTemplate = NpcTable.getInstance().getTemplate(_trapNpcId);
|
||||
trap = new L2TrapInstance(IdFactory.getInstance().getNextId(), TrapTemplate, activeChar, getTotalLifeTime(), skill);
|
||||
trap.setCurrentHp(trap.getMaxHp());
|
||||
trap.setCurrentMp(trap.getMaxMp());
|
||||
trap.setIsInvul(true);
|
||||
trap.setHeading(activeChar.getHeading());
|
||||
activeChar.setTrap(trap);
|
||||
// L2World.getInstance().storeObject(trap);
|
||||
trap.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user