Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Copyright (C) 2004-2015 L2J DataPack
- *
- * This file is part of L2J DataPack.
- *
- * L2J DataPack 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.
- *
- * L2J DataPack 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.ArrayList;
- import java.util.List;
- import java.util.concurrent.ScheduledFuture;
- import com.l2jserver.gameserver.ThreadPoolManager;
- import com.l2jserver.gameserver.datatables.SkillData;
- import com.l2jserver.gameserver.handler.ITargetTypeHandler;
- import com.l2jserver.gameserver.handler.TargetHandler;
- import com.l2jserver.gameserver.model.L2Object;
- import com.l2jserver.gameserver.model.StatsSet;
- import com.l2jserver.gameserver.model.actor.L2Character;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- import com.l2jserver.gameserver.model.conditions.Condition;
- import com.l2jserver.gameserver.model.effects.AbstractEffect;
- import com.l2jserver.gameserver.model.holders.SkillHolder;
- import com.l2jserver.gameserver.model.skills.BuffInfo;
- import com.l2jserver.gameserver.model.skills.Skill;
- import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
- /**
- * Force Skill effect implementation.
- * @author Mobius
- */
- public final class TriggerForce extends AbstractEffect
- {
- private final SkillHolder _skill;
- private final L2TargetType _targetType;
- private ScheduledFuture<?> _partyForceCheckTask = null;
- private List<L2PcInstance> _affectedPlayers = new ArrayList<>();
- private final static int SIGEL_AURA = 1927;
- private final static int TYRR_AURA = 1929;
- private final static int OTHELL_AURA = 1931;
- private final static int YUL_AURA = 1933;
- private final static int FEOH_AURA = 1935;
- private final static int WYNN_AURA = 1937;
- private final static int AEORE_AURA = 1939;
- private final static int SIGEL_FORCE = 1928;
- private final static int TYRR_FORCE = 1930;
- private final static int OTHELL_FORCE = 1932;
- private final static int YUL_FORCE = 1934;
- private final static int FEOH_FORCE = 1936;
- private final static int WYNN_FORCE = 1938;
- private final static int AEORE_FORCE = 1940;
- private final static int PARTY_SOLIDARITY = 1955;
- /**
- * @param attachCond
- * @param applyCond
- * @param set
- * @param params
- */
- public TriggerForce(Condition attachCond, Condition applyCond, StatsSet set, StatsSet params)
- {
- super(attachCond, applyCond, set, params);
- _skill = new SkillHolder(params.getInt("skillId", 0), params.getInt("skillLevel", 0));
- _targetType = params.getEnum("targetType", L2TargetType.class, L2TargetType.ONE);
- }
- @Override
- public void onStart(BuffInfo info)
- {
- final L2PcInstance effector = info.getEffector().getActingPlayer();
- final L2PcInstance effected = info.getEffected().getActingPlayer();
- if (effected.isDead() || (effector == null))
- {
- return;
- }
- if ((_skill.getSkillId() == 0) || (_skill.getSkillLvl() == 0))
- {
- return;
- }
- final ITargetTypeHandler targetHandler = TargetHandler.getInstance().getHandler(_targetType);
- if (targetHandler == null)
- {
- _log.warning("Handler for target type: " + _targetType + " does not exist.");
- return;
- }
- final Skill triggerSkill = _skill.getSkill();
- final L2Object[] targets = targetHandler.getTargetList(triggerSkill, effector, false, effected);
- for (L2Object triggerTarget : targets)
- {
- if ((triggerTarget == null) || !triggerTarget.isCharacter())
- {
- continue;
- }
- final L2Character targetChar = (L2Character) triggerTarget;
- if (!targetChar.isInvul())
- {
- effector.makeTriggerCast(triggerSkill, targetChar);
- }
- }
- if (effector.getParty() != null)
- {
- _affectedPlayers = effector.getParty().getMembers();
- }
- else
- {
- _affectedPlayers.add(effector);
- }
- managePartySolidarity();
- _partyForceCheckTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(() ->
- {
- partyForceCheckTask(effector, triggerSkill);
- }, 1000, 5000);
- }
- @Override
- public void onExit(BuffInfo info)
- {
- final L2PcInstance effected = info.getEffected().getActingPlayer();
- if ((effected.getEffectList().getBuffInfoBySkillId(SIGEL_AURA) == null) && (effected.getEffectList().getBuffInfoBySkillId(SIGEL_FORCE) != null))
- {
- effected.getEffectList().remove(true, effected.getEffectList().getBuffInfoBySkillId(SIGEL_FORCE));
- }
- if ((effected.getEffectList().getBuffInfoBySkillId(TYRR_AURA) == null) && (effected.getEffectList().getBuffInfoBySkillId(TYRR_FORCE) != null))
- {
- effected.getEffectList().remove(true, effected.getEffectList().getBuffInfoBySkillId(TYRR_FORCE));
- }
- if ((effected.getEffectList().getBuffInfoBySkillId(OTHELL_AURA) == null) && (effected.getEffectList().getBuffInfoBySkillId(OTHELL_FORCE) != null))
- {
- effected.getEffectList().remove(true, effected.getEffectList().getBuffInfoBySkillId(OTHELL_FORCE));
- }
- if ((effected.getEffectList().getBuffInfoBySkillId(YUL_AURA) == null) && (effected.getEffectList().getBuffInfoBySkillId(YUL_FORCE) != null))
- {
- effected.getEffectList().remove(true, effected.getEffectList().getBuffInfoBySkillId(YUL_FORCE));
- }
- if ((effected.getEffectList().getBuffInfoBySkillId(FEOH_AURA) == null) && (effected.getEffectList().getBuffInfoBySkillId(FEOH_FORCE) != null))
- {
- effected.getEffectList().remove(true, effected.getEffectList().getBuffInfoBySkillId(FEOH_FORCE));
- }
- if ((effected.getEffectList().getBuffInfoBySkillId(WYNN_AURA) == null) && (effected.getEffectList().getBuffInfoBySkillId(WYNN_FORCE) != null))
- {
- effected.getEffectList().remove(true, effected.getEffectList().getBuffInfoBySkillId(WYNN_FORCE));
- }
- if ((effected.getEffectList().getBuffInfoBySkillId(AEORE_AURA) == null) && (effected.getEffectList().getBuffInfoBySkillId(AEORE_FORCE) != null))
- {
- effected.getEffectList().remove(true, effected.getEffectList().getBuffInfoBySkillId(AEORE_FORCE));
- }
- }
- private void partyForceCheckTask(L2PcInstance effector, Skill triggerSkill)
- {
- if (!_affectedPlayers.contains(effector) || (effector == null) || (effector.getEffectList().getBuffInfoBySkillId(triggerSkill.getId() - 1) == null))
- {
- boolean stillExists = false;
- for (L2PcInstance member : _affectedPlayers)
- {
- if (member == null)
- {
- continue;
- }
- if (member.getEffectList().getBuffInfoBySkillId(triggerSkill.getId() - 1) != null)
- {
- stillExists = true;
- }
- }
- if (!stillExists)
- {
- for (L2PcInstance member : _affectedPlayers)
- {
- if (member == null)
- {
- continue;
- }
- member.getEffectList().remove(true, member.getEffectList().getBuffInfoBySkillId(triggerSkill.getId()));
- }
- managePartySolidarity();
- }
- _partyForceCheckTask.cancel(true);
- return;
- }
- if (effector.getParty() == null)
- {
- for (L2PcInstance member : _affectedPlayers)
- {
- if ((member == null) || (member == effector))
- {
- continue;
- }
- _affectedPlayers.remove(member);
- member.getEffectList().remove(true, member.getEffectList().getBuffInfoBySkillId(triggerSkill.getId()));
- member.getEffectList().remove(true, member.getEffectList().getBuffInfoBySkillId(PARTY_SOLIDARITY));
- }
- }
- else if (effector.getParty().getMembers() != _affectedPlayers)
- {
- for (L2PcInstance member : effector.getParty().getMembers())
- {
- if (!_affectedPlayers.contains(member))
- {
- _affectedPlayers.add(member);
- effector.makeTriggerCast(triggerSkill, member);
- }
- }
- for (L2PcInstance member : _affectedPlayers)
- {
- if ((member == null) || (member == effector))
- {
- continue;
- }
- if (!effector.getParty().getMembers().contains(member))
- {
- _affectedPlayers.remove(member);
- member.getEffectList().remove(true, member.getEffectList().getBuffInfoBySkillId(triggerSkill.getId()));
- member.getEffectList().remove(true, member.getEffectList().getBuffInfoBySkillId(PARTY_SOLIDARITY));
- }
- }
- managePartySolidarity();
- }
- }
- private void managePartySolidarity()
- {
- for (L2PcInstance member : _affectedPlayers)
- {
- int activeForces = 0;
- if (member.getEffectList().getBuffInfoBySkillId(SIGEL_FORCE) != null)
- {
- activeForces++;
- }
- if (member.getEffectList().getBuffInfoBySkillId(TYRR_FORCE) != null)
- {
- activeForces++;
- }
- if (member.getEffectList().getBuffInfoBySkillId(OTHELL_FORCE) != null)
- {
- activeForces++;
- }
- if (member.getEffectList().getBuffInfoBySkillId(YUL_FORCE) != null)
- {
- activeForces++;
- }
- if (member.getEffectList().getBuffInfoBySkillId(FEOH_FORCE) != null)
- {
- activeForces++;
- }
- if (member.getEffectList().getBuffInfoBySkillId(WYNN_FORCE) != null)
- {
- activeForces++;
- }
- if (member.getEffectList().getBuffInfoBySkillId(AEORE_FORCE) != null)
- {
- activeForces++;
- }
- if (activeForces < 4)
- {
- member.getEffectList().remove(true, member.getEffectList().getBuffInfoBySkillId(PARTY_SOLIDARITY));
- }
- if ((activeForces >= 4) && (member.getEffectList().getBuffInfoBySkillId(AEORE_FORCE) != null) && (member.getEffectList().getBuffInfoBySkillId(SIGEL_FORCE) != null))
- {
- member.makeTriggerCast(SkillData.getInstance().getSkill(PARTY_SOLIDARITY, Math.min((activeForces - 3), 3)), member);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement