1local ns = {} 2setmetatable(ns, {__index = _G}) 3battle_with_banesore_script = ns; 4setfenv(1, ns); 5 6local Battle = nil 7local Script = nil 8local DialogueManager = nil 9local start_timer = nil 10 11-- The overall time of active battle. 12local battle_time = 0 13 14local dialogue1_done = false; 15local dialogue2_done = false; 16local dialogue3_done = false; 17local dialogue4_done = false; 18local battle_exit_done = false; 19 20local fire1 = nil 21local fire1_1 = nil 22local fire1_2 = nil 23 24local soldier = nil 25local lilly = nil 26local herth_walking = nil; -- starting value 27 28local lilly_charge_time = 0; 29local lilly_reaction_time = 1200; 30 31local herth_x_position = 0.0; 32local bronann = nil 33 34function Initialize(battle_instance) 35 Battle = battle_instance; 36 Script = Battle:GetScriptSupervisor(); 37 38 fire1 = Script:CreateAnimation("data/entities/map/objects/campfire1.lua"); 39 fire1:SetDimensions(128.0, 128.0); 40 fire1_1 = Script:CreateAnimation("data/visuals/lights/torch_light_mask2.lua"); 41 fire1_1:SetDimensions(340.0, 340.0); 42 fire1_2 = Script:CreateImage("data/visuals/lights/sun_flare_light.png"); 43 fire1_2:SetDimensions(154.0, 161.0); 44 45 soldier = Script:CreateAnimation("data/story/layna_village/battle_with_banesore/battle_dark_soldier_idle_down.lua"); 46 soldier:SetDimensions(150.0, 150.0); 47 lilly = Script:CreateAnimation("data/story/layna_village/battle_with_banesore/battle_lilly_idle_down.lua"); 48 lilly:SetDimensions(70.0, 140.0); 49 50 local text = nil 51 local dialogue = nil 52 53 DialogueManager = Battle:GetDialogueSupervisor(); 54 55 -- Add all speakers for the dialogues to be added 56 DialogueManager:AddSpeaker("Bronann", vt_system.Translate("Bronann"), "data/entities/portraits/bronann.png"); 57 DialogueManager:AddSpeaker("Banesore", vt_system.Translate("Banesore"), "data/entities/portraits/npcs/lord_banesore.png"); 58 DialogueManager:AddSpeaker("Herth", vt_system.Translate("Herth"), "data/entities/portraits/npcs/herth.png"); 59 DialogueManager:AddSpeaker("Lilly", vt_system.Translate("Lilly"), ""); 60 61 dialogue = vt_common.Dialogue.Create(DialogueManager, "Battle intro dialogue"); 62 text = vt_system.Translate("So, you think you can wound me?"); 63 dialogue:AddLine(text, "Banesore"); 64 text = vt_system.Translate("You? A child with an old wooden stick?"); 65 dialogue:AddLine(text, "Banesore"); 66 text = vt_system.Translate("..."); 67 dialogue:AddLine(text, "Bronann"); 68 69 dialogue = vt_common.Dialogue.Create(DialogueManager, "'Stronger than I thought' dialogue"); 70 text = vt_system.Translate("You're stronger than I thought. But you are still too weak to challenge me!"); 71 dialogue:AddLine(text, "Banesore"); 72 73 dialogue = vt_common.Dialogue.Create(DialogueManager, "Herth appears"); 74 text = vt_system.Translate("Argh! It hurts!"); 75 dialogue:AddLine(text, "Bronann"); 76 text = vt_system.Translate("Yes! I can feel it coming closer to the surface!"); 77 dialogue:AddLine(text, "Banesore"); 78 text = vt_system.Translate("Let your fear grow, young boy!"); 79 dialogue:AddLine(text, "Banesore"); 80 text = vt_system.Translate("Bronann, don't listen to him!"); 81 dialogue:AddLine(text, "Herth"); 82 83 dialogue = vt_common.Dialogue.Create(DialogueManager, "Battle ending dialogue"); 84 text = vt_system.Translate("I will... try."); 85 dialogue:AddLine(text, "Bronann"); 86 text = vt_system.Translate("Hmph. Soldiers, leave that man to me!"); 87 dialogue:AddLine(text, "Banesore"); 88 text = vt_system.Translate("So, it appears that you remember me, Banesore. Is that correct?"); 89 dialogue:AddLine(text, "Herth"); 90 text = vt_system.Translate("I do remember you, old man..."); 91 dialogue:AddLine(text, "Banesore"); 92 text = vt_system.Translate("Then, you already know that your zombified soldiers are no match for me."); 93 dialogue:AddLine(text, "Herth"); 94 text = vt_system.Translate("Argh! My chest is burning!"); 95 dialogue:AddLine(text, "Bronann"); 96 97 -- Lilly helps Bronann 98 dialogue = vt_common.Dialogue.Create(DialogueManager, "Lilly helps Bronann dialogue"); 99 text = vt_system.Translate("Hold on Bronann!"); 100 dialogue:AddLine(text, "Lilly"); 101 102 -- Construct a timer so we can start the dialogue a couple seconds after the battle begins 103 start_timer = vt_system.SystemTimer(100, 0); 104 105 battle_time = 0; 106 dialogue1_done = false; 107 dialogue2_done = false; 108 dialogue3_done = false; 109 dialogue4_done = false; 110 battle_exit_done = false; 111 112 -- Add a charge time at the end of which Lilly can help Bronann 113 lilly_charge_time = 1200; 114 -- Time Lilly waits before actually healing Bronann 115 -- (to avoid triggering the Heal in the middle of Banesore's attack) 116 lilly_reaction_time = 1200; 117 118 -- Set Herth's starting x position 119 herth_x_position = 0.0; 120 121 -- Get Bronann actor 122 bronann = Battle:GetCharacterActor(0); 123end 124 125function Restart() 126 battle_time = 0; 127 dialogue1_done = false; 128 dialogue2_done = false; 129 dialogue3_done = false; 130 dialogue4_done = false; 131 battle_exit_done = false; 132 133 -- Add a charge time at the end of which lilly can help Bronann 134 lilly_charge_time = 1200; 135 136 -- Set Herth's starting x position 137 herth_x_position = 0.0; 138 139 -- Get Bronann actor 140 bronann = Battle:GetCharacterActor(0); 141 142 start_timer:Reset(); 143end 144 145 146function Update() 147 148 start_timer:Update(); 149 150 -- get time expired 151 local time_expired = SystemManager:GetUpdateTime(); 152 153 -- Update the animations 154 if (herth_walking ~= nil) then 155 herth_walking:Update(time_expired); 156 end 157 lilly:Update(time_expired); 158 soldier:Update(time_expired); 159 fire1:Update(time_expired); 160 fire1_1:Update(time_expired); 161 162 -- Wait until the initial battle sequence ends to begin running the dialogue start timer 163 if ((start_timer:IsInitial() == true) and (Battle:GetState() ~= vt_battle.BattleMode.BATTLE_STATE_INITIAL)) then 164 start_timer:Run(); 165 end 166 167 -- Wait for the battle to start 168 if (start_timer:IsFinished() == false) then 169 return; 170 end 171 172 -- Update herth position until he is in place 173 if (dialogue3_done == true and DialogueManager:IsDialogueActive() == false) then 174 if (herth_walking == nil) then 175 -- Load and start Herth animation only after the dialogue 3. 176 herth_walking = Script:CreateAnimation("data/story/layna_village/battle_with_banesore/herth_walking.lua"); 177 herth_walking:SetDimensions(70.0, 140.0); 178 end 179 if (herth_x_position <= 175.0) then 180 herth_x_position = herth_x_position + time_expired * 0.7; 181 end 182 end 183 184 -- If the dialogue has not been seen yet, check if its time to start it 185 if (DialogueManager:IsDialogueActive() == true) then 186 return; 187 end 188 189 -- Don't play a dialogue when bronann is acting 190 if (bronann:GetState() ~= vt_battle.BattleMode.ACTOR_STATE_IDLE and bronann:GetState() ~= vt_battle.BattleMode.ACTOR_STATE_COMMAND) then 191 return; 192 end 193 194 -- Stay in scene mode once the battle is over 195 if (battle_exit_done == true) then 196 return; 197 end 198 199 Battle:SetSceneMode(false); 200 201 -- Bronann is hurt by the crystal 202 if (dialogue4_done == true and battle_exit_done == false) then 203 Battle:SetSceneMode(true); 204 ModeManager:Pop(true, true); 205 battle_exit_done = true; 206 --Change Bronann animation 207 bronann:ChangeSpriteAnimation("poor"); 208 end 209 210 -- Only update the expired dialogue time when the battle isn't in scene mode 211 -- and the actors aren't paused... 212 if (Battle:AreActorStatesPaused() == false) then 213 battle_time = battle_time + time_expired; 214 215 if (lilly_charge_time > 0) then 216 lilly_charge_time = lilly_charge_time - time_expired; 217 elseif (lilly_reaction_time > 0 and bronann:GetHitPoints() <= 80) then 218 lilly_reaction_time = lilly_reaction_time - time_expired; 219 end 220 end 221 222 -- Lilly discretly helps Bronann: 223 -- - When Bronann's HP are low and at least a few seconds have passed 224 -- - And the dialogue with Herth isn't done. 225 if (dialogue3_done == false and lilly_reaction_time <= 0) then 226 DialogueManager:StartDialogue("Lilly helps Bronann dialogue"); 227 Battle:SetSceneMode(true); 228 -- Set the time depending on the game difficulty 229 if (SystemManager:GetGameDifficulty() == 1) then 230 lilly_charge_time = 500; -- Easy 231 else 232 lilly_charge_time = 1200; 233 end 234 lilly_reaction_time = 1200; 235 lilly_heals_bronann(); 236 end 237 238 if (dialogue1_done == false) then 239 DialogueManager:StartDialogue("Battle intro dialogue"); 240 Battle:SetSceneMode(true); 241 dialogue1_done = true; 242 end 243 244 if (battle_time >= 10000 and dialogue2_done == false) then 245 DialogueManager:StartDialogue("'Stronger than I thought' dialogue"); 246 Battle:SetSceneMode(true); 247 dialogue2_done = true; 248 end 249 250 -- Make Herth appear and help Bronann to flee 251 if (battle_time >= 20000 and dialogue3_done == false) then 252 DialogueManager:StartDialogue("Herth appears"); 253 Battle:SetSceneMode(true); 254 dialogue3_done = true; 255 bronann:ChangeSpriteAnimation("poor"); 256 end 257 258 -- Once Herth is in place, let's trigger the last dialogue 259 if (dialogue3_done == true and herth_x_position >= 175.0) then 260 if (dialogue4_done == false) then 261 DialogueManager:StartDialogue("Battle ending dialogue"); 262 Battle:SetSceneMode(true); 263 dialogue4_done = true; 264 end 265 end 266 267end 268 269local light_mask1_color = vt_video.Color(0.85, 0.32, 0.0, 0.7); 270local light_mask2_color = vt_video.Color(0.99, 1.0, 0.27, 0.5); 271local white_color = vt_video.Color(1.0, 1.0, 1.0, 1.0); 272 273function DrawBackground() 274 Script:SetDrawFlag(vt_video.GameVideo.VIDEO_BLEND); 275 276 VideoManager:Move(130.0, 280.0); 277 soldier:Draw(white_color); 278 VideoManager:Move(75.0, 250.0); 279 lilly:Draw(white_color); 280 281 VideoManager:Move(300.0, 290.0); 282 soldier:Draw(white_color); 283 VideoManager:Move(495.0, 330.0); 284 soldier:Draw(white_color); 285 286 VideoManager:Move(795.0, 250.0); 287 soldier:Draw(white_color); 288 289 VideoManager:Move(235.0, 340.0); 290 fire1:Draw(white_color); 291 292 Script:SetDrawFlag(vt_video.GameVideo.VIDEO_BLEND_ADD); 293 VideoManager:Move(115.0, 270.0); 294 fire1_1:Draw(light_mask1_color); 295 VideoManager:Move(220.0, 350.0); 296 fire1_2:Draw(light_mask2_color); 297end 298 299function DrawForeground() 300 if (dialogue3_done == true and herth_walking ~= nil) then 301 VideoManager:Move(herth_x_position, 450.0); 302 herth_walking:Draw(white_color); 303 end 304end 305 306function lilly_heals_bronann() 307 local hit_points = 60 308 309 if (SystemManager:GetGameDifficulty() == 1) then 310 hit_points = hit_points + vt_utils.RandomBoundedInteger(70, 150); -- Easy 311 else 312 hit_points = hit_points + vt_utils.RandomBoundedInteger(50, 80); 313 end 314 315 bronann:RegisterHealing(hit_points, true); 316 AudioManager:PlaySound("data/sounds/heal_spell.wav"); 317 Battle:TriggerBattleParticleEffect("data/visuals/particle_effects/heal_particle.lua", 318 bronann:GetXLocation(), bronann:GetYLocation() + 5); 319end 320