Decompile Wizzrobes

This commit is contained in:
octorock
2022-01-31 21:22:13 +01:00
parent 2b8d880ffc
commit 5ab9443679
39 changed files with 732 additions and 1701 deletions
+2 -2
View File
@@ -163,7 +163,7 @@ u32 sub_0806F548(Entity* a, Entity* b, u32 x, u32 y) {
}
u32 sub_0806F564(Entity* ent, u32 b, u32 c) {
u32 tmp = sub_080045D4(ent->x.HALF.HI, ent->y.HALF.HI, b, c);
u32 tmp = CalculateDirectionTo(ent->x.HALF.HI, ent->y.HALF.HI, b, c);
return ent->animationState == sub_0806F5A4(tmp);
}
@@ -247,7 +247,7 @@ u32 sub_0806F804(u32 x, u32 y) {
}
u32 sub_0806F824(Entity* a, Entity* b, s32 x, s32 y) {
return sub_080045D4(a->x.HALF.HI, a->y.HALF.HI, b->x.HALF.HI + x, b->y.HALF.HI + y);
return CalculateDirectionTo(a->x.HALF.HI, a->y.HALF.HI, b->x.HALF.HI + x, b->y.HALF.HI + y);
}
u32 sub_0806F854(Entity* ent, s32 x, s32 y) {
+1 -1
View File
@@ -518,7 +518,7 @@ void sub_08021424(Entity* this) {
if (!(6 < (x - this->x.HALF.HI) + 3U) && !(4 < (y - this->y.HALF.HI) + 2U)) {
sub_080212B0(this);
} else {
this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, x, y);
this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, x, y);
if (!ProcessMovement(this)) {
sub_080212B0(this);
} else {
+1 -1
View File
@@ -306,7 +306,7 @@ void sub_0803797C(GibdoEntity* this) {
super->actionDelay = 0x18;
super->field_0xf = 8;
m = super->direction =
(sub_080045D4(super->x.HALF.HI, super->y.HALF.HI, this->field_0x78, this->field_0x7a) + 4) & 0x18;
(CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, this->field_0x78, this->field_0x7a) + 4) & 0x18;
;
m = m / 8;
if (m != super->animationState) {
+1 -1
View File
@@ -269,7 +269,7 @@ void sub_0803CA84(Entity* this, u32 unkParameter) {
void sub_0803CAD0(Entity* this) {
if (EntityWithinDistance(this, this->field_0x74.HWORD, this->field_0x76.HWORD, 1) == 0) {
this->direction =
sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, this->field_0x74.HWORD, this->field_0x76.HWORD);
CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, this->field_0x74.HWORD, this->field_0x76.HWORD);
sub_080AEFE0(this);
}
+3 -3
View File
@@ -1109,7 +1109,7 @@ u32 sub_0803B4E4(Entity* this) {
this->y.HALF.HI = yoff;
return 1;
} else {
this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, xoff, yoff);
this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, xoff, yoff);
return 0;
}
}
@@ -1177,9 +1177,9 @@ void sub_0803B63C(Entity* this) {
x += gUnk_080CFD19[this->type];
y = gPlayerEntity.y.HALF.HI - 0xc;
if (this->actionDelay++ >= 0xb5) {
this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, x, y);
this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, x, y);
} else {
sub_08004596(this, sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, x, y));
sub_08004596(this, CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, x, y));
}
}
+1 -1
View File
@@ -247,7 +247,7 @@ void sub_0803414C(Entity* this) {
}
}
} else {
this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, x, y);
this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, x, y);
LinearMoveUpdate(this);
}
}
+2 -2
View File
@@ -178,8 +178,8 @@ void sub_08025230(Entity* this) {
void sub_080252E0(Entity* this) {
u32 tile;
this->direction =
sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, (u16)this->field_0x7c.HALF.LO, (u16)this->field_0x7c.HALF.HI);
this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, (u16)this->field_0x7c.HALF.LO,
(u16)this->field_0x7c.HALF.HI);
sub_08025C44(this);
GetNextFrame(this);
+3 -3
View File
@@ -642,8 +642,8 @@ void sub_08042E30(Entity* this) {
this->actionDelay = (Random() & 0x38) + 0x28;
this->speed = 0x200;
this->direction = pVVar9->unk00.HALF.HI >> 3;
uVar6 = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, gRoomControls.origin_x + 0x110,
gRoomControls.origin_y + 0x60);
uVar6 = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, gRoomControls.origin_x + 0x110,
gRoomControls.origin_y + 0x60);
this->field_0x78.HALF.HI = (gUnk_080D1304[Random() & 7] + uVar6) & 0x1f;
}
pVVar9->unk00.HWORD += pVVar9->unk08;
@@ -687,7 +687,7 @@ void sub_08042EF4(Entity* this) {
x = this->parent->x.HALF.HI;
y = this->parent->y.HALF.HI - 0x10;
if (EntityWithinDistance(this, x, y, 0x30)) {
temp = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, x, y);
temp = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, x, y);
if ((this->field_0x78.HALF.HI - temp) + 4 < 9) {
this->field_0x78.HALF.HI = temp ^ 0x10;
}
+2 -2
View File
@@ -878,7 +878,7 @@ void sub_080406A0(Entity* this) {
uVar4 = gRoomControls.origin_y + gUnk_080D0B58[tmp + 1];
}
}
uVar3 = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, uVar6, uVar4);
uVar3 = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, uVar6, uVar4);
this->direction = uVar3;
if (uVar2 & 0x20) {
u32 tmp = this->direction;
@@ -965,7 +965,7 @@ void sub_08040770(Entity* this) {
tmp6 = gRoomControls.origin_y + gUnk_080D0B64[tmp3 + 1];
}
}
this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, tmp5, tmp6);
this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, tmp5, tmp6);
if (tmp & 0x20) {
u32 tmp3 = this->direction;
if (tmp & 0x10) {
+3 -3
View File
@@ -829,11 +829,11 @@ u32 sub_0804207C(Entity* this) {
y = this->y.HALF.HI - 0x10;
arm = ((VaatiWrathHeapStruct*)this->myHeap)->arms[0];
if ((arm != NULL) && (arm->action >= 5) && EntityWithinDistance(arm, x, y, 0x30)) {
return sub_080045D4(arm->x.HALF.HI, arm->y.HALF.HI, x, y);
return CalculateDirectionTo(arm->x.HALF.HI, arm->y.HALF.HI, x, y);
} else {
arm = ((VaatiWrathHeapStruct*)this->myHeap)->arms[1];
if (((arm != NULL) && (arm->action >= 5)) && EntityWithinDistance(arm, x, y, 0x30)) {
return sub_080045D4(arm->x.HALF.HI, arm->y.HALF.HI, x, y);
return CalculateDirectionTo(arm->x.HALF.HI, arm->y.HALF.HI, x, y);
} else {
if (gPlayerEntity.y.HALF.HI < 0x40) {
tmp = gRoomControls.origin_y + 0x18;
@@ -841,7 +841,7 @@ u32 sub_0804207C(Entity* this) {
} else {
tmp = gPlayerEntity.y.HALF.HI - 0x28;
}
return sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, gPlayerEntity.x.HALF.HI, tmp);
return CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, gPlayerEntity.x.HALF.HI, tmp);
}
}
}
+1 -1
View File
@@ -86,7 +86,7 @@ void VaatiWrathEyeAction3(Entity* this) {
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);
direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, x, y);
this->direction = direction;
LinearMoveUpdate(this);
this->z.HALF.HI = this->parent->z.HALF.HI;
+157
View File
@@ -0,0 +1,157 @@
/**
* @file wizzrobeFire.c
* @ingroup Enemies
*
* @brief Wizzrobe Fire enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "enemy.h"
#include "enemy/wizzrobe.h"
#include "functions.h"
extern void (*const WizzrobeFire_Functions[])(WizzrobeEntity*);
extern void (*const WizzrobeFire_Actions[])(WizzrobeEntity*);
void WizzrobeFire(WizzrobeEntity* this) {
WizzrobeFire_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
}
void WizzrobeFire_OnTick(WizzrobeEntity* this) {
WizzrobeFire_Actions[super->action](this);
}
void sub_0802FB74(WizzrobeEntity* this) {
if (super->field_0x43 != 0) {
sub_0804A9FC(super, 0x1c);
}
sub_0804AA30(super, WizzrobeFire_Functions);
if (super->health == 0) {
SetTile(this->tileIndex, this->tilePosition, super->collisionLayer);
}
}
void WizzrobeFire_Init(WizzrobeEntity* this) {
Entity* projectile;
sub_0804A720(super);
super->action = 1;
this->timer2 = 0xff;
this->timer1 = 0x28;
super->actionDelay = 0x28;
super->field_0xf = 0x60;
sub_0802F888(this);
projectile = CreateProjectileWithParent(super, FIRE_PROJECTILE, 0);
if (projectile != NULL) {
super->child = projectile;
projectile->parent = super;
projectile->direction = super->direction;
}
InitializeAnimation(super, super->direction >> 3);
}
void WizzrobeFire_Action1(WizzrobeEntity* this) {
u8 tmp;
Entity* child;
switch (this->timer2) {
case 0xff:
if (--super->field_0xf == 0) {
this->timer2 = 0;
}
break;
case 0:
if (--super->actionDelay == 0) {
this->timer2 += 1;
super->actionDelay = 0x0e;
super->flags |= 0x80;
}
break;
case 1:
if (--super->actionDelay == 0) {
super->action = 2;
this->timer2 = 0;
super->actionDelay = 0x20;
tmp = super->direction >> 3;
child = super->child;
child->actionDelay = 1;
child->spriteSettings.draw = 1;
InitializeAnimation(super, tmp | 4);
}
break;
}
sub_0802F9C8(this);
}
void WizzrobeFire_Action2(WizzrobeEntity* this) {
switch (this->timer2) {
case 0:
switch (--super->actionDelay) {
case 0:
this->timer2 += 1;
super->actionDelay = 0x38;
super->field_0xf = 0;
super->child->spriteSettings.draw = 0;
break;
case 6:
if (EntityInRectRadius(super, &gPlayerEntity, 0xa0, 0xa0) && CheckOnScreen(super)) {
Entity* projectile = CreateProjectileWithParent(super, FIRE_PROJECTILE, 1);
if (projectile != NULL) {
projectile->direction = super->direction & 0x18;
}
}
break;
}
break;
case 1:
if (--super->actionDelay == 0) {
this->timer2++;
this->timer1 = 0x28;
super->actionDelay = 0x28;
super->field_0xf = 0;
super->flags &= 0x7f;
SetTile(this->tileIndex, this->tilePosition, super->collisionLayer);
EnqueueSFX(SFX_156);
InitializeAnimation(super, super->direction >> 3);
}
break;
case 2:
if (--super->actionDelay == 0) {
this->timer2++;
super->actionDelay = (Random() & 0x3f) + 0x1c;
super->spriteSettings.draw = 0;
}
break;
case 3:
if (--super->actionDelay == 0) {
super->action = 1;
this->timer2 = 0;
this->timer1 = 0x28;
super->actionDelay = 0x28;
EnqueueSFX(SFX_156);
sub_0802F8E4(this);
InitializeAnimation(super, super->direction >> 3);
}
break;
}
sub_0802F9C8(this);
}
void (*const WizzrobeFire_Functions[])(WizzrobeEntity*) = {
WizzrobeFire_OnTick,
sub_0802FB74,
(void (*)(WizzrobeEntity*))sub_08001324,
(void (*)(WizzrobeEntity*))sub_0804A7D4,
(void (*)(WizzrobeEntity*))sub_08001242,
WizzrobeFire_OnTick,
};
void (*const WizzrobeFire_Actions[])(WizzrobeEntity*) = {
WizzrobeFire_Init,
WizzrobeFire_Action1,
WizzrobeFire_Action2,
};
+163
View File
@@ -0,0 +1,163 @@
/**
* @file wizzrobeIce.c
* @ingroup Enemies
*
* @brief Wizzrobe Ice enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "enemy.h"
#include "enemy/wizzrobe.h"
#include "functions.h"
#include "object.h"
extern void (*const WizzrobeIce_Functions[])(WizzrobeEntity*);
extern void (*const WizzrobeIce_Actions[])(WizzrobeEntity*);
void WizzrobeIce(WizzrobeEntity* this) {
WizzrobeIce_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
}
void WizzrobeIce_OnTick(WizzrobeEntity* this) {
WizzrobeIce_Actions[super->action](this);
}
void sub_0802FE18(WizzrobeEntity* this) {
if (super->field_0x43 != 0) {
sub_0804A9FC(super, 0x1c);
}
sub_0804AA30(super, WizzrobeIce_Functions);
if (super->bitfield == 0x87) {
Entity* obj = CreateObject(OBJECT_2A, 3, 0);
if (obj != NULL) {
obj->spritePriority.b0 = 3;
obj->spriteOffsetY = -4;
obj->parent = super;
}
}
if (super->health == 0) {
SetTile(this->tileIndex, this->tilePosition, super->collisionLayer);
}
}
void WizzrobeIce_Init(WizzrobeEntity* this) {
Entity* projectile;
sub_0804A720(super);
super->action = 1;
this->timer2 = 0xff;
this->timer1 = 0x28;
super->actionDelay = 0x28;
super->field_0xf = 0x60;
sub_0802F888(this);
projectile = CreateProjectileWithParent(super, ICE_PROJECTILE, 0);
if (projectile != NULL) {
super->child = projectile;
projectile->parent = super;
projectile->direction = super->direction;
}
InitializeAnimation(super, super->direction >> 3);
}
void WizzrobeIce_Action1(WizzrobeEntity* this) {
u8 tmp;
Entity* child;
switch (this->timer2) {
case 0xff:
if (--super->field_0xf == 0) {
this->timer2 = 0;
}
break;
case 0:
if (--super->actionDelay == 0) {
this->timer2++;
super->actionDelay = 0xc;
super->flags |= 0x80;
}
break;
case 1:
if (--super->actionDelay == 0) {
super->action = 2;
this->timer2 = 0;
super->actionDelay = 0x20;
tmp = super->direction >> 3;
child = super->child;
child->actionDelay = 1;
child->spriteSettings.draw = 1;
InitializeAnimation(super, tmp | 4);
}
break;
}
sub_0802F9C8(this);
}
void WizzrobeIce_Action2(WizzrobeEntity* this) {
switch (this->timer2) {
case 0:
switch (--super->actionDelay) {
case 0:
this->timer2 += 1;
super->actionDelay = 0x38;
super->field_0xf = 0;
super->child->spriteSettings.draw = 0;
break;
case 0xa:
if (EntityInRectRadius(super, &gPlayerEntity, 0xa0, 0xa0) && CheckOnScreen(super)) {
Entity* projectile = CreateProjectileWithParent(super, ICE_PROJECTILE, 1);
if (projectile != NULL) {
projectile->direction = super->direction & 0x18;
}
}
break;
}
break;
case 1:
if (--super->actionDelay == 0) {
this->timer2++;
this->timer1 = 0x28;
super->actionDelay = 0x28;
super->field_0xf = 0;
super->flags &= 0x7f;
SetTile(this->tileIndex, this->tilePosition, super->collisionLayer);
EnqueueSFX(SFX_156);
InitializeAnimation(super, super->direction >> 3);
}
break;
case 2:
if (--super->actionDelay == 0) {
this->timer2++;
super->actionDelay = (Random() & 0x3f) + 0x18;
super->spriteSettings.draw = 0;
}
break;
case 3:
if (--super->actionDelay == 0) {
super->action = 1;
this->timer2 = 0;
this->timer1 = 0x28;
super->actionDelay = 0x28;
EnqueueSFX(SFX_156);
sub_0802F8E4(this);
InitializeAnimation(super, super->direction >> 3);
}
break;
}
sub_0802F9C8(this);
}
void (*const WizzrobeIce_Functions[])(WizzrobeEntity*) = {
WizzrobeIce_OnTick,
sub_0802FE18,
(void (*)(WizzrobeEntity*))sub_08001324,
(void (*)(WizzrobeEntity*))sub_0804A7D4,
(void (*)(WizzrobeEntity*))sub_08001242,
WizzrobeIce_OnTick,
};
void (*const WizzrobeIce_Actions[])(WizzrobeEntity*) = {
WizzrobeIce_Init,
WizzrobeIce_Action1,
WizzrobeIce_Action2,
};
+329
View File
@@ -0,0 +1,329 @@
/**
* @file wizzrobeWind.c
* @ingroup Enemies
*
* @brief Wizzrobe Wind enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "enemy.h"
#include "enemy/wizzrobe.h"
#include "functions.h"
#include "object.h"
extern void (*const WizzrobeWind_Functions[])(WizzrobeEntity*);
extern void (*const WizzrobeWind_Actions[])(WizzrobeEntity*);
void sub_0802F888(WizzrobeEntity*);
void sub_0802FA48(WizzrobeEntity*);
bool32 sub_0802FA88(WizzrobeEntity*);
void sub_0802F9C8(WizzrobeEntity*);
void sub_0802F8E4(WizzrobeEntity*);
void WizzrobeWind(WizzrobeEntity* this) {
WizzrobeWind_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
}
void WizzrobeWind_OnTick(WizzrobeEntity* this) {
WizzrobeWind_Actions[super->action](this);
}
void sub_0802F4E4(WizzrobeEntity* this) {
if (super->field_0x43 != 0) {
sub_0804A9FC(super, 0x1c);
}
sub_0804AA30(super, WizzrobeWind_Functions);
if (super->bitfield == 0x87) {
Entity* obj = CreateObject(OBJECT_2A, 3, 0);
if (obj != NULL) {
obj->spritePriority.b0 = 3;
obj->spriteOffsetY = -4;
obj->parent = super;
}
}
if (super->health == 0) {
SetTile(this->tileIndex, this->tilePosition, super->collisionLayer);
}
}
void WizzrobeWind_Init(WizzrobeEntity* this) {
Entity* projectile;
if (super->type2 != 0) {
super->action = 3;
super->speed = 0xc0;
super->flags |= 0x80;
this->targetIndex = 0;
super->child = (Entity*)GetCurrentRoomProperty(super->actionDelay);
sub_0802FA48(this);
sub_0802FA88(this);
} else {
sub_0804A720(super);
super->action = 1;
this->timer2 = 0xff;
this->timer1 = 0x28;
super->actionDelay = 0x28;
super->field_0xf = 0x60;
sub_0802F888(this);
}
projectile = CreateProjectileWithParent(super, WIND_PROJECTILE, 0);
if (projectile != NULL) {
super->parent = projectile;
projectile->parent = super;
projectile->direction = super->direction;
}
InitializeAnimation(super, super->direction >> 3);
}
void WizzrobeWind_Action1(WizzrobeEntity* this) {
u8 tmp;
Entity* parent;
switch (this->timer2) {
case 0xff:
if (--super->field_0xf == 0) {
this->timer2 = 0;
}
break;
case 0:
if (--super->actionDelay == 0) {
this->timer2++;
super->actionDelay = 0x10;
super->flags |= 0x80;
}
break;
case 1:
if (--super->actionDelay == 0) {
super->action = 2;
this->timer2 = 0;
super->actionDelay = 0x28;
tmp = super->direction >> 3;
parent = super->parent;
parent->actionDelay = 1;
parent->spriteSettings.draw = 1;
InitializeAnimation(super, tmp | 4);
}
break;
}
sub_0802F9C8(this);
}
void WizzrobeWind_Action2(WizzrobeEntity* this) {
switch (this->timer2) {
case 0:
switch (--super->actionDelay) {
case 0:
this->timer2++;
super->actionDelay = 0x38;
super->field_0xf = 0;
super->parent->spriteSettings.draw = 0;
break;
case 8:
if (EntityInRectRadius(super, &gPlayerEntity, 0xa0, 0xa0) && CheckOnScreen(super)) {
Entity* projectile = CreateProjectileWithParent(super, WIND_PROJECTILE, 1);
if (projectile != NULL) {
projectile->direction = super->direction & 0x18;
}
}
break;
}
break;
case 1:
if (--super->actionDelay == 0) {
this->timer2++;
this->timer1 = 0x28;
super->actionDelay = 0x28;
super->field_0xf = 0;
super->flags &= 0x7f;
EnqueueSFX(SFX_156);
SetTile(this->tileIndex, this->tilePosition, super->collisionLayer);
InitializeAnimation(super, super->direction >> 3);
}
break;
case 2:
if (--super->actionDelay == 0) {
this->timer2++;
super->actionDelay = (Random() & 0x3f) + 0x20;
super->spriteSettings.draw = 0;
}
break;
case 3:
if (--super->actionDelay == 0) {
super->action = 1;
this->timer2 = 0;
this->timer1 = 0x28;
super->actionDelay = 0x28;
EnqueueSFX(SFX_156);
sub_0802F8E4(this);
InitializeAnimation(super, super->direction >> 3);
}
break;
}
sub_0802F9C8(this);
}
void WizzrobeWind_Action3(WizzrobeEntity* this) {
Entity* parent;
sub_0802FA88(this);
sub_0802F9C8(this);
parent = super->parent;
if (this->timer1 == 0) {
switch (this->timer2) {
case 0:
this->timer2 = 1;
super->actionDelay = 0x40;
break;
case 1:
if (--super->actionDelay != 0) {
return;
}
this->timer2++;
super->actionDelay = 0x28;
parent->actionDelay = 1;
parent->spriteSettings.draw = 1;
InitializeAnimation(super, super->animationState >> 1 | 4);
break;
case 2:
if (--super->actionDelay == 0) {
this->timer2++;
super->actionDelay = (Random() & 0x1f) + 0x30;
parent->spriteSettings.draw = 0;
InitializeAnimation(super, super->animationState >> 1);
} else if (super->actionDelay == 8) {
parent = CreateProjectileWithParent(super, WIND_PROJECTILE, 1);
if (parent != NULL) {
parent->direction = super->direction & 0x18;
}
}
}
} else {
if (this->timer2 != 0) {
this->timer2 = 0;
parent->spriteSettings.draw = 0;
}
}
}
void sub_0802F888(WizzrobeEntity* this) {
super->direction = (sub_08049F84(super, 3) + 4) & 0x18;
this->tilePosition = COORD_TO_TILE(super);
this->tileIndex = GetTileIndex(this->tilePosition, super->collisionLayer);
SetTile(0x4071, this->tilePosition, super->collisionLayer);
}
void sub_0802F8E4(WizzrobeEntity* this) {
u16 uVar1;
s32 iVar4;
u32 uVar6;
u32 uVar7;
u32 uVar8;
bool32 loopCondition;
u32 rand;
if (super->type2 == 0) {
loopCondition = TRUE;
do {
rand = Random();
uVar1 = this->unk_70;
iVar4 = ((s32)rand & 0x7ff0) % (this->unk_6e << 3);
uVar8 = (uVar1 + iVar4) | 8;
rand >>= 0x10;
uVar1 = this->unk_72;
iVar4 = ((s32)(rand)&0x7ff0) % (this->unk_6f << 3);
uVar7 = (uVar1 + iVar4) | 8;
uVar6 = TILE(uVar8, uVar7);
if ((sub_080002E0(uVar6, super->collisionLayer) == 0) &&
(GetTileIndex(uVar6, super->collisionLayer) != 0x4071)) {
super->x.HALF.HI = (s16)uVar8;
super->y.HALF.HI = (s16)uVar7;
if (sub_08049FA0(super) != 0) {
loopCondition = FALSE;
}
}
} while (loopCondition);
sub_0802F888(this);
}
}
void sub_0802F9C8(WizzrobeEntity* this) {
if (super->field_0xf == 0) {
if (this->timer1 != 0) {
if ((--this->timer1 & 1) != 0) {
super->spriteSettings.draw = 0;
} else {
super->spriteSettings.draw = 1;
}
if ((super->type2 != 0) && (LinearMoveUpdate(super), this->timer1 == 0)) {
super->flags |= 0x80;
}
} else {
if (super->type2 != 0) {
ProcessMovement(super);
if (super->collisions != 0) {
super->flags &= 0x7f;
this->timer1 = 0x28;
}
}
}
GetNextFrame(super);
}
}
void sub_0802FA48(WizzrobeEntity* this) {
u16* target;
u16* child;
child = (u16*)super->child;
target = &child[this->targetIndex * 2];
if (target[0] == 0xffff) {
this->targetIndex = 0;
target = child;
}
this->targetX = gRoomControls.origin_x + target[0];
this->targetY = gRoomControls.origin_y + target[1];
}
bool32 sub_0802FA88(WizzrobeEntity* this) {
u32 direction;
bool32 result = FALSE;
if (EntityWithinDistance(super, this->targetX, this->targetY, 2)) {
this->targetIndex++;
sub_0802FA48(this);
direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, this->targetX, this->targetY);
super->direction = direction;
super->animationState = ((direction + 4) & 0x18) >> 2;
if (((super->parent)->spriteSettings.draw & 3) != 0) {
InitializeAnimation(super, direction >> 3 | 4);
} else {
InitializeAnimation(super, direction >> 3);
}
result = TRUE;
} else {
direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, this->targetX, this->targetY);
sub_08004596(super, direction);
direction = ((super->direction + 4) & 0x18) >> 2;
if (direction != super->animationState) {
super->animationState = direction;
InitializeAnimation(super, direction >> 1);
}
}
return result;
}
void (*const WizzrobeWind_Functions[])(WizzrobeEntity*) = {
WizzrobeWind_OnTick,
sub_0802F4E4,
(void (*)(WizzrobeEntity*))sub_08001324,
(void (*)(WizzrobeEntity*))sub_0804A7D4,
(void (*)(WizzrobeEntity*))sub_08001242,
WizzrobeWind_OnTick,
};
void (*const WizzrobeWind_Actions[])(WizzrobeEntity*) = {
WizzrobeWind_Init,
WizzrobeWind_Action1,
WizzrobeWind_Action2,
WizzrobeWind_Action3,
};
+2 -1
View File
@@ -37,7 +37,8 @@ void sub_0806D8A0(Entity* this, ScriptExecutionContext* context) {
}
void sub_0806D908(Entity* this) {
this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI);
this->direction =
CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI);
this->animationState = (this->animationState & 0x80) | gUnk_08114144[this->direction >> 0x1];
}
+2 -2
View File
@@ -384,7 +384,7 @@ void sub_08061090(Entity* this, u32 a, u32 b) {
}
void sub_08061120(Entity* this, u32 param_a, u32 param_b, u32 param_c) {
this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, param_a, param_b);
this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, param_a, param_b);
if ((param_c != this->field_0x6c.HALF.LO) || (10 < ((this->direction + this->animationState * -4 + 5) & 0x1f))) {
this->animationState = DirectionRoundUp(this->direction) >> 2;
sub_08060E70(this, param_c);
@@ -566,7 +566,7 @@ void sub_08061464(Entity* this, u32 param_a, u32 param_b) {
iVar10 = this->x.HALF.HI;
iVar9 = this->y.HALF.HI;
switch (((sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, param_a, param_b) + 2) & 0x1c) >> 2) {
switch (((CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, param_a, param_b) + 2) & 0x1c) >> 2) {
case 0:
this->field_0x6e.HWORD = param_b;
if (this->x.HALF.HI > (s32)param_a) {
+3 -3
View File
@@ -420,7 +420,7 @@ void sub_080871F8(Entity* this) {
if ((temp->x.HALF.HI == this->x.HALF.HI) && (temp->y.HALF.HI - 32 == this->y.HALF.HI)) {
this->action = 2;
} else {
this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, temp->x.HALF.HI, temp->y.HALF.HI - 32);
this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, temp->x.HALF.HI, temp->y.HALF.HI - 32);
LinearMoveUpdate(this);
}
}
@@ -467,8 +467,8 @@ void sub_080872F8(Entity* this) {
GetNextFrame(this);
if (((u16)(this->field_0x68.HWORD - this->x.HALF.HI) > 0xc) ||
((u16)(this->field_0x6a.HWORD - this->y.HALF.HI) > 0xc)) {
this->direction =
sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, (s16)this->field_0x68.HWORD, (s16)this->field_0x6a.HWORD);
this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, (s16)this->field_0x68.HWORD,
(s16)this->field_0x6a.HWORD);
this->direction = (this->direction + gUnk_081207AC[Random() & 3]) & 0x1f;
}
temp = gSineTable[this->actionDelay + 64];
+4 -4
View File
@@ -1076,7 +1076,7 @@ static void PortalJumpOnUpdate(Entity* this) {
y = gArea.curPortalY;
if ((this->x.HALF.HI != x) || (this->y.HALF.HI != y)) {
this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, gArea.curPortalX, gArea.curPortalY);
this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, gArea.curPortalX, gArea.curPortalY);
this->speed = JUMP_SPEED_FWD;
UpdatePlayerMovement();
}
@@ -3184,7 +3184,7 @@ static void sub_08073F4C(Entity* this) {
u32 x = gArea.curPortalX;
u32 y = gArea.curPortalY;
if (this->x.HALF.HI != x || this->y.HALF.HI != y) {
this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, gArea.curPortalX, gArea.curPortalY);
this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, gArea.curPortalX, gArea.curPortalY);
this->speed = 0x100;
LinearMoveUpdate(this);
} else {
@@ -3472,8 +3472,8 @@ void SurfaceAction_16(Entity* this) {
SoundReq(SFX_PLY_VO6);
this->iframes = 24;
this->knockbackDuration = 4;
this->knockbackDirection = sub_080045D4((this->x.HALF.HI & 0xFFF0) | 8, (this->y.HALF.HI & 0xFFF0) | 8,
this->x.HALF.HI, this->y.HALF.HI);
this->knockbackDirection = CalculateDirectionTo(
(this->x.HALF.HI & 0xFFF0) | 8, (this->y.HALF.HI & 0xFFF0) | 8, this->x.HALF.HI, this->y.HALF.HI);
}
if ((gPlayerState.flags & PL_MINISH) == 0)
sub_08008790(this, 7);