diff options
Diffstat (limited to 'arm9/src')
-rw-r--r-- | arm9/src/scrcmd_18_c.c | 22 | ||||
-rw-r--r-- | arm9/src/scrcmd_party.c | 815 |
2 files changed, 815 insertions, 22 deletions
diff --git a/arm9/src/scrcmd_18_c.c b/arm9/src/scrcmd_18_c.c deleted file mode 100644 index d4437c5f..00000000 --- a/arm9/src/scrcmd_18_c.c +++ /dev/null @@ -1,22 +0,0 @@ -#include "global.h"
-#include "script.h"
-#include "party.h"
-#include "save_block_2.h"
-#include "unk_0204639C.h"
-#include "map_header.h"
-#include "scrcmd.h"
-
-extern BOOL GiveMon(u32 heap_id, struct SaveBlock2 * sav2, u16 species, u8 level, u16 item, u32 mapSec, u8 encounterType);
-
-THUMB_FUNC BOOL ScrCmd_GiveMon(struct ScriptContext* ctx)
-{
- u32 mapSec = MapHeader_GetMapSec(*(ctx->unk80->mapId));
- struct UnkSavStruct80 *savePtr = ctx->unk80;
- u16 species = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
- u16 level = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
- u16 item = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
- u16 * varPtr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
- struct PlayerParty * party = SavArray_PlayerParty_get(savePtr->saveBlock2);
- *varPtr = (u16)GiveMon(11, savePtr->saveBlock2, species, (u8)level, item, mapSec, 12);
- return FALSE;
-}
diff --git a/arm9/src/scrcmd_party.c b/arm9/src/scrcmd_party.c new file mode 100644 index 00000000..48d558c9 --- /dev/null +++ b/arm9/src/scrcmd_party.c @@ -0,0 +1,815 @@ +#include "scrcmd.h"
+#include "constants/moves.h"
+#include "itemtool.h"
+#include "map_header.h"
+#include "module_05.h"
+#include "party.h"
+#include "save_block_2.h"
+#include "script_pokemon_util.h"
+#include "unk_02015CC0.h"
+#include "unk_02022504.h"
+#include "unk_0204639C.h"
+#include "unk_0207FC5C.h"
+
+extern u16 FUN_02054DEC(struct SaveBlock2* sav2);
+
+THUMB_FUNC BOOL ScrCmd_GiveMon(struct ScriptContext* ctx)
+{
+ u32 mapSec = MapHeader_GetMapSec(*(ctx->unk80->mapId));
+ struct UnkSavStruct80 *savePtr = ctx->unk80;
+ u16 species = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 level = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 item = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 * varPtr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty * party = SavArray_PlayerParty_get(savePtr->saveBlock2);
+ *varPtr = (u16)GiveMon(11, savePtr->saveBlock2, species, (u8)level, item, mapSec, 12);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GetPartyMonSpecies(struct ScriptContext* ctx)
+{
+ u32 species;
+ u16* ret_ptr;
+
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16* mon_slot = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, *mon_slot);
+
+ BOOL party_mon_is_egg = (BOOL)GetMonData(party_mon, MON_DATA_IS_EGG, NULL);
+ if (party_mon_is_egg == FALSE)
+ {
+ species = GetMonData(party_mon, MON_DATA_SPECIES, NULL);
+ }
+ else
+ {
+ species = SPECIES_NONE;
+ }
+
+ *ret_ptr = (u16)species;
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CheckPartyMonOTID(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ struct SaveBlock2* sav2 = ScriptEnvironment_GetSav2Ptr(sav_ptr);
+ struct PlayerData* player = Sav2_PlayerData_GetProfileAddr(sav2);
+
+ u16* mon_slot = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, *mon_slot);
+
+ u16 party_mon_otid = (u16)GetMonData(party_mon, MON_DATA_OTID, NULL);
+ u16 player_otid = (u16)PlayerProfile_GetTrainerID(player);
+ if (party_mon_otid == player_otid)
+ {
+ *ret_ptr = 0;
+ }
+ else
+ {
+ *ret_ptr = 1;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GiveEgg(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ struct PlayerData* player = Sav2_PlayerData_GetProfileAddr(sav_ptr->saveBlock2);
+ u16 species = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 unk = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ u8 party_count = (u8)GetPartyCount(party);
+
+ if (party_count < PARTY_SIZE)
+ {
+ struct Pokemon* egg = AllocMonZeroed(11);
+ ZeroMonData(egg);
+
+ s32 met_loc = FUN_02015CF8(1, unk);
+ MOD05_SetEggStats(egg, species, 1, player, 3, met_loc);
+
+ AddMonToParty(party, egg);
+ FreeToHeap(egg);
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_SetPartyMonMove(struct ScriptContext* ctx)
+{
+ u16 mon_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 move_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 move = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(ctx->unk80->saveBlock2);
+
+ PartyMonSetMoveInSlot(party, mon_slot, move_slot, move);
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_PartyMonHasMove(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 required_move = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 mon_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, mon_slot);
+
+ *ret_ptr = 0;
+
+ BOOL party_mon_is_egg = (BOOL)GetMonData(party_mon, MON_DATA_IS_EGG, NULL);
+ if (party_mon_is_egg)
+ {
+ return FALSE;
+ }
+
+ if (required_move == GetMonData(party_mon, MON_DATA_MOVE1, NULL) ||
+ required_move == GetMonData(party_mon, MON_DATA_MOVE2, NULL) ||
+ required_move == GetMonData(party_mon, MON_DATA_MOVE3, NULL) ||
+ required_move == GetMonData(party_mon, MON_DATA_MOVE4, NULL))
+ {
+ *ret_ptr = 1;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_FindPartyMonWithMove(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 required_move = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u8 party_count = (u8)GetPartyCount(SavArray_PlayerParty_get(sav_ptr->saveBlock2));
+
+ u8 i;
+ for (i = 0, *ret_ptr = PARTY_SIZE; i < party_count; i++)
+ {
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, i);
+
+ BOOL party_mon_is_egg = (BOOL)GetMonData(party_mon, MON_DATA_IS_EGG, NULL);
+ if (party_mon_is_egg == FALSE)
+ {
+ if (required_move == GetMonData(party_mon, MON_DATA_MOVE1, NULL) ||
+ required_move == GetMonData(party_mon, MON_DATA_MOVE2, NULL) ||
+ required_move == GetMonData(party_mon, MON_DATA_MOVE3, NULL) ||
+ required_move == GetMonData(party_mon, MON_DATA_MOVE4, NULL))
+ {
+ *ret_ptr = i;
+ break;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_SurvivePsn(struct ScriptContext* ctx)
+{
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 mon_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(ctx->unk80->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, mon_slot);
+
+ *ret_ptr = (u16)SurvivePoisoning(party_mon);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CountPartyMonsAtOrBelowLevel(struct ScriptContext* ctx)
+{
+ u8 party_count;
+ u8 i;
+
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 highest_level = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ party_count = (u8)GetPartyCount(SavArray_PlayerParty_get(sav_ptr->saveBlock2));
+
+ u8 mons;
+ for (i = 0, mons = 0, *ret_ptr = 0; i < party_count; i++)
+ {
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, i);
+
+ BOOL party_mon_is_egg = (BOOL)GetMonData(party_mon, MON_DATA_IS_EGG, NULL);
+ if (party_mon_is_egg == FALSE)
+ {
+ u32 party_mon_level = GetMonData(party_mon, MON_DATA_LEVEL, NULL);
+ if (party_mon_level <= highest_level)
+ {
+ mons++;
+ }
+ }
+ }
+
+ *ret_ptr = mons;
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GetPartyMonLevel(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 mon_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, mon_slot);
+
+ *ret_ptr = 0;
+
+ BOOL party_mon_is_egg = (BOOL)GetMonData(party_mon, MON_DATA_IS_EGG, NULL);
+ if (party_mon_is_egg == FALSE)
+ {
+ *ret_ptr = (u16)GetMonData(party_mon, MON_DATA_LEVEL, NULL);
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GetPartyMonNature(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 mon_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u8 party_count = (u8)GetPartyCount(SavArray_PlayerParty_get(sav_ptr->saveBlock2));
+
+ if (mon_slot >= party_count)
+ {
+ *ret_ptr = 0;
+ return FALSE;
+ }
+
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, mon_slot);
+
+ BOOL party_mon_is_egg = (BOOL)GetMonData(party_mon, MON_DATA_IS_EGG, NULL);
+ if (party_mon_is_egg)
+ {
+ *ret_ptr = 0;
+ return FALSE;
+ }
+
+ *ret_ptr = GetMonNature(party_mon);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_FindPartyMonWithNature(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 required_nature = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u8 party_count = (u8)GetPartyCount(SavArray_PlayerParty_get(sav_ptr->saveBlock2));
+
+ u8 i;
+ for (i = 0, *ret_ptr = 0xFF; i < party_count; i++)
+ {
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, i);
+
+ BOOL party_mon_is_egg = (BOOL)GetMonData(party_mon, MON_DATA_IS_EGG, NULL);
+ if (party_mon_is_egg == FALSE)
+ {
+ u8 party_mon_nature = GetMonNature(party_mon);
+ if (required_nature == party_mon_nature)
+ {
+ *ret_ptr = i;
+ break;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GetPartyMonFriendship(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 mon_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, mon_slot);
+
+ *ret_ptr = (u16)GetMonData(party_mon, MON_DATA_FRIENDSHIP, NULL);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_AddPartyMonFriendship(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16 friendship_to_add = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 mon_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 map_sec = MapHeader_GetMapSec(*ctx->unk80->mapId);
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, mon_slot);
+
+ u16 friendship = (u16)GetMonData(party_mon, MON_DATA_FRIENDSHIP, NULL);
+
+ if (friendship_to_add != 0)
+ {
+ u16 party_mon_held_item = (u16)GetMonData(party_mon, MON_DATA_HELD_ITEM, NULL);
+ u32 held_item_hold_effect = GetItemAttr(party_mon_held_item, ITEMATTR_HOLD_EFFECT, 11);
+ if (held_item_hold_effect == HOLD_EFFECT_FRIENDSHIP_UP)
+ {
+ friendship_to_add = (u16)((friendship_to_add * 150) / 100);
+ }
+
+ u32 party_mon_pokeball = GetMonData(party_mon, MON_DATA_POKEBALL, NULL);
+ if (party_mon_pokeball == ITEM_LUXURY_BALL)
+ {
+ friendship_to_add++;
+ }
+
+ u32 party_mon_egg_met_location = GetMonData(party_mon, MON_DATA_EGG_MET_LOCATION, NULL);
+ if (map_sec == party_mon_egg_met_location)
+ {
+ friendship_to_add++;
+ }
+ }
+
+ friendship += friendship_to_add;
+ if (friendship > 0xFF)
+ {
+ friendship = 0xFF;
+ }
+
+ SetMonData(party_mon, MON_DATA_FRIENDSHIP, &friendship);
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_SubtractPartyMonFriendship(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16 friendship_to_deplete = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 mon_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, mon_slot);
+
+ u16 friendship = (u16)GetMonData(party_mon, MON_DATA_FRIENDSHIP, NULL);
+ if (friendship_to_deplete > friendship)
+ {
+ friendship = 0;
+ }
+ else
+ {
+ friendship -= friendship_to_deplete;
+ }
+
+ SetMonData(party_mon, MON_DATA_FRIENDSHIP, &friendship);
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GetPartyMonContestCondition(struct ScriptContext* ctx)
+{
+ u16 mon_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 contest_condition_id = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(ctx->unk80->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, mon_slot);
+
+ *ret_ptr = (u16)GetMonData(party_mon, MON_DATA_COOL + contest_condition_id, NULL);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GetLeadingPartyMonSlot(struct ScriptContext* ctx)
+{
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+
+ *ret_ptr = FUN_02054DEC(ctx->unk80->saveBlock2);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GetPartyMonTypes(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16* type1 = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16* type2 = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 mon_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, mon_slot);
+
+ *type1 = (u16)GetMonData(party_mon, MON_DATA_TYPE_1, NULL);
+ *type2 = (u16)GetMonData(party_mon, MON_DATA_TYPE_2, NULL);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CountPartyMons(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+
+ *ret_ptr = (u16)GetPartyCount(party);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CountPartyMons_OmitEggs(struct ScriptContext* ctx)
+{
+ u32 non_egg_mons;
+ s32 i;
+
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ s32 party_count = GetPartyCount(SavArray_PlayerParty_get(sav_ptr->saveBlock2));
+
+ for (i = 0, non_egg_mons = 0; i < party_count; i++)
+ {
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, i);
+
+ BOOL party_mon_is_egg = (BOOL)GetMonData(party_mon, MON_DATA_IS_EGG, NULL);
+ if (party_mon_is_egg == FALSE)
+ {
+ non_egg_mons++;
+ }
+
+ }
+
+ *ret_ptr = (u16)non_egg_mons;
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CountAvailablePartyMons_IgnoreSlot(struct ScriptContext* ctx)
+{
+ u16 slot_to_ignore;
+ s32 party_count;
+
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ slot_to_ignore = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ party_count = GetPartyCount(SavArray_PlayerParty_get(sav_ptr->saveBlock2));
+
+ u32 available_mons;
+ s32 i;
+ for (i = 0, available_mons = 0; i < party_count; i++)
+ {
+ if (i != slot_to_ignore)
+ {
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, i);
+
+ BOOL party_mon_is_egg = (BOOL)GetMonData(party_mon, MON_DATA_IS_EGG, NULL);
+ if (party_mon_is_egg == FALSE)
+ {
+ u32 party_mon_hp = GetMonData(party_mon, MON_DATA_HP, NULL);
+ if (party_mon_hp != 0)
+ {
+ available_mons++;
+ }
+ }
+ }
+ }
+
+ *ret_ptr = (u16)available_mons;
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CountAvailablePartyAndPCMons(struct ScriptContext* ctx)
+{
+ s32 party_count;
+ struct PCStorage* pc;
+
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ pc = GetStoragePCPointer(sav_ptr->saveBlock2);
+ party_count = GetPartyCount(SavArray_PlayerParty_get(sav_ptr->saveBlock2));
+
+ u32 mons;
+ s32 i;
+ for (i = 0, mons = 0; i < party_count; i++)
+ {
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, i);
+
+ BOOL party_mon_is_egg = (BOOL)GetMonData(party_mon, MON_DATA_IS_EGG, NULL);
+ if (party_mon_is_egg == FALSE)
+ {
+ u32 party_mon_hp = GetMonData(party_mon, MON_DATA_HP, NULL);
+ if (party_mon_hp != 0)
+ {
+ mons++;
+ }
+ }
+ }
+
+ *ret_ptr = (u16)(mons + PCStorage_CountMonsInAllBoxes(pc));
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GetPartyEggCount(struct ScriptContext* ctx)
+{
+ s32 party_count;
+ u32 eggs_in_party;
+
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ party_count = GetPartyCount(SavArray_PlayerParty_get(sav_ptr->saveBlock2));
+
+ s32 i;
+ for (i = 0, eggs_in_party = 0; i < party_count; i++)
+ {
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, i);
+
+ BOOL party_mon_is_egg = (BOOL)GetMonData(party_mon, MON_DATA_IS_EGG, NULL);
+ if (party_mon_is_egg)
+ {
+ eggs_in_party++;
+ }
+ }
+
+ *ret_ptr = (u16)eggs_in_party;
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CheckPartyForPokerus(struct ScriptContext* ctx)
+{
+ u16 party_count;
+ u16 i;
+
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ party_count = (u16)GetPartyCount(SavArray_PlayerParty_get(sav_ptr->saveBlock2));
+
+ for (i = 0, *ret_ptr = 0; i < party_count; i++)
+ {
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, i);
+
+ BOOL party_mon_has_pokerus = (BOOL)GetMonData(party_mon, MON_DATA_POKERUS, NULL);
+ if (party_mon_has_pokerus)
+ {
+ *ret_ptr = 1;
+ break;
+ }
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GetPartyMonGender(struct ScriptContext* ctx)
+{
+ u16 mon_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(ctx->unk80->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, mon_slot);
+
+ *ret_ptr = (u16)GetMonData(party_mon, MON_DATA_GENDER, NULL);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CountPartyMonMoves(struct ScriptContext* ctx)
+{
+ struct Pokemon* party_mon;
+ u8 moves;
+
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 mon_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ party_mon = GetPartyMonByIndex(party, mon_slot);
+
+ BOOL party_mon_is_egg = (BOOL)GetMonData(party_mon, MON_DATA_IS_EGG, NULL);
+ if (party_mon_is_egg)
+ {
+ *ret_ptr = 0;
+ return FALSE;
+ }
+
+ moves = 0;
+
+ u32 move1 = GetMonData(party_mon, MON_DATA_MOVE1, NULL);
+ if (move1 != MOVE_NONE)
+ {
+ moves++;
+ }
+
+ u32 move2 = GetMonData(party_mon, MON_DATA_MOVE2, NULL);
+ if (move2 != MOVE_NONE)
+ {
+ moves++;
+ }
+
+ u32 move3 = GetMonData(party_mon, MON_DATA_MOVE3, NULL);
+ if (move3 != MOVE_NONE)
+ {
+ moves++;
+ }
+
+ u32 move4 = GetMonData(party_mon, MON_DATA_MOVE4, NULL);
+ if (move4 != MOVE_NONE)
+ {
+ moves++;
+ }
+
+ *ret_ptr = moves;
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_ForgetPartyMonMove(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16 mon_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 move_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, mon_slot);
+
+ FUN_020699A4(party_mon, move_slot);
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GetPartyMonMove(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 mon_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 move_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, mon_slot);
+
+ *ret_ptr = (u16)GetMonData(party_mon, MON_DATA_MOVE1 + move_slot, NULL);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GetPartyMonHeldItem(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 mon_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, mon_slot);
+
+ *ret_ptr = (u16)GetMonData(party_mon, MON_DATA_HELD_ITEM, NULL);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_ResetPartyMonHeldItem(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16 mon_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, mon_slot);
+
+ u16 party_mon_held_item = ITEM_NONE;
+ SetMonData(party_mon, MON_DATA_HELD_ITEM, &party_mon_held_item);
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CheckPartyForSpecies(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80* sav_ptr = ctx->unk80;
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 species = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u8 party_count = (u8)GetPartyCount(SavArray_PlayerParty_get(sav_ptr->saveBlock2));
+
+ u8 i;
+ for (i = 0, *ret_ptr = 0; i < party_count; i++)
+ {
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav_ptr->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, i);
+
+ BOOL party_mon_is_egg = (BOOL)GetMonData(party_mon, MON_DATA_IS_EGG, NULL);
+ if (party_mon_is_egg == FALSE)
+ {
+ u16 party_mon_species = (u16)GetMonData(party_mon, MON_DATA_SPECIES, NULL);
+ if (species == party_mon_species)
+ {
+ *ret_ptr = 1;
+ break;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CountPartyMonRibbons(struct ScriptContext* ctx)
+{
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 mon_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(ctx->unk80->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, mon_slot);
+
+ u16 ribbon_idx;
+ u16 ribbons;
+ for (ribbon_idx = 0, ribbons = 0; ribbon_idx < 80; ribbon_idx++)
+ {
+ BOOL party_mon_has_ribbon = (BOOL)GetMonData(party_mon, FUN_0207FC5C((u8)ribbon_idx, 0), NULL);
+ if (party_mon_has_ribbon)
+ {
+ ribbons++;
+ }
+ }
+
+ *ret_ptr = ribbons;
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CountTotalPartyRibbons(struct ScriptContext* ctx)
+{
+ struct PlayerParty* party;
+ u16 ribbon_idx;
+ u16 ribbons;
+
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 party_count = (u16)GetPartyCount(SavArray_PlayerParty_get(ctx->unk80->saveBlock2));
+ party = SavArray_PlayerParty_get(ctx->unk80->saveBlock2);
+
+ for (ribbon_idx = 0, ribbons = 0; ribbon_idx < 80; ribbon_idx++)
+ {
+ for (u16 i = 0; i < party_count; i++)
+ {
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, i);
+
+ BOOL party_mon_is_egg = (BOOL)GetMonData(party_mon, MON_DATA_IS_EGG, NULL);
+ if (party_mon_is_egg)
+ {
+ // BUG: This `break` should be a `continue`, as any party mons after a detected
+ // egg would have their ribbons ignored.
+ break;
+ }
+
+ BOOL party_mon_has_ribbon = (BOOL)GetMonData(party_mon, FUN_0207FC5C((u8)ribbon_idx, 0), NULL);
+ if (party_mon_has_ribbon)
+ {
+ ribbons++;
+ break;
+ }
+ }
+ }
+
+ *ret_ptr = ribbons;
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_PartyMonHasRibbon(struct ScriptContext* ctx)
+{
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 mon_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 ribbon_idx = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(ctx->unk80->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, mon_slot);
+
+ *ret_ptr = (u16)GetMonData(party_mon, FUN_0207FC5C((u8)ribbon_idx, 0), NULL);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GivePartyMonRibbon(struct ScriptContext* ctx)
+{
+ u16 mon_slot = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 ribbon_idx = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u8 mon_has_ribbon = TRUE;
+ struct PlayerParty* party = SavArray_PlayerParty_get(ctx->unk80->saveBlock2);
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, mon_slot);
+
+ SetMonData(party_mon, (s32)FUN_0207FC5C((u8)ribbon_idx, 0), &mon_has_ribbon);
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CheckPartyForBadEgg(struct ScriptContext* ctx)
+{
+ u16 ribbon_idx;
+
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 party_count = (u16)GetPartyCount(SavArray_PlayerParty_get(ctx->unk80->saveBlock2));
+ struct PlayerParty* party = SavArray_PlayerParty_get(ctx->unk80->saveBlock2);
+
+ // BUG: Probably a copy-paste fail. Checks if your party has a Bad Egg in it,
+ // 80 times.
+ for (ribbon_idx = 0; ribbon_idx < 80; ribbon_idx++)
+ {
+ for (u16 i = 0; i < party_count; i++)
+ {
+ struct Pokemon* party_mon = GetPartyMonByIndex(party, i);
+ BOOL party_mon_is_egg = (BOOL)GetMonData(party_mon, MON_DATA_IS_EGG, NULL);
+ if (party_mon_is_egg)
+ {
+ BOOL party_mon_is_bad_egg = (BOOL)GetMonData(party_mon, MON_DATA_CHECKSUM_FAILED, NULL);
+ if (party_mon_is_bad_egg)
+ {
+ *ret_ptr = 1;
+ return FALSE;
+ }
+ }
+ }
+ }
+
+ *ret_ptr = 0;
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk00A0(struct ScriptContext* ctx)
+{
+#pragma unused(ctx)
+ return FALSE;
+}
|