Merged with released L2J-Unity files.

This commit is contained in:
mobiusdev
2016-06-12 01:34:09 +00:00
parent e003e87887
commit 635557f5da
18352 changed files with 3245113 additions and 2892959 deletions

View File

@@ -0,0 +1,58 @@
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Target Outpost npc (36590).
* @author Nik
*/
public class AdvanceBase implements ITargetTypeHandler
{
@Override
public Enum<TargetType> getTargetType()
{
return TargetType.ADVANCE_BASE;
}
@Override
public L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage)
{
final L2Object target = activeChar.getTarget();
if ((target != null) && target.isNpc() && (target.getId() == 36590))
{
if (!((L2Npc) target).isDead())
{
return target;
}
}
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
}
return null;
}
}

View File

@@ -1,106 +0,0 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class Area implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final List<L2Character> targetList = new ArrayList<>();
if ((target == null) || (((target == activeChar) || target.isAlikeDead()) && (skill.getCastRange() >= 0)) || (!target.isAttackable() && !target.isPlayable()))
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return EMPTY_TARGET_LIST;
}
final L2Character origin;
final boolean srcInArena = activeChar.isInsideZone(ZoneId.PVP) && !activeChar.isInsideZone(ZoneId.SIEGE);
if (skill.getCastRange() >= 0)
{
if (!Skill.checkForAreaOffensiveSkills(activeChar, target, skill, srcInArena))
{
return EMPTY_TARGET_LIST;
}
if (onlyFirst)
{
return new L2Character[]
{
target
};
}
origin = target;
targetList.add(origin); // Add target to target list
}
else
{
origin = activeChar;
}
final int maxTargets = skill.getAffectLimit();
final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharacters();
for (L2Character obj : objs)
{
if ((!obj.isAttackable() && !obj.isPlayable()) || (obj == origin))
{
continue;
}
if (Util.checkIfInRange(skill.getAffectRange(), origin, obj, true))
{
if (!Skill.checkForAreaOffensiveSkills(activeChar, obj, skill, srcInArena))
{
continue;
}
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
}
targetList.add(obj);
}
}
return targetList.isEmpty() ? EMPTY_TARGET_LIST : targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.AREA;
}
}

View File

@@ -1,82 +0,0 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class AreaCorpseMob implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
if ((target == null) || !target.isAttackable() || !target.isDead())
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return EMPTY_TARGET_LIST;
}
if (onlyFirst)
{
return new L2Character[]
{
target
};
}
final List<L2Character> targetList = new ArrayList<>();
targetList.add(target);
final boolean srcInArena = activeChar.isInsideZone(ZoneId.PVP) && !activeChar.isInsideZone(ZoneId.SIEGE);
final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharacters();
for (L2Character obj : objs)
{
if ((!obj.isAttackable() && !obj.isPlayable()) || !Util.checkIfInRange(skill.getAffectRange(), target, obj, true))
{
continue;
}
if (!Skill.checkForAreaOffensiveSkills(activeChar, obj, skill, srcInArena))
{
continue;
}
targetList.add(obj);
}
return targetList.isEmpty() ? EMPTY_TARGET_LIST : targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.AREA_CORPSE_MOB;
}
}

View File

@@ -1,179 +0,0 @@
/*
* 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.targethandlers;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2SiegeFlagInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Area Friendly target handler implementation.
* @author Adry_85, Zoey76
*/
public class AreaFriendly implements ITargetTypeHandler
{
private static final CharComparator CHAR_COMPARATOR = new CharComparator();
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final L2PcInstance player = activeChar.getActingPlayer();
if (!checkTarget(player, target) && (skill.getCastRange() >= 0))
{
player.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return EMPTY_TARGET_LIST;
}
if (onlyFirst)
{
return new L2Character[]
{
target
};
}
if (player.getActingPlayer().isInOlympiadMode())
{
return new L2Character[]
{
player
};
}
final List<L2Character> targetList = new LinkedList<>();
if (target != null)
{
// Add target to target list.
targetList.add(target);
final int maxTargets = skill.getAffectLimit();
for (L2Character obj : target.getKnownList().getKnownCharactersInRadius(skill.getAffectRange()))
{
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
}
if (!checkTarget(player, obj) || (obj == activeChar))
{
continue;
}
targetList.add(obj);
}
// Sort creatures, the most injured first.
Collections.sort(targetList, CHAR_COMPARATOR);
}
return targetList.isEmpty() ? EMPTY_TARGET_LIST : targetList.toArray(new L2Character[targetList.size()]);
}
private boolean checkTarget(L2PcInstance activeChar, L2Character target)
{
if (!GeoData.getInstance().canSeeTarget(activeChar, target))
{
return false;
}
if ((target == null) || target.isAlikeDead() || target.isDoor() || (target instanceof L2SiegeFlagInstance) || target.isMonster())
{
return false;
}
// GMs and hidden creatures.
if (target.isInvisible())
{
return false;
}
if (target.isPlayable())
{
final L2PcInstance targetPlayer = target.getActingPlayer();
if (activeChar == targetPlayer)
{
return true;
}
if (targetPlayer.inObserverMode() || targetPlayer.isInOlympiadMode())
{
return false;
}
if (activeChar.isInDuelWith(target))
{
return false;
}
if (activeChar.isInPartyWith(target))
{
return true;
}
// Only siege allies.
if (activeChar.isInSiege() && !activeChar.isOnSameSiegeSideWith(targetPlayer))
{
return false;
}
if (target.isInsideZone(ZoneId.PVP))
{
return false;
}
if (activeChar.isInClanWith(target) || activeChar.isInAllyWith(target) || activeChar.isInCommandChannelWith(target))
{
return true;
}
if ((targetPlayer.getPvpFlag() > 0) || (targetPlayer.getReputation() < 0))
{
return false;
}
}
return true;
}
static class CharComparator implements Comparator<L2Character>
{
@Override
public int compare(L2Character char1, L2Character char2)
{
return Double.compare(char1.getCurrentHp() / char1.getMaxHp(), char2.getCurrentHp() / char2.getMaxHp());
}
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.AREA_FRIENDLY;
}
}

View File

@@ -1,95 +0,0 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class AreaSummon implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final List<L2Character> targetList = new ArrayList<>();
if ((target == null) || !target.isServitor() || target.isDead())
{
return EMPTY_TARGET_LIST;
}
if (onlyFirst && activeChar.hasSummon())
{
return new L2Character[]
{
activeChar.getServitors().values().stream().findFirst().orElse(activeChar.getPet())
};
}
final boolean srcInArena = activeChar.isInsideZone(ZoneId.PVP) && !activeChar.isInsideZone(ZoneId.SIEGE);
final Collection<L2Character> objs = target.getKnownList().getKnownCharacters();
final int maxTargets = skill.getAffectLimit();
for (L2Character obj : objs)
{
if ((obj == null) || (obj == target) || (obj == activeChar))
{
continue;
}
if (!Util.checkIfInRange(skill.getAffectRange(), target, obj, true))
{
continue;
}
if (!obj.isAttackable() && !obj.isPlayable())
{
continue;
}
if (!Skill.checkForAreaOffensiveSkills(activeChar, obj, skill, srcInArena))
{
continue;
}
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
}
targetList.add(obj);
}
return targetList.isEmpty() ? EMPTY_TARGET_LIST : targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.AREA_SUMMON;
}
}

View File

@@ -1,54 +1,59 @@
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* @author UnAfraid
*/
public class PartyMember implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
if (target == null)
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return EMPTY_TARGET_LIST;
}
if (!target.isDead() && ((target == activeChar) || (activeChar.isInParty() && target.isInParty() && (activeChar.getParty().getLeaderObjectId() == target.getParty().getLeaderObjectId())) || (activeChar.isPlayer() && target.isSummon() && ((activeChar.getPet() == target) || activeChar.hasServitor(target.getObjectId()))) || (activeChar.isSummon() && target.isPlayer() && ((activeChar == target.getPet()) || target.hasServitor(activeChar.getObjectId())))))
{
return new L2Character[]
{
target
};
}
return EMPTY_TARGET_LIST;
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.PARTY_MEMBER;
}
}
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Target siege doors and walls.
* @author Nik
*/
public class Artillery implements ITargetTypeHandler
{
@Override
public Enum<TargetType> getTargetType()
{
return TargetType.ARTILLERY;
}
@Override
public L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage)
{
final L2Object target = activeChar.getTarget();
if ((target != null) && target.isDoor())
{
final L2DoorInstance targetDoor = (L2DoorInstance) target;
if (!targetDoor.isDead() && targetDoor.isAutoAttackable(activeChar) && targetDoor.isEnemy())
{
return targetDoor;
}
}
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
}
return null;
}
}

View File

@@ -1,80 +0,0 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
/**
* Aura target handler.
* @author UnAfraid
*/
public class Aura implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final List<L2Character> targetList = new ArrayList<>();
final boolean srcInArena = activeChar.isInsideZone(ZoneId.PVP) && !activeChar.isInsideZone(ZoneId.SIEGE);
for (L2Character obj : activeChar.getKnownList().getKnownCharactersInRadius(skill.getAffectRange()))
{
if (obj.isDoor() || obj.isAttackable() || obj.isPlayable())
{
// Stealth door targeting.
if (obj.isDoor() && !((L2DoorInstance) obj).getTemplate().isStealth())
{
continue;
}
if (!Skill.checkForAreaOffensiveSkills(activeChar, obj, skill, srcInArena))
{
continue;
}
if (activeChar.isPlayable() && obj.isAttackable() && !skill.isBad())
{
continue;
}
if (onlyFirst)
{
return new L2Character[]
{
obj
};
}
targetList.add(obj);
}
}
return targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.AURA;
}
}

View File

@@ -1,69 +0,0 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
/**
* @author UnAfraid
*/
public class AuraCorpseMob implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final List<L2Character> targetList = new ArrayList<>();
// Go through the L2Character _knownList
final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharactersInRadius(skill.getAffectRange());
final int maxTargets = skill.getAffectLimit();
for (L2Character obj : objs)
{
if (obj.isAttackable() && obj.isDead())
{
if (onlyFirst)
{
return new L2Character[]
{
obj
};
}
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
}
targetList.add(obj);
}
}
return targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.AURA_CORPSE_MOB;
}
}

View File

@@ -1,111 +0,0 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2SiegeFlagInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
/**
* @author Sahar
*/
public class AuraFriendly implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final List<L2Character> targetList = new ArrayList<>();
final L2PcInstance player = activeChar.getActingPlayer();
final int maxTargets = skill.getAffectLimit();
for (L2Character obj : player.getKnownList().getKnownCharactersInRadius(skill.getAffectRange()))
{
if ((obj == activeChar) || !checkTarget(player, obj))
{
continue;
}
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
}
targetList.add(obj);
}
return targetList.isEmpty() ? EMPTY_TARGET_LIST : targetList.toArray(new L2Character[targetList.size()]);
}
private boolean checkTarget(L2PcInstance activeChar, L2Character target)
{
if (!GeoData.getInstance().canSeeTarget(activeChar, target))
{
return false;
}
if ((target == null) || target.isAlikeDead() || target.isDoor() || (target instanceof L2SiegeFlagInstance) || target.isMonster())
{
return false;
}
if (target.isPlayable())
{
final L2PcInstance targetPlayer = target.getActingPlayer();
if (activeChar.isInDuelWith(target))
{
return false;
}
if (activeChar.isInPartyWith(target))
{
return true;
}
if (target.isInsideZone(ZoneId.PVP))
{
return false;
}
if (activeChar.isInClanWith(target) || activeChar.isInAllyWith(target) || activeChar.isInCommandChannelWith(target))
{
return true;
}
if ((targetPlayer.getPvpFlag() > 0) || (targetPlayer.getReputation() < 0))
{
return false;
}
}
return true;
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.AURA_FRIENDLY;
}
}

View File

@@ -1,116 +0,0 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class BehindArea implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final List<L2Character> targetList = new ArrayList<>();
if ((target == null) || (((target == activeChar) || target.isAlikeDead()) && (skill.getCastRange() >= 0)) || (!target.isAttackable() && !target.isPlayable()))
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return EMPTY_TARGET_LIST;
}
final L2Character origin;
final boolean srcInArena = activeChar.isInsideZone(ZoneId.PVP) && !activeChar.isInsideZone(ZoneId.SIEGE);
if (skill.getCastRange() >= 0)
{
if (!Skill.checkForAreaOffensiveSkills(activeChar, target, skill, srcInArena))
{
return EMPTY_TARGET_LIST;
}
if (onlyFirst)
{
return new L2Character[]
{
target
};
}
origin = target;
targetList.add(origin); // Add target to target list
}
else
{
origin = activeChar;
}
final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharacters();
final int maxTargets = skill.getAffectLimit();
for (L2Character obj : objs)
{
if (!obj.isAttackable() && !obj.isPlayable())
{
continue;
}
if (obj == origin)
{
continue;
}
if (Util.checkIfInRange(skill.getAffectRange(), origin, obj, true))
{
if (!obj.isBehind(activeChar))
{
continue;
}
if (!Skill.checkForAreaOffensiveSkills(activeChar, obj, skill, srcInArena))
{
continue;
}
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
}
targetList.add(obj);
}
}
return targetList.isEmpty() ? EMPTY_TARGET_LIST : targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.BEHIND_AREA;
}
}

View File

