2#include "message_ids.h"
18API_CALLABLE(CanInteractWithShopItem);
19API_CALLABLE(BeginShopItemInteraction);
20API_CALLABLE(ShowShopPurchaseDialog);
21API_CALLABLE(ShowShopOwnerDialog);
61 Call(CanInteractWithShopItem)
77 Call(ShowShopOwnerDialog)
87 script->varTable[0] = shopMsgID;
118 script->varTable[0] = shopMsgID;
131 script->varTable[0] = shopMsgID;
134 script->functionTemp[3] = script->varTable[3] = shop->
owner->
idleAnim;
158 script->varTable[0] = shopMsgID;
161 script->functionTemp[3] = script->varTable[3] = shop->
owner->
idleAnim;
171 script->varTable[0] = shopMsgID;
174 script->functionTemp[3] = script->varTable[3] = shop->
owner->
idleAnim;
185 script->functionTemp[3] = script->varTable[2] = shop->
owner->
idleAnim;
190API_CALLABLE(CanInteractWithShopItem) {
193 script->varTable[2] = FALSE;
204 script->varTable[2] = TRUE;
208API_CALLABLE(BeginShopItemInteraction) {
209 static Evt* ShopInteractScript;
210 static s32 ShopInteractScriptID;
228 childScript->varTable[0] = currentItemSlot;
229 ShopInteractScript = childScript;
230 ShopInteractScriptID = childScript->
id;
240 shop->
flags &= ~SHOP_FLAG_INTERACT_SCRIPT_RUNNING;
257API_CALLABLE(ShowShopPurchaseDialog) {
259 s32 shopItemSlot = script->varTable[0];
266 static Evt* wShopBuyCallbackScript;
267 static s32 wShopSelectedItem;
268 static s32 wShopBuyResult;
274 shop->
flags &= ~SHOP_FLAG_SHOWING_ITEM_INFO;
278 wShopSelectedItem = ITEM_NONE;
291 switch (script->functionTemp[0]) {
295 script->functionTemp[2] = FALSE;
300 if (script->functionTemp[2] == TRUE) {
310 if (item_is_badge(shopInventory->
itemID)) {
328 wShopSelectedItem = shopInventory->
itemID;
335 wShopSelectedItem = shopInventory->
itemID;
342 wShopSelectedItem = shopInventory->
itemID;
349 wShopSelectedItem = shopInventory->
itemID;
354 wShopBuyCallbackScript = NULL;
355 if (shop->
owner != NULL) {
358 wShopBuyCallbackScript->varTable[0] = wShopBuyResult;
359 wShopBuyCallbackScript->varTable[1] = wShopSelectedItem;
360 wShopBuyCallbackScript->varTable[2] = shopItemSlot;
411 for (i = 0; i < numItemSlots; i++) {
412 s32 itemID = itemArray[i];
413 if (itemID == ITEM_NONE) {
420 menu->
enabled[numEntries] = TRUE;
450 *selectedIndex = menu->
userIndex[menuResult - 1];
469 for (i = 0; i < numItems; i++) {
470 if (items[i].itemID == itemID) {
478API_CALLABLE(ShowShopOwnerDialog) {
484 DIALOG_STATE_DONE_INSTRUCTIONS = 0,
485 DIALOG_STATE_AWAIT_GREETING = 4,
486 DIALOG_STATE_AWAIT_MAIN_MENU = 41,
487 DIALOG_STATE_CLOSED_MAIN_MENU = 42,
488 DIALOG_STATE_CLOSED_SUBMENU = 9,
489 DIALOG_STATE_DONE = 10,
491 DIALOG_STATE_INIT_SELL_CHOICE = 201,
492 DIALOG_STATE_AWAIT_SELL_CHOICE = 2,
493 DIALOG_STATE_INIT_SELL_CONFIRM = 21,
494 DIALOG_STATE_AWAIT_SELL_CONFIRM = 3,
495 DIALOG_STATE_HANDLE_SELL_CHOICE = 31,
496 DIALOG_STATE_INIT_SELL_MORE_CHOICE = 32,
497 DIALOG_STATE_AWAIT_SELL_MORE_CHOICE = 12,
499 DIALOG_STATE_INIT_CHECK_CHOICE = 501,
500 DIALOG_STATE_AWAIT_CHECK_CHOICE = 5,
501 DIALOG_STATE_HANDLE_CHECK_CHOICE = 51,
502 DIALOG_STATE_INIT_CHECK_MORE_CHOICE = 52,
503 DIALOG_STATE_AWAIT_CHECK_MORE_CHOICE = 53,
505 DIALOG_STATE_INIT_CLAIM_CHOICE = 701,
506 DIALOG_STATE_AWAIT_CLAIM_CHOICE = 7,
507 DIALOG_STATE_HANDLE_CLAIM_CHOICE = 71,
508 DIALOG_STATE_INIT_CLAIM_MORE_CHOICE = 72,
509 DIALOG_STATE_AWAIT_CLAIM_MORE_CHOICE = 73,
514 script->functionTemp[0] = DIALOG_STATE_AWAIT_GREETING;
517 switch (script->functionTemp[0]) {
518 case DIALOG_STATE_AWAIT_GREETING:
520 script->functionTemp[0] = DIALOG_STATE_AWAIT_MAIN_MENU;
521 script->functionTemp[2] = 0;
525 case DIALOG_STATE_AWAIT_MAIN_MENU:
526 if (script->functionTemp[2] == 1) {
527 switch (ShopOwnerPrintState->
curOption) {
530 script->functionTemp[0] = DIALOG_STATE_DONE_INSTRUCTIONS;
535 script->functionTemp[0] = DIALOG_STATE_CLOSED_SUBMENU;
538 script->functionTemp[0] = DIALOG_STATE_INIT_SELL_CHOICE;
544 script->functionTemp[0] = DIALOG_STATE_CLOSED_SUBMENU;
549 script->functionTemp[0] = DIALOG_STATE_CLOSED_SUBMENU;
553 script->functionTemp[0] = DIALOG_STATE_INIT_CHECK_CHOICE;
558 script->functionTemp[0] = DIALOG_STATE_CLOSED_SUBMENU;
563 script->functionTemp[0] = DIALOG_STATE_CLOSED_SUBMENU;
567 script->functionTemp[0] = DIALOG_STATE_INIT_CLAIM_CHOICE;
571 script->functionTemp[0] = DIALOG_STATE_CLOSED_MAIN_MENU;
576 case DIALOG_STATE_INIT_SELL_CHOICE:
579 script->functionTemp[0] = DIALOG_STATE_AWAIT_SELL_CHOICE;
582 case DIALOG_STATE_AWAIT_SELL_CHOICE:
584 script->functionTemp[0] = DIALOG_STATE_INIT_SELL_CONFIRM;
585 script->functionTemp[1] = 15;
588 case DIALOG_STATE_INIT_SELL_CONFIRM:
589 if (script->functionTemp[1] > 0) {
590 script->functionTemp[1]--;
598 script->functionTemp[0] = DIALOG_STATE_AWAIT_SELL_CONFIRM;
601 script->functionTemp[0] = DIALOG_STATE_CLOSED_SUBMENU;
604 case DIALOG_STATE_AWAIT_SELL_CONFIRM:
606 script->functionTemp[0] = DIALOG_STATE_HANDLE_SELL_CHOICE;
607 script->functionTemp[2] = 0;
611 case DIALOG_STATE_HANDLE_SELL_CHOICE:
612 if (script->functionTemp[2] == 1) {
613 if (ShopOwnerPrintState->
curOption == 0) {
618 script->functionTemp[0] = DIALOG_STATE_CLOSED_SUBMENU;
622 script->functionTemp[0] = DIALOG_STATE_INIT_SELL_MORE_CHOICE;
626 script->functionTemp[0] = DIALOG_STATE_INIT_SELL_MORE_CHOICE;
631 case DIALOG_STATE_INIT_SELL_MORE_CHOICE:
633 script->functionTemp[0] = DIALOG_STATE_AWAIT_SELL_MORE_CHOICE;
634 script->functionTemp[2] = 0;
638 case DIALOG_STATE_AWAIT_SELL_MORE_CHOICE:
639 if (script->functionTemp[2] == 1) {
640 if (ShopOwnerPrintState->
curOption == 0) {
642 script->functionTemp[0] = DIALOG_STATE_INIT_SELL_CHOICE;
647 script->functionTemp[0] = DIALOG_STATE_CLOSED_SUBMENU;
651 case DIALOG_STATE_INIT_CHECK_CHOICE:
654 script->functionTemp[0] = DIALOG_STATE_AWAIT_CHECK_CHOICE;
657 case DIALOG_STATE_AWAIT_CHECK_CHOICE:
659 script->functionTemp[0] = DIALOG_STATE_HANDLE_CHECK_CHOICE;
660 script->functionTemp[1] = 15;
663 case DIALOG_STATE_HANDLE_CHECK_CHOICE:
664 if (script->functionTemp[1] > 0) {
665 script->functionTemp[1]--;
676 script->functionTemp[0] = DIALOG_STATE_CLOSED_SUBMENU;
679 script->functionTemp[0] = DIALOG_STATE_INIT_CHECK_MORE_CHOICE;
683 script->functionTemp[0] = DIALOG_STATE_CLOSED_SUBMENU;
686 case DIALOG_STATE_INIT_CHECK_MORE_CHOICE:
688 script->functionTemp[0] = DIALOG_STATE_AWAIT_CHECK_MORE_CHOICE;
689 script->functionTemp[2] = 0;
693 case DIALOG_STATE_AWAIT_CHECK_MORE_CHOICE:
694 if (script->functionTemp[2] == 1) {
695 if (ShopOwnerPrintState->
curOption == 0) {
697 script->functionTemp[0] = DIALOG_STATE_INIT_CHECK_CHOICE;
700 script->functionTemp[0] = DIALOG_STATE_CLOSED_SUBMENU;
704 case DIALOG_STATE_INIT_CLAIM_CHOICE:
707 script->functionTemp[0] = DIALOG_STATE_AWAIT_CLAIM_CHOICE;
710 case DIALOG_STATE_AWAIT_CLAIM_CHOICE:
712 script->functionTemp[0] = DIALOG_STATE_HANDLE_CLAIM_CHOICE;
713 script->functionTemp[1] = 15;
716 case DIALOG_STATE_HANDLE_CLAIM_CHOICE:
717 if (script->functionTemp[1] > 0) {
718 script->functionTemp[1]--;
729 script->functionTemp[0] = DIALOG_STATE_CLOSED_SUBMENU;
732 script->functionTemp[0] = DIALOG_STATE_INIT_CLAIM_MORE_CHOICE;
736 script->functionTemp[0] = DIALOG_STATE_CLOSED_SUBMENU;
739 case DIALOG_STATE_INIT_CLAIM_MORE_CHOICE:
741 script->functionTemp[0] = DIALOG_STATE_AWAIT_CLAIM_MORE_CHOICE;
742 script->functionTemp[2] = 0;
746 case DIALOG_STATE_AWAIT_CLAIM_MORE_CHOICE:
747 if (script->functionTemp[2] == 1) {
748 if (ShopOwnerPrintState->
curOption == 0) {
750 script->functionTemp[0] = DIALOG_STATE_INIT_CLAIM_CHOICE;
753 script->functionTemp[0] = DIALOG_STATE_CLOSED_SUBMENU;
757 case DIALOG_STATE_DONE_INSTRUCTIONS:
758 case DIALOG_STATE_CLOSED_SUBMENU:
759 case DIALOG_STATE_CLOSED_MAIN_MENU:
761 script->functionTemp[0] = DIALOG_STATE_DONE;
764 case DIALOG_STATE_DONE:
765 if (shop->
owner != NULL) {
816 for (i = 0; i < shop->
numItems; i++, itemData++, shopItemEntities++) {
817 inX = shopItemEntities->
pos.
x;
818 inY = shopItemEntities->
pos.
y + 30.0f;
819 inZ = shopItemEntities->
pos.
z;
827 z = (z * s + 1.0f) * 0.5;
829 if (z > 0.0f && z < 1.0f) {
833 if (itemData->price < 100) {
855 shop->
flags &= ~SHOP_FLAG_SHOWING_ITEM_INFO;
860API_CALLABLE(MakeShop) {
861 Bytecode* args = script->ptrReadPos;
865 s32 inventoryItemFlags;
888 inventoryItemFlags = var4;
899 while (inventory->
itemID != ITEM_NONE) {
906 if (prices != NULL) {
907 while (prices->
itemID != ITEM_NONE) {
921 while (inventory->
itemID != ITEM_NONE) {
959API_CALLABLE(MakeShopOwner) {
ShopItemEntity * shopItemEntities
@ ITEM_ENTITY_FLAG_HIDDEN
@ DRAW_NUMBER_CHARSET_THIN
@ SHOP_FLAG_SHOWING_ITEM_INFO
@ SHOP_FLAG_INTERACT_SCRIPT_RUNNING
@ ACTION_STATE_BOUNCE
Used with Kooper.
@ SHOP_MSG_NOT_ENOUGH_COINS
@ SHOP_MSG_NOTHING_TO_CLAIM
@ SHOP_MSG_CHECK_ACCEPTED
@ SHOP_MSG_CLAIM_ACCEPTED
@ SHOP_MSG_NOTHING_TO_CHECK
@ SHOP_MSG_NOTHING_TO_SELL
@ SHOP_MSG_NOT_ENOUGH_ROOM
@ SHOP_BUY_RESULT_NOT_ENOUGH_COINS
@ SHOP_BUY_RESULT_NOT_ENOUGH_ROOM
Worker * get_worker(s32 idx)
void show_coin_counter(void)
s32 evt_get_variable(Evt *script, Bytecode var)
s32 get_model_list_index_from_tree_index(s32 treeIndex)
void hide_popup_menu(void)
void basic_hidden_window_update(s32 windowIndex, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
void status_bar_ignore_changes(void)
void set_window_update(s32 panelID, s32)
void decrement_status_bar_disabled(void)
void hide_coin_counter(void)
s32 disable_player_input(void)
ItemEntity * get_item_entity(s32 itemEntityIndex)
void open_status_bar_quickly(void)
void basic_window_update(s32 windowIndex, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
s32 disable_player_static_collisions(void)
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
void close_status_bar(void)
s32 make_item_entity_nodelay(s32 itemID, f32 x, f32 y, f32 z, s32 itemSpawnMode, s32 pickupVar)
s32 enable_player_input(void)
void destroy_popup_menu(void)
struct Model * get_model_from_list_index(s32 listIndex)
Evt * start_script(EvtScript *source, s32 priority, s32 initialState)
MessagePrintState * msg_get_printer_for_msg(s32 msgID, s32 *a1)
void set_message_int_var(s32 value, s32 index)
void status_bar_always_show_off(void)
void set_message_text_var(s32 msgID, s32 index)
void hide_coin_counter_immediately(void)
void set_window_properties(s32 panelID, s32 posX, s32 posY, s32 width, s32 height, u8, void *drawContents, void *drawContentsArg, s8 parent)
s32 does_script_exist(s32 id)
s32 create_worker_frontUI(void(*updateFunc)(void), void(*drawFunc)(void))
s32 enable_player_static_collisions(void)
void set_item_entity_flags(s32 itemEntityIndex, s32 flag)
Trigger * bind_trigger_1(EvtScript *script, s32 flags, s32 triggerFlagIndex, s32 triggerVar0, s32 triggerVar1, s32 priority)
void draw_number(s32 value, s32 x, s32 y, s32 variableWidthChars, s32 palette, s32 opacity, u16 style)
void * heap_malloc(s32 size)
void status_bar_respond_to_changes(void)
void status_bar_always_show_on(void)
void get_model_center_and_size(u16 modelID, f32 *centerX, f32 *centerY, f32 *centerZ, f32 *sizeX, f32 *sizeY, f32 *sizeZ)
void increment_status_bar_disabled(void)
void hud_element_set_scale(s32 index, f32 scale)
void hud_element_set_render_pos(s32 id, s32 x, s32 y)
s32 hud_element_create(HudScript *anim)
Creates a new HUD element and returns its ID.
void hud_element_set_flags(s32 id, s32 flags)
Turns on the given flags.
void hud_element_clear_flags(s32 id, s32 flags)
Turns off the given flags.
void hud_element_draw_clipped(s32 id)
ShopSellPriceData * staticPriceList
ShopItemLocation * itemDataPositions
@ HUD_ELEMENT_FLAG_FILTER_TEX
s32 selectedStoreItemSlot
ShopItemData * staticInventory
s32 store_item(s32 itemID)
Add itemID to player storage and return slot in which it was placed.
s32 get_consumables_empty(void)
s32 get_stored_empty(void)
s32 get_stored_count(void)
s32 get_consumables_count(void)
s32 add_item(s32 itemID)
Add itemID to player inventory and return inventory slot in which it was placed.
#define EndSpeech(ARGS...)
#define ContinueSpeech(ARGS...)
#define SpeakToPlayer(ARGS...)
@ GF_MAC01_BoughtBadgeFromRowf
ApiStatus GetPartnerInUse(Evt *script, b32 isInitialCall)
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
#define Goto(LABEL_ID)
Moves execution to the given label.
#define Label(LABEL_ID)
Marks this point in the script as a Goto target.
#define EndIf
Marks the end of an if statement or an else block.
#define IfEq(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR == RVAR.
#define Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
#define Return
Kills the current EVT thread.
void shop_draw_item_desc(s32 arg0, s32 posX, s32 posY)
EvtScript EVS_ShopItemInteract
s32 shop_get_sell_price(s32 itemID)
EvtScript EVS_ShopResetSpeech
void draw_shop_items(void)
EvtScript EVS_ShopContinueSpeech
s32 shop_update_item_select_popup(s32 *selectedIndex)
s32 shop_owner_begin_speech(s32 messageIndex)
s32 shop_owner_end_speech(void)
s32 shop_owner_buy_dialog(s32 messageIndex, s32 itemName, s32 coinCost, s32 bpCost)
void shop_close_item_select_popup(void)
EvtScript EVS_ShopPurchaseDialog
@ PURCHASE_DIALOG_STATE_CANCEL
@ PURCHASE_DIALOG_STATE_ACCEPTED
@ PURCHASE_DIALOG_STATE_NOT_ENOUGH_ROOM
@ PURCHASE_DIALOG_STATE_INIT
@ PURCHASE_DIALOG_STATE_AWAIT_CALLBACK
@ PURCHASE_DIALOG_STATE_EXEC_CALLBACK
@ PURCHASE_DIALOG_STATE_WAIT_FOR_SPEECH
@ PURCHASE_DIALOG_STATE_NOT_ENOUGH_COINS
EvtScript EVS_ShopBeginSpeech
EvtScript EVS_ShopOwnerDialog
EvtScript EVS_ShopEndSpeech
void shop_open_item_select_popup(s32 mode)
void create_shop_popup_menu(PopupMenu *popup)
void shop_draw_item_name(s32 arg0, s32 posX, s32 posY)
s32 shop_owner_continue_speech_with_quantity(s32 messageIndex, s32 amount)
s32 shop_owner_reset_speech(s32 messageIndex)
s32 shop_owner_continue_speech(s32 messageIndex)
GameStatus * gGameStatusPtr
WindowStyle gWindowStyles[]
PlayerStatus gPlayerStatus