mirror of
https://github.com/zeldaret/oot.git
synced 2025-08-08 15:30:14 +00:00
EnEncount1 (#457)
* Darkmeiro decompilation Bg_Gnd_Darkmeiro decompiled, matched, and documented. * give this a shot * fix conflict * one more try * could be useful * whoops * Leevers and Tektites and Wolfos, ohmy! * changes and cleanup * the need for speed
This commit is contained in:
parent
0b9b2edf1b
commit
930cee3061
12 changed files with 421 additions and 1202 deletions
|
@ -1,4 +1,5 @@
|
|||
#include "z_en_encount1.h"
|
||||
#include "vt.h"
|
||||
|
||||
#define FLAGS 0x08000010
|
||||
|
||||
|
@ -7,7 +8,13 @@
|
|||
void EnEncount1_Init(Actor* thisx, GlobalContext* globalCtx);
|
||||
void EnEncount1_Update(Actor* thisx, GlobalContext* globalCtx);
|
||||
|
||||
/*
|
||||
void EnEncount1_SpawnLeevers(EnEncount1* this, GlobalContext* globalCtx);
|
||||
void EnEncount1_SpawnTektites(EnEncount1* this, GlobalContext* globalCtx);
|
||||
void EnEncount1_SpawnStalchildOrWolfos(EnEncount1* this, GlobalContext* globalCtx);
|
||||
|
||||
s16 sLeeverAngles[] = { 0x0000, 0x2710, 0x7148, 0x8EB8, 0xD8F0 };
|
||||
f32 sLeeverDists[] = { 200.0f, 170.0f, 120.0f, 120.0f, 170.0f };
|
||||
|
||||
const ActorInit En_Encount1_InitVars = {
|
||||
ACTOR_EN_ENCOUNT1,
|
||||
ACTORTYPE_PROP,
|
||||
|
@ -19,13 +26,313 @@ const ActorInit En_Encount1_InitVars = {
|
|||
(ActorFunc)EnEncount1_Update,
|
||||
NULL,
|
||||
};
|
||||
*/
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Encount1/EnEncount1_Init.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Encount1/func_80A0693C.s")
|
||||
void EnEncount1_Init(Actor* thisx, GlobalContext* globalCtx) {
|
||||
s32 pad;
|
||||
EnEncount1* this = THIS;
|
||||
f32 spawnRange;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Encount1/func_80A06CD0.s")
|
||||
if (this->actor.params <= 0) {
|
||||
osSyncPrintf("\n\n");
|
||||
// Input error death!
|
||||
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 入力エラーデッス! ☆☆☆☆☆ \n" VT_RST);
|
||||
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 入力エラーデッス! ☆☆☆☆☆ \n" VT_RST);
|
||||
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 入力エラーデッス! ☆☆☆☆☆ \n" VT_RST);
|
||||
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 入力エラーデッス! ☆☆☆☆☆ \n" VT_RST);
|
||||
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 入力エラーデッス! ☆☆☆☆☆ \n" VT_RST);
|
||||
osSyncPrintf("\n\n");
|
||||
Actor_Kill(&this->actor);
|
||||
return;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Encount1/func_80A06E88.s")
|
||||
this->spawnType = (this->actor.params >> 0xB) & 0x1F;
|
||||
this->maxCurSpawns = (this->actor.params >> 6) & 0x1F;
|
||||
this->maxTotalSpawns = this->actor.params & 0x3F;
|
||||
this->curNumSpawn = this->totalNumSpawn = 0;
|
||||
spawnRange = 120.0f + (40.0f * this->actor.posRot.rot.z);
|
||||
this->spawnRange = spawnRange;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Encount1/EnEncount1_Update.s")
|
||||
osSyncPrintf("\n\n");
|
||||
// It's an enemy spawner!
|
||||
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 敵発生ゾーンでた! ☆☆☆☆☆ %x\n" VT_RST, this->actor.params);
|
||||
// Type
|
||||
osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 種類\t\t ☆☆☆☆☆ %d\n" VT_RST, this->spawnType);
|
||||
// Maximum number of simultaneous spawns
|
||||
osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 最大同時発生数 ☆☆☆☆☆ %d\n" VT_RST, this->maxCurSpawns);
|
||||
// Maximum number of spawns
|
||||
osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 最大発生数 \t ☆☆☆☆☆ %d\n" VT_RST, this->maxTotalSpawns);
|
||||
// Spawn check range
|
||||
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発生チェック範囲 ☆☆☆☆☆ %f\n" VT_RST, this->spawnRange);
|
||||
osSyncPrintf("\n\n");
|
||||
|
||||
this->actor.flags &= ~1;
|
||||
switch (this->spawnType) {
|
||||
case SPAWNER_LEEVER:
|
||||
this->timer = 30;
|
||||
this->maxCurSpawns = 5;
|
||||
if (globalCtx->sceneNum == SCENE_SPOT13) { // Haunted Wasteland
|
||||
this->reduceLeevers = true;
|
||||
this->maxCurSpawns = 3;
|
||||
}
|
||||
this->updateFunc = EnEncount1_SpawnLeevers;
|
||||
break;
|
||||
case SPAWNER_TEKTITE:
|
||||
this->maxCurSpawns = 2;
|
||||
this->updateFunc = EnEncount1_SpawnTektites;
|
||||
break;
|
||||
case SPAWNER_STALCHILDREN:
|
||||
case SPAWNER_WOLFOS:
|
||||
if (globalCtx->sceneNum == SCENE_SPOT00) { // Hyrule Field
|
||||
this->maxTotalSpawns = 10000;
|
||||
}
|
||||
this->updateFunc = EnEncount1_SpawnStalchildOrWolfos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void EnEncount1_SpawnLeevers(EnEncount1* this, GlobalContext* globalCtx) {
|
||||
Player* player = PLAYER;
|
||||
s32 floorType;
|
||||
f32 spawnDist;
|
||||
s32 spawnParams;
|
||||
s16 spawnLimit;
|
||||
s16 spawnAngle;
|
||||
Vec3f spawnPos;
|
||||
CollisionPoly* floorPoly;
|
||||
s32 bgId;
|
||||
f32 floorY;
|
||||
EnReeba* leever;
|
||||
|
||||
this->outOfRangeTimer = 0;
|
||||
spawnPos = this->actor.posRot.pos;
|
||||
|
||||
if ((this->timer == 0) && (globalCtx->csCtx.state == 0) && (this->curNumSpawn <= this->maxCurSpawns) &&
|
||||
(this->curNumSpawn < 5)) {
|
||||
floorType = func_80041D4C(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorPolySource);
|
||||
if ((floorType != 4) && (floorType != 7) && (floorType != 12)) {
|
||||
this->numLeeverSpawns = 0;
|
||||
} else if (!(this->reduceLeevers && (this->actor.xzDistFromLink > 1300.0f))) {
|
||||
spawnLimit = 5;
|
||||
if (this->reduceLeevers) {
|
||||
spawnLimit = 3;
|
||||
}
|
||||
while ((this->curNumSpawn < this->maxCurSpawns) && (this->curNumSpawn < spawnLimit) && (this->timer == 0)) {
|
||||
spawnDist = sLeeverDists[this->leeverIndex];
|
||||
spawnAngle = sLeeverAngles[this->leeverIndex] + player->actor.shape.rot.y;
|
||||
spawnParams = LEEVER_SMALL;
|
||||
|
||||
if ((this->killCount >= 10) && (this->bigLeever == NULL)) {
|
||||
this->killCount = this->numLeeverSpawns = 0;
|
||||
spawnAngle = sLeeverAngles[0];
|
||||
spawnDist = sLeeverDists[2];
|
||||
spawnParams = LEEVER_BIG;
|
||||
}
|
||||
|
||||
spawnPos.x = player->actor.posRot.pos.x + Math_Sins(spawnAngle) * spawnDist;
|
||||
spawnPos.y = player->actor.groundY + 120.0f;
|
||||
spawnPos.z = player->actor.posRot.pos.z + Math_Coss(spawnAngle) * spawnDist;
|
||||
|
||||
floorY = func_8003C9A4(&globalCtx->colCtx, &floorPoly, &bgId, &this->actor, &spawnPos);
|
||||
if (floorY <= -32000.0f) {
|
||||
break;
|
||||
}
|
||||
spawnPos.y = floorY;
|
||||
|
||||
leever = (EnReeba*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_REEBA,
|
||||
spawnPos.x, spawnPos.y, spawnPos.z, 0, 0, 0, spawnParams);
|
||||
|
||||
if (1) {} if (1) {}
|
||||
if (leever != NULL) {
|
||||
this->curNumSpawn++;
|
||||
leever->unk_280 = this->leeverIndex++;
|
||||
if (this->leeverIndex >= 5) {
|
||||
this->leeverIndex = 0;
|
||||
}
|
||||
this->numLeeverSpawns++;
|
||||
if (this->numLeeverSpawns >= 12) {
|
||||
this->timer = 150;
|
||||
this->numLeeverSpawns = 0;
|
||||
}
|
||||
if (spawnParams != LEEVER_SMALL) {
|
||||
this->timer = 300;
|
||||
this->bigLeever = leever;
|
||||
}
|
||||
if (!this->reduceLeevers) {
|
||||
this->maxCurSpawns = (s16)Math_Rand_ZeroFloat(3.99f) + 2;
|
||||
} else {
|
||||
this->maxCurSpawns = (s16)Math_Rand_ZeroFloat(2.99f) + 1;
|
||||
}
|
||||
} else {
|
||||
// Cannot spawn!
|
||||
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発生できません! ☆☆☆☆☆\n" VT_RST);
|
||||
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発生できません! ☆☆☆☆☆\n" VT_RST);
|
||||
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発生できません! ☆☆☆☆☆\n" VT_RST);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EnEncount1_SpawnTektites(EnEncount1* this, GlobalContext* globalCtx) {
|
||||
Player* player = PLAYER;
|
||||
s32 bgId;
|
||||
CollisionPoly* floorPoly;
|
||||
Vec3f spawnPos;
|
||||
f32 floorY;
|
||||
|
||||
if (this->timer == 0) {
|
||||
this->timer = 10;
|
||||
if ((fabsf(player->actor.posRot.pos.y - this->actor.posRot.pos.y) > 100.0f) ||
|
||||
(this->actor.xzDistFromLink > this->spawnRange)) {
|
||||
this->outOfRangeTimer++;
|
||||
} else {
|
||||
this->outOfRangeTimer = 0;
|
||||
if ((this->curNumSpawn < this->maxCurSpawns) && (this->totalNumSpawn < this->maxTotalSpawns)) {
|
||||
spawnPos.x = this->actor.posRot.pos.x + Math_Rand_CenteredFloat(50.0f);
|
||||
spawnPos.y = this->actor.posRot.pos.y + 120.0f;
|
||||
spawnPos.z = this->actor.posRot.pos.z + Math_Rand_CenteredFloat(50.0f);
|
||||
floorY = func_8003C9A4(&globalCtx->colCtx, &floorPoly, &bgId, &this->actor, &spawnPos);
|
||||
if (floorY <= -32000.0f) {
|
||||
return;
|
||||
}
|
||||
spawnPos.y = floorY;
|
||||
if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TITE, spawnPos.x,
|
||||
spawnPos.y, spawnPos.z, 0, 0, 0, -1) != NULL) { // Red tektite
|
||||
this->curNumSpawn++;
|
||||
this->totalNumSpawn++;
|
||||
} else {
|
||||
// Cannot spawn!
|
||||
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発生できません! ☆☆☆☆☆\n" VT_RST);
|
||||
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発生できません! ☆☆☆☆☆\n" VT_RST);
|
||||
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発生できません! ☆☆☆☆☆\n" VT_RST);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EnEncount1_SpawnStalchildOrWolfos(EnEncount1* this, GlobalContext* globalCtx) {
|
||||
Player* player = PLAYER;
|
||||
f32 spawnDist;
|
||||
s16 spawnAngle;
|
||||
s16 spawnId;
|
||||
s16 spawnParams;
|
||||
s16 kcOver10;
|
||||
s16 tempmod;
|
||||
Vec3f spawnPos;
|
||||
CollisionPoly* floorPoly;
|
||||
s32 bgId;
|
||||
f32 floorY;
|
||||
|
||||
if (globalCtx->sceneNum != SCENE_SPOT00) {
|
||||
if ((fabsf(player->actor.posRot.pos.y - this->actor.posRot.pos.y) > 100.0f) ||
|
||||
(this->actor.xzDistFromLink > this->spawnRange)) {
|
||||
this->outOfRangeTimer++;
|
||||
return;
|
||||
}
|
||||
} else if (!gSaveContext.nightFlag || (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY)) {
|
||||
this->killCount = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
this->outOfRangeTimer = 0;
|
||||
spawnPos = this->actor.posRot.pos;
|
||||
if ((this->curNumSpawn < this->maxCurSpawns) && (this->totalNumSpawn < this->maxTotalSpawns)) {
|
||||
while ((this->curNumSpawn < this->maxCurSpawns) && (this->totalNumSpawn < this->maxTotalSpawns)) {
|
||||
if (globalCtx->sceneNum == SCENE_SPOT00) {
|
||||
if ((player->unk_89E == 0) || (player->actor.floorPolySource != 0x32) ||
|
||||
!(player->actor.bgCheckFlags & 1) || (player->stateFlags1 & 0x08000000)) {
|
||||
|
||||
this->fieldSpawnTimer = 60;
|
||||
break;
|
||||
}
|
||||
if (this->fieldSpawnTimer == 60) {
|
||||
this->maxCurSpawns = 2;
|
||||
}
|
||||
if (this->fieldSpawnTimer != 0) {
|
||||
this->fieldSpawnTimer--;
|
||||
break;
|
||||
}
|
||||
|
||||
spawnDist = Math_Rand_CenteredFloat(40.0f) + 200.0f;
|
||||
spawnAngle = player->actor.shape.rot.y;
|
||||
if (this->curNumSpawn != 0) {
|
||||
spawnAngle = -spawnAngle;
|
||||
spawnDist = Math_Rand_CenteredFloat(40.0f) + 100.0f;
|
||||
}
|
||||
spawnPos.x =
|
||||
player->actor.posRot.pos.x + (Math_Sins(spawnAngle) * spawnDist) + Math_Rand_CenteredFloat(40.0f);
|
||||
spawnPos.y = player->actor.groundY + 120.0f;
|
||||
spawnPos.z =
|
||||
player->actor.posRot.pos.z + (Math_Coss(spawnAngle) * spawnDist) + Math_Rand_CenteredFloat(40.0f);
|
||||
floorY = func_8003C9A4(&globalCtx->colCtx, &floorPoly, &bgId, &this->actor, &spawnPos);
|
||||
if (floorY <= -32000.0f) {
|
||||
break;
|
||||
}
|
||||
if ((player->actor.waterY != -32000.0f) &&
|
||||
(floorY < (player->actor.posRot.pos.y - player->actor.waterY))) {
|
||||
break;
|
||||
}
|
||||
spawnPos.y = floorY;
|
||||
}
|
||||
if (this->spawnType == SPAWNER_WOLFOS) {
|
||||
spawnId = ACTOR_EN_WF;
|
||||
spawnParams = (0xFF << 8) | 0x00;
|
||||
} else {
|
||||
spawnId = ACTOR_EN_SKB;
|
||||
spawnParams = 0;
|
||||
|
||||
kcOver10 = this->killCount / 10;
|
||||
if (kcOver10 > 0) {
|
||||
tempmod = this->killCount % 10;
|
||||
if (tempmod == 0) {
|
||||
spawnParams = kcOver10 * 5;
|
||||
}
|
||||
}
|
||||
this->killCount++;
|
||||
}
|
||||
if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, spawnId, spawnPos.x, spawnPos.y,
|
||||
spawnPos.z, 0, 0, 0, spawnParams) != NULL) {
|
||||
this->curNumSpawn++;
|
||||
if (this->curNumSpawn >= this->maxCurSpawns) {
|
||||
this->fieldSpawnTimer = 100;
|
||||
}
|
||||
if (globalCtx->sceneNum != SCENE_SPOT00) {
|
||||
this->totalNumSpawn++;
|
||||
}
|
||||
} else {
|
||||
// Cannot spawn!
|
||||
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発生できません! ☆☆☆☆☆\n" VT_RST);
|
||||
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発生できません! ☆☆☆☆☆\n" VT_RST);
|
||||
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発生できません! ☆☆☆☆☆\n" VT_RST);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EnEncount1_Update(Actor* thisx, GlobalContext* globalCtx) {
|
||||
s32 pad;
|
||||
EnEncount1* this = THIS;
|
||||
|
||||
if (this->timer != 0) {
|
||||
this->timer--;
|
||||
}
|
||||
|
||||
this->updateFunc(this, globalCtx);
|
||||
|
||||
if (BREG(0) != 0) {
|
||||
if (this->outOfRangeTimer != 0) {
|
||||
if ((this->outOfRangeTimer & 1) == 0) {
|
||||
DebugDisplay_AddObject(this->actor.posRot.pos.x, this->actor.posRot.pos.y, this->actor.posRot.pos.z,
|
||||
this->actor.posRot.rot.x, this->actor.posRot.rot.y, this->actor.posRot.rot.z,
|
||||
1.0f, 1.0f, 1.0f, 120, 120, 120, 255, 4, globalCtx->state.gfxCtx);
|
||||
}
|
||||
} else {
|
||||
DebugDisplay_AddObject(this->actor.posRot.pos.x, this->actor.posRot.pos.y, this->actor.posRot.pos.z,
|
||||
this->actor.posRot.rot.x, this->actor.posRot.rot.y, this->actor.posRot.rot.z, 1.0f,
|
||||
1.0f, 1.0f, 255, 0, 255, 255, 4, globalCtx->state.gfxCtx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,21 +3,40 @@
|
|||
|
||||
#include "ultra64.h"
|
||||
#include "global.h"
|
||||
#include "overlays/actors/ovl_En_Reeba/z_en_reeba.h"
|
||||
|
||||
#define SPAWNER_PARAMS(type, number, total) ((type << 0xB) | (number << 0x6) | total)
|
||||
|
||||
struct EnEncount1;
|
||||
|
||||
typedef void (*EnEncount1UpdateFunc)(struct EnEncount1*, GlobalContext*);
|
||||
|
||||
typedef struct EnEncount1 {
|
||||
/* 0x0000 */ Actor actor;
|
||||
/* 0x014C */ char unk_14C[0x6];
|
||||
/* 0x0152 */ s16 unk_152;
|
||||
/* 0x0154 */ char unk_154[0xA];
|
||||
/* 0x015E */ s16 numLeeversDead;
|
||||
/* 0x0160 */ char unk_160[0x4];
|
||||
/* 0x0164 */ s16 unk_164;
|
||||
/* 0x0166 */ char unk_166[0x6];
|
||||
/* 0x016C */ UNK_TYPE unk_16C;
|
||||
/* 0x014C */ EnEncount1UpdateFunc updateFunc;
|
||||
/* 0x0150 */ s16 maxCurSpawns;
|
||||
/* 0x0152 */ s16 curNumSpawn;
|
||||
/* 0x0154 */ s16 spawnType;
|
||||
/* 0x0156 */ s16 maxTotalSpawns;
|
||||
/* 0x0158 */ s16 totalNumSpawn;
|
||||
/* 0x015A */ s16 outOfRangeTimer;
|
||||
/* 0x015C */ s16 fieldSpawnTimer;
|
||||
/* 0x015E */ s16 killCount;
|
||||
/* 0x0160 */ s16 numLeeverSpawns;
|
||||
/* 0x0162 */ s16 leeverIndex;
|
||||
/* 0x0164 */ s16 timer;
|
||||
/* 0x0166 */ u8 reduceLeevers;
|
||||
/* 0x0168 */ f32 spawnRange;
|
||||
/* 0x016C */ EnReeba* bigLeever;
|
||||
} EnEncount1; // size = 0x0170
|
||||
|
||||
typedef enum {
|
||||
/* 0 */ SPAWNER_LEEVER,
|
||||
/* 1 */ SPAWNER_TEKTITE,
|
||||
/* 2 */ SPAWNER_STALCHILDREN,
|
||||
/* 3 */ SPAWNER_WOLFOS
|
||||
} EnEncount1type;
|
||||
|
||||
extern const ActorInit En_Encount1_InitVars;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue