Balok AI.

Contributed by gigilo1968.
This commit is contained in:
MobiusDev
2017-01-15 18:06:50 +00:00
parent dc528f1936
commit a915abe001
8 changed files with 433 additions and 10 deletions

View File

@@ -1,4 +1,4 @@
<html><body>Crystal Prison Entrance Portal:<br>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest BaylorWarzone enterInstance">Enter Baylor Warzone</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h menu_select?ask=2423001&reply=2">Enter Balok Warzone</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest BalokWarzone enterInstance">Enter Balok Warzone</Button>
</body></html>

View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Balok Warzone -->
<instance id="167" maxWorlds="80" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../xsd/instance.xsd">
<time duration="60" empty="3" />
<removeBuffs type="ALL" />
<locations>
<enter type="FIXED">
<location x="153567" y="143319" z="-12736" />
</enter>
<exit type="ORIGIN" />
</locations>
<conditions>
<condition type="Party">
<param name="html" value="condNoParty.html" />
</condition>
<condition type="PartyLeader">
<param name="html" value="condNoPartyLeader.html" />
</condition>
<condition type="GroupMin">
<param name="limit" value="7" />
</condition>
<condition type="GroupMax">
<param name="limit" value="21" />
</condition>
<condition type="Level">
<param name="min" value="97" />
</condition>
<condition type="Distance" />
<condition type="Reenter" />
</conditions>
<reenter apply="NONE">
<reset day="MONDAY" hour="6" minute="30" />
<reset day="TUESDAY" hour="6" minute="30" />
<reset day="WEDNESDAY" hour="6" minute="30" />
<reset day="THURSDAY" hour="6" minute="30" />
<reset day="FRIDAY" hour="6" minute="30" />
<reset day="SATURDAY" hour="6" minute="30" />
<reset day="SUNDAY" hour="6" minute="30" />
</reenter>
<doorlist>
<door id="24220008">
<openStatus default="close" />
</door>
<door id="24220009" />
<door id="24220010" />
<door id="24220011" />
<door id="24220012" />
<door id="24220013" />
<door id="24220014" />
<door id="24220015" />
<door id="24220016" />
<door id="24220017" />
<door id="24220018" />
<door id="24220019" />
</doorlist>
<spawnlist>
<group>
<npc id="29106" x="153571" y="142858" z="-12736" heading="60000" /> <!-- Invicible Npc -->
</group>
</spawnlist>
</instance>

View File

