More enemy

This commit is contained in:
robojumper
2025-06-27 09:32:52 +02:00
parent b522045f0e
commit e1f7e2ac58
17 changed files with 1061 additions and 831 deletions
+4
View File
@@ -19,6 +19,10 @@ public:
void shutdown() {
mSound.Shutdown();
}
void setField_0x98(f32 value) {
field_0x98 = value;
}
private:
static void animCallback(int, s32, const char *, UNKWORD, void *userData);
+3 -4
View File
@@ -15,7 +15,6 @@
/** Size: probably 0x15C */
class dSoundSource_c : public dSoundSourceIf_c, public dSnd3DActor_c {
public:
static dSoundSource_c *create(u32 id, dAcBase_c *actor, const char *name, u8 subtype);
dSoundSource_c(u8 sourceType, dAcBase_c *, const char *name, dSndSourceGroup_c *pOwnerGroup);
virtual ~dSoundSource_c();
@@ -54,7 +53,7 @@ public:
/* 0x198 */ virtual void postStartSound(nw4r::snd::SoundHandle &handle, dSndSeSound_c *pSound, u32 id) override;
/* 0x19C */ virtual u32 overrideHitObjSoundId(u32 soundId, dSoundSource_c *source);
/* 0x1A0 */ virtual u32 d_s_vt_0x1A0(u32 soundId, UNKWORD);
/* 0x1A0 */ virtual u32 overrideHoldSoundId(u32 soundId, bool initial);
/* 0x1A4 */ virtual void
postHoldSound(nw4r::snd::SoundHandle &handle, dSndSeSound_c *pSound, u32 id, UNKWORD) override;
@@ -201,8 +200,8 @@ public:
/* 0x10C */ virtual void setRate(f32 frame) override {}
/* 0x110 */ virtual void setPolyAttrs(u8 polyAttr0, u8 polyAttr1) override;
/* 0x114 */ virtual void setBattleBgmRelated(UNKWORD) override {}
/* 0x118 */ virtual bool checkBattleBgmRelated() override {
return false;
/* 0x118 */ virtual UNKWORD checkBattleBgmRelated() override {
return 0;
}
dSndSeSound2_c *getHandleType2ForSoundId(u32 soundId);
+81
View File
@@ -0,0 +1,81 @@
#ifndef D_SND_SOURCE_ENEMY_H
#define D_SND_SOURCE_ENEMY_H
#include "d/snd/d_snd_anim_sound.h"
#include "d/snd/d_snd_source.h"
#include "nw4r/ut/ut_list.h"
class dSndSourceEnemy_c : public dSoundSource_c {
public:
dSndSourceEnemy_c(u8 sourceType, dAcBase_c *ac, const char *name, dSndSourceGroup_c *pOwnerGroup);
virtual ~dSndSourceEnemy_c();
/* 0x020 */ virtual void vt_0x020() override;
/* 0x044 */ virtual void shutdown() override;
/* 0x114 */ virtual void setBattleBgmRelated(UNKWORD arg) override {
field_0x164 = arg;
}
/* 0x118 */ virtual UNKWORD checkBattleBgmRelated() override;
/* 0x188 */ virtual void postSetup() override;
/* 0x194 */ virtual u32 overrideStartSoundId(u32 soundId) override;
/* 0x1A0 */ virtual u32 overrideHoldSoundId(u32 soundId, bool initial) override;
/* 0x1CC */ virtual void postSetupSound(u32 playingId, u32 requestedId, dSndSeSound_c *seSound) override;
/* 0x1E8 */ virtual u32 d_s_vt_0x1E8(u32 soundId) override {
return specializeBgHitSoundId(soundId, mPolyAttr0, mPolyAttr1);
}
private:
// Probably not a problem for weak function order since getName is emitted
// earlier through an explicit call
bool isName(const char *name) const {
return streq(name, getName());
}
void unregisterEnemySource();
/* 0x15C */ nw4r::ut::Node mMgrEnemyLink;
/* 0x164 */ UNKWORD field_0x164;
/* 0x168 */ u8 field_0x168;
/* 0x169 */ u8 field_0x169;
/* 0x16A */ bool mIsRegisteredEnemy;
};
class dSndSourceEnemyAnimBase_c : public dSndSourceEnemy_c {
public:
dSndSourceEnemyAnimBase_c(u8 sourceType, dAcBase_c *ac, const char *name, dSndSourceGroup_c *pOwnerGroup)
: dSndSourceEnemy_c(sourceType, ac, name, pOwnerGroup), mAnimSound(this) {}
/* 0x1A8 */ virtual StartResult
SetupSound(nw4r::snd::SoundHandle *pHandle, u32 soundId, const StartInfo *pStartInfo, void *arg) override {
return setupSoundCommon(pHandle, soundId, pStartInfo, arg);
}
/* 0x1D4 */ virtual dSndAnimSound_c *getAnimSound() override {
return &mAnimSound;
}
/* 0x100 */ virtual bool hasAnimSound() override {
return true;
}
/* 0x104 */ virtual void load(void *data, const char *name) override {
mAnimSound.setData(data, name);
}
/* 0x108 */ virtual void setFrame(f32 frame) override {
if (isInaudibleInternal()) {
mAnimSound.resetFrame(frame);
} else {
mAnimSound.setFrame(frame);
}
}
/* 0x10C */ virtual void setRate(f32 frame) override {
mAnimSound.setRate(frame);
}
private:
/* 0x16C */ dSndAnimSound_c mAnimSound;
};
#endif
+7 -3
View File
@@ -19,10 +19,14 @@ enum SoundSourceType_e {
// 10-31: Enemy? (2)
SND_SOURCE_ENEMY_10 = 10,
SND_SOURCE_LIZARUFOS = 13,
SND_SOURCE_BC_Z = 16,
SND_SOURCE_SPARK = 17,
SND_SOURCE_BIGBOSS = 20,
SND_SOURCE_GIRAHUMU_3 = 24,
SND_SOURCE_ENEMY_28 = 28,
SND_SOURCE_BULLET = 29,
SND_SOURCE_BULLET_MAGUPPO = 30,
SND_SOURCE_ENEMY_31 = 31,
// 32-42: Object? (3)
@@ -41,7 +45,7 @@ enum SoundSourceType_e {
SND_SOURCE_NPC_43 = 43,
SND_SOURCE_KENSEI = 44,
SND_SOURCE_PLAYER_BIRD = 45,
SND_SOURCE_NPC_48 = 48,
SND_SOURCE_NPC_HEAD = 48,
SND_SOURCE_INSECT = 49,
SND_SOURCE_NPC_NRM = 51,
SND_SOURCE_NPC_DRAGON = 52,
@@ -53,7 +57,7 @@ enum SoundSourceType_e {
SND_SOURCE_54 = 54,
SND_SOURCE_OBJECT_WARP = 55,
SND_SOURCE_SW_HARP = 56,
SND_SOURCE_57 = 57,
SND_SOURCE_TG_HARP = 57,
// 58: ? (7)
SND_SOURCE_58 = 58,
@@ -72,7 +76,7 @@ enum SoundSourceCategory_e {
SND_SOURCE_CATEGORY_OBJECT = 3,
SND_SOURCE_CATEGORY_NPC = 4,
SND_SOURCE_CATEGORY_TG_SOUND = 5,
SND_SOURCE_CATEGORY_6 = 6,
SND_SOURCE_CATEGORY_HARP_RELATED = 6,
SND_SOURCE_CATEGORY_7 = 7,
SND_SOURCE_CATEGORY_9 = 9,
};
+3 -1
View File
@@ -27,6 +27,8 @@ struct dSndSoundCtxParam {
/** An abstract interface for sound relating to a particular actor. */
class dSoundSourceIf_c {
public:
static dSoundSourceIf_c *create(u32 id, dAcBase_c *actor, const char *name, u8 subtype);
virtual ~dSoundSourceIf_c() {}
/* 0x00C */ virtual void setup() = 0;
@@ -100,7 +102,7 @@ public:
/* 0x10C */ virtual void setRate(f32 frame) = 0;
/* 0x110 */ virtual void setPolyAttrs(u8 polyAttr0, u8 polyAttr1) = 0;
/* 0x114 */ virtual void setBattleBgmRelated(UNKWORD) = 0;
/* 0x118 */ virtual bool checkBattleBgmRelated() = 0;
/* 0x118 */ virtual UNKWORD checkBattleBgmRelated() = 0;
};
#endif
+14 -3
View File
@@ -22,9 +22,13 @@ public:
void unregisterSource(dSoundSource_c *source);
void onShutdownSource(dSoundSource_c *source);
// Only for sources 10, 11, 12, 13, 14
void registerUnkEnemyType(dSndSourceEnemy_c *);
void playFlowSound(u32 id);
static s32 getSourceCategoryForSourceType(s32 sourceType, const char *name);
static bool isSwOrEOc(const char *name);
s32 getPlayerSourceRoomId() const;
static dSoundSource_c *getPlayerSource() {
return GetInstance()->mpPlayerSource;
@@ -45,12 +49,19 @@ public:
void stopAllSound();
void stopAllNonPlayerSound();
void incrementEnemyCount() {
field_0x3868++;
}
void decrementEnemyCount() {
field_0x3868--;
}
private:
static bool isCertainEnemyType(dSoundSource_c *source);
void removeSourceFromList(dSoundSource_c *source, nw4r::ut::List *list);
void clearSourceLists();
void clearSourceList(nw4r::ut::List *list);
s32 getPlayerSourceRoomId() const;
/* 0x0010 */ u8 field_0x0010;
/* 0x0011 */ u8 field_0x0011;
@@ -64,8 +75,8 @@ private:
/* 0x003C */ dSndSourceGroup_c mGroups[NUM_GROUPS];
// Not sure what these are for
/* 0x383C */ nw4r::ut::List mAllSources; // node offset 0xE8, probably into dSoundSource::mMgrLink
/* 0x3848 */ nw4r::ut::List field_0x3848; // node offset 0x15C, possibly a subset of source types
/* 0x383C */ nw4r::ut::List mAllSources; // node offset 0xE8, -> dSoundSource::mMgrLink
/* 0x3848 */ nw4r::ut::List field_0x3848; // node offset 0x15C, -> dSndSourceEnemy_c::mMgrEnemyLink
/* 0x3854 */ nw4r::ut::List field_0x3854; // node offset 0x160
/* 0x3860 */ UNKWORD field_0x3860;
+2
View File
@@ -19,6 +19,8 @@ public:
}
private:
// Probably not a problem for weak function order since getName is emitted
// earlier through an explicit call
bool isName(const char *name) const {
return streq(name, getName());
}
+2
View File
@@ -8,6 +8,8 @@ class dSoundSource_c;
class dSndSourceGroup_c;
class dSndDistantSoundActor_c;
class dSndSourceEnemy_c;
class dSndSound_c;
class dSndSoundCtxParam;