diff options
Diffstat (limited to 'arm9/src')
-rw-r--r-- | arm9/src/scrcmd_18_c.c | 23 | ||||
-rw-r--r-- | arm9/src/script_pokemon_util_c.c | 39 |
2 files changed, 62 insertions, 0 deletions
diff --git a/arm9/src/scrcmd_18_c.c b/arm9/src/scrcmd_18_c.c new file mode 100644 index 00000000..e4f950c5 --- /dev/null +++ b/arm9/src/scrcmd_18_c.c @@ -0,0 +1,23 @@ +#include "global.h"
+#include "script.h"
+#include "party.h"
+#include "save_block_2.h"
+#include "unk_0204639C.h"
+#include "map_header.h"
+
+extern u16 VarGet(struct UnkStruct_0204639C* arg, u16 wk);
+extern u16 *GetVarPointer(struct UnkStruct_0204639C* arg, u16);
+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 = FUN_02034824(*(ctx->unk80->unk1C));
+ struct UnkStruct_0204639C *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((struct SaveBlock2 *) savePtr->unkC);
+ *varPtr = GiveMon(11, (struct SaveBlock2 *) savePtr->unkC, species, level, item, mapSec, 12);
+ return FALSE;
+}
\ No newline at end of file diff --git a/arm9/src/script_pokemon_util_c.c b/arm9/src/script_pokemon_util_c.c new file mode 100644 index 00000000..7ab52b67 --- /dev/null +++ b/arm9/src/script_pokemon_util_c.c @@ -0,0 +1,39 @@ +#include "global.h"
+#include "heap.h"
+#include "party.h"
+#include "player_data.h"
+#include "pokemon.h"
+#include "save_block_2.h"
+#include "unk_0202C144.h"
+#include "constants/items.h"
+
+#pragma thumb on
+
+BOOL MonNotFaintedOrEgg(struct Pokemon * pokemon)
+{
+ if (GetMonData(pokemon, MON_DATA_HP, NULL) == 0)
+ return FALSE;
+ if (GetMonData(pokemon, MON_DATA_IS_EGG, NULL))
+ return FALSE;
+ return TRUE;
+}
+
+BOOL GiveMon(u32 heap_id, struct SaveBlock2 * sav2, u16 species, u8 level, u16 item, u32 mapSec, u32 encounterType)
+{
+ u32 ptr;
+ struct PlayerData * data = Sav2_PlayerData_GetProfileAddr(sav2);
+ struct PlayerParty * party = SavArray_PlayerParty_get(sav2);
+ struct Pokemon * mon = AllocMonZeroed(heap_id);
+ ZeroMonData(mon);
+ CreateMon(mon, species, level, 32, 0, 0, OT_ID_PLAYER_ID, 0);
+ FUN_0206A014(mon, data, ITEM_POKE_BALL, mapSec, encounterType, heap_id);
+ ptr = item;
+ SetMonData(mon, MON_DATA_HELD_ITEM, &ptr);
+ BOOL isAdded = AddMonToParty(party, mon);
+ if (isAdded)
+ {
+ FUN_0202C144(sav2, mon);
+ }
+ FreeToHeap(mon);
+ return isAdded;
+}
|