Skip to content
This repository was archived by the owner on Dec 4, 2020. It is now read-only.

Commit 0f12d94

Browse files
committed
Merge branch 'raptor-speed' into release
# Conflicts: # scripts/zones/Batallia_Downs/Zone.lua # scripts/zones/Upper_Jeuno/npcs/Mapitoto.lua # sql/npc_list.sql
2 parents 5b4b57b + e65e4d8 commit 0f12d94

26 files changed

+617
-42
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-----------------------------------
2+
--
3+
-- tpz.effect.FULL_SPEED_AHEAD
4+
-- Helper for quest: Full Speed Ahead!
5+
--
6+
-----------------------------------
7+
require("scripts/quests/full_speed_ahead")
8+
require("scripts/globals/status")
9+
-----------------------------------
10+
11+
function onEffectGain(target,effect)
12+
tpz.fsa.onEffectGain(target, effect)
13+
end
14+
15+
function onEffectTick(target,effect)
16+
tpz.fsa.tick(target, effect)
17+
end
18+
19+
function onEffectLose(target,effect)
20+
tpz.fsa.onEffectLose(target, effect)
21+
end

scripts/globals/player.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ require("scripts/globals/teleports")
66
require("scripts/globals/titles")
77
require("scripts/globals/zone")
88
-----------------------------------
9+
require("scripts/quests/full_speed_ahead")
10+
-----------------------------------
911

1012
local startingRaceInfo =
1113
{
@@ -188,3 +190,9 @@ end
188190

189191
function onPlayerLevelDown(player)
190192
end
193+
194+
function onPlayerEmote(player, emoteId)
195+
if emoteId == tpz.emote.CHEER and player:hasStatusEffect(tpz.effect.FULL_SPEED_AHEAD) then
196+
tpz.fsa.onCheer(player)
197+
end
198+
end

scripts/globals/quests.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,8 @@ tpz.quest.id =
481481
VW_OP_115_VALKURM_DUSTER = 168,
482482
VW_OP_118_BUBURIMU_SQUALL = 169,
483483
PRELUDE_TO_PUISSANCE = 170,
484+
485+
FULL_SPEED_AHEAD = 179, -- + --
484486
},
485487

486488
-----------------------------------

scripts/globals/status.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,8 +816,9 @@ tpz.effect =
816816
DYNAMIS = 800,
817817
MEDITATE = 801, -- Dummy effect for SAM Meditate JA
818818
ELEMENTALRES_DOWN = 802, -- Elemental resistance down
819-
-- PLACEHOLDER = 803, -- Description
820-
-- 803-1022
819+
FULL_SPEED_AHEAD = 803, -- Helper for quest: Full Speed Ahead!
820+
-- PLACEHOLDER = 804, -- Description
821+
-- 804-1022
821822
-- PLACEHOLDER = 1023 -- The client dat file seems to have only this many "slots", results of exceeding that are untested.
822823
}
823824

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
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

scripts/zones/Batallia_Downs/IDs.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ zones[tpz.zone.BATALLIA_DOWNS] =
2929
NO_COMBINATION = 7698, -- You were unable to enter a combination.
3030
REGIME_REGISTERED = 9976, -- New training regime registered!
3131
COMMON_SENSE_SURVIVAL = 12832, -- It appears that you have arrived at a new survival guide provided by the Adventurers' Mutual Aid Network. Common sense dictates that you should now be able to teleport here from similar tomes throughout the world.
32+
RAPTOR_OVERCOME_MUNCHIES = 12985, -- The raptor has overcome the munchies! (<n>/<n>)
33+
RAPTOR_SECOND_WIND = 12986, -- The raptor has gained a second wind!
34+
MEET_SYRILLIA = 12987, -- Meet up with Syrillia.
35+
RAPTOR_SPEEDS_OFF = 12988, -- The raptor speeds off into the sunset...
3236
},
3337
mob =
3438
{
@@ -52,7 +56,10 @@ zones[tpz.zone.BATALLIA_DOWNS] =
5256
},
5357
npc =
5458
{
55-
CASKET_BASE = 17207794,
59+
CASKET_BASE = 17207794,
60+
SYRILLIA = 17207972,
61+
BLUE_BEAM_BASE = 17207973,
62+
RAPTOR_FOOD_BASE = 17207981,
5663
},
5764
}
5865

scripts/zones/Batallia_Downs/Zone.lua

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,53 @@ require("scripts/globals/chocobo_digging")
99
require("scripts/globals/missions")
1010
require("scripts/globals/zone")
1111
-----------------------------------
12+
require("scripts/quests/full_speed_ahead")
13+
-----------------------------------
1214

1315
function onChocoboDig(player, precheck)
1416
return tpz.chocoboDig.start(player, precheck)
1517
end
1618