@@ -1,80 +0,0 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
/**
* @author UnAfraid
*/
public class BehindAura implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final List<L2Character> targetList = new ArrayList<>();
final boolean srcInArena = activeChar.isInsideZone(ZoneId.PVP) && !activeChar.isInsideZone(ZoneId.SIEGE);
final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharactersInRadius(skill.getAffectRange());
final int maxTargets = skill.getAffectLimit();
for (L2Character obj : objs)
{
if (obj.isAttackable() || obj.isPlayable())
{
if (!obj.isBehind(activeChar))
{
continue;
}
if (!Skill.checkForAreaOffensiveSkills(activeChar, obj, skill, srcInArena))
{
continue;
}
if (onlyFirst)
{
return new L2Character[]
{
obj
};
}
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
}
targetList.add(obj);
}
}
return targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.BEHIND_AURA;
}
}

View File

@@ -1,196 +0,0 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.L2ClanMember;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.TvTEvent;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class Clan implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final List<L2Character> targetList = new ArrayList<>();
if (activeChar.isPlayable())
{
final L2PcInstance player = activeChar.getActingPlayer();
if (player == null)
{
return EMPTY_TARGET_LIST;
}
if (player.isInOlympiadMode())
{
return new L2Character[]
{
player
};
}
if (onlyFirst)
{
return new L2Character[]
{
player
};
}
targetList.add(player);
final int radius = skill.getAffectRange();
final L2Clan clan = player.getClan();
if (Skill.addPet(activeChar, player, radius, false))
{
targetList.add(player.getPet());
}
player.getServitors().values().forEach(s ->
{
if (Skill.addCharacter(activeChar, s, radius, false))
{
targetList.add(s);
}
});
if (clan != null)
{
L2PcInstance obj;
for (L2ClanMember member : clan.getMembers())
{
obj = member.getPlayerInstance();
if ((obj == null) || (obj == player))
{
continue;
}
if (player.isInDuel())
{
if (player.getDuelId() != obj.getDuelId())
{
continue;
}
if (player.isInParty() && obj.isInParty() && (player.getParty().getLeaderObjectId() != obj.getParty().getLeaderObjectId()))
{
continue;
}
}
// Don't add this target if this is a Pc->Pc pvp casting and pvp condition not met
if (!player.checkPvpSkill(obj, skill))
{
continue;
}
if (!TvTEvent.checkForTvTSkill(player, obj, skill))
{
continue;
}
if (Skill.addPet(activeChar, obj, radius, false))
{
targetList.add(obj.getPet());
}
obj.getServitors().values().forEach(s ->
{
if (Skill.addCharacter(activeChar, s, radius, false))
{
targetList.add(s);
}
});
if (!Skill.addCharacter(activeChar, obj, radius, false))
{
continue;
}
if (onlyFirst)
{
return new L2Character[]
{
obj
};
}
targetList.add(obj);
}
}
}
else if (activeChar.isNpc())
{
// for buff purposes, returns friendly mobs nearby and mob itself
final L2Npc npc = (L2Npc) activeChar;
if ((npc.getTemplate().getClans() == null) || npc.getTemplate().getClans().isEmpty())
{
return new L2Character[]
{
activeChar
};
}
targetList.add(activeChar);
final Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
final int maxTargets = skill.getAffectLimit();
for (L2Object newTarget : objs)
{
if (newTarget.isNpc() && npc.isInMyClan((L2Npc) newTarget))
{
if (!Util.checkIfInRange(skill.getCastRange(), activeChar, newTarget, true))
{
continue;
}
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
}
targetList.add((L2Npc) newTarget);
}
}
}
return targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.CLAN;
}
}

View File

@@ -1,85 +0,0 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class ClanMember implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final List<L2Character> targetList = new ArrayList<>();
if (activeChar.isNpc())
{
// for buff purposes, returns friendly mobs nearby and mob itself
final L2Npc npc = (L2Npc) activeChar;
if ((npc.getTemplate().getClans() == null) || npc.getTemplate().getClans().isEmpty())
{
return new L2Character[]
{
activeChar
};
}
final Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
for (L2Object newTarget : objs)
{
if (newTarget.isNpc() && npc.isInMyClan((L2Npc) newTarget))
{
if (!Util.checkIfInRange(skill.getCastRange(), activeChar, newTarget, true))
{
continue;
}
if (((L2Npc) newTarget).isAffectedBySkill(skill.getId()))
{
continue;
}
targetList.add((L2Npc) newTarget);
break;
}
}
if (targetList.isEmpty())
{
targetList.add(npc);
}
}
else
{
return EMPTY_TARGET_LIST;
}
return targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.CLAN_MEMBER;
}
}

View File

@@ -1,99 +0,0 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
/**
* @author UnAfraid
*/
public class CommandChannel implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final List<L2Character> targetList = new ArrayList<>();
final L2PcInstance player = activeChar.getActingPlayer();
if (player == null)
{
return EMPTY_TARGET_LIST;
}
targetList.add(player);
final int radius = skill.getAffectRange();
final L2Party party = player.getParty();
final boolean hasChannel = (party != null) && party.isInCommandChannel();
if (Skill.addPet(activeChar, player, radius, false))
{
targetList.add(player.getPet());
}
player.getServitors().values().forEach(s ->
{
if (Skill.addCharacter(activeChar, s, radius, false))
{
targetList.add(s);
}
});
// if player in not in party
if (party == null)
{
return targetList.toArray(new L2Character[targetList.size()]);
}
// Get all visible objects in a spherical area near the L2Character
final int maxTargets = skill.getAffectLimit();
final List<L2PcInstance> members = hasChannel ? party.getCommandChannel().getMembers() : party.getMembers();
for (L2PcInstance member : members)
{
if (activeChar == member)
{
continue;
}
if (Skill.addCharacter(activeChar, member, radius, false))
{
targetList.add(member);
if (targetList.size() >= maxTargets)
{
break;
}
}
}
return targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.COMMAND_CHANNEL;
}
}

View File

@@ -1,168 +0,0 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.L2ClanMember;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.TvTEvent;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class CorpseClan implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final List<L2Object> targetList = new ArrayList<>();
if (activeChar.isPlayable())
{
final L2PcInstance player = activeChar.getActingPlayer();
if (player == null)
{
return EMPTY_TARGET_LIST;
}
if (player.isInOlympiadMode())
{
return new L2Object[]
{
player
};
}
final L2Clan clan = player.getClan();
if (clan != null)
{
final int radius = skill.getAffectRange();
final int maxTargets = skill.getAffectLimit();
for (L2ClanMember member : clan.getMembers())
{
final L2PcInstance obj = member.getPlayerInstance();
if ((obj == null) || (obj == player))
{
continue;
}
if (player.isInDuel())
{
if (player.getDuelId() != obj.getDuelId())
{
continue;
}
if (player.isInParty() && obj.isInParty() && (player.getParty().getLeaderObjectId() != obj.getParty().getLeaderObjectId()))
{
continue;
}
}
// Don't add this target if this is a Pc->Pc pvp casting and pvp condition not met
if (!player.checkPvpSkill(obj, skill))
{
continue;
}
if (!TvTEvent.checkForTvTSkill(player, obj, skill))
{
continue;
}
if (!Skill.addCharacter(activeChar, obj, radius, true))
{
continue;
}
// check target is not in a active siege zone
if (obj.isInsideZone(ZoneId.SIEGE) && !obj.isInSiege())
{
continue;
}
if (onlyFirst)
{
return new L2Object[]
{
obj
};
}
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
}
targetList.add(obj);
}
}
}
else if (activeChar.isNpc())
{
// for buff purposes, returns friendly mobs nearby and mob itself
final L2Npc npc = (L2Npc) activeChar;
if ((npc.getTemplate().getClans() == null) || npc.getTemplate().getClans().isEmpty())
{
return new L2Object[]
{
activeChar
};
}
targetList.add(activeChar);
final Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
final int maxTargets = skill.getAffectLimit();
for (L2Object newTarget : objs)
{
if (newTarget.isNpc() && npc.isInMyClan((L2Npc) newTarget))
{
if (!Util.checkIfInRange(skill.getCastRange(), activeChar, newTarget, true))
{
continue;
}
if (targetList.size() >= maxTargets)
{
break;
}
targetList.add(newTarget);
}
}
}
return targetList.toArray(new L2Object[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.CORPSE_CLAN;
}
}

View File

@@ -1,53 +1,55 @@
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* @author UnAfraid
*/
public class One implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
// Check for null target or any other invalid target
if ((target == null) || target.isDead() || ((target == activeChar) && skill.isBad()))
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return EMPTY_TARGET_LIST;
}
// If a target is found, return it in a table else send a system message TARGET_IS_INCORRECT
return new L2Character[]
{
target
};
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.ONE;
}
}
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2ChestInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Target door or treasure chest.
* @author UnAfraid
*/
public class DoorTreasure implements ITargetTypeHandler
{
@Override
public Enum<TargetType> getTargetType()
{
return TargetType.DOOR_TREASURE;
}
@Override
public L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage)
{
final L2Object target = activeChar.getTarget();
if ((target != null) && (target.isDoor() || (target instanceof L2ChestInstance)))
{
return target;
}
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
}
return null;
}
}

View File

@@ -0,0 +1,151 @@
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Target enemy or ally if force attacking.
* @author Nik
*/
public class Enemy implements ITargetTypeHandler
{
@Override
public Enum<TargetType> getTargetType()
{
return TargetType.ENEMY;
}
@Override
public L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage)
{
if (selectedTarget == null)
{
return null;
}
if (!selectedTarget.isCharacter())
{
return null;
}
final L2Character target = (L2Character) selectedTarget;
// You cannot attack yourself even with force.
if (activeChar == target)
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
return null;
}
// You cannot attack dead targets.
if (target.isDead())
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
return null;
}
// Doors do not care about force attack.
if (target.isDoor() && !target.isAutoAttackable(activeChar))
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
return null;
}
// Monsters can attack/be attacked anywhere. Players can attack creatures that aren't autoattackable with force attack.
if (target.isAutoAttackable(activeChar) || forceUse)
{
// Check for cast range if character cannot move. TODO: char will start follow until within castrange, but if his moving is blocked by geodata, this msg will be sent.
if (dontMove)
{
if (activeChar.calculateDistance(target, false, false) > skill.getCastRange())
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.THE_DISTANCE_IS_TOO_FAR_AND_SO_THE_CASTING_HAS_BEEN_STOPPED);
}
return null;
}
}
// Geodata check when character is within range.
if (!GeoData.getInstance().canSeeTarget(activeChar, target))
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.CANNOT_SEE_TARGET);
}
return null;
}
// Skills with this target type cannot be used by playables on playables in peace zone, but can be used by and on NPCs.
if (target.isInsidePeaceZone(activeChar))
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.A_MALICIOUS_SKILL_CANNOT_BE_USED_IN_A_PEACE_ZONE);
}
return null;
}
// Is this check still actual?
if (forceUse && (target.getActingPlayer() != null) && (activeChar.getActingPlayer() != null))
{
if ((activeChar.getActingPlayer().getSiegeState() > 0) && activeChar.isInsideZone(ZoneId.SIEGE) && (target.getActingPlayer().getSiegeState() == activeChar.getActingPlayer().getSiegeState()) && (target.getActingPlayer() != activeChar.getActingPlayer()) && (target.getActingPlayer().getSiegeSide() == activeChar.getActingPlayer().getSiegeSide()))
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.FORCE_ATTACK_IS_IMPOSSIBLE_AGAINST_A_TEMPORARY_ALLIED_MEMBER_DURING_A_SIEGE);
}
return null;
}
}
return target;
}
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
return null;
}
}

View File

@@ -0,0 +1,107 @@
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.FlyToLocation.FlyType;
/**
* Any friendly selected target. Works on dead targets or doors as well. Unable to force use.
* @author Nik
*/
public class EnemyNot implements ITargetTypeHandler
{
@Override
public Enum<TargetType> getTargetType()
{
return TargetType.ENEMY_NOT;
}
@Override
public L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage)
{
if (selectedTarget == null)
{
return null;
}
if (!selectedTarget.isCharacter())
{
return null;
}
final L2Character target = (L2Character) selectedTarget;
// You can always target yourself.
if (activeChar == target)
{
return target;
}
if (!target.isAutoAttackable(activeChar))
{
// Check for cast range if character cannot move. TODO: char will start follow until within castrange, but if his moving is blocked by geodata, this msg will be sent.
if (dontMove)
{
if (activeChar.calculateDistance(target, false, false) > skill.getCastRange())
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.THE_DISTANCE_IS_TOO_FAR_AND_SO_THE_CASTING_HAS_BEEN_STOPPED);
}
return null;
}
}
if ((skill.getFlyType() == FlyType.CHARGE) && !GeoData.getInstance().canMove(activeChar, target))
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.THE_TARGET_IS_LOCATED_WHERE_YOU_CANNOT_CHARGE);
}
return null;
}
// Geodata check when character is within range.
if (!GeoData.getInstance().canSeeTarget(activeChar, target))
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.CANNOT_SEE_TARGET);
}
return null;
}
return target;
}
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
return null;
}
}

View File

