Orfen AI and grandboss SQL adjustments.
Contributed by nasseka.
This commit is contained in:
		@@ -13,12 +13,12 @@ CREATE TABLE IF NOT EXISTS `grandboss_data` (
 | 
			
		||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
 | 
			
		||||
 | 
			
		||||
INSERT IGNORE INTO `grandboss_data` (`boss_id`,`loc_x`,`loc_y`,`loc_z`,`heading`,`currentHP`,`currentMP`) VALUES
 | 
			
		||||
(29001, -21610, 181594, -5734, 0, 229898.48, 667.776), -- Queen Ant
 | 
			
		||||
(29001, 93069, 8925, -3904, 0, 229898.48, 667.776), -- Queen Ant
 | 
			
		||||
(29006, 17726, 108915, -6480, 0, 622493.58388, 3793.536), -- Core
 | 
			
		||||
(29014, 55024, 17368, -5412, 10126, 622493.58388, 3793.536), -- Orfen
 | 
			
		||||
(29014, 64418, 29467, -3792, 10126, 622493.58388, 3793.536), -- Orfen
 | 
			
		||||
(29020, 116033, 17447, 10107, -25348, 4068372, 39960), -- Baium
 | 
			
		||||
(29022, 52207, 217230, -3341, 0, 28531442, 12240), -- Zaken
 | 
			
		||||
-- (29028, -105200, -253104, -15264, 0, 62041918, 2248572), -- Valakas
 | 
			
		||||
(29068, 185708, 114298, -8221,32768, 62802301, 1998000); -- Antharas
 | 
			
		||||
-- (25286, 185080, -12613, -5499, 16550, 556345880, 86847), -- Anakim
 | 
			
		||||
-- (25283, 185062, -9605, -5499, 15640, 486021997, 79600), -- Lilith
 | 
			
		||||
-- (25286, -6675, 18505, -5488, 16550, 556345880, 86847), -- Anakim
 | 
			
		||||
-- (25283, 185059, -9610, -5488, 15640, 486021997, 79600), -- Lilith
 | 
			
		||||
 
 | 
			
		||||
@@ -16,14 +16,10 @@
 | 
			
		||||
 */
 | 
			
		||||
package ai.bosses.Orfen;
 | 
			
		||||
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
import java.util.concurrent.ConcurrentHashMap;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.Config;
 | 
			
		||||
import org.l2jmobius.gameserver.ai.CtrlIntention;
 | 
			
		||||
import org.l2jmobius.gameserver.enums.ChatType;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
 | 
			
		||||
import org.l2jmobius.gameserver.model.Location;
 | 
			
		||||
import org.l2jmobius.gameserver.model.Spawn;
 | 
			
		||||
import org.l2jmobius.gameserver.model.StatSet;
 | 
			
		||||
@@ -35,8 +31,6 @@ import org.l2jmobius.gameserver.model.actor.Player;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.instance.GrandBoss;
 | 
			
		||||
import org.l2jmobius.gameserver.model.holders.SkillHolder;
 | 
			
		||||
import org.l2jmobius.gameserver.model.skill.Skill;
 | 
			
		||||
import org.l2jmobius.gameserver.model.skill.SkillCaster;
 | 
			
		||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
 | 
			
		||||
import org.l2jmobius.gameserver.network.NpcStringId;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.PlaySound;
 | 
			
		||||
 | 
			
		||||
@@ -44,17 +38,11 @@ import ai.AbstractNpcAI;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Orfen's AI
 | 
			
		||||
 * @author Emperorc
 | 
			
		||||
 * @author Emperorc, NasSeKa
 | 
			
		||||
 */
 | 
			
		||||
public class Orfen extends AbstractNpcAI
 | 
			
		||||
{
 | 
			
		||||
	private static final Location[] POS =
 | 
			
		||||
	{
 | 
			
		||||
		new Location(43728, 17220, -4342),
 | 
			
		||||
		new Location(55024, 17368, -5412),
 | 
			
		||||
		new Location(53504, 21248, -5486),
 | 
			
		||||
		new Location(53248, 24576, -5262)
 | 
			
		||||
	};
 | 
			
		||||
	private static final Location POS = new Location(64418, 29467, -3792);
 | 
			
		||||
	
 | 
			
		||||
	private static final NpcStringId[] TEXT =
 | 
			
		||||
	{
 | 
			
		||||
@@ -65,33 +53,15 @@ public class Orfen extends AbstractNpcAI
 | 
			
		||||
	};
 | 
			
		||||
	
 | 
			
		||||
	private static final int ORFEN = 29014;
 | 
			
		||||
	// private static final int RAIKEL = 29015;
 | 
			
		||||
	private static final int RAIKEL_LEOS = 29016;
 | 
			
		||||
	// private static final int RIBA = 29017;
 | 
			
		||||
	private static final int RIBA_IREN = 29018;
 | 
			
		||||
	
 | 
			
		||||
	private static final byte ALIVE = 0;
 | 
			
		||||
	private static final byte DEAD = 1;
 | 
			
		||||
	
 | 
			
		||||
	private static final SkillHolder PARALYSIS = new SkillHolder(4064, 1);
 | 
			
		||||
	private static final SkillHolder BLOW = new SkillHolder(4067, 4);
 | 
			
		||||
	private static final SkillHolder ORFEN_HEAL = new SkillHolder(4516, 1);
 | 
			
		||||
	
 | 
			
		||||
	private static boolean _isTeleported;
 | 
			
		||||
	private static Set<Attackable> _minions = ConcurrentHashMap.newKeySet();
 | 
			
		||||
	private static ZoneType _zone;
 | 
			
		||||
	
 | 
			
		||||
	private Orfen()
 | 
			
		||||
	{
 | 
			
		||||
		final int[] mobs =
 | 
			
		||||
		{
 | 
			
		||||
			ORFEN,
 | 
			
		||||
			RAIKEL_LEOS,
 | 
			
		||||
			RIBA_IREN
 | 
			
		||||
		};
 | 
			
		||||
		registerMobs(mobs);
 | 
			
		||||
		_isTeleported = false;
 | 
			
		||||
		_zone = ZoneManager.getInstance().getZoneById(12013);
 | 
			
		||||
		registerMobs(ORFEN);
 | 
			
		||||
		final StatSet info = GrandBossManager.getInstance().getStatSet(ORFEN);
 | 
			
		||||
		final int status = GrandBossManager.getInstance().getStatus(ORFEN);
 | 
			
		||||
		if (status == DEAD)
 | 
			
		||||
@@ -107,21 +77,7 @@ public class Orfen extends AbstractNpcAI
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				// the time has already expired while the server was offline. Immediately spawn Orfen.
 | 
			
		||||
				final int i = getRandom(10);
 | 
			
		||||
				Location loc;
 | 
			
		||||
				if (i < 4)
 | 
			
		||||
				{
 | 
			
		||||
					loc = POS[1];
 | 
			
		||||
				}
 | 
			
		||||
				else if (i < 7)
 | 
			
		||||
				{
 | 
			
		||||
					loc = POS[2];
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					loc = POS[3];
 | 
			
		||||
				}
 | 
			
		||||
				final GrandBoss orfen = (GrandBoss) addSpawn(ORFEN, loc, false, 0);
 | 
			
		||||
				final GrandBoss orfen = (GrandBoss) addSpawn(ORFEN, POS, false, 0);
 | 
			
		||||
				GrandBossManager.getInstance().setStatus(ORFEN, ALIVE);
 | 
			
		||||
				spawnBoss(orfen);
 | 
			
		||||
			}
 | 
			
		||||
@@ -145,8 +101,8 @@ public class Orfen extends AbstractNpcAI
 | 
			
		||||
		((Attackable) npc).clearAggroList();
 | 
			
		||||
		npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null, null);
 | 
			
		||||
		final Spawn spawn = npc.getSpawn();
 | 
			
		||||
		spawn.setLocation(POS[index]);
 | 
			
		||||
		npc.teleToLocation(POS[index], false);
 | 
			
		||||
		spawn.setLocation(POS);
 | 
			
		||||
		npc.teleToLocation(POS, false);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void spawnBoss(GrandBoss npc)
 | 
			
		||||
@@ -154,23 +110,6 @@ public class Orfen extends AbstractNpcAI
 | 
			
		||||
		GrandBossManager.getInstance().addBoss(npc);
 | 
			
		||||
		npc.broadcastPacket(new PlaySound(1, "BS01_A", 1, npc.getObjectId(), npc.getX(), npc.getY(), npc.getZ()));
 | 
			
		||||
		startQuestTimer("check_orfen_pos", 10000, npc, null, true);
 | 
			
		||||
		// Spawn minions
 | 
			
		||||
		final int x = npc.getX();
 | 
			
		||||
		final int y = npc.getY();
 | 
			
		||||
		Attackable mob;
 | 
			
		||||
		mob = (Attackable) addSpawn(RAIKEL_LEOS, x + 100, y + 100, npc.getZ(), 0, false, 0);
 | 
			
		||||
		mob.setIsRaidMinion(true);
 | 
			
		||||
		_minions.add(mob);
 | 
			
		||||
		mob = (Attackable) addSpawn(RAIKEL_LEOS, x + 100, y - 100, npc.getZ(), 0, false, 0);
 | 
			
		||||
		mob.setIsRaidMinion(true);
 | 
			
		||||
		_minions.add(mob);
 | 
			
		||||
		mob = (Attackable) addSpawn(RAIKEL_LEOS, x - 100, y + 100, npc.getZ(), 0, false, 0);
 | 
			
		||||
		mob.setIsRaidMinion(true);
 | 
			
		||||
		_minions.add(mob);
 | 
			
		||||
		mob = (Attackable) addSpawn(RAIKEL_LEOS, x - 100, y - 100, npc.getZ(), 0, false, 0);
 | 
			
		||||
		mob.setIsRaidMinion(true);
 | 
			
		||||
		_minions.add(mob);
 | 
			
		||||
		startQuestTimer("check_minion_loc", 10000, npc, null, true);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
@@ -178,62 +117,10 @@ public class Orfen extends AbstractNpcAI
 | 
			
		||||
	{
 | 
			
		||||
		if (event.equalsIgnoreCase("orfen_unlock"))
 | 
			
		||||
		{
 | 
			
		||||
			final int i = getRandom(10);
 | 
			
		||||
			Location loc;
 | 
			
		||||
			if (i < 4)
 | 
			
		||||
			{
 | 
			
		||||
				loc = POS[1];
 | 
			
		||||
			}
 | 
			
		||||
			else if (i < 7)
 | 
			
		||||
			{
 | 
			
		||||
				loc = POS[2];
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				loc = POS[3];
 | 
			
		||||
			}
 | 
			
		||||
			final GrandBoss orfen = (GrandBoss) addSpawn(ORFEN, loc, false, 0);
 | 
			
		||||
			final GrandBoss orfen = (GrandBoss) addSpawn(ORFEN, POS, false, 0);
 | 
			
		||||
			GrandBossManager.getInstance().setStatus(ORFEN, ALIVE);
 | 
			
		||||
			spawnBoss(orfen);
 | 
			
		||||
		}
 | 
			
		||||
		else if (event.equalsIgnoreCase("check_orfen_pos"))
 | 
			
		||||
		{
 | 
			
		||||
			if ((_isTeleported && (npc.getCurrentHp() > (npc.getMaxHp() * 0.95))) || (!_zone.isInsideZone(npc) && !_isTeleported))
 | 
			
		||||
			{
 | 
			
		||||
				setSpawnPoint(npc, getRandom(3) + 1);
 | 
			
		||||
				_isTeleported = false;
 | 
			
		||||
			}
 | 
			
		||||
			else if (_isTeleported && !_zone.isInsideZone(npc))
 | 
			
		||||
			{
 | 
			
		||||
				setSpawnPoint(npc, 0);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else if (event.equalsIgnoreCase("check_minion_loc"))
 | 
			
		||||
		{
 | 
			
		||||
			for (Attackable mob : _minions)
 | 
			
		||||
			{
 | 
			
		||||
				if (!npc.isInsideRadius2D(mob, 3000))
 | 
			
		||||
				{
 | 
			
		||||
					mob.teleToLocation(npc.getLocation());
 | 
			
		||||
					((Attackable) npc).clearAggroList();
 | 
			
		||||
					npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null, null);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else if (event.equalsIgnoreCase("despawn_minions"))
 | 
			
		||||
		{
 | 
			
		||||
			for (Attackable mob : _minions)
 | 
			
		||||
			{
 | 
			
		||||
				mob.decayMe();
 | 
			
		||||
			}
 | 
			
		||||
			_minions.clear();
 | 
			
		||||
		}
 | 
			
		||||
		else if (event.equalsIgnoreCase("spawn_minion"))
 | 
			
		||||
		{
 | 
			
		||||
			final Attackable mob = (Attackable) addSpawn(RAIKEL_LEOS, npc.getX(), npc.getY(), npc.getZ(), 0, false, 0);
 | 
			
		||||
			mob.setIsRaidMinion(true);
 | 
			
		||||
			_minions.add(mob);
 | 
			
		||||
		}
 | 
			
		||||
		return super.onAdvEvent(event, npc, player);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
@@ -254,49 +141,13 @@ public class Orfen extends AbstractNpcAI
 | 
			
		||||
		return super.onSkillSee(npc, caster, skill, targets, isSummon);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public String onFactionCall(Npc npc, Npc caller, Player attacker, boolean isSummon)
 | 
			
		||||
	{
 | 
			
		||||
		if ((caller == null) || (npc == null) || npc.isCastingNow(SkillCaster::isAnyNormalType))
 | 
			
		||||
		{
 | 
			
		||||
			return super.onFactionCall(npc, caller, attacker, isSummon);
 | 
			
		||||
		}
 | 
			
		||||
		final int npcId = npc.getId();
 | 
			
		||||
		final int callerId = caller.getId();
 | 
			
		||||
		if ((npcId == RAIKEL_LEOS) && (getRandom(20) == 0))
 | 
			
		||||
		{
 | 
			
		||||
			npc.setTarget(attacker);
 | 
			
		||||
			npc.doCast(BLOW.getSkill());
 | 
			
		||||
		}
 | 
			
		||||
		else if (npcId == RIBA_IREN)
 | 
			
		||||
		{
 | 
			
		||||
			int chance = 1;
 | 
			
		||||
			if (callerId == ORFEN)
 | 
			
		||||
			{
 | 
			
		||||
				chance = 9;
 | 
			
		||||
			}
 | 
			
		||||
			if ((callerId != RIBA_IREN) && (caller.getCurrentHp() < (caller.getMaxHp() / 2.0)) && (getRandom(10) < chance))
 | 
			
		||||
			{
 | 
			
		||||
				npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null, null);
 | 
			
		||||
				npc.setTarget(caller);
 | 
			
		||||
				npc.doCast(ORFEN_HEAL.getSkill());
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return super.onFactionCall(npc, caller, attacker, isSummon);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public String onAttack(Npc npc, Player attacker, int damage, boolean isSummon)
 | 
			
		||||
	{
 | 
			
		||||
		final int npcId = npc.getId();
 | 
			
		||||
		if (npcId == ORFEN)
 | 
			
		||||
		{
 | 
			
		||||
			if (!_isTeleported && ((npc.getCurrentHp() - damage) < (npc.getMaxHp() / 4)))
 | 
			
		||||
			{
 | 
			
		||||
				_isTeleported = true;
 | 
			
		||||
				setSpawnPoint(npc, 0);
 | 
			
		||||
			}
 | 
			
		||||
			else if (npc.isInsideRadius2D(attacker, 1000) && !npc.isInsideRadius2D(attacker, 300) && (getRandom(10) == 0))
 | 
			
		||||
			if (npc.isInsideRadius2D(attacker, 1000) && !npc.isInsideRadius2D(attacker, 300) && (getRandom(10) == 0))
 | 
			
		||||
			{
 | 
			
		||||
				npc.broadcastSay(ChatType.NPC_GENERAL, TEXT[getRandom(3)], attacker.getName());
 | 
			
		||||
				attacker.teleToLocation(npc.getLocation());
 | 
			
		||||
@@ -304,14 +155,6 @@ public class Orfen extends AbstractNpcAI
 | 
			
		||||
				npc.doCast(PARALYSIS.getSkill());
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else if (npcId == RIBA_IREN)
 | 
			
		||||
		{
 | 
			
		||||
			if (!npc.isCastingNow(SkillCaster::isAnyNormalType) && ((npc.getCurrentHp() - damage) < (npc.getMaxHp() / 2.0)))
 | 
			
		||||
			{
 | 
			
		||||
				npc.setTarget(attacker);
 | 
			
		||||
				npc.doCast(ORFEN_HEAL.getSkill());
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return super.onAttack(npc, attacker, damage, isSummon);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
@@ -330,15 +173,7 @@ public class Orfen extends AbstractNpcAI
 | 
			
		||||
			final StatSet info = GrandBossManager.getInstance().getStatSet(ORFEN);
 | 
			
		||||
			info.set("respawn_time", System.currentTimeMillis() + respawnTime);
 | 
			
		||||
			GrandBossManager.getInstance().setStatSet(ORFEN, info);
 | 
			
		||||
			cancelQuestTimer("check_minion_loc", npc, null);
 | 
			
		||||
			cancelQuestTimer("check_orfen_pos", npc, null);
 | 
			
		||||
			startQuestTimer("despawn_minions", 20000, null, null);
 | 
			
		||||
			cancelQuestTimers("spawn_minion");
 | 
			
		||||
		}
 | 
			
		||||
		else if ((GrandBossManager.getInstance().getStatus(ORFEN) == ALIVE) && (npc.getId() == RAIKEL_LEOS))
 | 
			
		||||
		{
 | 
			
		||||
			_minions.remove(npc);
 | 
			
		||||
			startQuestTimer("spawn_minion", 360000, npc, null);
 | 
			
		||||
		}
 | 
			
		||||
		return super.onKill(npc, killer, isSummon);
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -763,9 +763,6 @@
 | 
			
		||||
			<param name="MoveAroundSocial" value="80" />
 | 
			
		||||
			<param name="MoveAroundSocial1" value="80" />
 | 
			
		||||
			<param name="MoveAroundSocial2" value="80" />
 | 
			
		||||
			<minions name="Privates">
 | 
			
		||||
				<npc id="29016" count="4" respawnTime="360" weightPoint="1" />
 | 
			
		||||
			</minions>
 | 
			
		||||
		</parameters>
 | 
			
		||||
		<race>FAIRY</race>
 | 
			
		||||
		<sex>FEMALE</sex>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user