Skip to content

Commit 950d381

Browse files
committed
Merge branch 'feature/mystery' into release
2 parents 58b3d31 + 526d4a3 commit 950d381

File tree

37 files changed

+933
-0
lines changed

37 files changed

+933
-0
lines changed

conf/default/map.conf

+5
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,8 @@ msg_server_ip: 127.0.0.1
238238
#anticheat_enabled: 1
239239
#Set to 1 to completely disable auto-jailing offenders
240240
#anticheat_jail_disable: 0
241+
242+
# Gobbie Mystery Box settings
243+
daily_tally_amount: 10
244+
daily_tally_limit: 50000
245+

scripts/globals/gobbiemysterybox.lua

+234
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
--------------------------------------------------------
2+
require("scripts/globals/settings")
3+
require("scripts/globals/utils")
4+
-------------------------------------------------------
5+
6+
tpz = tpz or {}
7+
tpz.mystery = tpz.mystery or {}
8+
9+
local adoulinOptionOff = 0x80
10+
local pictlogicaOptionOff = 0x100
11+
local wantedOptionOff = 0x1000
12+
local hideOptionFlags = adoulinOptionOff + pictlogicaOptionOff + wantedOptionOff
13+
local costs =
14+
{
15+
[1] = 10,
16+
[2] = 10,
17+
[3] = 10,
18+
[4] = 10,
19+
[5] = 10,
20+
[6] = 50
21+
}
22+
local keyToDial =
23+
{
24+
[8973] = 6, -- special dial
25+
[9217] = 9, -- abjuration
26+
[9218] = 10, -- fortune
27+
--[????] = 11, -- furnishing
28+
[9274] = 13, -- anniversary
29+
}
30+
local abjurationItems =
31+
{
32+
1314,1315,1316,1317,1318, -- dryadic
33+
1319,1320,1321,1322,1323, -- earthen
34+
1324,1325,1326,1327,1328, -- aquarian
35+
1329,1330,1331,1332,1333, -- martial
36+
1334,1335,1336,1337,1338, -- wyrmal
37+
1339,1340,1341,1342,1343, -- neptunal
38+
1441,1442, -- food
39+
2429,2430,2431,2432,2433, -- phantasmal
40+
2434,2435,2436,2437,2438, -- hadean
41+
3559,3560,3561,3562,3563, -- corvine
42+
3564,3565,3566,3567,3568, -- supernal
43+
3569,3570,3571,3572,3573, -- transitory
44+
3574,3575,3576,3577,3578, -- foreboding
45+
3579,3580,3581,3582,3583, -- lenitive
46+
8762,8763,8764,8765,8766, -- bushin
47+
8767,8768,8769,8770,8771, -- vale
48+
8772,8773,8774,8775,8776, -- grove
49+
8777,8778,8779,8780,8781, -- triton
50+
8782,8783,8784,8785,8786, -- shinryu
51+
8787,8788,8789,8790,8791, -- abyssal
52+
9105,9106,9107,9108,9109, -- cronian
53+
9110,9111,9112,9113,9114, -- arean
54+
9115,9116,9117,9118,9119, -- jovian
55+
9120,9121,9122,9123,9124, -- venerian
56+
9125,9126,9127,9128,9129, -- cyllenian
57+
}
58+
local fortuneItems =
59+
{
60+
5737,5736, -- alexandrite
61+
6180,6183,6532, -- pluton
62+
6181,6184,6535, -- beitetsu
63+
6182,6185,6534, -- rift boulder
64+
5854,5855,5856,5857,5858, -- frayed pouches
65+
5109,5110,5111,5112,5946,5947,6264,6345,6346,6370,6486,6487,6488 -- frayed sacks
66+
}
67+
local anniversaryItems =
68+
{
69+
9274 -- just give them back their key until this table can be populated
70+
}
71+
local gobbieJunk =
72+
{
73+
507,
74+
508,
75+
510,
76+
511,
77+
566,
78+
568,
79+
1239,
80+
1868,
81+
2542,
82+
2543,
83+
4539,
84+
4543,
85+
9777,
86+
15203,
87+
18180,
88+
19220
89+
}
90+
tpz.mystery.onTrade = function (player, npc, trade, events)
91+
if trade:getItemCount() == 1 then
92+
local tradeID = trade:getItemId(0)
93+
if keyToDial[tradeID] ~= nil then
94+
if player:getFreeSlotsCount() == 0 then
95+
player:startEvent(events.FULL_INV, tradeID, keyToDial[tradeID])
96+
return false
97+
end
98+
player:setLocalVar("gobbieBoxKey", tradeID)
99+
player:startEvent(events.KEY_TRADE, tradeID, keyToDial[tradeID])
100+
else -- trade for points
101+
return false
102+
end
103+
else
104+
return false
105+
end
106+
end
107+
108+
tpz.mystery.onTrigger = function (player, npc, events)
109+
local event = events
110+
local playerAgeDays = (os.time() - player:getTimeCreated()) / 86400
111+
local dailyTallyPoints = player:getCurrency("daily_tally")
112+
local firstVisit = dailyTallyPoints == -1
113+
local gobbieBoxUsed = player:getCharVar("gobbieBoxUsed")
114+
local specialDialUsed = utils.mask.getBit(gobbieBoxUsed, 0) and 1 or 0
115+
local adoulinDialUsed = utils.mask.getBit(gobbieBoxUsed, 1) and 1 or 0
116+
local pictlogicaDialUsed = utils.mask.getBit(gobbieBoxUsed, 2) and 1 or 0
117+
local wantedDialUsed = utils.mask.getBit(gobbieBoxUsed, 3) and 1 or 0
118+
local holdingItem = player:getCharVar("gobbieBoxHoldingItem")
119+
120+
if playerAgeDays >= GOBBIE_BOX_MIN_AGE and firstVisit then
121+
player:startEvent(event.INTRO)
122+
elseif playerAgeDays >= GOBBIE_BOX_MIN_AGE then
123+
if holdingItem ~= 0 then
124+
player:startEvent(event.HOLDING_ITEM)
125+
else
126+
player:startEvent(event.DEFAULT, specialDialUsed, adoulinDialUsed, pictlogicaDialUsed, wantedDialUsed, 0, 0, hideOptionFlags, dailyTallyPoints)
127+
end
128+
else
129+
player:messageSpecial(zones[player:getZoneID()].text.YOU_MUST_WAIT_ANOTHER_N_DAYS, GOBBIE_BOX_MIN_AGE - playerAgeDays + 1)
130+
end
131+
end
132+
133+
tpz.mystery.onEventUpdate = function (player, csid, option, events)
134+
local event = events
135+
local dailyTallyPoints = player:getCurrency("daily_tally")
136+
local holdingItem = player:getCharVar("gobbieBoxHoldingItem")
137+
local gobbieBoxUsed = player:getCharVar("gobbieBoxUsed")
138+
local specialDialUsed = utils.mask.getBit(gobbieBoxUsed, 0) and 1 or 0
139+
local adoulinDialUsed = utils.mask.getBit(gobbieBoxUsed, 1) and 1 or 0
140+
local pictlogicaDialUsed = utils.mask.getBit(gobbieBoxUsed, 2) and 1 or 0
141+
local wantedDialUsed = utils.mask.getBit(gobbieBoxUsed, 3) and 1 or 0
142+
local itemID = 0
143+
144+
if csid == event.KEY_TRADE then
145+
if option == 1 then
146+
local keyID = player:getLocalVar("gobbieBoxKey")
147+
player:setLocalVar("gobbieBoxKey", 0)
148+
switch (keyToDial[keyID]): caseof
149+
{
150+
[6] = function() itemID = SelectDailyItem(player, 6) end, -- special dial
151+
[9] = function() -- abjuration
152+
itemID = abjurationItems[math.random(1, #abjurationItems)]
153+
if player:hasItem(itemID) then
154+
itemID = gobbieJunk[math.random(1, #gobbieJunk)]
155+
end
156+
end,
157+
[10] = function() itemID = fortuneItems[math.random(1, #fortuneItems)] end, -- fortune
158+
--[??] = function() end, -- furnishing
159+
[13] = function()-- anniversary
160+
if math.random(1,100) == 1 then -- 1% chance for ANV exclusive item?
161+
itemID = anniversaryItems[math.random(1, #anniversaryItems)]
162+
else
163+
itemID = SelectDailyItem(player, 6)
164+
end
165+
end
166+
}
167+
player:setCharVar("gobbieBoxHoldingItem", itemID)
168+
player:tradeComplete()
169+
player:updateEvent(itemID, keyToDial[keyID], 3)
170+
elseif option == 2 then
171+
if holdingItem > 0 and npcUtil.giveItem(player, holdingItem) then
172+
player:setCharVar("gobbieBoxHoldingItem", 0)
173+
end
174+
player:updateEvent(itemID, 0)
175+
end
176+
elseif csid == event.DEFAULT then
177+
if option == 4 then
178+
player:updateEvent(SelectDailyItem(player, 6), SelectDailyItem(player, 6), SelectDailyItem(player, 6), 0, 0, 0, 0, dailyTallyPoints) -- peek
179+
else
180+
local dial = math.floor(option / 8)
181+
local option_type = option % 8
182+
local dial_used = false
183+
local dial_cost = costs[dial]
184+
local dial_mask = false
185+
if dial >= 6 then
186+
dial_mask = dial - 6
187+
dial_used = utils.mask.getBit(gobbieBoxUsed, dial_mask)
188+
end
189+
switch (option_type): caseof
190+
{
191+
[1] = function()
192+
if dial_used then
193+
player:updateEvent(1, dial, 2) -- already used this dial
194+
elseif dailyTallyPoints >= dial_cost then
195+
itemID = SelectDailyItem(player, dial)
196+
player:setCharVar("gobbieBoxHoldingItem", itemID)
197+
player:setCurrency("daily_tally", dailyTallyPoints - dial_cost)
198+
if dial_mask then
199+
player:setCharVar("gobbieBoxUsed", utils.mask.setBit(gobbieBoxUsed, dial_mask, true))
200+
end
201+
player:updateEvent(itemID, dial, 0)
202+
else
203+
player:updateEvent(1, dial, 1) -- not enough points
204+
end
205+
end,
206+
[2] = function()
207+
if player:getFreeSlotsCount() == 0 then
208+
player:updateEvent(holdingItem, 0, 0, 1) -- inventory full, exit event
209+
player:messageSpecial(zones[player:getZoneID()].text.ITEM_CANNOT_BE_OBTAINED + 2) -- generic "Cannot obtain the item."
210+
end
211+
end,
212+
[5] = function()
213+
if holdingItem > 0 and npcUtil.giveItem(player, holdingItem) then
214+
player:setCharVar("gobbieBoxHoldingItem", 0)
215+
end
216+
player:updateEvent(specialDialUsed, adoulinDialUsed, pictlogicaDialUsed, wantedDialUsed, 0, 0, hideOptionFlags, dailyTallyPoints)
217+
end,
218+
}
219+
end
220+
end
221+
end
222+
223+
tpz.mystery.onEventFinish = function (player, csid, option, events)
224+
local event = events
225+
if csid == event.INTRO then
226+
player:setCurrency("daily_tally", 50)
227+
elseif csid == event.HOLDING_ITEM then
228+
if player:getFreeSlotsCount() == 0 then
229+
player:messageSpecial(zones[player:getZoneID()].text.ITEM_CANNOT_BE_OBTAINED + 2) -- generic "Cannot obtain the item."
230+
elseif npcUtil.giveItem(player, player:getCharVar("gobbieBoxHoldingItem")) then
231+
player:setCharVar("gobbieBoxHoldingItem", 0)
232+
end
233+
end
234+
end

scripts/globals/settings.lua

+1
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,4 @@ DIG_GRANT_BURROW = 0 -- Set to 1 to grant burrow ability
164164
DIG_GRANT_BORE = 0 -- Set to 1 to grant bore ability
165165
ENM_COOLDOWN = 120 -- Number of hours before a player can obtain same KI for ENMs (default: 5 days)
166166
FORCE_SPAWN_QM_RESET_TIME = 300 -- Number of seconds the ??? remains hidden for after the despawning of the mob it force spawns.
167+
GOBBIE_BOX_MIN_AGE = 45 -- Minimum character age in days before a character can sign up for Gobbie Mystery Box

scripts/zones/Aht_Urhgan_Whitegate/IDs.lua

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ zones[tpz.zone.AHT_URHGAN_WHITEGATE] =
1616
GIL_OBTAINED = 226, -- Obtained <number> gil.
1717
KEYITEM_OBTAINED = 228, -- Obtained key item: <keyitem>.
1818
NOT_HAVE_ENOUGH_GIL = 230, -- You do not have enough gil.
19+
YOU_MUST_WAIT_ANOTHER_N_DAYS = 833, -- You must wait another ≺number≻ [day/days] to perform that action.
1920
CARRIED_OVER_POINTS = 836, -- You have carried over <number> login point[/s].
2021
LOGIN_CAMPAIGN_UNDERWAY = 837, -- The [/January/February/March/April/May/June/July/August/September/October/November/December] <number> Login Campaign is currently underway!<space>
2122
LOGIN_NUMBER = 838, -- In celebration of your most recent login (login no. <number>), we have provided you with <number> points! You currently have a total of <number> points.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
-----------------------------------
2+
-- Area: Aht Urhgan Whitegate
3+
-- NPC: Wondrix
4+
-- Gobbie Mystery Box
5+
-----------------------------------
6+
local ID = require("scripts/zones/Aht_Urhgan_Whitegate/IDs")
7+
require("scripts/globals/settings")
8+
require("scripts/globals/gobbiemysterybox")
9+
-----------------------------------
10+
11+
local events =
12+
{
13+
INTRO = 979,
14+
DEFAULT = 980,
15+
HOLDING_ITEM = 981,
16+
TRADE = 982,
17+
BAD_TRADE = 983,
18+
DAILY_COOLDOWN = 984,
19+
HIT_MAX = 985,
20+
RESULT = 988,
21+
KEY_TRADE = 989,
22+
NO_THANKS = 990,
23+
FULL_INV = 991,
24+
OTHER_BAD_TRADE = 992
25+
}
26+
27+
function onTrade(player,npc,trade)
28+
tpz.mystery.onTrade(player, npc, trade, events)
29+
end
30+
31+
function onTrigger(player, npc)
32+
tpz.mystery.onTrigger(player, npc, events)
33+
end
34+
35+
function onEventUpdate(player, csid, option)
36+
tpz.mystery.onEventUpdate(player, csid, option, events)
37+
end
38+
39+
function onEventFinish(player, csid, option)
40+
tpz.mystery.onEventFinish(player, csid, options, events)
41+
end

scripts/zones/Bastok_Markets/IDs.lua

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ zones[tpz.zone.BASTOK_MARKETS] =
1717
KEYITEM_OBTAINED = 6391, -- Obtained key item: <keyitem>.
1818
KEYITEM_LOST = 6392, -- Lost key item: <keyitem>.
1919
NOT_HAVE_ENOUGH_GIL = 6393, -- You do not have enough gil.
20+
YOU_MUST_WAIT_ANOTHER_N_DAYS= 6424, -- You must wait another ≺number≻ [day/days] to perform that action.
2021
ITEMS_OBTAINED = 6397, -- You obtain <number> <item>!
2122
CARRIED_OVER_POINTS = 6427, -- You have carried over <number> login point[/s].
2223
LOGIN_CAMPAIGN_UNDERWAY = 6428, -- The [/January/February/March/April/May/June/July/August/September/October/November/December] <number> Login Campaign is currently underway!<space>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
-----------------------------------
2+
-- Area: Bastok Markets
3+
-- NPC: Specilox
4+
-- Gobbie Mystery Box
5+
-----------------------------------
6+
local ID = require("scripts/zones/Bastok_Markets/IDs")
7+
require("scripts/globals/settings")
8+
require("scripts/globals/gobbiemysterybox")
9+
-----------------------------------
10+
11+
local events =
12+
{
13+
INTRO = 6000,
14+
DEFAULT = 6001,
15+
HOLDING_ITEM = 6002,
16+
TRADE = 6003,
17+
BAD_TRADE = 6004,
18+
DAILY_COOLDOWN = 6005,
19+
HIT_MAX = 6006,
20+
RESULT = 6009,
21+
KEY_TRADE = 6010,
22+
NO_THANKS = 6011,
23+
FULL_INV = 6012,
24+
OTHER_BAD_TRADE = 6013
25+
}
26+
27+
function onTrade(player,npc,trade)
28+
tpz.mystery.onTrade(player, npc, trade, events)
29+
end
30+
31+
function onTrigger(player, npc)
32+
tpz.mystery.onTrigger(player, npc, events)
33+
end
34+
35+
function onEventUpdate(player, csid, option)
36+
tpz.mystery.onEventUpdate(player, csid, option, events)
37+
end
38+
39+
function onEventFinish(player, csid, option)
40+
tpz.mystery.onEventFinish(player, csid, options, events)
41+
end

scripts/zones/Bastok_Mines/IDs.lua

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ zones[tpz.zone.BASTOK_MINES] =
1717
KEYITEM_OBTAINED = 6391, -- Obtained key item: <keyitem>.
1818
KEYITEM_LOST = 6392, -- Lost key item: <keyitem>.
1919
NOT_HAVE_ENOUGH_GIL = 6393, -- You do not have enough gil.
20+
YOU_MUST_WAIT_ANOTHER_N_DAYS = 6424, -- You must wait another ≺number≻ [day/days] to perform that action.
2021
CARRIED_OVER_POINTS = 6427, -- You have carried over <number> login point[/s].
2122
LOGIN_CAMPAIGN_UNDERWAY = 6428, -- The [/January/February/March/April/May/June/July/August/September/October/November/December] <number> Login Campaign is currently underway!<space>
2223
LOGIN_NUMBER = 6429, -- In celebration of your most recent login (login no. <number>), we have provided you with <number> points! You currently have a total of <number> points.

0 commit comments

Comments
 (0)