mirror of
https://github.com/zeldaret/oot.git
synced 2025-08-05 22:00:15 +00:00
ovl_Item_Shield OK (#717)
* ovl_Item_Shield OK * ovl_Item_Shield fix spec * review changes * review comments 2
This commit is contained in:
parent
7c5ae8cc03
commit
8e0fa07a7e
14 changed files with 196 additions and 720 deletions
|
@ -4,6 +4,7 @@
|
|||
* Description: Deku Shield
|
||||
*/
|
||||
|
||||
#include "vt.h"
|
||||
#include "z_item_shield.h"
|
||||
|
||||
#define FLAGS 0x00000010
|
||||
|
@ -15,22 +16,12 @@ void ItemShield_Destroy(Actor* thisx, GlobalContext* globalCtx);
|
|||
void ItemShield_Update(Actor* thisx, GlobalContext* globalCtx);
|
||||
void ItemShield_Draw(Actor* thisx, GlobalContext* globalCtx);
|
||||
|
||||
extern UNK_TYPE D_060224F8;
|
||||
void func_80B86F68(ItemShield* this, GlobalContext* globalCtx);
|
||||
void func_80B86BC8(ItemShield* this, GlobalContext* globalCtx);
|
||||
|
||||
/*
|
||||
const ActorInit Item_Shield_InitVars = {
|
||||
ACTOR_ITEM_SHIELD,
|
||||
ACTORCAT_ITEMACTION,
|
||||
FLAGS,
|
||||
OBJECT_LINK_CHILD,
|
||||
sizeof(ItemShield),
|
||||
(ActorFunc)ItemShield_Init,
|
||||
(ActorFunc)ItemShield_Destroy,
|
||||
(ActorFunc)ItemShield_Update,
|
||||
(ActorFunc)ItemShield_Draw,
|
||||
};
|
||||
extern Gfx D_060224F8[];
|
||||
|
||||
static ColliderCylinderInit D_80B871A0 = {
|
||||
static ColliderCylinderInit sCylinderInit = {
|
||||
{
|
||||
COLTYPE_NONE,
|
||||
AT_NONE,
|
||||
|
@ -49,21 +40,192 @@ static ColliderCylinderInit D_80B871A0 = {
|
|||
},
|
||||
{ 15, 15, 0, { 0, 0, 0 } },
|
||||
};
|
||||
*/
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Shield/func_80B86920.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Shield/ItemShield_Init.s")
|
||||
const ActorInit Item_Shield_InitVars = {
|
||||
ACTOR_ITEM_SHIELD,
|
||||
ACTORCAT_ITEMACTION,
|
||||
FLAGS,
|
||||
OBJECT_LINK_CHILD,
|
||||
sizeof(ItemShield),
|
||||
(ActorFunc)ItemShield_Init,
|
||||
(ActorFunc)ItemShield_Destroy,
|
||||
(ActorFunc)ItemShield_Update,
|
||||
(ActorFunc)ItemShield_Draw,
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Shield/ItemShield_Destroy.s")
|
||||
static Color_RGBA8 unused = { 255, 255, 0, 255 };
|
||||
static Color_RGBA8 unused2 = { 255, 0, 0, 255 };
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Shield/func_80B86AC8.s")
|
||||
void ItemShield_SetupAction(ItemShield* this, ItemShieldActionFunc actionFunc) {
|
||||
this->actionFunc = actionFunc;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Shield/func_80B86BC8.s")
|
||||
void ItemShield_Init(Actor* thisx, GlobalContext* globalCtx) {
|
||||
ItemShield* this = THIS;
|
||||
s32 i;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Shield/func_80B86CA8.s")
|
||||
this->timer = 0;
|
||||
this->unk_19C = 0;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Shield/func_80B86F68.s")
|
||||
switch (this->actor.params) {
|
||||
case 0:
|
||||
ActorShape_Init(&this->actor.shape, 1400.0f, NULL, 0.0f);
|
||||
this->actor.shape.rot.x = 0x4000;
|
||||
ItemShield_SetupAction(this, func_80B86BC8);
|
||||
break;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Shield/ItemShield_Update.s")
|
||||
case 1:
|
||||
ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f);
|
||||
ItemShield_SetupAction(this, func_80B86F68);
|
||||
this->unk_19C |= 2;
|
||||
for (i = 0; i < 8; i++) {
|
||||
this->unk_19E[i] = 1 + 2 * i;
|
||||
this->unk_1A8[i].x = Rand_CenteredFloat(10.0f);
|
||||
this->unk_1A8[i].y = Rand_CenteredFloat(10.0f);
|
||||
this->unk_1A8[i].z = Rand_CenteredFloat(10.0f);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Shield/ItemShield_Draw.s")
|
||||
Actor_SetScale(&this->actor, 0.01f);
|
||||
Collider_InitCylinder(globalCtx, &this->collider);
|
||||
Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit);
|
||||
osSyncPrintf(VT_FGCOL(GREEN) "Item_Shild %d \n" VT_RST, this->actor.params);
|
||||
}
|
||||
|
||||
void ItemShield_Destroy(Actor* thisx, GlobalContext* globalCtx) {
|
||||
ItemShield* this = THIS;
|
||||
|
||||
Collider_DestroyCylinder(globalCtx, &this->collider);
|
||||
}
|
||||
|
||||
void func_80B86AC8(ItemShield* this, GlobalContext* globalCtx) {
|
||||
Actor_MoveForward(&this->actor);
|
||||
if (Actor_HasParent(&this->actor, globalCtx)) {
|
||||
Actor_Kill(&this->actor);
|
||||
return;
|
||||
}
|
||||
func_8002F434(&this->actor, globalCtx, GI_SHIELD_DEKU, 30.0f, 50.0f);
|
||||
Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 0.0f, 5);
|
||||
if (this->actor.bgCheckFlags & 1) {
|
||||
this->timer--;
|
||||
if (this->timer < 60) {
|
||||
if (this->timer & 1) {
|
||||
this->unk_19C |= 2;
|
||||
} else {
|
||||
this->unk_19C &= ~2;
|
||||
}
|
||||
}
|
||||
if (this->timer == 0) {
|
||||
Actor_Kill(&this->actor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void func_80B86BC8(ItemShield* this, GlobalContext* globalCtx) {
|
||||
if (Actor_HasParent(&this->actor, globalCtx)) {
|
||||
Actor_Kill(&this->actor);
|
||||
return;
|
||||
}
|
||||
func_8002F434(&this->actor, globalCtx, GI_SHIELD_DEKU, 30.0f, 50.0f);
|
||||
if (this->collider.base.acFlags & AC_HIT) {
|
||||
ItemShield_SetupAction(this, func_80B86AC8);
|
||||
this->actor.velocity.y = 4.0f;
|
||||
this->actor.minVelocityY = -4.0f;
|
||||
this->actor.gravity = -0.8f;
|
||||
this->actor.speedXZ = 0.0f;
|
||||
this->timer = 160;
|
||||
} else {
|
||||
Collider_UpdateCylinder(&this->actor, &this->collider);
|
||||
CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base);
|
||||
}
|
||||
}
|
||||
|
||||
void func_80B86CA8(ItemShield* this, GlobalContext* globalCtx) {
|
||||
static Vec3f D_80B871F4 = { 0.0f, 0.0f, 0.0f };
|
||||
static f32 D_80B87200[] = { 0.3f, 0.6f, 0.9f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
|
||||
1.0f, 0.85f, 0.7f, 0.55f, 0.4f, 0.25f, 0.1f, 0.0f };
|
||||
static f32 D_80B87240[] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.8f,
|
||||
0.6f, 0.4f, 0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
s32 i;
|
||||
s32 temp;
|
||||
|
||||
Actor_MoveForward(&this->actor);
|
||||
Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 0.0f, 5);
|
||||
this->actor.shape.yOffset = ABS(Math_SinS(this->actor.shape.rot.x)) * 1500.0f;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
temp = 15 - this->unk_19E[i];
|
||||
D_80B871F4.x = this->unk_1A8[i].x;
|
||||
D_80B871F4.y = this->unk_1A8[i].y + (this->actor.shape.yOffset * 0.01f) + (D_80B87200[temp] * -10.0f * 0.2f);
|
||||
D_80B871F4.z = this->unk_1A8[i].z;
|
||||
EffectSsFireTail_SpawnFlame(globalCtx, &this->actor, &D_80B871F4, D_80B87200[temp] * 0.2f, -1, D_80B87240[temp]);
|
||||
if (this->unk_19E[i] != 0) {
|
||||
this->unk_19E[i]--;
|
||||
} else if (this->timer > 16) {
|
||||
this->unk_19E[i] = 15;
|
||||
this->unk_1A8[i].x = Rand_CenteredFloat(15.0f);
|
||||
this->unk_1A8[i].y = Rand_CenteredFloat(10.0f);
|
||||
this->unk_1A8[i].z = Rand_CenteredFloat(15.0f);
|
||||
}
|
||||
}
|
||||
if (this->actor.bgCheckFlags & 1) {
|
||||
this->unk_198 -= this->actor.shape.rot.x >> 1;
|
||||
this->unk_198 -= this->unk_198 >> 2;
|
||||
this->actor.shape.rot.x += this->unk_198;
|
||||
if ((this->timer >= 8) && (this->timer < 24)) {
|
||||
Actor_SetScale(&this->actor, (this->timer - 8) * 0.000625f);
|
||||
}
|
||||
if (this->timer != 0) {
|
||||
this->timer--;
|
||||
} else {
|
||||
Actor_Kill(&this->actor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void func_80B86F68(ItemShield* this, GlobalContext* globalCtx) {
|
||||
s32 pad;
|
||||
Player* player = PLAYER;
|
||||
MtxF* shield = &player->shieldMf;
|
||||
|
||||
this->actor.world.pos.x = shield->wx;
|
||||
this->actor.world.pos.y = shield->wy;
|
||||
this->actor.world.pos.z = shield->wz;
|
||||
this->unk_19C &= ~2;
|
||||
|
||||
this->actor.shape.rot.y = Math_Atan2S(-shield->zz, -shield->zx);
|
||||
this->actor.shape.rot.x = Math_Atan2S(-shield->zy, sqrtf(shield->zz * shield->zz + shield->zx * shield->zx));
|
||||
|
||||
if (ABS(this->actor.shape.rot.x) > 0x4000) {
|
||||
this->unk_19C |= 1;
|
||||
}
|
||||
|
||||
ItemShield_SetupAction(this, func_80B86CA8);
|
||||
|
||||
this->actor.velocity.y = 4.0;
|
||||
this->actor.minVelocityY = -4.0;
|
||||
this->actor.gravity = -0.8;
|
||||
this->unk_198 = 0;
|
||||
this->timer = 70;
|
||||
this->actor.speedXZ = 0;
|
||||
}
|
||||
|
||||
void ItemShield_Update(Actor* thisx, GlobalContext* globalCtx) {
|
||||
ItemShield* this = THIS;
|
||||
|
||||
this->actionFunc(this, globalCtx);
|
||||
}
|
||||
|
||||
void ItemShield_Draw(Actor* thisx, GlobalContext* globalCtx) {
|
||||
ItemShield* this = THIS;
|
||||
|
||||
if (!(this->unk_19C & 2)) {
|
||||
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_item_shield.c", 457);
|
||||
func_80093D18(globalCtx->state.gfxCtx);
|
||||
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_item_shield.c", 460),
|
||||
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gSPDisplayList(POLY_OPA_DISP++, SEGMENTED_TO_VIRTUAL(D_060224F8));
|
||||
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_item_shield.c", 465);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,9 +6,17 @@
|
|||
|
||||
struct ItemShield;
|
||||
|
||||
typedef void (*ItemShieldActionFunc)(struct ItemShield*, GlobalContext*);
|
||||
|
||||
typedef struct ItemShield {
|
||||
/* 0x0000 */ Actor actor;
|
||||
/* 0x014C */ char unk_14C[0xC0];
|
||||
/* 0x014C */ ColliderCylinder collider;
|
||||
/* 0x0198 */ s16 unk_198;
|
||||
/* 0x019A */ s16 timer;
|
||||
/* 0x019C */ s16 unk_19C;
|
||||
/* 0x019E */ u8 unk_19E[8];
|
||||
/* 0x01A8 */ Vec3f unk_1A8[8];
|
||||
/* 0x0208 */ ItemShieldActionFunc actionFunc;
|
||||
} ItemShield; // size = 0x020C
|
||||
|
||||
extern const ActorInit Item_Shield_InitVars;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue