mirror of
https://github.com/pret/pmd-sky.git
synced 2026-08-20 01:25:24 -05:00
Merge pull request #257 from slaw-22/spawn-1
Some checks are pending
build / build (push) Waiting to run
Some checks are pending
build / build (push) Waiting to run
Decomp GetMonsterIdToSpawn and GetMonsterLevelToSpawn
This commit is contained in:
@@ -6,15 +6,10 @@
|
||||
.public ChangeMonsterAnimation
|
||||
.public CheckActiveChallengeRequest
|
||||
.public CheckSpawnThreshold
|
||||
.public CloseTextBox2
|
||||
.public CreateTextBox
|
||||
.public DIRECTIONS_XY
|
||||
.public DisplayAnimatedNumbers
|
||||
.public DrawTextInWindow
|
||||
.public DUNGEON_FRAMES_PASSED
|
||||
.public DUNGEON_PTR
|
||||
.public DisplayAnimatedNumbers
|
||||
.public DungeonFloorToGroupFloor
|
||||
.public DungeonGetSpriteIndex
|
||||
.public DungeonGetTotalSpriteFileSize
|
||||
.public DungeonGoesUp
|
||||
.public DungeonRandInt
|
||||
@@ -24,9 +19,7 @@
|
||||
.public FloorNumberIsEven
|
||||
.public GetEffectAnimationField0x19
|
||||
.public GetFloorType
|
||||
.public GetIdleAnimationId
|
||||
.public GetItemCategoryVeneer
|
||||
.public GetKecleonIdToSpawnByFloor
|
||||
.public GetLeader
|
||||
.public GetMonsterGenderVeneer
|
||||
.public GetMonsterIdFromSpawnEntry
|
||||
@@ -34,13 +27,10 @@
|
||||
.public GetNbFloorsPlusOne
|
||||
.public GetNbPrecedingFloors
|
||||
.public GetNbRecruited
|
||||
.public GetPlayerGender
|
||||
.public GetSecondFormIfValid
|
||||
.public GetSpriteFileSize
|
||||
.public GetSpriteSize
|
||||
.public GetTopScreenOption
|
||||
.public HandleSir0Translation
|
||||
.public InitPreprocessorArgs
|
||||
.public IsBossFight
|
||||
.public IsCurrentFixedRoomBossFight
|
||||
.public IsCurrentMissionType
|
||||
@@ -50,88 +40,16 @@
|
||||
.public IsFullFloorFixedRoom
|
||||
.public IsInSpawnList
|
||||
.public IsItemForSpecialSpawnInBag
|
||||
.public IsTeamStatsOnTopScreen
|
||||
.public LoadFileFromRom
|
||||
.public LoadFixedRoom
|
||||
.public LogMessageByIdWithPopup
|
||||
.public MemAlloc
|
||||
.public MemFree
|
||||
.public MemZero
|
||||
.public MonsterIsType
|
||||
.public NeedsItemToSpawn
|
||||
.public ov10_022BDC68
|
||||
.public ov10_022BDE50
|
||||
.public ov10_022BEC08
|
||||
.public ov10_022BEC94
|
||||
.public ov10_022BEFD8
|
||||
.public ov10_022BF274
|
||||
.public ov10_022BF2B4
|
||||
.public ov10_022BF45C
|
||||
.public ov10_022BF9CC
|
||||
.public ov10_022BFB6C
|
||||
.public ov10_022C1DE0
|
||||
.public ov10_022C1E50
|
||||
.public ov10_022C1E80
|
||||
.public ov10_022C21D8
|
||||
.public ov10_022C2278
|
||||
.public ov10_022C22A0
|
||||
.public ov29_022DC684
|
||||
.public ov29_022DC694
|
||||
.public ov29_022DC6D0
|
||||
.public ov29_022DC6DC
|
||||
.public ov29_022DC6E8
|
||||
.public ov29_022DC728
|
||||
.public ov29_022DC738
|
||||
.public ov29_022DC76C
|
||||
.public ov29_022DC778
|
||||
.public ov29_022DC77C
|
||||
.public ov29_022DE5D8
|
||||
.public ov29_022DE5F0
|
||||
.public ov29_022E2CA0
|
||||
.public ov29_022EA370
|
||||
.public ov29_022EACE4
|
||||
.public ov29_022ED0F4
|
||||
.public ov29_0230027C
|
||||
.public ov29_0230D618
|
||||
.public ov29_02339138
|
||||
.public ov29_02339148
|
||||
.public ov29_02339D7C
|
||||
.public ov29_0233A0E8
|
||||
.public ov29_0233A1BC
|
||||
.public ov29_02349378
|
||||
.public ov29_0234B1A4
|
||||
.public ov29_0234B4E0
|
||||
.public ov29_0234C70C
|
||||
.public ov29_0234F25C
|
||||
.public ov29_0234F278
|
||||
.public ov29_0234F290
|
||||
.public ov29_0234F2B8
|
||||
.public ov29_0235118C
|
||||
.public ov29_02351194
|
||||
.public ov29_0235119C
|
||||
.public ov29_023511A4
|
||||
.public ov29_023511B0
|
||||
.public ov29_023511DC
|
||||
.public ov29_0235122C
|
||||
.public ov29_0235124C
|
||||
.public ov29_02351464
|
||||
.public ov29_02351584
|
||||
.public ov29_02351594
|
||||
.public ov29_023515B0
|
||||
.public ov29_023515CC
|
||||
.public ov29_023515E8
|
||||
.public ov29_023515F4
|
||||
.public ov29_0235352C
|
||||
.public ov29_0235354C
|
||||
.public ov29_02353558
|
||||
.public PlayEffectAnimationEntity
|
||||
.public PlaySeByIdIfNotSilence
|
||||
.public RandIntSafe
|
||||
.public SetMinimapDataE447
|
||||
.public SetMinimapDataE448
|
||||
.public SetMonsterId
|
||||
.public ShouldDisplayEntityWrapper
|
||||
.public StartFadeDungeonWrapper
|
||||
.public STATUS_ICON_ARRAY_BIDE
|
||||
.public STATUS_ICON_ARRAY_BLINDED
|
||||
.public STATUS_ICON_ARRAY_BURN
|
||||
@@ -147,18 +65,44 @@
|
||||
.public STATUS_ICON_ARRAY_REFLECT
|
||||
.public STATUS_ICON_ARRAY_SLEEP
|
||||
.public STATUS_ICON_ARRAY_SURE_SHOT
|
||||
.public StringFromId
|
||||
.public sub_0200B330
|
||||
.public sub_0200B3D4
|
||||
.public SetMonsterId
|
||||
.public ShouldDisplayEntityWrapper
|
||||
.public SubstitutePlaceholderStringTags
|
||||
.public UnloadFile
|
||||
.public ov10_022BDC68
|
||||
.public ov10_022BDE50
|
||||
.public ov10_022BEC08
|
||||
.public ov10_022BEC94
|
||||
.public ov10_022BEFD8
|
||||
.public ov10_022BF274
|
||||
.public ov10_022BF2B4
|
||||
.public ov10_022BF45C
|
||||
.public ov10_022BF9CC
|
||||
.public ov10_022BFB6C
|
||||
.public ov29_022DE5D8
|
||||
.public ov29_022DE5F0
|
||||
.public ov29_022E2CA0
|
||||
.public ov29_022EA370
|
||||
.public ov29_022EACE4
|
||||
.public ov29_022ED0F4
|
||||
.public ov29_0230D618
|
||||
.public ov29_02339148
|
||||
.public ov29_02349378
|
||||
.public ov29_0234B1A4
|
||||
.public ov29_0235118C
|
||||
.public ov29_02351194
|
||||
.public ov29_0235119C
|
||||
.public ov29_023511A4
|
||||
.public ov29_023511B0
|
||||
.public ov29_023511DC
|
||||
.public ov29_0235122C
|
||||
.public ov29_0235124C
|
||||
.public ov29_02351464
|
||||
.public ov29_02351584
|
||||
.public ov29_02351594
|
||||
.public ov29_023515B0
|
||||
.public ov29_023515CC
|
||||
.public ov29_0235354C
|
||||
.public sub_0201C000
|
||||
.public sub_0201CF90
|
||||
.public sub_0201D034
|
||||
.public sub_02048384
|
||||
.public sub_020483B8
|
||||
.public sub_020483D8
|
||||
.public sub_02048400
|
||||
.public SubstitutePlaceholderStringTags
|
||||
.public TOP_SCREEN_STATUS_PTR
|
||||
.public UnloadFile
|
||||
.public UpdateMinimap
|
||||
.public UpdateWindow
|
||||
|
||||
59
asm/include/overlay_29_022E7EC4.inc
Normal file
59
asm/include/overlay_29_022E7EC4.inc
Normal file
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
.public CloseTextBox2
|
||||
.public CreateTextBox
|
||||
.public DUNGEON_FRAMES_PASSED
|
||||
.public DUNGEON_PTR
|
||||
.public DrawTextInWindow
|
||||
.public DungeonGetSpriteIndex
|
||||
.public GetIdleAnimationId
|
||||
.public GetPlayerGender
|
||||
.public GetTopScreenOption
|
||||
.public InitPreprocessorArgs
|
||||
.public IsTeamStatsOnTopScreen
|
||||
.public MemAlloc
|
||||
.public MemFree
|
||||
.public MemZero
|
||||
.public SetMinimapDataE447
|
||||
.public SetMinimapDataE448
|
||||
.public StartFadeDungeonWrapper
|
||||
.public StringFromId
|
||||
.public TOP_SCREEN_STATUS_PTR
|
||||
.public UpdateMinimap
|
||||
.public UpdateWindow
|
||||
.public ov10_022C1DE0
|
||||
.public ov10_022C1E50
|
||||
.public ov10_022C1E80
|
||||
.public ov10_022C21D8
|
||||
.public ov10_022C2278
|
||||
.public ov10_022C22A0
|
||||
.public ov29_022DC684
|
||||
.public ov29_022DC694
|
||||
.public ov29_022DC6D0
|
||||
.public ov29_022DC6DC
|
||||
.public ov29_022DC6E8
|
||||
.public ov29_022DC728
|
||||
.public ov29_022DC738
|
||||
.public ov29_022DC76C
|
||||
.public ov29_022DC778
|
||||
.public ov29_022DC77C
|
||||
.public ov29_0230027C
|
||||
.public ov29_02339138
|
||||
.public ov29_02339D7C
|
||||
.public ov29_0233A0E8
|
||||
.public ov29_0233A1BC
|
||||
.public ov29_0234B4E0
|
||||
.public ov29_0234C70C
|
||||
.public ov29_0234F25C
|
||||
.public ov29_0234F278
|
||||
.public ov29_0234F290
|
||||
.public ov29_0234F2B8
|
||||
.public ov29_023515E8
|
||||
.public ov29_023515F4
|
||||
.public ov29_0235352C
|
||||
.public ov29_02353558
|
||||
.public sub_0200B330
|
||||
.public sub_0200B3D4
|
||||
.public sub_02048384
|
||||
.public sub_020483B8
|
||||
.public sub_020483D8
|
||||
.public sub_02048400
|
||||
File diff suppressed because it is too large
Load Diff
1454
asm/overlay_29_022E7EC4.s
Normal file
1454
asm/overlay_29_022E7EC4.s
Normal file
File diff suppressed because it is too large
Load Diff
@@ -835,10 +835,9 @@ struct mission_destination_info {
|
||||
// Contains data about a monster that spawns in a dungeon
|
||||
struct monster_spawn_entry {
|
||||
u16 level_mult_512; // 0x0: Spawn level << 9
|
||||
// 0x2: Incremental spawn weight of this entry for normal spawns
|
||||
u16 incremental_spawn_weight;
|
||||
// 0x4: Incremental spawn weight of this entry for monster house spawns
|
||||
u16 incremental_spawn_weight_monster_house;
|
||||
// 0x2: Incremental spawn weights for this entry.
|
||||
// [0] = normal spawn weight, [1] = monster house spawn weight
|
||||
u16 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;
|
||||
|
||||
9
include/spawn.h
Normal file
9
include/spawn.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef PMDSKY_SPAWN_H
|
||||
#define PMDSKY_SPAWN_H
|
||||
|
||||
// Weight type index is 0 for normal spawns and 1 for monster house spawns.
|
||||
// Returns a monster ID.
|
||||
s32 GetMonsterIdToSpawn(s32 weight_type_idx);
|
||||
s32 GetMonsterLevelToSpawn(s32 monster_id);
|
||||
|
||||
#endif //PMDSKY_SPAWN_H
|
||||
2
main.lsf
2
main.lsf
@@ -453,6 +453,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 asm/overlay_29_022E7EC4.o
|
||||
Object src/position_util.o
|
||||
Object asm/overlay_29_rodata_02351628.o
|
||||
Object src/dungeon_range.o
|
||||
|
||||
42
src/spawn.c
Normal file
42
src/spawn.c
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "dg_random.h"
|
||||
#include "dungeon.h"
|
||||
#include "overlay_29_022F73B4.h"
|
||||
#include "spawn.h"
|
||||
|
||||
extern s32 GetMonsterIdFromSpawnEntry(struct monster_spawn_entry *);
|
||||
extern s32 GetMonsterLevelFromSpawnEntry(struct monster_spawn_entry *);
|
||||
|
||||
s32 GetMonsterIdToSpawn(s32 weight_type_idx)
|
||||
{
|
||||
s32 rand = DungeonRandInt(10000);
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < DUNGEON_PTR[0]->monster_spawn_entries_length; i++) {
|
||||
s16 threshold = DUNGEON_PTR[0]->spawn_entries[i].incremental_spawn_weight[weight_type_idx];
|
||||
if (threshold != 0 && threshold >= rand) {
|
||||
return GetMonsterIdFromSpawnEntry(
|
||||
(struct monster_spawn_entry *) &DUNGEON_PTR[0]->spawn_entries[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < DUNGEON_PTR[0]->monster_spawn_entries_length; i++) {
|
||||
s16 threshold = DUNGEON_PTR[0]->spawn_entries[i].incremental_spawn_weight[weight_type_idx];
|
||||
if (threshold != 0) {
|
||||
return GetMonsterIdFromSpawnEntry(
|
||||
(struct monster_spawn_entry *) &DUNGEON_PTR[0]->spawn_entries[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return GetKecleonIdToSpawnByFloor();
|
||||
}
|
||||
|
||||
s32 GetMonsterLevelToSpawn(s32 monster_id) {
|
||||
for(s32 i = 0; i < DUNGEON_PTR[0]->monster_spawn_entries_length; i++) {
|
||||
s32 entry_mon_id = GetMonsterIdFromSpawnEntry(&DUNGEON_PTR[0]->spawn_entries[i]);
|
||||
if(monster_id == entry_mon_id) {
|
||||
return GetMonsterLevelFromSpawnEntry(&DUNGEON_PTR[0]->spawn_entries[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
Reference in New Issue
Block a user