@@ -0,0 +1,151 @@
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Target only enemy no matter if force attacking or not.
* @author Nik
*/
public class EnemyOnly implements ITargetTypeHandler
{
@Override
public Enum<TargetType> getTargetType()
{
return TargetType.ENEMY_ONLY;
}
@Override
public L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage)
{
if (selectedTarget == null)
{
return null;
}
if (!selectedTarget.isCharacter())
{
return null;
}
final L2Character target = (L2Character) selectedTarget;
// You cannot attack yourself even with force.
if (activeChar == target)
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
return null;
}
// You cannot attack dead targets.
if (target.isDead())
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
return null;
}
// Doors do not care about force attack.
if (target.isDoor() && !target.isAutoAttackable(activeChar))
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
return null;
}
// Monsters can attack/be attacked anywhere. Players can attack creatures that aren't autoattackable with force attack.
if (target.isAutoAttackable(activeChar))
{
// Check for cast range if character cannot move. TODO: char will start follow until within castrange, but if his moving is blocked by geodata, this msg will be sent.
if (dontMove)
{
if (activeChar.calculateDistance(target, false, false) > skill.getCastRange())
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.THE_DISTANCE_IS_TOO_FAR_AND_SO_THE_CASTING_HAS_BEEN_STOPPED);
}
return null;
}
}
// Geodata check when character is within range.
if (!GeoData.getInstance().canSeeTarget(activeChar, target))
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.CANNOT_SEE_TARGET);
}
return null;
}
// Skills with this target type cannot be used by playables on playables in peace zone, but can be used by and on NPCs.
if (target.isInsidePeaceZone(activeChar))
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.A_MALICIOUS_SKILL_CANNOT_BE_USED_IN_A_PEACE_ZONE);
}
return null;
}
// Is this check still actual?
if ((target.getActingPlayer() != null) && (activeChar.getActingPlayer() != null))
{
if ((activeChar.getActingPlayer().getSiegeState() > 0) && activeChar.isInsideZone(ZoneId.SIEGE) && (target.getActingPlayer().getSiegeState() == activeChar.getActingPlayer().getSiegeState()) && (target.getActingPlayer() != activeChar.getActingPlayer()) && (target.getActingPlayer().getSiegeSide() == activeChar.getActingPlayer().getSiegeSide()))
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.FORCE_ATTACK_IS_IMPOSSIBLE_AGAINST_A_TEMPORARY_ALLIED_MEMBER_DURING_A_SIEGE);
}
return null;
}
}
return target;
}
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
return null;
}
}

View File

@@ -1,55 +0,0 @@
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
/**
* Enemy Summon target handler implementation.
* @author UnAfraid
*/
public class EnemySummon implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
if ((target != null) && target.isSummon())
{
final L2Summon targetSummon = (L2Summon) target;
if ((activeChar.isPlayer() && (activeChar.getPet() != targetSummon) && activeChar.hasServitor(targetSummon.getObjectId()) && !targetSummon.isDead() && ((targetSummon.getOwner().getPvpFlag() != 0) || (targetSummon.getOwner().getReputation() < 0))) || (targetSummon.getOwner().isInsideZone(ZoneId.PVP) && activeChar.getActingPlayer().isInsideZone(ZoneId.PVP)) || (targetSummon.getOwner().isInDuel() && activeChar.getActingPlayer().isInDuel() && (targetSummon.getOwner().getDuelId() == activeChar.getActingPlayer().getDuelId())))
{
return new L2Character[]
{
targetSummon
};
}
}
return EMPTY_TARGET_LIST;
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.ENEMY_SUMMON;
}
}

View File

@@ -1,65 +1,78 @@
/*
* 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.targethandlers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.effects.L2EffectType;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Corpse Mob target handler.
* @author UnAfraid, Zoey76
*/
public class CorpseMob implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
if ((target == null) || !target.isAttackable() || !target.isDead())
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return EMPTY_TARGET_LIST;
}
if (skill.hasEffectType(L2EffectType.SUMMON) && target.isServitor() && (target.getActingPlayer() != null) && (target.getActingPlayer().getObjectId() == activeChar.getObjectId()))
{
return EMPTY_TARGET_LIST;
}
if (skill.hasEffectType(L2EffectType.HP_DRAIN) && ((L2Attackable) target).isOldCorpse(activeChar.getActingPlayer(), Config.CORPSE_CONSUME_SKILL_ALLOWED_TIME_BEFORE_DECAY, true))
{
return EMPTY_TARGET_LIST;
}
return new L2Character[]
{
target
};
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.CORPSE_MOB;
}
}
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Target fortress flagpole
* @author Nik
*/
public class FortressFlagpole implements ITargetTypeHandler
{
@Override
public Enum<TargetType> getTargetType()
{
return TargetType.FORTRESS_FLAGPOLE;
}
@Override
public L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage)
{
final L2Object target = activeChar.getTarget();
if (target != null)
{
switch (target.getId())
{
case 35657:
case 35688:
case 35726:
case 35757:
case 35795:
case 35826:
case 35857:
case 35895:
case 35926:
case 35964:
case 35002:
case 36033:
case 36071:
case 36109:
case 36140:
case 36171:
case 36209:
case 36247:
case 36285:
case 36316:
case 36354:
return target;
}
}
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
}
return null;
}
}

View File

@@ -1,116 +0,0 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class FrontArea implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final List<L2Character> targetList = new ArrayList<>();
if ((target == null) || (((target == activeChar) || target.isAlikeDead()) && (skill.getCastRange() >= 0)) || (!target.isAttackable() && !target.isPlayable()))
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return EMPTY_TARGET_LIST;
}
final L2Character origin;
final boolean srcInArena = activeChar.isInsideZone(ZoneId.PVP) && !activeChar.isInsideZone(ZoneId.SIEGE);
if (skill.getCastRange() >= 0)
{
if (!Skill.checkForAreaOffensiveSkills(activeChar, target, skill, srcInArena))
{
return EMPTY_TARGET_LIST;
}
if (onlyFirst)
{
return new L2Character[]
{
target
};
}
origin = target;
targetList.add(origin); // Add target to target list
}
else
{
origin = activeChar;
}
final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharacters();
final int maxTargets = skill.getAffectLimit();
for (L2Character obj : objs)
{
if (!obj.isAttackable() && !obj.isPlayable())
{
continue;
}
if (obj == origin)
{
continue;
}
if (Util.checkIfInRange(skill.getAffectRange(), origin, obj, true))
{
if (!obj.isInFrontOf(activeChar))
{
continue;
}
if (!Skill.checkForAreaOffensiveSkills(activeChar, obj, skill, srcInArena))
{
continue;
}
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
}
targetList.add(obj);
}
}
return targetList.isEmpty() ? EMPTY_TARGET_LIST : targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.FRONT_AREA;
}
}

View File

@@ -1,80 +0,0 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
/**
* @author UnAfraid
*/
public class FrontAura implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final List<L2Character> targetList = new ArrayList<>();
final boolean srcInArena = activeChar.isInsideZone(ZoneId.PVP) && !activeChar.isInsideZone(ZoneId.SIEGE);
final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharactersInRadius(skill.getAffectRange());
final int maxTargets = skill.getAffectLimit();
for (L2Character obj : objs)
{
if (obj.isAttackable() || obj.isPlayable())
{
if (!obj.isInFrontOf(activeChar))
{
continue;
}
if (!Skill.checkForAreaOffensiveSkills(activeChar, obj, skill, srcInArena))
{
continue;
}
if (onlyFirst)
{
return new L2Character[]
{
obj
};
}
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
}
targetList.add(obj);
}
}
return targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.FRONT_AURA;
}
}

View File

@@ -1,78 +1,80 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.effects.L2EffectType;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
/**
* @author St3eT
*/
public class Ground implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final List<L2Character> targetList = new ArrayList<>();
final L2PcInstance player = (L2PcInstance) activeChar;
final int maxTargets = skill.getAffectLimit();
final boolean srcInArena = activeChar.isInsideZone(ZoneId.PVP) && !activeChar.isInsideZone(ZoneId.SIEGE);
for (L2Character character : activeChar.getKnownList().getKnownCharacters())
{
if ((character != null) && character.isInsideRadius(player.getCurrentSkillWorldPosition(), skill.getAffectRange(), false, false))
{
if (!Skill.checkForAreaOffensiveSkills(activeChar, character, skill, srcInArena))
{
continue;
}
if (character.isDoor())
{
continue;
}
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
}
targetList.add(character);
}
}
if (targetList.isEmpty() && skill.hasEffectType(L2EffectType.SUMMON_NPC))
{
targetList.add(activeChar);
}
return targetList.isEmpty() ? EMPTY_TARGET_LIST : targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.GROUND;
}
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneRegion;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Target ground location. Returns yourself if your current skill's ground location meets the conditions.
* @author Nik
*/
public class Ground implements ITargetTypeHandler
{
@Override
public Enum<TargetType> getTargetType()
{
return TargetType.GROUND;
}
@Override
public L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage)
{
if (activeChar.isPlayer())
{
final Location worldPosition = activeChar.getActingPlayer().getCurrentSkillWorldPosition();
if (worldPosition != null)
{
if (dontMove && !activeChar.isInsideRadius(worldPosition.getX(), worldPosition.getY(), worldPosition.getZ(), skill.getCastRange() + activeChar.getTemplate().getCollisionRadius(), false, false))
{
return null;
}
if (!GeoData.getInstance().canSeeTarget(activeChar, worldPosition))
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.CANNOT_SEE_TARGET);
}
return null;
}
final ZoneRegion zoneRegion = ZoneManager.getInstance().getRegion(activeChar);
if (skill.isBad() && !zoneRegion.checkEffectRangeInsidePeaceZone(skill, worldPosition.getX(), worldPosition.getY(), worldPosition.getZ()))
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.A_MALICIOUS_SKILL_CANNOT_BE_USED_IN_A_PEACE_ZONE);
}
return null;
}
return activeChar; // Return yourself to know that your ground location is legit.
}
}
return null;
}
}

View File

@@ -1,50 +1,53 @@
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2ChestInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
/**
* @author UnAfraid
*/
public class Unlockable implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
if ((target == null) || (!target.isDoor() && !(target instanceof L2ChestInstance)))
{
return EMPTY_TARGET_LIST;
}
return new L2Character[]
{
target
};
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.UNLOCKABLE;
}
}
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2ArtefactInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Target siege artefact.
* @author Nik
*/
public class HolyThing implements ITargetTypeHandler
{
@Override
public Enum<TargetType> getTargetType()
{
return TargetType.HOLYTHING;
}
@Override
public L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage)
{
if (activeChar.getTarget() instanceof L2ArtefactInstance)
{
return activeChar.getTarget();
}
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
}
return null;
}
}

View File

@@ -1,49 +1,43 @@
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
/**
* @author UnAfraid
*/
public class FlagPole implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
if (!activeChar.isPlayer())
{
return EMPTY_TARGET_LIST;
}
return new L2Object[]
{
target
};
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.FLAGPOLE;
}
}
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
/**
* TODO: Target item.
* @author Nik
*/
public class Item implements ITargetTypeHandler
{
@Override
public Enum<TargetType> getTargetType()
{
return TargetType.ITEM;
}
@Override
public L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage)
{
return null;
}
}

View File

@@ -1,53 +1,53 @@
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
/**
* @author UnAfraid
*/
public class OwnerPet implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
if (activeChar.isSummon())
{
target = ((L2Summon) activeChar).getOwner();
if ((target != null) && !target.isDead())
{
return new L2Character[]
{
target
};
}
}
return EMPTY_TARGET_LIST;
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.OWNER_PET;
}
}
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.instancemanager.MentorManager;
import com.l2jmobius.gameserver.model.L2Mentee;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
/**
* Target my mentor.
* @author Nik
*/
public class MyMentor implements ITargetTypeHandler
{
@Override
public Enum<TargetType> getTargetType()
{
return TargetType.MY_MENTOR;
}
@Override
public L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage)
{
if (activeChar.isPlayer())
{
final L2Mentee mentor = MentorManager.getInstance().getMentor(activeChar.getObjectId());
if (mentor != null)
{
return mentor.getPlayerInstance();
}
}
return null;
}
}

View File

@@ -0,0 +1,53 @@
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
/**
* Something like target self, but party. Used in aura skills.
* @author Nik
*/
public class MyParty implements ITargetTypeHandler
{
@Override
public Enum<TargetType> getTargetType()
{
return TargetType.MY_PARTY;
}
@Override
public L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage)
{
if ((selectedTarget != null) && selectedTarget.isPlayer() && (selectedTarget != activeChar))
{
final L2Party party = activeChar.getParty();
final L2Party targetParty = selectedTarget.getActingPlayer().getParty();
if ((party != null) && (targetParty != null) && (party.getLeaderObjectId() == targetParty.getLeaderObjectId()))
{
return selectedTarget;
}
}
return null;
}
}

View File

@@ -1,50 +1,41 @@
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2ArtefactInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
/**
* @author UnAfraid
*/
public class Holy implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
if (!(target instanceof L2ArtefactInstance))
{
return EMPTY_TARGET_LIST;
}
return new L2Object[]
{
target
};
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.HOLY;
}
}
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
/**
* @author Sdw
*/
public class None implements ITargetTypeHandler
{
@Override
public L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage)
{
return activeChar;
}
@Override
public Enum<TargetType> getTargetType()
{
return TargetType.NONE;
}
}

View File

