Merged with released L2J-Unity files.
This commit is contained in:
@@ -1,112 +1,125 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.effecthandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
|
||||
import com.l2jmobius.gameserver.handler.TargetHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.StatsSet;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import com.l2jmobius.gameserver.model.events.EventType;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.OnCreatureSkillUse;
|
||||
import com.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* Trigger Skill By Skill effect implementation.
|
||||
* @author Zealar
|
||||
*/
|
||||
public final class TriggerSkillBySkill extends AbstractEffect
|
||||
{
|
||||
private final int _castSkillId;
|
||||
private final int _chance;
|
||||
private final SkillHolder _skill;
|
||||
private final L2TargetType _targetType;
|
||||
private final int AQUAMARINE = 17822;
|
||||
|
||||
/**
|
||||
* @param attachCond
|
||||
* @param applyCond
|
||||
* @param set
|
||||
* @param params
|
||||
*/
|
||||
public TriggerSkillBySkill(Condition attachCond, Condition applyCond, StatsSet set, StatsSet params)
|
||||
{
|
||||
super(attachCond, applyCond, set, params);
|
||||
|
||||
_castSkillId = params.getInt("castSkillId", 0);
|
||||
_chance = params.getInt("chance", 100);
|
||||
_skill = new SkillHolder(params.getInt("skillId", 0), params.getInt("skillLevel", 0));
|
||||
_targetType = params.getEnum("targetType", L2TargetType.class, L2TargetType.ONE);
|
||||
}
|
||||
|
||||
public void onSkillUseEvent(OnCreatureSkillUse event)
|
||||
{
|
||||
if ((_chance == 0) || (_skill.getSkillId() == 0) || (_skill.getSkillLvl() == 0) || ((_castSkillId == 0) && (_skill.getSkillId() != AQUAMARINE)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_castSkillId != event.getSkill().getId()) && (_skill.getSkillId() != AQUAMARINE))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final ITargetTypeHandler targetHandler = TargetHandler.getInstance().getHandler(_targetType);
|
||||
if (targetHandler == null)
|
||||
{
|
||||
_log.warning("Handler for target type: " + _targetType + " does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Rnd.get(100) > _chance)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Skill triggerSkill = _skill.getSkill();
|
||||
for (L2Object triggerTarget : targetHandler.getTargetList(triggerSkill, event.getCaster(), false, event.getTarget()))
|
||||
{
|
||||
if ((triggerTarget == null) || !triggerTarget.isCharacter())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!((L2Character) triggerTarget).isInvul())
|
||||
{
|
||||
event.getCaster().makeTriggerCast(triggerSkill, (L2Character) triggerTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExit(BuffInfo info)
|
||||
{
|
||||
info.getEffected().removeListenerIf(EventType.ON_CREATURE_SKILL_USE, listener -> listener.getOwner() == this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(BuffInfo info)
|
||||
{
|
||||
info.getEffected().addListener(new ConsumerEventListener(info.getEffected(), EventType.ON_CREATURE_SKILL_USE, (OnCreatureSkillUse event) -> onSkillUseEvent(event), this));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.effecthandlers;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
|
||||
import com.l2jmobius.gameserver.handler.TargetHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.StatsSet;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import com.l2jmobius.gameserver.model.events.EventType;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.OnCreatureSkillFinishCast;
|
||||
import com.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.skills.SkillCaster;
|
||||
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
|
||||
|
||||
/**
|
||||
* Trigger Skill By Skill effect implementation.
|
||||
* @author Zealar
|
||||
*/
|
||||
public final class TriggerSkillBySkill extends AbstractEffect
|
||||
{
|
||||
private final int _castSkillId;
|
||||
private final int _chance;
|
||||
private final SkillHolder _skill;
|
||||
private final int _skillLevelScaleTo;
|
||||
private final TargetType _targetType;
|
||||
|
||||
public TriggerSkillBySkill(StatsSet params)
|
||||
{
|
||||
_castSkillId = params.getInt("castSkillId", 0);
|
||||
_chance = params.getInt("chance", 100);
|
||||
_skill = new SkillHolder(params.getInt("skillId", 0), params.getInt("skillLevel", 0));
|
||||
_skillLevelScaleTo = params.getInt("skillLevelScaleTo", 0);
|
||||
_targetType = params.getEnum("targetType", TargetType.class, TargetType.TARGET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(L2Character effector, L2Character effected, Skill skill)
|
||||
{
|
||||
effected.addListener(new ConsumerEventListener(effected, EventType.ON_CREATURE_SKILL_FINISH_CAST, (OnCreatureSkillFinishCast event) -> onSkillUseEvent(event), this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExit(BuffInfo info)
|
||||
{
|
||||
info.getEffected().removeListenerIf(EventType.ON_CREATURE_SKILL_FINISH_CAST, listener -> listener.getOwner() == this);
|
||||
}
|
||||
|
||||
public void onSkillUseEvent(OnCreatureSkillFinishCast event)
|
||||
{
|
||||
if ((_chance == 0) || ((_skill.getSkillId() == 0) || (_skill.getSkillLvl() == 0) || (_castSkillId == 0)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_castSkillId != event.getSkill().getId())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.getTarget().isCharacter())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_chance < 100) && (Rnd.get(100) > _chance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Skill triggerSkill;
|
||||
if (_skillLevelScaleTo <= 0)
|
||||
{
|
||||
triggerSkill = _skill.getSkill();
|
||||
}
|
||||
else
|
||||
{
|
||||
final BuffInfo buffInfo = ((L2Character) event.getTarget()).getEffectList().getBuffInfoBySkillId(_skill.getSkillId());
|
||||
if (buffInfo != null)
|
||||
{
|
||||
triggerSkill = SkillData.getInstance().getSkill(_skill.getSkillId(), Math.min(_skillLevelScaleTo, buffInfo.getSkill().getLevel() + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
triggerSkill = _skill.getSkill();
|
||||
}
|
||||
}
|
||||
|
||||
L2Object target = null;
|
||||
try
|
||||
{
|
||||
target = TargetHandler.getInstance().getHandler(_targetType).getTarget(event.getCaster(), event.getTarget(), triggerSkill, false, false, false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception in ITargetTypeHandler.getTarget(): " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
if ((target != null) && target.isCharacter())
|
||||
{
|
||||
SkillCaster.triggerCast(event.getCaster(), (L2Character) target, triggerSkill);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user