-
Notifications
You must be signed in to change notification settings - Fork 22
Decomp LoadScriptVariableValue #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AnonymousRandomPerson
merged 1 commit into
pret:main
from
slaw-22:LoadScriptVariableValue
Oct 24, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,91 @@ | ||
| #include "enums.h" | ||
| #include "scripting.h" | ||
|
|
||
| // Global script variable definitions | ||
| extern struct script_var_def SCRIPT_VARS[]; | ||
| // Local script variable definitions | ||
| extern struct script_var_def SCRIPT_VARS_LOCALS[]; | ||
| // Global script variable values | ||
| extern u8 SCRIPT_VARS_VALUES[]; | ||
|
|
||
| extern struct script_var_definition SCRIPT_VARS[]; | ||
| extern struct script_var_definition SCRIPT_VARS_LOCALS[]; | ||
| extern struct script_var_global_value SCRIPT_VARS_VALUES[]; | ||
| extern s32 GetPartyMembers(s32 param1); | ||
| extern s32 GetMoneyCarried(); | ||
| extern s32 GetMoneyStored(); | ||
| extern s32 GetLanguageType(); | ||
| extern s32 GetGameMode(); | ||
| extern s32 sub_0204C918(); | ||
| extern s32 GetSpecialEpisodeType(); | ||
| extern s32 GetNotifyNote(); | ||
|
|
||
| void LoadScriptVariableRaw(struct script_var_raw* sv_raw, | ||
| struct script_var_local_value sv_locals[], | ||
| const enum script_variables sv_id) | ||
| { | ||
| union script_var_value sv_val_local[], | ||
| const enum script_var_id sv_id) { | ||
| if (sv_id < LOCAL_SCRIPT_VAR_OFFSET) { | ||
| // script var is global | ||
| // global script var | ||
| sv_raw->def = &SCRIPT_VARS[sv_id]; | ||
| sv_raw->value.global = &SCRIPT_VARS_VALUES[sv_raw->def->value_offset]; | ||
| sv_raw->value = (union script_var_value*) | ||
| &SCRIPT_VARS_VALUES[sv_raw->def->mem_offset]; | ||
| } else { | ||
| // script var is local | ||
| // local script var | ||
| sv_raw->def = &SCRIPT_VARS_LOCALS[sv_id - LOCAL_SCRIPT_VAR_OFFSET]; | ||
| sv_raw->value.local = &sv_locals[sv_raw->def->value_offset]; | ||
| sv_raw->value = &sv_val_local[sv_raw->def->mem_offset]; | ||
| } | ||
| } | ||
|
|
||
| s32 LoadScriptVariableValue(union script_var_value sv_local[], enum script_var_id sv_id) | ||
| { | ||
| struct script_var_raw result; | ||
| LoadScriptVariableRaw(&result, sv_local, sv_id); | ||
|
|
||
| switch((s16)result.def->type) { | ||
| case VARTYPE_NONE: | ||
| break; | ||
| case VARTYPE_BIT: | ||
| // Return true if the value has a particular bit set | ||
| if(result.value->u8 & (u8)(1 << result.def->bitshift)) { | ||
| return TRUE; | ||
| } | ||
| return FALSE; | ||
| case VARTYPE_STRING: | ||
| case VARTYPE_UINT8: | ||
| return result.value->u8; | ||
| case VARTYPE_INT8: | ||
| return result.value->s8; | ||
| case VARTYPE_UINT16: | ||
| return result.value->u16; | ||
| case VARTYPE_INT16: | ||
| return result.value->s16; | ||
| case VARTYPE_UINT32: | ||
| case VARTYPE_INT32: | ||
| return result.value->u32; | ||
| case VARTYPE_SPECIAL: | ||
| switch(sv_id) { | ||
| case VAR_FRIEND_SUM: | ||
| return 1; | ||
| case VAR_UNIT_SUM: | ||
| return GetPartyMembers(0); | ||
| case VAR_CARRY_GOLD: | ||
| return GetMoneyCarried(); | ||
| case VAR_BANK_GOLD: | ||
| return GetMoneyStored(); | ||
| case VAR_LANGUAGE_TYPE: | ||
| return GetLanguageType(); | ||
| case VAR_GAME_MODE: | ||
| return GetGameMode(); | ||
| case VAR_EXECUTE_SPECIAL_EPISODE_TYPE: | ||
| switch(GetGameMode()) { | ||
| case EPISODE_IGGLYBUFF_THE_PRODIGY: | ||
| return sub_0204C918(); | ||
| case EPISODE_HERE_COMES_TEAM_CHARM: | ||
| return GetSpecialEpisodeType(); | ||
| default: | ||
| return -1; | ||
| } | ||
| case VAR_NOTE_MODIFY_FLAG: | ||
| return GetNotifyNote(); | ||
| } | ||
| } | ||
|
|
||
| return 0; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might as well bring over the whole enum since it is known.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the rest of this enum yet. Did something go wrong with the commits?