|
| 1 | +----------------------------------- |
| 2 | +-- Full Speed Ahead! Helper |
| 3 | +----------------------------------- |
| 4 | +local ID = require("scripts/zones/Batallia_Downs/IDs") |
| 5 | +require("scripts/globals/status") |
| 6 | +require("scripts/globals/utils") |
| 7 | +require("scripts/globals/zone") |
| 8 | +----------------------------------- |
| 9 | + |
| 10 | +--[[ |
| 11 | +Debugging: |
| 12 | +Reset: !delquest 3 179 |
| 13 | +
|
| 14 | +CharVar: [QUEST]FullSpeedAhead == ... |
| 15 | +1 : Starting minigame on Normal Mode |
| 16 | +2 : Starting minigame on Easy Mode |
| 17 | +3 : Minigame active/playable |
| 18 | +4 : Minigame complete, time to hand in |
| 19 | +
|
| 20 | +FULL_SPEED_AHEAD effect power: |
| 21 | +0 : Normal Mode |
| 22 | +1 : Easy Mode |
| 23 | +]]-- |
| 24 | + |
| 25 | +tpz = tpz or {} |
| 26 | +tpz.full_speed_ahead = tpz.full_speed_ahead or {} |
| 27 | + |
| 28 | +tpz.full_speed_ahead.duration = 600 |
| 29 | +tpz.full_speed_ahead.motivation_decay = 2 |
| 30 | +tpz.full_speed_ahead.motivation_food_bonus = 15 |
| 31 | +tpz.full_speed_ahead.pep_growth = 1 |
| 32 | + |
| 33 | +tpz.full_speed_ahead.onEffectGain = function(player, effect) |
| 34 | + player:setLocalVar("FSA_Time", os.time() + tpz.full_speed_ahead.duration) |
| 35 | + player:setLocalVar("FSA_Motivation", 100) |
| 36 | + player:setLocalVar("FSA_Pep", 0) |
| 37 | + player:setLocalVar("FSA_Food", 0xFF) |
| 38 | + player:setLocalVar("FSA_FoodCount", 0) |
| 39 | + player:addStatusEffect(tpz.effect.MOUNTED, tpz.mount.QUEST_RAPTOR, 3, 0) |
| 40 | + player:setCharVar("[QUEST]FullSpeedAhead", 3) |
| 41 | +end |
| 42 | + |
| 43 | +tpz.full_speed_ahead.onEffectLose = function(player, effect) |
| 44 | + player:delStatusEffectSilent(tpz.effect.MOUNTED) |
| 45 | + player:countdown(0) |
| 46 | + player:enableEntities({}) |
| 47 | + |
| 48 | + -- If in Batallia Downs and didn't get the completion flag (failed/dismounted) |
| 49 | + if player:getZoneID() == tpz.zone.BATALLIA_DOWNS and player:getCharVar("[QUEST]FullSpeedAhead") ~= 4 then |
| 50 | + player:startEvent(26, 0, effect:getPower()) |
| 51 | + end |
| 52 | +end |
| 53 | + |
| 54 | +tpz.full_speed_ahead.tick = function(player, effect) |
| 55 | + player:setLocalVar("FSA_Motivation", player:getLocalVar("FSA_Motivation") - tpz.full_speed_ahead.motivation_decay + effect:getPower()) |
| 56 | + player:setLocalVar("FSA_Pep", player:getLocalVar("FSA_Pep") + tpz.full_speed_ahead.pep_growth + effect:getPower()) |
| 57 | + |
| 58 | + local timeLeft = player:getLocalVar("FSA_Time") - os.time() |
| 59 | + local motivation = player:getLocalVar("FSA_Motivation") |
| 60 | + local pep = player:getLocalVar("FSA_Pep") |
| 61 | + local food_byte = player:getLocalVar("FSA_Food") |
| 62 | + local food_count = player:getLocalVar("FSA_FoodCount") |
| 63 | + |
| 64 | + local food_data = {} |
| 65 | + for i = 0, 7 do |
| 66 | + if bit.band(food_byte, bit.lshift(1, i)) > 0 then |
| 67 | + table.insert(food_data, ID.npc.BLUE_BEAM_BASE + i) |
| 68 | + table.insert(food_data, ID.npc.RAPTOR_FOOD_BASE + i) |
| 69 | + end |
| 70 | + end |
| 71 | + |
| 72 | + if motivation <= 0 or timeLeft <= 0 or not player:hasStatusEffect(tpz.effect.MOUNTED) then |
| 73 | + player:delStatusEffectSilent(tpz.effect.FULL_SPEED_AHEAD) |
| 74 | + else |
| 75 | + player:countdown(timeLeft, "Motivation", motivation, "Pep", pep) |
| 76 | + player:enableEntities(food_data) |
| 77 | + end |
| 78 | +end |
| 79 | + |
| 80 | +tpz.full_speed_ahead.onRegionEnter = function(player, index) |
| 81 | + local food_byte = player:getLocalVar("FSA_Food") |
| 82 | + local food_count = player:getLocalVar("FSA_FoodCount") |
| 83 | + local motivation = player:getLocalVar("FSA_Motivation") |
| 84 | + |
| 85 | + if index == 9 and food_count >= 5 then -- Syrillia |
| 86 | + player:startEvent(24) -- End CS and teleport |
| 87 | + elseif bit.band(food_byte, bit.lshift(1, index - 1)) > 0 then |
| 88 | + local new_food_byte = food_byte - bit.lshift(1, index - 1) |
| 89 | + player:setLocalVar("FSA_Food", new_food_byte) |
| 90 | + player:setLocalVar("FSA_FoodCount", food_count + 1) |
| 91 | + |
| 92 | + local new_food_count = player:getLocalVar("FSA_FoodCount") |
| 93 | + local new_motivation = utils.clamp(motivation + tpz.full_speed_ahead.motivation_food_bonus, 0, 100) |
| 94 | + player:setLocalVar("FSA_Motivation", new_motivation) |
| 95 | + |
| 96 | + -- Hearts |
| 97 | + player:independantAnimation(player, 251, 4) |
| 98 | + |
| 99 | + player:messageSpecial(ID.text.RAPTOR_OVERCOME_MUNCHIES, new_food_count, 5) |
| 100 | + |
| 101 | + if new_food_count == 5 then |
| 102 | + player:messageSpecial(ID.text.MEET_SYRILLIA) |
| 103 | + end |
| 104 | + end |
| 105 | +end |
| 106 | + |
| 107 | +tpz.full_speed_ahead.onCheer = function(player) |
| 108 | + local timeLeft = player:getLocalVar("FSA_Time") - os.time() |
| 109 | + local motivation = player:getLocalVar("FSA_Motivation") |
| 110 | + local pep = player:getLocalVar("FSA_Pep") |
| 111 | + |
| 112 | + local new_motivation = utils.clamp(motivation + (pep / 2), 0, 100) |
| 113 | + |
| 114 | + player:setLocalVar("FSA_Motivation", new_motivation) |
| 115 | + player:setLocalVar("FSA_Pep", 0) |
| 116 | + |
| 117 | + player:messageSpecial(ID.text.RAPTOR_SECOND_WIND) |
| 118 | + |
| 119 | + -- Music Notes |
| 120 | + player:independantAnimation(player, 252, 4) |
| 121 | + |
| 122 | + player:countdown(timeLeft, "Motivation", new_motivation, "Pep", 0) |
| 123 | +end |
| 124 | + |
| 125 | +tpz.full_speed_ahead.completeGame = function(player) |
| 126 | + player:setCharVar("[QUEST]FullSpeedAhead", 4) |
| 127 | + player:delStatusEffectSilent(tpz.effect.FULL_SPEED_AHEAD) |
| 128 | + player:setPos(-104.5, 0, 187.4, 64, 244) |
| 129 | +end |
| 130 | + |
| 131 | +tpz.fsa = tpz.full_speed_ahead |
0 commit comments