mirror of
https://github.com/pret/pmd-red.git
synced 2026-09-13 19:45:40 -05:00
Document dungeon spawns file
This commit is contained in:
17
include/dungeon_spawns.h
Normal file
17
include/dungeon_spawns.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef GUARD_DUNGEON_SPAWNS_H
|
||||
#define GUARD_DUNGEON_SPAWNS_H
|
||||
|
||||
#include "structs/str_spawn_pokemon_data.h"
|
||||
|
||||
void sub_803D4AC(void);
|
||||
void SetFloorItemMonsterSpawns(void);
|
||||
u8 GetRandomFloorTrap(void);
|
||||
u8 GetRandomFloorItem(s32 spawnType);
|
||||
s32 SetMonsterSpawnsArray(SpawnPokemonData *strPtr, s32 id);
|
||||
s32 GetAvailableMonsToTransform(SpawnPokemonData *strPtr, s32 id);
|
||||
void SetCurrentMonsterSpawns(void);
|
||||
bool8 CanMonsterBeSpawnedHere(s16 speciesToFind);
|
||||
s16 GetRandomFloorMonsterId(s32 arrId);
|
||||
s32 GetSpawnedMonsterLevel(s32 species);
|
||||
|
||||
#endif // GUARD_DUNGEON_SPAWNS_H
|
||||
@@ -2,7 +2,7 @@
|
||||
#define GUARD_POKEMON_3_H
|
||||
|
||||
#include "pokemon.h"
|
||||
#include "structs/str_packed_pokemon_data.h"
|
||||
#include "structs/str_spawn_pokemon_data.h"
|
||||
|
||||
// size: 0x8
|
||||
typedef struct EvolveStatus
|
||||
@@ -73,10 +73,10 @@ void SetDefaultIQSkills(IqSkillFlags *iq, bool8 enableSelfCurer);
|
||||
void sub_808F468(PokemonStruct1 *param_1, EvolveStatus *evolveStatus, bool8 param_3);
|
||||
s32 sub_808F700(PokemonStruct1 *pokemon);
|
||||
PokemonStruct1 *sub_808F734(PokemonStruct1 *pokemon, s16 _species);
|
||||
s16 ExtractSpeciesIndex(PackedPokemonData *data);
|
||||
void SetSpeciesToExtract(PackedPokemonData *data, s32 species_);
|
||||
void SetSpeciesLevelToExtract(PackedPokemonData *data, s32 level, s32 species_);
|
||||
s32 ExtractLevel(PackedPokemonData *data);
|
||||
s16 ExtractSpeciesIndex(SpawnPokemonData *data);
|
||||
void SetSpeciesToExtract(SpawnPokemonData *data, s32 species_);
|
||||
void SetSpeciesLevelToExtract(SpawnPokemonData *data, s32 level, s32 species_);
|
||||
s32 ExtractLevel(SpawnPokemonData *data);
|
||||
PokemonStruct1 *sub_808F798(PokemonStruct1 *pokemon, short _species);
|
||||
void CreatePokemonInfoTabScreen(s32 param_1, s32 param_2, struct unkStruct_808FF20 *mon, struct UnkInfoTabStruct *param_4, u32 windowId);
|
||||
void sub_808FF20(struct unkStruct_808FF20 *param_1, struct PokemonStruct1 *pokemon, bool8 param_3);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define GUARD_DUNGEON_MAPPARAM_H
|
||||
|
||||
#include "dungeon.h"
|
||||
#include "structs/str_packed_pokemon_data.h"
|
||||
#include "structs/str_spawn_pokemon_data.h"
|
||||
|
||||
struct DungeonMapParam1
|
||||
{
|
||||
@@ -15,10 +15,10 @@ struct DungeonMapParam1
|
||||
struct DungeonMapParam2
|
||||
{
|
||||
struct DungeonMapParam1 **unk0;
|
||||
FloorProperties *unk4;
|
||||
u16 **unk8;
|
||||
PackedPokemonData **unkC;
|
||||
u16 **unk10;
|
||||
FloorProperties *floorProperties;
|
||||
u16 **itemSpawns;
|
||||
SpawnPokemonData **monsterSpawns;
|
||||
u16 **trapSpawnChances;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "structs/str_traps.h"
|
||||
#include "structs/str_dungeon_location.h"
|
||||
#include "structs/str_dungeon_mail_seed.h"
|
||||
#include "structs/str_packed_pokemon_data.h"
|
||||
#include "structs/str_spawn_pokemon_data.h"
|
||||
|
||||
#define DUNGEON_MAX_SIZE_X 56
|
||||
#define DUNGEON_MAX_SIZE_Y 32
|
||||
@@ -357,6 +357,8 @@ struct DungeonMap
|
||||
bool8 resetTilesScheduledForCopy;
|
||||
};
|
||||
|
||||
#define MONSTER_SPAWNS_ARR_COUNT 32
|
||||
|
||||
// size: 0x1CEDC
|
||||
typedef struct Dungeon
|
||||
{
|
||||
@@ -396,12 +398,12 @@ typedef struct Dungeon
|
||||
EntityInfo unk69C[MAX_TEAM_MEMBERS];
|
||||
EntityInfo unkEBC[DUNGEON_MAX_WILD_POKEMON_BODY_SIZE];
|
||||
/* 0x2F3C */ unkDungeon2F3C unk2F3C[64];
|
||||
/* 0x343C */ PackedPokemonData unk343C[32];
|
||||
/* 0x343C */ SpawnPokemonData monsterSpawns[MONSTER_SPAWNS_ARR_COUNT];
|
||||
u8 fill353C[0x363c-0x353c];
|
||||
/* 0x363C */ u8 expYieldRankings[MONSTER_MAX];
|
||||
/* 0x37E4 */ s32 unk37E4;
|
||||
/* 0x37E4 */ s32 currFloorMonsterSpawnsCount;
|
||||
u8 fill37E8[4];
|
||||
/* 0x37EC */ u8 unk37EC;
|
||||
/* 0x37EC */ bool8 monsterSpawnsPopulated; // From fileMonsterSpawns to monsterSpawns
|
||||
/* 0x37F0 */ u32 unk37F0;
|
||||
/* 0x37F4 */ s32 unk37F4;
|
||||
/* 0x37F8 */ bool8 plusIsActive[2]; // Index 0: Enemy , Index 1: Team
|
||||
@@ -479,8 +481,8 @@ typedef struct Dungeon
|
||||
/* 0x1C570 */ DungeonLocation unk1C570;
|
||||
/* 0x1C574 */ FloorProperties floorProperties;
|
||||
/* 0x1C590 */ ItemSpawns itemSpawns[ITEM_SPAWN_TYPES_COUNT];
|
||||
u16 unk1CD70[20];
|
||||
PackedPokemonData unk1CD98[32];
|
||||
/* 0x1CD70 */ u16 trapSpawnChances[NUM_TRAPS];
|
||||
SpawnPokemonData fileMonsterSpawns[MONSTER_SPAWNS_ARR_COUNT]; // Taken directly from "mapparam" which corresponds to available monsters on given dungeon's floor.
|
||||
UnkDungeonGlobal_unk1CE98_sub unk1CE98; // TODO: not sure how large this is
|
||||
u8 unk1CEC8;
|
||||
/* 0x1CECC */ DungeonMusicPlayer musPlayer;
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#ifndef GUARD_STR_PACKED_POKEMON_DATA_H
|
||||
#define GUARD_STR_PACKED_POKEMON_DATA_H
|
||||
|
||||
#define PACKED_BITS_SPECIES 0x1FF
|
||||
#define PACKED_BITS_LEVEL 0x7F
|
||||
#define PACKED_BITS_LEVEL_SHIFT 9
|
||||
|
||||
// size: R=0x8 | B=0x6
|
||||
typedef struct PackedPokemonData
|
||||
{
|
||||
u16 bits; // species first 9 bits, level last 7 bits
|
||||
s16 unk2[2];
|
||||
} PackedPokemonData;
|
||||
|
||||
#endif // GUARD_STR_PACKED_POKEMON_DATA_H
|
||||
15
include/structs/str_spawn_pokemon_data.h
Normal file
15
include/structs/str_spawn_pokemon_data.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef GUARD_STR_SPAWN_POKEMON_DATA_H
|
||||
#define GUARD_STR_SPAWN_POKEMON_DATA_H
|
||||
|
||||
#define PACKED_BITS_SPECIES 0x1FF
|
||||
#define PACKED_BITS_LEVEL 0x7F
|
||||
#define PACKED_BITS_LEVEL_SHIFT 9
|
||||
|
||||
// size: R=0x8 | B=0x6
|
||||
typedef struct SpawnPokemonData
|
||||
{
|
||||
u16 bits; // species first 9 bits, level last 7 bits
|
||||
s16 randNum[2];
|
||||
} SpawnPokemonData;
|
||||
|
||||
#endif // GUARD_STR_SPAWN_POKEMON_DATA_H
|
||||
@@ -192,7 +192,7 @@ SECTIONS {
|
||||
src/personality_test1.o(.text);
|
||||
src/personality_test2.o(.text);
|
||||
src/code_803D0D8.o(.text);
|
||||
src/code_803D110.o(.text);
|
||||
src/dungeon_spawns.o(.text);
|
||||
src/dungeon_name_banner.o(.text);
|
||||
src/code_803DA7C_2.o(.text);
|
||||
src/dungeon_vram.o(.text);
|
||||
@@ -551,7 +551,7 @@ SECTIONS {
|
||||
src/personality_test2.o(.rodata);
|
||||
src/code_803D0D8.o(.rodata);
|
||||
src/dungeon_pos_data.o(.rodata);
|
||||
src/code_803D110.o(.rodata);
|
||||
src/dungeon_spawns.o(.rodata);
|
||||
src/dungeon_config.o(.rodata);
|
||||
src/dungeon_name_banner.o(.rodata);
|
||||
src/code_803DA7C_2.o(.rodata);
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "pokemon_3.h"
|
||||
#include "position_util.h"
|
||||
#include "weather.h"
|
||||
#include "dungeon_spawns.h"
|
||||
|
||||
extern void sub_8042900(Entity *r0);
|
||||
extern void sub_8042968(Entity *r0);
|
||||
@@ -43,9 +44,7 @@ extern void sub_804178C(u32);
|
||||
extern void sub_803F508(Entity *);
|
||||
extern void sub_8042B20(Entity *entity);
|
||||
extern void sub_8042B0C(Entity *entity);
|
||||
extern s32 sub_803D808(PackedPokemonData *strPtr, s32 id);
|
||||
extern void sub_8072AC8(u16 *param_1, s32 species, s32 param_3);
|
||||
extern s16 sub_803D970(u32);
|
||||
extern bool8 sub_8083660(const DungeonPos *param_1);
|
||||
extern Entity *gLeaderPointer;
|
||||
extern DungeonPos gUnknown_202EE0C;
|
||||
@@ -55,7 +54,6 @@ extern u8 gUnknown_202F32C;
|
||||
extern u8 GetRandomFloorItem(s32 a0);
|
||||
extern void DeletePokemonDungeonSprite(s32 id);
|
||||
extern void sub_80429E8(Entity *r0);
|
||||
extern s32 sub_803DA20(s32 param_1);
|
||||
extern Entity *sub_804550C(s16 a);
|
||||
extern Entity *sub_80453AC(s16 id);
|
||||
extern void sub_803F580(s32);
|
||||
@@ -80,9 +78,9 @@ void sub_806AD3C(void)
|
||||
{
|
||||
s32 r10;
|
||||
s32 i, j;
|
||||
PackedPokemonData sp[64];
|
||||
SpawnPokemonData sp[64];
|
||||
unkDungeon2F3C *structPtr = gDungeon->unk2F3C;
|
||||
s32 var_24 = sub_803D808(sp, 0);
|
||||
s32 var_24 = SetMonsterSpawnsArray(sp, 0);
|
||||
|
||||
for (i = 0; i < var_24; structPtr++, i++) {
|
||||
structPtr->species = ExtractSpeciesIndex(&sp[i]);
|
||||
@@ -212,14 +210,14 @@ void sub_806AED8(Moves *moves, s16 *maxHPStat, u8 *atk, u8 *def, s16 _species, s
|
||||
moves->struggleMoveFlags = 0;
|
||||
}
|
||||
|
||||
UNUSED static s32 sub_806B09C(PackedPokemonData *unkPtr, bool8 a1)
|
||||
UNUSED static s32 sub_806B09C(SpawnPokemonData *unkPtr, bool8 a1)
|
||||
{
|
||||
s32 i, j;
|
||||
s32 count = 0;
|
||||
s16 *unk2Field;
|
||||
PackedPokemonData *loopPtr;
|
||||
SpawnPokemonData *loopPtr;
|
||||
|
||||
for (i = 0, unk2Field = unkPtr->unk2, loopPtr = unkPtr; i < MAX_TEAM_MEMBERS; i++) {
|
||||
for (i = 0, unk2Field = unkPtr->randNum, loopPtr = unkPtr; i < MAX_TEAM_MEMBERS; i++) {
|
||||
PokemonStruct2 *monStructPtr = &gRecruitedPokemonRef->pokemon2[i];
|
||||
|
||||
if (PokemonFlag1Struct2(monStructPtr) && PokemonFlag2Struct2(monStructPtr))
|
||||
@@ -233,18 +231,18 @@ UNUSED static s32 sub_806B09C(PackedPokemonData *unkPtr, bool8 a1)
|
||||
SetSpeciesLevelToExtract(loopPtr, 0, monStructPtr->speciesNum);
|
||||
unk2Field[0] = 0;
|
||||
unk2Field[1] = 0;
|
||||
unk2Field += sizeof(*unkPtr) / sizeof(unkPtr->unk2[0]); // Hacky solution, because loopPtr->unk2[0/1] = 0; doesn't match
|
||||
unk2Field += sizeof(*unkPtr) / sizeof(unkPtr->randNum[0]); // Hacky solution, because loopPtr->unk2[0/1] = 0; doesn't match
|
||||
loopPtr++;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
count = sub_803D808(unkPtr, count);
|
||||
count = SetMonsterSpawnsArray(unkPtr, count);
|
||||
if (a1) {
|
||||
SetSpeciesLevelToExtract(&unkPtr[count], 1, MONSTER_DECOY);
|
||||
unkPtr[count].unk2[0] = 0;
|
||||
unkPtr[count].unk2[1] = 0;
|
||||
unkPtr[count].randNum[0] = 0;
|
||||
unkPtr[count].randNum[1] = 0;
|
||||
count++;
|
||||
}
|
||||
|
||||
@@ -511,7 +509,7 @@ void sub_806B6C4(void)
|
||||
r6 = TRUE;
|
||||
}
|
||||
else {
|
||||
spStruct.species = sub_803D970(0);
|
||||
spStruct.species = GetRandomFloorMonsterId(0);
|
||||
spStruct.level = 0;
|
||||
spStruct.unk2 = 0;
|
||||
}
|
||||
@@ -770,7 +768,7 @@ void sub_806BC68(bool8 a0, Entity *entity, struct unkStruct_806B7F8 *structPtr,
|
||||
gDungeon->unk37F0++;
|
||||
entInfo->unk9C = 0;
|
||||
if (structPtr->level == 0) {
|
||||
entInfo->level = sub_803DA20(structPtr->species);
|
||||
entInfo->level = GetSpawnedMonsterLevel(structPtr->species);
|
||||
}
|
||||
else {
|
||||
entInfo->level = structPtr->level;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "dungeon_random.h"
|
||||
#include "dungeon_vram.h"
|
||||
#include "dungeon_util.h"
|
||||
#include "dungeon_spawns.h"
|
||||
#include "dungeon.h"
|
||||
#include "pokemon_3.h"
|
||||
#include "code_805D8C8.h"
|
||||
@@ -39,7 +40,6 @@ void GetAvailTacticsforLvl_Bool(u8 *tacticsBuffer, s32 pokeLevel);
|
||||
bool8 sub_80723D0(Entity *, Entity *, u8, u8);
|
||||
void sub_807218C(Entity *);
|
||||
|
||||
extern bool8 sub_803D930(u32);
|
||||
extern void sub_8072B78(Entity *pokemon, Entity *target, s16 id);
|
||||
extern s32 GetMovesLearnedAtLevel(u16* dst, s16 species, s32 level, s32 IQPoints);
|
||||
|
||||
@@ -137,7 +137,7 @@ void sub_8071DA4(Entity *entity)
|
||||
for(counter = 0; counter < numMons; counter++)
|
||||
{
|
||||
id = &idStack[randIndex];
|
||||
if ((sub_803D930(*id) != 0) && (GetSpriteData(*id) != NULL)) {
|
||||
if ((CanMonsterBeSpawnedHere(*id) != 0) && (GetSpriteData(*id) != NULL)) {
|
||||
sub_8072B78(entityPtr,target,*id);
|
||||
break;
|
||||
}
|
||||
@@ -802,7 +802,7 @@ void sub_8072B78(Entity *pokemon, Entity *target, s16 id)
|
||||
tile = GetTile(gAdjacentTileOffsets[index].x + target->pos.x,gAdjacentTileOffsets[index].y + target->pos.y);
|
||||
if (sub_807034C(MONSTER_SHEDINJA,tile) == 0) break;
|
||||
}
|
||||
if (sub_803D930(MONSTER_SHEDINJA)) {
|
||||
if (CanMonsterBeSpawnedHere(MONSTER_SHEDINJA)) {
|
||||
local_2c.species = MONSTER_SHEDINJA;
|
||||
local_2c.level = entityInfo->level;
|
||||
local_2c.unk2 = 0;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "dungeon_strings.h"
|
||||
|
||||
extern bool8 sub_806AA0C(s32, u32);
|
||||
extern s16 sub_803D970(u32);
|
||||
extern s16 GetRandomFloorMonsterId(u32);
|
||||
extern void sub_804178C(u32);
|
||||
|
||||
void sub_807AA30(void)
|
||||
@@ -169,7 +169,7 @@ void sub_807AB38(Entity *entity, bool8 forcedMonsterHouse)
|
||||
{
|
||||
struct unkStruct_806B7F8 spawnStruct;
|
||||
|
||||
spawnStruct.species = sub_803D970(1);
|
||||
spawnStruct.species = GetRandomFloorMonsterId(1);
|
||||
spawnStruct.level = 0;
|
||||
spawnStruct.unk2 = 0;
|
||||
spawnStruct.unk4 = 0;
|
||||
|
||||
@@ -15,12 +15,11 @@
|
||||
#include "code_805D8C8.h"
|
||||
#include "structs/str_806B7F8.h"
|
||||
#include "dungeon_logic.h"
|
||||
#include "dungeon_spawns.h"
|
||||
|
||||
extern u8 *gUnknown_80FED68[];
|
||||
|
||||
extern void sub_8042920(struct Entity *r0);
|
||||
extern s16 sub_803D970(u32);
|
||||
extern s32 sub_803DA20(s32 param_1);
|
||||
extern bool8 sub_806AA0C(s32, u32);
|
||||
extern bool8 sub_8083660(DungeonPos *param_1);
|
||||
|
||||
@@ -96,10 +95,10 @@ void sub_8071B48(void)
|
||||
index1 = 0x17c;
|
||||
}
|
||||
else {
|
||||
index1 = sub_803D970(0);
|
||||
index1 = GetRandomFloorMonsterId(0);
|
||||
}
|
||||
|
||||
level = sub_803DA20(index1);
|
||||
level = GetSpawnedMonsterLevel(index1);
|
||||
if (level == 0) {
|
||||
level = 1;
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
#include "dungeon_util.h"
|
||||
#include "dungeon_items.h"
|
||||
#include "dungeon_message.h"
|
||||
#include "dungeon_spawns.h"
|
||||
#include "structs/str_806B7F8.h"
|
||||
#include "constants/monster.h"
|
||||
#include "constants/trap.h"
|
||||
#include "constants/item.h"
|
||||
|
||||
extern s32 sub_803DA20(s16 species);
|
||||
extern void sub_80429FC(DungeonPos *r0);
|
||||
|
||||
static bool8 sub_805210C(u8 itemId);
|
||||
@@ -48,7 +48,7 @@ static void SpawnSpeciesAtPos(s16 species_, s32 x, s32 y, u32 monsterBehav_, u32
|
||||
|
||||
if (species_ == MONSTER_DECOY) {
|
||||
unkStruct.species = MONSTER_POLIWAG;
|
||||
unkStruct.level = sub_803DA20(MONSTER_POLIWAG);
|
||||
unkStruct.level = GetSpawnedMonsterLevel(MONSTER_POLIWAG);
|
||||
unkStruct.unk2 = monsterBehav;
|
||||
unkStruct.unk4 = 0;
|
||||
unkStruct.unk10 = 0;
|
||||
@@ -58,7 +58,7 @@ static void SpawnSpeciesAtPos(s16 species_, s32 x, s32 y, u32 monsterBehav_, u32
|
||||
}
|
||||
else if (species != MONSTER_NONE) {
|
||||
unkStruct.species = species;
|
||||
unkStruct.level = sub_803DA20(species);
|
||||
unkStruct.level = GetSpawnedMonsterLevel(species);
|
||||
unkStruct.unk2 = monsterBehav;
|
||||
unkStruct.unk4 = 0;
|
||||
unkStruct.unk10 = 0;
|
||||
|
||||
@@ -294,16 +294,16 @@ static void SetRecruitableMons(struct MonRecruitList *tabsData)
|
||||
spArray[i] = 0;
|
||||
}
|
||||
|
||||
for (id = 0; id < gDungeon->unk37E4; id++) {
|
||||
for (id = 0; id < gDungeon->currFloorMonsterSpawnsCount; id++) {
|
||||
u8 byte = 1;
|
||||
s32 val1 = gDungeon->unk343C[id].unk2[0];
|
||||
s32 val2 = gDungeon->unk343C[id].unk2[1];
|
||||
s32 val1 = gDungeon->monsterSpawns[id].randNum[0];
|
||||
s32 val2 = gDungeon->monsterSpawns[id].randNum[1];
|
||||
if (val1 == 0) {
|
||||
if (val2 == 0)
|
||||
continue;
|
||||
byte = 2;
|
||||
}
|
||||
spArray[ExtractSpeciesIndex(&gDungeon->unk343C[id])] = byte;
|
||||
spArray[ExtractSpeciesIndex(&gDungeon->monsterSpawns[id])] = byte;
|
||||
}
|
||||
|
||||
if (gDungeon->unk644.unk2A) {
|
||||
|
||||
@@ -124,9 +124,9 @@ void LoadDungeonPokemonSprites(void)
|
||||
gDungeon->sprites[index] = NULL;
|
||||
}
|
||||
LoadPokemonSprite(MONSTER_DECOY, TRUE);
|
||||
for(index = 0; index < gDungeon->unk37E4; index++)
|
||||
for(index = 0; index < gDungeon->currFloorMonsterSpawnsCount; index++)
|
||||
{
|
||||
LoadPokemonSprite(ExtractSpeciesIndex(&gDungeon->unk343C[index]), TRUE);
|
||||
LoadPokemonSprite(ExtractSpeciesIndex(&gDungeon->monsterSpawns[index]), TRUE);
|
||||
}
|
||||
if(gDungeon->unk644.unk44)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "global.h"
|
||||
#include "globaldata.h"
|
||||
#include "dungeon_spawns.h"
|
||||
#include "constants/dungeon.h"
|
||||
#include "constants/trap.h"
|
||||
#include "structs/str_202ED28.h"
|
||||
#include "structs/str_202EDE8.h"
|
||||
#include "bg_palette_buffer.h"
|
||||
@@ -31,7 +33,7 @@ void sub_803D4AC(void)
|
||||
gDungeon->unk1C570.floor = 0xFF;
|
||||
}
|
||||
|
||||
void sub_803D4D0(void)
|
||||
void SetFloorItemMonsterSpawns(void)
|
||||
{
|
||||
s16 spArray[NUM_ITEM_CATEGORIES + NUMBER_OF_ITEM_IDS];
|
||||
s32 i, j, k;
|
||||
@@ -49,24 +51,24 @@ void sub_803D4D0(void)
|
||||
gDungeon->unk1CEC8 = GetDungeonFloorCount(gDungeon->unk644.dungeonLocation.id);
|
||||
gDungeon->unk14 = sub_80902C8(gDungeon->unk644.dungeonLocation.id);
|
||||
|
||||
gDungeon->floorProperties = ((struct DungeonMapParam2 *)(file->data))->unk4[strPtr->unk0];
|
||||
gDungeon->floorProperties = ((struct DungeonMapParam2 *)(file->data))->floorProperties[strPtr->unk0];
|
||||
|
||||
for (i = 0; i < 20; i++) {
|
||||
gDungeon->unk1CD70[i] = ((struct DungeonMapParam2 *)(file->data))->unk10[strPtr->unk4][i];
|
||||
for (i = 0; i < NUM_TRAPS; i++) {
|
||||
gDungeon->trapSpawnChances[i] = ((struct DungeonMapParam2 *)(file->data))->trapSpawnChances[strPtr->unk4][i];
|
||||
}
|
||||
for (i = 0; i < 31; i++) {
|
||||
gDungeon->unk1CD98[i] = ((struct DungeonMapParam2 *)(file->data))->unkC[strPtr->unk2][i];
|
||||
if (ExtractSpeciesIndex(&gDungeon->unk1CD98[i]) == 0)
|
||||
for (i = 0; i < MONSTER_SPAWNS_ARR_COUNT - 1; i++) {
|
||||
gDungeon->fileMonsterSpawns[i] = ((struct DungeonMapParam2 *)(file->data))->monsterSpawns[strPtr->unk2][i];
|
||||
if (ExtractSpeciesIndex(&gDungeon->fileMonsterSpawns[i]) == 0)
|
||||
break;
|
||||
}
|
||||
while (i <= 31) {
|
||||
SetSpeciesToExtract(&gDungeon->unk1CD98[i], 0);
|
||||
while (i < MONSTER_SPAWNS_ARR_COUNT) {
|
||||
SetSpeciesToExtract(&gDungeon->fileMonsterSpawns[i], 0);
|
||||
i++;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
u16 *src = ((struct DungeonMapParam2 *)(file->data))->unk8[strPtr->unk6[i]];
|
||||
u16 *src = ((struct DungeonMapParam2 *)(file->data))->itemSpawns[strPtr->unk6[i]];
|
||||
s32 arrId = 0;
|
||||
|
||||
for (j = 0; j < NUM_ITEM_CATEGORIES + NUMBER_OF_ITEM_IDS; ) {
|
||||
@@ -96,16 +98,16 @@ void sub_803D4D0(void)
|
||||
CloseFile(file);
|
||||
}
|
||||
|
||||
u8 sub_803D6FC(void)
|
||||
u8 GetRandomFloorTrap(void)
|
||||
{
|
||||
s32 i;
|
||||
s32 rand = DungeonRandInt(10000);
|
||||
for (i = 0; i < 20; i++) {
|
||||
if (gDungeon->unk1CD70[i] != 0 && gDungeon->unk1CD70[i] >= rand)
|
||||
for (i = 0; i < NUM_TRAPS; i++) {
|
||||
if (gDungeon->trapSpawnChances[i] != 0 && gDungeon->trapSpawnChances[i] >= rand)
|
||||
return i;
|
||||
}
|
||||
|
||||
return 16;
|
||||
return TRAP_CHESTNUT_TRAP;
|
||||
}
|
||||
|
||||
u8 GetRandomFloorItem(s32 spawnType)
|
||||
@@ -132,30 +134,30 @@ u8 GetRandomFloorItem(s32 spawnType)
|
||||
return ITEM_POKE;
|
||||
}
|
||||
|
||||
s32 sub_803D808(PackedPokemonData *strPtr, s32 id)
|
||||
s32 SetMonsterSpawnsArray(SpawnPokemonData *strPtr, s32 id)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
if (ExtractSpeciesIndex(&gDungeon->unk1CD98[i]) == 0)
|
||||
for (i = 0; i < MONSTER_SPAWNS_ARR_COUNT; i++) {
|
||||
if (ExtractSpeciesIndex(&gDungeon->fileMonsterSpawns[i]) == 0)
|
||||
break;
|
||||
strPtr[id] = gDungeon->unk1CD98[i];
|
||||
strPtr[id] = gDungeon->fileMonsterSpawns[i];
|
||||
id++;
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
s32 sub_803D870(PackedPokemonData *strPtr, s32 id)
|
||||
s32 GetAvailableMonsToTransform(SpawnPokemonData *strPtr, s32 id)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
s16 species = ExtractSpeciesIndex(&gDungeon->unk1CD98[i]);
|
||||
for (i = 0; i < MONSTER_SPAWNS_ARR_COUNT; i++) {
|
||||
s16 species = ExtractSpeciesIndex(&gDungeon->fileMonsterSpawns[i]);
|
||||
if (species == 0)
|
||||
break;
|
||||
if (GetBodySize(species) < 2 && gDungeon->unk1CD98[i].unk2[0] != 0) {
|
||||
strPtr[id] = gDungeon->unk1CD98[i];
|
||||
if (GetBodySize(species) < 2 && gDungeon->fileMonsterSpawns[i].randNum[0] != 0) {
|
||||
strPtr[id] = gDungeon->fileMonsterSpawns[i];
|
||||
id++;
|
||||
}
|
||||
}
|
||||
@@ -163,21 +165,21 @@ s32 sub_803D870(PackedPokemonData *strPtr, s32 id)
|
||||
return id;
|
||||
}
|
||||
|
||||
void sub_803D8F0(void)
|
||||
void SetCurrentMonsterSpawns(void)
|
||||
{
|
||||
if (gDungeon->unk37EC == 0) {
|
||||
gDungeon->unk37EC = 1;
|
||||
gDungeon->unk37E4 = sub_803D808(gDungeon->unk343C, 0);
|
||||
if (!gDungeon->monsterSpawnsPopulated) {
|
||||
gDungeon->monsterSpawnsPopulated = TRUE;
|
||||
gDungeon->currFloorMonsterSpawnsCount = SetMonsterSpawnsArray(gDungeon->monsterSpawns, 0);
|
||||
}
|
||||
}
|
||||
|
||||
bool8 sub_803D930(s16 speciesToFind)
|
||||
bool8 CanMonsterBeSpawnedHere(s16 speciesToFind)
|
||||
{
|
||||
s32 i;
|
||||
s32 id = SpeciesId(speciesToFind);
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
s16 species = ExtractSpeciesIndex(&gDungeon->unk1CD98[i]);
|
||||
for (i = 0; i < MONSTER_SPAWNS_ARR_COUNT; i++) {
|
||||
s16 species = ExtractSpeciesIndex(&gDungeon->fileMonsterSpawns[i]);
|
||||
if (species == 0)
|
||||
break;
|
||||
if (species == id)
|
||||
@@ -186,33 +188,33 @@ bool8 sub_803D930(s16 speciesToFind)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
s16 sub_803D970(s32 arrId)
|
||||
s16 GetRandomFloorMonsterId(s32 arrId)
|
||||
{
|
||||
s32 i;
|
||||
s32 rand = DungeonRandInt(10000);
|
||||
|
||||
for (i = 0; i < gDungeon->unk37E4; i++) {
|
||||
if (gDungeon->unk343C[i].unk2[arrId] != 0 && gDungeon->unk343C[i].unk2[arrId] >= rand) {
|
||||
return ExtractSpeciesIndex(&gDungeon->unk343C[i]);
|
||||
for (i = 0; i < gDungeon->currFloorMonsterSpawnsCount; i++) {
|
||||
if (gDungeon->monsterSpawns[i].randNum[arrId] != 0 && gDungeon->monsterSpawns[i].randNum[arrId] >= rand) {
|
||||
return ExtractSpeciesIndex(&gDungeon->monsterSpawns[i]);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < gDungeon->unk37E4; i++) {
|
||||
if (gDungeon->unk343C[i].unk2[arrId] != 0) {
|
||||
return ExtractSpeciesIndex(&gDungeon->unk343C[i]);
|
||||
for (i = 0; i < gDungeon->currFloorMonsterSpawnsCount; i++) {
|
||||
if (gDungeon->monsterSpawns[i].randNum[arrId] != 0) {
|
||||
return ExtractSpeciesIndex(&gDungeon->monsterSpawns[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return MONSTER_KECLEON;
|
||||
}
|
||||
|
||||
s32 sub_803DA20(s32 species)
|
||||
s32 GetSpawnedMonsterLevel(s32 species)
|
||||
{
|
||||
s32 i;
|
||||
s32 speciesId = SpeciesId(species);
|
||||
|
||||
for (i = 0; i < gDungeon->unk37E4; i++) {
|
||||
if (ExtractSpeciesIndex(&gDungeon->unk343C[i]) == speciesId)
|
||||
return ExtractLevel(&gDungeon->unk343C[i]);
|
||||
for (i = 0; i < gDungeon->currFloorMonsterSpawnsCount; i++) {
|
||||
if (ExtractSpeciesIndex(&gDungeon->monsterSpawns[i]) == speciesId)
|
||||
return ExtractLevel(&gDungeon->monsterSpawns[i]);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ extern void HandleDroughtOrbAction(Entity *);
|
||||
extern void HandleLuminousOrbAction(Entity *pokemon);
|
||||
extern void HandleTrawlOrbAction(Entity *, Entity *);
|
||||
extern void HandlePounceOrbAction(Entity *, Entity *, s32);
|
||||
extern s16 sub_803D970(u32);
|
||||
extern s16 GetRandomFloorMonsterId(u32);
|
||||
extern bool8 sub_806AA0C(s32, u32);
|
||||
extern void sub_806BB6C(Entity *, s32);
|
||||
extern void HandleSwitcherOrb(Entity *, Entity *, u32);
|
||||
@@ -581,7 +581,7 @@ bool8 TransferOrbAction(Entity *pokemon, Entity * target, Move *move, s32 param_
|
||||
else
|
||||
{
|
||||
for (r6 = 0; r6 < 0x1E; r6++) {
|
||||
targetID = sub_803D970(0);
|
||||
targetID = GetRandomFloorMonsterId(0);
|
||||
if ((sub_806AA0C(targetID,0)) && (oldID != targetID)) {
|
||||
if (GetBodySize(oldID) == GetBodySize(targetID)) break;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "dungeon_strings.h"
|
||||
#include "dungeon_random.h"
|
||||
#include "dungeon_misc.h"
|
||||
#include "dungeon_spawns.h"
|
||||
|
||||
extern u32 gUnknown_8106A4C;
|
||||
|
||||
@@ -85,7 +86,6 @@ extern void nullsub_87(Entity *);
|
||||
extern void nullsub_86(Entity *);
|
||||
extern void sub_8041E0C(Entity *);
|
||||
extern void sub_8041DD8(Entity *r0, s32 r1); // NOTE: is s16 in another file
|
||||
extern s32 sub_803D870(PackedPokemonData *strPtr, s32 id);
|
||||
extern bool8 sub_806AA0C(s32, u32);
|
||||
extern void sub_803F580(u32);
|
||||
extern void ShowWholeRevealedDungeonMap(void);
|
||||
@@ -909,7 +909,7 @@ void TransformStatusTarget(Entity * pokemon, Entity * target)
|
||||
s32 index;
|
||||
EntityInfo *entityInfo;
|
||||
OpenedFile *sprite;
|
||||
PackedPokemonData auStack544[64];
|
||||
SpawnPokemonData auStack544[64];
|
||||
|
||||
if (!EntityIsValid(target))
|
||||
return;
|
||||
@@ -920,7 +920,7 @@ void TransformStatusTarget(Entity * pokemon, Entity * target)
|
||||
TryDisplayDungeonLoggableMessage3(pokemon, target, gUnknown_80FBF04);
|
||||
else {
|
||||
SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0], target, 0);
|
||||
iVar5 = sub_803D870(auStack544, 0);
|
||||
iVar5 = GetAvailableMonsToTransform(auStack544, 0);
|
||||
|
||||
if (iVar5 == 0)
|
||||
TryDisplayDungeonLoggableMessage3(pokemon, target, gUnknown_80FBEE4);
|
||||
|
||||
@@ -260,13 +260,13 @@ s32 GetUnownIndex(s16 index)
|
||||
}
|
||||
|
||||
// arm9.bin::02059B98
|
||||
s16 ExtractSpeciesIndex(PackedPokemonData *data)
|
||||
s16 ExtractSpeciesIndex(SpawnPokemonData *data)
|
||||
{
|
||||
return data->bits & PACKED_BITS_SPECIES;
|
||||
}
|
||||
|
||||
// arm9.bin::02059B7C
|
||||
void SetSpeciesToExtract(PackedPokemonData *data, s32 species_)
|
||||
void SetSpeciesToExtract(SpawnPokemonData *data, s32 species_)
|
||||
{
|
||||
s32 species = (s16) species_;
|
||||
data->bits &= (PACKED_BITS_LEVEL << PACKED_BITS_LEVEL_SHIFT);
|
||||
@@ -274,7 +274,7 @@ void SetSpeciesToExtract(PackedPokemonData *data, s32 species_)
|
||||
}
|
||||
|
||||
#if (GAME_VERSION == VERSION_RED)
|
||||
void SetSpeciesLevelToExtract(PackedPokemonData *data, s32 level, s32 species_)
|
||||
void SetSpeciesLevelToExtract(SpawnPokemonData *data, s32 level, s32 species_)
|
||||
{
|
||||
s32 species = (s16) (species_);
|
||||
data->bits = species | (level << PACKED_BITS_LEVEL_SHIFT) ;
|
||||
@@ -282,7 +282,7 @@ void SetSpeciesLevelToExtract(PackedPokemonData *data, s32 level, s32 species_)
|
||||
#endif
|
||||
|
||||
// arm9.bin::02059B6C
|
||||
s32 ExtractLevel(PackedPokemonData *data)
|
||||
s32 ExtractLevel(SpawnPokemonData *data)
|
||||
{
|
||||
return (data->bits >> PACKED_BITS_LEVEL_SHIFT) & PACKED_BITS_LEVEL;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "dungeon_misc.h"
|
||||
#include "dungeon_music.h"
|
||||
#include "dungeon_name_banner.h"
|
||||
#include "dungeon_spawns.h"
|
||||
#include "dungeon_random.h"
|
||||
#include "dungeon_strings.h"
|
||||
#include "dungeon_serializer.h"
|
||||
@@ -94,11 +95,10 @@ extern void sub_807E7FC(u8);
|
||||
extern bool8 IsLevelResetTo1(u8 dungeon);
|
||||
extern void sub_8068A84(PokemonStruct1 *pokemon);
|
||||
extern void sub_807EAA0(u32, u32);
|
||||
extern void sub_803D4D0(void);
|
||||
extern void SetFloorItemMonsterSpawns(void);
|
||||
extern void sub_80842F0(void);
|
||||
extern void sub_80427AC(void);
|
||||
extern void sub_806AA70(void);
|
||||
extern void sub_803D8F0(void);
|
||||
extern void sub_806AD3C(void);
|
||||
extern void sub_806C42C(void);
|
||||
extern void sub_806B678(void);
|
||||
@@ -294,7 +294,7 @@ void RunDungeon_Async(DungeonSetupStruct *setupPtr)
|
||||
gDungeon->unk644.unk24 = 10;
|
||||
InitDungeonRNG(gDungeon->unk644.unk3C);
|
||||
}
|
||||
gDungeon->unk37EC = 0;
|
||||
gDungeon->monsterSpawnsPopulated = FALSE;
|
||||
if (!r6) {
|
||||
s32 rnd;
|
||||
|
||||
@@ -306,7 +306,7 @@ void RunDungeon_Async(DungeonSetupStruct *setupPtr)
|
||||
gDungeon->unk37FF = 0;
|
||||
gDungeon->unk644.unk31 = 0;
|
||||
}
|
||||
sub_803D4D0();
|
||||
SetFloorItemMonsterSpawns();
|
||||
gDungeon->unk1 = 0;
|
||||
gDungeon->unk10 = 0;
|
||||
gDungeon->unk2 = 0;
|
||||
@@ -349,7 +349,7 @@ void RunDungeon_Async(DungeonSetupStruct *setupPtr)
|
||||
sub_807E5E4(0);
|
||||
sub_80842F0();
|
||||
}
|
||||
sub_803D8F0();
|
||||
SetCurrentMonsterSpawns();
|
||||
LoadDungeonPokemonSprites();
|
||||
if (!r6) {
|
||||
sub_80687AC();
|
||||
|
||||
11
src/trap.c
11
src/trap.c
@@ -18,6 +18,7 @@
|
||||
#include "dungeon_random.h"
|
||||
#include "dungeon_util.h"
|
||||
#include "dungeon_vram.h"
|
||||
#include "dungeon_spawns.h"
|
||||
#include "items.h"
|
||||
#include "move_effects_target.h"
|
||||
#include "moves.h"
|
||||
@@ -34,7 +35,6 @@ extern u32 gUnknown_8106A4C;
|
||||
extern u32 gUnknown_8106A50;
|
||||
extern SpriteOAM gUnknown_202EDC0;
|
||||
|
||||
s16 sub_803D970(u32);
|
||||
bool8 sub_806AA0C(s32, s32);
|
||||
void sub_80421EC(DungeonPos *, u32);
|
||||
bool8 sub_8045888(Entity *);
|
||||
@@ -45,7 +45,6 @@ void sub_806F480(Entity *, u32);
|
||||
void sub_804225C(Entity *, DungeonPos *, u8);
|
||||
void sub_8071DA4(Entity *);
|
||||
void sub_806A1E8(Entity *pokemon);
|
||||
u8 sub_803D6FC(void);
|
||||
Entity *sub_8045684(u8, DungeonPos *, u8);
|
||||
extern void HandleExplosion(Entity *pokemon, Entity *target, DungeonPos *pos, u32, u8 moveType, s16);
|
||||
|
||||
@@ -65,7 +64,7 @@ void sub_807FA18(void)
|
||||
trapId = TRAP_WARP_TRAP;
|
||||
}
|
||||
else {
|
||||
trapId = sub_803D6FC();
|
||||
trapId = GetRandomFloorTrap();
|
||||
}
|
||||
|
||||
if (trapId == TRAP_WONDER_TILE) {
|
||||
@@ -162,7 +161,7 @@ bool8 LayTrap(DungeonPos *pos, u8 trapID, u8 param_3)
|
||||
tile = GetTileMut(pos->x, pos->y);
|
||||
if (TRAP_SPIKE_TRAP < trapID) {
|
||||
counter = 0;
|
||||
while ((counter < 0x1e && (trapID = sub_803D6FC(), trapID == TRAP_WONDER_TILE))) {
|
||||
while ((counter < 0x1e && (trapID = GetRandomFloorTrap(), trapID == TRAP_WONDER_TILE))) {
|
||||
counter++;
|
||||
}
|
||||
if (counter == 0x1e) {
|
||||
@@ -633,7 +632,7 @@ void HandleSummonTrap(Entity *pokemon,DungeonPos *pos)
|
||||
if (pokemonSummonCount < r4) {
|
||||
for (i = 0; i < r4; i++)
|
||||
{
|
||||
species = sub_803D970(0);
|
||||
species = GetRandomFloorMonsterId(0);
|
||||
direction &= DIRECTION_MASK;
|
||||
stack.species = species;
|
||||
if (sub_806AA0C(stack.species,0)) {
|
||||
@@ -795,7 +794,7 @@ void HandlePokemonTrap(Entity *param_1,DungeonPos *pos)
|
||||
species = MONSTER_KECLEON;
|
||||
}
|
||||
else {
|
||||
species = (s16) sub_803D970(0);
|
||||
species = (s16) GetRandomFloorMonsterId(0);
|
||||
ASM_MATCH_TRICK(species);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ void sub_80ADD9C(OpenedFile **a0, OpenedFile **a1, u32 *a2, void *a3, u16 *a4, D
|
||||
}
|
||||
|
||||
strPtr = &((struct DungeonMapParam2 *)(mapParamFile->data))->unk0[dungId][dungFloor];
|
||||
r8 = ((struct DungeonMapParam2 *)(mapParamFile->data))->unk4[strPtr->unk0].unk2;
|
||||
r8 = ((struct DungeonMapParam2 *)(mapParamFile->data))->floorProperties[strPtr->unk0].unk2;
|
||||
|
||||
CloseFile(mapParamFile);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user