@@ -0,0 +1,104 @@
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Target dead monster.
* @author Nik
*/
public class NpcBody implements ITargetTypeHandler
{
@Override
public Enum<TargetType> getTargetType()
{
return TargetType.NPC_BODY;
}
@Override
public L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage)
{
if (selectedTarget == null)
{
return null;
}
if (!selectedTarget.isCharacter())
{
return null;
}
if (!selectedTarget.isNpc())
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
return null;
}
final L2Playable target = (L2Playable) selectedTarget;
if (target.isDead())
{
// Check for cast range if character cannot move. TODO: char will start follow until within castrange, but if his moving is blocked by geodata, this msg will be sent.
if (dontMove)
{
if (activeChar.calculateDistance(target, false, false) > skill.getCastRange())
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.THE_DISTANCE_IS_TOO_FAR_AND_SO_THE_CASTING_HAS_BEEN_STOPPED);
}
return null;
}
}
// Geodata check when character is within range.
if (!GeoData.getInstance().canSeeTarget(activeChar, target))
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.CANNOT_SEE_TARGET);
}
return null;
}
return target;
}
// If target is not dead or not player/pet it will not even bother to walk within range, unlike Enemy target type.
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
return null;
}
}

View File

@@ -1,97 +0,0 @@
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2SiegeFlagInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* @author St3eT
*/
public final class OneFriendly implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
// Check for null target or any other invalid target
if ((target == null) || target.isDead())
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return EMPTY_TARGET_LIST;
}
if (!checkTarget(activeChar, target))
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return EMPTY_TARGET_LIST;
}
// If a target is found, return it in a table else send a system message TARGET_IS_INCORRECT
return new L2Character[]
{
target
};
}
private boolean checkTarget(L2Character activeChar, L2Character target)
{
if ((target == null) || target.isAlikeDead() || target.isDoor() || (target instanceof L2SiegeFlagInstance) || target.isMonster())
{
return false;
}
if ((target.getActingPlayer() != null) && (target.getActingPlayer() != activeChar) && (target.getActingPlayer().inObserverMode() || target.getActingPlayer().isInOlympiadMode()))
{
return false;
}
if (target.isPlayable())
{
boolean friendly = false;
if ((activeChar.getAllyId() > 0) && (activeChar.getAllyId() == target.getActingPlayer().getAllyId()))
{
friendly = true;
}
else if ((activeChar.getClanId() > 0) && (activeChar.getClanId() == target.getActingPlayer().getClanId()))
{
friendly = true;
}
else if (activeChar.isInParty() && activeChar.getParty().containsPlayer(target.getActingPlayer()))
{
friendly = true;
}
else if ((target != activeChar) && (target.getActingPlayer().getPvpFlag() == 0))
{
friendly = true;
}
return friendly;
}
return true;
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.ONE_FRIENDLY;
}
}

View File

@@ -1,46 +1,43 @@
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
/**
* Target Servitor handler.
* @author Zoey76
*/
public class Servitor implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
if (activeChar.hasServitors())
{
return activeChar.getServitors().values().toArray(new L2Character[activeChar.getServitors().size()]);
}
return EMPTY_TARGET_LIST;
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.SERVITOR;
}
}
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
/**
* Target other things (skills with this target type appear to be disabled).
* @author Nik
*/
public class Others implements ITargetTypeHandler
{
@Override
public Enum<TargetType> getTargetType()
{
return TargetType.OTHERS;
}
@Override
public L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage)
{
return null;
}
}

View File

@@ -1,110 +0,0 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
/**
* @author UnAfraid
*/
public class Party implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final List<L2Character> targetList = new ArrayList<>();
if (onlyFirst)
{
return new L2Character[]
{
activeChar
};
}
targetList.add(activeChar);
final int radius = skill.getAffectRange();
final L2PcInstance player = activeChar.getActingPlayer();
if (activeChar.isSummon())
{
if (Skill.addCharacter(activeChar, player, radius, false))
{
targetList.add(player);
}
}
else if (activeChar.isPlayer())
{
if (Skill.addPet(activeChar, player, radius, false))
{
targetList.add(player.getPet());
}
player.getServitors().values().forEach(s ->
{
if (Skill.addCharacter(activeChar, s, radius, false))
{
targetList.add(s);
}
});
}
if (activeChar.isInParty())
{
// Get a list of Party Members
for (L2PcInstance partyMember : activeChar.getParty().getMembers())
{
if ((partyMember == null) || (partyMember == player))
{
continue;
}
if (Skill.addCharacter(activeChar, partyMember, radius, false))
{
targetList.add(partyMember);
}
if (Skill.addPet(activeChar, partyMember, radius, false))
{
targetList.add(partyMember.getPet());
}
partyMember.getServitors().values().forEach(s ->
{
if (Skill.addCharacter(activeChar, s, radius, false))
{
targetList.add(s);
}
});
}
}
return targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.PARTY;
}
}

View File

@@ -1,170 +0,0 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.TvTEvent;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
/**
* @author UnAfraid
*/
public class PartyClan implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final List<L2Character> targetList = new ArrayList<>();
if (onlyFirst)
{
return new L2Character[]
{
activeChar
};
}
final L2PcInstance player = activeChar.getActingPlayer();
if (player == null)
{
return EMPTY_TARGET_LIST;
}
targetList.add(player);
final int radius = skill.getAffectRange();
final boolean hasClan = player.getClan() != null;
final boolean hasParty = player.isInParty();
if (Skill.addPet(activeChar, player, radius, false))
{
targetList.add(player.getPet());
}
player.getServitors().values().forEach(s ->
{
if (Skill.addCharacter(activeChar, s, radius, false))
{
targetList.add(s);
}
});
// if player in clan and not in party
if (!hasClan && !hasParty)
{
return targetList.toArray(new L2Character[targetList.size()]);
}
// Get all visible objects in a spherical area near the L2Character
final Collection<L2PcInstance> objs = activeChar.getKnownList().getKnownPlayersInRadius(radius);
final int maxTargets = skill.getAffectLimit();
for (L2PcInstance obj : objs)
{
if (obj == null)
{
continue;
}
// olympiad mode - adding only own side
if (player.isInOlympiadMode())
{
if (!obj.isInOlympiadMode())
{
continue;
}
if (player.getOlympiadGameId() != obj.getOlympiadGameId())
{
continue;
}
if (player.getOlympiadSide() != obj.getOlympiadSide())
{
continue;
}
}
if (player.isInDuel())
{
if (player.getDuelId() != obj.getDuelId())
{
continue;
}
if (hasParty && obj.isInParty() && (player.getParty().getLeaderObjectId() != obj.getParty().getLeaderObjectId()))
{
continue;
}
}
if ((!hasClan || (obj.getClanId() != player.getClanId())) && (!hasParty || !obj.isInParty() || (player.getParty().getLeaderObjectId() != obj.getParty().getLeaderObjectId())))
{
continue;
}
// Don't add this target if this is a Pc->Pc pvp
// casting and pvp condition not met
if (!player.checkPvpSkill(obj, skill))
{
continue;
}
if (!TvTEvent.checkForTvTSkill(player, obj, skill))
{
continue;
}
if (Skill.addPet(activeChar, obj, radius, false))
{
targetList.add(obj.getPet());
}
obj.getServitors().values().forEach(s ->
{
if (Skill.addCharacter(activeChar, s, radius, false))
{
targetList.add(s);
}
});
if (!Skill.addCharacter(activeChar, obj, radius, false))
{
continue;
}
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
}
targetList.add(obj);
}
return targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.PARTY_CLAN;
}
}

View File

@@ -1,79 +0,0 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class PartyNotMe implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final List<L2Character> targetList = new ArrayList<>();
final int radius = skill.getAffectRange();
if (activeChar.getParty() != null)
{
for (L2PcInstance partyMember : activeChar.getParty().getMembers())
{
if ((partyMember == activeChar) || !Util.checkIfInRange(Config.ALT_PARTY_RANGE, activeChar, partyMember, true))
{
continue;
}
if (Skill.addPet(activeChar, partyMember, radius, false))
{
targetList.add(partyMember.getPet());
}
partyMember.getServitors().values().forEach(s ->
{
if (Skill.addCharacter(activeChar, s, radius, false))
{
targetList.add(s);
}
});
if (Skill.addCharacter(activeChar, partyMember, radius, false))
{
targetList.add(partyMember);
}
targetList.add(partyMember);
}
}
return targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.PARTY_NOTME;
}
}

View File

@@ -1,83 +0,0 @@
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* @author UnAfraid
*/
public class PartyOther implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
if ((target != null) && (target != activeChar) && activeChar.isInParty() && target.isInParty() && (activeChar.getParty().getLeaderObjectId() == target.getParty().getLeaderObjectId()))
{
if (!target.isDead())
{
if (target.isPlayer())
{
switch (skill.getId())
{
// FORCE BUFFS may cancel here but there should be a proper condition
case 426:
{
if (!target.getActingPlayer().isMageClass())
{
return new L2Character[]
{
target
};
}
return EMPTY_TARGET_LIST;
}
case 427:
{
if (target.getActingPlayer().isMageClass())
{
return new L2Character[]
{
target
};
}
return EMPTY_TARGET_LIST;
}
}
}
return new L2Character[]
{
target
};
}
return EMPTY_TARGET_LIST;
}
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return EMPTY_TARGET_LIST;
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.PARTY_OTHER;
}
}

View File

@@ -1,107 +1,131 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
import com.l2jmobius.gameserver.model.effects.L2EffectType;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* @author UnAfraid
*/
public class PcBody implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final List<L2Character> targetList = new ArrayList<>();
if ((target != null) && target.isDead())
{
final L2PcInstance player;
if (activeChar.isPlayer())
{
player = activeChar.getActingPlayer();
}
else
{
player = null;
}
final L2PcInstance targetPlayer;
if (target.isPlayer())
{
targetPlayer = target.getActingPlayer();
}
else
{
targetPlayer = null;
}
final L2PetInstance targetPet;
if (target.isPet())
{
targetPet = (L2PetInstance) target;
}
else
{
targetPet = null;
}
if ((player != null) && ((targetPlayer != null) || (targetPet != null)))
{
boolean condGood = true;
if (skill.hasEffectType(L2EffectType.RESURRECTION) && (targetPlayer != null) && targetPlayer.isInsideZone(ZoneId.SIEGE) && !targetPlayer.isInSiege())
{
condGood = false;
activeChar.sendPacket(SystemMessageId.IT_IS_NOT_POSSIBLE_TO_RESURRECT_IN_BATTLEGROUNDS_WHERE_A_SIEGE_WAR_IS_TAKING_PLACE);
}
if (condGood)
{
if (!onlyFirst)
{
targetList.add(target);
return targetList.toArray(new L2Character[targetList.size()]);
}
return new L2Character[]
{
target
};
}
}
}
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return EMPTY_TARGET_LIST;
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.PC_BODY;
}
}
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.effects.L2EffectType;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Target dead player or pet.
* @author Nik
*/
public class PcBody implements ITargetTypeHandler
{
@Override
public Enum<TargetType> getTargetType()
{
return TargetType.PC_BODY;
}
@Override
public L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage)
{
if (selectedTarget == null)
{
return null;
}
if (!selectedTarget.isCharacter())
{
return null;
}
if (!selectedTarget.isPlayer() || selectedTarget.isPet())
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
return null;
}
final L2Playable target = (L2Playable) selectedTarget;
if (target.isDead())
{
if (skill.hasEffectType(L2EffectType.RESURRECTION))
{
if (activeChar.isResurrectionBlocked() || target.isResurrectionBlocked())
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.REJECT_RESURRECTION); // Reject resurrection
target.sendPacket(SystemMessageId.REJECT_RESURRECTION); // Reject resurrection
}
return null;
}
// check target is not in a active siege zone
if (target.isPlayer() && target.isInsideZone(ZoneId.SIEGE) && !target.getActingPlayer().isInSiege())
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.IT_IS_NOT_POSSIBLE_TO_RESURRECT_IN_BATTLEGROUNDS_WHERE_A_SIEGE_WAR_IS_TAKING_PLACE);
}
return null;
}
}
// Check for cast range if character cannot move. TODO: char will start follow until within castrange, but if his moving is blocked by geodata, this msg will be sent.
if (dontMove)
{
if (activeChar.calculateDistance(target, false, false) > skill.getCastRange())
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.THE_DISTANCE_IS_TOO_FAR_AND_SO_THE_CASTING_HAS_BEEN_STOPPED);
}
return null;
}
}
// Geodata check when character is within range.
if (!GeoData.getInstance().canSeeTarget(activeChar, target))
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.CANNOT_SEE_TARGET);
}
return null;
}
return target;
}
// If target is not dead or not player/pet it will not even bother to walk within range, unlike Enemy target type.
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
return null;
}
}

View File

@@ -1,44 +1,54 @@
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
/**
* @author UnAfraid
*/
public class Self implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
return new L2Character[]
{
activeChar
};
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.SELF;
}
}
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Target yourself.
* @author Nik
*/
public class Self implements ITargetTypeHandler
{
@Override
public Enum<TargetType> getTargetType()
{
return TargetType.SELF;
}
@Override
public L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage)
{
if (activeChar.isInsideZone(ZoneId.PEACE) && skill.isBad())
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.A_MALICIOUS_SKILL_CANNOT_BE_USED_IN_A_PEACE_ZONE);
}
return null;
}
return activeChar;
}
}

View File

