mirror of
https://github.com/redstrate/Kawari.git
synced 2025-07-01 12:17:46 +00:00

Document some opcodes related to shops and implement a generic gil shopkeeper script * You can now interact with shopkeepers, and if you have enough gil, you can attempt to purchase items * Upon trying to buy items the event will auto-cancel for now, because we're missing implementations of several opcodes related to inventory management
27 lines
1.1 KiB
Lua
27 lines
1.1 KiB
Lua
-- TODO: actually implement this menu
|
|
|
|
-- Scene 00000: NPC greeting (usually an animation, sometimes text too?)
|
|
-- Scene 00010: Displays shop interface
|
|
-- Scene 00255: Unknown, but this was also observed when capturing gil shop transaction packets. When used standalone it softlocks.
|
|
|
|
function onTalk(target, player)
|
|
--[[ Params observed:
|
|
Gil shops: [0, 1]
|
|
Non- shops: [1, 0]
|
|
MGP shops: [1, 100]
|
|
It's unclear what these mean since shops seem to open fine without these.
|
|
]]
|
|
player:play_scene(target, EVENT_ID, 00000, 8192, {0})
|
|
end
|
|
|
|
function onReturn(scene, results, player)
|
|
if scene == 0 then
|
|
--[[ Retail sends 221 zeroes as u32s as the params to the shop cutscene, but it opens fine with a single zero u32.
|
|
Perhaps they are leftovers from earlier expansions? According to Sapphire, the params used to be significantly more complex.
|
|
Historically, it also seems cutscene 00040 was used instead of 00010 as it is now.
|
|
]]
|
|
player:play_scene(player.id, EVENT_ID, 00010, 1 | 0x2000, {0})
|
|
elseif scene == 10 then
|
|
player:finish_event(EVENT_ID)
|
|
end
|
|
end
|