1-- Set the namespace according to the map name. 2local ns = {}; 3setmetatable(ns, {__index = _G}); 4mt_elbrus_shrine1_script = ns; 5setfenv(1, ns); 6 7-- The map name, subname and location image 8map_name = "Mt. Elbrus" 9map_image_filename = "data/story/common/locations/mt_elbrus.png" 10map_subname = "Underpass" 11 12-- The music file used as default background music on this map. 13-- Other musics will have to handled through scripting. 14music_filename = "data/music/icy_wind.ogg" 15 16-- c++ objects instances 17local Map = nil 18local EventManager = nil 19local Script = nil 20 21-- the main character handler 22local hero = nil 23 24-- Dialogue sprites 25local bronann = nil 26local kalya = nil 27local orlinn = nil 28local nekko = nil 29 30-- Objects used during the door opening scene 31local shrine_entrance_door = nil 32local shrine_entrance_sign = nil 33 34local shrine_flame1 = nil 35local shrine_flame2 = nil 36 37-- the main map loading code 38function Load(m) 39 40 Map = m; 41 Script = Map:GetScriptSupervisor(); 42 EventManager = Map:GetEventSupervisor(); 43 Map:SetUnlimitedStamina(true); 44 45 _CreateCharacters(); 46 _CreateObjects(); 47 48 -- Set the camera focus on hero 49 Map:SetCamera(hero); 50 -- This is a dungeon map, we'll use the front battle member sprite as default sprite. 51 Map:SetPartyMemberVisibleSprite(hero); 52 53 _CreateEvents(); 54 _CreateZones(); 55 56 -- Add a mediumly dark overlay when necessary 57 if (GlobalManager:GetGameEvents():GetEventValue("story", "mountain_shrine_entrance_light_done") == 0) then 58 Map:GetEffectSupervisor():EnableAmbientOverlay("data/visuals/ambient/dark.png", 0.0, 0.0, false); 59 end 60 61 -- Event Scripts 62 Script:AddScript("data/story/mt_elbrus/shrine_entrance_show_crystal_script.lua"); 63 64 -- Start the dialogue about the shrine entrance if not done 65 if (GlobalManager:GetGameEvents():GetEventValue("story", "mt_elbrus_shrine_entrance_event") ~= 1) then 66 hero:SetMoving(false); 67 EventManager:StartEvent("Shrine entrance event start", 200); 68 end 69 70 if (GlobalManager:GetGameEvents():GetEventValue("story", "mt_elbrus_shrine_door_opening_event") == 1) then 71 _set_shrine_door_open(); 72 shrine_entrance_sign:SetVisible(true); 73 _show_flames(); 74 end 75 76 -- Preload sounds 77 AudioManager:LoadSound("data/sounds/heartbeat_slow.wav", Map); 78 AudioManager:LoadSound("data/sounds/ancient_invocation.wav", Map); 79 AudioManager:LoadSound("data/sounds/cave-in.ogg", Map); 80end 81 82-- the map update function handles checks done on each game tick. 83function Update() 84 -- Check whether the character is in one of the zones 85 _CheckZones(); 86end 87 88-- Character creation 89function _CreateCharacters() 90 -- Default hero and position (from mountain path 4) 91 hero = CreateSprite(Map, "Bronann", 29, 44.5, vt_map.MapMode.GROUND_OBJECT); 92 hero:SetDirection(vt_map.MapMode.NORTH); 93 hero:SetMovementSpeed(vt_map.MapMode.NORMAL_SPEED); 94 95 -- Load previous save point data 96 local x_position = GlobalManager:GetMapData():GetSaveLocationX(); 97 local y_position = GlobalManager:GetMapData():GetSaveLocationY(); 98 if (x_position ~= 0 and y_position ~= 0) then 99 -- Make the character look at us in that case 100 hero:SetDirection(vt_map.MapMode.SOUTH); 101 hero:SetPosition(x_position, y_position); 102 elseif (GlobalManager:GetMapData():GetPreviousLocation() == "from_shrine_main_room") then 103 hero:SetDirection(vt_map.MapMode.SOUTH); 104 hero:SetPosition(42.0, 9.0); 105 end 106 107 bronann = CreateSprite(Map, "Bronann", 0, 0, vt_map.MapMode.GROUND_OBJECT); 108 bronann:SetDirection(vt_map.MapMode.WEST); 109 bronann:SetMovementSpeed(vt_map.MapMode.NORMAL_SPEED); 110 bronann:SetCollisionMask(vt_map.MapMode.NO_COLLISION); 111 bronann:SetVisible(false); 112 113 kalya = CreateSprite(Map, "Kalya", 0, 0, vt_map.MapMode.GROUND_OBJECT); 114 kalya:SetDirection(vt_map.MapMode.EAST); 115 kalya:SetMovementSpeed(vt_map.MapMode.NORMAL_SPEED); 116 kalya:SetCollisionMask(vt_map.MapMode.NO_COLLISION); 117 kalya:SetVisible(false); 118 119 orlinn = CreateSprite(Map, "Orlinn", 0, 0, vt_map.MapMode.GROUND_OBJECT); 120 orlinn:SetDirection(vt_map.MapMode.EAST); 121 orlinn:SetMovementSpeed(vt_map.MapMode.NORMAL_SPEED); 122 orlinn:SetCollisionMask(vt_map.MapMode.NO_COLLISION); 123 orlinn:SetVisible(false); 124 125 -- Mushroom shop! 126 local dialogue = vt_map.SpriteDialogue.Create() 127 local text = vt_system.Translate("Please, don't hurt me, my life is already so short!") 128 dialogue:AddLineEmote(text, nil, "exclamation") 129 text = vt_system.Translate("What about buying some items instead?") 130 dialogue:AddLineEvent(text, nil, "", "Shroom Shop") 131 132 local event = vt_map.ShopEvent.Create("Shroom Shop", "Shroom Shop") 133 event:AddItem(1, 0) -- infinite minor potions 134 event:AddItem(11, 0) -- infinite minor moon juices 135 event:AddItem(1001, 0) -- infinite minor elixirs 136 event:AddItem(15, 0) -- infinite Lotus petals (cure poison) 137 event:AddItem(16, 0) -- infinite Candies (regen) 138 event:AddItem(40003, 1) -- Sturdy leather gloves 139 event:AddItem(10002, 1) -- Hardened practice sword 140 event:AddItem(11002, 1) -- Improved arbalest 141 event:SetPriceLevels(vt_shop.ShopMode.SHOP_PRICE_POOR, 142 vt_shop.ShopMode.SHOP_PRICE_POOR) 143 144 local shroom = CreateSprite(Map, "Shop Mushroom", 55, 38, vt_map.MapMode.GROUND_OBJECT) 145 shroom:AddDialogueReference(dialogue) 146end 147 148-- The heal particle effect map object 149local heal_effect = nil 150 151function _CreateObjects() 152 local object = nil 153 local npc = nil 154 local dialogue = nil 155 local text = nil 156 local event = nil 157 158 vt_map.SavePoint.Create(51, 29); 159 160 -- Load the spring heal effect. 161 heal_effect = vt_map.ParticleObject.Create("data/visuals/particle_effects/heal_particle.lua", 0, 0, vt_map.MapMode.GROUND_OBJECT); 162 heal_effect:Stop(); -- Don't run it until the character heals itself 163 164 object = CreateObject(Map, "Layna Statue", 41, 28, vt_map.MapMode.GROUND_OBJECT); 165 object:SetEventWhenTalking("Heal dialogue"); 166 object:SetInteractionIcon("data/gui/map/heal_anim.lua") 167 168 dialogue = vt_map.SpriteDialogue.Create(); 169 text = vt_system.Translate("Your party feels better."); 170 dialogue:AddLineEvent(text, nil, "Heal event", ""); -- 'nil' means no portrait and no name 171 vt_map.DialogueEvent.Create("Heal dialogue", dialogue); 172 173 -- Snow effect at shrine entrance 174 vt_map.ParticleObject.Create("data/story/mt_elbrus/particles_snow_south_entrance.lua", 29, 48, vt_map.MapMode.GROUND_OBJECT); 175 vt_map.Halo.Create("data/visuals/lights/torch_light_mask.lua", 29, 55, 176 vt_video.Color(1.0, 1.0, 1.0, 0.8)); 177 178 -- Adds the north gate 179 shrine_entrance_door = CreateObject(Map, "Door1_big", 42, 4, vt_map.MapMode.GROUND_OBJECT); 180 181 -- Adds a hidden sign, show just before the opening of the door 182 shrine_entrance_sign = CreateObject(Map, "Ancient_Sign1", 42, 10, vt_map.MapMode.FLATGROUND_OBJECT); 183 shrine_entrance_sign:SetVisible(false); 184 185 -- Flames that are burning after the opening of the shrine. 186 shrine_flame1 = CreateObject(Map, "Flame1", 33, 9.1, vt_map.MapMode.GROUND_OBJECT); 187 shrine_flame2 = CreateObject(Map, "Flame1", 51, 9.1, vt_map.MapMode.GROUND_OBJECT); 188 shrine_flame1:SetVisible(false); 189 shrine_flame2:SetVisible(false); 190 shrine_flame1:RandomizeCurrentAnimationFrame(); 191 shrine_flame2:RandomizeCurrentAnimationFrame(); 192 193 -- When the lighting has improved, show the source of it. 194 if (GlobalManager:GetGameEvents():GetEventValue("story", "mountain_shrine_entrance_light_done") == 1) then 195 vt_map.Halo.Create("data/visuals/lights/torch_light_mask.lua", 42, 8, vt_video.Color(1.0, 1.0, 1.0, 0.6)); 196 -- Adds a door horizon... 197 object = vt_map.PhysicalObject.Create(vt_map.MapMode.FLATGROUND_OBJECT); 198 object:SetPosition(42, 0.8); 199 object:SetCollPixelHalfWidth(16); 200 object:SetCollPixelHeight(32); 201 object:SetImgPixelHalfWidth(16); 202 object:SetImgPixelHeight(32); 203 object:AddStillFrame("data/story/mt_elbrus/shrine_entrance_light.png"); 204 end 205end 206 207-- Special event references which destinations must be updated just before being called. 208-- shrine entrance event 209local kalya_move_next_to_bronann_event1 = nil 210local orlinn_move_next_to_bronann_event1 = nil 211-- Shrine door opening event 212local kalya_move_next_to_bronann_event2 = nil 213local orlinn_move_next_to_bronann_event2 = nil 214 215-- Creates all events and sets up the entire event sequence chain 216function _CreateEvents() 217 local event = nil 218 local dialogue = nil 219 local text = nil 220 221 vt_map.MapTransitionEvent.Create("to mountain shrine", "data/story/mt_elbrus/mt_elbrus_shrine2_map.lua", 222 "data/story/mt_elbrus/mt_elbrus_shrine2_script.lua", "from_shrine_entrance"); 223 224 vt_map.MapTransitionEvent.Create("to mountain shrine-waterfalls", "data/story/mt_elbrus/mt_elbrus_shrine2_2_map.lua", 225 "data/story/mt_elbrus/mt_elbrus_shrine2_script.lua", "from_shrine_entrance"); 226 227 vt_map.MapTransitionEvent.Create("to mountain bridge", "data/story/mt_elbrus/mt_elbrus_path4_map.lua", 228 "data/story/mt_elbrus/mt_elbrus_path4_script.lua", "from_shrine_entrance"); 229 230 -- Heal point 231 vt_map.ScriptedEvent.Create("Heal event", "heal_party", "heal_done"); 232 233 -- Generic events 234 vt_map.ChangeDirectionSpriteEvent.Create("Orlinn looks north", orlinn, vt_map.MapMode.NORTH); 235 vt_map.ChangeDirectionSpriteEvent.Create("Orlinn looks west", orlinn, vt_map.MapMode.WEST); 236 vt_map.ChangeDirectionSpriteEvent.Create("Orlinn looks south", orlinn, vt_map.MapMode.SOUTH); 237 vt_map.ChangeDirectionSpriteEvent.Create("Bronann looks north", bronann, vt_map.MapMode.NORTH); 238 vt_map.ChangeDirectionSpriteEvent.Create("Bronann looks south", bronann, vt_map.MapMode.SOUTH); 239 vt_map.ChangeDirectionSpriteEvent.Create("Kalya looks north", kalya, vt_map.MapMode.NORTH); 240 vt_map.ChangeDirectionSpriteEvent.Create("Kalya looks west", kalya, vt_map.MapMode.WEST); 241 vt_map.ChangeDirectionSpriteEvent.Create("Kalya looks south", kalya, vt_map.MapMode.SOUTH); 242 vt_map.LookAtSpriteEvent.Create("Kalya looks at Bronann", kalya, bronann); 243 vt_map.LookAtSpriteEvent.Create("Kalya looks at Orlinn", kalya, orlinn); 244 vt_map.LookAtSpriteEvent.Create("Bronann looks at Kalya", bronann, kalya); 245 vt_map.LookAtSpriteEvent.Create("Orlinn looks at Kalya", orlinn, kalya); 246 vt_map.LookAtSpriteEvent.Create("Orlinn looks at Bronann", orlinn, bronann); 247 248 -- entrance in the map event 249 event = vt_map.ScriptedEvent.Create("Shrine entrance event start", "shrine_entrance_event_start", ""); 250 event:AddEventLinkAtEnd("Kalya moves next to Bronann1", 100); 251 event:AddEventLinkAtEnd("Orlinn moves next to Bronann1", 100); 252 253 -- NOTE: The actual destination is set just before the actual start call 254 kalya_move_next_to_bronann_event1 = vt_map.PathMoveSpriteEvent.Create("Kalya moves next to Bronann1", kalya, 0, 0, false); 255 kalya_move_next_to_bronann_event1:AddEventLinkAtEnd("Kalya moves a bit"); 256 kalya_move_next_to_bronann_event1:AddEventLinkAtEnd("Bronann moves a bit"); 257 258 orlinn_move_next_to_bronann_event1 = vt_map.PathMoveSpriteEvent.Create("Orlinn moves next to Bronann1", orlinn, 0, 0, false); 259 orlinn_move_next_to_bronann_event1:AddEventLinkAtEnd("Orlinn moves near the passway"); 260 261 event = vt_map.PathMoveSpriteEvent.Create("Kalya moves a bit", kalya, 31, 39, false); 262 event:AddEventLinkAtEnd("Kalya looks at Bronann"); 263 event:AddEventLinkAtEnd("Dialogue about the passage to Estoria", 500); 264 265 event = vt_map.PathMoveSpriteEvent.Create("Bronann moves a bit", bronann, 29, 39, false); 266 event:AddEventLinkAtEnd("Bronann looks at Kalya"); 267 268 -- Orlinn move near the passway 269 event = vt_map.PathMoveSpriteEvent.Create("Orlinn moves near the passway", orlinn, 29, 33, true); 270 event:AddEventLinkAtEnd("Orlinn looks west"); 271 272 dialogue = vt_map.SpriteDialogue.Create(); 273 text = vt_system.Translate("You'll see. There's plenty of things I need to show you there. Plus, it's a safe place."); 274 dialogue:AddLine(text, kalya); 275 text = vt_system.Translate("Err, sis?"); 276 dialogue:AddLineEventEmote(text, orlinn, "Orlinn looks at Kalya", "", "sweat drop"); 277 text = vt_system.Translate("Our elder will also be able to help us. And you'll get a better explanation than I could ever..."); 278 dialogue:AddLine(text, kalya); 279 text = vt_system.Translate("Sis!"); 280 dialogue:AddLineEvent(text, orlinn, "Orlinn looks at Kalya", ""); 281 text = vt_system.Translate("One second, Orlinn. I'm trying to..."); 282 dialogue:AddLineEvent(text, kalya, "Kalya looks north", "Kalya looks at Bronann"); 283 text = vt_system.Translate("But Kalya, look at the passageway!"); 284 dialogue:AddLineEmote(text, orlinn, "exclamation"); 285 text = vt_system.Translate("What about the..."); 286 dialogue:AddLineEvent(text, kalya, "Kalya looks north", ""); 287 text = vt_system.Translate("No!"); 288 dialogue:AddLineEmote(text, kalya, "exclamation"); 289 event = vt_map.DialogueEvent.Create("Dialogue about the passage to Estoria", dialogue); 290 event:AddEventLinkAtEnd("Kalya runs to the blocked passage"); 291 event:AddEventLinkAtEnd("Bronann looks north"); 292 event:AddEventLinkAtEnd("Move camera to the obstructed passage"); 293 294 vt_map.ScriptedEvent.Create("Move camera to the obstructed passage", "camera_to_passage", ""); 295 296 event = vt_map.PathMoveSpriteEvent.Create("Kalya runs to the blocked passage", kalya, 27, 34, true); 297 event:AddEventLinkAtEnd("Kalya looks west"); 298 event:AddEventLinkAtEnd("Dialogue about the passage to Estoria 2"); 299 300 dialogue = vt_map.SpriteDialogue.Create(); 301 text = vt_system.Translate("No, it can't be."); 302 dialogue:AddLineEventEmote(text, kalya, "Orlinn looks at Kalya", "", "sweat drop"); 303 text = vt_system.Translate("After all we've been through, this..."); 304 dialogue:AddLineEvent(text, kalya, "Kalya looks north", ""); 305 event = vt_map.DialogueEvent.Create("Dialogue about the passage to Estoria 2", dialogue); 306 event:AddEventLinkAtEnd("Bronann goes near both"); 307 308 vt_map.ScriptedEvent.Create("Move camera back to Bronann", "camera_to_bronann", ""); 309 310 event = vt_map.PathMoveSpriteEvent.Create("Bronann goes near both", bronann, 28, 36, false); 311 event:AddEventLinkAtEnd("Bronann looks north"); 312 event:AddEventLinkAtEnd("Move camera back to Bronann"); 313 event:AddEventLinkAtEnd("Dialogue about the passage to Estoria 3"); 314 315 vt_map.AnimateSpriteEvent.Create("Orlinn laughs", orlinn, "laughing", 0); -- infinite time. 316 317 dialogue = vt_map.SpriteDialogue.Create(); 318 text = vt_system.Translate("Calm down Kalya, there must be a way to go through this somehow."); 319 dialogue:AddLineEmote(text, bronann, "sweat drop"); 320 text = vt_system.Translate("Unfortunately, yes. There is one."); 321 dialogue:AddLineEvent(text, kalya, "Kalya looks west", ""); 322 text = vt_system.Translate("We'll have to enter the ancient shrine."); 323 dialogue:AddLineEvent(text, kalya, "Kalya looks north", ""); 324 text = vt_system.Translate("If we wouldn't have gotten here all by ourselves, I would swear Banesore's army pushed us here on purpose."); 325 dialogue:AddLine(text, kalya); 326 text = vt_system.Translate("What's with this 'ancient shrine'?"); 327 dialogue:AddLineEmote(text, bronann, "thinking dots"); 328 text = vt_system.Translate("Some say it is haunted. It was sealed a long time ago, long before I was even born."); 329 dialogue:AddLineEvent(text, kalya, "Kalya looks at Bronann", ""); 330 text = vt_system.Translate("Indeed, it must be a long time ago."); 331 dialogue:AddLineEventEmote(text, orlinn, "", "Orlinn laughs", "thinking dots"); 332 text = vt_system.Translate("Orlinn!"); 333 dialogue:AddLineEventEmote(text, kalya, "Kalya looks at Orlinn", "", "exclamation"); 334 text = vt_system.Translate("Anyway, we might not be able to enter there at all. But you're right, let's have a look around first. Who knows?"); 335 dialogue:AddLineEvent(text, kalya, "Kalya looks at Bronann", ""); 336 event = vt_map.DialogueEvent.Create("Dialogue about the passage to Estoria 3", dialogue); 337 event:AddEventLinkAtEnd("Orlinn goes back to party"); 338 event:AddEventLinkAtEnd("Kalya goes back to party"); 339 340 event = vt_map.PathMoveSpriteEvent.Create("Orlinn goes back to party", orlinn, bronann, false); 341 event:AddEventLinkAtEnd("Shrine entrance event end"); 342 343 vt_map.PathMoveSpriteEvent.Create("Kalya goes back to party", kalya, bronann, false); 344 345 vt_map.ScriptedEvent.Create("Shrine entrance event end", "shrine_entrance_event_end", ""); 346 347 -- Event where Bronann opens the shrine's door... 348 event = vt_map.ScriptedEvent.Create("Shrine door opening event start", "shrine_door_opening_event_start", ""); 349 event:AddEventLinkAtEnd("Bronann moves in the middle of platform"); 350 351 event = vt_map.PathMoveSpriteEvent.Create("Bronann moves in the middle of platform", hero, 42.0, 8.0, false); 352 event:AddEventLinkAtEnd("Bronann looks north"); 353 event:AddEventLinkAtEnd("Shrine door opening event actual start"); 354 355 event = vt_map.ScriptedEvent.Create("Shrine door opening event actual start", "shrine_door_opening_event_start2", ""); 356 event:AddEventLinkAtEnd("Kalya moves next to Bronann2", 100); 357 event:AddEventLinkAtEnd("Orlinn moves next to Bronann2", 100); 358 359 -- NOTE: The actual destination is set just before the actual start call 360 kalya_move_next_to_bronann_event2 = vt_map.PathMoveSpriteEvent.Create("Kalya moves next to Bronann2", kalya, 0, 0, false); 361 kalya_move_next_to_bronann_event2:AddEventLinkAtEnd("Kalya looks north"); 362 363 orlinn_move_next_to_bronann_event2 = vt_map.PathMoveSpriteEvent.Create("Orlinn moves next to Bronann2", orlinn, 0, 0, false); 364 orlinn_move_next_to_bronann_event2:AddEventLinkAtEnd("Orlinn looks north"); 365 orlinn_move_next_to_bronann_event2:AddEventLinkAtEnd("Dialogue before opening the door", 500); 366 367 vt_map.AnimateSpriteEvent.Create("Bronann kneels", bronann, "kneeling", 0); -- 0 means forever 368 369 dialogue = vt_map.SpriteDialogue.Create(); 370 text = vt_system.Translate("Here we are, looking at this huge and wonderful, yet creepy door. I don't like this."); 371 dialogue:AddLineEmote(text, kalya, "thinking dots"); 372 text = vt_system.Translate("It's not like I actually want to open this, but how are we going to do so?"); 373 dialogue:AddLineEventEmote(text, kalya, "Kalya looks at Bronann", "Orlinn looks at Bronann", "sweat drop"); 374 event = vt_map.DialogueEvent.Create("Dialogue before opening the door", dialogue); 375 event:AddEventLinkAtEnd("Show hurt effect"); 376 377 event = vt_map.ScriptedEvent.Create("Show hurt effect", "hurt_effect_start", "hurt_effect_update") 378 event:AddEventLinkAtEnd("Dialogue before opening the door2"); 379 380 dialogue = vt_map.SpriteDialogue.Create(); 381 text = vt_system.Translate("Ow, my chest. It hurts!"); 382 dialogue:AddLineEventEmote(text, bronann, "Bronann looks south", "Bronann kneels", "exclamation"); 383 text = vt_system.Translate("The crystal! Orlinn! Let's stand back!"); 384 dialogue:AddLineEmote(text, kalya, "exclamation"); 385 event = vt_map.DialogueEvent.Create("Dialogue before opening the door2", dialogue); 386 event:AddEventLinkAtEnd("Orlinn rushes down the stairs"); 387 event:AddEventLinkAtEnd("Kalya rushes down the stairs"); 388 389 event = vt_map.PathMoveSpriteEvent.Create("Kalya rushes down the stairs", kalya, 43.0, 16.0, true); 390 event:AddEventLinkAtEnd("Kalya looks north"); 391 392 event = vt_map.PathMoveSpriteEvent.Create("Orlinn rushes down the stairs", orlinn, 41.0, 16.0, true); 393 event:AddEventLinkAtEnd("Orlinn goes behind Kalya"); 394 395 event = vt_map.PathMoveSpriteEvent.Create("Orlinn goes behind Kalya", orlinn, 42.6, 17.0, true); 396 event:AddEventLinkAtEnd("Orlinn looks north"); 397 event:AddEventLinkAtEnd("The crystal opens the door"); 398 399 event = vt_map.ScriptedEvent.Create("The crystal opens the door", "show_crystal", "show_crystal_update"); 400 event:AddEventLinkAtEnd("Dialogue after crystals appearance"); 401 402 dialogue = vt_map.SpriteDialogue.Create(); 403 text = vt_system.Translate("That sign, it is the sign of the ancients! Bronann! Are you alright?"); 404 dialogue:AddLineEmote(text, kalya, "exclamation"); 405 event = vt_map.DialogueEvent.Create("Dialogue after crystals appearance", dialogue); 406 event:AddEventLinkAtEnd("Bronann gets up", 1200); 407 408 -- Simply stop the custom animation 409 event = vt_map.ScriptedSpriteEvent.Create("Bronann gets up", bronann, "Terminate_all_events", ""); 410 event:AddEventLinkAtEnd("Dialogue after crystals appearance2", 1000); 411 412 dialogue = vt_map.SpriteDialogue.Create(); 413 text = vt_system.Translate("I'm fine, I guess. The pain faded away."); 414 dialogue:AddLineEvent(text, bronann, "Bronann looks south", ""); 415 text = vt_system.Translate("Thank the goddess."); 416 dialogue:AddLineEmote(text, kalya, "sweat drop"); 417 text = vt_system.Translate("Well, the door is open now."); 418 dialogue:AddLineEmote(text, kalya, "thinking dots"); 419 text = vt_system.Translate("Yiek! Do you really want to go there??"); 420 dialogue:AddLineEmote(text, orlinn, "sweat drop"); 421 text = vt_system.Translate("I believe we don't really have a choice. Somehow this place... called me."); 422 dialogue:AddLineEventEmote(text, bronann, "Bronann looks north", "", "thinking dots"); 423 text = vt_system.Translate("Anyway, let's stick together and we'll be fine as always, right?"); 424 dialogue:AddLineEvent(text, kalya, "Kalya looks at Orlinn", ""); 425 text = vt_system.Translate("I have a bad feeling about all this now."); 426 dialogue:AddLineEvent(text, orlinn, "Orlinn looks at Kalya", ""); 427 event = vt_map.DialogueEvent.Create("Dialogue after crystals appearance2", dialogue); 428 event:AddEventLinkAtEnd("Orlinn goes back to party2"); 429 event:AddEventLinkAtEnd("Kalya goes back to party2"); 430 431 event = vt_map.PathMoveSpriteEvent.Create("Orlinn goes back to party2", orlinn, bronann, false); 432 event:AddEventLinkAtEnd("Shrine door opening event end"); 433 434 vt_map.PathMoveSpriteEvent.Create("Kalya goes back to party2", kalya, bronann, false); 435 436 vt_map.ScriptedEvent.Create("Shrine door opening event end", "shrine_door_opening_event_end", ""); 437end 438 439-- zones 440local to_shrine_zone = nil 441local to_mountain_bridge_zone = nil 442local shrine_door_opening_zone = nil 443 444-- Create the different map zones triggering events 445function _CreateZones() 446 -- N.B.: left, right, top, bottom 447 to_shrine_zone = vt_map.CameraZone.Create(40, 44, 2, 4); 448 to_mountain_bridge_zone = vt_map.CameraZone.Create(26, 32, 46, 48); 449 shrine_door_opening_zone = vt_map.CameraZone.Create(40, 44, 8, 10); 450end 451 452-- Check whether the active camera has entered a zone. To be called within Update() 453function _CheckZones() 454 if (to_shrine_zone:IsCameraEntering() == true) then 455 hero:SetMoving(false); 456 if (GlobalManager:GetGameEvents():GetEventValue("triggers", "mt elbrus waterfall trigger") == 0) then 457 EventManager:StartEvent("to mountain shrine"); 458 else 459 EventManager:StartEvent("to mountain shrine-waterfalls"); 460 end 461 elseif (to_mountain_bridge_zone:IsCameraEntering() == true) then 462 hero:SetMoving(false); 463 EventManager:StartEvent("to mountain bridge"); 464 elseif (shrine_door_opening_zone:IsCameraEntering() == true and Map:CurrentState() == vt_map.MapMode.STATE_EXPLORE) then 465 if (GlobalManager:GetGameEvents():GetEventValue("story", "mt_elbrus_shrine_door_opening_event") == 0) then 466 hero:SetMoving(false); 467 EventManager:StartEvent("Shrine door opening event start"); 468 end 469 end 470end 471 472-- Opens the shrine door 473function _open_shrine_door() 474 -- Permit the entrance into the shrine... 475 shrine_entrance_door:SetCollisionMask(vt_map.MapMode.NO_COLLISION); 476 -- Makes the door open 477 local opening_anim_id = shrine_entrance_door:AddAnimation("data/entities/map/objects/door_big1_opening.lua"); 478 shrine_entrance_door:SetCurrentAnimation(opening_anim_id); 479end 480 481-- Set the shrine door as opened 482function _set_shrine_door_open() 483 -- Permit the entrance into the shrine... 484 shrine_entrance_door:SetCollisionMask(vt_map.MapMode.NO_COLLISION); 485 -- Makes the door open 486 local open_anim_id = shrine_entrance_door:AddAnimation("data/entities/map/objects/door_big1_open.lua"); 487 shrine_entrance_door:SetCurrentAnimation(open_anim_id); 488end 489 490function _show_flames() 491 vt_map.SoundObject.Create("data/sounds/campfire.ogg", 33.0, 9.1, 10.0); 492 vt_map.SoundObject.Create("data/sounds/campfire.ogg", 51.0, 9.1, 10.0); 493 494 vt_map.Halo.Create("data/visuals/lights/torch_light_mask2.lua", 33.0, 9.1 + 3.0, 495 vt_video.Color(0.85, 0.32, 0.0, 0.6)); 496 vt_map.Halo.Create("data/visuals/lights/sun_flare_light_main.lua", 33.0, 9.1 + 2.0, 497 vt_video.Color(0.99, 1.0, 0.27, 0.1)); 498 vt_map.Halo.Create("data/visuals/lights/torch_light_mask2.lua", 51.0, 9.1 + 3.0, 499 vt_video.Color(0.85, 0.32, 0.0, 0.6)); 500 vt_map.Halo.Create("data/visuals/lights/sun_flare_light_main.lua", 51.0, 9.1 + 2.0, 501 vt_video.Color(0.99, 1.0, 0.27, 0.1)); 502 503 shrine_flame1:SetVisible(true); 504 shrine_flame2:SetVisible(true); 505end 506 507-- Effect time used when applying the heal light effect 508local heal_effect_time = 0; 509local heal_color = vt_video.Color(0.0, 0.0, 1.0, 1.0); 510 511-- Shown when Bronnan feels bad. 512local hurt_effect_time = 0; 513local hurt_color = vt_video.Color(1.0, 0.0, 0.0, 1.0); 514 515-- Used in the crystal appearance scene. 516local crystal_appearance_time = 0; 517local ancient_sign_visible = false; 518 519-- Map Custom functions 520-- Used through scripted events 521map_functions = { 522 heal_party = function() 523 hero:SetMoving(false); 524 -- Should be sufficient to heal anybody 525 local character_handler = GlobalManager:GetCharacterHandler() 526 character_handler:GetActiveParty():AddHitPoints(10000) 527 character_handler:GetActiveParty():AddSkillPoints(10000) 528 Map:SetStamina(10000) 529 Map:RemoveNegativeActiveStatusEffects() 530 AudioManager:PlaySound("data/sounds/heal_spell.wav"); 531 heal_effect:SetPosition(hero:GetXPosition(), hero:GetYPosition()); 532 heal_effect:Start(); 533 heal_effect_time = 0; 534 end, 535 536 heal_done = function() 537 heal_effect_time = heal_effect_time + SystemManager:GetUpdateTime(); 538 539 if (heal_effect_time < 300.0) then 540 heal_color:SetAlpha(heal_effect_time / 300.0 / 3.0); 541 Map:GetEffectSupervisor():EnableLightingOverlay(heal_color); 542 return false; 543 end 544 545 if (heal_effect_time < 1000.0) then 546 heal_color:SetAlpha(((1000.0 - heal_effect_time) / 700.0) / 3.0); 547 Map:GetEffectSupervisor():EnableLightingOverlay(heal_color); 548 return false; 549 end 550 return true; 551 end, 552 553 shrine_entrance_event_start = function() 554 Map:PushState(vt_map.MapMode.STATE_SCENE); 555 hero:SetMoving(false); 556 557 bronann:SetPosition(hero:GetXPosition(), hero:GetYPosition()) 558 bronann:SetDirection(hero:GetDirection()) 559 bronann:SetVisible(true) 560 hero:SetVisible(false) 561 Map:SetCamera(bronann) 562 hero:SetPosition(0, 0) 563 564 kalya:SetPosition(bronann:GetXPosition(), bronann:GetYPosition()); 565 kalya:SetVisible(true); 566 orlinn:SetPosition(bronann:GetXPosition(), bronann:GetYPosition()); 567 orlinn:SetVisible(true); 568 kalya:SetCollisionMask(vt_map.MapMode.NO_COLLISION); 569 orlinn:SetCollisionMask(vt_map.MapMode.NO_COLLISION); 570 571 kalya_move_next_to_bronann_event1:SetDestination(bronann:GetXPosition() + 2.0, bronann:GetYPosition(), false); 572 orlinn_move_next_to_bronann_event1:SetDestination(bronann:GetXPosition() - 2.0, bronann:GetYPosition(), false); 573 end, 574 575 camera_to_passage = function() 576 Map:MoveVirtualFocus(15, 30); 577 Map:SetCamera(Map:GetVirtualFocus(), 1000); 578 end, 579 580 camera_to_hero = function() 581 Map:SetCamera(hero, 2000); 582 end, 583 584 camera_to_bronann = function() 585 Map:SetCamera(bronann, 2000); 586 end, 587 588 shrine_entrance_event_end = function() 589 Map:PopState(); 590 kalya:SetPosition(0, 0); 591 kalya:SetVisible(false); 592 kalya:SetCollisionMask(vt_map.MapMode.NO_COLLISION); 593 orlinn:SetPosition(0, 0); 594 orlinn:SetVisible(false); 595 orlinn:SetCollisionMask(vt_map.MapMode.NO_COLLISION); 596 597 hero:SetPosition(bronann:GetXPosition(), bronann:GetYPosition()) 598 hero:SetDirection(bronann:GetDirection()) 599 hero:SetVisible(true) 600 bronann:SetVisible(false) 601 Map:SetCamera(hero) 602 bronann:SetPosition(0, 0) 603 604 -- Set event as done 605 GlobalManager:GetGameEvents():SetEventValue("story", "mt_elbrus_shrine_entrance_event", 1); 606 end, 607 608 shrine_door_opening_event_start = function() 609 Map:PushState(vt_map.MapMode.STATE_SCENE); 610 hero:SetMoving(false); 611 end, 612 613 shrine_door_opening_event_start2 = function() 614 bronann:SetPosition(hero:GetXPosition(), hero:GetYPosition()) 615 bronann:SetDirection(hero:GetDirection()) 616 bronann:SetVisible(true) 617 hero:SetVisible(false) 618 Map:SetCamera(bronann) 619 hero:SetPosition(0, 0) 620 621 kalya:SetPosition(bronann:GetXPosition(), bronann:GetYPosition()); 622 kalya:SetVisible(true); 623 orlinn:SetPosition(bronann:GetXPosition(), bronann:GetYPosition()); 624 orlinn:SetVisible(true); 625 kalya:SetCollisionMask(vt_map.MapMode.NO_COLLISION); 626 orlinn:SetCollisionMask(vt_map.MapMode.NO_COLLISION); 627 628 kalya_move_next_to_bronann_event2:SetDestination(bronann:GetXPosition() + 2.0, bronann:GetYPosition(), false); 629 orlinn_move_next_to_bronann_event2:SetDestination(bronann:GetXPosition() - 2.0, bronann:GetYPosition(), false); 630 end, 631 632 hurt_effect_start = function() 633 hurt_effect_time = 0; 634 AudioManager:PlaySound("data/sounds/heartbeat_slow.wav"); 635 end, 636 637 hurt_effect_update = function() 638 hurt_effect_time = hurt_effect_time + SystemManager:GetUpdateTime(); 639 640 if (hurt_effect_time < 300.0) then 641 hurt_color:SetAlpha(hurt_effect_time / 300.0 / 3.0); 642 Map:GetEffectSupervisor():EnableLightingOverlay(hurt_color); 643 return false; 644 end 645 646 if (hurt_effect_time < 600.0) then 647 hurt_color:SetAlpha(((600.0 - hurt_effect_time) / 300.0) / 3.0); 648 Map:GetEffectSupervisor():EnableLightingOverlay(hurt_color); 649 return false; 650 end 651 return true; 652 end, 653 654 show_crystal = function() 655 -- Triggers the crystal appearance 656 GlobalManager:GetGameEvents():SetEventValue("scripts_events", "shrine_entrance_show_crystal", 1) 657 crystal_appearance_time = 0; 658 ancient_sign_visible = false; 659 end, 660 661 show_crystal_update = function() 662 -- Show the ancient sign on ground. 663 if (ancient_sign_visible == false) then 664 crystal_appearance_time = crystal_appearance_time + SystemManager:GetUpdateTime(); 665 if (crystal_appearance_time >= 8000) then 666 shrine_entrance_sign:SetVisible(true); 667 ancient_sign_visible = true; 668 AudioManager:PlaySound("data/sounds/ancient_invocation.wav"); 669 end 670 end 671 if (GlobalManager:GetGameEvents():GetEventValue("scripts_events", "shrine_entrance_show_crystal") == 0) then 672 Map:GetEffectSupervisor():ShakeScreen(0.4, 2200, vt_mode_manager.EffectSupervisor.SHAKE_FALLOFF_GRADUAL); 673 AudioManager:PlaySound("data/sounds/cave-in.ogg"); 674 _open_shrine_door(); 675 -- Show a slight fire spiral effect. 676 Map:GetParticleManager():AddParticleEffect("data/visuals/particle_effects/fire_spiral.lua", 512.0, 284.0); 677 _show_flames(); 678 return true; 679 end 680 return false; 681 end, 682 683 shrine_door_opening_event_end = function() 684 Map:PopState(); 685 kalya:SetPosition(0, 0); 686 kalya:SetVisible(false); 687 kalya:SetCollisionMask(vt_map.MapMode.NO_COLLISION); 688 orlinn:SetPosition(0, 0); 689 orlinn:SetVisible(false); 690 orlinn:SetCollisionMask(vt_map.MapMode.NO_COLLISION); 691 692 hero:SetPosition(bronann:GetXPosition(), bronann:GetYPosition()) 693 hero:SetDirection(bronann:GetDirection()) 694 hero:SetVisible(true) 695 bronann:SetVisible(false) 696 Map:SetCamera(hero) 697 bronann:SetPosition(0, 0) 698 699 -- Set event as done 700 GlobalManager:GetGameEvents():SetEventValue("story", "mt_elbrus_shrine_door_opening_event", 1); 701 end, 702} 703