@@ -0,0 +1,348 @@
/*
* 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 ai.bosses.Balok;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.enums.Movie;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.events.impl.character.OnCreatureSee;
import com.l2jmobius.gameserver.model.holders.SkillHolder;
import com.l2jmobius.gameserver.model.instancezone.Instance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import instances.AbstractInstance;
/**
* Baylor Warzone instance zone.
* @author LasTravel, Gigi
* @Video https://www.youtube.com/watch?v=w_-SNNPoulo&t=204s
*/
public final class BalokWarzone extends AbstractInstance
{
// NPCs
private static final int BALOK = 29218;
private static final int MINION = 23123;
private static final int HELL_DISCIPLE = 29219;
private static final int ENTRANCE_PORTAL = 33523;
private static final int INVISIBLE_NPC_1 = 29106;
private static final int BLUE_GRAVE = 19562; // TODO need find retail npc ID
// Item
private static final int PRISON_KEY = 10015;
// Skills
private static final SkillHolder DARKNESS_DRAIN = new SkillHolder(14367, 1);
private static final SkillHolder REAR_DESTROY = new SkillHolder(14576, 1);
private static final SkillHolder INVINCIBILITY_ACTIVATION = new SkillHolder(14190, 1);
private static final SkillHolder EARTH_DEMOLITION = new SkillHolder(14246, 1);
private static final SkillHolder IMPRISION = new SkillHolder(5226, 1);
// Misc
private static final int TEMPLATE_ID = 167;
//@formatter:off
private static final int[][] MINION_SPAWN =
{
{154592, 141488, -12738, 26941},
{154759, 142073, -12738, 32333},
{154158, 143112, -12738, 43737},
{152963, 143102, -12738, 53988},
{152360, 142067, -12740, 0},
{152530, 141457, -12740, 7246},
{153571, 140878, -12738, 16756},
{154174, 141057, -12738, 22165}
};
private static final int[][] PRISONS_SPAWN =
{
{154428, 140551, -12712},
{155061, 141204, -12704},
{155268, 142097, -12712},
{154438, 143581, -12712},
{152695, 143560, -12704},
{151819, 142063, -12712},
{152055, 141231, -12712},
{153608, 140371, -12712}
};
//@formatter:on
private final List<L2Npc> minionList = new ArrayList<>();
private L2Npc currentMinion;
private L2Npc balok;
public BalokWarzone()
{
super(TEMPLATE_ID);
addStartNpc(ENTRANCE_PORTAL);
addTalkId(ENTRANCE_PORTAL);
addInstanceCreatedId(TEMPLATE_ID);
addAttackId(BALOK);
addSkillSeeId(BALOK);
addKillId(BALOK, MINION);
addSpellFinishedId(BALOK);
addSpawnId(INVISIBLE_NPC_1);
setCreatureSeeId(this::onCreatureSee, INVISIBLE_NPC_1);
}
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
if (event.equals("enterInstance"))
{
if (hasQuestItems(player, PRISON_KEY))
{
takeItems(player, PRISON_KEY, -1);
}
enterInstance(player, npc, TEMPLATE_ID);
}
return super.onAdvEvent(event, npc, player);
}
@Override
public void onTimerEvent(String event, StatsSet params, L2Npc npc, L2PcInstance player)
{
final Instance world = npc.getInstanceWorld();
if (isInInstance(world))
{
switch (event)
{
case "stage_1_start":
{
playMovie(world.getPlayers(), Movie.SI_BARLOG_STORY);
getTimers().addTimer("stage_1_balok_intro", 72500, npc, null);
break;
}
case "stage_1_balok_intro":
{
playMovie(world.getPlayers(), Movie.SI_BARLOG_OPENING);
getTimers().addTimer("stage_1_spawn_balok", 21300, npc, null);
break;
}
case "stage_1_spawn_balok":
{
balok = addSpawn(BALOK, 153573, 142071, -12738, 16565, false, 0, false, world.getId());
world.setStatus(1);
break;
}
case "stage_last_send_minions":
{
L2Npc minion = minionList.get(Rnd.get(minionList.size()));
if (minion != null)
{
minion.setIsRunning(true);
((L2Attackable) minion).setCanReturnToSpawnPoint(false);
currentMinion = minion;
getTimers().addTimer("stage_last_minion_walk", 2000, minion, player);
}
break;
}
case "stage_last_minion_walk":
{
if (npc.getId() == MINION)
{
if (npc.calculateDistance(balok.getXdestination(), balok.getYdestination(), 0, false, true) < (800 * 800))
{
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(balok.getX() + 100, balok.getY() + 50, balok.getZ(), balok.getHeading()));
getTimers().addTimer("stage_last_minion_walk", 2000, npc, player);
}
else
{
npc.stopSkillEffects(INVINCIBILITY_ACTIVATION.getSkill());
balok.setTarget(npc);
balok.doCast(DARKNESS_DRAIN.getSkill());
}
}
break;
}
case "stage_spawn_apostols":
{
for (int i = 0; i < 4; i++)
{
L2Npc disciple = addSpawn(HELL_DISCIPLE, npc.getX(), npc.getY(), npc.getZ(), 0, true, 600000, false);
addAttackPlayerDesire(disciple, player);
}
break;
}
}
}
}
@Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon)
{
final Instance world = npc.getInstanceWorld();
if (isInInstance(world))
{
if (npc.getId() == BALOK)
{
if ((npc.getCurrentHp() < (npc.getMaxHp() * 0.85)) && (world.getStatus() == 1))
{
for (int[] a : MINION_SPAWN)
{
L2Npc minion = addSpawn(MINION, a[0], a[1], a[2], a[3], false, 0, false, world.getId());
minionList.add(minion);
INVINCIBILITY_ACTIVATION.getSkill().applyEffects(minion, minion);
world.setStatus(2);
}
}
else if ((npc.getCurrentHp() < (npc.getMaxHp() * 0.50)) && (world.getStatus() == 2))
{
if (npc.isScriptValue(0))
{
INVINCIBILITY_ACTIVATION.getSkill().applyEffects(npc, npc);
npc.setScriptValue(1);
}
L2World.getInstance().forEachVisibleObjectInRange(npc, L2PcInstance.class, 300, instPlayer ->
{
if ((instPlayer == null) || (Rnd.get(100) > 2))
{
return;
}
npc.setTarget(instPlayer);
npc.doCast(IMPRISION.getSkill());
int[] randomJail = PRISONS_SPAWN[Rnd.get(PRISONS_SPAWN.length)]; // Random jail
instPlayer.teleToLocation(randomJail[0], randomJail[1], randomJail[2]);
world.broadcastPacket(new ExShowScreenMessage("$s1, locked away in the prison.".replace("$s1", instPlayer.getName()), 5000));
});
getTimers().addTimer("stage_last_send_minions", 2000, npc, null);
}
else if ((npc.getCurrentHp() < (npc.getMaxHp() * 0.30)))
{
npc.setTarget(attacker);
npc.doCast(EARTH_DEMOLITION.getSkill());
// TODO: does not spawn
addSpawn(BLUE_GRAVE, npc.getX() + 100, npc.getY() + 50, npc.getZ(), npc.getHeading(), false, 0, false, world.getId());
getTimers().addTimer("stage_spawn_apostols", 2000, npc, attacker);
}
}
}
return super.onAttack(npc, attacker, damage, isSummon);
}
@Override
public String onSpellFinished(L2Npc npc, L2PcInstance player, Skill skill)
{
final Instance world = npc.getInstanceWorld();
if (isInInstance(world))
{
if (world != null)
{
if (skill.getId() == DARKNESS_DRAIN.getSkillId())
{
if (!currentMinion.isDead())
{
balok.setCurrentHp(balok.getCurrentHp() + currentMinion.getMaxHp());
}
}
}
}
return super.onSpellFinished(npc, player, skill);
}
@Override
public String onKill(L2Npc npc, L2PcInstance player, boolean isPet)
{
final Instance world = npc.getInstanceWorld();
if (npc == balok)
{
if (world.getAliveNpcs(BALOK).isEmpty())
{
world.getAliveNpcs(MINION).forEach(guard -> guard.doDie(null));
world.removeNpcs();
world.finishInstance();
world.broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_DUNGEON_WILL_EXPIRE_IN_S1_MINUTE_S_YOU_WILL_BE_FORCED_OUT_OF_THE_DUNGEON_WHEN_THE_TIME_EXPIRES).addInt((int) 5.0D));
}
else
{
world.setReenterTime();
}
}
else if (npc == currentMinion)
{
synchronized (minionList)
{
if (minionList.contains(npc))
{
minionList.remove(npc);
if (minionList.size() > 0)
{
startQuestTimer("stage_last_send_minions", 2000, npc, null);
}
else
{
balok.stopSkillEffects(INVINCIBILITY_ACTIVATION.getSkill());
}
}
}
}
return super.onKill(npc, player, isPet);
}
public void onCreatureSee(OnCreatureSee event)
{
final L2Character creature = event.getSeen();
final L2Npc npc = (L2Npc) event.getSeer();
final Instance world = npc.getInstanceWorld();
if (isInInstance(world) && creature.isPlayer() && npc.isScriptValue(0))
{
npc.setScriptValue(1);
getTimers().addTimer("stage_1_start", 60000, npc, null);
}
}
@Override
public String onSkillSee(L2Npc npc, L2PcInstance caster, Skill skill, L2Object[] targets, boolean isSummon)
{
if (!npc.isDead() && npc.getEffectList().isAffectedBySkill(INVINCIBILITY_ACTIVATION.getSkillId()) /* && caster.isBehindTarget() */) // TODO: does not work
{
npc.setTarget(caster);
npc.doCast(REAR_DESTROY.getSkill());
if (getRandom(100) < 30)
{
npc.stopSkillEffects(INVINCIBILITY_ACTIVATION.getSkill());
}
}
return super.onSkillSee(npc, caster, skill, targets, isSummon);
}
@Override
public String onSpawn(L2Npc npc)
{
if (npc.getId() == INVISIBLE_NPC_1)
{
npc.initSeenCreatures();
}
return super.onSpawn(npc);
}
public static void main(String[] args)
{
new BalokWarzone();
}
}