@@ -1,63 +1,47 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
/**
* Target Summon handler.
* @author UnAfraid
*/
public class Summon implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
if (!activeChar.hasSummon())
{
return EMPTY_TARGET_LIST;
}
if (!activeChar.hasPet() && activeChar.hasServitors())
{
return activeChar.getServitors().values().toArray(new L2Character[0]);
}
if (activeChar.hasPet() && !activeChar.hasServitors())
{
return new L2Character[]
{
activeChar.getPet()
};
}
final List<L2Character> targets = new ArrayList<>(1 + activeChar.getServitors().size());
targets.add(activeChar.getPet());
targets.addAll(activeChar.getServitors().values());
return targets.toArray(new L2Character[0]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.SUMMON;
}
}
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
/**
* Target automatically one of my summons.
* @author Nik
*/
public class Summon implements ITargetTypeHandler
{
@Override
public Enum<TargetType> getTargetType()
{
return TargetType.SUMMON;
}
@Override
public L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage)
{
if (activeChar.isPlayer() && activeChar.hasSummon())
{
return activeChar.getActingPlayer().getAnyServitor();
}
return activeChar.getPet();
}
}

View File

@@ -0,0 +1,100 @@
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.FlyToLocation.FlyType;
/**
* Any friendly selected target or enemy if force use. Works on dead targets or doors as well.
* @author Nik
*/
public class Target implements ITargetTypeHandler
{
@Override
public Enum<TargetType> getTargetType()
{
return TargetType.TARGET;
}
@Override
public L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage)
{
if (selectedTarget == null)
{
return null;
}
if (!selectedTarget.isCharacter())
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
return null;
}
final L2Character target = (L2Character) selectedTarget;
// You can always target yourself.
if (activeChar == target)
{
return target;
}
// Check for cast range if character cannot move. TODO: char will start follow until within castrange, but if his moving is blocked by geodata, this msg will be sent.
if (dontMove)
{
if (activeChar.calculateDistance(target, false, false) > skill.getCastRange())
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.THE_DISTANCE_IS_TOO_FAR_AND_SO_THE_CASTING_HAS_BEEN_STOPPED);
}
return null;
}
}
if ((skill.getFlyType() == FlyType.CHARGE) && !GeoData.getInstance().canMove(activeChar, target))
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.THE_TARGET_IS_LOCATED_WHERE_YOU_CANNOT_CHARGE);
}
return null;
}
// Geodata check when character is within range.
if (!GeoData.getInstance().canSeeTarget(activeChar, target))
{
if (sendMessage)
{
activeChar.sendPacket(SystemMessageId.CANNOT_SEE_TARGET);
}
return null;
}
return target;
}
}

View File

@@ -1,90 +0,0 @@
/*
* 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.targethandlers;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* @author St3eT
*/
public class TargetParty implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final List<L2Character> targetList = new ArrayList<>();
// Check for null target or any other invalid target
if ((target == null) || target.isDead() || (target == activeChar))
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return EMPTY_TARGET_LIST;
}
final int radius = skill.getAffectRange();
final L2PcInstance player = (L2PcInstance) activeChar.getTarget();
if (player.isInParty())
{
for (L2PcInstance partyMember : player.getParty().getMembers())
{
if (partyMember == null)
{
continue;
}
if (Skill.addCharacter(player, partyMember, radius, false))
{
targetList.add(partyMember);
}
if (Skill.addPet(player, partyMember, radius, false))
{
targetList.add(partyMember.getPet());
}
partyMember.getServitors().values().forEach(s ->
{
if (Skill.addCharacter(activeChar, s, radius, false))
{
targetList.add(s);
}
});
}
}
else
{
targetList.add(target);
}
return targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.TARGET_PARTY;
}
}

View File

@@ -1,51 +1,43 @@
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
/**
* Target Pet handler.
* @author UnAfraid
*/
public class Pet implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
final L2Summon pet = activeChar.getPet();
if (pet != null)
{
return new L2Character[]
{
pet
};
}
return EMPTY_TARGET_LIST;
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.PET;
}
}
/*
* 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.targethandlers;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
/**
* TODO: Target while riding wyvern.
* @author Nik
*/
public class WyvernTarget implements ITargetTypeHandler
{
@Override
public Enum<TargetType> getTargetType()
{
return TargetType.WYVERN_TARGET;
}
@Override
public L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage)
{
return null;
}
}

View File

@@ -0,0 +1,39 @@
/*
* 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.targethandlers.affectobject;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.targets.AffectObject;
/**
* @author Nik
*/
public class All implements IAffectObjectHandler
{
@Override
public boolean checkAffectedObject(L2Character activeChar, L2Character target)
{
return true;
}
@Override
public Enum<AffectObject> getAffectObjectType()
{
return AffectObject.ALL;
}
}

View File

@@ -0,0 +1,61 @@
/*
* 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.targethandlers.affectobject;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.targets.AffectObject;
/**
* @author Nik
*/
public class Clan implements IAffectObjectHandler
{
@Override
public boolean checkAffectedObject(L2Character activeChar, L2Character target)
{
if (activeChar == target)
{
return true;
}
final L2PcInstance player = activeChar.getActingPlayer();
if (player != null)
{
final L2Clan clan = player.getClan();
if (clan != null)
{
return clan == target.getClan();
}
}
else if (activeChar.isNpc() && target.isNpc())
{
return ((L2Npc) activeChar).isInMyClan(((L2Npc) target));
}
return false;
}
@Override
public Enum<AffectObject> getAffectObjectType()
{
return AffectObject.CLAN;
}
}

View File

@@ -0,0 +1,130 @@
/*
* 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.targethandlers.affectobject;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.targets.AffectObject;
import com.l2jmobius.gameserver.model.zone.ZoneId;
/**
* @author Nik
*/
public class Friend implements IAffectObjectHandler
{
@Override
public boolean checkAffectedObject(L2Character activeChar, L2Character target)
{
if (activeChar == target)
{
return true;
}
final L2PcInstance player = activeChar.getActingPlayer();
final L2PcInstance targetPlayer = target.getActingPlayer();
if (player != null)
{
if (targetPlayer != null)
{
// Same player.
if (player == targetPlayer)
{
return true;
}
// Party (command channel doesn't make you friends).
final L2Party party = player.getParty();
final L2Party targetParty = targetPlayer.getParty();
if ((party != null) && (targetParty != null) && (party.getLeaderObjectId() == targetParty.getLeaderObjectId()))
{
return true;
}
// Arena.
if (activeChar.isInsideZone(ZoneId.PVP) && target.isInsideZone(ZoneId.PVP))
{
return false;
}
// Duel.
if (player.isInDuel() && targetPlayer.isInDuel() && (player.getDuelId() == targetPlayer.getDuelId()))
{
return false;
}
// Olympiad.
if (player.isInOlympiadMode() && targetPlayer.isInOlympiadMode() && (player.getOlympiadGameId() == targetPlayer.getOlympiadGameId()))
{
return false;
}
// Clan.
final L2Clan clan = player.getClan();
final L2Clan targetClan = targetPlayer.getClan();
if (clan != null)
{
if (clan == targetClan)
{
return true;
}
// War
if ((targetClan != null) && clan.isAtWarWith(targetClan) && targetClan.isAtWarWith(clan))
{
return false;
}
}
// Alliance.
if ((player.getAllyId() != 0) && (player.getAllyId() == targetPlayer.getAllyId()))
{
return true;
}
// Siege.
if (target.isInsideZone(ZoneId.SIEGE))
{
// Players in the same siege side at the same castle are considered friends.
if ((player.getSiegeState() > 0) && (player.getSiegeState() == targetPlayer.getSiegeState()) && (player.getSiegeSide() == targetPlayer.getSiegeSide()))
{
return true;
}
return false;
}
// By default any neutral non-flagged player is considered a friend.
return (target.getActingPlayer().getPvpFlag() == 0) && (target.getActingPlayer().getReputation() >= 0);
}
// By default any npc that isnt mob is considered friend.
return !target.isMonster() && !target.isAutoAttackable(player);
}
return !target.isAutoAttackable(activeChar);
}
@Override
public Enum<AffectObject> getAffectObjectType()
{
return AffectObject.FRIEND;
}
}

View File

@@ -0,0 +1,124 @@
/*
* 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.targethandlers.affectobject;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.targets.AffectObject;
import com.l2jmobius.gameserver.model.zone.ZoneId;
/**
* @author Nik
*/
public class FriendPc implements IAffectObjectHandler
{
@Override
public boolean checkAffectedObject(L2Character activeChar, L2Character target)
{
if (!target.isPlayer())
{
return false;
}
final L2PcInstance player = activeChar.getActingPlayer();
final L2PcInstance targetPlayer = target.getActingPlayer();
if (player != null)
{
// Same player.
if (player == targetPlayer)
{
return true;
}
// Party (command channel doesn't make you friends).
final L2Party party = player.getParty();
final L2Party targetParty = targetPlayer.getParty();
if ((party != null) && (targetParty != null) && (party.getLeaderObjectId() == targetParty.getLeaderObjectId()))
{
return true;
}
// Arena.
if (activeChar.isInsideZone(ZoneId.PVP) && target.isInsideZone(ZoneId.PVP))
{
return false;
}
// Duel.
if (player.isInDuel() && targetPlayer.isInDuel() && (player.getDuelId() == targetPlayer.getDuelId()))
{
return false;
}
// Olympiad.
if (player.isInOlympiadMode() && targetPlayer.isInOlympiadMode() && (player.getOlympiadGameId() == targetPlayer.getOlympiadGameId()))
{
return false;
}
// Clan.
final L2Clan clan = player.getClan();
final L2Clan targetClan = targetPlayer.getClan();
if (clan != null)
{
if (clan == targetClan)
{
return true;
}
// War
if ((targetClan != null) && clan.isAtWarWith(targetClan) && targetClan.isAtWarWith(clan))
{
return false;
}
}
// Alliance.
if ((player.getAllyId() != 0) && (player.getAllyId() == targetPlayer.getAllyId()))
{
return true;
}
// Siege.
if (target.isInsideZone(ZoneId.SIEGE))
{
// Players in the same siege side at the same castle are considered friends.
if ((player.getSiegeState() > 0) && (player.getSiegeState() == targetPlayer.getSiegeState()) && (player.getSiegeSide() == targetPlayer.getSiegeSide()))
{
return true;
}
return false;
}
// By default any neutral non-flagged player is considered a friend.
return (target.getActingPlayer().getPvpFlag() == 0) && (target.getActingPlayer().getReputation() >= 0);
}
return target.isAutoAttackable(activeChar);
}
@Override
public Enum<AffectObject> getAffectObjectType()
{
return AffectObject.FRIEND_PC;
}
}

View File

@@ -0,0 +1,41 @@
/*
* 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.targethandlers.affectobject;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.targets.AffectObject;
/**
* @author Nik
*/
public class HiddenPlace implements IAffectObjectHandler
{
@Override
public boolean checkAffectedObject(L2Character activeChar, L2Character target)
{
// TODO: What is this?
return false;
}
@Override
public Enum<AffectObject> getAffectObjectType()
{
return AffectObject.HIDDEN_PLACE;
}
}

View File

@@ -0,0 +1,40 @@
/*
* 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.targethandlers.affectobject;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.targets.AffectObject;
/**
* Invisible affect object implementation.
* @author Nik
*/
public class Invisible implements IAffectObjectHandler
{
@Override
public boolean checkAffectedObject(L2Character activeChar, L2Character target)
{
return target.isInvisible();
}
@Override
public Enum<AffectObject> getAffectObjectType()
{
return AffectObject.INVISIBLE;
}
}

View File

@@ -0,0 +1,138 @@
/*
* 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.targethandlers.affectobject;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.targets.AffectObject;
import com.l2jmobius.gameserver.model.zone.ZoneId;
/**
* Not Friend affect object implementation. Based on Gracia Final retail tests.<br>
* Such are considered flagged/karma players (except party/clan/ally). Doesn't matter if in command channel.<br>
* In arena such are considered clan/ally/command channel (except party). <br>
* In peace zone such are considered monsters.<br>
* Monsters consider such all players, npcs (Citizens, Guild Masters, Merchants, Guards, etc. except monsters). Doesn't matter if in peace zone or arena.
* @author Nik
*/
public class NotFriend implements IAffectObjectHandler
{
@Override
public boolean checkAffectedObject(L2Character activeChar, L2Character target)
{
if (activeChar == target)
{
return false;
}
final L2PcInstance player = activeChar.getActingPlayer();
final L2PcInstance targetPlayer = target.getActingPlayer();
if (player != null)
{
if (targetPlayer != null)
{
// Same player.
if (player == targetPlayer)
{
return false;
}
// Peace Zone.
if (target.isInsidePeaceZone(player) && !player.getAccessLevel().allowPeaceAttack())
{
return false;
}
// Party (command channel doesn't make you friends).
final L2Party party = player.getParty();
final L2Party targetParty = targetPlayer.getParty();
if ((party != null) && (targetParty != null) && (party.getLeaderObjectId() == targetParty.getLeaderObjectId()))
{
return false;
}
// Arena.
if (activeChar.isInsideZone(ZoneId.PVP) && target.isInsideZone(ZoneId.PVP))
{
return true;
}
// Duel.
if (player.isInDuel() && targetPlayer.isInDuel() && (player.getDuelId() == targetPlayer.getDuelId()))
{
return true;
}
// Olympiad.
if (player.isInOlympiadMode() && targetPlayer.isInOlympiadMode() && (player.getOlympiadGameId() == targetPlayer.getOlympiadGameId()))
{
return true;
}
// Clan.
final L2Clan clan = player.getClan();
final L2Clan targetClan = targetPlayer.getClan();
if (clan != null)
{
if (clan == targetClan)
{
return false;
}
// War
if ((targetClan != null) && clan.isAtWarWith(targetClan) && targetClan.isAtWarWith(clan))
{
return true;
}
}
// Alliance.
if ((player.getAllyId() != 0) && (player.getAllyId() == targetPlayer.getAllyId()))
{
return false;
}
// Siege.
if (target.isInsideZone(ZoneId.SIEGE))
{
// Players in the same siege side at the same castle are considered friends.
if ((player.getSiegeState() > 0) && (player.getSiegeState() == targetPlayer.getSiegeState()) && (player.getSiegeSide() == targetPlayer.getSiegeSide()))
{
return false;
}
return true;
}
// By default any flagged/PK player is considered enemy.
return (target.getActingPlayer().getPvpFlag() > 0) || (target.getActingPlayer().getReputation() < 0);
}
}
return target.isAutoAttackable(activeChar);
}
@Override
public Enum<AffectObject> getAffectObjectType()
{
return AffectObject.NOT_FRIEND;
}
}

