mirror of
https://github.com/zeldaret/mm.git
synced 2026-08-17 21:03:30 -04:00
Fire and Light arrows (#710)
* fire arrow OK * Light arrows OK * Format * Assets * Mtx Mode * PR fixes * pr fixes * Update src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c * Update src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include "z_arrow_fire.h"
|
||||
#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h"
|
||||
|
||||
#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000)
|
||||
|
||||
@@ -15,19 +16,10 @@ void ArrowFire_Destroy(Actor* thisx, GlobalContext* globalCtx);
|
||||
void ArrowFire_Update(Actor* thisx, GlobalContext* globalCtx);
|
||||
void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx);
|
||||
|
||||
void func_80920440(ArrowFire* this, GlobalContext* globalCtx);
|
||||
void func_8092058C(ArrowFire* this, GlobalContext* globalCtx);
|
||||
void func_809207A0(ArrowFire* this, GlobalContext* globalCtx);
|
||||
void FireArrow_ChargeAndWait(ArrowFire* this, GlobalContext* globalCtx);
|
||||
void FireArrow_Fly(ArrowFire* this, GlobalContext* globalCtx);
|
||||
|
||||
void ArrowFire_SetupAction(ArrowFire* this, ArrowFireActionFunc actionFunc);
|
||||
|
||||
#if 0
|
||||
// static ColliderQuadInit sQuadInit = {
|
||||
static ColliderQuadInit D_80922230 = {
|
||||
{ COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_TYPE_PLAYER, COLSHAPE_QUAD, },
|
||||
{ ELEMTYPE_UNK0, { 0x08000000, 0x00, 0x02 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, },
|
||||
{ { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } },
|
||||
};
|
||||
#include "overlays/ovl_Arrow_fire/ovl_Arrow_Fire.c"
|
||||
|
||||
const ActorInit Arrow_Fire_InitVars = {
|
||||
ACTOR_ARROW_FIRE,
|
||||
@@ -41,29 +33,264 @@ const ActorInit Arrow_Fire_InitVars = {
|
||||
(ActorFunc)ArrowFire_Draw,
|
||||
};
|
||||
|
||||
#endif
|
||||
static ColliderQuadInit sQuadInit = {
|
||||
{
|
||||
COLTYPE_NONE,
|
||||
AT_ON | AT_TYPE_PLAYER,
|
||||
AC_NONE,
|
||||
OC1_NONE,
|
||||
OC2_TYPE_PLAYER,
|
||||
COLSHAPE_QUAD,
|
||||
},
|
||||
{
|
||||
ELEMTYPE_UNK0,
|
||||
{ 0x08000000, 0x00, 0x02 },
|
||||
{ 0x00000000, 0x00, 0x00 },
|
||||
TOUCH_ON | TOUCH_SFX_NORMAL,
|
||||
BUMP_NONE,
|
||||
OCELEM_NONE,
|
||||
},
|
||||
{ { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } },
|
||||
};
|
||||
|
||||
extern ColliderQuadInit D_80922230;
|
||||
static InitChainEntry sInitChain[] = {
|
||||
ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_STOP),
|
||||
};
|
||||
|
||||
// there are uses of D_0E000000.fillRect (appearing as D_0E0002E0) in this file
|
||||
extern GfxMasterList D_0E000000;
|
||||
s32 sUnused;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_SetupAction.s")
|
||||
void ArrowFire_SetupAction(ArrowFire* this, ArrowFireActionFunc actionFunc) {
|
||||
this->actionFunc = actionFunc;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_Init.s")
|
||||
void ArrowFire_Init(Actor* thisx, GlobalContext* globalCtx) {
|
||||
ArrowFire* this = THIS;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_Destroy.s")
|
||||
Actor_ProcessInitChain(&this->actor, sInitChain);
|
||||
this->radius = 0;
|
||||
this->height = 1.0f;
|
||||
ArrowFire_SetupAction(this, FireArrow_ChargeAndWait);
|
||||
Actor_SetScale(&this->actor, 0.01f);
|
||||
this->alpha = 160;
|
||||
this->timer = 0;
|
||||
this->screenFillIntensity = 0.0f;
|
||||
Collider_InitAndSetQuad(globalCtx, &this->collider1, &this->actor, &sQuadInit);
|
||||
Collider_InitAndSetQuad(globalCtx, &this->collider2, &this->actor, &sQuadInit);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/func_80920440.s")
|
||||
void ArrowFire_Destroy(Actor* thisx, GlobalContext* globalCtx) {
|
||||
ArrowFire* this = THIS;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/FireArrow_Lerp.s")
|
||||
func_80115D5C(&globalCtx->state);
|
||||
Collider_DestroyQuad(globalCtx, &this->collider1);
|
||||
Collider_DestroyQuad(globalCtx, &this->collider2);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/func_8092058C.s")
|
||||
void FireArrow_ChargeAndWait(ArrowFire* this, GlobalContext* globalCtx) {
|
||||
EnArrow* arrow = (EnArrow*)this->actor.parent;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/func_809207A0.s")
|
||||
if ((arrow == NULL) || (arrow->actor.update == NULL)) {
|
||||
Actor_MarkForDeath(&this->actor);
|
||||
return;
|
||||
}
|
||||
if (this->radius < 10) {
|
||||
this->radius++;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_Update.s")
|
||||
this->actor.world.pos = arrow->actor.world.pos;
|
||||
this->actor.shape.rot = arrow->actor.shape.rot;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/func_80920948.s")
|
||||
func_800B9010(&this->actor, NA_SE_PL_ARROW_CHARGE_FIRE - SFX_FLAG);
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_Draw.s")
|
||||
// if arrow has no parent, player has fired the arrow
|
||||
if (arrow->actor.parent == NULL) {
|
||||
this->firedPos = this->actor.world.pos;
|
||||
this->radius = 10;
|
||||
ArrowFire_SetupAction(this, FireArrow_Fly);
|
||||
this->alpha = 255;
|
||||
}
|
||||
}
|
||||
|
||||
void FireArrow_Lerp(Vec3f* firedPos, Vec3f* pos, f32 scale) {
|
||||
VEC3F_LERPIMPDST(firedPos, firedPos, pos, scale);
|
||||
}
|
||||
|
||||
void FireArrow_Hit(ArrowFire* this, GlobalContext* globalCtx) {
|
||||
f32 offset;
|
||||
f32 scale;
|
||||
u16 timer;
|
||||
|
||||
if (this->actor.projectedW < 50.0f) {
|
||||
scale = 10.0f;
|
||||
} else if (this->actor.projectedW > 950.0f) {
|
||||
scale = 310.0f;
|
||||
} else {
|
||||
scale = this->actor.projectedW;
|
||||
scale = ((scale - 50.0f) * (1.0f / 3.0f)) + 10.0f;
|
||||
}
|
||||
|
||||
timer = this->timer;
|
||||
if (timer != 0) {
|
||||
this->timer--;
|
||||
if (this->timer >= 8) {
|
||||
offset = (this->timer - 8) * (1.0f / 24.0f);
|
||||
offset = SQ(offset);
|
||||
this->radius = (((1.0f - offset) * scale) + 10.0f);
|
||||
this->height = F32_LERPIMP(this->height, 2.0f, 0.1f);
|
||||
if (this->timer < 16) {
|
||||
this->alpha = (this->timer * 35) - 280;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this->timer >= 9) {
|
||||
if (this->screenFillIntensity < 1.0f) {
|
||||
this->screenFillIntensity += 0.25f;
|
||||
}
|
||||
} else {
|
||||
if (this->screenFillIntensity > 0.0f) {
|
||||
this->screenFillIntensity -= 0.125f;
|
||||
}
|
||||
}
|
||||
if (this->timer < 8) {
|
||||
this->alpha = 0;
|
||||
}
|
||||
if (this->timer == 0) {
|
||||
this->timer = 255;
|
||||
Actor_MarkForDeath(&this->actor);
|
||||
return;
|
||||
}
|
||||
if (this->timer >= 13) {
|
||||
CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base);
|
||||
CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base);
|
||||
}
|
||||
}
|
||||
|
||||
void FireArrow_Fly(ArrowFire* this, GlobalContext* globalCtx) {
|
||||
EnArrow* arrow = (EnArrow*)this->actor.parent;
|
||||
s32 pad;
|
||||
s32 pad2;
|
||||
|
||||
if ((arrow == NULL) || (arrow->actor.update == NULL)) {
|
||||
Actor_MarkForDeath(&this->actor);
|
||||
return;
|
||||
}
|
||||
|
||||
this->actor.world.pos = arrow->actor.world.pos;
|
||||
this->actor.shape.rot = arrow->actor.shape.rot;
|
||||
|
||||
this->height = Math_Vec3f_DistXYZ(&this->firedPos, &this->actor.world.pos) * (1.0f / 24.0f);
|
||||
|
||||
if (this->height < 1.0f) {
|
||||
this->height = 1.0f;
|
||||
}
|
||||
|
||||
FireArrow_Lerp(&this->firedPos, &this->actor.world.pos, 0.05f);
|
||||
if (arrow->unk_261 & 1) {
|
||||
Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_EXPLOSION_FRAME);
|
||||
ArrowFire_SetupAction(this, FireArrow_Hit);
|
||||
this->timer = 32;
|
||||
this->alpha = 255;
|
||||
return;
|
||||
}
|
||||
if (arrow->unk_260 < 34) {
|
||||
if (this->alpha < 35) {
|
||||
Actor_MarkForDeath(&this->actor);
|
||||
return;
|
||||
}
|
||||
this->alpha -= 25;
|
||||
}
|
||||
}
|
||||
|
||||
void ArrowFire_Update(Actor* thisx, GlobalContext* globalCtx) {
|
||||
ArrowFire* this = (ArrowFire*)thisx;
|
||||
|
||||
if ((globalCtx->msgCtx.msgMode == 0xE) || (globalCtx->msgCtx.msgMode == 0x12)) {
|
||||
Actor_MarkForDeath(&this->actor);
|
||||
return;
|
||||
}
|
||||
this->actionFunc(this, globalCtx);
|
||||
}
|
||||
|
||||
void FireArrow_SetQuadVerticies(ArrowFire* this) {
|
||||
static Vec3f D_80922284 = { 100.0f, 700.0f, 0.0f };
|
||||
static Vec3f D_80922290 = { 400.0f, 27.0f, 0.0f };
|
||||
static Vec3f D_8092229C = { -100.0f, 700.0f, 0.0f };
|
||||
static Vec3f D_809222A8 = { -400, 27.0f, 0.0f };
|
||||
static Vec3f D_809222B4 = { 0.0f, 700.0f, 100.0f };
|
||||
static Vec3f D_809222C0 = { 0.0f, 27.0f, 400.0f };
|
||||
static Vec3f D_809222CC = { 0.0f, 700.0f, -100.0f };
|
||||
static Vec3f D_809222D8 = { 0.0f, 27.0f, -400.0f };
|
||||
Vec3f sp44;
|
||||
Vec3f sp38;
|
||||
Vec3f sp2C;
|
||||
Vec3f sp20;
|
||||
|
||||
Matrix_MultiplyVector3fByState(&D_80922284, &sp44);
|
||||
Matrix_MultiplyVector3fByState(&D_80922290, &sp38);
|
||||
Matrix_MultiplyVector3fByState(&D_8092229C, &sp2C);
|
||||
Matrix_MultiplyVector3fByState(&D_809222A8, &sp20);
|
||||
Collider_SetQuadVertices(&this->collider1, &sp44, &sp38, &sp2C, &sp20);
|
||||
Matrix_MultiplyVector3fByState(&D_809222B4, &sp44);
|
||||
Matrix_MultiplyVector3fByState(&D_809222C0, &sp38);
|
||||
Matrix_MultiplyVector3fByState(&D_809222CC, &sp2C);
|
||||
Matrix_MultiplyVector3fByState(&D_809222D8, &sp20);
|
||||
Collider_SetQuadVertices(&this->collider2, &sp44, &sp38, &sp2C, &sp20);
|
||||
}
|
||||
|
||||
void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx) {
|
||||
EnArrow* arrow;
|
||||
ArrowFire* this = THIS;
|
||||
u32 frames = globalCtx->state.frames;
|
||||
s32 pad;
|
||||
|
||||
arrow = (EnArrow*)this->actor.parent;
|
||||
|
||||
if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) {
|
||||
Actor* transform = (arrow->unk_261 & 2) ? &this->actor : &arrow->actor;
|
||||
|
||||
OPEN_DISPS(globalCtx->state.gfxCtx);
|
||||
Matrix_InsertTranslation(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW);
|
||||
Matrix_RotateY(transform->shape.rot.y, MTXMODE_APPLY);
|
||||
Matrix_InsertXRotation_s(transform->shape.rot.x, MTXMODE_APPLY);
|
||||
Matrix_InsertZRotation_s(transform->shape.rot.z, MTXMODE_APPLY);
|
||||
|
||||
Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY);
|
||||
if (this->screenFillIntensity > 0.0f) {
|
||||
POLY_XLU_DISP = func_8012BFC4(POLY_XLU_DISP);
|
||||
|
||||
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s32)(this->screenFillIntensity * 40.0f) & 0xFF, 0, 0,
|
||||
(s32)(150.0f * this->screenFillIntensity) & 0xFF);
|
||||
|
||||
gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_DISABLE);
|
||||
gDPSetColorDither(POLY_XLU_DISP++, G_CD_DISABLE);
|
||||
|
||||
gSPDisplayList(POLY_XLU_DISP++, D_0E000000.fillRect);
|
||||
}
|
||||
func_8012C2DC(globalCtx->state.gfxCtx);
|
||||
|
||||
gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, this->alpha);
|
||||
gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128);
|
||||
|
||||
Matrix_InsertRotation(0x4000, 0, 0, MTXMODE_APPLY);
|
||||
|
||||
if (this->timer != 0) {
|
||||
Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY);
|
||||
} else {
|
||||
Matrix_InsertTranslation(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY);
|
||||
}
|
||||
|
||||
Matrix_Scale(this->radius * 0.2f, this->height * 4.0f, this->radius * 0.2f, MTXMODE_APPLY);
|
||||
Matrix_InsertTranslation(0.0f, -700.0f, 0.0f, MTXMODE_APPLY);
|
||||
|
||||
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
FireArrow_SetQuadVerticies(this);
|
||||
gSPDisplayList(POLY_XLU_DISP++, gFireArrowMaterialDL);
|
||||
gSPDisplayList(POLY_XLU_DISP++,
|
||||
Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 255 - ((frames * 2) % 256), 0, 64, 32, 1,
|
||||
255 - (frames % 256), 511 - ((frames * 10) % 512), 64, 64));
|
||||
gSPDisplayList(POLY_XLU_DISP++, gFireArrowModelDL);
|
||||
|
||||
CLOSE_DISPS(globalCtx->state.gfxCtx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,19 @@ struct ArrowFire;
|
||||
typedef void (*ArrowFireActionFunc)(struct ArrowFire*, GlobalContext*);
|
||||
|
||||
typedef struct ArrowFire {
|
||||
/* 0x0000 */ Actor actor;
|
||||
/* 0x0144 */ char unk_144[0x114];
|
||||
/* 0x0258 */ ArrowFireActionFunc actionFunc;
|
||||
/* 0x025C */ char unk_25C[0x8];
|
||||
/* 0x000 */ Actor actor;
|
||||
/* 0x144 */ ColliderQuad collider1;
|
||||
/* 0x1C4 */ ColliderQuad collider2;
|
||||
/* 0x244 */ Vec3f firedPos;
|
||||
/* 0x250 */ f32 height;
|
||||
/* 0x254 */ f32 screenFillIntensity;
|
||||
/* 0x258 */ ArrowFireActionFunc actionFunc;
|
||||
/* 0x25C */ s16 radius;
|
||||
/* 0x25E */ u16 timer;
|
||||
/* 0x260 */ u8 alpha;
|
||||
} ArrowFire; // size = 0x264
|
||||
|
||||
|
||||
extern const ActorInit Arrow_Fire_InitVars;
|
||||
|
||||
#endif // Z_ARROW_FIRE_H
|
||||
|
||||
@@ -17,7 +17,6 @@ void ArrowIce_Update(Actor* thisx, GlobalContext* globalCtx);
|
||||
void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx);
|
||||
|
||||
void ArrowIce_Charge(ArrowIce* this, GlobalContext* globalCtx);
|
||||
void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx);
|
||||
void ArrowIce_Fly(ArrowIce* this, GlobalContext* globalCtx);
|
||||
|
||||
#include "overlays/ovl_Arrow_Ice/ovl_Arrow_Ice.c"
|
||||
@@ -94,7 +93,6 @@ void ArrowIce_LerpFiredPosition(Vec3f* firedPos, Vec3f* icePos, f32 scale) {
|
||||
|
||||
void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx) {
|
||||
f32 scale;
|
||||
f32 offset;
|
||||
u16 timer;
|
||||
|
||||
if (this->actor.projectedW < 50.0f) {
|
||||
@@ -111,12 +109,12 @@ void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx) {
|
||||
this->timer--;
|
||||
|
||||
if (this->timer >= 8) {
|
||||
offset = ((this->timer - 8) * (1.0f / 24.0f));
|
||||
f32 offset = ((this->timer - 8) * (1.0f / 24.0f));
|
||||
|
||||
offset = SQ(offset);
|
||||
this->radius = (((1.0f - offset) * scale) + 10.0f);
|
||||
this->height += ((2.0f - this->height) * 0.1f);
|
||||
this->height = F32_LERPIMP(this->height, 2.0f, 0.1f);
|
||||
if (this->timer < 16) {
|
||||
if (1) {}
|
||||
this->alpha = ((this->timer * 35) - 280);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include "z_arrow_light.h"
|
||||
#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h"
|
||||
|
||||
#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000)
|
||||
|
||||
@@ -15,13 +16,11 @@ void ArrowLight_Destroy(Actor* thisx, GlobalContext* globalCtx);
|
||||
void ArrowLight_Update(Actor* thisx, GlobalContext* globalCtx);
|
||||
void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx);
|
||||
|
||||
void func_809243AC(ArrowLight* this, GlobalContext* globalCtx);
|
||||
void func_809244F8(ArrowLight* this, GlobalContext* globalCtx);
|
||||
void func_809246C4(ArrowLight* this, GlobalContext* globalCtx);
|
||||
void ArrowLight_Charge(ArrowLight* this, GlobalContext* globalCtx);
|
||||
void ArrowLight_Fly(ArrowLight* this, GlobalContext* globalCtx);
|
||||
|
||||
void ArrowLight_SetupAction(ArrowLight* this, ArrowLightActionFunc actionFunc);
|
||||
#include "overlays/ovl_Arrow_Light/ovl_Arrow_Light.c"
|
||||
|
||||
#if 0
|
||||
const ActorInit Arrow_Light_InitVars = {
|
||||
ACTOR_ARROW_LIGHT,
|
||||
ACTORCAT_ITEMACTION,
|
||||
@@ -34,34 +33,198 @@ const ActorInit Arrow_Light_InitVars = {
|
||||
(ActorFunc)ArrowLight_Draw,
|
||||
};
|
||||
|
||||
// static InitChainEntry sInitChain[] = {
|
||||
static InitChainEntry D_809260A0[] = {
|
||||
static InitChainEntry sInitChain[] = {
|
||||
ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_STOP),
|
||||
};
|
||||
|
||||
#endif
|
||||
static s32 sUnused;
|
||||
|
||||
extern InitChainEntry D_809260A0[];
|
||||
void ArrowLight_SetupAction(ArrowLight* this, ArrowLightActionFunc actionFunc) {
|
||||
this->actionFunc = actionFunc;
|
||||
}
|
||||
|
||||
// there are uses of D_0E000000.fillRect (appearing as D_0E0002E0) in this file
|
||||
extern GfxMasterList D_0E000000;
|
||||
void ArrowLight_Init(Actor* thisx, GlobalContext* globalCtx) {
|
||||
ArrowLight* this = (ArrowLight*)thisx;
|
||||
Actor_ProcessInitChain(&this->actor, sInitChain);
|
||||
this->radius = 0;
|
||||
this->height = 1.0f;
|
||||
ArrowLight_SetupAction(this, ArrowLight_Charge);
|
||||
Actor_SetScale(&this->actor, 0.01f);
|
||||
this->alpha = 130;
|
||||
this->timer = 0;
|
||||
this->screenFillIntensity = 0.0f;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/D_809260B0.s")
|
||||
void ArrowLight_Destroy(Actor* thisx, GlobalContext* globalCtx) {
|
||||
func_80115D5C(&globalCtx->state);
|
||||
(void)"消滅"; // Unreferenced in retail, means "Disappearance"
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_SetupAction.s")
|
||||
void ArrowLight_Charge(ArrowLight* this, GlobalContext* globalCtx) {
|
||||
EnArrow* arrow = (EnArrow*)this->actor.parent;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_Init.s")
|
||||
if ((arrow == NULL) || (arrow->actor.update == NULL)) {
|
||||
Actor_MarkForDeath(&this->actor);
|
||||
return;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_Destroy.s")
|
||||
if (this->radius < 10) {
|
||||
this->radius++;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/func_809243AC.s")
|
||||
this->actor.world.pos = arrow->actor.world.pos;
|
||||
this->actor.shape.rot = arrow->actor.shape.rot;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/func_809244A0.s")
|
||||
func_800B9010(&this->actor, NA_SE_PL_ARROW_CHARGE_LIGHT - SFX_FLAG);
|
||||
if (arrow->actor.parent == NULL) {
|
||||
this->firedPos = this->actor.world.pos;
|
||||
this->radius = 10;
|
||||
ArrowLight_SetupAction(this, ArrowLight_Fly);
|
||||
this->alpha = 255;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/func_809244F8.s")
|
||||
void ArrowLight_Lerp(Vec3f* firedPos, Vec3f* pos, f32 scale) {
|
||||
VEC3F_LERPIMPDST(firedPos, firedPos, pos, scale);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/func_809246C4.s")
|
||||
void ArrowLight_Hit(ArrowLight* this, GlobalContext* globalCtx) {
|
||||
f32 scale;
|
||||
u16 timer;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_Update.s")
|
||||
if (this->actor.projectedW < 50.0f) {
|
||||
scale = 10.0f;
|
||||
} else if (this->actor.projectedW > 950.0f) {
|
||||
scale = 310.0f;
|
||||
} else {
|
||||
scale = this->actor.projectedW;
|
||||
scale = ((scale - 50.0f) * (1.0f / 3.0f)) + 10.0f;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_Draw.s")
|
||||
timer = this->timer;
|
||||
if (timer != 0) {
|
||||
this->timer--;
|
||||
if (this->timer >= 8) {
|
||||
f32 offset = (this->timer - 8) * (1.0f / 24.0f);
|
||||
|
||||
offset = SQ(offset);
|
||||
this->radius = (((1.0f - offset) * scale) + 10.0f);
|
||||
this->height = F32_LERPIMP(this->height, 2.0f, 0.1f);
|
||||
if (this->timer < 16) {
|
||||
this->alpha = (this->timer * 35) - 280;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this->timer >= 9) {
|
||||
if (this->screenFillIntensity < 1.0f) {
|
||||
this->screenFillIntensity += 0.25f;
|
||||
}
|
||||
} else {
|
||||
if (this->screenFillIntensity > 0.0f) {
|
||||
this->screenFillIntensity -= 0.125f;
|
||||
}
|
||||
}
|
||||
if (this->timer < 8) {
|
||||
this->alpha = 0;
|
||||
}
|
||||
if (this->timer == 0) {
|
||||
this->timer = 255;
|
||||
Actor_MarkForDeath(&this->actor);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void ArrowLight_Fly(ArrowLight* this, GlobalContext* globalCtx) {
|
||||
EnArrow* arrow = (EnArrow*)this->actor.parent;
|
||||
s32 pad[2];
|
||||
|
||||
if ((arrow == NULL) || (arrow->actor.update == NULL)) {
|
||||
Actor_MarkForDeath(&this->actor);
|
||||
return;
|
||||
}
|
||||
|
||||
this->actor.world.pos = arrow->actor.world.pos;
|
||||
this->actor.shape.rot = arrow->actor.shape.rot;
|
||||
|
||||
this->height = Math_Vec3f_DistXYZ(&this->firedPos, &this->actor.world.pos) * (1.0f / 24.0f);
|
||||
if (this->height < 1.0f) {
|
||||
this->height = 1.0f;
|
||||
}
|
||||
|
||||
ArrowLight_Lerp(&this->firedPos, &this->actor.world.pos, 0.05f);
|
||||
|
||||
if (arrow->unk_261 & 1) {
|
||||
Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_EXPLOSION_LIGHT);
|
||||
ArrowLight_SetupAction(this, ArrowLight_Hit);
|
||||
this->timer = 32;
|
||||
this->alpha = 255;
|
||||
return;
|
||||
}
|
||||
if (arrow->unk_260 < 34) {
|
||||
if (this->alpha < 35) {
|
||||
Actor_MarkForDeath(&this->actor);
|
||||
return;
|
||||
}
|
||||
this->alpha -= 25;
|
||||
}
|
||||
}
|
||||
|
||||
void ArrowLight_Update(Actor* thisx, GlobalContext* globalCtx) {
|
||||
ArrowLight* this = THIS;
|
||||
|
||||
if ((globalCtx->msgCtx.msgMode == 0xE) || (globalCtx->msgCtx.msgMode == 0x12)) {
|
||||
Actor_MarkForDeath(&this->actor);
|
||||
return;
|
||||
}
|
||||
this->actionFunc(this, globalCtx);
|
||||
}
|
||||
|
||||
void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx) {
|
||||
s32 pad;
|
||||
ArrowLight* this = (ArrowLight*)thisx;
|
||||
u32 frames = globalCtx->state.frames;
|
||||
EnArrow* arrow = (EnArrow*)this->actor.parent;
|
||||
|
||||
if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) {
|
||||
Actor* transform = (arrow->unk_261 & 2) ? &this->actor : &arrow->actor;
|
||||
|
||||
OPEN_DISPS(globalCtx->state.gfxCtx);
|
||||
|
||||
Matrix_InsertTranslation(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW);
|
||||
Matrix_RotateY(transform->shape.rot.y, MTXMODE_APPLY);
|
||||
Matrix_InsertXRotation_s(transform->shape.rot.x, MTXMODE_APPLY);
|
||||
Matrix_InsertZRotation_s(transform->shape.rot.z, MTXMODE_APPLY);
|
||||
Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY);
|
||||
if (this->screenFillIntensity > 0.0f) {
|
||||
POLY_XLU_DISP = func_8012BFC4(POLY_XLU_DISP);
|
||||
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s32)(this->screenFillIntensity * 30.0f) & 0xFF,
|
||||
(s32)(40.0f * this->screenFillIntensity) & 0xFF, 0,
|
||||
(s32)(150.0f * this->screenFillIntensity) & 0xFF);
|
||||
gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_DISABLE);
|
||||
gDPSetColorDither(POLY_XLU_DISP++, G_CD_DISABLE);
|
||||
gSPDisplayList(POLY_XLU_DISP++, D_0E000000.fillRect);
|
||||
}
|
||||
|
||||
func_8012C2DC(globalCtx->state.gfxCtx);
|
||||
|
||||
gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, this->alpha);
|
||||
gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 128);
|
||||
|
||||
Matrix_InsertRotation(0x4000, 0, 0, MTXMODE_APPLY);
|
||||
if (this->timer != 0) {
|
||||
Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY);
|
||||
} else {
|
||||
Matrix_InsertTranslation(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY);
|
||||
}
|
||||
Matrix_Scale(this->radius * 0.2f, this->height * 4.0f, this->radius * 0.2f, MTXMODE_APPLY);
|
||||
Matrix_InsertTranslation(0.0f, -700.0f, 0.0f, MTXMODE_APPLY);
|
||||
|
||||
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gSPDisplayList(POLY_XLU_DISP++, gLightArrowMaterialDL);
|
||||
gSPDisplayList(POLY_XLU_DISP++,
|
||||
Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 511 - ((frames * 5) % 512), 0, 4, 32, 1,
|
||||
511 - ((frames * 10) % 512), 511 - ((frames * 30) % 512), 8, 16));
|
||||
gSPDisplayList(POLY_XLU_DISP++, gLightArrowModelDL);
|
||||
CLOSE_DISPS(globalCtx->state.gfxCtx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,11 +8,17 @@ struct ArrowLight;
|
||||
typedef void (*ArrowLightActionFunc)(struct ArrowLight*, GlobalContext*);
|
||||
|
||||
typedef struct ArrowLight {
|
||||
/* 0x0000 */ Actor actor;
|
||||
/* 0x0144 */ char unk_144[0x1C];
|
||||
/* 0x0160 */ ArrowLightActionFunc actionFunc;
|
||||
/* 0x000 */ Actor actor;
|
||||
/* 0x144 */ s16 radius;
|
||||
/* 0x146 */ u16 timer;
|
||||
/* 0x148 */ u8 alpha;
|
||||
/* 0x14C */ Vec3f firedPos;
|
||||
/* 0x158 */ f32 height;
|
||||
/* 0x15C */ f32 screenFillIntensity;
|
||||
/* 0x160 */ ArrowLightActionFunc actionFunc;
|
||||
} ArrowLight; // size = 0x164
|
||||
|
||||
|
||||
extern const ActorInit Arrow_Light_InitVars;
|
||||
|
||||
#endif // Z_ARROW_LIGHT_H
|
||||
|
||||
Reference in New Issue
Block a user