This commit is contained in:
mobius
2015-01-01 20:02:50 +00:00
parent eeae660458
commit a6a3718849
17894 changed files with 2818932 additions and 0 deletions

View File

@ -0,0 +1,118 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class Area implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
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;
}
int maxTargets = skill.getAffectLimit();
final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharacters();
for (L2Character obj : objs)
{
if (!(obj.isAttackable() || obj.isPlayable()))
{
continue;
}
if (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);
}
}
if (targetList.isEmpty())
{
return EMPTY_TARGET_LIST;
}
return targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.AREA;
}
}

View File

@ -0,0 +1,88 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.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);
}
if (targetList.isEmpty())
{
return EMPTY_TARGET_LIST;
}
return targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.AREA_CORPSE_MOB;
}
}

View File

@ -0,0 +1,156 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import com.l2jserver.Config;
import com.l2jserver.gameserver.GeoData;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2SiegeFlagInstance;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.gameserver.network.SystemMessageId;
/**
* @author Adry_85
*/
public class AreaFriendly implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
List<L2Character> targetList = new ArrayList<>();
if (!checkTarget(activeChar, target) && (skill.getCastRange() >= 0))
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return EMPTY_TARGET_LIST;
}
if (onlyFirst)
{
return new L2Character[]
{
target
};
}
if (activeChar.getActingPlayer().isInOlympiadMode())
{
return new L2Character[]
{
activeChar
};
}
targetList.add(target); // Add target to target list
if (target != null)
{
int maxTargets = skill.getAffectLimit();
final Collection<L2Character> objs = target.getKnownList().getKnownCharactersInRadius(skill.getAffectRange());
// TODO: Chain Heal - The recovery amount decreases starting from the most injured person.
Collections.sort(targetList, new CharComparator());
for (L2Character obj : objs)
{
if (!checkTarget(activeChar, obj) || (obj == activeChar))
{
continue;
}
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
}
targetList.add(obj);
}
}
if (targetList.isEmpty())
{
return EMPTY_TARGET_LIST;
}
return targetList.toArray(new L2Character[targetList.size()]);
}
private boolean checkTarget(L2Character activeChar, L2Character target)
{
if ((Config.GEODATA > 0) && !GeoData.getInstance().canSeeTarget(activeChar, target))
{
return false;
}
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())
{
if ((target != activeChar) && activeChar.isInParty() && target.isInParty())
{
return (activeChar.getParty().getLeader() == target.getParty().getLeader());
}
if ((activeChar.getClanId() != 0) && (target.getClanId() != 0))
{
return (activeChar.getClanId() == target.getClanId());
}
if ((activeChar.getAllyId() != 0) && (target.getAllyId() != 0))
{
return (activeChar.getAllyId() == target.getAllyId());
}
if ((target != activeChar) && (target.getActingPlayer().getPvpFlag() > 0))
{
return false;
}
}
return true;
}
public 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

@ -0,0 +1,103 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class AreaSummon implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
List<L2Character> targetList = new ArrayList<>();
target = activeChar.getSummon();
if ((target == null) || !target.isServitor() || target.isDead())
{
return EMPTY_TARGET_LIST;
}
if (onlyFirst)
{
return new L2Character[]
{
target
};
}
final boolean srcInArena = (activeChar.isInsideZone(ZoneId.PVP) && !activeChar.isInsideZone(ZoneId.SIEGE));
final Collection<L2Character> objs = target.getKnownList().getKnownCharacters();
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);
}
if (targetList.isEmpty())
{
return EMPTY_TARGET_LIST;
}
return targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.AREA_SUMMON;
}
}

View File

@ -0,0 +1,86 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.List;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.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())
{
final L2DoorInstance door = (L2DoorInstance) obj;
if (!door.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

@ -0,0 +1,71 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
/**
* @author UnAfraid
*/
public class AuraCorpseMob implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
List<L2Character> targetList = new ArrayList<>();
// Go through the L2Character _knownList
final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharactersInRadius(skill.getAffectRange());
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

@ -0,0 +1,123 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class BehindArea implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
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();
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);
}
}
if (targetList.isEmpty())
{
return EMPTY_TARGET_LIST;
}
return targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.BEHIND_AREA;
}
}

View File

@ -0,0 +1,83 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.gameserver.model.zone.ZoneId;
/**
* @author UnAfraid
*/
public class BehindAura implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
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());
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

@ -0,0 +1,182 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.L2ClanMember;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.TvTEvent;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class Clan implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
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.addSummon(activeChar, player, radius, false))
{
targetList.add(player.getSummon());
}
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 (!onlyFirst && Skill.addSummon(activeChar, obj, radius, false))
{
targetList.add(obj.getSummon());
}
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();
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

@ -0,0 +1,87 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class ClanMember implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
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

@ -0,0 +1,93 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.List;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Party;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.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.addSummon(activeChar, player, radius, false))
{
targetList.add(player.getSummon());
}
// 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
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

@ -0,0 +1,170 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.L2ClanMember;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.TvTEvent;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class CorpseClan implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
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();
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