View File

@@ -0,0 +1,135 @@
/*
* 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.targethandlers.affectobject;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.targets.AffectObject;
import com.l2jmobius.gameserver.model.zone.ZoneId;
/**
* @author Nik
*/
public class NotFriendPc implements IAffectObjectHandler
{
@Override
public boolean checkAffectedObject(L2Character activeChar, L2Character target)
{
if (!target.isPlayer())
{
return false;
}
if (activeChar == target)
{
return false;
}
final L2PcInstance player = activeChar.getActingPlayer();
final L2PcInstance targetPlayer = target.getActingPlayer();
if (player != null)
{
// Same player.
if (player == targetPlayer)
{
return false;
}
// Peace Zone.
if (target.isInsidePeaceZone(player) && !player.getAccessLevel().allowPeaceAttack())
{
return false;
}
// Party (command channel doesn't make you friends).
final L2Party party = player.getParty();
final L2Party targetParty = targetPlayer.getParty();
if ((party != null) && (targetParty != null) && (party.getLeaderObjectId() == targetParty.getLeaderObjectId()))
{
return false;
}
// Arena.
if (activeChar.isInsideZone(ZoneId.PVP) && target.isInsideZone(ZoneId.PVP))
{
return true;
}
// Duel.
if (player.isInDuel() && targetPlayer.isInDuel() && (player.getDuelId() == targetPlayer.getDuelId()))
{
return true;
}
// Olympiad.
if (player.isInOlympiadMode() && targetPlayer.isInOlympiadMode() && (player.getOlympiadGameId() == targetPlayer.getOlympiadGameId()))
{
return true;
}
// Clan.
final L2Clan clan = player.getClan();
final L2Clan targetClan = targetPlayer.getClan();
if (clan != null)
{
if (clan == targetClan)
{
return false;
}
// War
if ((targetClan != null) && clan.isAtWarWith(targetClan) && targetClan.isAtWarWith(clan))
{
return true;
}
}
// Alliance.
if ((player.getAllyId() != 0) && (player.getAllyId() == targetPlayer.getAllyId()))
{
return false;
}
// Siege.
if (target.isInsideZone(ZoneId.SIEGE))
{
// Players in the same siege side at the same castle are considered friends.
if ((player.getSiegeState() > 0) && (player.getSiegeState() == targetPlayer.getSiegeState()) && (player.getSiegeSide() == targetPlayer.getSiegeSide()))
{
return false;
}
return true;
}
// By default any flagged/PK player is considered enemy.
return (target.getActingPlayer().getPvpFlag() > 0) || (target.getActingPlayer().getReputation() < 0);
}
return target.isAutoAttackable(activeChar);
}
@Override
public Enum<AffectObject> getAffectObjectType()
{
return AffectObject.NOT_FRIEND_PC;
}
}

View File

@@ -0,0 +1,44 @@
/*
* 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.targethandlers.affectobject;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.targets.AffectObject;
/**
* @author Nik
*/
public class ObjectDeadNpcBody implements IAffectObjectHandler
{
@Override
public boolean checkAffectedObject(L2Character activeChar, L2Character target)
{
if (activeChar == target)
{
return false;
}
return target.isNpc() && target.isDead();
}
@Override
public Enum<AffectObject> getAffectObjectType()
{
return AffectObject.OBJECT_DEAD_NPC_BODY;
}
}

View File

@@ -0,0 +1,46 @@
/*
* 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.targethandlers.affectobject;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.targets.AffectObject;
/**
* Undead enemy npc affect object implementation.
* @author Nik
*/
public class UndeadRealEnemy implements IAffectObjectHandler
{
@Override
public boolean checkAffectedObject(L2Character activeChar, L2Character target)
{
// You are not an enemy of yourself.
if (activeChar == target)
{
return false;
}
return target.isUndead() && target.isAutoAttackable(activeChar);
}
@Override
public Enum<AffectObject> getAffectObjectType()
{
return AffectObject.UNDEAD_REAL_ENEMY;
}
}

View File

@@ -0,0 +1,42 @@
/*
* 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.targethandlers.affectobject;
import com.l2jmobius.gameserver.data.xml.impl.CategoryData;
import com.l2jmobius.gameserver.enums.CategoryType;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.targets.AffectObject;
/**
* @author Nik
*/
public class WyvernObject implements IAffectObjectHandler
{
@Override
public boolean checkAffectedObject(L2Character activeChar, L2Character target)
{
// TODO Check if this is proper. Not sure if this is the object we are looking for.
return CategoryData.getInstance().isInCategory(CategoryType.WYVERN_GROUP, target.getId());
}
@Override
public Enum<AffectObject> getAffectObjectType()
{
return AffectObject.WYVERN_OBJECT;
}
}

View File

@@ -0,0 +1,44 @@
/*
* 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.targethandlers.affectscope;
import java.util.function.Consumer;
import com.l2jmobius.gameserver.handler.IAffectScopeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
/**
* TODO: Valakas affect scope implementation.
* @author Nik
*/
public class BalakasScope implements IAffectScopeHandler
{
@Override
public void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action)
{
// TODO Unknown affect scope.
}
@Override
public Enum<AffectScope> getAffectScopeType()
{
return AffectScope.BALAKAS_SCOPE;
}
}

View File

@@ -0,0 +1,107 @@
/*
* 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.targethandlers.affectscope;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import com.l2jmobius.gameserver.handler.AffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectScopeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
/**
* @author Nik
*/
public class DeadParty implements IAffectScopeHandler
{
@Override
public void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action)
{
final IAffectObjectHandler affectObject = AffectObjectHandler.getInstance().getHandler(skill.getAffectObject());
final int affectRange = skill.getAffectRange();
final int affectLimit = skill.getAffectLimit();
if (target.isPlayable())
{
final L2PcInstance player = target.getActingPlayer();
final L2Party party = player.getParty();
// Create the target filter.
final AtomicInteger affected = new AtomicInteger(0);
final Predicate<L2Playable> filter = plbl ->
{
if ((affectLimit > 0) && (affected.get() >= affectLimit))
{
return false;
}
final L2PcInstance p = plbl.getActingPlayer();
if ((p == null) || !p.isDead())
{
return false;
}
if (p != player)
{
final L2Party targetParty = p.getParty();
if ((party == null) || (targetParty == null) || (party.getLeaderObjectId() != targetParty.getLeaderObjectId()))
{
return false;
}
}
if ((affectObject != null) && !affectObject.checkAffectedObject(activeChar, p))
{
return false;
}
affected.incrementAndGet();
return true;
};
// Affect object of origin since its skipped in the forEachVisibleObjectInRange method.
if (filter.test((L2Playable) target))
{
action.accept(target);
}
// Check and add targets.
L2World.getInstance().forEachVisibleObjectInRange(target, L2Playable.class, affectRange, c ->
{
if (filter.test(c))
{
action.accept(c);
}
});
}
}
@Override
public Enum<AffectScope> getAffectScopeType()
{
return AffectScope.DEAD_PARTY;
}
}

View File

@@ -0,0 +1,111 @@
/*
* 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.targethandlers.affectscope;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import com.l2jmobius.gameserver.handler.AffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectScopeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
/**
* Dead Party and Clan affect scope implementation.
* @author Nik
*/
public class DeadPartyPledge implements IAffectScopeHandler
{
@Override
public void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action)
{
final IAffectObjectHandler affectObject = AffectObjectHandler.getInstance().getHandler(skill.getAffectObject());
final int affectRange = skill.getAffectRange();
final int affectLimit = skill.getAffectLimit();
if (target.isPlayable())
{
final L2Playable playable = (L2Playable) target;
final L2PcInstance player = playable.getActingPlayer();
final L2Party party = player.getParty();
// Create the target filter.
final AtomicInteger affected = new AtomicInteger(0);
final Predicate<L2Playable> filter = plbl ->
{
if ((affectLimit > 0) && (affected.get() >= affectLimit))
{
return false;
}
final L2PcInstance p = plbl.getActingPlayer();
if ((p == null) || !p.isDead())
{
return false;
}
if (p != player)
{
if ((p.getClanId() == 0) || (p.getClanId() != player.getClanId()))
{
final L2Party targetParty = p.getParty();
if ((party == null) || (targetParty == null) || (party.getLeaderObjectId() != targetParty.getLeaderObjectId()))
{
return false;
}
}
}
if ((affectObject != null) && !affectObject.checkAffectedObject(activeChar, p))
{
return false;
}
affected.incrementAndGet();
return true;
};
// Affect object of origin since its skipped in the forEachVisibleObjectInRange method.
if (filter.test(playable))
{
action.accept(playable);
}
// Check and add targets.
L2World.getInstance().forEachVisibleObjectInRange(playable, L2Playable.class, affectRange, c ->
{
if (filter.test(c))
{
action.accept(c);
}
});
}
}
@Override
public Enum<AffectScope> getAffectScopeType()
{
return AffectScope.DEAD_PARTY_PLEDGE;
}
}

View File

@@ -0,0 +1,101 @@
/*
* 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.targethandlers.affectscope;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import com.l2jmobius.gameserver.handler.AffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectScopeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
/**
* @author Nik
*/
public class DeadPledge implements IAffectScopeHandler
{
@Override
public void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action)
{
final IAffectObjectHandler affectObject = AffectObjectHandler.getInstance().getHandler(skill.getAffectObject());
final int affectRange = skill.getAffectRange();
final int affectLimit = skill.getAffectLimit();
if (target.isPlayable())
{
final L2Playable playable = (L2Playable) target;
final L2PcInstance player = playable.getActingPlayer();
// Create the target filter.
final AtomicInteger affected = new AtomicInteger(0);
final Predicate<L2Playable> filter = plbl ->
{
if ((affectLimit > 0) && (affected.get() >= affectLimit))
{
return false;
}
final L2PcInstance p = plbl.getActingPlayer();
if ((p == null) || !p.isDead())
{
return false;
}
if ((p != player) && ((p.getClanId() == 0) || (p.getClanId() != player.getClanId())))
{
return false;
}
if ((affectObject != null) && !affectObject.checkAffectedObject(activeChar, p))
{
return false;
}
affected.incrementAndGet();
return true;
};
// Add object of origin since its skipped in the forEachVisibleObjectInRange method.
if (filter.test(playable))
{
action.accept(playable);
}
// Check and add targets.
L2World.getInstance().forEachVisibleObjectInRange(playable, L2Playable.class, affectRange, c ->
{
if (filter.test(c))
{
action.accept(c);
}
});
}
}
@Override
public Enum<AffectScope> getAffectScopeType()
{
return AffectScope.DEAD_PLEDGE;
}
}

View File

@@ -0,0 +1,119 @@
/*
* 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.targethandlers.affectscope;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import com.l2jmobius.gameserver.handler.AffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectScopeHandler;
import com.l2jmobius.gameserver.model.L2CommandChannel;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
/**
* Dead command channel/party affect scope implementation.
* @author Nik
*/
public class DeadUnion implements IAffectScopeHandler
{
@Override
public void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action)
{
final IAffectObjectHandler affectObject = AffectObjectHandler.getInstance().getHandler(skill.getAffectObject());
final int affectRange = skill.getAffectRange();
final int affectLimit = skill.getAffectLimit();
if (target.isPlayable())
{
final L2PcInstance player = target.getActingPlayer();
final L2Party party = player.getParty();
final L2CommandChannel commandChannel = party != null ? party.getCommandChannel() : null;
// Create the target filter.
final AtomicInteger affected = new AtomicInteger(0);
final Predicate<L2Playable> filter = plbl ->
{
if ((affectLimit > 0) && (affected.get() >= affectLimit))
{
return false;
}
final L2PcInstance p = plbl.getActingPlayer();
if ((p == null) || !p.isDead())
{
return false;
}
if (p != player)
{
final L2Party targetParty = p.getParty();
if ((party == null) || (targetParty == null))
{
return false;
}
if (party.getLeaderObjectId() != targetParty.getLeaderObjectId())
{
final L2CommandChannel targetCommandChannel = targetParty.getCommandChannel();
if ((commandChannel == null) || (targetCommandChannel == null) || (commandChannel.getLeaderObjectId() != targetCommandChannel.getLeaderObjectId()))
{
return false;
}
}
}
if ((affectObject != null) && !affectObject.checkAffectedObject(activeChar, p))
{
return false;
}
affected.incrementAndGet();
return true;
};
// Affect object of origin since its skipped in the forEachVisibleObjectInRange method.
if (filter.test((L2Playable) target))
{
action.accept(target);
}
// Check and add targets.
L2World.getInstance().forEachVisibleObjectInRange(target, L2Playable.class, affectRange, c ->
{
if (filter.test(c))
{
action.accept(c);
}
});
}
}
@Override
public Enum<AffectScope> getAffectScopeType()
{
return AffectScope.DEAD_UNION;
}
}

