Reset back to master and implemented trailType enum

This commit is contained in:
macq 2024-02-23 15:38:21 -05:00
parent bcbe4cb1c3
commit d8e88ab477
6 changed files with 74 additions and 95 deletions

View File

@ -14,6 +14,19 @@ struct PlayState;
#define TOTAL_EFFECT_COUNT SPARK_COUNT + BLURE_COUNT + SHIELD_PARTICLE_COUNT #define TOTAL_EFFECT_COUNT SPARK_COUNT + BLURE_COUNT + SHIELD_PARTICLE_COUNT
typedef enum {
TRAIL_TYPE_REST,
TRAIL_TYPE_SWORDS,
TRAIL_TYPE_BOOMERANG,
TRAIL_TYPE_BOMBCHU,
TRAIL_TYPE_KOKIRI_SWORD,
TRAIL_TYPE_MASTER_SWORD,
TRAIL_TYPE_BIGGORON_SWORD,
TRAIL_TYPE_STICK,
TRAIL_TYPE_HAMMER,
TRAIL_TYPE_STICK_INIT = 4, //conflict in struct definitions, one defines 4 as stick and one defines as bombchu
} TrailType;
typedef struct { typedef struct {
/* 0x00 */ u8 active; /* 0x00 */ u8 active;
/* 0x01 */ u8 unk_01; /* 0x01 */ u8 unk_01;
@ -73,7 +86,7 @@ typedef struct {
/* 0x194 */ s32 elemDuration; /* 0x194 */ s32 elemDuration;
/* 0x198 */ s32 unkFlag; /* 0x198 */ s32 unkFlag;
/* 0x19C */ s32 calcMode; /* 0x19C */ s32 calcMode;
/* 0x1A0 */ u8 trailType; // 1 is swords, 2 is boomerang, 3 is bombchu, 0 is rest /* 0x1A0 */ TrailType trailType; // 1 is swords, 2 is boomerang, 3 is bombchu, 0 is rest
} EffectBlureInit1; // size = 0x1A0 } EffectBlureInit1; // size = 0x1A0
typedef struct { typedef struct {
@ -90,7 +103,7 @@ typedef struct {
/* 0x1B */ u8 mode4Param; /* 0x1B */ u8 mode4Param;
/* 0x1C */ Color_RGBA8 altPrimColor; // used with drawMode 1 /* 0x1C */ Color_RGBA8 altPrimColor; // used with drawMode 1
/* 0x20 */ Color_RGBA8 altEnvColor; // used with drawMode 1 /* 0x20 */ Color_RGBA8 altEnvColor; // used with drawMode 1
/* 0x1A0 */ u8 trailType; // 1 is swords, 2 is boomerang, 3 is bombchu, 4 is stick, 0 is rest /* 0x1A0 */ TrailType trailType; // 1 is swords, 2 is boomerang, 3 is bombchu, 4 is stick, 0 is rest
} EffectBlureInit2; // size = 0x24 } EffectBlureInit2; // size = 0x24
typedef struct { typedef struct {
@ -110,7 +123,7 @@ typedef struct {
/* 0x1A1 */ u8 drawMode; // 0: simple; 1: simple with alt colors; 2+: smooth /* 0x1A1 */ u8 drawMode; // 0: simple; 1: simple with alt colors; 2+: smooth
/* 0x1A2 */ Color_RGBA8 altPrimColor; // used with drawMode 1 /* 0x1A2 */ Color_RGBA8 altPrimColor; // used with drawMode 1
/* 0x1A6 */ Color_RGBA8 altEnvColor; // used with drawMode 1 /* 0x1A6 */ Color_RGBA8 altEnvColor; // used with drawMode 1
/* 0x1A0 */ u8 trailType; // 1 is default swords, 2 is boomerang, 3 is bombchu, 0 is rest. 4 is Kokiri, 5 is Master, 6 is BGS, 7 is Stick, 8 is Hammer. /* 0x1A0 */ TrailType trailType; // 1 is default swords, 2 is boomerang, 3 is bombchu, 0 is rest. 4 is Kokiri, 5 is Master, 6 is BGS, 7 is Stick, 8 is Hammer.
} EffectBlure; // size = 0x1AC } EffectBlure; // size = 0x1AC
typedef struct { typedef struct {

View File

@ -3,6 +3,7 @@
#include "soh/frame_interpolation.h" #include "soh/frame_interpolation.h"
#include <assert.h> #include <assert.h>
#include <stdio.h>
void EffectBlure_AddVertex(EffectBlure* this, Vec3f* p1, Vec3f* p2) { void EffectBlure_AddVertex(EffectBlure* this, Vec3f* p1, Vec3f* p2) {
EffectBlureElement* elem; EffectBlureElement* elem;
@ -72,7 +73,7 @@ void EffectBlure_AddVertex(EffectBlure* this, Vec3f* p1, Vec3f* p2) {
} }
} }
//dumb doo doo command to change the type of an object's blur on the fly. Link's Swords with unique trail colors. // dumb doo doo command to change the type of an object's blur on the fly. Link's Swords with unique trail colors.
void EffectBlure_ChangeType(EffectBlure* this, int type) { void EffectBlure_ChangeType(EffectBlure* this, int type) {
this->trailType = type; this->trailType = type;
} }
@ -199,6 +200,36 @@ void EffectBlure_Init2(void* thisx, void* initParamsx) {
void EffectBlure_Destroy(void* thisx) { void EffectBlure_Destroy(void* thisx) {
} }
void updateTrailColor(const char* trailName, Color_RGBA8* color, int* changed, int* reset) {
Color_RGBA8 defaultColor = { 255, 255, 255, 255 };
char cvarName[50];
if (CVarGetInteger(snprintf(cvarName, sizeof(cvarName), "%s.Changed", trailName), 0)) {
*color = CVarGetColor(snprintf(cvarName, sizeof(cvarName), "%s.Value", trailName), defaultColor);
*changed = 1;
} else if (*changed) {
*color = defaultColor;
*reset = 1;
}
}
void updateParticleColors(Color_RGBA8* color, Color_RGBA8 p1StartColor, Color_RGBA8 p2StartColor,
Color_RGBA8 p1EndColor, Color_RGBA8 p2EndColor) {
p1StartColor.r = color->r;
p2StartColor.r = color->r * 0.8f;
p1EndColor.r = color->r * 0.6f;
p2EndColor.r = color->r * 0.4f;
p1StartColor.g = color->g;
p2StartColor.g = color->g * 0.8f;
p1EndColor.g = color->g * 0.6f;
p2EndColor.g = color->g * 0.4f;
p1StartColor.b = color->b;
p2StartColor.b = color->b * 0.8f;
p1EndColor.b = color->b * 0.6f;
p2EndColor.b = color->b * 0.4f;
}
s32 EffectBlure_Update(void* thisx) { s32 EffectBlure_Update(void* thisx) {
EffectBlure* this = (EffectBlure*)thisx; EffectBlure* this = (EffectBlure*)thisx;
s32 i; s32 i;
@ -206,93 +237,30 @@ s32 EffectBlure_Update(void* thisx) {
static u8 changed = 0; static u8 changed = 0;
u8 reset = 0; u8 reset = 0;
switch (this->trailType) { //there HAS to be a better way to do this. switch (this->trailType) { // a better way?
case 2: case TRAIL_TYPE_BOOMERANG:
if (CVarGetInteger("gCosmetics.Trails_Boomerang.Changed", 0)) { updateTrailColor("gCosmetics.Trails_Boomerang", &color, &changed, &reset);
color = CVarGetColor("gCosmetics.Trails_Boomerang.Value", (Color_RGBA8){ 255, 255, 100, 255 });
changed = 1;
} else if (changed) {
color = (Color_RGBA8){ 255, 255, 100, 255 };
reset = 1;
}
break; break;
case 3: case TRAIL_TYPE_BOMBCHU:
if (CVarGetInteger("gCosmetics.Trails_Bombchu.Changed", 0)) { updateTrailColor("gCosmetics.Trails_Bombchu", &color, &changed, &reset);
color = CVarGetColor("gCosmetics.Trails_Bombchu.Value", (Color_RGBA8){ 250, 0, 0, 255 }); updateParticleColors(&color, this->p1StartColor, this->p2StartColor, this->p1EndColor, this->p2EndColor);
this->p1StartColor.r = color.r;
this->p2StartColor.r = color.r * 0.8f;
this->p1EndColor.r = color.r * 0.6f;
this->p2EndColor.r = color.r * 0.4f;
this->p1StartColor.g = color.g;
this->p2StartColor.g = color.g * 0.8f;
this->p1EndColor.g = color.g * 0.6f;
this->p2EndColor.g = color.g * 0.4f;
this->p1StartColor.b = color.b;
this->p2StartColor.b = color.b * 0.8f;
this->p1EndColor.b = color.b * 0.6f;
this->p2EndColor.b = color.b * 0.4f;
} else if (changed) {
color = (Color_RGBA8){ 250, 0, 0, 255 };
this->p1StartColor.r = color.r;
this->p2StartColor.r = color.r * 0.8f;
this->p1EndColor.r = color.r * 0.6f;
this->p2EndColor.r = color.r * 0.4f;
this->p1StartColor.g = color.g;
this->p2StartColor.g = color.g * 0.8f;
this->p1EndColor.g = color.g * 0.6f;
this->p2EndColor.g = color.g * 0.4f;
this->p1StartColor.b = color.b;
this->p2StartColor.b = color.b * 0.8f;
this->p1EndColor.b = color.b * 0.6f;
this->p2EndColor.b = color.b * 0.4f;
}
break; break;
case 4: case TRAIL_TYPE_KOKIRI_SWORD:
if (CVarGetInteger("gCosmetics.Trails_KokiriSword.Changed", 0)) { updateTrailColor("gCosmetics.Trails_KokiriSword", &color, &changed, &reset);
color = CVarGetColor("gCosmetics.Trails_KokiriSword.Value", (Color_RGBA8){ 255, 255, 255, 255 });
changed = 1;
} else if (changed) {
color = (Color_RGBA8){ 255, 255, 255, 255 };
reset = 1;
}
break; break;
case 5: case TRAIL_TYPE_MASTER_SWORD:
if (CVarGetInteger("gCosmetics.Trails_MasterSword.Changed", 0)) { updateTrailColor("gCosmetics.Trails_MasterSword", &color, &changed, &reset);
color = CVarGetColor("gCosmetics.Trails_MasterSword.Value", (Color_RGBA8){ 255, 255, 255, 255 });
changed = 1;
} else if (changed) {
color = (Color_RGBA8){ 255, 255, 255, 255 };
reset = 1;
}
break; break;
case 6: case TRAIL_TYPE_BIGGORON_SWORD:
if (CVarGetInteger("gCosmetics.Trails_BiggoronSword.Changed", 0)) { updateTrailColor("gCosmetics.Trails_BiggoronSword", &color, &changed, &reset);
color = CVarGetColor("gCosmetics.Trails_BiggoronSword.Value", (Color_RGBA8){ 255, 255, 255, 255 });
changed = 1;
} else if (changed) {
color = (Color_RGBA8){ 255, 255, 255, 255 };
reset = 1;
}
break; break;
case 7: case TRAIL_TYPE_STICK:
if (CVarGetInteger("gCosmetics.Trails_Stick.Changed", 0)) { updateTrailColor("gCosmetics.Trails_Stick", &color, &changed, &reset);
color = CVarGetColor("gCosmetics.Trails_Stick.Value", (Color_RGBA8){ 255, 255, 255, 255 });
changed = 1;
} else if (changed) {
color = (Color_RGBA8){ 255, 255, 255, 255 };
reset = 1;
}
break; break;
case 8: case TRAIL_TYPE_HAMMER:
if (CVarGetInteger("gCosmetics.Trails_Hammer.Changed", 0)) { updateTrailColor("gCosmetics.Trails_Hammer", &color, &changed, &reset);
color = CVarGetColor("gCosmetics.Trails_Hammer.Value", (Color_RGBA8){ 255, 255, 255, 255 });
changed = 1;
} else if (changed) {
color = (Color_RGBA8){ 255, 255, 255, 255 };
reset = 1;
}
break; break;
default: // don't do anything default:
break; break;
} }
@ -316,7 +284,7 @@ s32 EffectBlure_Update(void* thisx) {
} }
// Don't override boomerang and bombchu trail durations // Don't override boomerang and bombchu trail durations
if (this->trailType != 2 && this->trailType != 3) { if (this->trailType != TRAIL_TYPE_BOOMERANG && this->trailType != TRAIL_TYPE_BOMBCHU) {
if (CVarGetInteger("gCosmetics.Trails_Duration.Changed", 0)) { if (CVarGetInteger("gCosmetics.Trails_Duration.Changed", 0)) {
this->elemDuration = CVarGetInteger("gCosmetics.Trails_Duration.Value", 4); this->elemDuration = CVarGetInteger("gCosmetics.Trails_Duration.Value", 4);
} }
@ -831,7 +799,6 @@ void EffectBlure_DrawSmooth(EffectBlure* this2, GraphicsContext* gfxCtx) {
} else { } else {
EffectBlure_DrawElemHermiteInterpolation(this, elem, i, gfxCtx); EffectBlure_DrawElemHermiteInterpolation(this, elem, i, gfxCtx);
} }
} }
FrameInterpolation_RecordCloseChild(); FrameInterpolation_RecordCloseChild();
@ -1170,7 +1137,6 @@ void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx) {
} else { } else {
gSP1Quadrangle(POLY_XLU_DISP++, j - 2, j - 1, j + 1, j, 0); gSP1Quadrangle(POLY_XLU_DISP++, j - 2, j - 1, j + 1, j, 0);
if (this->unkFlag == 1) { if (this->unkFlag == 1) {
phi_t2 = 0; phi_t2 = 0;
} }
@ -1188,4 +1154,4 @@ void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx) {
CLOSE_DISPS(gfxCtx); CLOSE_DISPS(gfxCtx);
FrameInterpolation_RecordCloseChild(); FrameInterpolation_RecordCloseChild();
} }

View File

@ -1775,7 +1775,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Ve
D_80126080.x = this->unk_85C * 5000.0f; D_80126080.x = this->unk_85C * 5000.0f;
func_80090A28(this, sp124); func_80090A28(this, sp124);
if (this->meleeWeaponState != 0) { if (this->meleeWeaponState != 0) {
EffectBlure_ChangeType(Effect_GetByIndex(this->meleeWeaponEffectIndex), 7); // stick sword type EffectBlure_ChangeType(Effect_GetByIndex(this->meleeWeaponEffectIndex), TRAIL_TYPE_STICK);
func_800906D4(play, this, sp124); func_800906D4(play, this, sp124);
} else { } else {
Math_Vec3f_Copy(&this->meleeWeaponInfo[0].tip, &sp124[0]); Math_Vec3f_Copy(&this->meleeWeaponInfo[0].tip, &sp124[0]);

View File

@ -64,19 +64,19 @@ void EnArrow_SetupAction(EnArrow* this, EnArrowActionFunc actionFunc) {
void EnArrow_Init(Actor* thisx, PlayState* play) { void EnArrow_Init(Actor* thisx, PlayState* play) {
static EffectBlureInit2 blureNormal = { static EffectBlureInit2 blureNormal = {
0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16,
0, 1, 0, { 255, 255, 170, 255 }, { 0, 150, 0, 0 }, 0, 0, 1, 0, { 255, 255, 170, 255 }, { 0, 150, 0, 0 }, TRAIL_TYPE_REST,
}; };
static EffectBlureInit2 blureFire = { static EffectBlureInit2 blureFire = {
0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16,
0, 1, 0, { 255, 200, 0, 255 }, { 255, 0, 0, 0 }, 0, 0, 1, 0, { 255, 200, 0, 255 }, { 255, 0, 0, 0 }, TRAIL_TYPE_REST,
}; };
static EffectBlureInit2 blureIce = { static EffectBlureInit2 blureIce = {
0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16,
0, 1, 0, { 170, 255, 255, 255 }, { 0, 100, 255, 0 }, 0, 0, 1, 0, { 170, 255, 255, 255 }, { 0, 100, 255, 0 }, TRAIL_TYPE_REST,
}; };
static EffectBlureInit2 blureLight = { static EffectBlureInit2 blureLight = {
0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16,
0, 1, 0, { 255, 255, 170, 255 }, { 255, 255, 0, 0 }, 0, 0, 1, 0, { 255, 255, 170, 255 }, { 255, 255, 0, 0 }, TRAIL_TYPE_REST,
}; };
static u32 dmgFlags[] = { static u32 dmgFlags[] = {
0x00000800, 0x00000020, 0x00000020, 0x00000800, 0x00001000, 0x00000800, 0x00000020, 0x00000020, 0x00000800, 0x00001000,

View File

@ -89,7 +89,7 @@ void EnBoom_Init(Actor* thisx, PlayState* play) {
blure.elemDuration = 8; blure.elemDuration = 8;
blure.unkFlag = 0; blure.unkFlag = 0;
blure.calcMode = 0; blure.calcMode = 0;
blure.trailType = 2; blure.trailType = TRAIL_TYPE_BOOMERANG;
Effect_Add(play, &this->effectIndex, EFFECT_BLURE1, 0, 0, &blure); Effect_Add(play, &this->effectIndex, EFFECT_BLURE1, 0, 0, &blure);

View File

@ -10113,7 +10113,7 @@ static InitChainEntry sInitChain[] = {
static EffectBlureInit2 blureSword = { static EffectBlureInit2 blureSword = {
0, 8, 0, { 255, 255, 255, 255 }, { 255, 255, 255, 64 }, { 255, 255, 255, 0 }, { 255, 255, 255, 0 }, 4, 0, 8, 0, { 255, 255, 255, 255 }, { 255, 255, 255, 64 }, { 255, 255, 255, 0 }, { 255, 255, 255, 0 }, 4,
0, 2, 0, { 255, 255, 255, 255 }, { 255, 255, 255, 64 }, 1, 0, 2, 0, { 255, 255, 255, 255 }, { 255, 255, 255, 64 }, TRAIL_TYPE_SWORDS,
}; };
static Vec3s D_80854730 = { -57, 3377, 0 }; static Vec3s D_80854730 = { -57, 3377, 0 };