Added the PGL200 quest The House Always Wins. Fixed quest instances not being set on spawn. Fixed PrivateAreaPast. Added You have left the instance messages when leaving a PrivateArea. Fixed EmoteEvents. DefaultTalk has been disabled temporarily to speed up warps.

This commit is contained in:
Filip Maj 2022-03-03 01:59:13 -05:00
parent f491c63b98
commit b773098abf
9 changed files with 383 additions and 53 deletions

View File

@ -2,11 +2,16 @@ function init(npc)
return false, false, 0, 0;
end
function onEventStarted(player, npc, triggerName)
if (triggerName == "caution") then
worldMaster = GetWorldMaster();
player:SendGameMessage(player, worldMaster, 34109, 0x20);
elseif (triggerName == "exit") then
end
function onEventStarted(player, npc, eventType, eventName)
player:EndEvent();
if (eventName == "caution") then
player:SendGameMessage(player, GetWorldMaster(), 34109, 0x20);
elseif (eventName == "exit") then
local activeQuests = player:GetQuestsForNpc(npc);
print(tostring(#activeQuests));
if (#activeQuests >= 1) then
activeQuests[1]:OnPush(player, npc, eventName);
end
end
end

View File

@ -22,44 +22,61 @@ function init(npc)
end
function onEventStarted(player, npc, eventType, eventName)
local defaultTalk = player:GetDefaultTalkQuest(npc);
local tutorialTalk = player:GetTutorialQuest(npc);
local activeQuests = player:GetQuestsForNpc(npc);
local possibleQuests = {};
-- Create the switch table for this npc
if (defaultTalk ~= nil and eventType == ETYPE_TALK) then
table.insert(possibleQuests, defaultTalk);
end
if (tutorialTalk ~= nil and eventType == ETYPE_TALK) then
table.insert(possibleQuests, tutorialTalk);
end
if (activeQuests ~= nil) then
table.insert(possibleQuests, unpack(activeQuests));
end
-- Either let the player choose the quest or start it if it's the only one.
local chosenQuest = nil;
if (#possibleQuests > 1) then
local currentPage = 0;
local numPages = math.floor((#possibleQuests-1)/4) + 1;
print(tostring(eventType));
print(tostring(eventType));
print(tostring(eventType));
print(tostring(eventType));
print(tostring(eventType));
print(tostring(eventType));
print(tostring(eventType));
if (eventType == 1) then
local defaultTalk = player:GetDefaultTalkQuest(npc);
local tutorialTalk = player:GetTutorialQuest(npc);
local activeQuests = player:GetQuestsForNpc(npc);
local possibleQuests = {};
while (true) do
local page, index = callClientFunction(player, "switchEvent", possibleQuests[currentPage * 4 + 1], possibleQuests[currentPage * 4 + 2], possibleQuests[currentPage * 4 + 3], possibleQuests[currentPage * 4 + 4], currentPage + 1, numPages, 0x3F1);
if (page == 0) then
chosenQuest = possibleQuests[(currentPage * 4) + index];
break;
elseif (page > 0) then
currentPage = page - 1;
else
player:EndEvent();
return;
-- Create the switch table for this npc
if (defaultTalk ~= nil and eventType == ETYPE_TALK) then
table.insert(possibleQuests, defaultTalk);
end
if (tutorialTalk ~= nil and eventType == ETYPE_TALK) then
table.insert(possibleQuests, tutorialTalk);
end
if (activeQuests ~= nil) then
for i=1,#activeQuests do
table.insert(possibleQuests, activeQuests[i]);
end
end
elseif (#possibleQuests == 1) then
chosenQuest = possibleQuests[1];
end
end
-- Either let the player choose the quest or start it if it's the only one.
if (#possibleQuests > 1) then
local currentPage = 0;
local numPages = math.floor((#possibleQuests-1)/4) + 1;
while (true) do
local page, index = callClientFunction(player, "switchEvent", possibleQuests[currentPage * 4 + 1], possibleQuests[currentPage * 4 + 2], possibleQuests[currentPage * 4 + 3], possibleQuests[currentPage * 4 + 4], currentPage + 1, numPages, 0x3F1);
if (page == 0) then
chosenQuest = possibleQuests[(currentPage * 4) + index];
break;
elseif (page > 0) then
currentPage = page - 1;
else
player:EndEvent();
return;
end
end
elseif (#possibleQuests == 1) then
chosenQuest = possibleQuests[1];
end
else
local activeQuests = player:GetQuestsForNpc(npc);
if (#activeQuests != 0) then
chosenQuest = activeQuests[1];
end
end
-- Run the quest event or tell the devs it's missing.
if (chosenQuest ~= nil) then

View File

@ -66,7 +66,7 @@ emoteTable = {
};
function onEventStarted(player, actor, triggerName, emoteId, showText, arg2, arg3, targetId)
function onEventStarted(player, actor, eventType, triggerName, emoteId, showText, arg2, arg3, targetId)
if (targetId == nil) then
targetId = 0;

View File

@ -0,0 +1,301 @@
require ("global")
--[[
Quest Script
Name: The House Always Wins
Code: Pgl200
Id: 110060
Prereq: Level 20, Pugilist
]]
-- Sequence Numbers
SEQ_000 = 0; -- Talk to Titinin.
SEQ_005 = 5; -- Head to the GSM guild and talk to Esperaunce 3 times.
SEQ_010 = 10; -- Warp into a duty; pickup coins.
SEQ_015 = 15; -- Head to the ADV guild and talk to the Wise Miser. Journal Data 3: Set to 1 if talked to Titinin.
SEQ_025 = 25; -- Head to the PGL guild entrence and talk to Lady Lewena. Journal Data 4: Set to 1 if talked to Titinin.
SEQ_030 = 30; -- Head to GLA guild and warp into the duty and fight. Journal Data 5: Set to 1 once you win the fight.
SEQ_035 = 35; -- Return to Titinin.
-- Actor Class Ids
ENPC_GAGARUNA = 1000862;
ENPC_TITININ = 1000934;
ENPC_NAIDA_ZAMAIDA = 1000955;
ENPC_SINGLETON = 1001445;
ENPC_TRIGGER_GSM = 1090058;
ENPC_TRIGGER_PGL = 1090042;
ENPC_PRIVAREA_EXIT = 1290002;
-- PGL Actors
ENPC_MELISIE = 1001009;
ENPC_GUNNULF = 1001256;
ENPC_SHAMANI = 1001012;
ENPC_HALSTEIN = 1001007;
ENPC_HEIBERT = 1001257;
ENPC_IPAGHLO = 1001260;
-- GSM Actors
ENPC_SULTRY_STRUMPET = 1000952;
ENPC_BEAUTEOUS_BEAUTY = 1000953;
ENPC_ESPERAUNCE = 1000954;
-- Quest Markers
MRKR_TITININ = 11006001;
MRKR_OBJECTIVE = 11006002;
MRKR_ESPERAUNCE1 = 11006003;
MRKR_ESPERAUNCE2 = 11006004;
MRKR_NAIDA_ZAMADIA = 11006005;
MRKR_OBJECTIVE2 = 11006006;
MRKR_SINGLETON = 11006007;
MRKR_TITININ2 = 11006008;
-- Quest Details
ITEM_PLATINUM_LEDGER = 11000134;
ITEM_KINGOFPLOTS_GIL = 11000097;
ITEM_WISEMISER_GIL = 11000098;
ITEM_LEWENA_GIL = 11000099;
COUNTER_005 = 0;
COUNTER_015 = 1;
COUNTER_025 = 2;
COUNTER_030 = 3;
function onStart(player, quest)
quest:StartSequence(SEQ_000);
end
function onFinish(player, quest)
end
function onStateChange(player, quest, sequence)
if (sequence == SEQ_ACCEPT) then
quest:SetENpc(ENPC_GAGARUNA, QFLAG_PLATE);
elseif (sequence == SEQ_000) then
quest:SetENpc(ENPC_TITININ, QFLAG_PLATE);
quest:SetENpc(ENPC_GAGARUNA);
quest:SetENpc(ENPC_MELISIE);
quest:SetENpc(ENPC_GUNNULF);
quest:SetENpc(ENPC_SHAMANI);
quest:SetENpc(ENPC_HALSTEIN);
quest:SetENpc(ENPC_HEIBERT);
quest:SetENpc(ENPC_IPAGHLO);
elseif (sequence == SEQ_005) then
quest:SetENpc(ENPC_TITININ);
quest:SetENpc(ENPC_GAGARUNA);
quest:SetENpc(ENPC_SULTRY_STRUMPET);
quest:SetENpc(ENPC_BEAUTEOUS_BEAUTY);
quest:SetENpc(ENPC_ESPERAUNCE, QFLAG_PLATE);
quest:SetENpc(ENPC_TRIGGER_GSM, QFLAG_NONE, false, true);
quest:SetENpc(ENPC_PRIVAREA_EXIT, QFLAG_NONE, false, true);
elseif (sequence == SEQ_010) then
quest:SetENpc(ENPC_SULTRY_STRUMPET);
quest:SetENpc(ENPC_BEAUTEOUS_BEAUTY);
quest:SetENpc(ENPC_ESPERAUNCE);
elseif (sequence == SEQ_015) then
quest:SetENpc(ENPC_TITININ);
quest:SetENpc(ENPC_NAIDA_ZAMAIDA, QFLAG_PLATE);
quest:SetENpc(ENPC_GAGARUNA);
elseif (sequence == SEQ_025) then
quest:SetENpc(ENPC_TITININ);
quest:SetENpc(ENPC_GAGARUNA);
quest:SetENpc(ENPC_TRIGGER_PGL, QFLAG_MAP, false, true);
elseif (sequence == SEQ_030) then
quest:SetENpc(ENPC_TITININ);
quest:SetENpc(ENPC_GAGARUNA);
quest:SetENpc(ENPC_SINGLETON, QFLAG_PLATE);
elseif (sequence == SEQ_035) then
quest:SetENpc(ENPC_TITININ, QFLAG_REWARD);
quest:SetENpc(ENPC_GAGARUNA);
quest:SetENpc(ENPC_MELISIE);
quest:SetENpc(ENPC_GUNNULF);
quest:SetENpc(ENPC_SHAMANI);
quest:SetENpc(ENPC_HALSTEIN);
quest:SetENpc(ENPC_HEIBERT);
quest:SetENpc(ENPC_IPAGHLO);
end
end
function onTalk(player, quest, npc, eventName)
local npcClassId = npc.GetActorClassId();
local seq = quest:GetSequence();
local data = quest:GetData();
-- Offer the quest
if (npcClassId == ENPC_GAGARUNA and seq == SEQ_ACCEPT) then
local questAccepted = callClientFunction(player, "delegateEvent", player, quest, "processEventGagarunaStart");
if (questAccepted == 1) then
player:AcceptQuest(quest);
end
player:EndEvent();
return;
-- Quest Progress
elseif (seq == SEQ_000) then
if (npcClassId == ENPC_TITININ) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent010");
player:SendGameMessage(GetWorldMaster(), 25246, MESSAGE_TYPE_SYSTEM, ITEM_PLATINUM_LEDGER, 1);
quest:StartSequence(SEQ_005);
elseif (npcClassId == ENPC_GAGARUNA) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent005_2");
elseif (npcClassId == ENPC_IPAGHLO) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent005_3");
elseif (npcClassId == ENPC_HALSTEIN) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent005_4");
elseif (npcClassId == ENPC_MELISIE) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent005_5");
elseif (npcClassId == ENPC_HEIBERT) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent005_6");
elseif (npcClassId == ENPC_GUNNULF) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent005_7");
elseif (npcClassId == ENPC_SHAMANI) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent005_8");
end
elseif (seq == SEQ_005) then
if (npcClassId == ENPC_ESPERAUNCE) then
local talkCount = data:IncCounter(COUNTER_005);
if (talkCount == 1) then
player:SendGameMessage(quest, 117, MESSAGE_TYPE_SYSTEM);
elseif (talkCount == 2) then
player:SendGameMessage(quest, 118, MESSAGE_TYPE_SYSTEM);
elseif (talkCount >= 3) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent020");
quest:StartSequence(SEQ_010); -- Temp until Duty is finished. Should go to a duty here.
end
elseif (npcClassId == ENPC_TITININ) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent010_2");
elseif (npcClassId == ENPC_GAGARUNA) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent010_3");
elseif (npcClassId == ENPC_SULTRY_STRUMPET) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent010_4");
elseif (npcClassId == ENPC_BEAUTEOUS_BEAUTY) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent010_5");
end
elseif (seq == SEQ_010) then
if (npcClassId == ENPC_ESPERAUNCE) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent020_2");
callClientFunction(player, "delegateEvent", player, quest, "processEvent030");
quest:StartSequence(SEQ_015); -- Temp until Duty is finished.
player:SendGameMessage(GetWorldMaster(), 25246, MESSAGE_TYPE_SYSTEM, ITEM_KINGOFPLOTS_GIL, 1);
player:EndEvent();
GetWorldManager():WarpToPublicArea(player);
return;
elseif (npcClassId == ENPC_SULTRY_STRUMPET) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent020_3");
elseif (npcClassId == ENPC_BEAUTEOUS_BEAUTY) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent020_4");
end
elseif (seq == SEQ_015) then
if (npcClassId == ENPC_NAIDA_ZAMAIDA) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent040");
quest:StartSequence(SEQ_025);
player:SendGameMessage(GetWorldMaster(), 25246, MESSAGE_TYPE_SYSTEM, ITEM_WISEMISER_GIL, 1);
elseif (npcClassId == ENPC_TITININ) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent030_2");
data:SetCounter(COUNTER_015, 1);
elseif (npcClassId == ENPC_GAGARUNA) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent030_3");
end
elseif (seq == SEQ_025) then
if (npcClassId == ENPC_PUSH_PGL) then
elseif (npcClassId == ENPC_TITININ) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent040_2");
data:SetCounter(COUNTER_025, 1);
elseif (npcClassId == ENPC_GAGARUNA) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent040_3");
end
elseif (seq == SEQ_030) then
if (npcClassId == ENPC_SINGLETON) then
local enterDuty = callClientFunction(player, "delegateEvent", player, quest, "processEvent050_4");
if (enterDuty == 1) then
--Enter duty at this point....
callClientFunction(player, "delegateEvent", player, quest, "processEvent060");
data:SetCounter(COUNTER_030, 1);
quest:StartSequence(SEQ_035); -- Temp until Duty is finished.
player:SendGameMessage(GetWorldMaster(), 25246, MESSAGE_TYPE_SYSTEM, ITEM_LEWENA_GIL, 1);
GetWorldManager():DoZoneChange(player, 209, nil, 0, 0x2, -192.0, 194.5, 193.785, 3.0);
end
elseif (npcClassId == ENPC_TITININ) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent050_2");
elseif (npcClassId == ENPC_GAGARUNA) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent050_3");
end
elseif (seq == SEQ_035) then
if (npcClassId == ENPC_TITININ) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent070");
callClientFunction(player, "delegateEvent", player, quest, "sqrwa", 200, 2)
player:CompleteQuest(quest);
elseif (npcClassId == ENPC_GAGARUNA) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent060_2");
elseif (npcClassId == ENPC_IPAGHLO) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent060_3");
elseif (npcClassId == ENPC_HALSTEIN) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent060_4");
elseif (npcClassId == ENPC_MELISIE) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent060_5");
elseif (npcClassId == ENPC_HEIBERT) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent060_6");
elseif (npcClassId == ENPC_GUNNULF) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent060_7");
elseif (npcClassId == ENPC_SHAMANI) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent060_8");
end
end
quest:UpdateENPCs();
player:EndEvent();
end
function onPush(player, quest, npc)
local npcClassId = npc.GetActorClassId();
local seq = quest:GetSequence();
local data = quest:GetData();
if (seq == SEQ_005) then
player:EndEvent();
if (npcClassId == ENPC_TRIGGER_GSM) then
GetWorldManager():WarpToPrivateArea(player, "PrivateAreaMasterPast", 5);
elseif (npcClassId == ENPC_PRIVAREA_EXIT) then
GetWorldManager():WarpToPublicArea(player);
end
elseif (seq == SEQ_025) then
if (npcClassId == ENPC_TRIGGER_PGL) then
callClientFunction(player, "delegateEvent", player, quest, "processEvent050");
quest:StartSequence(SEQ_030);
player:EndEvent();
end
end
end
function getJournalInformation(player, quest)
local data = quest:GetData();
return 0, data:GetCounter(COUNTER_015), data:GetCounter(COUNTER_025), data:GetCounter(COUNTER_030);
end
function getJournalMapMarkerList(player, quest)
local seq = quest:getSequence();
local data = quest:GetData();
if (seq == SEQ_000) then
return MRKR_TITININ;
elseif (seq == SEQ_005) then
return MRKR_ESPERAUNCE1;
elseif (seq == SEQ_010) then
return MRKR_OBJECTIVE;
elseif (seq == SEQ_015) then
if (data:GetCounter(COUNTER_015) == 1) then
return MRKR_NAIDA_ZAMADIA;
end
elseif (seq == SEQ_025) then
if (data:GetCounter(COUNTER_025) == 1) then
return MRKR_OBJECTIVE2;
end
elseif (seq == SEQ_030) then
return MRKR_SINGLETON;
elseif (seq == SEQ_035) then
return MRKR_TITININ2;
end
return;
end

View File

@ -0,0 +1,3 @@
function init(npc)
return false, false, 0, 0, 0x1A5, 0xFCB;
end

View File

@ -149,19 +149,19 @@ namespace Meteor.Map.Actors.QuestNS
LuaEngine.GetInstance().CallLuaFunction(caller, this, "onTalk", true, npc);
}
public void OnEmote(Player caller, Npc npc, Command command)
public void OnEmote(Player caller, Npc npc, string triggerName)
{
LuaEngine.GetInstance().CallLuaFunction(caller, this, "onEmote", true, npc, command);
LuaEngine.GetInstance().CallLuaFunction(caller, this, "onEmote", true, npc, triggerName);
}
public void OnPush(Player caller, Npc npc)
public void OnPush(Player caller, Npc npc, string triggerName)
{
LuaEngine.GetInstance().CallLuaFunction(caller, this, "onPush", true, npc);
LuaEngine.GetInstance().CallLuaFunction(caller, this, "onPush", true, npc, triggerName);
}
public void OnNotice(Player caller)
public void OnNotice(Player caller, string triggerName)
{
LuaEngine.GetInstance().CallLuaFunction(caller, this, "onNotice", true);
LuaEngine.GetInstance().CallLuaFunction(caller, this, "onNotice", true, triggerName);
}
public void OnNpcLS(Player caller, uint npcLSId)
@ -190,9 +190,9 @@ namespace Meteor.Map.Actors.QuestNS
public bool IsQuestENPC(Player caller, Npc npc)
{
List<LuaParam> returned = LuaEngine.GetInstance().CallLuaFunctionForReturn(caller, this, "IsQuestENPC", true, npc, this);
bool scriptReturned = returned != null && returned.Count != 0 && returned[0].typeID == 3;
return scriptReturned || (questState?.HasENpc(npc.GetActorClassId()) ?? false);
//List<LuaParam> returned = LuaEngine.GetInstance().CallLuaFunctionForReturn(caller, this, "IsQuestENPC", true, npc, this);
//bool scriptReturned = returned != null && returned.Count != 0 && returned[0].typeID == 3;
return (questState?.HasENpc(npc.GetActorClassId()) ?? false);
}
public void StartSequence(ushort sequence)

View File

@ -169,7 +169,7 @@ namespace Meteor.Map.DataObjects
if (quests.Length != 0)
{
QuestENpc questInstance = quests[0].GetQuestState().GetENpc(npc.GetActorClassId());
QueuePacket(npc.GetSetEventStatusPackets());
QueuePacket(npc.GetSetEventStatusPackets(questInstance.isTalkEnabled, questInstance.isEmoteEnabled, questInstance.isPushEnabled));
QueuePacket(SetActorQuestGraphicPacket.BuildPacket(npc.Id, questInstance.questFlagType));
}
}

View File

@ -45,7 +45,7 @@ namespace Meteor.Map.packets.send.actor.events
binWriter.Write((UInt32)0x44533088);
binWriter.Write((Single)100.0f);
binWriter.Seek(4, SeekOrigin.Current);
binWriter.Write((Byte)(condition.outwards ? 0x11 : 0x1)); //If == 0x10, Inverted Bounding Box
binWriter.Write((Byte)(condition.outwards ? 0x10 : 0x1)); //If == 0x10, Inverted Bounding Box
binWriter.Write((Byte)0);
binWriter.Write((Byte)(condition.silent ? 0x1 : 0x0)); //Silent Trigger
binWriter.Write(Encoding.ASCII.GetBytes(condition.conditionName), 0, Encoding.ASCII.GetByteCount(condition.conditionName) >= 0x24 ? 0x24 : Encoding.ASCII.GetByteCount(condition.conditionName));

View File

@ -878,6 +878,10 @@ namespace Meteor.Map
player.playerSession.LockUpdates(false);
//Send "You have left the instance" if old area is a Private Area
if (oldArea is PrivateArea)
player.SendGameMessage(GetActor(), 34110, 0x20);
//Send "You have entered an instance" if it's a Private Area
if (newArea is PrivateArea)
player.SendGameMessage(GetActor(), 34108, 0x20);