Incubator of Evil initial commit.

This commit is contained in:
MobiusDev
2016-02-14 22:25:27 +00:00
parent 560576e2d4
commit 5d1e8973b1
23 changed files with 756 additions and 50 deletions

View File

@ -1,121 +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 instances.KartiasLabyrinth.AI;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2QuestGuardInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.util.Util;
import com.l2jmobius.util.Rnd;
/**
* @author Mobius
*/
public final class Fighter implements Runnable
{
private L2PcInstance _player;
private final L2QuestGuardInstance _guard;
private int _followRange = 150;
public Fighter(L2PcInstance player, L2QuestGuardInstance guard)
{
_player = player;
_guard = guard;
_guard.setIsRunning(true);
if (_guard.getSpawn() != null)
{
_guard.setSpawn(null);
}
}
public void setPlayer(L2PcInstance player)
{
_player = player;
}
public void setFollowRange(int range)
{
_followRange = range;
}
@Override
public void run()
{
// Schedule new task only when necessary.
if ((_guard == null) || _guard.isDead() || (_player == null))
{
return;
}
ThreadPoolManager.getInstance().scheduleGeneral(new Fighter(_player, _guard), _guard.isInCombat() ? 1000 : 3000);
// Guard is occupied. Use skills logic.
if (_guard.isInCombat())
{
if ((_guard.getTarget() != null) && _guard.getTarget().isMonster() && ((L2Character) _guard.getTarget()).isAlikeDead())
{
for (Skill skill : _guard.getSkills().values())
{
if (skill.isBad() && (skill.getCoolTime() <= 0) && !_guard.isCastingNow() && (_guard.calculateDistance(_guard.getTarget(), false, false) < skill.getCastRange()))
{
_guard.setHeading(Util.calculateHeadingFrom(_guard, _guard.getTarget()));
skill.activateSkill(_guard, _guard.getTarget());
break;
}
}
}
return; // Guard is occupied, no need to proceed.
}
// Assist combat logic.
if (_player.isInCombat() && (_player.getTarget() != null) && _player.getTarget().isMonster() && !_player.getTarget().isInvul() //
&& ((L2Character) _player.getTarget()).isInCombat() && !((L2Character) _player.getTarget()).isAlikeDead())
{
if (_guard.calculateDistance(_player.getTarget(), false, false) > 50)
{
_guard.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, _player.getTarget().getLocation());
}
else if (_guard.getTarget() != _player.getTarget())
{
_guard.addDamageHate((L2Character) _player.getTarget(), 0, 1000);
}
}
// Try to kill nearby monsters logic.
for (L2Character ch : _guard.getKnownList().getKnownCharacters())
{
if (ch.isMonster() && !ch.isInvul() && !ch.isAlikeDead())
{
_guard.addDamageHate(ch, 0, 1000);
break;
}
}
// Out of combat follow logic.
if (!_guard.isInCombat())
{
final int moveToLocX = _player.getLocation().getX() + Rnd.get((_followRange * -1), _followRange);
final int moveToLocY = _player.getLocation().getY() + Rnd.get((_followRange * -1), _followRange);
final int moveToLocZ = _player.getLocation().getZ();
final Location moveToLocation = new Location(moveToLocX, moveToLocY, moveToLocZ);
_guard.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, moveToLocation);
}
}
}

View File

@ -1,129 +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 instances.KartiasLabyrinth.AI;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2QuestGuardInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.util.Util;
import com.l2jmobius.util.Rnd;
/**
* @author Mobius
*/
final class Healer implements Runnable
{
private L2PcInstance _player;
private final L2QuestGuardInstance _guard;
private int _followRange = 200;
public Healer(L2PcInstance player, L2QuestGuardInstance guard)
{
_player = player;
_guard = guard;
_guard.setIsRunning(true);
if (_guard.getSpawn() != null)
{
_guard.setSpawn(null);
}
}
public void setPlayer(L2PcInstance player)
{
_player = player;
}
public void setFollowRange(int range)
{
_followRange = range;
}
@Override
public void run()
{
// Schedule new task only when necessary.
if ((_guard == null) || _guard.isDead() || (_player == null))
{
return;
}
ThreadPoolManager.getInstance().scheduleGeneral(new Healer(_player, _guard), _guard.isInCombat() ? 1000 : 3000);
// Guard is occupied. Use skills logic.
if (_guard.isInCombat())
{
L2PcInstance targetPlayer = null;
for (L2Character ch : _guard.getKnownList().getKnownCharacters())
{
if (ch.isPlayer() && !ch.isAlikeDead())
{
targetPlayer = (L2PcInstance) ch;
break;
}
}
for (Skill skill : _guard.getSkills().values())
{
if ((targetPlayer != null) && !targetPlayer.isAlikeDead() //
&& !skill.isBad() && !_guard.isCastingNow() && (_guard.calculateDistance(targetPlayer, false, false) < skill.getCastRange()))
{
_guard.setHeading(Util.calculateHeadingFrom(_guard, targetPlayer));
_guard.setTarget(targetPlayer);
skill.activateSkill(_guard, targetPlayer);
break;
}
}
return; // Guard is occupied, no need to proceed.
}
// Assist combat logic.
if (_player.isInCombat() && (_player.getTarget() != null) && _player.getTarget().isMonster() && !_player.getTarget().isInvul() //
&& ((L2Character) _player.getTarget()).isInCombat() && !((L2Character) _player.getTarget()).isAlikeDead())
{
if (_guard.calculateDistance(_player.getTarget(), false, false) > 50)
{
_guard.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, _player.getTarget().getLocation());
}
else if (_guard.getTarget() != _player.getTarget())
{
_guard.addDamageHate((L2Character) _player.getTarget(), 0, 1000);
}
}
// Try to kill nearby monsters logic.
for (L2Character ch : _guard.getKnownList().getKnownCharacters())
{
if (ch.isMonster() && !ch.isInvul() && !ch.isAlikeDead())
{
_guard.addDamageHate(ch, 0, 1000);
break;
}
}
// Out of combat follow logic.
if (!_guard.isInCombat())
{
final int moveToLocX = _player.getLocation().getX() + Rnd.get((_followRange * -1), _followRange);
final int moveToLocY = _player.getLocation().getY() + Rnd.get((_followRange * -1), _followRange);
final int moveToLocZ = _player.getLocation().getZ();
final Location moveToLocation = new Location(moveToLocX, moveToLocY, moveToLocZ);
_guard.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, moveToLocation);
}
}
}

View File

@ -23,6 +23,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.ai.npc.FighterAI;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Character;
@ -38,7 +39,6 @@ import com.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
import com.l2jmobius.gameserver.util.Util;
import instances.AbstractInstance;
import instances.KartiasLabyrinth.AI.Fighter;
import quests.Q00494_IncarnationOfGreedZellakaGroup.Q00494_IncarnationOfGreedZellakaGroup;
import quests.Q00495_IncarnationOfJealousyPellineGroup.Q00495_IncarnationOfJealousyPellineGroup;
import quests.Q00496_IncarnationOfGluttonyKaliosGroup.Q00496_IncarnationOfGluttonyKaliosGroup;
@ -831,23 +831,23 @@ public final class KartiasLabyrinth extends AbstractInstance
}
if (((KartiaWorld) world).adolph != null)
{
ThreadPoolManager.getInstance().scheduleGeneral(new Fighter(player, ((KartiaWorld) world).adolph), 1000);
ThreadPoolManager.getInstance().scheduleGeneral(new FighterAI(player, ((KartiaWorld) world).adolph), 1000);
}
if (((KartiaWorld) world).barton != null)
{
ThreadPoolManager.getInstance().scheduleGeneral(new Fighter(player, ((KartiaWorld) world).barton), 1000);
ThreadPoolManager.getInstance().scheduleGeneral(new FighterAI(player, ((KartiaWorld) world).barton), 1000);
}
if (((KartiaWorld) world).hayuk != null)
{
ThreadPoolManager.getInstance().scheduleGeneral(new Fighter(player, ((KartiaWorld) world).hayuk), 1000);
ThreadPoolManager.getInstance().scheduleGeneral(new FighterAI(player, ((KartiaWorld) world).hayuk), 1000);
}
if (((KartiaWorld) world).eliyah != null)
{
ThreadPoolManager.getInstance().scheduleGeneral(new Fighter(player, ((KartiaWorld) world).eliyah), 1000);
ThreadPoolManager.getInstance().scheduleGeneral(new FighterAI(player, ((KartiaWorld) world).eliyah), 1000);
}
if (((KartiaWorld) world).elise != null)
{
ThreadPoolManager.getInstance().scheduleGeneral(new Fighter(player, ((KartiaWorld) world).elise), 1000);
ThreadPoolManager.getInstance().scheduleGeneral(new FighterAI(player, ((KartiaWorld) world).elise), 1000);
}
((KartiaWorld) world).savedSpawns.addAll(spawnGroup("wave1", world.getInstanceId()));
startQuestTimer("checkStatus", 5000, null, player, true);