View File

@@ -0,0 +1,100 @@
/*
* 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.targethandlers.affectscope;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.handler.AffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectScopeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
import com.l2jmobius.gameserver.util.Util;
/**
* Fan affect scope implementation. Gathers objects in a certain angle of circular area around yourself (including origin itself).
* @author Nik
*/
public class Fan implements IAffectScopeHandler
{
@Override
public void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action)
{
final IAffectObjectHandler affectObject = AffectObjectHandler.getInstance().getHandler(skill.getAffectObject());
final double headingAngle = Util.convertHeadingToDegree(activeChar.getHeading());
final int fanStartAngle = skill.getFanRange()[1];
final int fanRadius = skill.getFanRange()[2];
final int fanAngle = skill.getFanRange()[3];
final double fanHalfAngle = fanAngle / 2; // Half left and half right.
final int affectLimit = skill.getAffectLimit();
// Target checks.
final AtomicInteger affected = new AtomicInteger(0);
final Predicate<L2Character> filter = c ->
{
if ((affectLimit > 0) && (affected.get() >= affectLimit))
{
return false;
}
if (c.isDead())
{
return false;
}
if (Math.abs(Util.calculateAngleFrom(activeChar, c) - (headingAngle + fanStartAngle)) > fanHalfAngle)
{
return false;
}
if ((affectObject != null) && !affectObject.checkAffectedObject(activeChar, c))
{
return false;
}
if (!GeoData.getInstance().canSeeTarget(activeChar, c))
{
return false;
}
affected.incrementAndGet();
return true;
};
// Add object of origin since its skipped in the forEachVisibleObjectInRange method.
if (target.isCharacter() && filter.test((L2Character) target))
{
action.accept(target);
}
// Check and add targets.
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2Character.class, fanRadius, c ->
{
if (filter.test(c))
{
action.accept(c);
}
});
}
@Override
public Enum<AffectScope> getAffectScopeType()
{
return AffectScope.FAN;
}
}

View File

@@ -0,0 +1,95 @@
/*
* 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.targethandlers.affectscope;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.handler.AffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectScopeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
import com.l2jmobius.gameserver.util.Util;
/**
* Fan point blank affect scope implementation. Gathers objects in a certain angle of circular area around yourself without taking target into account.
* @author Nik
*/
public class FanPB implements IAffectScopeHandler
{
@Override
public void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action)
{
final IAffectObjectHandler affectObject = AffectObjectHandler.getInstance().getHandler(skill.getAffectObject());
final double headingAngle = Util.convertHeadingToDegree(activeChar.getHeading());
final int fanStartAngle = skill.getFanRange()[1];
final int fanRadius = skill.getFanRange()[2];
final int fanAngle = skill.getFanRange()[3];
final double fanHalfAngle = fanAngle / 2; // Half left and half right.
final int affectLimit = skill.getAffectLimit();
// Target checks.
final AtomicInteger affected = new AtomicInteger(0);
final Predicate<L2Character> filter = c ->
{
if ((affectLimit > 0) && (affected.get() >= affectLimit))
{
return false;
}
if (c.isDead())
{
return false;
}
if (Math.abs(Util.calculateAngleFrom(activeChar, c) - (headingAngle + fanStartAngle)) > fanHalfAngle)
{
return false;
}
if ((affectObject != null) && !affectObject.checkAffectedObject(activeChar, c))
{
return false;
}
if (!GeoData.getInstance().canSeeTarget(activeChar, c))
{
return false;
}
affected.incrementAndGet();
return true;
};
// Check and add targets.
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2Character.class, fanRadius, c ->
{
if (filter.test(c))
{
action.accept(c);
}
});
}
@Override
public Enum<AffectScope> getAffectScopeType()
{
return AffectScope.FAN_PB;
}
}

View File

@@ -0,0 +1,162 @@
/*
* 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.targethandlers.affectscope;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import com.l2jmobius.gameserver.handler.AffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectScopeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
/**
* @author Nik
*/
public class Party implements IAffectScopeHandler
{
@Override
public void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action)
{
final IAffectObjectHandler affectObject = AffectObjectHandler.getInstance().getHandler(skill.getAffectObject());
final int affectRange = skill.getAffectRange();
final int affectLimit = skill.getAffectLimit();
if (target.isPlayable())
{
final L2PcInstance player = target.getActingPlayer();
final com.l2jmobius.gameserver.model.L2Party party = player.getParty();
// Create the target filter.
final AtomicInteger affected = new AtomicInteger(0);
final Predicate<L2Playable> filter = plbl ->
{
// Range skills appear to not affect you unless you are the main target.
if ((plbl == activeChar) && (target != activeChar))
{
return false;
}
if ((affectLimit > 0) && (affected.get() >= affectLimit))
{
return false;
}
final L2PcInstance p = plbl.getActingPlayer();
if ((p == null) || p.isDead())
{
return false;
}
if (p != player)
{
final com.l2jmobius.gameserver.model.L2Party targetParty = p.getParty();
if ((party == null) || (targetParty == null) || (party.getLeaderObjectId() != targetParty.getLeaderObjectId()))
{
return false;
}
}
if ((affectObject != null) && !affectObject.checkAffectedObject(activeChar, p))
{
return false;
}
affected.incrementAndGet();
return true;
};
// Affect object of origin since its skipped in the forEachVisibleObjectInRange method.
if (filter.test((L2Playable) target))
{
action.accept(target);
}
// Check and add targets.
L2World.getInstance().forEachVisibleObjectInRange(target, L2Playable.class, affectRange, c ->
{
if (filter.test(c))
{
action.accept(c);
}
});
}
else if (target.isNpc())
{
final L2Npc npc = (L2Npc) target;
// Create the target filter.
final AtomicInteger affected = new AtomicInteger(0);
final Predicate<L2Npc> filter = n ->
{
if ((affectLimit > 0) && (affected.get() >= affectLimit))
{
return false;
}
if (n.isDead())
{
return false;
}
if (n.isAutoAttackable(npc))
{
return false;
}
if ((affectObject != null) && !affectObject.checkAffectedObject(activeChar, n))
{
return false;
}
affected.incrementAndGet();
return true;
};
// Add object of origin since its skipped in the getVisibleObjects method.
if (filter.test(npc))
{
action.accept(npc);
}
// Check and add targets.
L2World.getInstance().forEachVisibleObjectInRange(npc, L2Npc.class, affectRange, n ->
{
if (n == activeChar)
{
return;
}
if (filter.test(n))
{
action.accept(n);
}
});
}
}
@Override
public Enum<AffectScope> getAffectScopeType()
{
return AffectScope.PARTY;
}
}

View File

@@ -0,0 +1,108 @@
/*
* 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.targethandlers.affectscope;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import com.l2jmobius.gameserver.handler.AffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectScopeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
/**
* Party and Clan affect scope implementation.
* @author Nik
*/
public class PartyPledge implements IAffectScopeHandler
{
@Override
public void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action)
{
final IAffectObjectHandler affectObject = AffectObjectHandler.getInstance().getHandler(skill.getAffectObject());
final int affectRange = skill.getAffectRange();
final int affectLimit = skill.getAffectLimit();
if (target.isPlayable())
{
final L2Playable playable = (L2Playable) target;
final L2PcInstance player = playable.getActingPlayer();
final L2Party party = player.getParty();
// Create the target filter.
final AtomicInteger affected = new AtomicInteger(0);
final Predicate<L2Playable> filter = plbl ->
{
if ((affectLimit > 0) && (affected.get() >= affectLimit))
{
return false;
}
final L2PcInstance p = plbl.getActingPlayer();
if ((p == null) || p.isDead())
{
return false;
}
if (p != player)
{
if (((p.getClanId() == 0) && (p.getParty() == null)) || ((p.getClanId() != player.getClanId()) && (party != player.getParty())))
{
return false;
}
}
if ((affectObject != null) && !affectObject.checkAffectedObject(activeChar, p))
{
return false;
}
affected.incrementAndGet();
return true;
};
// Add object of origin since its skipped in the forEachVisibleObjectInRange method.
if (filter.test(playable))
{
action.accept(playable);
}
// Check and add targets.
L2World.getInstance().forEachVisibleObjectInRange(playable, L2Playable.class, affectRange, c ->
{
if (filter.test(c))
{
action.accept(c);
}
});
}
}
@Override
public Enum<AffectScope> getAffectScopeType()
{
return AffectScope.PARTY_PLEDGE;
}
}

View File

@@ -0,0 +1,100 @@
/*
* 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.targethandlers.affectscope;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import com.l2jmobius.gameserver.handler.AffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectScopeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
/**
* @author Nik
*/
public class Pledge implements IAffectScopeHandler
{
@Override
public void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action)
{
final IAffectObjectHandler affectObject = AffectObjectHandler.getInstance().getHandler(skill.getAffectObject());
final int affectRange = skill.getAffectRange();
final int affectLimit = skill.getAffectLimit();
if (target.isPlayable())
{
final L2Playable playable = (L2Playable) target;
final L2PcInstance player = playable.getActingPlayer();
// Create the target filter.
final AtomicInteger affected = new AtomicInteger(0);
final Predicate<L2Playable> filter = plbl ->
{
if ((affectLimit > 0) && (affected.get() >= affectLimit))
{
return false;
}
final L2PcInstance p = plbl.getActingPlayer();
if ((p == null) || p.isDead())
{
return false;
}
if ((p != player) && ((p.getClanId() == 0) || (p.getClanId() != player.getClanId())))
{
return false;
}
if ((affectObject != null) && !affectObject.checkAffectedObject(activeChar, p))
{
return false;
}
affected.incrementAndGet();
return true;
};
// Add object of origin since its skipped in the forEachVisibleObjectInRange method.
if (filter.test(playable))
{
action.accept(playable);
}
// Check and add targets.
L2World.getInstance().forEachVisibleObjectInRange(playable, L2Playable.class, affectRange, c ->
{
if (filter.test(c))
{
action.accept(c);
}
});
}
}
@Override
public Enum<AffectScope> getAffectScopeType()
{
return AffectScope.PLEDGE;
}
}

View File

@@ -0,0 +1,112 @@
/*
* 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.targethandlers.affectscope;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.handler.AffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectScopeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
/**
* Point Blank affect scope implementation. Gathers targets in specific radius except initial target.
* @author Nik
*/
public class PointBlank implements IAffectScopeHandler
{
@Override
public void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action)
{
final IAffectObjectHandler affectObject = AffectObjectHandler.getInstance().getHandler(skill.getAffectObject());
final int affectRange = skill.getAffectRange();
final int affectLimit = skill.getAffectLimit();
// Target checks.
final AtomicInteger affected = new AtomicInteger(0);
final Predicate<L2Character> filter = c ->
{
if ((affectLimit > 0) && (affected.get() >= affectLimit))
{
return false;
}
if (c.isDead())
{
return false;
}
if ((affectObject != null) && !affectObject.checkAffectedObject(activeChar, c))
{
return false;
}
if (!GeoData.getInstance().canSeeTarget(target, c))
{
return false;
}
affected.incrementAndGet();
return true;
};
// Check and add targets.
if (skill.getTargetType() == TargetType.GROUND)
{
if (activeChar.isPlayable())
{
final Location worldPosition = activeChar.getActingPlayer().getCurrentSkillWorldPosition();
if (worldPosition != null)
{
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2Character.class, (int) (affectRange + activeChar.calculateDistance(worldPosition, false, false)), c ->
{
if (!c.isInsideRadius(worldPosition, affectRange, true, true))
{
return;
}
if (filter.test(c))
{
action.accept(c);
}
});
}
}
}
else
{
L2World.getInstance().forEachVisibleObjectInRange(target, L2Character.class, affectRange, c ->
{
if (filter.test(c))
{
action.accept(c);
}
});
}
}
@Override
public Enum<AffectScope> getAffectScopeType()
{
return AffectScope.POINT_BLANK;
}
}

View File

@@ -0,0 +1,122 @@
/*
* 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.targethandlers.affectscope;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.handler.AffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectScopeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
/**
* Range affect scope implementation. Gathers objects in area of target origin (including origin itself).
* @author Nik
*/
public class Range implements IAffectScopeHandler
{
@Override
public void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action)
{
final IAffectObjectHandler affectObject = AffectObjectHandler.getInstance().getHandler(skill.getAffectObject());
final int affectRange = skill.getAffectRange();
final int affectLimit = skill.getAffectLimit();
// Target checks.
final AtomicInteger affected = new AtomicInteger(0);
final Predicate<L2Character> filter = c ->
{
if ((affectLimit > 0) && (affected.get() >= affectLimit))
{
return false;
}
if (c.isDead())
{
return false;
}
if ((c == activeChar) && (target != activeChar)) // Range skills appear to not affect you unless you are the main target.
{
return false;
}
if ((affectObject != null) && !affectObject.checkAffectedObject(activeChar, c))
{
return false;
}
if (!GeoData.getInstance().canSeeTarget(target, c))
{
return false;
}
affected.incrementAndGet();
return true;
};
// Check and add targets.
if (skill.getTargetType() == TargetType.GROUND)
{
if (activeChar.isPlayable())
{
final Location worldPosition = activeChar.getActingPlayer().getCurrentSkillWorldPosition();
if (worldPosition != null)
{
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2Character.class, (int) (affectRange + activeChar.calculateDistance(worldPosition, false, false)), c ->
{
if (!c.isInsideRadius(worldPosition, affectRange, true, true))
{
return;
}
if (filter.test(c))
{
action.accept(c);
}
});
}
}
}
else
{
// Add object of origin since its skipped in the forEachVisibleObjectInRange method.
if (target.isCharacter() && filter.test((L2Character) target))
{
action.accept(target);
}
L2World.getInstance().forEachVisibleObjectInRange(target, L2Character.class, affectRange, c ->
{
if (filter.test(c))
{
action.accept(c);
}
});
}
}
@Override
public Enum<AffectScope> getAffectScopeType()
{
return AffectScope.RANGE;
}
}

