Skip to content
Snippets Groups Projects
Commit cc1988f3 authored by Adry85's avatar Adry85
Browse files

Fixed quest Invention Ambition (269) reward and improved code.

- Reported by: Zoey76
parent 65e847af
No related branches found
No related tags found
No related merge requests found
/*
* Copyright (C) 2004-2016 L2J DataPack
* Copyright (C) 2004-2017 L2J DataPack
*
* This file is part of L2J DataPack.
*
......@@ -21,12 +21,10 @@ package quests.Q00269_InventionAmbition;
import java.util.HashMap;
import java.util.Map;
import com.l2jserver.gameserver.enums.audio.Sound;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.model.quest.QuestState;
import com.l2jserver.gameserver.model.quest.State;
/**
* Invention Ambition (269)
......@@ -39,17 +37,17 @@ public final class Q00269_InventionAmbition extends Quest
// Items
private static final int ENERGY_ORE = 10866;
// Monsters
private static final Map<Integer, Integer> MONSTERS = new HashMap<>();
private static final Map<Integer, Double> MONSTERS = new HashMap<>();
static
{
MONSTERS.put(21124, 46); // Red Eye Barbed Bat
MONSTERS.put(21125, 48); // Northern Trimden
MONSTERS.put(21126, 50); // Kerope Werewolf
MONSTERS.put(21127, 64); // Northern Goblin
MONSTERS.put(21128, 66); // Spine Golem
MONSTERS.put(21129, 68); // Kerope Werewolf Chief
MONSTERS.put(21130, 76); // Northern Goblin Leader
MONSTERS.put(21131, 78); // Enchanted Spine Golem
MONSTERS.put(21124, 0.46); // Red Eye Barbed Bat
MONSTERS.put(21125, 0.48); // Northern Trimden
MONSTERS.put(21126, 0.5); // Kerope Werewolf
MONSTERS.put(21127, 0.64); // Northern Goblin
MONSTERS.put(21128, 0.66); // Spine Golem
MONSTERS.put(21129, 0.68); // Kerope Werewolf Chief
MONSTERS.put(21130, 0.76); // Northern Goblin Leader
MONSTERS.put(21131, 0.78); // Enchanted Spine Golem
}
// Misc
private static final int MIN_LVL = 18;
......@@ -67,33 +65,41 @@ public final class Q00269_InventionAmbition extends Quest
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
final QuestState st = getQuestState(player, false);
if (st == null)
{
return null;
}
String htmltext = null;
if (st != null)
switch (event)
{
switch (event)
case "32486-03.htm":
{
case "32486-03.htm":
if (player.getLevel() >= MIN_LVL)
{
htmltext = (player.getLevel() >= MIN_LVL) ? event : null;
break;
}
case "32486-04.htm":
{
st.startQuest();
htmltext = event;
break;
}
case "32486-07.html":
{
st.exitQuest(true, true);
htmltext = event;
break;
}
case "32486-08.html":
break;
}
case "32486-04.htm":
{
if (player.getLevel() >= MIN_LVL)
{
st.startQuest();
htmltext = event;
break;
}
break;
}
case "32486-07.html":
{
st.exitQuest(true, true);
htmltext = event;
break;
}
case "32486-08.html":
{
htmltext = event;
break;
}
}
return htmltext;
......@@ -102,11 +108,10 @@ public final class Q00269_InventionAmbition extends Quest
@Override
public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
{
final QuestState st = getQuestState(killer, false);
if ((st != null) && (getRandom(100) < MONSTERS.get(npc.getId())))
final QuestState st = getRandomPartyMemberState(killer, -1, 3, npc);
if (st != null)
{
st.giveItems(ENERGY_ORE, 1);
st.playSound(Sound.ITEMSOUND_QUEST_ITEMGET);
giveItemRandomly(st.getPlayer(), npc, ENERGY_ORE, 1, 0, MONSTERS.get(npc.getId()), true);
}
return super.onKill(npc, killer, isSummon);
}
......@@ -116,30 +121,22 @@ public final class Q00269_InventionAmbition extends Quest
{
final QuestState st = getQuestState(player, true);
String htmltext = getNoQuestMsg(player);
if (st != null)
if (st.isCreated())
{
htmltext = (player.getLevel() >= MIN_LVL) ? "32486-01.htm" : "32486-02.html";
}
else if (st.isStarted())
{
switch (st.getState())
if (st.hasQuestItems(ENERGY_ORE))
{
case State.CREATED:
{
htmltext = (player.getLevel() >= MIN_LVL) ? "32486-01.htm" : "32486-02.html";
break;
}
case State.STARTED:
{
if (st.hasQuestItems(ENERGY_ORE))
{
final long count = st.getQuestItemsCount(ENERGY_ORE);
st.giveAdena((count * 50) + (count >= 10 ? 2044 : null), true);
st.takeItems(ENERGY_ORE, -1);
htmltext = "32486-06.html";
}
else
{
htmltext = "32486-05.html";
}
break;
}
final long count = getQuestItemsCount(player, ENERGY_ORE);
giveAdena(player, (count * 50) + (count >= 10 ? 2044 : 0), true);
takeItems(player, ENERGY_ORE, -1);
htmltext = "32486-06.html";
}
else
{
htmltext = "32486-05.html";
}
}
return htmltext;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment