Skip to content

Commit

Permalink
Removed map_filename_based event group support and fixed the story.
Browse files Browse the repository at this point in the history
Map based event groups prevented map renaming without major flaws,
thus making them a bad practice.
I removed support for them in the code, made the game stop
counting the time you talked to someone
(which wasn't working and useless anyway.),
and made the treasures have their own event table.

Warning: Save games made before this change will behave as if
player didn't do anything in the story.
  • Loading branch information
Yohann Ferreira committed Aug 23, 2012
1 parent 847aa4b commit 7bb2018
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 94 deletions.
11 changes: 5 additions & 6 deletions dat/maps/layna_village/layna_village_bronanns_home.lua
Expand Up @@ -251,7 +251,6 @@ function Load(m)
ObjectManager = Map.object_supervisor;
DialogueManager = Map.dialogue_supervisor;
EventManager = Map.event_supervisor;
GlobalEvents = Map.map_event_group;

Map.unlimited_stamina = true;

Expand Down Expand Up @@ -627,7 +626,7 @@ function _CheckZones()
-- Don't check that zone when dealing with the quest 2 start scene.
if (quest2_start_scene == false and home_exit_zone:IsCameraEntering() == true) then
-- Prevent Bronann from exiting until his mother talked to him
if (GlobalEvents:DoesEventExist("quest1_mother_start_dialogue_done") == false) then
if (GlobalManager:DoesEventExist("bronanns_home", "quest1_mother_start_dialogue_done") == false) then
Map:PushState(hoa_map.MapMode.STATE_SCENE);
EventManager:StartEvent("Start Quest1");
else
Expand Down Expand Up @@ -687,7 +686,7 @@ function _UpdateMotherDialogue()
bronanns_mother:AddDialogueReference(dialogue);
return;
end
if (GlobalManager:DoesEventExist("dat_maps_vt_layna_riverbank_lua", "quest1_barley_meal_done") == true) then
if (GlobalManager:DoesEventExist("story", "quest1_barley_meal_done") == true) then
-- Got some barley meal, Mom!
-- Begining dialogue
local dialogue = hoa_map.SpriteDialogue();
Expand All @@ -697,14 +696,14 @@ function _UpdateMotherDialogue()
dialogue:AddLineEvent(text, bronanns_mother, "Quest1: end and transition to after-dinner");
DialogueManager:AddDialogue(dialogue);
bronanns_mother:AddDialogueReference(dialogue);
elseif (GlobalEvents:DoesEventExist("quest1_mother_start_dialogue_done") == true) then
elseif (GlobalManager:DoesEventExist("bronanns_home", "quest1_mother_start_dialogue_done") == true) then
-- 1st quest dialogue
local dialogue = hoa_map.SpriteDialogue();
local text = hoa_system.Translate("Could you go and buy some barley meal for us three?");
dialogue:AddLine(text, bronanns_mother);
DialogueManager:AddDialogue(dialogue);
bronanns_mother:AddDialogueReference(dialogue);
elseif (GlobalEvents:DoesEventExist("quest1_mother_start_dialogue_done") == false) then
elseif (GlobalManager:DoesEventExist("bronanns_home", "quest1_mother_start_dialogue_done") == false) then
-- Begining dialogue
local dialogue = hoa_map.SpriteDialogue();
local text = hoa_system.Translate("Hi Son, did you have a nightmare this night also?");
Expand Down Expand Up @@ -763,7 +762,7 @@ map_functions = {
end,

Quest1MotherStartDialogueDone = function()
GlobalEvents:SetEvent("quest1_mother_start_dialogue_done", 1);
GlobalManager:SetEventValue("bronanns_home", "quest1_mother_start_dialogue_done", 1);
_UpdateMotherDialogue();
end,

Expand Down
Expand Up @@ -259,7 +259,6 @@ function Load(m)
ObjectManager = Map.object_supervisor;
DialogueManager = Map.dialogue_supervisor;
EventManager = Map.event_supervisor;
GlobalEvents = Map.map_event_group;

Map.unlimited_stamina = true;

Expand All @@ -273,7 +272,7 @@ function Load(m)
_CreateZones();

-- If not done, start the opening dialogue
if (GlobalEvents:DoesEventExist("opening_dialogue_done") == false) then
if (GlobalManager:DoesEventExist("story", "opening_dialogue_done") == false) then
Map:PushState(hoa_map.MapMode.STATE_SCENE);
EventManager:StartEvent("opening", 1000);
end
Expand Down Expand Up @@ -454,6 +453,6 @@ map_functions = {
end,

OpeningDialogueDone = function()
GlobalEvents:SetEvent("opening_dialogue_done", 1);
GlobalManager:SetEventValue("story", "opening_dialogue_done", 1);
end
}
35 changes: 17 additions & 18 deletions dat/maps/layna_village/layna_village_center.lua
Expand Up @@ -282,7 +282,6 @@ function Load(m)
ObjectManager = Map.object_supervisor;
DialogueManager = Map.dialogue_supervisor;
EventManager = Map.event_supervisor;
GlobalEvents = Map.map_event_group;

Map.unlimited_stamina = true;

Expand Down Expand Up @@ -418,8 +417,8 @@ function _CreateNPCs()
npc:SetDirection(hoa_map.MapMode.SOUTH);
dialogue = hoa_map.SpriteDialogue();
text = hoa_system.Translate("You're too young to trade stuff with me!");
if (GlobalManager:DoesEventExist("dat_maps_vt_layna_south_entrance_lua", "quest1_orlinn_hide_n_seek1_done") == true) then
if (GlobalManager:DoesEventExist("dat_maps_vt_layna_riverbank_lua", "quest1_orlinn_hide_n_seek2_done") == false) then
if (GlobalManager:DoesEventExist("layna_south_entrance", "quest1_orlinn_hide_n_seek1_done") == true) then
if (GlobalManager:DoesEventExist("layna_riverbank", "quest1_orlinn_hide_n_seek2_done") == false) then
text = hoa_system.Translate("If you're running after Orlinn, I just saw him disappear near your house.");
end
end
Expand Down Expand Up @@ -1067,16 +1066,16 @@ function _TriggerPotentialDialogueAfterFadeIn()
GlobalManager:SetEventValue("story", "Quest2_wants_to_buy_sword_dialogue", 1);
return;
end
elseif (GlobalEvents:DoesEventExist("first_time_in_village_center") == false) then
elseif (GlobalManager:DoesEventExist("layna_center", "first_time_in_village_center") == false) then
EventManager:StartEvent("Quest1: Bronann wonders where he can find some barley meal");
GlobalEvents:AddNewEvent("first_time_in_village_center", 1);
GlobalManager:SetEventValue("layna_center", "first_time_in_village_center", 1);
return;
end
end

-- Make the rock blocks the secret passage as long as the kid hasn't been found once.
function _UpdateBlockingRock()
if (GlobalManager:DoesEventExist("dat_maps_vt_layna_south_entrance_lua", "quest1_orlinn_hide_n_seek1_done") == true) then
if (GlobalManager:DoesEventExist("layna_south_entrance", "quest1_orlinn_hide_n_seek1_done") == true) then
blocking_rock:SetNoCollision(true);
blocking_rock:SetVisible(false);
else
Expand All @@ -1092,10 +1091,10 @@ function _UpdateGeorgesDialogue()

georges:ClearDialogueReferences();

if (GlobalManager:DoesEventExist("dat_maps_vt_layna_riverbank_lua", "quest1_barley_meal_done") == true) then
if (GlobalManager:DoesEventExist("story", "quest1_barley_meal_done") == true) then
-- default behaviour once the barley meal is given
elseif (GlobalEvents:DoesEventExist("quest1_pen_given_done") == true
and GlobalManager:DoesEventExist("dat_maps_vt_layna_riverbank_lua", "quest1_barley_meal_done") == false) then
elseif (GlobalManager:DoesEventExist("layna_center", "quest1_pen_given_done") == true
and GlobalManager:DoesEventExist("story", "quest1_barley_meal_done") == false) then
dialogue = hoa_map.SpriteDialogue();
text = hoa_system.Translate("In fact, the barley meal was for Lilly.");
dialogue:AddLine(text, georges);
Expand All @@ -1107,7 +1106,7 @@ function _UpdateGeorgesDialogue()
georges:AddDialogueReference(dialogue);
return;
-- Quest 1 done as for Georges
elseif (GlobalManager:DoesEventExist("dat_maps_vt_layna_riverbank_lua", "quest1_orlinn_hide_n_seek3_done") == true) then
elseif (GlobalManager:DoesEventExist("layna_riverbank", "quest1_orlinn_hide_n_seek3_done") == true) then
-- Give the pen to Georges
dialogue = hoa_map.SpriteDialogue();
text = hoa_system.Translate("Here it is, Georges.");
Expand All @@ -1127,7 +1126,7 @@ function _UpdateGeorgesDialogue()
DialogueManager:AddDialogue(dialogue);
georges:AddDialogueReference(dialogue);
return;
elseif (GlobalEvents:DoesEventExist("quest1_georges_dialogue_done") == true) then
elseif (GlobalManager:DoesEventExist("layna_center", "quest1_georges_dialogue_done") == true) then
-- Once talked to him after the shop conversation, just put the end of the dialogue
dialogue = hoa_map.SpriteDialogue();
text = hoa_system.Translate("You see, I lost my beloved pen. Was it near a tree or next to the waving child of the mountain snow?");
Expand All @@ -1139,7 +1138,7 @@ function _UpdateGeorgesDialogue()
DialogueManager:AddDialogue(dialogue);
georges:AddDialogueReference(dialogue);
return;
elseif (GlobalManager:DoesEventExist("dat_maps_vt_layna_center_shop_lua", "quest1_flora_dialogue_done") == true) then
elseif (GlobalManager:DoesEventExist("layna_center_shop", "quest1_flora_dialogue_done") == true) then
dialogue = hoa_map.SpriteDialogue();
text = hoa_system.Translate("Hi Georges. Erm, I'm coming from the shop and I ...");
dialogue:AddLine(text, bronann);
Expand Down Expand Up @@ -1195,7 +1194,7 @@ function _UpdateOrlinnAndKalyaState()
kalya:SetMoving(false);
return;
end
if (GlobalManager:DoesEventExist("dat_maps_vt_layna_riverbank_lua", "quest1_orlinn_hide_n_seek3_done") == true) then
if (GlobalManager:DoesEventExist("layna_riverbank", "quest1_orlinn_hide_n_seek3_done") == true) then
-- Bronann got Georges' pen, update orlinn dialogue
dialogue = hoa_map.SpriteDialogue();
text = hoa_system.Translate("I promise I won't bother you again ...");
Expand All @@ -1214,12 +1213,12 @@ function _UpdateOrlinnAndKalyaState()
kalya:AddDialogueReference(dialogue);


elseif (GlobalEvents:DoesEventExist("quest1_orlinn_dialogue1_done") == true) then
elseif (GlobalManager:DoesEventExist("layna_center", "quest1_orlinn_dialogue1_done") == true) then
-- At that time, Orlinn isn't in the village center anymore.
orlinn:SetVisible(false);
orlinn:SetNoCollision(true);
return;
elseif (GlobalEvents:DoesEventExist("quest1_georges_dialogue_done") == true) then
elseif (GlobalManager:DoesEventExist("layna_center", "quest1_georges_dialogue_done") == true) then
dialogue = hoa_map.SpriteDialogue();
text = hoa_system.Translate("Hi hi hi!!");
dialogue:AddLine(text, orlinn);
Expand Down Expand Up @@ -1268,7 +1267,7 @@ end
map_functions = {

Quest1GeorgesDialogueDone = function()
GlobalEvents:SetEvent("quest1_georges_dialogue_done", 1);
GlobalManager:SetEventValue("layna_center", "quest1_georges_dialogue_done", 1);
-- Makes Orlinn aware that Bronann has talked to Georges.
_UpdateOrlinnAndKalyaState();
_UpdateGeorgesDialogue();
Expand All @@ -1281,11 +1280,11 @@ map_functions = {
EventManager:TerminateAllEvents(orlinn);

-- Updates Orlinn's state
GlobalEvents:SetEvent("quest1_orlinn_dialogue1_done", 1);
GlobalManager:SetEventValue("layna_center", "quest1_orlinn_dialogue1_done", 1);
end,

Quest1GeorgesTellsBronannAboutLilly = function()
GlobalEvents:SetEvent("quest1_pen_given_done", 1);
GlobalManager:SetEventValue("layna_center", "quest1_pen_given_done", 1);

-- Remove the pen key item from inventory
local pen_item_id = 70001;
Expand Down
7 changes: 3 additions & 4 deletions dat/maps/layna_village/layna_village_center_shop.lua
Expand Up @@ -222,7 +222,6 @@ function Load(m)
ObjectManager = Map.object_supervisor;
DialogueManager = Map.dialogue_supervisor;
EventManager = Map.event_supervisor;
GlobalEvents = Map.map_event_group;

Map.unlimited_stamina = true;

Expand Down Expand Up @@ -357,15 +356,15 @@ function _UpdateFloraDialogue()
DialogueManager:AddDialogue(dialogue);
flora:AddDialogueReference(dialogue);
return;
elseif (GlobalEvents:DoesEventExist("quest1_flora_dialogue_done") == true) then
elseif (GlobalManager:DoesEventExist("layna_center_shop", "quest1_flora_dialogue_done") == true) then
-- Just repeat the last dialogue sentence, when the dialogue is already done.
dialogue = hoa_map.SpriteDialogue();
text = hoa_system.Translate("Just find our *poet* and he should give you some barley meal, ok?");
dialogue:AddLine(text, flora);
DialogueManager:AddDialogue(dialogue);
flora:AddDialogueReference(dialogue);
return;
elseif (GlobalManager:DoesEventExist("dat_maps_vt_bronanns_home_lua", "quest1_mother_start_dialogue_done") == true) then
elseif (GlobalManager:DoesEventExist("bronanns_home", "quest1_mother_start_dialogue_done") == true) then
dialogue = hoa_map.SpriteDialogue();
text = hoa_system.Translate("Hi Bronnan! What can I do for you?");
dialogue:AddLine(text, flora);
Expand Down Expand Up @@ -400,7 +399,7 @@ end
map_functions = {

Quest1FloraDialogueDone = function()
GlobalEvents:SetEvent("quest1_flora_dialogue_done", 1);
GlobalManager:SetEventValue("layna_center_shop", "quest1_flora_dialogue_done", 1);
_UpdateFloraDialogue();
end,

Expand Down
Expand Up @@ -219,7 +219,6 @@ function Load(m)
ObjectManager = Map.object_supervisor;
DialogueManager = Map.dialogue_supervisor;
EventManager = Map.event_supervisor;
GlobalEvents = Map.map_event_group;

Map.unlimited_stamina = true;

Expand Down
Expand Up @@ -222,7 +222,6 @@ function Load(m)
ObjectManager = Map.object_supervisor;
DialogueManager = Map.dialogue_supervisor;
EventManager = Map.event_supervisor;
GlobalEvents = Map.map_event_group;

Map.unlimited_stamina = true;

Expand Down
1 change: 0 additions & 1 deletion dat/maps/layna_village/layna_village_kalya_house_path.lua
Expand Up @@ -277,7 +277,6 @@ function Load(m)
ObjectManager = Map.object_supervisor;
DialogueManager = Map.dialogue_supervisor;
EventManager = Map.event_supervisor;
GlobalEvents = Map.map_event_group;

Map.unlimited_stamina = true;

Expand Down
Expand Up @@ -219,7 +219,6 @@ function Load(m)
ObjectManager = Map.object_supervisor;
DialogueManager = Map.dialogue_supervisor;
EventManager = Map.event_supervisor;
GlobalEvents = Map.map_event_group;

Map.unlimited_stamina = true;

Expand Down
21 changes: 10 additions & 11 deletions dat/maps/layna_village/layna_village_riverbank.lua
Expand Up @@ -365,7 +365,6 @@ function Load(m)
ObjectManager = Map.object_supervisor;
DialogueManager = Map.dialogue_supervisor;
EventManager = Map.event_supervisor;
GlobalEvents = Map.map_event_group;

Map.unlimited_stamina = true;

Expand Down Expand Up @@ -832,11 +831,11 @@ function _CheckZones()
end

-- zone based story events
if (GlobalManager:DoesEventExist("dat_maps_vt_layna_south_entrance_lua", "quest1_orlinn_hide_n_seek1_done") == true) then
if (GlobalManager:DoesEventExist("layna_south_entrance", "quest1_orlinn_hide_n_seek1_done") == true) then
if (orlinn_hide_n_seek2_zone:IsCameraEntering() == true) then
-- Updates the story state
if (GlobalEvents:DoesEventExist("quest1_orlinn_hide_n_seek2_done") == false) then
GlobalEvents:AddNewEvent("quest1_orlinn_hide_n_seek2_done", 1);
if (GlobalManager:DoesEventExist("layna_riverbank", "quest1_orlinn_hide_n_seek2_done") == false) then
GlobalManager:SetEventValue("layna_riverbank", "quest1_orlinn_hide_n_seek2_done", 1);

-- Orlinn speaks and flee
Map:PushState(hoa_map.MapMode.STATE_SCENE);
Expand All @@ -858,13 +857,13 @@ function _SetLillyState()
dialogue:AddLine(text, lilly);
DialogueManager:AddDialogue(dialogue);
lilly :AddDialogueReference(dialogue);
elseif (GlobalEvents:DoesEventExist("quest1_barley_meal_done") == true) then
elseif (GlobalManager:DoesEventExist("story", "quest1_barley_meal_done") == true) then
dialogue = hoa_map.SpriteDialogue();
text = hoa_system.Translate("You should go back home. Your mom must be waiting for you.");
dialogue:AddLine(text, lilly);
DialogueManager:AddDialogue(dialogue);
lilly :AddDialogueReference(dialogue);
elseif (GlobalManager:DoesEventExist("dat_maps_vt_layna_center_lua", "quest1_pen_given_done") == true) then
elseif (GlobalManager:DoesEventExist("layna_center", "quest1_pen_given_done") == true) then
dialogue = hoa_map.SpriteDialogue();
text = hoa_system.Translate("What a nice day, isn't it?");
dialogue:AddLine(text, lilly);
Expand Down Expand Up @@ -898,11 +897,11 @@ function _SetOrlinnState()
orlinn_dialogue_npc:ClearDialogueReferences();
orlinn:ClearDialogueReferences();

if (GlobalEvents:DoesEventExist("quest1_orlinn_hide_n_seek3_done") == true) then
if (GlobalManager:DoesEventExist("layna_riverbank", "quest1_orlinn_hide_n_seek3_done") == true) then
orlinn:SetNoCollision(true);
orlinn:SetVisible(false);
return;
elseif (GlobalEvents:DoesEventExist("quest1_orlinn_hide_n_seek2_done") == true) then
elseif (GlobalManager:DoesEventExist("layna_riverbank", "quest1_orlinn_hide_n_seek2_done") == true) then
orlinn:SetPosition(74, 44);
orlinn:SetDirection(hoa_map.MapMode.WEST);

Expand All @@ -915,7 +914,7 @@ function _SetOrlinnState()

EventManager:StartEvent("Quest1: Hide and Seek3: Orlinn goes top-right", 8000);
return;
elseif (GlobalManager:DoesEventExist("dat_maps_vt_layna_south_entrance_lua", "quest1_orlinn_hide_n_seek1_done") == true) then
elseif (GlobalManager:DoesEventExist("layna_south_entrance", "quest1_orlinn_hide_n_seek1_done") == true) then
-- Orlinn is on the cliff and is mocking Bronann.
dialogue = hoa_map.SpriteDialogue();
text = hoa_system.Translate("Hi hi hi!");
Expand Down Expand Up @@ -967,7 +966,7 @@ map_functions = {
end,

Set_Hide_And_Seek3_Done = function()
GlobalEvents:SetEvent("quest1_orlinn_hide_n_seek3_done", 1);
GlobalManager:SetEventValue("layna_riverbank", "quest1_orlinn_hide_n_seek3_done", 1);

-- Also reset Lilly direction
lilly:SetDirection(hoa_map.MapMode.WEST);
Expand All @@ -982,7 +981,7 @@ map_functions = {
end,

GiveBarleyMeal = function()
GlobalEvents:SetEvent("quest1_barley_meal_done", 1);
GlobalManager:SetEventValue("story", "quest1_barley_meal_done", 1);
end,

Reset_lilly_dialogue = function()
Expand Down
1 change: 0 additions & 1 deletion dat/maps/layna_village/layna_village_riverbank_house.lua
Expand Up @@ -220,7 +220,6 @@ function Load(m)
ObjectManager = Map.object_supervisor;
DialogueManager = Map.dialogue_supervisor;
EventManager = Map.event_supervisor;
GlobalEvents = Map.map_event_group;

Map.unlimited_stamina = true;

Expand Down
9 changes: 3 additions & 6 deletions dat/maps/layna_village/layna_village_south_entrance.lua
Expand Up @@ -251,7 +251,6 @@ function Load(m)
ObjectManager = Map.object_supervisor;
DialogueManager = Map.dialogue_supervisor;
EventManager = Map.event_supervisor;
GlobalEvents = Map.map_event_group;

Map.unlimited_stamina = true;

Expand Down Expand Up @@ -486,14 +485,12 @@ function _UpdateOrlinnState()
event:AddEventLinkAtEnd("Hide n Seek1: Orlinn goes right", 8000); -- finish the event loop.
EventManager:RegisterEvent(event);

local layna_center_event_group = GlobalManager:GetEventGroup("dat_maps_vt_layna_center_lua");

if (GlobalEvents:DoesEventExist("quest1_orlinn_hide_n_seek1_done") == true) then
if (GlobalManager:DoesEventExist("layna_south_entrance", "quest1_orlinn_hide_n_seek1_done") == true) then
-- Orlinn shouldn't be here, so we make him invisible
orlinn:SetNoCollision(true);
orlinn:SetVisible(false);
return;
elseif (GlobalManager:DoesEventExist("dat_maps_vt_layna_center_lua", "quest1_orlinn_dialogue1_done") == true) then
elseif (GlobalManager:DoesEventExist("layna_center", "quest1_orlinn_dialogue1_done") == true) then
-- Start the hide and seek 1 position when it has to happen
EventManager:StartEvent("Hide n Seek1: Orlinn goes right", 8000);

Expand Down Expand Up @@ -526,7 +523,7 @@ map_functions = {
EventManager:TerminateAllEvents(orlinn);

-- Updates Orlinn's state
GlobalEvents:SetEvent("quest1_orlinn_hide_n_seek1_done", 1);
GlobalManager:SetEventValue("layna_south_entrance", "quest1_orlinn_hide_n_seek1_done", 1);
end,

MakeInvisible = function(sprite)
Expand Down

0 comments on commit 7bb2018

Please sign in to comment.