View File

@@ -0,0 +1,3 @@
<html><body>Crystal Prison Entrance Portal:<br>
You must be in a party to enter.
</body></html>

View File

@@ -0,0 +1,3 @@
<html><body>Crystal Prison Entrance Portal:<br>
The leader of the party should try to enter.
</body></html>

View File

@@ -1388,6 +1388,13 @@
<skill id="14765" level="4" /> <!-- Blood Siphon Resistance -->
</skill_list>
<ai aggroRange="300" isAggressive="true" clanHelpRange="300" />
<drop_lists>
<death>
<group chance="90">
<item id="10015" min="1" max="1" chance="100" /> <!-- Prison Gate Key -->
</group>
</death>
</drop_lists>
<collision>
<radius normal="60" />
<height normal="99.5" />

View File

@@ -945,14 +945,8 @@
</npc>
<npc id="29218" level="99" type="L2RaidBoss" name="Balok" title="Hell's Warden">
<!-- AUTO GENERATED NPC TODO: FIX IT -->
<parameters>
<skill name="boss_skill_01" id="14246" level="1" />
<skill name="boss_skill_02" id="14247" level="1" />
<skill name="boss_skill_03" id="14248" level="1" />
<skill name="boss_skill_04" id="14249" level="1" />
<skill name="boss_skill_05" id="5226" level="1" />
<skill name="boss_skill_06" id="14366" level="1" />
<skill name="boss_skill_07" id="14367" level="1" />
<parameters>
<skill name="boss_skill_01" id="14366" level="1" />
<param name="Attack_BoostValue" value="155" />
</parameters>
<race>DEMONIC</race>
@@ -976,9 +970,13 @@
<status attackable="false" undying="false" />
<skill_list>
<skill id="5467" level="1" /> <!-- Strong against the dark elemental. -->
<skill id="14727" level="1" /> <!-- Balok -->
<skill id="14246" level="1" /> <!-- Black Vortex -->
<skill id="14727" level="1" /> <!-- Earth Demolition -->
<skill id="14366" level="1" /> <!-- Black Vortex Swamp -->
<!-- <skill id="14367" level="1" /> Darkness Drain -->
<skill id="4416" level="9" /> <!-- Demons -->
<skill id="5226" level="1" /> <!-- Imprison -->
<!-- <skill id="14576" level="1" /> Rear Destroy -->
<skill id="4415" level="4" /> <!-- One-handed Sword -->
<skill id="14765" level="4" /> <!-- Blood Siphon Resistance -->
<skill id="4045" level="1" /> <!-- Resist Full Magic Attack -->

View File

@@ -1919,6 +1919,9 @@
<conditions>
<condition name="OpUnlock" />
</conditions>
<cond msgId="113" addName="1">
<player instanceId="167" />
</cond>
<effects>
<effect name="OpenDoor">
<chance>100</chance>