@ -0,0 +1,67 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import com.l2jserver.Config;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Attackable;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.effects.L2EffectType;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.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;
}
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.gameserver.model.zone.ZoneId;
/**
* @author UnAfraid
*/
public class EnemySummon implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
if (target.isSummon())
{
L2Summon targetSummon = (L2Summon) target;
if ((activeChar.isPlayer() && (activeChar.getSummon() != targetSummon) && !targetSummon.isDead() && ((targetSummon.getOwner().getPvpFlag() != 0) || (targetSummon.getOwner().getKarma() > 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

@ -0,0 +1,51 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.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;
}
}

View File

@ -0,0 +1,123 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class FrontArea implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
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();
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);
}
}
if (targetList.isEmpty())
{
return EMPTY_TARGET_LIST;
}
return targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.FRONT_AREA;
}
}

View File

@ -0,0 +1,83 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.gameserver.model.zone.ZoneId;
/**
* @author UnAfraid
*/
public class FrontAura implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
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());
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

@ -0,0 +1,83 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.List;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.effects.L2EffectType;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.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())
{
if (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;
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2ArtefactInstance;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.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;
}
}

View File

@ -0,0 +1,55 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.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;
}
}

View File

@ -0,0 +1,55 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.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;
}
}

View File

@ -0,0 +1,96 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.List;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
/**
* @author UnAfraid
*/
public class Party implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
List<L2Character> targetList = new ArrayList<>();
if (onlyFirst)
{
return new L2Character[]
{
activeChar
};
}
targetList.add(activeChar);
final int radius = skill.getAffectRange();
L2PcInstance player = activeChar.getActingPlayer();
if (activeChar.isSummon())
{
if (Skill.addCharacter(activeChar, player, radius, false))
{
targetList.add(player);
}
}
else if (activeChar.isPlayer())
{
if (Skill.addSummon(activeChar, player, radius, false))
{
targetList.add(player.getSummon());
}
}
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.addSummon(activeChar, partyMember, radius, false))
{
targetList.add(partyMember.getSummon());
}
}
}
return targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.PARTY;
}
}

View File

@ -0,0 +1,164 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.TvTEvent;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
/**
* @author UnAfraid
*/
public class PartyClan implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
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.addSummon(activeChar, player, radius, false))
{
targetList.add(player.getSummon());
}
// 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);
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 (!onlyFirst && Skill.addSummon(activeChar, obj, radius, false))
{
targetList.add(obj.getSummon());
}
if (!Skill.addCharacter(activeChar, obj, radius, false))
{
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.PARTY_CLAN;
}
}

View File

@ -0,0 +1,59 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.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())
{
if ((target == activeChar) || (activeChar.isInParty() && target.isInParty() && (activeChar.getParty().getLeaderObjectId() == target.getParty().getLeaderObjectId())) || (activeChar.isPlayer() && target.isSummon() && (activeChar.getSummon() == target)) || (activeChar.isSummon() && target.isPlayer() && (activeChar == target.getSummon())))
{
return new L2Character[]
{
target
};
}
}
return EMPTY_TARGET_LIST;
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.PARTY_MEMBER;
}
}

View File

@ -0,0 +1,82 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.List;
import com.l2jserver.Config;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.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<>();
if (activeChar.getParty() != null)
{
final List<L2PcInstance> partyList = activeChar.getParty().getMembers();
for (L2PcInstance partyMember : partyList)
{
if ((partyMember == null) || partyMember.isDead())
{
continue;
}
else if (partyMember == activeChar)
{
continue;
}
else if (!Util.checkIfInRange(Config.ALT_PARTY_RANGE, activeChar, partyMember, true))
{
continue;
}
else if ((skill.getAffectRange() > 0) && !Util.checkIfInRange(skill.getAffectRange(), activeChar, partyMember, true))
{
continue;
}
else
{
targetList.add(partyMember);
if ((partyMember.getSummon() != null) && !partyMember.getSummon().isDead())
{
targetList.add(partyMember.getSummon());
}
}
}
}
return targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.PARTY_NOTME;
}
}

View File

@ -0,0 +1,81 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.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

@ -0,0 +1,116 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.List;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
import com.l2jserver.gameserver.model.effects.L2EffectType;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.network.SystemMessageId;
/**
* @author UnAfraid
*/
public class PcBody implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
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))
{
if (targetPlayer != null)
{
// check target is not in a active siege zone
if (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 L2Object[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;
}
}

View File

@ -0,0 +1,51 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.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)
{
if (activeChar.hasPet())
{
return new L2Character[]
{
activeChar.getSummon()
};
}
return EMPTY_TARGET_LIST;
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.PET;
}
}

View File

@ -0,0 +1,47 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.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;
}
}

View File

@ -0,0 +1,51 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.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.hasServitor())
{
return new L2Character[]
{
activeChar.getSummon()
};
}
return EMPTY_TARGET_LIST;
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.SERVITOR;
}
}

View File

@ -0,0 +1,51 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.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 new L2Character[]
{
activeChar.getSummon()
};
}
return EMPTY_TARGET_LIST;
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.SUMMON;
}
}

View File

@ -0,0 +1,84 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.List;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.gameserver.network.SystemMessageId;
/**
* @author St3eT
*/
public class TargetParty implements ITargetTypeHandler
{
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
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.addSummon(player, partyMember, radius, false))
{
targetList.add(partyMember.getSummon());
}
}
}
else
{
targetList.add(target);
}
return targetList.toArray(new L2Character[targetList.size()]);
}
@Override
public Enum<L2TargetType> getTargetType()
{
return L2TargetType.TARGET_PARTY;
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.targethandlers;
import com.l2jserver.gameserver.handler.ITargetTypeHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2ChestInstance;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.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;
}
}