Reworked some scripts.

Contributed by Stayway, gigilo1968.
This commit is contained in:
MobiusDev
2017-05-28 18:37:26 +00:00
parent 9cb39dc889
commit 29042a9311
45 changed files with 487 additions and 390 deletions

View File

@@ -1,3 +1,4 @@
<html><body>[Desk]:<br>
You've found <font color="LEVEL">The War of Gods and Giants</font>. Take it back to Pantheon.
You've found <font color="LEVEL">The War of Gods and Giants</font>.<br1>
Found It!
</body></html>

View File

@@ -19,7 +19,9 @@ package instances.MuseumDungeon;
import java.util.List;
import com.l2jmobius.gameserver.enums.ChatType;
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.EventType;
@@ -27,7 +29,11 @@ import com.l2jmobius.gameserver.model.events.ListenerRegisterType;
import com.l2jmobius.gameserver.model.events.annotations.Id;
import com.l2jmobius.gameserver.model.events.annotations.RegisterEvent;
import com.l2jmobius.gameserver.model.events.annotations.RegisterType;
import com.l2jmobius.gameserver.model.events.impl.character.OnCreatureAttacked;
import com.l2jmobius.gameserver.model.events.impl.character.OnCreatureDamageReceived;
import com.l2jmobius.gameserver.model.events.impl.character.OnCreatureDeath;
import com.l2jmobius.gameserver.model.events.returns.DamageReturn;
import com.l2jmobius.gameserver.model.holders.SkillHolder;
import com.l2jmobius.gameserver.model.instancezone.Instance;
import com.l2jmobius.gameserver.model.quest.QuestState;
import com.l2jmobius.gameserver.model.skills.Skill;
@@ -35,7 +41,7 @@ import com.l2jmobius.gameserver.network.NpcStringId;
import com.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
import instances.AbstractInstance;
import quests.Q10327_IntruderWhoWantsTheBookOfGiants.Q10327_IntruderWhoWantsTheBookOfGiants;
import quests.Q10542_SearchingForNewPower.Q10542_SearchingForNewPower;
/**
* Museum Dungeon Instance Zone.
@@ -44,14 +50,17 @@ import quests.Q10327_IntruderWhoWantsTheBookOfGiants.Q10327_IntruderWhoWantsTheB
public final class MuseumDungeon extends AbstractInstance
{
// NPCs
private static final int PANTHEON = 32972;
private static final int SHANNON = 32974;
private static final int TOYRON = 33004;
private static final int DESK = 33126;
private static final int THIEF = 23121;
// Items
private static final int THE_WAR_OF_GODS_AND_GIANTS = 17575;
// Skills
private static final SkillHolder SPOIL = new SkillHolder(254, 1);
// Misc
private static final int TEMPLATE_ID = 182;
private static final double DAMAGE_BY_SKILL = 0.5d;
private static final NpcStringId[] THIEF_SHOUT =
{
@@ -62,9 +71,9 @@ public final class MuseumDungeon extends AbstractInstance
public MuseumDungeon()
{
super(TEMPLATE_ID);
addStartNpc(PANTHEON);
addStartNpc(SHANNON);
addFirstTalkId(DESK);
addTalkId(PANTHEON, TOYRON);
addTalkId(SHANNON, TOYRON);
addAttackId(THIEF);
}
@@ -86,19 +95,30 @@ public final class MuseumDungeon extends AbstractInstance
toyron.setCanReturnToSpawnPoint(false);
}
final QuestState qs = player.getQuestState(Q10327_IntruderWhoWantsTheBookOfGiants.class.getSimpleName());
final QuestState qs = player.getQuestState(Q10542_SearchingForNewPower.class.getSimpleName());
if (qs != null)
{
if (qs.isCond(1))
switch (qs.getCond())
{
showOnScreenMsg(player, NpcStringId.AMONG_THE_4_BOOKSHELVES_FIND_THE_ONE_CONTAINING_A_VOLUME_CALLED_THE_WAR_OF_GODS_AND_GIANTS, ExShowScreenMessage.TOP_CENTER, 4500);
}
else if (qs.isCond(2))
{
startQuestTimer("TOYRON_FOLLOW", 500, toyron, player);
if (instance.getNpcs(THIEF).isEmpty())
case 1:
{
startQuestTimer("SPAWN_THIEFS_STAGE_2", 500, null, player);
qs.setCond(2, true);
break;
}
case 3:
{
showOnScreenMsg(player, NpcStringId.AMONG_THE_4_BOOKSHELVES_FIND_THE_ONE_CONTAINING_A_VOLUME_CALLED_THE_WAR_OF_GODS_AND_GIANTS, ExShowScreenMessage.TOP_CENTER, 4500);
break;
}
case 4:
{
getTimers().addTimer("TOYRON_FOLLOW", 1500, toyron, player);
toyron.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.WHEN_DID_THEY_GET_IN_HERE);
if (instance.getNpcs(THIEF).isEmpty())
{
instance.spawnGroup("thiefs").forEach(npc -> npc.setIsRunning(true));
}
}
}
}
@@ -111,116 +131,150 @@ public final class MuseumDungeon extends AbstractInstance
{
enterInstance(player, npc, TEMPLATE_ID);
}
else
{
final Instance world = player.getInstanceWorld();
if (world != null)
{
switch (event)
{
case "TOYRON_FOLLOW":
{
npc.getAI().startFollow(player);
break;
}
case "SPAWN_THIEFS_STAGE_1":
{
final List<L2Npc> thiefs = world.spawnGroup("thiefs");
for (L2Npc thief : thiefs)
{
thief.setIsRunning(true);
addAttackPlayerDesire(thief, player);
thief.broadcastSay(ChatType.NPC_GENERAL, THIEF_SHOUT[getRandom(2)]);
}
final L2Npc toyron = world.getNpc(TOYRON);
toyron.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.WHEN_DID_THEY_GET_IN_HERE);
startQuestTimer("TOYRON_MSG_1", 2500, toyron, player);
startQuestTimer("SKILL_MSG", 4500, toyron, player);
break;
}
case "SPAWN_THIEFS_STAGE_2":
{
final List<L2Npc> thiefs = world.spawnGroup("thiefs");
for (L2Npc thief : thiefs)
{
thief.setIsRunning(true);
}
break;
}
case "SKILL_MSG":
{
showOnScreenMsg(player, NpcStringId.USE_YOUR_SKILL_ATTACKS_AGAINST_THEM, ExShowScreenMessage.TOP_CENTER, 4500);
break;
}
case "TOYRON_MSG_1":
{
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.YOUR_NORMAL_ATTACKS_AREN_T_WORKING);
startQuestTimer("TOYRON_MSG_2", 2500, npc, player);
break;
}
case "TOYRON_MSG_2":
{
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.LOOKS_LIKE_ONLY_SKILL_BASED_ATTACKS_DAMAGE_THEM);
break;
}
}
}
}
return super.onAdvEvent(event, npc, player);
}
@Override
public String onFirstTalk(L2Npc npc, L2PcInstance player)
{
final Instance world = npc.getInstanceWorld();
if (world == null)
{
return null;
}
String htmltext = null;
final QuestState qs = player.getQuestState(Q10327_IntruderWhoWantsTheBookOfGiants.class.getSimpleName());
if ((qs == null) || qs.isCond(2))
{
htmltext = "33126.html";
}
else if (qs.isCond(1))
{
if (npc.getVariables().getBoolean("book", false) && !hasQuestItems(player, THE_WAR_OF_GODS_AND_GIANTS))
{
qs.setCond(2);
giveItems(player, THE_WAR_OF_GODS_AND_GIANTS, 1);
showOnScreenMsg(player, NpcStringId.WATCH_OUT_YOU_ARE_BEING_ATTACKED, ExShowScreenMessage.TOP_CENTER, 4500);
htmltext = "33126-01.html";
final L2Npc toyron = world.getNpc(TOYRON);
startQuestTimer("SPAWN_THIEFS_STAGE_1", 500, null, player);
startQuestTimer("TOYRON_FOLLOW", 500, toyron, player);
}
else
{
htmltext = "33126-02.html";
}
}
return htmltext;
}
@Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, Skill skill)
{
final Instance instance = npc.getInstanceWorld();
if (instance != null)
if (skill == null)
{
final L2Npc toyron = instance.getNpc(TOYRON);
if (!toyron.isInCombat())
showOnScreenMsg(attacker, NpcStringId.USE_YOUR_SKILL_ATTACKS_AGAINST_THEM, ExShowScreenMessage.TOP_CENTER, 2500);
}
return onAttack(npc, attacker, damage, isSummon);
}
@Override
public void onTimerEvent(String event, StatsSet params, L2Npc npc, L2PcInstance player)
{
final Instance instance = npc.getInstanceWorld();
final L2Attackable toyron = (L2Attackable) instance.getNpc(TOYRON);
if (isInInstance(instance))
{
switch (event)
{
toyron.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.ENOUGH_OF_THIS_COME_AT_ME);
toyron.reduceCurrentHp(1, npc, null); // TODO: Find better way for attack
npc.reduceCurrentHp(1, toyron, null);
startQuestTimer("TOYRON_FOLLOW", 3000, toyron, attacker);
case "TOYRON_FOLLOW":
{
toyron.getAI().startFollow(player);
toyron.setIsRunning(true);
break;
}
case "SPAWN_THIEFS_STAGE_1":
{
instance.spawnGroup("thiefs").forEach(thief ->
{
thief.setIsRunning(true);
addAttackPlayerDesire(thief, player);
thief.broadcastSay(ChatType.NPC_GENERAL, THIEF_SHOUT[getRandom(2)]);
});
toyron.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.WHEN_DID_THEY_GET_IN_HERE);
getTimers().addRepeatingTimer("TOYRON_MSG_1", 10000, toyron, player);
getTimers().addRepeatingTimer("TOYRON_MSG_2", 12500, toyron, player);
break;
}
case "TOYRON_MSG_1":
{
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.YOUR_NORMAL_ATTACKS_AREN_T_WORKING);
break;
}
case "TOYRON_MSG_2":
{
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.LOOKS_LIKE_ONLY_SKILL_BASED_ATTACKS_DAMAGE_THEM);
break;
}
case "THIEF_DIE":
{
toyron.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.ENOUGH_OF_THIS_COME_AT_ME);
break;
}
}
}
return super.onAttack(npc, attacker, damage, isSummon, skill);
}
@Override
public String onFirstTalk(L2Npc npc, L2PcInstance player)
{
final Instance instance = npc.getInstanceWorld();
String htmltext = null;
if (isInInstance(instance))
{
final L2Npc toyron = instance.getNpc(TOYRON);
final QuestState qs = player.getQuestState(Q10542_SearchingForNewPower.class.getSimpleName());
if ((qs == null) || qs.isCond(4) || qs.isCond(5))
{
htmltext = "33126.html";
}
else if (qs.isCond(3))
{
if (npc.getVariables().getBoolean("book", false) && !hasQuestItems(player, THE_WAR_OF_GODS_AND_GIANTS))
{
qs.setCond(4, true);
giveItems(player, THE_WAR_OF_GODS_AND_GIANTS, 1);
showOnScreenMsg(player, NpcStringId.WATCH_OUT_YOU_ARE_BEING_ATTACKED, ExShowScreenMessage.TOP_CENTER, 4500, true);
getTimers().addTimer("SPAWN_THIEFS_STAGE_1", 1000, npc, player);
getTimers().addTimer("TOYRON_FOLLOW", 1000, toyron, player);
htmltext = "33126-01.html";
}
else
{
htmltext = "33126-02.html";
}
}
}
return htmltext;
}
@RegisterEvent(EventType.ON_CREATURE_ATTACKED)
@RegisterType(ListenerRegisterType.NPC)
@Id(THIEF)
public void onCreatureAttacked(OnCreatureAttacked event)
{
final L2Character creature = event.getAttacker();
final L2Npc npc = (L2Npc) event.getTarget();
final Skill skill = event.getSkill();
final Instance instance = npc.getInstanceWorld();
if (isInInstance(instance) && !creature.isPlayer() && npc.isScriptValue(1))
{
getTimers().addTimer("THIEF_DIE", 500, npc, null);
}
else if (isInInstance(instance) && creature.isPlayer() && (skill == SPOIL.getSkill()) && npc.isScriptValue(0))
{
final L2Npc toyron = instance.getNpc(TOYRON);
addAttackDesire(toyron, npc);
npc.setScriptValue(1);
}
}
@RegisterEvent(EventType.ON_CREATURE_DAMAGE_RECEIVED)
@RegisterType(ListenerRegisterType.NPC)
@Id(THIEF)
public DamageReturn onCreatureDamageReceived(OnCreatureDamageReceived event)
{
final L2Character target = event.getTarget();
if (target.isNpc() && event.getAttacker().isPlayer())
{
final L2PcInstance player = event.getAttacker().getActingPlayer();
final Instance instance = player.getInstanceWorld();
if (isInInstance(instance))
{
final QuestState qs = player.getQuestState(Q10542_SearchingForNewPower.class.getSimpleName());
if ((qs != null) && qs.isCond(4))
{
if (event.getSkill() == null)
{
return new DamageReturn(true, true, true, 0);
}
final L2Npc toyron = instance.getNpc(TOYRON);
addAttackDesire(toyron, target);
((L2Npc) target).setScriptValue(1);
return new DamageReturn(false, true, false, target.getMaxHp() * DAMAGE_BY_SKILL);
}
}
}
return null;
}
@RegisterEvent(EventType.ON_CREATURE_DEATH)
@@ -229,16 +283,29 @@ public final class MuseumDungeon extends AbstractInstance
public void onCreatureKill(OnCreatureDeath event)
{
final L2Npc npc = (L2Npc) event.getTarget();
final Instance world = npc.getInstanceWorld();
if (world != null)
final Instance instance = npc.getInstanceWorld();
if (isInInstance(instance))
{
final L2PcInstance player = world.getFirstPlayer();
final QuestState qs = player.getQuestState(Q10327_IntruderWhoWantsTheBookOfGiants.class.getSimpleName());
if ((qs != null) && qs.isCond(2) && world.getAliveNpcs(THIEF).isEmpty())
final L2Attackable toyron = (L2Attackable) instance.getNpc(TOYRON);
final L2PcInstance player = instance.getFirstPlayer();
final QuestState qs = player.getQuestState(Q10542_SearchingForNewPower.class.getSimpleName());
if ((qs != null) && qs.isCond(4))
{
qs.setCond(3, true);
showOnScreenMsg(player, NpcStringId.TALK_TO_TOYRON_TO_RETURN_TO_THE_MUSEUM_LOBBY, ExShowScreenMessage.TOP_CENTER, 4500);
if (instance.getAliveNpcs(THIEF).isEmpty())
{
qs.setCond(5, true);
showOnScreenMsg(player, NpcStringId.SPEAK_WITH_TOYRON_IN_ORDER_TO_RETURN_SHANNON, ExShowScreenMessage.TOP_CENTER, 4500);
getTimers().cancelTimer("TOYRON_MSG_1", toyron, player);
getTimers().cancelTimer("TOYRON_MSG_2", toyron, player);
}
else
{
final int value = qs.getMemoStateEx(Q10542_SearchingForNewPower.KILL_COUNT_VAR) + 1;
qs.setMemoStateEx(Q10542_SearchingForNewPower.KILL_COUNT_VAR, value);
qs.getQuest().sendNpcLogList(player);
getTimers().addTimer("TOYRON_FOLLOW", 1500, toyron, player);
}
}
}
}