mirror of
				https://bitbucket.org/Ioncannon/project-meteor-server.git
				synced 2025-05-20 08:26:59 -04:00 
			
		
		
		
	Refactored quest state system seems to work!
This commit is contained in:
		| @@ -24,7 +24,6 @@ end | ||||
| function onEventStarted(player, npc, eventType, eventName) | ||||
| 	local defaultTalk = player:GetDefaultTalkQuest(npc); | ||||
| 	local tutorialTalk = player:GetTutorialQuest(npc); | ||||
| 	local journalQuests = player:GetJournalQuestsForNpc(npc); | ||||
| 	local activeQuests = player:GetQuestsForNpc(npc); | ||||
| 	local possibleQuests = {}; | ||||
| 	 | ||||
| @@ -35,9 +34,6 @@ function onEventStarted(player, npc, eventType, eventName) | ||||
| 	if (tutorialTalk ~= nil and eventType == ETYPE_TALK) then | ||||
| 		table.insert(possibleQuests, tutorialTalk); | ||||
| 	end | ||||
| 	if (journalQuests ~= nil) then | ||||
| 		table.insert(possibleQuests, unpack(journalQuests)); | ||||
| 	end | ||||
| 	if (activeQuests ~= nil) then | ||||
| 		table.insert(possibleQuests, unpack(activeQuests)); | ||||
| 	end | ||||
|   | ||||
| @@ -48,18 +48,19 @@ end | ||||
| function onFinish(player, quest) | ||||
| end | ||||
|  | ||||
| function onStateChange(player, quest, sequence) | ||||
| 	if (sequence == 65536) then | ||||
| function onStateChange(player, quest, sequence)	 | ||||
| 	if (sequence == 65535) then | ||||
| 		quest:SetENpc(KINNISON, QFLAG_PLATE); | ||||
| 	end | ||||
|  | ||||
| 	local data = quest:GetData(); | ||||
| 	if (sequence == SEQ_000) then | ||||
|         quest:SetENpc(KINNISON); | ||||
| 		quest:SetENpc(SYBELL,           (not quest:GetFlag(FLAG_TALKED_SYBELL) and QFLAG_PLATE or QFLAG_NONE)); | ||||
| 		quest:SetENpc(KHUMA_MOSHROCA,   (not quest:GetFlag(FLAG_TALKED_KHUMA_MOSHROCA) and QFLAG_PLATE or QFLAG_NONE)); | ||||
| 		quest:SetENpc(NELLAURE,         (not quest:GetFlag(FLAG_TALKED_NELLAURE) and QFLAG_PLATE or QFLAG_NONE)); | ||||
| 		quest:SetENpc(MESTONNAUX,       (not quest:GetFlag(FLAG_TALKED_MESTONNAUX) and QFLAG_PLATE or QFLAG_NONE)); | ||||
| 		quest:SetENpc(LEFWYNE,          (not quest:GetFlag(FLAG_TALKED_LEFWYNE) and QFLAG_PLATE or QFLAG_NONE)); | ||||
| 		quest:SetENpc(SYBELL,           (not data:GetFlag(FLAG_TALKED_SYBELL) and QFLAG_PLATE or QFLAG_NONE)); | ||||
| 		quest:SetENpc(KHUMA_MOSHROCA,   (not data:GetFlag(FLAG_TALKED_KHUMA_MOSHROCA) and QFLAG_PLATE or QFLAG_NONE)); | ||||
| 		quest:SetENpc(NELLAURE,         (not data:GetFlag(FLAG_TALKED_NELLAURE) and QFLAG_PLATE or QFLAG_NONE)); | ||||
| 		quest:SetENpc(MESTONNAUX,       (not data:GetFlag(FLAG_TALKED_MESTONNAUX) and QFLAG_PLATE or QFLAG_NONE)); | ||||
| 		quest:SetENpc(LEFWYNE,          (not data:GetFlag(FLAG_TALKED_LEFWYNE) and QFLAG_PLATE or QFLAG_NONE)); | ||||
| 	elseif (sequence == SEQ_001) then | ||||
| 		quest:SetENpc(KINNISON, QFLAG_PLATE); | ||||
| 	end	 | ||||
| @@ -74,67 +75,66 @@ function onTalk(player, quest, npc, eventName) | ||||
| 	if (npcClassId == KINNISON and not player:HasQuest(quest)) then | ||||
| 		local questAccepted = callClientFunction(player, "delegateEvent", player, quest, "processEventOffersStart"); | ||||
| 		if (questAccepted) then | ||||
| 			player:AddQuest(quest); | ||||
| 			player:AcceptQuest(quest); | ||||
| 		end | ||||
| 		player:EndEvent(); | ||||
| 		return; | ||||
| 	end | ||||
| 	 | ||||
| 	-- Quest Progress | ||||
| 	local data = quest:GetData(); | ||||
| 	if (seq == SEQ_000) then | ||||
|         if (npcClassId == KINNISON) then | ||||
|             callClientFunction(player, "delegateEvent", player, quest, "processEventOffersAfter"); | ||||
| 		elseif (npcClassId == SYBELL) then | ||||
| 			if (not quest:GetFlag(FLAG_TALKED_SYBELL)) then | ||||
| 			if (not data:GetFlag(FLAG_TALKED_SYBELL)) then | ||||
| 				callClientFunction(player, "delegateEvent", player, quest, "processEventSybellSpeak"); | ||||
| 				quest:SetFlag(FLAG_TALKED_SYBELL); | ||||
| 				data:SetFlag(FLAG_TALKED_SYBELL); | ||||
|                 incCounter = true; | ||||
| 			else | ||||
| 				callClientFunction(player, "delegateEvent", player, quest, "processEventSybellSpeakAfter"); | ||||
| 			end | ||||
| 		elseif (npcClassId == KHUMA_MOSHROCA) then | ||||
| 			if (not quest:GetFlag(FLAG_TALKED_KHUMA_MOSHROCA)) then | ||||
| 			if (not data:GetFlag(FLAG_TALKED_KHUMA_MOSHROCA)) then | ||||
| 				callClientFunction(player, "delegateEvent", player, quest, "processEventKhumaSpeak"); | ||||
| 				quest:SetFlag(FLAG_TALKED_KHUMA_MOSHROCA); | ||||
| 				data:SetFlag(FLAG_TALKED_KHUMA_MOSHROCA); | ||||
|                incCounter = true; | ||||
| 			else | ||||
| 				callClientFunction(player, "delegateEvent", player, quest, "processEventKhumaSpeakAfter"); | ||||
| 			end | ||||
| 		elseif (npcClassId == NELLAURE) then | ||||
| 			if (not quest:GetFlag(FLAG_TALKED_NELLAURE)) then | ||||
| 			if (not data:GetFlag(FLAG_TALKED_NELLAURE)) then | ||||
| 				callClientFunction(player, "delegateEvent", player, quest, "processEventNellaureSpeak"); | ||||
| 				quest:SetFlag(FLAG_TALKED_NELLAURE);	 | ||||
| 				data:SetFlag(FLAG_TALKED_NELLAURE);	 | ||||
|                 incCounter = true; | ||||
| 			else | ||||
| 				callClientFunction(player, "delegateEvent", player, quest, "processEventNellaureSpeakAfter"); | ||||
| 			end | ||||
| 		elseif (npcClassId == MESTONNAUX) then | ||||
| 			if (not quest:GetFlag(FLAG_TALKED_MESTONNAUX)) then | ||||
| 			if (not data:GetFlag(FLAG_TALKED_MESTONNAUX)) then | ||||
| 				callClientFunction(player, "delegateEvent", player, quest, "processEventMestonnauxSpeak"); | ||||
| 				quest:SetFlag(FLAG_TALKED_MESTONNAUX); | ||||
| 				data:SetFlag(FLAG_TALKED_MESTONNAUX); | ||||
|                 incCounter = true;                 | ||||
| 			else | ||||
| 				callClientFunction(player, "delegateEvent", player, quest, "processEventMestonnauxSpeakAfter"); | ||||
| 			end | ||||
| 		elseif (npcClassId == LEFWYNE) then | ||||
| 			if (not quest:GetFlag(FLAG_TALKED_LEFWYNE)) then | ||||
| 			if (not data:GetFlag(FLAG_TALKED_LEFWYNE)) then | ||||
| 				callClientFunction(player, "delegateEvent", player, quest, "processEventLefwyneSpeak"); | ||||
| 				quest:SetFlag(FLAG_TALKED_LEFWYNE);	 | ||||
| 				data:SetFlag(FLAG_TALKED_LEFWYNE);	 | ||||
|                 incCounter = true; | ||||
| 			else | ||||
| 				callClientFunction(player, "delegateEvent", player, quest, "processEventLefwyneSpeakAfter"); | ||||
| 			end | ||||
| 		end | ||||
| 		 | ||||
|          | ||||
| 		         | ||||
| 		-- Increase objective counter & play relevant messages | ||||
| 		if (incCounter == true) then | ||||
|             quest:IncCounter(COUNTER_TALKED); | ||||
|             local counterAmount = quest:GetCounter(COUNTER_TALKED); | ||||
|             local counterAmount = data:IncCounter(COUNTER_TALKED); | ||||
|  | ||||
|             attentionMessage(player, 51061, 0, counterAmount, 5); -- You have heard word of the Seedseers. (... of 5) | ||||
|              | ||||
|             if (seq000_checkCondition(quest)) then -- All Seers spoken to | ||||
|             if (seq000_checkCondition(data)) then -- All Seers spoken to | ||||
|                 attentionMessage(player, 25225, 110674); -- "Seeing the Seers" objectives complete! | ||||
|                 quest:UpdateENPCs(); -- Band-aid for a QFLAG_PLATE issue | ||||
|                 quest:StartSequence(SEQ_001); | ||||
| @@ -155,12 +155,12 @@ end | ||||
|  | ||||
|  | ||||
| -- Check if all seers are talked to | ||||
| function seq000_checkCondition(quest) | ||||
| 	return (quest:GetFlag(FLAG_TALKED_SYBELL) and | ||||
| 			quest:GetFlag(FLAG_TALKED_KHUMA_MOSHROCA) and | ||||
| 			quest:GetFlag(FLAG_TALKED_NELLAURE) and | ||||
| 			quest:GetFlag(FLAG_TALKED_MESTONNAUX) and | ||||
| 			quest:GetFlag(FLAG_TALKED_LEFWYNE)); | ||||
| function seq000_checkCondition(data) | ||||
| 	return (data:GetFlag(FLAG_TALKED_SYBELL) and | ||||
| 			data:GetFlag(FLAG_TALKED_KHUMA_MOSHROCA) and | ||||
| 			data:GetFlag(FLAG_TALKED_NELLAURE) and | ||||
| 			data:GetFlag(FLAG_TALKED_MESTONNAUX) and | ||||
| 			data:GetFlag(FLAG_TALKED_LEFWYNE)); | ||||
| end | ||||
|  | ||||
|  | ||||
| @@ -169,11 +169,11 @@ function getJournalMapMarkerList(player, quest) | ||||
|     local possibleMarkers = {}; | ||||
|      | ||||
|     if (sequence == SEQ_000) then | ||||
|         if (not quest:GetFlag(FLAG_TALKED_SYBELL)) then table.insert(possibleMarkers, MRKR_SYBELL); end | ||||
|         if (not quest:GetFlag(FLAG_TALKED_KHUMA_MOSHROCA)) then table.insert(possibleMarkers, MRKR_KHUMA_MOSHROCA); end | ||||
|         if (not quest:GetFlag(FLAG_TALKED_NELLAURE)) then table.insert(possibleMarkers, MRKR_NELLAURE); end | ||||
|         if (not quest:GetFlag(FLAG_TALKED_MESTONNAUX)) then table.insert(possibleMarkers, MRKR_MESTONNAUX); end | ||||
|         if (not quest:GetFlag(FLAG_TALKED_LEFWYNE)) then table.insert(possibleMarkers, MRKR_LEFWYNE); end | ||||
|         if (not data:GetFlag(FLAG_TALKED_SYBELL)) then table.insert(possibleMarkers, MRKR_SYBELL); end | ||||
|         if (not data:GetFlag(FLAG_TALKED_KHUMA_MOSHROCA)) then table.insert(possibleMarkers, MRKR_KHUMA_MOSHROCA); end | ||||
|         if (not data:GetFlag(FLAG_TALKED_NELLAURE)) then table.insert(possibleMarkers, MRKR_NELLAURE); end | ||||
|         if (not data:GetFlag(FLAG_TALKED_MESTONNAUX)) then table.insert(possibleMarkers, MRKR_MESTONNAUX); end | ||||
|         if (not data:GetFlag(FLAG_TALKED_LEFWYNE)) then table.insert(possibleMarkers, MRKR_LEFWYNE); end | ||||
|     elseif (sequence == SEQ_001) then | ||||
|         table.insert(possibleMarkers, MRKR_KINNISON); | ||||
|     end | ||||
|   | ||||
		Reference in New Issue
	
	Block a user