19+
local function registerRegionAroundNPC(zone, NPCID, zoneID)
20+
local npc = GetNPCByID(NPCID)
21+
local x = npc:getXPos()
22+
local y = npc:getYPos()
23+
local z = npc:getZPos()
24+
local distance = 7
25+
zone:registerRegion(zoneID,
26+
x - distance, y - distance, z - distance,
27+
x + distance, y + distance, z + distance)
28+
end
29+
1730
function onInitialize(zone)
18-
UpdateNMSpawnPoint(ID.mob.AHTU)
19-
GetMobByID(ID.mob.AHTU):setRespawnTime(math.random(900, 10800))
31+
UpdateNMSpawnPoint(ID.mob.AHTU);
32+
GetMobByID(ID.mob.AHTU):setRespawnTime(math.random(900, 10800));
33+
34+
for i = 0, 7 do
35+
registerRegionAroundNPC(zone, ID.npc.RAPTOR_FOOD_BASE + i, i + 1)
36+
end
37+
registerRegionAroundNPC(zone, ID.npc.SYRILLIA, 9)
2038
end
2139

22-
function onZoneIn( player, prevZone)
23-
local cs = -1
40+
function onZoneIn(player, prevZone)
41+
local cs = -1;
42+
43+
if player:getCharVar("[QUEST]FullSpeedAhead") == 1 then -- Normal Mode
44+
player:addStatusEffect(tpz.effect.FULL_SPEED_AHEAD, 0, 3, tpz.fsa.duration)
45+
return -1
46+
elseif player:getCharVar("[QUEST]FullSpeedAhead") == 2 then -- Easy Mode
47+
player:addStatusEffect(tpz.effect.FULL_SPEED_AHEAD, 1, 3, tpz.fsa.duration)
48+
return -1
49+
end
2450

2551
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
26-
player:setPos( -693.609, -14.583, 173.59, 30)
52+
player:setPos(-693.609, -14.583, 173.59, 30);
2753
end
2854

2955
if (triggerLightCutscene(player)) then -- Quest: I Can Hear A Rainbow
30-
cs = 901
31-
elseif (player:getCurrentMission(WINDURST) == tpz.mission.id.windurst.VAIN and player:getCharVar("MissionStatus") ==1) then
32-
cs = 903
56+
cs = 901;
57+
elseif (player:getCurrentMission(WINDURST) == tpz.mission.id.windurst.VAIN and player:getCharVar("MissionStatus") == 1) then
58+
cs = 903;
3359
end
3460

3561
return cs
@@ -39,16 +65,19 @@ function onConquestUpdate(zone, updatetype)
3965
tpz.conq.onConquestUpdate(zone, updatetype)
4066
end
4167

42-
function onRegionEnter( player, region)
43-
end
68+
function onRegionEnter(player, region)
69+
if player:hasStatusEffect(tpz.effect.FULL_SPEED_AHEAD) then
70+
tpz.fsa.onRegionEnter(player, region:GetRegionID())
71+
end
72+
end;
4473

45-
function onEventUpdate( player, csid, option)
74+
function onEventUpdate(player, csid, option)
4675
if (csid == 901) then
4776
lightCutsceneUpdate(player) -- Quest: I Can Hear A Rainbow
4877
end
4978
end
5079

51-
function onEventFinish( player, csid, option)
80+
function onEventFinish(player, csid, option)
5281
if (csid == 901) then
5382
lightCutsceneFinish(player) -- Quest: I Can Hear A Rainbow
5483
elseif (csid == 903) then
@@ -57,5 +86,13 @@ function onEventFinish( player, csid, option)
5786
else
5887
player:updateEvent(0, 0, 0, 0, 0, 2)
5988
end
89+
elseif csid == 24 then
90+
tpz.fsa.completeGame(player)
91+
elseif csid == 26 and option == 0 then
92+
player:setCharVar("[QUEST]FullSpeedAhead", 1)
93+
player:setPos(475, 8.8, -159, 128, 105)
94+
elseif csid == 26 and option == 1 then
95+
player:setCharVar("[QUEST]FullSpeedAhead", 2)
96+
player:setPos(475, 8.8, -159, 128, 105)
6097
end
6198
end
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-----------------------------------
2+
-- Area: Batallia Downs
3+
-- NPC: Syrillia
4+
-- Involved in quest "Full Speed Ahead"
5+
-- !pos -512.4 -16 207.160 105
6+
-----------------------------------
7+
local ID = require("scripts/zones/Batallia_Downs/IDs");
8+
-----------------------------------
9+
10+
function onTrade(player, npc, trade)
11+
end
12+
13+
function onTrigger(player, npc)
14+
end
15+
16+
function onEventUpdate(player, csid, option)
17+
end
18+
19+
function onEventFinish(player, csid, option)
20+
end

scripts/zones/Upper_Jeuno/IDs.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ zones[tpz.zone.UPPER_JEUNO] =
4141
},
4242
npc =
4343
{
44+
MAPITOTO = 17776895,
4445
},
4546
}
4647

0 commit comments

Comments
 (0)