View File

@@ -0,0 +1,98 @@
/*
* 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.targethandlers.affectscope;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import com.l2jmobius.gameserver.handler.AffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectScopeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
/**
* Range sorted by lowest to highest hp percent affect scope implementation.
* @author Nik
*/
public class RangeSortByHp implements IAffectScopeHandler
{
@Override
public void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action)
{
final IAffectObjectHandler affectObject = AffectObjectHandler.getInstance().getHandler(skill.getAffectObject());
final int affectRange = skill.getAffectRange();
final int affectLimit = skill.getAffectLimit();
// Target checks.
final AtomicInteger affected = new AtomicInteger(0);
final Predicate<L2Character> filter = c ->
{
if ((affectLimit > 0) && (affected.get() >= affectLimit))
{
return false;
}
if (c.isDead())
{
return false;
}
// Range skills appear to not affect you unless you are the main target.
if ((c == activeChar) && (target != activeChar))
{
return false;
}
if ((affectObject != null) && !affectObject.checkAffectedObject(activeChar, c))
{
return false;
}
affected.incrementAndGet();
return true;
};
final List<L2Character> result = L2World.getInstance().getVisibleObjects(target, L2Character.class, affectRange, filter);
// Add object of origin since its skipped in the getVisibleObjects method.
if (target.isCharacter() && filter.test((L2Character) target))
{
result.add((L2Character) target);
}
// Sort from lowest hp to highest hp.
//@formatter:off
result.stream()
.sorted(Comparator.comparingInt(L2Character::getCurrentHpPercent))
.limit(affectLimit > 0 ? affectLimit : Long.MAX_VALUE)
.forEach(action);
//@formatter:on
}
@Override
public Enum<AffectScope> getAffectScopeType()
{
return AffectScope.RANGE_SORT_BY_HP;
}
}

View File

@@ -0,0 +1,96 @@
/*
* 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.targethandlers.affectscope;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.handler.AffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectScopeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
/**
* Ring Range affect scope implementation. Gathers objects in ring/donut shaped area with start and end range.
* @author Nik
*/
public class RingRange implements IAffectScopeHandler
{
@Override
public void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action)
{
final IAffectObjectHandler affectObject = AffectObjectHandler.getInstance().getHandler(skill.getAffectObject());
final int affectRange = skill.getAffectRange();
final int affectLimit = skill.getAffectLimit();
final int startRange = skill.getFanRange()[2];
// Target checks.
final AtomicInteger affected = new AtomicInteger(0);
final Predicate<L2Character> filter = c ->
{
if ((affectLimit > 0) && (affected.get() >= affectLimit))
{
return false;
}
if (c.isDead())
{
return false;
}
// Targets before the start range are unaffected.
if (c.isInsideRadius(target, startRange, false, true))
{
return false;
}
if ((affectObject != null) && !affectObject.checkAffectedObject(activeChar, c))
{
return false;
}
if (!GeoData.getInstance().canSeeTarget(target, c))
{
return false;
}
affected.incrementAndGet();
return true;
};
// Check and add targets.
L2World.getInstance().forEachVisibleObjectInRange(target, L2Character.class, affectRange, c ->
{
if (filter.test(c))
{
action.accept(c);
}
});
}
@Override
public Enum<AffectScope> getAffectScopeType()
{
return AffectScope.RING_RANGE;
}
}

View File

@@ -0,0 +1,63 @@
/*
* 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.targethandlers.affectscope;
import java.util.function.Consumer;
import com.l2jmobius.gameserver.handler.AffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectScopeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
/**
* Single target affect scope implementation.
* @author Nik
*/
public class Single implements IAffectScopeHandler
{
@Override
public void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action)
{
final IAffectObjectHandler affectObject = AffectObjectHandler.getInstance().getHandler(skill.getAffectObject());
if (target.isCharacter())
{
if (skill.getTargetType() == TargetType.GROUND)
{
action.accept(activeChar); // Return yourself to mark that effects can use your current skill's world position.
}
if (((affectObject == null) || affectObject.checkAffectedObject(activeChar, (L2Character) target)))
{
action.accept(target); // Return yourself to mark that effects can use your current skill's world position.
}
}
else if (target.isItem())
{
action.accept(target); // Return yourself to mark that effects can use your current skill's world position.
}
}
@Override
public Enum<AffectScope> getAffectScopeType()
{
return AffectScope.SINGLE;
}
}

View File

@@ -0,0 +1,113 @@
/*
* 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.targethandlers.affectscope;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.handler.AffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectScopeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
import com.l2jmobius.gameserver.util.Util;
/**
* Square affect scope implementation (actually more like a rectangle).
* @author Nik
*/
public class Square implements IAffectScopeHandler
{
@Override
public void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action)
{
final IAffectObjectHandler affectObject = AffectObjectHandler.getInstance().getHandler(skill.getAffectObject());
final int squareStartAngle = skill.getFanRange()[1];
final int squareLength = skill.getFanRange()[2];
final int squareWidth = skill.getFanRange()[3];
final int radius = (int) Math.sqrt((squareLength * squareLength) + (squareWidth * squareWidth));
final int affectLimit = skill.getAffectLimit();
final int rectX = activeChar.getX();
final int rectY = activeChar.getY() - (squareWidth / 2);
final double heading = Math.toRadians(squareStartAngle + Util.convertHeadingToDegree(activeChar.getHeading()));
final double cos = Math.cos(-heading);
final double sin = Math.sin(-heading);
// Target checks.
final AtomicInteger affected = new AtomicInteger(0);
final Predicate<L2Character> filter = c ->
{
if ((affectLimit > 0) && (affected.get() >= affectLimit))
{
return false;
}
if (c.isDead())
{
return false;
}
// Check if inside square.
final int xp = c.getX() - activeChar.getX();
final int yp = c.getY() - activeChar.getY();
final int xr = (int) ((activeChar.getX() + (xp * cos)) - (yp * sin));
final int yr = (int) (activeChar.getY() + (xp * sin) + (yp * cos));
if ((xr > rectX) && (xr < (rectX + squareLength)) && (yr > rectY) && (yr < (rectY + squareWidth)))
{
if ((affectObject != null) && !affectObject.checkAffectedObject(activeChar, c))
{
return false;
}
if (!GeoData.getInstance().canSeeTarget(activeChar, c))
{
return false;
}
affected.incrementAndGet();
return true;
}
return false;
};
// Add object of origin since its skipped in the forEachVisibleObjectInRange method.
if (target.isCharacter() && filter.test((L2Character) target))
{
action.accept(target);
}
// Check and add targets.
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2Character.class, radius, c ->
{
if (filter.test(c))
{
action.accept(c);
}
});
}
@Override
public Enum<AffectScope> getAffectScopeType()
{
return AffectScope.SQUARE;
}
}

View File

@@ -0,0 +1,107 @@
/*
* 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.targethandlers.affectscope;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.handler.AffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectScopeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
import com.l2jmobius.gameserver.util.Util;
/**
* Square point blank affect scope implementation (actually more like a rectangle). Gathers objects around yourself except target itself.
* @author Nik
*/
public class SquarePB implements IAffectScopeHandler
{
@Override
public void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action)
{
final IAffectObjectHandler affectObject = AffectObjectHandler.getInstance().getHandler(skill.getAffectObject());
final int squareStartAngle = skill.getFanRange()[1];
final int squareLength = skill.getFanRange()[2];
final int squareWidth = skill.getFanRange()[3];
final int radius = (int) Math.sqrt((squareLength * squareLength) + (squareWidth * squareWidth));
final int affectLimit = skill.getAffectLimit();
final int rectX = activeChar.getX();
final int rectY = activeChar.getY() - (squareWidth / 2);
final double heading = Math.toRadians(squareStartAngle + Util.convertHeadingToDegree(activeChar.getHeading()));
final double cos = Math.cos(-heading);
final double sin = Math.sin(-heading);
// Target checks.
final AtomicInteger affected = new AtomicInteger(0);
final Predicate<L2Character> filter = c ->
{
if ((affectLimit > 0) && (affected.get() >= affectLimit))
{
return false;
}
if (c.isDead())
{
return false;
}
// Check if inside square.
final int xp = c.getX() - activeChar.getX();
final int yp = c.getY() - activeChar.getY();
final int xr = (int) ((activeChar.getX() + (xp * cos)) - (yp * sin));
final int yr = (int) (activeChar.getY() + (xp * sin) + (yp * cos));
if ((xr > rectX) && (xr < (rectX + squareLength)) && (yr > rectY) && (yr < (rectY + squareWidth)))
{
if ((affectObject != null) && !affectObject.checkAffectedObject(activeChar, c))
{
return false;
}
if (!GeoData.getInstance().canSeeTarget(activeChar, c))
{
return false;
}
affected.incrementAndGet();
return true;
}
return false;
};
// Check and add targets.
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2Character.class, radius, c ->
{
if (filter.test(c))
{
action.accept(c);
}
});
}
@Override
public Enum<AffectScope> getAffectScopeType()
{
return AffectScope.SQUARE_PB;
}
}

View File

@@ -0,0 +1,95 @@
/*
* 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.targethandlers.affectscope;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import com.l2jmobius.gameserver.handler.AffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectScopeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2StaticObjectInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
/**
* Static Object affect scope implementation. Used to detect hidden doors.
* @author Nik
*/
public class StaticObjectScope implements IAffectScopeHandler
{
@Override
public void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action)
{
final IAffectObjectHandler affectObject = AffectObjectHandler.getInstance().getHandler(skill.getAffectObject());
final int affectRange = skill.getAffectRange();
final int affectLimit = skill.getAffectLimit();
// Target checks.
final AtomicInteger affected = new AtomicInteger(0);
final Predicate<L2Character> filter = c ->
{
if ((affectLimit > 0) && (affected.get() >= affectLimit))
{
return false;
}
if (c.isDead())
{
return false;
}
if (!(c instanceof L2DoorInstance) && !(c instanceof L2StaticObjectInstance))
{
return false;
}
if ((affectObject != null) && !affectObject.checkAffectedObject(activeChar, c))
{
return false;
}
affected.incrementAndGet();
return true;
};
// Add object of origin since its skipped in the forEachVisibleObjectInRange method.
if (target.isCharacter() && filter.test((L2Character) target))
{
action.accept(target);
}
// Check and add targets.
L2World.getInstance().forEachVisibleObjectInRange(target, L2Character.class, affectRange, c ->
{
if (filter.test(c))
{
action.accept(c);
}
});
}
@Override
public Enum<AffectScope> getAffectScopeType()
{
return AffectScope.STATIC_OBJECT_SCOPE;
}
}

View File

@@ -0,0 +1,62 @@
/*
* 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.targethandlers.affectscope;
import java.util.function.Consumer;
import com.l2jmobius.gameserver.handler.AffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectObjectHandler;
import com.l2jmobius.gameserver.handler.IAffectScopeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
import com.l2jmobius.gameserver.util.Util;
/**
* @author Nik
*/
public class SummonExceptMaster implements IAffectScopeHandler
{
@Override
public void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action)
{
final IAffectObjectHandler affectObject = AffectObjectHandler.getInstance().getHandler(skill.getAffectObject());
final int affectRange = skill.getAffectRange();
final int affectLimit = skill.getAffectLimit();
if (target.isPlayable())
{
final L2PcInstance player = target.getActingPlayer();
//@formatter:off
player.getServitorsAndPets().stream()
.filter(c -> !c.isDead())
.filter(c -> affectRange > 0 ? Util.checkIfInRange(affectRange, c, target, true) : true)
.filter(c -> (affectObject == null) || affectObject.checkAffectedObject(activeChar, c))
.limit(affectLimit > 0 ? affectLimit : Long.MAX_VALUE)
.forEach(action);
//@formatter:on
}
}
@Override
public Enum<AffectScope> getAffectScopeType()
{
return AffectScope.SUMMON_EXCEPT_MASTER;
}
}

View File

@@ -0,0 +1,44 @@
/*
* 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.targethandlers.affectscope;
import java.util.function.Consumer;
import com.l2jmobius.gameserver.handler.IAffectScopeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
/**
* TODO: Wyvern affect scope.
* @author Nik
*/
public class WyvernScope implements IAffectScopeHandler
{
@Override
public void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action)
{
// TODO Unknown affect scope.
}
@Override
public Enum<AffectScope> getAffectScopeType()
{
return AffectScope.WYVERN_SCOPE;
}
}