mirror of
https://github.com/pret/pmd-sky.git
synced 2026-09-30 22:27:51 -05:00
Merge pull request #265 from slaw-22/spawn-3
Some checks are pending
build / build (push) Waiting to run
Some checks are pending
build / build (push) Waiting to run
Decomp spawning functions
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
.public ChangeGiratinaFormIfSkyDungeon
|
||||
.public ClearHiddenStairs
|
||||
.public CloseFixedBin
|
||||
.public CopySpawnEntriesOnce
|
||||
.public CountItemsOnFloorForAcuteSniffer
|
||||
.public Debug_Print0
|
||||
.public DeleteAllMonsterSpriteFiles
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
.public CheckActiveChallengeRequest
|
||||
.public CheckSpawnThreshold
|
||||
.public DIRECTIONS_XY
|
||||
.public DisplayAnimatedNumbers
|
||||
.public DUNGEON_PTR
|
||||
.public DisplayAnimatedNumbers
|
||||
.public DungeonFloorToGroupFloor
|
||||
.public DungeonGetTotalSpriteFileSize
|
||||
.public DungeonGoesUp
|
||||
@@ -19,7 +19,6 @@
|
||||
.public FloorNumberIsEven
|
||||
.public GetEffectAnimationField0x19
|
||||
.public GetFloorType
|
||||
.public GetItemCategoryVeneer
|
||||
.public GetLeader
|
||||
.public GetMonsterGenderVeneer
|
||||
.public GetMonsterIdFromSpawnEntry
|
||||
@@ -29,7 +28,6 @@
|
||||
.public GetNbRecruited
|
||||
.public GetSecondFormIfValid
|
||||
.public GetSpriteFileSize
|
||||
.public GetSpriteSize
|
||||
.public HandleSir0Translation
|
||||
.public IsBossFight
|
||||
.public IsCurrentFixedRoomBossFight
|
||||
@@ -47,6 +45,28 @@
|
||||
.public MemFree
|
||||
.public MonsterIsType
|
||||
.public NeedsItemToSpawn
|
||||
.public PlayEffectAnimationEntity
|
||||
.public PlaySeByIdIfNotSilence
|
||||
.public RandIntSafe
|
||||
.public STATUS_ICON_ARRAY_BIDE
|
||||
.public STATUS_ICON_ARRAY_BLINDED
|
||||
.public STATUS_ICON_ARRAY_BURN
|
||||
.public STATUS_ICON_ARRAY_CRINGE
|
||||
.public STATUS_ICON_ARRAY_CURSE
|
||||
.public STATUS_ICON_ARRAY_FREEZE
|
||||
.public STATUS_ICON_ARRAY_INVISIBLE
|
||||
.public STATUS_ICON_ARRAY_LEECH_SEED
|
||||
.public STATUS_ICON_ARRAY_LONG_TOSS
|
||||
.public STATUS_ICON_ARRAY_MAGNET_RISE
|
||||
.public STATUS_ICON_ARRAY_MIRACLE_EYE
|
||||
.public STATUS_ICON_ARRAY_MUZZLED
|
||||
.public STATUS_ICON_ARRAY_REFLECT
|
||||
.public STATUS_ICON_ARRAY_SLEEP
|
||||
.public STATUS_ICON_ARRAY_SURE_SHOT
|
||||
.public SetMonsterId
|
||||
.public ShouldDisplayEntityWrapper
|
||||
.public SubstitutePlaceholderStringTags
|
||||
.public UnloadFile
|
||||
.public ov10_022BDC68
|
||||
.public ov10_022BDE50
|
||||
.public ov10_022BEC08
|
||||
@@ -81,28 +101,6 @@
|
||||
.public ov29_023515B0
|
||||
.public ov29_023515CC
|
||||
.public ov29_0235354C
|
||||
.public PlayEffectAnimationEntity
|
||||
.public PlaySeByIdIfNotSilence
|
||||
.public RandIntSafe
|
||||
.public SetMonsterId
|
||||
.public ShouldDisplayEntityWrapper
|
||||
.public STATUS_ICON_ARRAY_BIDE
|
||||
.public STATUS_ICON_ARRAY_BLINDED
|
||||
.public STATUS_ICON_ARRAY_BURN
|
||||
.public STATUS_ICON_ARRAY_CRINGE
|
||||
.public STATUS_ICON_ARRAY_CURSE
|
||||
.public STATUS_ICON_ARRAY_FREEZE
|
||||
.public STATUS_ICON_ARRAY_INVISIBLE
|
||||
.public STATUS_ICON_ARRAY_LEECH_SEED
|
||||
.public STATUS_ICON_ARRAY_LONG_TOSS
|
||||
.public STATUS_ICON_ARRAY_MAGNET_RISE
|
||||
.public STATUS_ICON_ARRAY_MIRACLE_EYE
|
||||
.public STATUS_ICON_ARRAY_MUZZLED
|
||||
.public STATUS_ICON_ARRAY_REFLECT
|
||||
.public STATUS_ICON_ARRAY_SLEEP
|
||||
.public STATUS_ICON_ARRAY_SURE_SHOT
|
||||
.public sub_0201C000
|
||||
.public sub_0201CF90
|
||||
.public sub_0201D034
|
||||
.public SubstitutePlaceholderStringTags
|
||||
.public UnloadFile
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
.public GetOutlawLeaderLevel
|
||||
.public GetOutlawLevel
|
||||
.public GetOutlawMinionLevel
|
||||
.public GetRandomSecretRoomItem
|
||||
.public GetResolvedPerformanceProgressFlag
|
||||
.public GetSpecialTargetItem
|
||||
.public GetTileSafe
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
.public GetMissionEnemyMinionGroup
|
||||
.public GetMissionTargetEnemy
|
||||
.public GetMoneyCarried
|
||||
.public GetRandomBazaarItem
|
||||
.public InitStandardItem
|
||||
.public IsBagFull
|
||||
.public IsItemInBag
|
||||
|
||||
@@ -710,7 +710,7 @@ _022DF574:
|
||||
bl ov29_022E8708
|
||||
bl ov29_022DD5B4
|
||||
bl ov29_023369F8
|
||||
bl ov29_022E7CFC
|
||||
bl CopySpawnEntriesOnce
|
||||
bl ov29_022F7130
|
||||
cmp r5, #0
|
||||
bne _022DF5C4
|
||||
|
||||
@@ -5403,252 +5403,3 @@ _022E7AB8:
|
||||
moveq r0, #0x10
|
||||
ldmia sp!, {r4, pc}
|
||||
arm_func_end GetRandomTrapId
|
||||
|
||||
arm_func_start GetItemIdToSpawn
|
||||
GetItemIdToSpawn: ; 0x022E7AC4
|
||||
stmdb sp!, {r3, r4, r5, r6, r7, r8, sb, lr}
|
||||
mov r4, r0
|
||||
ldr r0, _022E7BA8 ; =0x00002710
|
||||
bl DungeonRandInt
|
||||
mov r1, #0xb10
|
||||
mul r5, r4, r1
|
||||
ldr r2, _022E7BAC ; =DUNGEON_PTR
|
||||
mov r4, #0x10
|
||||
ldr r1, [r2]
|
||||
mov r3, #0
|
||||
add r6, r1, r5
|
||||
ldr r1, _022E7BB0 ; =0x000286D2
|
||||
b _022E7B18
|
||||
_022E7AF8:
|
||||
add r2, r6, r3, lsl #1
|
||||
ldrsh r2, [r2, r1]
|
||||
cmp r2, #0
|
||||
beq _022E7B14
|
||||
cmp r2, r0
|
||||
andge r4, r3, #0xff
|
||||
bge _022E7B20
|
||||
_022E7B14:
|
||||
add r3, r3, #1
|
||||
_022E7B18:
|
||||
cmp r3, #0x10
|
||||
blt _022E7AF8
|
||||
_022E7B20:
|
||||
cmp r4, #0x10
|
||||
moveq r0, #0xb7
|
||||
ldmeqia sp!, {r3, r4, r5, r6, r7, r8, sb, pc}
|
||||
ldr r0, _022E7BA8 ; =0x00002710
|
||||
bl DungeonRandInt
|
||||
mov r6, r0
|
||||
mov r7, #0
|
||||
ldr sb, _022E7BAC ; =DUNGEON_PTR
|
||||
ldr r8, _022E7BB4 ; =0x000286F2
|
||||
b _022E7B98
|
||||
_022E7B48:
|
||||
ldr r0, [sb]
|
||||
add r0, r5, r0
|
||||
add r0, r0, r7, lsl #1
|
||||
ldrsh r0, [r0, r8]
|
||||
cmp r0, #0
|
||||
beq _022E7B94
|
||||
mov r0, r7, lsl #0x10
|
||||
mov r0, r0, asr #0x10
|
||||
bl GetItemCategoryVeneer
|
||||
cmp r4, r0
|
||||
bne _022E7B94
|
||||
ldr r0, [sb]
|
||||
add r0, r5, r0
|
||||
add r0, r0, r7, lsl #1
|
||||
ldrsh r0, [r0, r8]
|
||||
cmp r0, r6
|
||||
movge r0, r7, lsl #0x10
|
||||
movge r0, r0, asr #0x10
|
||||
ldmgeia sp!, {r3, r4, r5, r6, r7, r8, sb, pc}
|
||||
_022E7B94:
|
||||
add r7, r7, #1
|
||||
_022E7B98:
|
||||
cmp r7, #0x16c
|
||||
blt _022E7B48
|
||||
mov r0, #0xb7
|
||||
ldmia sp!, {r3, r4, r5, r6, r7, r8, sb, pc}
|
||||
.align 2, 0
|
||||
_022E7BA8: .word 0x00002710
|
||||
_022E7BAC: .word DUNGEON_PTR
|
||||
#ifdef JAPAN
|
||||
_022E7BB0: .word 0x0002862E
|
||||
_022E7BB4: .word 0x0002864E
|
||||
#else
|
||||
_022E7BB0: .word 0x000286D2
|
||||
_022E7BB4: .word 0x000286F2
|
||||
#endif
|
||||
arm_func_end GetItemIdToSpawn
|
||||
|
||||
arm_func_start ov29_022E7BB8
|
||||
ov29_022E7BB8: ; 0x022E7BB8
|
||||
stmdb sp!, {r3, lr}
|
||||
mov r0, #4
|
||||
bl GetItemIdToSpawn
|
||||
cmp r0, #0xb7
|
||||
moveq r0, #0x46
|
||||
ldmia sp!, {r3, pc}
|
||||
arm_func_end ov29_022E7BB8
|
||||
|
||||
arm_func_start ov29_022E7BD0
|
||||
ov29_022E7BD0: ; 0x022E7BD0
|
||||
stmdb sp!, {r3, lr}
|
||||
mov r0, #5
|
||||
bl GetItemIdToSpawn
|
||||
cmp r0, #0xb7
|
||||
moveq r0, #0x46
|
||||
ldmia sp!, {r3, pc}
|
||||
arm_func_end ov29_022E7BD0
|
||||
|
||||
arm_func_start CopySpawnEntriesMaster
|
||||
CopySpawnEntriesMaster: ; 0x022E7BE8
|
||||
stmdb sp!, {r3, r4, r5, r6, r7, lr}
|
||||
mov r6, r0
|
||||
mov r5, r1
|
||||
mov r4, #0
|
||||
ldr r7, _022E7C5C ; =DUNGEON_PTR
|
||||
b _022E7C4C
|
||||
_022E7C00:
|
||||
ldr r0, [r7]
|
||||
#ifdef JAPAN
|
||||
add r0, r0, #0x8c0
|
||||
add r0, r0, #0x2c000
|
||||
#else
|
||||
add r0, r0, #0x164
|
||||
add r0, r0, #0x2c800
|
||||
#endif
|
||||
add r0, r0, r4, lsl #3
|
||||
bl GetMonsterIdFromSpawnEntry
|
||||
cmp r0, #0
|
||||
beq _022E7C54
|
||||
ldr r0, [r7]
|
||||
add r2, r6, r5, lsl #3
|
||||
add r0, r0, r4, lsl #3
|
||||
#ifdef JAPAN
|
||||
add r0, r0, #0x8c0
|
||||
add r3, r0, #0x2c000
|
||||
#else
|
||||
add r0, r0, #0x164
|
||||
add r3, r0, #0x2c800
|
||||
#endif
|
||||
mov r1, #4
|
||||
_022E7C34:
|
||||
ldrh r0, [r3], #2
|
||||
subs r1, r1, #1
|
||||
strh r0, [r2], #2
|
||||
bne _022E7C34
|
||||
add r5, r5, #1
|
||||
add r4, r4, #1
|
||||
_022E7C4C:
|
||||
cmp r4, #0x10
|
||||
blt _022E7C00
|
||||
_022E7C54:
|
||||
mov r0, r5
|
||||
ldmia sp!, {r3, r4, r5, r6, r7, pc}
|
||||
.align 2, 0
|
||||
_022E7C5C: .word DUNGEON_PTR
|
||||
arm_func_end CopySpawnEntriesMaster
|
||||
|
||||
arm_func_start MonsterSpawnListPartialCopy
|
||||
MonsterSpawnListPartialCopy: ; 0x022E7C60
|
||||
stmdb sp!, {r4, r5, r6, lr}
|
||||
mov r6, r0
|
||||
mov r5, r1
|
||||
mov r4, #0
|
||||
b _022E7CE4
|
||||
_022E7C74:
|
||||
ldr r0, _022E7CF4 ; =DUNGEON_PTR
|
||||
ldr r0, [r0]
|
||||
#ifdef JAPAN
|
||||
add r0, r0, #0x8c0
|
||||
add r0, r0, #0x2c000
|
||||
#else
|
||||
add r0, r0, #0x164
|
||||
add r0, r0, #0x2c800
|
||||
#endif
|
||||
add r0, r0, r4, lsl #3
|
||||
bl GetMonsterIdFromSpawnEntry
|
||||
cmp r0, #0
|
||||
beq _022E7CEC
|
||||
bl GetSpriteSize
|
||||
cmp r0, #6
|
||||
bhi _022E7CE0
|
||||
#ifdef JAPAN
|
||||
ldr r0, _022E7CF4 ; =DUNGEON_PTR
|
||||
ldr r0, [r0]
|
||||
add r1, r0, r4, lsl #3
|
||||
add r0, r1, #0x2c800
|
||||
ldrsh r0, [r0, #0xc2]
|
||||
cmp r0, #0
|
||||
beq _022E7CE0
|
||||
add r0, r1, #0x8c0
|
||||
add r3, r0, #0x2c000
|
||||
#else
|
||||
ldr r1, _022E7CF4 ; =DUNGEON_PTR
|
||||
ldr r0, _022E7CF8 ; =0x0002C966
|
||||
ldr r1, [r1]
|
||||
add r1, r1, r4, lsl #3
|
||||
ldrsh r0, [r1, r0]
|
||||
cmp r0, #0
|
||||
beq _022E7CE0
|
||||
add r0, r1, #0x164
|
||||
add r3, r0, #0x2c800
|
||||
#endif
|
||||
add r2, r6, r5, lsl #3
|
||||
mov r1, #4
|
||||
_022E7CCC:
|
||||
ldrh r0, [r3], #2
|
||||
subs r1, r1, #1
|
||||
strh r0, [r2], #2
|
||||
bne _022E7CCC
|
||||
add r5, r5, #1
|
||||
_022E7CE0:
|
||||
add r4, r4, #1
|
||||
_022E7CE4:
|
||||
cmp r4, #0x10
|
||||
blt _022E7C74
|
||||
_022E7CEC:
|
||||
mov r0, r5
|
||||
ldmia sp!, {r4, r5, r6, pc}
|
||||
.align 2, 0
|
||||
_022E7CF4: .word DUNGEON_PTR
|
||||
#ifndef JAPAN
|
||||
_022E7CF8: .word 0x0002C966
|
||||
#endif
|
||||
arm_func_end MonsterSpawnListPartialCopy
|
||||
|
||||
arm_func_start ov29_022E7CFC
|
||||
ov29_022E7CFC: ; 0x022E7CFC
|
||||
#ifdef JAPAN
|
||||
#define OV29_022E7CFC_OFFSET -0xA4
|
||||
#else
|
||||
#define OV29_022E7CFC_OFFSET 0
|
||||
#endif
|
||||
stmdb sp!, {r3, lr}
|
||||
ldr r1, _022E7D48 ; =DUNGEON_PTR
|
||||
ldr r0, [r1]
|
||||
add r0, r0, #0x3000
|
||||
ldrb r2, [r0, #0xe28 + OV29_022E7CFC_OFFSET]
|
||||
cmp r2, #0
|
||||
ldmneia sp!, {r3, pc}
|
||||
mov r2, #1
|
||||
strb r2, [r0, #0xe28 + OV29_022E7CFC_OFFSET]
|
||||
ldr r0, [r1]
|
||||
mov r1, #0
|
||||
#ifdef JAPAN
|
||||
add r0, r0, #0x124
|
||||
#else
|
||||
add r0, r0, #0x174
|
||||
#endif
|
||||
add r0, r0, #0x3800
|
||||
bl CopySpawnEntriesMaster
|
||||
ldr r1, _022E7D48 ; =DUNGEON_PTR
|
||||
ldr r1, [r1]
|
||||
add r1, r1, #0x3000
|
||||
str r0, [r1, #0xe20 + OV29_022E7CFC_OFFSET]
|
||||
ldmia sp!, {r3, pc}
|
||||
.align 2, 0
|
||||
_022E7D48: .word DUNGEON_PTR
|
||||
arm_func_end ov29_022E7CFC
|
||||
|
||||
@@ -1672,7 +1672,7 @@ _023434D8:
|
||||
bl IsSecretRoom
|
||||
cmp r0, #0
|
||||
beq _023434F0
|
||||
bl ov29_022E7BD0
|
||||
bl GetRandomSecretRoomItem
|
||||
mov r3, r0
|
||||
b _02343528
|
||||
_023434F0:
|
||||
|
||||
@@ -501,7 +501,7 @@ _023447C4:
|
||||
cmp r0, #0x32
|
||||
movlt r6, #0x46
|
||||
blt _023447FC
|
||||
bl ov29_022E7BB8
|
||||
bl GetRandomBazaarItem
|
||||
mov r6, r0
|
||||
_023447FC:
|
||||
mov r1, r5
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
#define DUNGEON_MAX_SIZE_Y 32
|
||||
#define CORRIDOR_ROOM 0xFF
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
enum terrain_type
|
||||
{
|
||||
// These 3 seem to indicate the 'main' type of the terrain. See helper functions for how they're set.
|
||||
@@ -101,6 +99,14 @@ struct dungeon_generation_info {
|
||||
// There's another 6 words that look like spawn positions right after these 4
|
||||
};
|
||||
|
||||
// Thresholds are ascending cumulative weights (0-10000)
|
||||
struct item_spawn_weights {
|
||||
s16 category_threshold[0x8];
|
||||
s16 unknown_1[0x8];
|
||||
s16 item_threshold[0x16c];
|
||||
s16 unknown_2[0x40c];
|
||||
};
|
||||
|
||||
// Dungeon state
|
||||
struct dungeon {
|
||||
u8 field_0x0; // 0x0: Initialized to 0x0.
|
||||
@@ -1217,9 +1223,8 @@ struct dungeon {
|
||||
u8 field_0x3e25;
|
||||
u8 field_0x3e26;
|
||||
u8 field_0x3e27;
|
||||
// 0x3E28: Related in some way to the spawn entries on the floor. Does something about them
|
||||
// if false, then set to true.
|
||||
bool8 unk_spawn_entry_id_check;
|
||||
// 0x3E28: Set to true after spawn entries are copied. Prevents copying spawn entries more than once.
|
||||
bool8 spawn_entries_copied;
|
||||
u8 field_0x3e29;
|
||||
u8 field_0x3e2a;
|
||||
u8 field_0x3e2b;
|
||||
@@ -1643,41 +1648,10 @@ struct dungeon {
|
||||
// 0x286B1: Initialized to 0xFF, then set to a copy of dungeon::0x74B
|
||||
u8 field_0x286b1;
|
||||
struct floor_properties floor_properties; // 0x286B2: Properties about the current floor
|
||||
// 0x286D2: Maybe a 0x10 long array?
|
||||
u16 field_0x286d2;
|
||||
u16 field_0x286d4;
|
||||
u16 field_0x286d6;
|
||||
u16 field_0x286d8;
|
||||
u16 field_0x286da;
|
||||
u16 field_0x286dc;
|
||||
u16 field_0x286de;
|
||||
u16 field_0x286e0;
|
||||
u16 field_0x286e2;
|
||||
u16 field_0x286e4;
|
||||
u16 field_0x286e6;
|
||||
u16 field_0x286e8;
|
||||
u16 field_0x286ea;
|
||||
u16 field_0x286ec;
|
||||
u16 field_0x286ee;
|
||||
u16 field_0x286f0;
|
||||
// 0x286F2: Spawn weights for regular items. It's the unrolled form of this floor's regular
|
||||
// item spawn list.
|
||||
// It has enough space to hold 1416 entries (1400 items + 16 categories), but only the
|
||||
// first 0x16C slots are used since spawn lists can't encode item IDs larger than that.
|
||||
u16 regular_item_weights[1416];
|
||||
// 0x29202: Spawn weights for Kecleon shop items. Same format as regular_item_weights.
|
||||
u16 kecleon_item_weights[1416];
|
||||
// 0x29D12: Spawn weights for monster house items. Same format as regular_item_weights.
|
||||
u16 monster_house_item_weights[1416];
|
||||
// 0x2A822: Spawn weights for buried items. Same format as regular_item_weights.
|
||||
u16 buried_item_weights[1416];
|
||||
// 0x2B332: Spawn weights for bazaar grab bag items. Same format as regular_item_weights.
|
||||
u16 grab_bag_item_weights[1416];
|
||||
// 0x2BE42: Spawn weights for secret room items in treasure boxes.
|
||||
// Same format as regular_item_weights? For some reason the weights for the secret rooms
|
||||
// are of a different length than the other item weight lists before it. The trap weights
|
||||
// appear to overlap what would be entries 1400-1415.
|
||||
u16 secret_room_item_weights[1400];
|
||||
// Spawn weights for items in different contexts.
|
||||
// 0 = regular, 1 = Kecleon shop, 2 = monster house, 3 buried,
|
||||
// 4 = bazaar, 5 = secret room
|
||||
struct item_spawn_weights item_spawn_weights[6];
|
||||
// 0x2C932: Spawn weights for traps.
|
||||
u16 trap_weights[25];
|
||||
// 0x2C964: List of spawn entries on this floor
|
||||
|
||||
@@ -837,7 +837,7 @@ struct monster_spawn_entry {
|
||||
u16 level_mult_512; // 0x0: Spawn level << 9
|
||||
// 0x2: Incremental spawn weights for this entry.
|
||||
// [0] = normal spawn weight, [1] = monster house spawn weight
|
||||
u16 incremental_spawn_weight[2];
|
||||
s16 incremental_spawn_weight[2];
|
||||
// 0x6: Monster id. Depending on where this struct is used, it can have values above 600
|
||||
// to list secondary gender entries.
|
||||
enum monster_id id;
|
||||
|
||||
@@ -3716,4 +3716,13 @@ enum dungeon_mode {
|
||||
DMODE_OPEN_AND_REQUEST = 3, // Dunegon is unlocked and cleared
|
||||
};
|
||||
|
||||
enum spawn_weight_type {
|
||||
SPAWN_REGULAR = 0,
|
||||
SPAWN_KECLEON_SHOP = 1,
|
||||
SPAWN_MONSTER_HOUSE = 2,
|
||||
SPAWN_BURIED = 3,
|
||||
SPAWN_BAZAAR = 4,
|
||||
SPAWN_SECRET_ROOM = 5,
|
||||
};
|
||||
|
||||
#endif //PMDSKY_ENUMS_H
|
||||
|
||||
@@ -1426,6 +1426,7 @@ enum item_category {
|
||||
CATEGORY_TREASURE_BOXES_2 = 13,
|
||||
CATEGORY_TREASURE_BOXES_3 = 14,
|
||||
CATEGORY_EXCLUSIVE_ITEMS = 15,
|
||||
CATEGORY_DUMMY = 16,
|
||||
};
|
||||
|
||||
enum item_flag {
|
||||
|
||||
11
include/spawn_1.h
Normal file
11
include/spawn_1.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef PMDSKY_SPAWN_1_H
|
||||
#define PMDSKY_SPAWN_1_H
|
||||
|
||||
s16 GetItemIdToSpawn(enum spawn_weight_type spawn_type);
|
||||
s32 GetRandomBazaarItem();
|
||||
s32 GetRandomSecretRoomItem();
|
||||
s32 CopySpawnEntriesMaster(struct monster_spawn_entry out[], s32 idx_out);
|
||||
s32 MonsterSpawnListPartialCopy(struct monster_spawn_entry entry_out[], s32 idx_out);
|
||||
void CopySpawnEntriesOnce();
|
||||
|
||||
#endif //PMDSKY_SPAWN_1_H
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef PMDSKY_SPAWN_H
|
||||
#define PMDSKY_SPAWN_H
|
||||
#ifndef PMDSKY_SPAWN_2_H
|
||||
#define PMDSKY_SPAWN_2_H
|
||||
|
||||
// Weight type index is 0 for normal spawns and 1 for monster house spawns.
|
||||
// Returns a monster ID.
|
||||
@@ -7,4 +7,4 @@ s32 GetMonsterIdToSpawn(s32 weight_type_idx);
|
||||
s32 GetMonsterLevelToSpawn(s32 monster_id);
|
||||
s32 IsOnMonsterSpawnList(s32 monster_id);
|
||||
|
||||
#endif //PMDSKY_SPAWN_H
|
||||
#endif //PMDSKY_SPAWN_2_H
|
||||
3
main.lsf
3
main.lsf
@@ -506,7 +506,8 @@ Overlay OVY_29
|
||||
Object asm/overlay_29_022E335C.o
|
||||
Object src/dg_effect.o
|
||||
Object asm/overlay_29_022E37DC.o
|
||||
Object src/spawn.o
|
||||
Object src/spawn_1.o
|
||||
Object src/spawn_2.o
|
||||
Object asm/overlay_29_022E7EC4.o
|
||||
Object src/position_util.o
|
||||
Object asm/overlay_29_rodata_02351628.o
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
// file starts at 0x022e26b68
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
bool8 EntityIsValid__022E32E8(struct entity *entity)
|
||||
{
|
||||
if (entity == NULL)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
// file starts at 0x022e9020
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
extern struct entity *LEADER_PTR;
|
||||
|
||||
struct entity* GetLeader()
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#define WATCHING_CAREFULLY_MESSAGE 0xDEE
|
||||
#endif
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
extern void EndFrozenClassStatus(struct entity *user, struct entity *target, bool8 log);
|
||||
extern void SubstitutePlaceholderStringTags(u8 *string_id, struct entity *entity, u32 param_3);
|
||||
extern void LogMessageByIdWithPopupCheckUser(struct entity *user, u32 message_id);
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
bool8 AI_CAN_ATTACK_IN_DIRECTION[NUM_DIRECTIONS] = {0};
|
||||
u8 AI_POTENTIAL_ATTACK_TARGET_DIRECTIONS[NUM_DIRECTIONS] = {0};
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
// AI_POTENTIAL_ATTACK_TARGET_WEIGHTS is defined twice within AiConsiderMove, so it needs two separate symbols in ASM until the function is matched.
|
||||
#ifdef NONMATCHING
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
|
||||
#define REGULAR_ATTACK_INDEX 4
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
// https://decomp.me/scratch/zg7V6
|
||||
#ifdef NONMATCHING
|
||||
void ChooseAiMove(struct entity *monster)
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
// This needs to be marked as non-volatile here to match GetPossibleAiThrownItemDirections,
|
||||
// but AiDecideUseItem needs it to be volatile to match.
|
||||
extern s32 AI_THROWN_ITEM_ACTION_CHOICE_COUNT;
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
void GetPossibleAiThrownItemDirections(struct entity *entity, s32 ally_or_enemy, struct item *item, bool8 always_add)
|
||||
{
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
#define TURN_RIGHT_90 4
|
||||
#define TURN_LEFT_135 5
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
struct can_move_in_direction_info
|
||||
{
|
||||
bool8 try_turn;
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#include "secondary_terrain_types.h"
|
||||
#include "targeting.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
bool8 CanMonsterMoveOrSwapWithAllyInAnyDirection(struct entity *monster)
|
||||
{
|
||||
for (u8 i = 0; i < NUM_DIRECTIONS; i++)
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
#define NUM_EFFECTIVENESS 4
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
s32 WeightWeakTypePicker(struct entity *user, struct entity *target, enum type_id move_type)
|
||||
{
|
||||
s32 weight = 1;
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "overlay_29_023000E4.h"
|
||||
#include "special_move_types.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
extern s32 GetMoveBasePower(struct move*);
|
||||
|
||||
bool8 CanSeeTeammate(struct entity *monster)
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "fixed_room_data_1.h"
|
||||
#include "util.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
bool8 IsMonsterLoneOutlaw(struct monster* monster_info)
|
||||
{
|
||||
return IsBehaviorLoneOutlaw(monster_info->monster_behavior);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "dungeon_map_access.h"
|
||||
#include "dungeon.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
extern struct tile DEFAULT_TILE_COPY;
|
||||
extern struct tile* DEFAULT_TILE;
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "secondary_terrain_types.h"
|
||||
#include "tileset.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
bool8 IsTileGround(struct tile *tile)
|
||||
{
|
||||
bool8 is_ground = FALSE;
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "progression.h"
|
||||
#include "pokemon.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
bool8 CanSeeInvisibleMonsters(struct entity *entity)
|
||||
{
|
||||
if (GetEntInfo(entity)->blinker_class_status.blinded == STATUS_BLINKER_EYEDROPS)
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#define CURVED_PROJECTILE_LOG_MESSAGE_3 0xbe3
|
||||
#endif
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
extern bool8 ov29_022E2CA0(struct position *pos);
|
||||
extern void ov29_0234B4CC(bool8 val);
|
||||
extern s32 SinAbs4096(s32 x);
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "dungeon_range_2.h"
|
||||
#include "main_0208655C.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
bool8 IsPositionActuallyInSight(struct position *origin, struct position *target, bool8 user_has_dropeye)
|
||||
{
|
||||
s16 visibility = GetVisibilityRange();
|
||||
|
||||
@@ -33,6 +33,7 @@ extern const s16 ROCK_HORN_RECRUIT_BOOST;
|
||||
extern const s16 GRASS_CORNET_RECRUIT_BOOST;
|
||||
extern const s16 SKY_MELODICA_RECRUIT_BOOST;
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
extern s16 RECRUITMENT_LEVEL_BOOST_TABLE[];
|
||||
|
||||
bool8 SpecificRecruitCheck(u32 monster_id)
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "dungeon.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
bool8 IsFullFloorFixedRoom()
|
||||
{
|
||||
u8 fixed_room_id = DUNGEON_PTR[0]->gen_info.fixed_room_id;
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#include "trap.h"
|
||||
#include "weather.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
extern bool8 GendersEqualNotGenderless(s16 monster1, s16 monster2);
|
||||
|
||||
// https://decomp.me/scratch/TnODN
|
||||
|
||||
@@ -11,6 +11,8 @@ void sub_020091B0(s32, s32);
|
||||
void StartFadeDungeonWrapper(s32, s32, s32);
|
||||
void ov29_0234C738(s32);
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
struct dungeon* DungeonAlloc(void)
|
||||
{
|
||||
#ifdef JAPAN
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "util.h"
|
||||
#include "main_02051760.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
bool8 EntityIsValid__022F7364(struct entity *entity)
|
||||
{
|
||||
if (entity == NULL)
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "util.h"
|
||||
#include "enums.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
bool32 FloorNumberIsEven() {
|
||||
struct dungeon *dungeon = DUNGEON_PTR[0];
|
||||
if (dungeon->id == DUNGEON_LABYRINTH_CAVE && dungeon->floor == 10) return 0;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "enums.h"
|
||||
#include "wan.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
extern struct wan_table *WAN_TABLE;
|
||||
extern s16 GetSpriteIndex__020526EC(s16 monster_id);
|
||||
extern s16 ReplaceWanFromBinFile(struct wan_table *wan_table, s16 wan_id, s16 pack_id, s16 file_index, bool8 compressed);
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "overlay_29_02336428.h"
|
||||
#include "position_util.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
bool8 ShouldMonsterHeadToStairs(struct entity *entity)
|
||||
{
|
||||
u8 stairs_room = GetStairsRoom();
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "overlay_29_022F7364.h"
|
||||
#include "targeting.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
extern u8 GetScenarioBalanceVeneer();
|
||||
extern u32 GetSpawnThreshold();
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "dungeon_util_static.h"
|
||||
#include "overlay_29_022F7364.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
struct entity* FindMonsterWithBehavior(enum monster_behavior monster_behavior)
|
||||
{
|
||||
for (s32 i = 0; i < DUNGEON_MAX_POKEMON; i++)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "overlay_29_023000E4.h"
|
||||
#include "dungeon_util_static.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
bool8 EntityIsValid__023000E4(struct entity *entity)
|
||||
{
|
||||
if (entity == NULL)
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "dungeon_pokemon_attributes.h"
|
||||
#include "dungeon_util_static.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
bool8 ScrappyShouldActivate(struct entity *attacker, struct entity *defender, enum type_id attack_type)
|
||||
{
|
||||
for (s16 i = 0; i < 2; i++)
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include "dungeon.h"
|
||||
#include "dungeon_map_access.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
u8 GetStairsRoom()
|
||||
{
|
||||
return GetTile(DUNGEON_PTR[0]->gen_info.stairs_pos.x, DUNGEON_PTR[0]->gen_info.stairs_pos.y)->room;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "main_0200330C.h"
|
||||
#include "overlay_29_02337CA8.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
extern void LogMessageByIdWithPopupCheckUser(struct entity *user, u32 message_id);
|
||||
extern void ov29_02306D54(struct entity *);
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "dungeon.h"
|
||||
#include "dungeon_mode.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
extern void TryRevealAttackedTrap(struct position* pos, int param1);
|
||||
extern bool32 PositionIsOnHiddenStairs(struct position* pos);
|
||||
extern void HiddenStairsTrigger(bool32 param0);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "dungeon.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
bool8 TeamMemberHasExclusiveItemEffectActive(u8);
|
||||
|
||||
bool8 ShouldBoostKecleonShopSpawnChance(void)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "dungeon.h"
|
||||
#include "fixed_room_data_1.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
extern u16 ov29_02352B5C[2];
|
||||
|
||||
void ov29_02344E88(s16 *param_1);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "dungeon.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
bool8 IsSecretBazaar()
|
||||
{
|
||||
return DUNGEON_PTR[0]->gen_info.fixed_room_id==FIXED_SECRET_BAZAAR;
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "weather.h"
|
||||
#include "main_02001188.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
extern const u8 DUNGEON_MENU_SWITCH_STR1[];// = "[dungeon:0]";
|
||||
|
||||
extern struct struct_1* OVERLAY31_UNKNOWN_POINTER__NA_238A260[2];
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "dungeon_map_access.h"
|
||||
#include "overlay_29_022E1610.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
extern struct loc_struct* OVERLAY31_UNKNOWN_POINTER__NA_238A26C;
|
||||
extern struct bag_items* BAG_ITEMS_PTR_MIRROR;
|
||||
extern u32 OVERLAY31_UNKNOWN_STRUCT__NA_2389EF0;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "overlay_31_02383478.h"
|
||||
#include "main_02001188.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
extern struct loc_struct* OVERLAY31_UNKNOWN_POINTER__NA_238A26C;
|
||||
|
||||
extern u8 PositionHasItem(struct position* pos);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include "dungeon.h"
|
||||
#include "overlay_10_022C2574.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
bool8 IsCurrentTilesetBackground()
|
||||
{
|
||||
return IsBackgroundTileset(DUNGEON_PTR[0]->gen_info.tileset_id);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include "dungeon.h"
|
||||
#include "enums.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
bool8 IsBossFight(enum fixed_room_id fixed_room_id)
|
||||
{
|
||||
if (fixed_room_id != FIXED_NONE && fixed_room_id < FIXED_ZERO_ISLE_NORTH)
|
||||
|
||||
112
src/spawn_1.c
Normal file
112
src/spawn_1.c
Normal file
@@ -0,0 +1,112 @@
|
||||
#include "dg_random.h"
|
||||
#include "dungeon.h"
|
||||
#include "enums.h"
|
||||
#include "item.h"
|
||||
#include "item_util.h"
|
||||
#include "spawn_1.h"
|
||||
|
||||
extern s32 CopySpawnEntriesMaster(struct monster_spawn_entry[], s32);
|
||||
extern s32 GetMonsterIdFromSpawnEntry(struct monster_spawn_entry*);
|
||||
extern u32 GetSpriteSize(s32);
|
||||
extern struct dungeon *DUNGEON_PTR;
|
||||
|
||||
s16 GetItemIdToSpawn(enum spawn_weight_type spawn_type) {
|
||||
s32 idx;
|
||||
s32 rnd = DungeonRandInt(10000);
|
||||
enum item_category category = CATEGORY_DUMMY;
|
||||
for(idx = 0; idx < 16; idx++) {
|
||||
s16 threshold = DUNGEON_PTR->item_spawn_weights[spawn_type].category_threshold[idx];
|
||||
if(threshold == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(threshold >= rnd) {
|
||||
category = (enum item_category)idx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(category == CATEGORY_DUMMY) {
|
||||
return ITEM_POKE;
|
||||
}
|
||||
|
||||
rnd = DungeonRandInt(10000);
|
||||
for(idx = 0; idx < 0x16c; idx++) {
|
||||
s16 threshold = DUNGEON_PTR->item_spawn_weights[spawn_type].item_threshold[idx];
|
||||
if(threshold == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(category != GetItemCategoryVeneer(idx)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
threshold = DUNGEON_PTR->item_spawn_weights[spawn_type].item_threshold[idx];
|
||||
if(threshold >= rnd) {
|
||||
return idx;
|
||||
}
|
||||
}
|
||||
|
||||
return ITEM_POKE;
|
||||
}
|
||||
|
||||
s32 GetRandomBazaarItem() {
|
||||
s32 item_id = GetItemIdToSpawn(SPAWN_BAZAAR);
|
||||
if(item_id == ITEM_POKE) {
|
||||
return ITEM_ORAN_BERRY;
|
||||
}
|
||||
return item_id;
|
||||
}
|
||||
|
||||
s32 GetRandomSecretRoomItem() {
|
||||
s32 item_id = GetItemIdToSpawn(SPAWN_SECRET_ROOM);
|
||||
if(item_id == ITEM_POKE) {
|
||||
return ITEM_ORAN_BERRY;
|
||||
}
|
||||
return item_id;
|
||||
}
|
||||
|
||||
s32 CopySpawnEntriesMaster(struct monster_spawn_entry out[], s32 idx_out) {
|
||||
for(s32 i = 0; i < 16; i++) {
|
||||
s32 monster_id = GetMonsterIdFromSpawnEntry(&(DUNGEON_PTR->spawn_entries_master[i]));
|
||||
if(monster_id == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
out[idx_out] = DUNGEON_PTR->spawn_entries_master[i];
|
||||
idx_out++;
|
||||
}
|
||||
|
||||
return idx_out;
|
||||
}
|
||||
|
||||
s32 MonsterSpawnListPartialCopy(struct monster_spawn_entry entry_out[], s32 idx_out) {
|
||||
for(s32 i = 0; i < 16; i++) {
|
||||
s32 monster_id = GetMonsterIdFromSpawnEntry(&(DUNGEON_PTR->spawn_entries_master[i]));
|
||||
if(monster_id == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(GetSpriteSize(monster_id) > 6) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(DUNGEON_PTR->spawn_entries_master[i].incremental_spawn_weight[0] == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
entry_out[idx_out] = DUNGEON_PTR->spawn_entries_master[i];
|
||||
idx_out++;
|
||||
}
|
||||
return idx_out;
|
||||
}
|
||||
|
||||
void CopySpawnEntriesOnce() {
|
||||
if (DUNGEON_PTR->spawn_entries_copied != FALSE) {
|
||||
return;
|
||||
}
|
||||
|
||||
DUNGEON_PTR->spawn_entries_copied = 1;
|
||||
DUNGEON_PTR->monster_spawn_entries_length =
|
||||
CopySpawnEntriesMaster(DUNGEON_PTR->spawn_entries, 0);
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "dg_random.h"
|
||||
#include "dungeon.h"
|
||||
#include "overlay_29_022F73B4.h"
|
||||
#include "spawn.h"
|
||||
#include "spawn_2.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
extern s32 GetMonsterIdFromSpawnEntry(struct monster_spawn_entry *);
|
||||
extern s32 GetMonsterLevelFromSpawnEntry(struct monster_spawn_entry *);
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "dungeon_items.h"
|
||||
#include "dungeon_pokemon_attributes.h"
|
||||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
enum weather_id GetApparentWeather(struct entity *entity)
|
||||
{
|
||||
if (entity != NULL)
|
||||
|
||||
Reference in New Issue
Block a user