Merge branch 'demo-jp' into asset-extraction

This commit is contained in:
octorock
2021-10-23 14:16:44 +02:00
50 changed files with 6898 additions and 15095 deletions
+2 -2
View File
@@ -94,12 +94,12 @@ void (*const gEnemyFunctions[])(Entity* ent) = {
[MINI_SLIME] = MiniSlime,
[FIREBALL_GUY] = FireballGuy,
[MINI_FIREBALL_GUY] = MiniFireballGuy,
[ENEMY_5A] = Enemy5A,
[VAATI_TRANSFIGURED_EYE] = VaatiTransfiguredEye,
[BUSINESS_SCRUB_PROLOGUE] = BusinessScrubPrologue,
[GYORG_FEMALE] = GyorgFemale,
[GYORG_MALE] = GyorgMale,
[CURTAIN] = Curtain,
[ENEMY_5F] = Enemy5F,
[VAATI_WRATH_EYE] = VaatiWrathEye,
[GYORG_CHILD] = GyorgChild,
[GYORG_FEMALE_EYE] = GyorgFemaleEye,
[ENEMY_62] = Enemy62,
+1474
View File
File diff suppressed because it is too large Load Diff
+302
View File
@@ -0,0 +1,302 @@
#include "global.h"
#include "enemy.h"
#include "audio.h"
#include "random.h"
#include "functions.h"
extern u32 sub_080002E0(u32, u32);
extern s16 gUnk_080B4488[];
void VaatiEyesMacroFunction0(Entity*);
void VaatiEyesMacroFunction1(Entity*);
void VaatiEyesMacroFunction0Type0(Entity*);
void VaatiEyesMacroFunction0Type1(Entity*);
void VaatiEyesMacroFunction0Type2(Entity*);
void VaatiEyesMacroFunction0Type3(Entity*);
void VaatiEyesMacroFunction0Type0Action0(Entity*);
void VaatiEyesMacroFunction0Type0Action1(Entity*);
void VaatiEyesMacroFunction0Type1Action0(Entity*);
void VaatiEyesMacroFunction0Type1Action1(Entity*);
void sub_0802EF90(Entity*);
void sub_0802EFB8(Entity*);
void sub_0802EF58(Entity*);
void sub_0802F04C(Entity*);
void (*const vaatiEyesMacroFunctions[])(Entity*) = {
VaatiEyesMacroFunction0, VaatiEyesMacroFunction1, sub_08001324, sub_0804A7D4, sub_08001242, VaatiEyesMacroFunction0,
};
void (*const vaatiEyesMacroFunction0Types[])(Entity*) = {
VaatiEyesMacroFunction0Type0,
VaatiEyesMacroFunction0Type1,
VaatiEyesMacroFunction0Type2,
VaatiEyesMacroFunction0Type3,
};
void (*const vaatiEyesMacroFunction0Type0Actions[])(Entity*) = {
VaatiEyesMacroFunction0Type0Action0,
VaatiEyesMacroFunction0Type0Action1,
};
void (*const vaatiEyesMacroFunction0Type1Actions[])(Entity*) = {
VaatiEyesMacroFunction0Type1Action0,
VaatiEyesMacroFunction0Type1Action1,
};
const u8 gUnk_080CDE6C[] = { 0, 8, 0x18, 0 };
const u8 gUnk_080CDE70[] = {
9, 9, 8, 9, 8, 8, 8, 7, 7, 7, 6, 7, 6, 6, 6, 5, 5, 5, 12, 5, 12, 12, 12, 11, 11, 11, 10, 11, 10, 10, 10, 9,
};
const s8 gUnk_080CDE90[] = { -2, -3, -4, -5, -6, -5, -4, -3 };
const u16 gUnk_080CDE98[] = { 0xc0, 0x100, 0x140, 0x180 };
extern u8 gEntCount;
void VaatiEyesMacro(Entity* this) {
vaatiEyesMacroFunctions[GetNextFunction(this)](this);
SetChildOffset(this, 0, 1, -0x10);
}
void VaatiEyesMacroFunction0(Entity* this) {
vaatiEyesMacroFunction0Types[this->type](this);
if (this->type < 2) {
sub_0802EF90(this);
}
}
void VaatiEyesMacroFunction1(Entity* this) {
if (this->type == 0) {
if (this->currentHealth == 0) {
gScreenTransition.field_0x39 &= ~(1 << (gScreenTransition.field_0x3c + 2));
}
if (gRoomControls.roomID == 0) {
gScreenTransition.field_0x3a = this->currentHealth;
} else {
gScreenTransition.field_0x3b = this->currentHealth;
}
if (this->field_0x78.HALF.HI != this->currentHealth) {
EnqueueSFX(SFX_17A);
}
this->field_0x78.HALF.HI = this->currentHealth;
} else {
if (this->type == 1) {
if (0 < this->iframes) {
this->iframes *= -1;
}
if (this->currentHealth != 0xff) {
EnqueueSFX(SFX_BUTTON_DEPRESS);
}
this->currentHealth = 0xff;
}
}
if (this->field_0x43 != 0) {
sub_0804A9FC(this, 0x1c);
}
sub_0804AA30(this, vaatiEyesMacroFunctions);
}
void VaatiEyesMacroFunction0Type0(Entity* this) {
vaatiEyesMacroFunction0Type0Actions[this->action](this);
}
void VaatiEyesMacroFunction0Type0Action0(Entity* this) {
Manager* manager;
Entity* enemy;
if ((gEntCount < 0x47) && (manager = GetEmptyManager(), manager != NULL)) {
manager->type = 9;
manager->subtype = 0x34;
manager->parent = (Manager*)this;
AppendEntityToList((Entity*)manager, 8);
enemy = CreateEnemy(VAATI_EYES_MACRO, 2);
enemy->parent = this;
this->action = 1;
if (gRoomControls.roomID == 0) {
this->field_0x78.HALF.HI = this->currentHealth = gScreenTransition.field_0x3a;
} else {
this->field_0x78.HALF.HI = this->currentHealth = gScreenTransition.field_0x3b;
}
this->field_0x78.HALF.LO = Random();
sub_0802EFB8(this);
InitializeAnimation(this, 0);
sub_0802EF58(this);
}
}
void VaatiEyesMacroFunction0Type0Action1(Entity* this) {
sub_0802F04C(this);
GetNextFrame(this);
}
void VaatiEyesMacroFunction0Type1(Entity* this) {
vaatiEyesMacroFunction0Type1Actions[this->action](this);
}
void VaatiEyesMacroFunction0Type1Action0(Entity* this) {
Entity* entity;
u32 rand;
if (gEntCount < 0x47) {
entity = CreateEnemy(VAATI_EYES_MACRO, 3);
entity->parent = this;
this->action = 1;
rand = Random();
this->actionDelay = (rand & 3) + 1;
this->field_0x78.HALF.LO = Random() >> 8;
this->direction = gUnk_080CDE6C[rand >> 0x10 & 3];
InitializeAnimation(this, 1);
}
}
void VaatiEyesMacroFunction0Type1Action1(Entity* this) {
if (this->parent->next == NULL) {
this->flags &= 0x7f;
this->currentHealth = 0;
} else {
sub_0802F04C(this);
GetNextFrame(this);
}
}
typedef struct xy {
u8 x;
u8 y;
} xy;
void VaatiEyesMacroFunction0Type2(Entity* this) {
u32 uVar2;
xy* temp;
if (this->parent->next == NULL) {
DeleteThisEntity();
}
if (this->action == 0) {
this->action = 1;
this->animationState = 0xff;
}
CopyPositionAndSpriteOffset(this->parent, this);
uVar2 = (GetFacingDirection(this, &gPlayerEntity) + 1) & 0x1e;
temp = (xy*)&gUnk_080CDE70[uVar2];
if (temp->x != this->frameIndex) {
if (temp->y != this->frameIndex) {
this->frameIndex = temp->x;
}
}
this->y.HALF.HI++;
this->spriteOffsetY -= 1;
}
void VaatiEyesMacroFunction0Type3(Entity* this) {
if (this->parent->next == NULL) {
DeleteThisEntity();
}
if (this->action == 0) {
this->action = 1;
this->frameIndex = 0x11;
this->spritePriority.b0 = 6;
}
CopyPositionAndSpriteOffset(this->parent, this);
this->height.HALF.HI = 0;
}
void sub_0802EF58(Entity* this) {
Entity* entity;
u32 i;
for (i = 0; i < 7; i++) {
entity = CreateEnemy(VAATI_EYES_MACRO, 1);
if (entity != NULL) {
entity->type2 = i;
entity->collisionLayer = 1;
entity->parent = this;
UpdateSpriteForCollisionLayer(entity);
CopyPosition(this, entity);
}
}
}
void sub_0802EF90(Entity* this) {
this->height.HALF.HI = gUnk_080CDE90[this->field_0x78.HALF.LO++ >> 3 & 7];
}
void sub_0802EFB8(Entity* this) {
u32 uVar1;
u32 rand;
u32 uVar3;
int iVar4;
rand = Random();
if ((rand >> 0x10 & 3) != 0) {
uVar1 = rand & 0x18;
} else {
uVar3 = GetFacingDirection(&gPlayerEntity, this);
uVar1 = (uVar3 + 4) & 0x18;
}
iVar4 = sub_080002E0(TILE(this->x.HALF.HI, this->y.HALF.HI) + gUnk_080B4488[((uVar1) >> 3)], 1);
if (iVar4 != 0) {
this->direction = 0xff;
} else {
this->actionDelay = (rand & 3) + 1;
this->direction = (uVar1 & 0x18);
this->speed = gUnk_080CDE98[rand >> 0x18 & 3];
}
}
void sub_0802F04C(Entity* this) {
s32 oldX;
s32 oldY;
oldX = this->x.HALF.HI;
oldY = this->y.HALF.HI;
if (ProcessMovement(this) == 0) {
sub_0802EFB8(this);
return;
}
switch (this->direction >> 3) {
case 0:
if (((oldY & 0xf) > 8) && ((this->y.HALF.HI & 0xf) < 9)) {
this->actionDelay--;
oldY = (this->y.HALF.HI & 0xfff0) + 8;
}
if (this->actionDelay == 0) {
this->x.HALF.HI = oldX;
this->y.HALF.HI = oldY;
} else {
return;
}
break;
case 1:
if (((oldX & 0xf) < 8) && ((this->x.HALF.HI & 0xf) >= 8)) {
this->actionDelay--;
oldX = (this->x.HALF.HI & 0xfff0) + 8;
}
if (this->actionDelay == 0) {
this->x.HALF.HI = oldX;
this->y.HALF.HI = oldY;
} else {
return;
}
break;
case 2:
if (((oldY & 0xf) < 8) && ((this->y.HALF.HI & 0xf) >= 8)) {
this->actionDelay--;
oldY = (this->y.HALF.HI & 0xfff0) + 8;
}
if (this->actionDelay == 0) {
this->x.HALF.HI = oldX;
this->y.HALF.HI = oldY;
} else {
return;
}
break;
default:
if (((oldX & 0xf) >= 9) && ((this->x.HALF.HI & 0xf) < 9)) {
this->actionDelay--;
oldX = (this->x.HALF.HI & 0xfff0) + 8;
}
if (this->actionDelay == 0) {
this->x.HALF.HI = oldX;
this->y.HALF.HI = oldY;
} else {
return;
}
break;
}
sub_0802EFB8(this);
}
+279
View File
@@ -0,0 +1,279 @@
#include "global.h"
#include "enemy.h"
#include "random.h"
#include "functions.h"
extern bool32 PlayerInRange(Entity*, u32, u32);
extern void DoExitTransition(ScreenTransitionData*);
extern u32 sub_080002E0(u32, u32);
extern Entity* gUnk_020000B0;
extern const ScreenTransitionData gUnk_0813AB94;
bool32 sub_0803E4A0(Entity*);
void VaatiProjectileFunction0(Entity*);
void VaatiProjectileFunction1(Entity*);
void sub_08001328(Entity*);
void VaatiProjectileFunction3(Entity*);
void VaatiProjectileNoop(Entity*);
void VaatiProjectileFunction0Action0(Entity*);
void VaatiProjectileFunction0Action1(Entity*);
void VaatiProjectileFunction0Action2(Entity*);
void VaatiProjectileFunction0Action3(Entity*);
void VaatiProjectileFunction0Action4(Entity*);
void VaatiProjectileFunction0Action5(Entity*);
void VaatiProjectileFunction0Action6(Entity*);
void VaatiProjectileFunction0Action7(Entity*);
void VaatiProjectileFunction0Action8(Entity*);
void VaatiProjectileFunction0Action9(Entity*);
void sub_0803E444(Entity*);
void sub_0803E480(Entity*);
void sub_0803E4D8(Entity*);
void (*const vaatiProjectileFunctions[])(Entity*) = {
VaatiProjectileFunction0, VaatiProjectileFunction1, sub_08001328, VaatiProjectileFunction3, sub_08001242,
VaatiProjectileNoop,
};
void (*const vaatiProjectileFunction0Actions[])(Entity*) = {
VaatiProjectileFunction0Action0, VaatiProjectileFunction0Action1, VaatiProjectileFunction0Action2,
VaatiProjectileFunction0Action3, VaatiProjectileFunction0Action4, VaatiProjectileFunction0Action5,
VaatiProjectileFunction0Action6, VaatiProjectileFunction0Action7, VaatiProjectileFunction0Action8,
VaatiProjectileFunction0Action9,
};
void VaatiProjectile(Entity* this) {
if (sub_0803E4A0(this)) {
this->flags &= 0x7f;
this->currentHealth = 0;
this->parent = NULL;
}
vaatiProjectileFunctions[GetNextFunction(this)](this);
}
void VaatiProjectileFunction0(Entity* this) {
vaatiProjectileFunction0Actions[this->action](this);
}
void VaatiProjectileFunction1(Entity* this) {
Entity* entity;
if (this->bitfield == 0x80) {
#ifndef EU
if (this->currentHealth != 0) {
#endif
this->action = 5;
this->flags = this->flags & 0x7f;
this->spritePriority.b1 = 0;
gPlayerEntity.flags &= 0x7f;
gPlayerEntity.spriteOrientation.flipY = this->spriteOrientation.flipY;
gPlayerEntity.spriteRendering.b3 = this->spriteRendering.b3;
sub_0803E444(this);
#ifndef EU
sub_08078A90(2);
entity = this->parent;
if (entity != NULL) {
entity->flags = entity->flags & 0x7f;
}
} else {
gPlayerState.flags.all &= 0xfffffeff; // using b.unk8 does not match
entity = &gPlayerEntity;
entity->flags = gPlayerEntity.flags | 0x80;
}
#endif
}
sub_0804AA30(this, vaatiProjectileFunctions);
}
void VaatiProjectileFunction3(Entity* this) {
if (this->parent != NULL) {
this->parent->field_0xf--;
this->parent = NULL;
}
sub_0804A7D4(this);
}
void VaatiProjectileNoop(Entity* this) {
}
void VaatiProjectileFunction0Action0(Entity* this) {
Entity* entity;
if (this->type == 0) {
entity = CreateEnemy(VAATI_PROJECTILE, 1);
if (entity != NULL) {
entity->parent = this;
this->attachedEntity = entity;
if (this->type2 == 0) {
this->action = 1;
this->height.HALF.HI = -0x18;
} else {
this->action = 9;
this->height.HALF.HI = -0x80;
this->flags2 = 1;
}
InitializeAnimation(this, 0);
}
} else {
this->action = 8;
this->flags = this->flags & 0x7f;
this->spriteOffsetY = 1;
this->spriteOrientation.flipY = this->parent->spriteOrientation.flipY;
this->spriteRendering.b3 = this->parent->spriteRendering.b3;
this->spritePriority.b1 = 0;
PositionRelative(this->parent, this, 0, -0x10000);
InitializeAnimation(this, 1);
}
}
void VaatiProjectileFunction0Action1(Entity* this) {
sub_0803E480(this);
if (PlayerInRange(this, 0, 8) != 0) {
this->action = 2;
this->actionDelay = 10;
InitializeAnimation(this->attachedEntity, 2);
} else {
if (gUnk_020000B0 != NULL) {
sub_08004596(this, GetFacingDirection(this, gUnk_020000B0));
sub_0806F69C(this);
}
}
GetNextFrame(this);
}
void VaatiProjectileFunction0Action2(Entity* this) {
if (this->actionDelay != 0) {
this->actionDelay--;
} else {
if (++this->height.HALF.HI == 0) {
this->action = 3;
}
}
GetNextFrame(this);
}
void VaatiProjectileFunction0Action3(Entity* this) {
if ((this->attachedEntity->frames.b.f3) != 0) {
if (--this->height.HALF.HI <= -0x18) {
this->action = 4;
this->actionDelay = (Random() & 0xf) + 0xf;
InitializeAnimation(this->attachedEntity, 1);
}
GetNextFrame(this);
}
}
void VaatiProjectileFunction0Action4(Entity* this) {
if (--this->actionDelay == 0) {
this->action = 1;
this->direction = GetFacingDirection(this, &gPlayerEntity);
}
GetNextFrame(this);
}
void VaatiProjectileFunction0Action5(Entity* this) {
sub_0803E444(this);
if (this->actionDelay != 0) {
this->actionDelay--;
} else {
if (-0x18 < --this->height.HALF.HI) {
return;
}
this->action = 6;
this->actionDelay = 0x14;
}
}
void VaatiProjectileFunction0Action6(Entity* this) {
if (--this->actionDelay == 0) {
this->action = 7;
this->direction = 0x10;
this->speed = 0x300;
}
sub_0803E444(this);
}
void VaatiProjectileFunction0Action7(Entity* this) {
sub_0803E444(this);
sub_0806F69C(this);
sub_0803E4D8(this);
if ((gRoomControls.roomOriginY + gRoomControls.height + -0x10) <= this->y.HALF.HI) {
sub_0805E5A8();
DoExitTransition((ScreenTransitionData*)&gUnk_0813AB94);
}
}
void VaatiProjectileFunction0Action8(Entity* this) {
if (this->parent->next == NULL) {
DeleteThisEntity();
}
PositionRelative(this->parent, this, 0, -0x10000);
GetNextFrame(this);
}
void VaatiProjectileFunction0Action9(Entity* this) {
this->x.HALF.HI = gPlayerEntity.x.HALF.HI;
this->y.HALF.HI = gPlayerEntity.y.HALF.HI;
if (this->height.HALF.HI < -8) {
if (this->animIndex != 2) {
this->actionDelay = 0;
InitializeAnimation(this->attachedEntity, 2);
}
VaatiProjectileFunction0Action2(this);
} else {
this->height.HALF.HI += 8;
}
}
void sub_0803E444(Entity* this) {
ResetPlayer();
gPlayerState.field_0x1a[0] = gPlayerState.field_0x1a[0] | 0x80;
gPlayerState.field_0xa = gPlayerState.field_0xa | 0x80;
sub_0806FA90(this, this->field_0x4c, 0, -2);
gPlayerEntity.spriteOffsetY += 0xe;
}
void sub_0803E480(Entity* this) {
if (this->field_0x78.HWORD >= 0x4b1) {
this->speed = 0x180;
} else {
this->field_0x78.HWORD++;
}
}
bool32 sub_0803E4A0(Entity* this) {
#ifdef EU
bool32 ret;
if (gScreenTransition.field_0x39 == 0) {
return TRUE;
} else {
if (this->parent == NULL) {
return FALSE;
}
ret = this->parent->next == NULL;
}
return ret;
#else
bool32 ret;
if (gScreenTransition.field_0x39 != 0) {
if (this->parent == NULL) {
return FALSE;
}
if (this->parent->currentHealth == 0) {
return TRUE;
} else {
ret = this->parent->next == NULL;
}
} else {
return TRUE;
}
return ret;
#endif
}
void sub_0803E4D8(Entity* this) {
u32 tile;
tile = TILE(this->x.HALF.HI, this->y.HALF.HI + 8);
if (sub_080002E0(tile, gPlayerEntity.collisionLayer) != 0xff) {
SetTile(0x4074, tile, gPlayerEntity.collisionLayer);
}
}
+902
View File
@@ -0,0 +1,902 @@
#include "global.h"
#include "enemy.h"
#include "coord.h"
#include "flags.h"
#include "random.h"
#include "audio.h"
#include "area.h"
#include "functions.h"
extern void sub_080AEFB4(Entity*);
extern u8 gEntCount;
void VaatiRebornEnemyType0PreAction(Entity*);
void VaatiRebornEnemyType1PreAction(Entity*);
void VaatiRebornEnemyType0Action0(Entity*);
void VaatiRebornEnemyType0Action1(Entity*);
void VaatiRebornEnemyType0Action2(Entity*);
void VaatiRebornEnemyType0Action3(Entity*);
void VaatiRebornEnemyType0Action4(Entity*);
void VaatiRebornEnemyType0Action5(Entity*);
void VaatiRebornEnemyType0Action6(Entity*);
void VaatiRebornEnemyType0Action7(Entity*);
void VaatiRebornEnemyType1Action0(Entity*);
void VaatiRebornEnemyType1Action1(Entity*);
void VaatiRebornEnemyType2Action0(Entity*);
void VaatiRebornEnemyType2Action1(Entity*);
void VaatiRebornEnemyType3Action0(Entity*);
void VaatiRebornEnemyType3Action1(Entity*);
void sub_0803DD78(Entity*);
u32 sub_0803DEE0(Entity*);
u32 sub_0803E028(Entity*);
void sub_0803DC0C(Entity*);
typedef struct xy {
s8 x;
s8 y;
} PACKED xy;
void (*const vaatiRebornEnemyType0Actions[])(Entity*) = {
VaatiRebornEnemyType0Action0, VaatiRebornEnemyType0Action1, VaatiRebornEnemyType0Action2,
VaatiRebornEnemyType0Action3, VaatiRebornEnemyType0Action4, VaatiRebornEnemyType0Action5,
VaatiRebornEnemyType0Action6, VaatiRebornEnemyType0Action7,
};
void (*const vaatiRebornEnemyType1Actions[])(Entity*) = {
VaatiRebornEnemyType1Action0,
VaatiRebornEnemyType1Action1,
};
void (*const vaatiRebornEnemyType2Actions[])(Entity*) = {
VaatiRebornEnemyType2Action0,
VaatiRebornEnemyType2Action1,
};
void (*const vaatiRebornEnemyType3Actions[])(Entity*) = {
VaatiRebornEnemyType3Action0,
VaatiRebornEnemyType3Action1,
};
const xy gUnk_080D04A8[] = { { 16, -43 }, { -16, -43 } };
const Coords gUnk_080D04AC[] = { { .HALF = { 0x58, 0x60 } },
{ .HALF = { 0x58, 0x90 } },
{ .HALF = { 0x98, 0x78 } },
{ .HALF = { 0xd8, 0x60 } },
{ .HALF = { 0xd8, 0x90 } } };
const u8 gUnk_080D04C0[] = { 2, 0, 0, 2, 2, 2, 4, 4 };
const xy gUnk_080D04C8[] = { { 10, -29 }, { -10, -29 }, { 15, -21 }, { -15, -21 } };
#ifdef EU
const u8 gUnk_080D04D0[] = { -12, -20, -32 };
#else
const u8 gUnk_080D04D0[] = { -24, -40, -48 };
#endif
const u8 gUnk_080D04D3[] = { 0, 1, 0, -1 };
void VaatiRebornEnemy(Entity* this) {
switch (this->type) {
case 0:
VaatiRebornEnemyType0PreAction(this);
vaatiRebornEnemyType0Actions[this->action](this);
break;
case 1:
VaatiRebornEnemyType1PreAction(this);
vaatiRebornEnemyType1Actions[this->action](this);
break;
case 2:
vaatiRebornEnemyType2Actions[this->action](this);
break;
case 3:
vaatiRebornEnemyType3Actions[this->action](this);
break;
}
}
void VaatiRebornEnemyType0Action0(Entity* this) {
s32 i;
Entity* entity;
const xy* ptr;
if (CheckLocalFlag(0x7b) != 0) {
DeleteThisEntity();
}
sub_0804A720(this);
if (CheckRoomFlag(0) && (gEntCount < 0x42)) {
ClearRoomFlag(0);
this->action = 3;
this->field_0x74.HALF.LO = -1;
this->actionDelay = 0;
this->field_0x76.HALF.LO = 0;
this->spriteSettings.b.draw = 1;
this->direction = 0xff;
this->spritePriority.b0 = 4;
this->height.WORD = 0;
this->field_0x80.HALF.LO = 2;
this->field_0x86.HALF.LO = 0;
this->cutsceneBeh.HALF.HI = 0x30;
this->cutsceneBeh.HALF.LO = -1;
this->field_0x86.HALF.HI = 0;
this->field_0x82.HALF.LO = 0;
this->field_0x82.HALF.HI = 0;
*(u32*)(&this->field_0x78) = this->x.WORD;
this->field_0x7c = this->y;
entity = CreateEnemy(VAATI_REBORN_ENEMY, 1);
entity->parent = this;
this->attachedEntity = entity;
for (i = 0; i < 6; i++) {
entity = CreateEnemy(VAATI_BALL, 0);
entity->parent = this;
entity->field_0x78.HALF.HI = i;
}
for (i = 0; i < 4; i++) {
entity = CreateEnemy(VAATI_REBORN_ENEMY, 3);
entity->parent = this;
entity->actionDelay = i;
}
for (i = 0; i < 2; i++) {
entity = CreateEnemy(VAATI_BALL, 1);
entity->parent = this;
entity->spriteSettings.b.flipX = i;
ptr = &gUnk_080D04A8[i];
PositionRelative(this, entity, ptr->x << 0x10, ptr->y << 0x10);
}
InitAnimationForceUpdate(this, 0);
}
}
void VaatiRebornEnemyType0Action1(Entity* this) {
if (this->actionDelay != 0) {
if (--this->actionDelay == 0) {
if ((this->field_0x74.HALF.LO & 0x70) == 0) {
if (this->attachedEntity->actionDelay == 0) {
sub_0803DD78(this);
if (this->field_0x74.HALF.HI != 0) {
this->action = 2;
this->field_0x74.HALF.LO = 0;
this->actionDelay = 0x10;
this->direction = 0xff;
} else {
if ((this->field_0x86.HALF.LO != 0) || (this->field_0x80.HALF.LO != 0)) {
this->direction = ((Random() & 0x80) >> 3) | 8;
} else {
this->direction = 0xff;
}
}
} else {
this->actionDelay = 2;
}
} else {
this->action = 3;
this->field_0x74.HALF.HI = this->field_0x74.HALF.LO & 0x80;
this->field_0x74.HALF.LO = 0;
this->actionDelay = 0xc0;
this->direction = 0xff;
this->spriteSettings.b.draw = 1;
InitAnimationForceUpdate(this, 0);
}
}
} else {
if (--this->field_0x76.HALF.HI == 0) {
switch (sub_0803DEE0(this)) {
case 0:
this->action = 4;
this->actionDelay = 0xa0;
this->direction = 0xff;
this->cutsceneBeh.HALF.LO = 0xff;
InitAnimationForceUpdate(this, 1);
break;
case 1:
this->action = 6;
this->field_0x74.HALF.LO = 0;
this->actionDelay = 0;
this->direction = 0xff;
break;
case 3:
this->action = 5;
this->field_0x74.HALF.LO = 0;
this->field_0xf = 0x20;
this->direction = 0xff;
break;
case 2:
this->field_0x74.HALF.LO = 0;
this->actionDelay = 0x20;
if ((this->field_0x86.HALF.LO != 0) || (this->field_0x80.HALF.LO != 0)) {
this->direction = ((Random() & 0x80) >> 3) | 8;
} else {
this->direction = 0xff;
}
break;
}
}
if (this->attachedEntity->actionDelay == 0) {
this->cutsceneBeh.HALF.HI++;
if ((this->cutsceneBeh.HALF.HI & 3) == 0) {
switch (this->cutsceneBeh.HALF.HI & 0x30) {
case 0:
case 0x30:
this->y.HALF.HI++;
break;
case 0x10:
case 0x20:
this->y.HALF.HI--;
}
}
sub_080AEFB4(this);
}
}
UpdateAnimationSingleFrame(this);
}
void VaatiRebornEnemyType0Action2(Entity* this) {
const Coords* ptr;
switch (this->field_0x74.HALF.LO) {
case 0:
if (--this->actionDelay == 0) {
this->field_0x74.HALF.LO++;
this->actionDelay = 0x20;
InitAnimationForceUpdate(this, 3);
SoundReq(SFX_19B);
}
break;
case 1:
if ((this->frames.all & 0x80) != 0) {
this->field_0x74.HALF.LO = 2;
this->spriteSettings.b.draw = 0;
this->actionDelay = 0x10;
}
break;
case 2:
if (--this->actionDelay == 0) {
this->field_0x74.HALF.LO++;
if (sub_0803E028(this) == 0) {
s32 tmp;
this->field_0x80.HALF.HI += 1 + (Random() & 3);
tmp = this->field_0x80.HALF.HI;
this->field_0x80.HALF.HI = tmp % 5;
ptr = &gUnk_080D04AC[this->field_0x80.HALF.HI];
this->x.HALF.HI = gRoomControls.roomOriginX + ptr->HALF.x + 0x10;
this->y.HALF.HI = gRoomControls.roomOriginY + ptr->HALF.y + 0x10;
}
this->spriteSettings.b.draw = 1;
this->actionDelay = 0x20;
InitAnimationForceUpdate(this, 4);
SoundReq(SFX_F5);
}
break;
case 3:
if ((this->frames.all & 0x80) != 0) {
this->spriteSettings.b.draw = 1;
if (4 < this->field_0x80.HALF.HI) {
this->x.HALF.HI = gPlayerEntity.x.HALF.HI;
this->y.HALF.HI = gPlayerEntity.y.HALF.HI - 0x18;
}
if (--this->field_0x76.HALF.HI == 0) {
this->action = 1;
this->actionDelay = 1;
} else {
this->field_0x74.HALF.LO = 0;
this->actionDelay = 0x10;
}
InitAnimationForceUpdate(this, 0);
}
break;
}
UpdateAnimationSingleFrame(this);
}
void VaatiRebornEnemyType0Action3(Entity* this) {
u8 temp;
switch (this->field_0x74.HALF.LO) {
case 0xfe:
this->field_0x74.HALF.LO = 0;
this->actionDelay = 1;
break;
case 0xff:
if (this->height.HALF.HI != -4) {
this->height.WORD -= 0x2000;
}
if (this->actionDelay == 2) {
this->field_0x74.HALF.LO = 0xfe;
}
break;
case 0:
if (--this->actionDelay == 0) {
this->field_0x74.HALF.LO++;
if ((this->field_0x74.HALF.HI & 0x80) != 0) {
temp = 0x14;
} else {
temp = 0x20;
}
this->actionDelay = temp;
this->field_0x80.HALF.LO = ((this->field_0x86.HALF.LO + 1) >> 1) * 2 + 2;
}
break;
case 1:
if (--this->actionDelay == 0) {
this->field_0x74.HALF.LO++;
if ((this->field_0x74.HALF.HI & 0x80) == 0) {
SoundReq(SFX_1B0);
}
InitAnimationForceUpdate(this, 1);
}
break;
case 2:
if ((this->frames.all & 0x80) != 0) {
this->field_0x74.HALF.LO = 3;
InitAnimationForceUpdate(this, 0);
}
break;
case 3:
this->action = 1;
this->field_0x74.HALF.LO = 0;
this->actionDelay = 1;
break;
}
UpdateAnimationSingleFrame(this);
}
void VaatiRebornEnemyType0Action4(Entity* this) {
u32 index;
Entity* entity;
if (--this->actionDelay == 0) {
this->action = 1;
this->cutsceneBeh.HALF.LO = 0xff;
this->actionDelay = 1;
this->direction = (this->direction + 0x10) & 0x1f;
InitAnimationForceUpdate(this, 0);
} else {
if ((this->frames.all & 0x10) != 0) {
this->frames.all &= 0xef;
if (this->cutsceneBeh.HALF.LO == 0xff) {
index = Direction8RoundUp(GetFacingDirection(this, &gPlayerEntity));
this->cutsceneBeh.HALF.LO = gUnk_080D04C0[index >> 2];
this->field_0xf = 0;
}
if ((this->field_0xf < 0x10) &&
(entity = CreateProjectileWithParent(this, 0x1a, this->cutsceneBeh.HALF.LO), entity != NULL)) {
entity->field_0xf = this->field_0xf;
entity->parent = this;
entity->height.HALF.HI = this->height.HALF.HI;
this->field_0xf = this->field_0xf + 1;
}
}
}
UpdateAnimationSingleFrame(this);
}
void VaatiRebornEnemyType0Action5(Entity* this) {
u32 uVar3;
if (this->field_0x80.HALF.LO == 0) {
this->action = 1;
this->actionDelay = 1;
this->direction = 0xff;
InitAnimationForceUpdate(this, 0);
return;
}
switch (this->field_0x74.HALF.LO) {
case 0:
if (--this->field_0xf == 0) {
this->field_0x74.HALF.LO++;
InitAnimationForceUpdate(this, 1);
}
break;
case 1:
if ((this->frames.all & 0x10) != 0) {
this->field_0x74.HALF.LO = 2;
this->field_0xf = (Random() & 0x3f) + 0x40;
SoundReq(SFX_SUMMON);
}
break;
case 2:
if (--this->field_0xf == 0) {
if (!((this->field_0x86.HALF.LO < 2) || (3 < this->field_0x86.HALF.HI)) && (Random() & 0x10) != 0) {
this->field_0x86.HALF.HI++;
this->field_0xf = (Random() & 0x3f) + 0x40;
uVar3 = GetFacingDirection(this, &gPlayerEntity);
this->direction = (uVar3 & 0x10) | 8;
} else {
this->field_0x74.HALF.LO++;
this->field_0x86.HALF.HI = 0;
this->field_0xf = 0x30;
InitAnimationForceUpdate(this, 0);
}
}
break;
case 3:
if (--this->field_0xf == 0) {
this->action = 1;
this->field_0x74.HALF.LO = 0;
this->actionDelay = 1;
this->direction = 0xff;
}
break;
}
if (this->field_0x86.HALF.HI != 0) {
sub_080AEFB4(this);
}
UpdateAnimationSingleFrame(this);
}
void VaatiRebornEnemyType0Action6(Entity* this) {
Entity* target;
if (this->field_0x80.HALF.LO == 0) {
this->action = 1;
this->actionDelay = 1;
return;
}
switch (this->field_0x74.HALF.LO) {
case 0:
if (this->actionDelay != 0) {
this->field_0x74.HALF.LO = 1;
this->actionDelay = 0x70;
}
break;
case 1:
if (--this->actionDelay == 0) {
this->field_0x74.HALF.LO++;
SoundReq(SFX_150);
target = CreateProjectileWithParent(this, 0x18, 0);
if (target != NULL) {
PositionRelative(this, target, 0, -0x100000);
target->parent = this;
}
} else if (this->actionDelay == 0x40) {
SoundReq(SFX_196);
}
break;
case 2:
if (this->field_0xf != 0) {
this->field_0xf = 0;
}
break;
case 3:
if (this->field_0xf == 0) {
this->field_0xf = 1;
SoundReq(SFX_14F);
}
if (this->actionDelay) {
this->action = 1;
this->field_0x74.HALF.LO = 0;
this->actionDelay = 1;
}
break;
}
UpdateAnimationSingleFrame(this);
}
void VaatiRebornEnemyType0Action7(Entity* this) {
Entity* fx;
u32 tmp;
if (this->actionDelay != 0) {
if (--this->actionDelay == 0) {
SetRoomFlag(1);
} else {
if ((this->actionDelay & 7) == 0) {
fx = CreateFx(this, 2, 0);
if (fx != NULL) {
tmp = Random() & 0x3f3f;
fx->x.HALF.HI = ((tmp & 0xff) - 0x20) + fx->x.HALF.HI;
fx->y.HALF.HI = ((tmp >> 8) & 0xff) - 0x20 + fx->y.HALF.HI;
#ifndef EU
fx->spritePriority.b0 = 2;
#endif
}
}
}
}
}
void VaatiRebornEnemyType1Action0(Entity* this) {
Entity* enemy;
this->action = 1;
this->field_0x74.HALF.LO = 0;
this->field_0x74.HALF.HI = 1;
this->actionDelay = 0;
this->spriteOffsetY = -1;
PositionRelative(this->parent, this, 0, 0x10000);
enemy = CreateEnemy(VAATI_REBORN_ENEMY, 2);
enemy->parent = this;
enemy->attachedEntity = this->parent;
InitAnimationForceUpdate(this, this->field_0x74.HALF.LO);
}
void VaatiRebornEnemyType1Action1(Entity* this) {
Entity* parent;
parent = this->parent;
if (this->field_0x74.HALF.LO == 0) {
if (parent->field_0x80.HALF.LO == 0) {
this->field_0x74.HALF.LO = 1;
this->damageType = 0x30;
InitAnimationForceUpdate(this, this->field_0x74.HALF.LO);
}
} else {
if (parent->field_0x80.HALF.LO != 0) {
this->field_0x74.HALF.LO = 0;
this->damageType = 0x2f;
InitAnimationForceUpdate(this, this->field_0x74.HALF.LO);
} else {
if (((this->bitfield & 0x80) != 0) && (0 < this->iframes)) {
parent->iframes = this->iframes;
parent->bitfield = this->bitfield;
}
if ((this->frames.all & 0x40) != 0) {
InitAnimationForceUpdate(this, 2);
}
}
}
if (this->field_0x74.HALF.HI == 0) {
if (parent->action != 2) {
this->field_0x74.HALF.HI = 1;
this->flags |= 0x80;
}
} else {
if (parent->action == 2) {
this->field_0x74.HALF.HI = 0;
this->flags &= 0x7f;
}
}
this->spriteSettings.b.draw = parent->spriteSettings.b.draw;
this->spriteOffsetX = parent->spriteOffsetX;
PositionRelative(this->parent, this, 0, 0x10000);
UpdateAnimationSingleFrame(this);
}
void VaatiRebornEnemyType2Action0(Entity* this) {
Entity* source;
source = this->parent->parent;
this->action = 1;
this->field_0x74.HALF.LO = 1;
this->field_0x74.HALF.HI = 0;
this->spriteOffsetY = -2;
this->direction = 0xff;
PositionRelative(source, this, 0, 0x20000);
InitAnimationForceUpdate(this, 2);
}
void VaatiRebornEnemyType2Action1(Entity* this) {
u8 parentDirection;
Entity* parent;
parent = this->parent;
if (parent->field_0x74.HALF.LO == 0) {
if (this->field_0x74.HALF.LO != 0) {
this->field_0x74.HALF.LO = 0;
}
parentDirection = parent->parent->direction;
if (parentDirection != 0xff) {
if (this->field_0x74.HALF.HI == 0) {
this->field_0x74.HALF.HI = 1;
}
if (parentDirection != this->direction) {
this->direction = parentDirection;
InitAnimationForceUpdate(this, parentDirection >> 3);
}
} else {
if (this->field_0x74.HALF.HI != 0) {
this->field_0x74.HALF.HI = 0;
InitAnimationForceUpdate(this, 0);
}
}
} else {
if (this->field_0x74.HALF.LO == 0) {
this->field_0x74.HALF.LO = 1;
InitAnimationForceUpdate(this, 2);
}
}
this->spriteSettings.b.draw = parent->spriteSettings.b.draw;
this->spriteOffsetX = parent->spriteOffsetX;
PositionRelative(parent->parent, this, 0, 0x20000);
UpdateAnimationSingleFrame(this);
}
void VaatiRebornEnemyType3Action0(Entity* this) {
this->action = 1;
this->field_0x74.HALF.LO = 0;
this->direction = 0xff;
this->spriteOffsetY = -1;
InitAnimationForceUpdate(this, this->field_0x74.HALF.LO);
sub_0803DC0C(this);
}
void VaatiRebornEnemyType3Action1(Entity* this) {
Entity* parent = this->parent;
if (this->parent->direction != 0xff) {
if (this->field_0x74.HALF.LO == 0) {
this->field_0x74.HALF.LO = 1;
}
if (parent->direction != this->direction) {
this->direction = parent->direction;
InitAnimationForceUpdate(this, this->direction >> 3);
}
} else {
if (this->field_0x74.HALF.LO != 0) {
this->field_0x74.HALF.LO = 0;
this->direction = 0xff;
InitAnimationForceUpdate(this, 2);
}
}
sub_0803DC0C(this);
}
void sub_0803DC0C(Entity* this) {
Entity* parent;
const xy* tmp;
parent = this->parent;
tmp = &gUnk_080D04C8[this->actionDelay];
this->spriteSettings.b.draw = parent->spriteSettings.b.draw;
this->spriteOffsetX = parent->spriteOffsetX;
PositionRelative(parent, this, tmp->x << 0x10, (tmp->y + 1) * 0x10000);
UpdateAnimationSingleFrame(this);
}
void VaatiRebornEnemyType1PreAction(Entity* this) {
Entity* parent;
if (this->damageType != 0x30) {
return;
}
parent = this->parent;
this->field_0x76.HALF.HI = 0;
if ((this->bitfield & 0x80) != 0) {
if (gUnk_080D04D0[parent->field_0x86.HALF.LO] > this->currentHealth) {
if (2 < ++parent->field_0x86.HALF.LO) {
this->flags &= 0x7f;
parent->action = 7;
parent->flags &= 0x7f;
parent->actionDelay = 0x80;
parent->spriteOffsetX = 0;
parent->direction = -1;
this->actionDelay = 0;
SoundReq(SONG_STOP_BGM);
gArea.musicIndex = gArea.pMusicIndex;
return;
}
this->actionDelay = 1;
this->field_0x76.HALF.HI = 0xff;
}
if (0 < this->iframes) {
SoundReq(0x127);
sub_08080964(0xc, 1);
if (this->actionDelay == 0)
this->actionDelay = 0x48;
}
}
if (this->actionDelay != 0) {
if (--this->actionDelay == 0) {
this->damageType = 0x2f;
this->field_0x74.HALF.LO = 1;
if (this->field_0x76.HALF.HI == 0) {
parent->field_0x74.HALF.LO = 0xf0;
} else {
parent->field_0x74.HALF.LO = 0x70;
this->currentHealth = 0xff;
}
parent->action = 1;
parent->actionDelay = 1;
InitAnimationForceUpdate(this, 0);
}
}
}
void sub_0803DD78(Entity* this) {
u32 random_number;
random_number = ((u32)Random() & 0x7c) >> 2;
switch (this->field_0x86.HALF.LO) {
case 0:
if (this->field_0x80.HALF.LO == 0) {
this->field_0x74.HALF.HI = 0;
this->field_0x76.HALF.HI = 0x50;
break;
}
switch (this->field_0x82.HALF.HI) {
case 0:
case 2:
case 4:
this->field_0x74.HALF.HI = 0;
this->field_0x76.HALF.HI = 0x50;
break;
case 1:
case 3:
case 5:
this->field_0x74.HALF.HI = 0;
this->field_0x76.HALF.HI = 1;
break;
default:
break;
}
break;
case 1:
switch (this->field_0x82.HALF.HI) {
case 1:
case 3:
case 5:
this->field_0x74.HALF.HI = 0;
this->field_0x76.HALF.HI = 1;
break;
case 2:
if ((random_number & 8) != 0) {
this->field_0x74.HALF.HI = 0;
this->field_0x76.HALF.HI = 1;
} else {
this->field_0x74.HALF.HI = 0;
this->field_0x76.HALF.HI = 0x50;
}
break;
case 4:
if ((random_number & 8) != 0) {
this->field_0x74.HALF.HI = 0;
this->field_0x76.HALF.HI = 0x50;
break;
}
case 0:
this->field_0x74.HALF.HI = 1;
this->field_0x76.HALF.HI = 1;
break;
default:
break;
}
break;
case 2:
switch (this->field_0x82.HALF.HI) {
case 2:
if ((random_number & 0xf) < 3) {
this->field_0x74.HALF.HI = 0;
this->field_0x76.HALF.HI = 1;
} else {
this->field_0x74.HALF.HI = 1;
this->field_0x76.HALF.HI = 1;
}
break;
case 0:
this->field_0x74.HALF.HI = 1;
this->field_0x76.HALF.HI = 1;
break;
case 4:
if (9 < random_number) {
this->field_0x74.HALF.HI = 2;
this->field_0x76.HALF.HI = (Random() & 1) + 2;
break;
}
case 1:
case 3:
case 5:
this->field_0x74.HALF.HI = 0;
this->field_0x76.HALF.HI = 1;
break;
default:
break;
}
}
this->field_0x82.HALF.HI = (this->field_0x82.HALF.HI + 1) % 6;
}
u32 sub_0803DEE0(Entity* this) {
u32 randomValue;
u32 ret;
ret = 2;
randomValue = (Random() & 0xf8) >> 3;
if (this->field_0x80.HALF.LO) {
switch (this->field_0x86.HALF.LO) {
case 0:
ret = this->field_0x82.HALF.LO & 1;
this->field_0x82.HALF.LO = (this->field_0x82.HALF.LO + 1) & 3;
break;
case 1:
switch (this->field_0x82.HALF.LO) {
case 0:
case 2:
ret = 3;
break;
case 1:
case 3:
ret = 1;
break;
case 4:
if (randomValue & 8) {
ret = 3;
} else {
ret = 0;
}
break;
}
this->field_0x82.HALF.LO = (this->field_0x82.HALF.LO + 1) % 5;
break;
case 2:
switch (this->field_0x82.HALF.LO) {
case 0:
case 3:
ret = 3;
break;
case 1:
ret = 0;
if (randomValue > 5) {
ret = 3;
}
break;
case 2:
ret = 0;
if (randomValue < 10) {
ret = 3;
}
break;
case 4:
ret = 0;
break;
default:
ret = 2;
}
this->field_0x82.HALF.LO = (this->field_0x82.HALF.LO + 1) % 5;
break;
}
}
return ret;
}
void VaatiRebornEnemyType0PreAction(Entity* this) {
u32 bVar1;
if (this->action != 0) {
*(u32*)&this->field_0x78 = this->x.WORD;
this->field_0x7c = this->y;
}
if (this->field_0x76.HALF.LO == 0) {
if ((this->direction == 0xff) || sub_08049FA0(this)) {
if (this->field_0x80.HALF.LO == 0) {
this->animationState = (this->animationState + 1) & 3;
this->spriteOffsetX = gUnk_080D04D3[this->animationState];
}
return;
}
bVar1 = sub_08049EE4(this);
this->direction = (bVar1 & 0x10) | 8;
this->field_0x76.HALF.LO = 0x10;
} else {
this->field_0x76.HALF.LO--;
}
if (this->field_0x80.HALF.LO == 0) {
this->animationState = (this->animationState + 1) & 3;
this->spriteOffsetX = gUnk_080D04D3[this->animationState];
}
}
u32 sub_0803E028(Entity* this) {
u32 ret;
s32 tmp;
ret = 0;
if ((this->field_0x74.HALF.HI != 2) && ((Random() & 1) != 0)) {
return 0;
}
if (this->field_0x76.HALF.HI != 1) {
return ret;
}
tmp = gRoomControls.roomOriginX + 0x58;
if (tmp > gPlayerEntity.x.HALF.HI) {
return ret;
}
tmp = gRoomControls.roomOriginY + 0x58;
if (tmp > gPlayerEntity.x.HALF.HI) {
return ret;
}
tmp = gRoomControls.roomOriginY + 0xf8;
if (tmp >= gPlayerEntity.x.HALF.HI) {
this->field_0x80.HALF.HI += 5;
ret = 1;
}
return ret;
}
File diff suppressed because it is too large Load Diff
+333
View File
@@ -0,0 +1,333 @@
#include "entity.h"
#include "enemy.h"
#include "audio.h"
#include "textbox.h"
#include "coord.h"
#include "functions.h"
void sub_08045A00(Entity*);
void sub_08045A28(Entity*);
void VaatiTransfiguredEyeFunction0(Entity*);
void VaatiTransfiguredEyeFunction1(Entity*);
void VaatiTransfiguredEyeNoop(Entity*);
void VaatiTransfiguredEyeFunction0Action0(Entity*);
void VaatiTransfiguredEyeFunction0Action1(Entity*);
void VaatiTransfiguredEyeFunction0Action2(Entity*);
void VaatiTransfiguredEyeFunction0Action3(Entity*);
void VaatiTransfiguredEyeFunction0Action4(Entity*);
void (*const vaatiTransfiguredEyeFunctions[])(Entity*) = {
VaatiTransfiguredEyeFunction0,
VaatiTransfiguredEyeFunction1,
VaatiTransfiguredEyeFunction0,
sub_0804A7D4,
sub_08001242,
VaatiTransfiguredEyeNoop,
};
void (*const vaatiTransfiguredEyeFunction0Actions[])(Entity*) = {
VaatiTransfiguredEyeFunction0Action0, VaatiTransfiguredEyeFunction0Action1, VaatiTransfiguredEyeFunction0Action2,
VaatiTransfiguredEyeFunction0Action3, VaatiTransfiguredEyeFunction0Action4,
};
struct xy {
s8 x;
s8 y;
} PACKED;
const struct xy gUnk_080D18B4[] = { { 0xe8, 0xf6 }, { 0xf6, 0xe8 }, { 0x0a, 0xe8 }, { 0x18, 0xf6 },
{ 0x18, 0x0a }, { 0x0a, 0x18 }, { 0xf6, 0x18 }, { 0xe8, 0x0a } };
void VaatiTransfiguredEye(Entity* this) {
EnemyFunctionHandler(this, vaatiTransfiguredEyeFunctions);
}
void VaatiTransfiguredEyeFunction0(Entity* this) {
vaatiTransfiguredEyeFunction0Actions[this->action](this);
}
void VaatiTransfiguredEyeFunction1(Entity* this) {
u8 bVar1;
Entity* pEVar4;
if (this->type != 0) {
pEVar4 = this->parent->parent;
if ((this->bitfield & 0x80) != 0) {
bVar1 = this->bitfield & 0x3f;
if ((bVar1 == 0xe) || (bVar1 == 0x15)) {
if (this->field_0x80.HALF.HI == 0) {
this->action = 3;
this->field_0x80.HALF.HI += 1;
InitializeAnimation(this, (this->type << 3) | (this->actionDelay + 2));
InitializeAnimation(this->parent, (this->parent->type << 3) | (this->actionDelay + 2));
}
if (this->actionDelay != 0) {
SoundReq(SFX_17A);
} else {
SoundReq(SFX_ITEM_GLOVES_KNOCKBACK);
}
} else {
if (this->currentHealth != 0xff) {
this->currentHealth = 0xff;
if (this->actionDelay != 0 && (pEVar4->field_0x80.HALF.HI != 0)) {
pEVar4->field_0x76.HALF.LO |= (1 << this->type2);
if (this->cutsceneBeh.HALF.HI == 0) {
this->cutsceneBeh.HALF.HI += 1;
InitializeAnimation(this, this->type << 3 | 6);
InitializeAnimation(this->parent, this->parent->type << 3 | 6);
}
}
}
}
}
}
sub_0804AA30(this, vaatiTransfiguredEyeFunctions);
}
void VaatiTransfiguredEyeNoop(Entity* this) {
}
void VaatiTransfiguredEyeFunction0Action0(Entity* this) {
Entity* child;
u8 bVar2;
bVar2 = gTextBox.doTextBox & 0x7f;
if ((gTextBox.doTextBox & 0x7f) == 0) {
this->action = 1;
this->spriteSettings.b.draw = 0;
this->field_0x80.HALF.LO = bVar2;
this->field_0x80.HALF.HI = bVar2;
this->cutsceneBeh.HALF.HI = bVar2;
this->field_0xf = bVar2;
this->field_0x82.HALF.LO = 0x30;
this->field_0x82.HALF.HI = bVar2;
if (this->type == 0) {
sub_08045A00(this);
child = CreateEnemy(VAATI_TRANSFIGURED_EYE, 1);
if (child != NULL) {
child->parent = this;
this->attachedEntity = child;
child->actionDelay = this->actionDelay;
child->type2 = this->type2;
CopyPosition(this, child);
}
} else {
this->spriteOffsetY = 1;
}
InitializeAnimation(this, (u32)this->type << 3 | 1);
}
}
void VaatiTransfiguredEyeFunction0Action1(Entity* this) {
sub_08045A28(this);
if (this->field_0x82.HALF.LO == 0) {
if ((this->frames.all & 0x80) != 0) {
if (this->type != 0) {
this->flags |= 0x80;
}
this->action = 2;
InitializeAnimation(this, this->type << 3);
}
} else {
if (--this->field_0x82.HALF.LO == 0) {
this->spriteSettings.b.draw = 1;
}
}
}
void VaatiTransfiguredEyeFunction0Action2(Entity* this) {
Entity* parent;
sub_08045A28(this);
parent = this->parent;
if (this->type != 0) {
parent = parent->parent;
}
if ((parent->action == 3) && (parent->field_0x80.HALF.LO == 1)) {
this->action = 4;
this->field_0xf = 0;
if (this->type != 0) {
this->flags &= 0x7f;
if (this->actionDelay != 0) {
InitializeAnimation(this, this->type << 3 | 5);
InitializeAnimation(this->parent, this->parent->type << 3 | 5);
} else {
InitializeAnimation(this, this->type << 3 | 4);
InitializeAnimation(this->parent, this->parent->type << 3 | 4);
}
}
}
}
void VaatiTransfiguredEyeFunction0Action3(Entity* this) {
sub_08045A28(this);
if ((this->frames.all & 0x80) != 0) {
this->action = 2;
if (this->type != 0) {
if (this->actionDelay == 0) {
this->damageType = 0x32;
} else {
this->parent->parent->field_0x76.HALF.LO |= (1 << this->type2);
this->damageType = 0x31;
}
}
}
}
void VaatiTransfiguredEyeFunction0Action4(Entity* this) {
Entity* parent;
sub_08045A28(this);
if (this->field_0xf == 0) {
if ((this->frames.all & 0x80) != 0) {
this->field_0xf = 0x20;
}
} else {
parent = this->parent;
if (this->type != 0) {
parent = parent->parent;
}
if ((parent->animationState < 3) && (parent->action != 3)) {
this->action = 1;
this->field_0xf = 0;
this->field_0x80.HALF.HI = 0;
this->cutsceneBeh.HALF.HI = 0;
if (this->type != 0) {
this->damageType = 0x33;
}
if ((parent->field_0x74.HALF.HI >> this->type2 & 1U) != 0) {
this->actionDelay = 1;
} else {
this->actionDelay = 0;
}
InitializeAnimation(this, this->type << 3 | 1);
}
}
}
void sub_08045A00(Entity* this) {
const struct xy* t = &gUnk_080D18B4[this->type2];
PositionRelative(this->parent, this, t->x << 0x10, (t->y + 3) * 0x10000);
}
void sub_08045A28(Entity* this) {
u32 frames;
u32 type;
if (this->field_0x82.HALF.LO == 0) {
GetNextFrame(this);
}
frames = this->frames.all & 0x70;
type = this->type;
if (type == 0) {
sub_08045A00(this);
switch (this->field_0x82.HALF.HI) {
case 0:
switch (frames) {
case 0x20:
this->field_0x82.HALF.HI = 1;
sub_0801D2B4(this, 0x13e);
break;
case 0x00:
case 0x40:
this->field_0x82.HALF.HI = 2;
sub_0801D2B4(this, 0x13f);
break;
default:
break;
}
break;
case 1:
switch (frames) {
case 0x10:
this->field_0x82.HALF.HI = type;
sub_0801D2B4(this, 0x13b);
break;
case 0:
this->field_0x82.HALF.HI = 2;
sub_0801D2B4(this, 0x13f);
break;
default:
break;
}
break;
case 2:
switch (frames) {
case 0x20:
this->field_0x82.HALF.HI = 1;
sub_0801D2B4(this, 0x13e);
break;
case 0x10:
this->field_0x82.HALF.HI = 0;
sub_0801D2B4(this, 0x13b);
break;
case 0x40:
this->field_0x82.HALF.HI = 2;
sub_0801D2B4(this, 0x13f);
break;
default:
break;
}
break;
case 3:
switch (frames) {
case 0:
this->field_0x82.HALF.HI = 2;
sub_0801D2B4(this, 0x13f);
break;
default:
break;
}
break;
default:
break;
}
} else {
PositionRelative(this->parent, this, 0, -0x10000);
switch (this->field_0x82.HALF.HI) {
case 0:
switch (this->frames.all & 0x70) {
case 0x10:
this->field_0x82.HALF.HI = 2;
sub_0801D2B4(this, 0x13b);
break;
case 0x20:
this->field_0x82.HALF.HI = 1;
sub_0801D2B4(this, 0x13e);
break;
default:
break;
}
break;
case 1: {
u32 temp = this->frames.all & 0x70;
switch (temp) {
case 0:
this->field_0x82.HALF.HI = temp;
sub_0801D2B4(this, 0x13f);
break;
case 0x10:
this->field_0x82.HALF.HI = 2;
sub_0801D2B4(this, 0x13b);
break;
default:
break;
}
} break;
case 2:
switch (this->frames.all & 0x70) {
case 0:
this->field_0x82.HALF.HI = this->frames.all & 0x70;
sub_0801D2B4(this, 0x13f);
break;
default:
break;
}
break;
default:
break;
}
}
}
File diff suppressed because it is too large Load Diff
+211
View File
@@ -0,0 +1,211 @@
#include "entity.h"
#include "audio.h"
#include "structures.h"
#include "functions.h"
void sub_080485D8(Entity*);
void sub_080485FC(Entity*);
void VaatiWrathEyeAction0(Entity*);
void VaatiWrathEyeAction1(Entity*);
void VaatiWrathEyeAction2(Entity*);
void VaatiWrathEyeAction3(Entity*);
void VaatiWrathEyeAction4(Entity*);
void VaatiWrathEyeAction5(Entity*);
void VaatiWrathEyeAction6(Entity*);
void VaatiWrathEyeAction7(Entity*);
void VaatiWrathEyeAction8(Entity*);
void VaatiWrathEyeAction9(Entity*);
void (*const vaatiWrathEyeActions[])(Entity*) = {
VaatiWrathEyeAction0, VaatiWrathEyeAction1, VaatiWrathEyeAction2, VaatiWrathEyeAction3, VaatiWrathEyeAction4,
VaatiWrathEyeAction5, VaatiWrathEyeAction6, VaatiWrathEyeAction7, VaatiWrathEyeAction8, VaatiWrathEyeAction9,
};
const s8 gUnk_080D1D70[] = { 0xee, 0x01, 0xfa, 0x04, 0x06, 0x04, 0x13, 0x01 };
const s8 gUnk_080D1D78[] = { 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xfa, 0xfb, 0xfc, 0xfc, 0xfd, 0xfc,
0xfb, 0xfa, 0xf9, 0xfa, 0xfb, 0xfb, 0xfc, 0xfd, 0xfc, 0xfb, 0xfa,
0xf9, 0xfa, 0xfa, 0xfb, 0xfc, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9 };
const s8 gUnk_080D1D98[] = { 0xe8, 0x04, 0xf8, 0x08, 0x08, 0x08, 0x18, 0x04 };
void VaatiWrathEye(Entity* this) {
if (this->parent->next == NULL) {
DeleteThisEntity();
}
vaatiWrathEyeActions[this->action](this);
}
void VaatiWrathEyeAction0(Entity* this) {
if ((gScreenTransition.field_0x38 & 1) != 0) {
this->action = 2;
InitializeAnimation(this, 1);
} else {
this->action = 1;
InitializeAnimation(this, 0);
SoundReq(SFX_166);
}
sub_080485D8(this);
}
void VaatiWrathEyeAction1(Entity* this) {
sub_080485D8(this);
GetNextFrame(this);
if ((this->frames.all & 0x80) != 0) {
this->action = 2;
InitializeAnimation(this, 1);
}
}
void VaatiWrathEyeAction2(Entity* this) {
sub_080485D8(this);
if ((gScreenTransition.field_0x39 & 3) == 0) {
this->action = 3;
this->flags |= 0x80;
this->speed = 0x80;
}
}
void VaatiWrathEyeAction3(Entity* this) {
u32 direction;
Entity* parent;
u32 x;
u32 y;
const s8* ptr;
parent = this->parent;
if (parent->field_0x78.HALF.HI != 0) {
sub_080485D8(this);
} else {
ptr = &gUnk_080D1D98[this->type * 2];
x = parent->x.HALF.HI + ptr[0];
y = parent->y.HALF.HI + ptr[1];
direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, x, y);
this->direction = direction;
sub_0806F69C(this);
this->height.HALF.HI = this->parent->height.HALF.HI;
if ((this->x.HALF.HI == x) && (this->y.HALF.HI == y)) {
this->action = 4;
this->actionDelay = 0x3c;
}
}
}
void VaatiWrathEyeAction4(Entity* this) {
sub_080485FC(this);
if (this->actionDelay != 0) {
if (--this->actionDelay == 0) {
InitializeAnimation(this, 3);
}
} else {
GetNextFrame(this);
if ((this->frames.all & 0x80) != 0) {
this->action = 5;
this->actionDelay = 0;
}
}
}
void VaatiWrathEyeAction5(Entity* this) {
if (this->actionDelay != 0) {
this->action = 6;
if (this->parent->currentHealth >= 0x15) {
this->actionDelay = 120;
} else {
this->actionDelay = 0x3c;
}
this->attachedEntity = NULL;
InitializeAnimation(this, 5);
SoundReq(SFX_19B);
}
sub_080485FC(this);
}
void VaatiWrathEyeAction6(Entity* this) {
Entity* pEVar3;
sub_080485FC(this);
GetNextFrame(this);
if (this->actionDelay != 0) {
if (--this->actionDelay == 0) {
InitializeAnimation(this, 6);
}
} else {
if (this->frames.b.f3) {
this->action = 7;
this->actionDelay = 120;
this->field_0xf = 0;
} else {
if (this->frames.b.f0 != 0) {
this->frames.all &= 0xfe;
pEVar3 = CreateProjectile(0x24);
if (pEVar3 != NULL) {
pEVar3->parent = this;
this->attachedEntity = pEVar3;
PositionRelative(this, pEVar3, 0, 0xc0000);
}
}
}
}
}
void VaatiWrathEyeAction7(Entity* this) {
sub_080485FC(this);
GetNextFrame(this);
if (this->field_0xf != 0) {
this->action = 8;
this->actionDelay = 0x3c;
this->flags &= 0x7f;
this->spriteSettings.b.draw = 0;
CreateFx(this, 0x1f, 0x40);
this->parent->field_0x7a.HALF.HI |= 0x10 << this->type;
} else {
if (--this->actionDelay != 0) {
return;
}
this->action = 5;
this->actionDelay = 0;
this->parent->field_0x7a.HALF.HI |= 1 << this->type;
}
}
void VaatiWrathEyeAction8(Entity* this) {
if (this->parent->action == 0xb) {
this->actionDelay = 0x3c;
} else {
if (--this->actionDelay == 0) {
this->action = 9;
this->flags |= 0x80;
this->spriteSettings.b.draw = 1;
InitializeAnimation(this, 0);
sub_080485FC(this);
SoundReq(SFX_166);
}
}
}
void VaatiWrathEyeAction9(Entity* this) {
sub_080485FC(this);
GetNextFrame(this);
if ((this->frames.all & 0x80) != 0) {
this->action = 4;
this->actionDelay = 1;
this->parent->field_0x7a.HALF.HI = (this->parent->field_0x7a.HALF.HI & 0xf) | (1 << this->type);
}
}
void sub_080485D8(Entity* this) {
const s8* ptr;
ptr = &gUnk_080D1D70[this->type * 2];
sub_0806FA90(this->parent, this, ptr[0], ptr[1]);
}
void sub_080485FC(Entity* this) {
const s8* ptr;
ptr = &gUnk_080D1D98[this->type * 2];
sub_0806FA90(this->parent, this, ptr[0], ptr[1]);
this->height.HALF.HI = gUnk_080D1D78[this->type * 8 + (this->parent->field_0x78.HALF.LO >> 4 & 7)];
}
+1 -1
View File
@@ -22,7 +22,7 @@ void Manager34_Main(Manager34* this) {
void sub_0805DBB4(Manager34* this) {
this->manager.action = 1;
this->field_0x20 = gScreenTransition.filler[0] * 0x3c;
this->field_0x20 = gScreenTransition.field_0x3d * 0x3c;
}
void sub_0805DBCC(Manager34* this) {
+128 -128
View File
@@ -4,134 +4,134 @@
//clang-format off
void (*const gNPCFunctions[][3])(Entity* ent) = {
/*0x00*/ { DeleteEntity, NULL, NULL },
/*0x01*/ { Gentari, NULL, Gentari_Fusion },
/*0x02*/ { Festari, NULL, Festari_Fusion },
/*0x03*/ { ForestMinish, ForestMinish_Head, ForestMinish_Fusion },
/*0x04*/ { Postman, NULL, Postman_Fusion },
/*0x05*/ { NPC5, NULL, NULL },
/*0x06*/ { Townsperson, Townsperson_Head, Townsperson_Fusion },
/*0x07*/ { Kid, Kid_Head, Kid_Fusion },
/*0x08*/ { Guard, Guard_Head, NULL },
/*0x09*/ { NPC9, NULL, NULL },
/*0x0a*/ { Stamp, NULL, NULL },
/*0x0b*/ { Maid, Maid_Head, NULL },
/*0x0c*/ { Marcy, NULL, NULL },
/*0x0d*/ { Wheaton, NULL, NULL },
/*0x0e*/ { Pita, NULL, NULL },
/*0x0f*/ { MinishEzlo, MinishEzlo_Head, NULL },
/*0x10*/ { Mailbox, NULL, NULL },
/*0x11*/ { Beedle, Beedle_Head, NULL },
/*0x12*/ { Brocco, NULL, Brocco_Fusion },
/*0x13*/ { SittingPerson, SittingPerson_Head, SittingPerson_Fusion },
/*0x14*/ { Pina, NULL, Pina_Fusion },
/*0x15*/ { Guard, Guard_Head, NULL },
/*0x16*/ { Maid, Maid_Head, NULL },
/*0x17*/ { Din, NULL, Din_Fusion },
/*0x18*/ { Nayru, NULL, Nayru_Fusion },
/*0x19*/ { Farore, NULL, Farore_Fusion },
/*0x1a*/ { Sturgeon, Sturgeon_Head, Sturgeon_Fusion },
/*0x1b*/ { TingleSiblings, NULL, TingleSiblings_Fusion },
/*0x1c*/ { Stockwell, NULL, NULL },
/*0x1d*/ { Talon, Talon_Head, Talon_Fusion },
/*0x1e*/ { Malon, NULL, Malon_Fusion },
/*0x1f*/ { Epona, NULL, Epona_Fusion },
/*0x20*/ { MilkCart, NULL, NULL },
/*0x21*/ { GhostBrothers, NULL, GhostBrothers_Fusion },
/*0x22*/ { Smith, Smith_Head, Smith_Fusion },
/*0x23*/ { NPC23, NULL, NULL },
/*0x24*/ { KingDaltus, NULL, KingDaltus_Fusion },
/*0x25*/ { MinisterPotho, NULL, MinisterPotho_Fusion },
/*0x26*/ { NPC26, NULL, NULL },
/*0x27*/ { Vaati, NULL, NULL },
/*0x28*/ { Zelda, NULL, NULL },
/*0x29*/ { Mutoh, Mutoh_Head, Mutoh_Fusion },
/*0x2a*/ { Carpenter, Carpenter_Head, Carpenter_Fusion },
/*0x2b*/ { CastorWildsStatue, NULL, CastorWildsStatue_Fusion },
/*0x2c*/ { Cat, NULL, Cat_Fusion },
/*0x2d*/ { MountainMinish, MountainMinish_Head, MountainMinish_Fusion },
/*0x2e*/ { ZeldaFollower, NULL, NULL },
/*0x2f*/ { Melari, Melari_Head, Melari_Fusion },
/*0x30*/ { BladeBrothers, NULL, BladeBrothers_Fusion },
/*0x31*/ { Cow, NULL, Cow_Fusion },
/*0x32*/ { Goron, NULL, Goron_Fusion },
/*0x33*/ { GoronMerchant, NULL, NULL },
/*0x34*/ { Gorman, Gorman_Head, NULL },
/*0x35*/ { Dog, Dog_Head, Dog_Fusion },
/*0x36*/ { Syrup, Syrup_Head, NULL },
/*0x37*/ { Rem, NULL, NULL },
/*0x38*/ { TownMinish, TownMinish_Head, TownMinish_Fusion },
/*0x39*/ { Librari, NULL, Librari_Fusion },
/*0x3a*/ { Percy, Percy_Head, Percy_Fusion },
/*0x3b*/ { VaatiReborn, NULL, NULL },
/*0x3c*/ { MoblinLady, NULL, NULL },
/*0x3d*/ { Librarians, NULL, NULL },
/*0x3e*/ { Farmers, Farmers_Head, Farmers_Fusion },
/*0x3f*/ { Carlov, NULL, NULL },
/*0x40*/ { Dampe, NULL, Dampe_Fusion },
/*0x41*/ { DrLeft, NULL, NULL },
/*0x42*/ { KingGustaf, NULL, NULL },
/*0x43*/ { Gina, NULL, Gina_Fusion },
/*0x44*/ { Simon, NULL, NULL },
/*0x45*/ { Anju, NULL, Anju_Fusion },
/*0x46*/ { Mama, Mama_Head, Mama_Fusion },
/*0x47*/ { Emma, NULL, NULL },
/*0x48*/ { Teachers, Teachers_Head, Teachers_Fusion },
/*0x49*/ { WindTribespeople, WindTribespeople_Head, WindTribespeople_Fusion },
/*0x4a*/ { Gregal, NULL, Gregal_Fusion },
/*0x4b*/ { MayorHagen, NULL, MayorHagen_Fusion },
/*0x4c*/ { BigGoron, NULL, NULL },
/*0x4d*/ { EzloCap, NULL, NULL },
/*0x4e*/ { NPC4E, NULL, NPC4E_Fusion },
/*0x4f*/ { NPC4F, NULL, NULL },
/*0x50*/ { ClothesRack, NULL, NULL },
/*0x51*/ { PicolyteBottle, NULL, NULL },
/*0x52*/ { SmallTownMinish, NULL, NULL },
/*0x53*/ { HurdyGurdyMan, HurdyGurdyMan_Head, HurdyGurdyMan_Fusion },
/*0x54*/ { Cucco, NULL, Cucco_Fusion },
/*0x55*/ { CuccoChick, NULL, CuccoChick_Fusion },
/*0x56*/ { FusionMenuNPC, FusionMenuNPC_Head, NULL },
/*0x57*/ { Phonograph, NULL, NULL },
/*0x58*/ { NPC58, NPC58_Head, NULL },
/*0x59*/ { DeleteEntity, NULL, NULL },
/*0x5a*/ { DeleteEntity, NULL, NULL },
/*0x5b*/ { DeleteEntity, NULL, NULL },
/*0x5c*/ { DeleteEntity, NULL, NULL },
/*0x5d*/ { DeleteEntity, NULL, NULL },
/*0x5e*/ { DeleteEntity, NULL, NULL },
/*0x5f*/ { DeleteEntity, NULL, NULL },
/*0x60*/ { DeleteEntity, NULL, NULL },
/*0x61*/ { DeleteEntity, NULL, NULL },
/*0x62*/ { DeleteEntity, NULL, NULL },
/*0x63*/ { DeleteEntity, NULL, NULL },
/*0x64*/ { DeleteEntity, NULL, NULL },
/*0x65*/ { DeleteEntity, NULL, NULL },
/*0x66*/ { DeleteEntity, NULL, NULL },
/*0x67*/ { DeleteEntity, NULL, NULL },
/*0x68*/ { DeleteEntity, NULL, NULL },
/*0x69*/ { DeleteEntity, NULL, NULL },
/*0x6a*/ { DeleteEntity, NULL, NULL },
/*0x6b*/ { DeleteEntity, NULL, NULL },
/*0x6c*/ { DeleteEntity, NULL, NULL },
/*0x6d*/ { DeleteEntity, NULL, NULL },
/*0x6e*/ { DeleteEntity, NULL, NULL },
/*0x6f*/ { DeleteEntity, NULL, NULL },
/*0x70*/ { DeleteEntity, NULL, NULL },
/*0x71*/ { DeleteEntity, NULL, NULL },
/*0x72*/ { DeleteEntity, NULL, NULL },
/*0x73*/ { DeleteEntity, NULL, NULL },
/*0x74*/ { DeleteEntity, NULL, NULL },
/*0x75*/ { DeleteEntity, NULL, NULL },
/*0x76*/ { DeleteEntity, NULL, NULL },
/*0x77*/ { DeleteEntity, NULL, NULL },
/*0x78*/ { DeleteEntity, NULL, NULL },
/*0x79*/ { DeleteEntity, NULL, NULL },
/*0x7a*/ { DeleteEntity, NULL, NULL },
/*0x7b*/ { DeleteEntity, NULL, NULL },
/*0x7c*/ { DeleteEntity, NULL, NULL },
/*0x7d*/ { DeleteEntity, NULL, NULL },
/*0x7e*/ { DeleteEntity, NULL, NULL },
/*0x7f*/ { DeleteEntity, NULL, NULL }
[NPC_NONE_0] = { DeleteEntity, NULL, NULL },
[GENTARI] = { Gentari, NULL, Gentari_Fusion },
[FESTARI] = { Festari, NULL, Festari_Fusion },
[FOREST_MINISH] = { ForestMinish, ForestMinish_Head, ForestMinish_Fusion },
[POSTMAN] = { Postman, NULL, Postman_Fusion },
[NPC_UNK_5] = { NPC5, NULL, NULL },
[TPWNSPERSON] = { Townsperson, Townsperson_Head, Townsperson_Fusion },
[KID] = { Kid, Kid_Head, Kid_Fusion },
[GUARD] = { Guard, Guard_Head, NULL },
[NPC_UNK_9] = { NPC9, NULL, NULL },
[STAMP] = { Stamp, NULL, NULL },
[MAID] = { Maid, Maid_Head, NULL },
[MARCY] = { Marcy, NULL, NULL },
[WHEATON] = { Wheaton, NULL, NULL },
[PITA] = { Pita, NULL, NULL },
[MINISH_EZLO] = { MinishEzlo, MinishEzlo_Head, NULL },
[MAILBOX] = { Mailbox, NULL, NULL },
[BEEDLE] = { Beedle, Beedle_Head, NULL },
[BROCCO] = { Brocco, NULL, Brocco_Fusion },
[SITTING_PERSON] = { SittingPerson, SittingPerson_Head, SittingPerson_Fusion },
[PINA] = { Pina, NULL, Pina_Fusion },
[GUARD_1] = { Guard, Guard_Head, NULL },
[MAID_1] = { Maid, Maid_Head, NULL },
[DIN] = { Din, NULL, Din_Fusion },
[NAYRU] = { Nayru, NULL, Nayru_Fusion },
[FARORE] = { Farore, NULL, Farore_Fusion },
[STURGEON] = { Sturgeon, Sturgeon_Head, Sturgeon_Fusion },
[TINGLE_SIBLINGS] = { TingleSiblings, NULL, TingleSiblings_Fusion },
[STOCKWELL] = { Stockwell, NULL, NULL },
[TALON] = { Talon, Talon_Head, Talon_Fusion },
[MALON] = { Malon, NULL, Malon_Fusion },
[EPONA] = { Epona, NULL, Epona_Fusion },
[MILK_CART] = { MilkCart, NULL, NULL },
[GHOST_BROTHERS] = { GhostBrothers, NULL, GhostBrothers_Fusion },
[SMITH] = { Smith, Smith_Head, Smith_Fusion },
[NPC_UNK_23] = { NPC23, NULL, NULL },
[KING_DALTUS] = { KingDaltus, NULL, KingDaltus_Fusion },
[MINISTER_POTHO] = { MinisterPotho, NULL, MinisterPotho_Fusion },
[NPC_UNK_26] = { NPC26, NULL, NULL },
[VAATI] = { Vaati, NULL, NULL },
[ZELDA] = { Zelda, NULL, NULL },
[MUTOH] = { Mutoh, Mutoh_Head, Mutoh_Fusion },
[CARPENTER] = { Carpenter, Carpenter_Head, Carpenter_Fusion },
[CASTOR_WILDS_STATUE] = { CastorWildsStatue, NULL, CastorWildsStatue_Fusion },
[CAT] = { Cat, NULL, Cat_Fusion },
[MOUNTAIN_MINISH] = { MountainMinish, MountainMinish_Head, MountainMinish_Fusion },
[ZELDA_FOLLOWER] = { ZeldaFollower, NULL, NULL },
[MELARI] = { Melari, Melari_Head, Melari_Fusion },
[BLADE_BROTHERS] = { BladeBrothers, NULL, BladeBrothers_Fusion },
[COW] = { Cow, NULL, Cow_Fusion },
[GORON] = { Goron, NULL, Goron_Fusion },
[GORON_MERCHANT] = { GoronMerchant, NULL, NULL },
[GORMAN] = { Gorman, Gorman_Head, NULL },
[DOG] = { Dog, Dog_Head, Dog_Fusion },
[SYRUP] = { Syrup, Syrup_Head, NULL },
[REM] = { Rem, NULL, NULL },
[TOWN_MINISH] = { TownMinish, TownMinish_Head, TownMinish_Fusion },
[LIBRARI] = { Librari, NULL, Librari_Fusion },
[PERCY] = { Percy, Percy_Head, Percy_Fusion },
[VAATI_REBORN] = { VaatiReborn, NULL, NULL },
[MOBLIN_LADY] = { MoblinLady, NULL, NULL },
[LIBRARIANS] = { Librarians, NULL, NULL },
[FARMERS] = { Farmers, Farmers_Head, Farmers_Fusion },
[CARLOV] = { Carlov, NULL, NULL },
[DAMPE] = { Dampe, NULL, Dampe_Fusion },
[DR_LEFT] = { DrLeft, NULL, NULL },
[KING_GUSTAF] = { KingGustaf, NULL, NULL },
[GINA] = { Gina, NULL, Gina_Fusion },
[SIMON] = { Simon, NULL, NULL },
[ANJU] = { Anju, NULL, Anju_Fusion },
[MAMA] = { Mama, Mama_Head, Mama_Fusion },
[EMMA] = { Emma, NULL, NULL },
[TEACHERS] = { Teachers, Teachers_Head, Teachers_Fusion },
[WIND_TRIBESPEOPLE] = { WindTribespeople, WindTribespeople_Head, WindTribespeople_Fusion },
[GREGAL] = { Gregal, NULL, Gregal_Fusion },
[MAYOR_HAGEN] = { MayorHagen, NULL, MayorHagen_Fusion },
[BIG_GORON] = { BigGoron, NULL, NULL },
[EZLO_CAP] = { EzloCap, NULL, NULL },
[NPC_UNK_4E] = { NPC4E, NULL, NPC4E_Fusion },
[NPC_UNK_4F] = { NPC4F, NULL, NULL },
[CLOTHES_RACK] = { ClothesRack, NULL, NULL },
[PICOLYTE_BOTTLE] = { PicolyteBottle, NULL, NULL },
[SMALL_TOWN_MINISH] = { SmallTownMinish, NULL, NULL },
[HURDY_GURDY_MAN] = { HurdyGurdyMan, HurdyGurdyMan_Head, HurdyGurdyMan_Fusion },
[CUCCO] = { Cucco, NULL, Cucco_Fusion },
[CUCCO_CHICK] = { CuccoChick, NULL, CuccoChick_Fusion },
[FUSION_MENU_NPC] = { FusionMenuNPC, FusionMenuNPC_Head, NULL },
[PHONOGRAPH] = { Phonograph, NULL, NULL },
[NPC_UNK_58] = { NPC58, NPC58_Head, NULL },
[NPC_NONE_1] = { DeleteEntity, NULL, NULL },
[NPC_NONE_2] = { DeleteEntity, NULL, NULL },
[NPC_NONE_3] = { DeleteEntity, NULL, NULL },
[NPC_NONE_4] = { DeleteEntity, NULL, NULL },
[NPC_NONE_5] = { DeleteEntity, NULL, NULL },
[NPC_NONE_6] = { DeleteEntity, NULL, NULL },
[NPC_NONE_7] = { DeleteEntity, NULL, NULL },
[NPC_NONE_8] = { DeleteEntity, NULL, NULL },
[NPC_NONE_9] = { DeleteEntity, NULL, NULL },
[NPC_NONE_10] = { DeleteEntity, NULL, NULL },
[NPC_NONE_11] = { DeleteEntity, NULL, NULL },
[NPC_NONE_12] = { DeleteEntity, NULL, NULL },
[NPC_NONE_13] = { DeleteEntity, NULL, NULL },
[NPC_NONE_14] = { DeleteEntity, NULL, NULL },
[NPC_NONE_15] = { DeleteEntity, NULL, NULL },
[NPC_NONE_16] = { DeleteEntity, NULL, NULL },
[NPC_NONE_17] = { DeleteEntity, NULL, NULL },
[NPC_NONE_18] = { DeleteEntity, NULL, NULL },
[NPC_NONE_19] = { DeleteEntity, NULL, NULL },
[NPC_NONE_20] = { DeleteEntity, NULL, NULL },
[NPC_NONE_21] = { DeleteEntity, NULL, NULL },
[NPC_NONE_22] = { DeleteEntity, NULL, NULL },
[NPC_NONE_23] = { DeleteEntity, NULL, NULL },
[NPC_NONE_24] = { DeleteEntity, NULL, NULL },
[NPC_NONE_25] = { DeleteEntity, NULL, NULL },
[NPC_NONE_26] = { DeleteEntity, NULL, NULL },
[NPC_NONE_27] = { DeleteEntity, NULL, NULL },
[NPC_NONE_28] = { DeleteEntity, NULL, NULL },
[NPC_NONE_29] = { DeleteEntity, NULL, NULL },
[NPC_NONE_30] = { DeleteEntity, NULL, NULL },
[NPC_NONE_31] = { DeleteEntity, NULL, NULL },
[NPC_NONE_32] = { DeleteEntity, NULL, NULL },
[NPC_NONE_33] = { DeleteEntity, NULL, NULL },
[NPC_NONE_34] = { DeleteEntity, NULL, NULL },
[NPC_NONE_35] = { DeleteEntity, NULL, NULL },
[NPC_NONE_36] = { DeleteEntity, NULL, NULL },
[NPC_NONE_37] = { DeleteEntity, NULL, NULL },
[NPC_NONE_38] = { DeleteEntity, NULL, NULL },
[NPC_NONE_39] = { DeleteEntity, NULL, NULL }
};
//clang-format on
const u8 npc_unk[] = { 0x04, 0x05, 0x06, 0x06 };
+130
View File
@@ -0,0 +1,130 @@
#include "global.h"
#include "entity.h"
#include "script.h"
#include "audio.h"
#include "structures.h"
#include "functions.h"
extern void sub_08095CB0(Entity*);
extern void CreateManager36(Entity*);
extern void DeleteManager36(Entity*);
extern void sub_0805DA90(Entity*, u32);
void VaatiAction0(Entity*);
void VaatiAction1(Entity*);
void sub_08066B74(Entity*, ScriptExecutionContext*);
void (*const vaatiActions[])(Entity*) = { VaatiAction0, VaatiAction1 };
void Vaati(Entity* this) {
vaatiActions[this->action](this);
this->palette.b.b0 = this->palette.b.b4 + (this->frameSpriteSettings & 1);
}
void VaatiAction0(Entity* this) {
this->action = 1;
this->subAction = 0;
this->spriteSettings.b.draw = 1;
this->field_0x68.HALF.LO = 0;
this->field_0x68.HALF.HI = 0;
sub_0805E3A0(this, 2);
sub_0807DD64(this);
VaatiAction1(this);
}
void VaatiAction1(Entity* this) {
ScriptExecutionContext* tmp;
sub_0807DD94(this, sub_08066B74);
if ((*(s8*)&this->field_0x68.HALF.HI != 0) && ((gScreenTransition.frameCount & 3) == 0)) {
sub_08095CB0(this);
}
if ((this->frames.all & ~0x80) != 0) {
switch (this->frames.all & ~0x80u) {
case 1:
EnqueueSFX(SFX_21C);
break;
case 2:
EnqueueSFX(SFX_21E);
break;
case 3:
tmp = (*(ScriptExecutionContext**)&this->cutsceneBeh);
tmp->intVariable = 4;
CreateManager36(this);
break;
case 4:
tmp = (*(ScriptExecutionContext**)&this->cutsceneBeh);
tmp->intVariable = 4;
DeleteManager36(this);
EnqueueSFX(SFX_21D);
break;
}
this->frames.b.f3 = 0;
}
}
void sub_08066B74(Entity* this, ScriptExecutionContext* context) {
u8 animationState;
u32 currentAction;
u32 actions;
actions = context->postScriptActions & 0xfff00000;
context->postScriptActions = context->postScriptActions & 0xfffff;
if (actions != 0) {
do {
currentAction = (~actions + 1) & actions;
actions = actions ^ currentAction;
animationState = this->animationState >> 1;
switch (currentAction) {
case 1 << 20:
this->field_0x80.HWORD = animationState + 0x10;
break;
case 1 << 21:
this->field_0x80.HWORD = animationState + 0x14;
break;
case 1 << 22:
this->field_0x80.HWORD = animationState + 0x18;
break;
case 1 << 23:
this->field_0x80.HWORD = animationState + 0x1c;
break;
case 1 << 24:
this->field_0x80.HWORD = animationState + 0x20;
break;
case 1 << 25:
this->field_0x80.HWORD = animationState + 0x24;
break;
case 1 << 26:
this->field_0x80.HWORD = animationState + 0x28;
break;
case 1 << 27:
this->field_0x80.HWORD = animationState + 0x2c;
break;
case 1 << 28:
this->field_0x80.HWORD = animationState + 0x30;
break;
case 1 << 29:
this->field_0x68.HALF.LO = 1;
break;
case 1 << 30:
this->field_0x68.HALF.LO = 0xff;
break;
case 1 << 31:
this->field_0x68.HALF.HI ^= 1;
break;
}
} while (actions != 0);
}
HandlePostScriptActions(this, *(ScriptExecutionContext**)&this->cutsceneBeh);
}
void sub_08066C94(Entity* this) {
sub_0805DA90(this, 0);
SoundReq(SFX_APPARATE);
}
void sub_08066CA4(Entity* this) {
sub_0805DA90(this, 1);
SoundReq(SFX_EVAPORATE);
}
+213
View File
@@ -0,0 +1,213 @@
#include "global.h"
#include "npc.h"
#include "coord.h"
#include "flags.h"
#include "audio.h"
#include "textbox.h"
#include "functions.h"
void VaatiRebornAction0(Entity* this);
void VaatiRebornAction1(Entity* this);
void sub_0806B96C(Entity*);
Entity* sub_0806B9BC(Entity*);
typedef struct xy {
s8 x;
s8 y;
} PACKED xy;
void (*const vaatiRebornActions[])(Entity*) = {
VaatiRebornAction0,
VaatiRebornAction1,
};
const xy gUnk_08112F80[] = { { 10, -29 }, { -10, -29 }, { 15, -21 }, { -15, -21 } };
void VaatiReborn(Entity* this) {
vaatiRebornActions[this->action](this);
}
void VaatiRebornAction0(Entity* this) {
Entity* entity;
u32 i;
this->action = 1;
this->subAction = 0;
this->actionDelay = 0;
switch (this->type) {
case 0:
this->y.HALF.HI -= 0xa0;
this->actionDelay = 0xa0;
this->field_0xf = 0x20;
this->spriteOffsetY = 0x20;
for (i = 0; i < 4; i++) {
entity = CreateNPC(VAATI_REBORN, 2, i);
if (entity != NULL) {
entity->parent = this;
}
}
entity = CreateNPC(VAATI_REBORN, 1, 0);
entity->parent = this;
entity->spriteOffsetY = -1;
PositionRelative(this, entity, 0, 0x10000);
InitAnimationForceUpdate(this, 0);
break;
case 1:
case 5:
InitAnimationForceUpdate(this, 0);
break;
case 2:
if ((this->type2 & 2) != 0) {
this->spriteSettings.b.flipX = 1;
}
sub_0806B96C(this);
InitAnimationForceUpdate(this, 0);
break;
case 3:
this->actionDelay = 1;
this->field_0xf = 0x20;
entity = CreateNPC(VAATI_REBORN, 4, 0);
if (entity != NULL) {
CopyPosition(this, entity);
entity->parent = this;
entity->spritePriority.b0 = this->spritePriority.b0 - 1;
entity->frameIndex = 0;
}
entity = CreateNPC(VAATI_REBORN, 5, 0);
if (entity != NULL) {
CopyPosition(this, entity);
entity->parent = this;
entity->spritePriority.b0 = this->spritePriority.b0 + 1;
}
InitAnimationForceUpdate(this, 0);
break;
case 4:
InitializeAnimation(this, 0);
break;
default:
break;
}
}
void VaatiRebornAction1(Entity* this) {
Entity* entity;
if (CheckRoomFlag(3) == 0) {
return;
}
switch (this->type) {
case 0:
this->y.HALF.HI++;
if (--this->actionDelay == 0) {
entity = CreateNPC(VAATI_REBORN, 3, 0);
if (entity == NULL) {
break;
}
CopyPosition(this, entity);
TextboxNoOverlapFollow(0x1634);
this->subAction = this->subAction + 1;
DeleteThisEntity();
return;
}
if (this->field_0xf-- == 1) {
this->field_0xf = 0x20;
SoundReq(SFX_1A9);
}
UpdateAnimationSingleFrame(this);
break;
case 1:
entity = sub_0806B9BC(this);
if (entity == NULL) {
DeleteThisEntity();
}
PositionRelative(entity, this, 0, 0x210000);
UpdateAnimationSingleFrame(this);
break;
case 2:
sub_0806B96C(this);
UpdateAnimationSingleFrame(this);
break;
case 3:
switch (this->subAction) {
case 0:
if (--this->actionDelay == 0) {
this->subAction += 1;
}
break;
case 1:
if (this->frames.b.f3 != 0) {
this->subAction = 2;
sub_0801D2B4(this, 0x13f);
InitAnimationForceUpdate(this, this->subAction - 1);
}
break;
case 2:
if ((this->frames.all & 0x10) != 0) {
this->frames.all &= 0xef;
switch (++this->actionDelay) {
case 1:
break;
case 10:
this->subAction++;
EnqueueSFX(SFX_SUMMON);
this->actionDelay = 0;
InitAnimationForceUpdate(this, this->subAction - 1);
break;
}
}
break;
case 3:
if (this->frames.b.f3 != 0) {
SetRoomFlag(0);
DeleteThisEntity();
}
break;
}
if (--this->field_0xf == 0) {
this->field_0xf = 0x20;
SoundReq(SFX_1A9);
}
UpdateAnimationSingleFrame(this);
break;
default:
entity = sub_0806B9BC(this);
if (entity == NULL) {
DeleteThisEntity();
break;
}
if (entity->subAction == 0) {
break;
}
if (this->type != 4) {
UpdateAnimationSingleFrame(this);
} else {
GetNextFrame(this);
}
break;
}
}
void sub_0806B96C(Entity* this) {
Entity* entity;
const xy* ptr;
entity = sub_0806B9BC(this);
if (entity == NULL) {
DeleteThisEntity();
}
ptr = &gUnk_08112F80[this->type2];
this->spriteSettings.b.draw = entity->spriteSettings.b.draw;
PositionRelative(entity, this, ptr->x << 0x10, (ptr->y + 0x21) << 0x10);
UpdateAnimationSingleFrame(this);
}
Entity* sub_0806B9BC(Entity* this) {
Entity* entity;
entity = this->parent;
if (entity != NULL && entity->next == NULL) {
entity = NULL;
}
return entity;
}
+14
View File
@@ -0,0 +1,14 @@
#include "entity.h"
#include "room.h"
#include "player.h"
#include "coord.h"
void ObjectB5(Entity* this) {
if (this->action == 0) {
this->action = 1;
}
#ifndef EU
gRoomControls.cameraTarget = this;
#endif
PositionRelative(&gPlayerEntity, this, 0, -0x280000);
}