Merge pull request #291 from Cuyler36:scaffold_effect

Scaffold ef_effect_control structs
This commit is contained in:
Cuyler36
2024-03-11 00:57:31 -04:00
committed by GitHub
2 changed files with 395 additions and 316 deletions
+105 -9
View File
@@ -4,11 +4,14 @@
#include "types.h"
#include "m_lib.h"
#include "m_actor.h"
#include "m_lights.h"
#ifdef __cplusplus
extern "C" {
#endif
#define eEC_EFFECT_ACTIVE_MAX 100
enum effect_type {
eEC_EFFECT_SHOCK,
eEC_EFFECT_DUST,
@@ -149,27 +152,120 @@ enum {
eEC_LIGHT_COLOR_NUM
};
typedef void (*eEC_NAME2EFFECTMAKE_PROC)(int, xyz_t, int, short, GAME*, u16, s16, s16);
typedef void (*eEC_NAME2EFFECTKILL_PROC)(int, u16);
typedef struct effect_s eEC_Effect_c;
typedef void (*eEC_REGISTEFFECTLIGHT_PROC)(f32*, s16, s16, s16);
struct effect_s {
s16 timer;
s16 name;
s16 prog_idx;
s16 arg0;
s16 arg1;
s16 _0A;
u16 item_name;
u8 prio;
u8 state;
xyz_t position;
xyz_t velocity;
xyz_t acceleration;
xyz_t scale;
xyz_t offset;
s16 effect_specific[6];
};
typedef int (*eEC_EFFECTLIGHTSTATUS_PROC)(rgba_t*, int*); // returns eEC_LIGHT_COLOR_*
typedef void (*eEC_EFFECT_INIT_PROC)(xyz_t, int, s16, GAME*, u16, s16, s16);
typedef void (*eEC_EFFECT_CT_PROC)(eEC_Effect_c*, GAME*, void*);
typedef void (*eEC_EFFECT_MOVE_PROC)(eEC_Effect_c*, GAME*);
typedef void (*eEC_EFFECT_DRAW_PROC)(eEC_Effect_c*, GAME*);
typedef struct effect_profile_s {
eEC_EFFECT_INIT_PROC init_proc;
eEC_EFFECT_CT_PROC ct_proc;
eEC_EFFECT_MOVE_PROC move_proc;
eEC_EFFECT_DRAW_PROC draw_proc;
s16 n_frames;
s16 child_effect_id;
f32 max_dist;
} eEC_PROFILE_c;
typedef struct morph_data_s {
u8 start_frame;
u8 end_frame;
u8 morph_flag;
f32 start_val;
f32 end_val;
} eEC_morph_data_c;
typedef struct light_data_s {
s16 ctr;
rgba_t start_color;
rgba_t target_color;
s16 max_frame;
s16 n_frames;
int light_state;
int shadow_flag;
} eEC_light_data_c;
typedef void (*eEC_NAME2EFFECTMAKE_PROC)(int effect_id, xyz_t position, int prio, s16 angle, GAME* game, u16 item_name,
s16 arg0, s16 arg1);
typedef void (*eEC_NAME2EFFECTKILL_PROC)(int effect_id, u16 item_name);
typedef void (*eEC_NAME2EFFECTKILLALL_PROC)(u16 item_name);
typedef void (*eEC_VECTORROTATEY_PROC)(xyz_t* ofs, f32 rot_rad);
typedef s16 (*eEC_RANDOMFIRSTSPEED_PROC)(xyz_t* speed, f32 y, f32 max_z, f32 max_x);
typedef void (*eEC_SETCONTINIOUSENV_PROC)(eEC_Effect_c* effect, s16 unused, s16 timer);
typedef f32 (*eEC_CALCADJUST_PROC)(s16 now_timer, s16 start_timer, s16 end_timer, f32 start_val, f32 end_val);
typedef void (*eEC_AUTOMATRIXXLU_PROC)(GAME* game, xyz_t* pos, xyz_t* scale);
typedef void (*eEC_AUTOMATRIXXLU_OFFSET_PROC)(GAME* game, xyz_t* pos, xyz_t* scale, xyz_t* offset);
typedef eEC_Effect_c* (*eEC_MAKEEFFECT_PROC)(s16 effect_id, xyz_t* pos, xyz_t* ofs, GAME* game, void* ct_arg,
u16 item_name, int prio, s16 arg0, s16 arg1);
typedef void (*eEC_MORPHCOMBINE_PROC)(u8* result, eEC_morph_data_c* morph_data, s16 now_timer);
typedef void (*eEC_REGISTEFFECTLIGHT_PROC)(rgba_t color, s16 max_frames, s16 n_frames, int shadow_flag);
typedef void (*eEC_DECIDELIGHTPOWER_PROC)(rgba_t* result_color, rgba_t base_color, xyz_t pos, GAME* game, f32 max_power,
f32 min_power, f32 max_dist);
typedef int (*eEC_CHECKLOOKATBLOCK_PROC)(xyz_t pos);
typedef int (*eEC_EFFECTLIGHTSTATUS_PROC)(rgba_t* color, int* shadow_flag); // returns eEC_LIGHT_COLOR_*
typedef int (*eEC_SPECIALBLOCKCENTERPOS_PROC)(xyz_t* pos, u32 block_kind);
typedef struct effect_control_clip_s {
/* 0x00 */ eEC_NAME2EFFECTMAKE_PROC effect_make_proc;
/* 0x04 */ eEC_NAME2EFFECTKILL_PROC effect_kill_proc;
/* 0x08 */ u8 _08[0x30 - 0x08];
/* 0x08 */ eEC_VECTORROTATEY_PROC vector_rotate_y_proc;
/* 0x0C */ eEC_RANDOMFIRSTSPEED_PROC random_first_speed_proc;
/* 0x10 */ eEC_SETCONTINIOUSENV_PROC set_continious_env_proc;
/* 0x14 */ eEC_CALCADJUST_PROC calc_adjust_proc;
/* 0x18 */ eEC_AUTOMATRIXXLU_PROC auto_matrix_xlu_proc;
/* 0x1C */ eEC_AUTOMATRIXXLU_OFFSET_PROC auto_matrix_xlu_offset_proc;
/* 0x20 */ void* _20; // unused in AC
/* 0x24 */ void* _24; // unused in AC
/* 0x28 */ eEC_MAKEEFFECT_PROC make_effect_proc;
/* 0x2C */ eEC_MORPHCOMBINE_PROC morph_combine_proc;
/* 0x30 */ eEC_REGISTEFFECTLIGHT_PROC regist_effect_light;
/* 0x34 */ void* _34;
/* 0x38 */ void* _38;
/* 0x34 */ eEC_DECIDELIGHTPOWER_PROC decide_light_power_proc;
/* 0x38 */ eEC_CHECKLOOKATBLOCK_PROC check_lookat_block_proc;
/* 0x3C */ eEC_EFFECTLIGHTSTATUS_PROC effect_light_status;
/* 0x40 */ void* _40;
/* 0x44 */ void* _44;
/* 0x40 */ eEC_SPECIALBLOCKCENTERPOS_PROC special_block_center_pos_proc;
/* 0x44 */ eEC_NAME2EFFECTKILLALL_PROC effect_kill_all_proc;
} eEC_EffectControl_Clip_c;
typedef struct effect_control_s EFFECT_CONTROL_ACTOR;
// almost entirely scrapped in AC (functionally scrapped?)
typedef struct effect_prog_info_s {
u8 _00[0x18]; // scrapped
s16 end_frame;
u8 _1A[0x06]; // scrapped
} eEC_program_info_c;
typedef struct effect_work_s {
u8 _0000[0x004C - 0x0000];
eEC_program_info_c program_info[6];
u8 _010C[0x01D0 - 0x010C];
int active_effect_num;
eEC_Effect_c effects[eEC_EFFECT_ACTIVE_MAX];
u8 effect_active_flags[eEC_EFFECT_ACTIVE_MAX];
Lights light_info;
int _24A8;
} eEC_work_c;
struct effect_control_s {
ACTOR actor_class;
eEC_EffectControl_Clip_c clip;
+290 -307
View File
@@ -18,21 +18,16 @@ static void Weather_Actor_dt(ACTOR* actor, GAME* game);
static void Weather_Actor_move(ACTOR* actor, GAME* game);
static void Weather_Actor_draw(ACTOR* actor, GAME* game);
static void aWeather_SetNowProfile(WEATHER_ACTOR* weather, s16 id);
static aWeather_Profile_c* profile_tbl[] = {
&iam_weather_fine,
&iam_weather_rain,
&iam_weather_snow,
&iam_weather_sakura,
&iam_weather_leaf,
&iam_weather_fine, &iam_weather_rain, &iam_weather_snow, &iam_weather_sakura, &iam_weather_leaf,
};
ACTOR_PROFILE Weather_Profile = {
mAc_PROFILE_WEATHER,
ACTOR_PART_CONTROL,
ACTOR_STATE_CAN_MOVE_IN_DEMO_SCENES | ACTOR_STATE_NO_MOVE_WHILE_CULLED| ACTOR_STATE_NO_DRAW_WHILE_CULLED,
ACTOR_STATE_CAN_MOVE_IN_DEMO_SCENES | ACTOR_STATE_NO_MOVE_WHILE_CULLED | ACTOR_STATE_NO_DRAW_WHILE_CULLED,
EMPTY_NO,
ACTOR_OBJ_BANK_KEEP,
sizeof(WEATHER_ACTOR),
@@ -43,17 +38,16 @@ ACTOR_PROFILE Weather_Profile = {
NULL,
};
static void aWeather_SysLevCall_MoveEnd(WEATHER_ACTOR* weather){
static void aWeather_SysLevCall_MoveEnd(WEATHER_ACTOR* weather) {
if(weather->basement_event == 1){
if (weather->basement_event == 1) {
weather->stop_sound_effect = 0;
weather->start_sound_effect = 0;
}
else{
if(weather->stop_sound_effect != 0){
} else {
if (weather->stop_sound_effect != 0) {
sAdo_SysLevStop(weather->stop_sound_effect);
}
if(weather->start_sound_effect != 0){
if (weather->start_sound_effect != 0) {
sAdo_SysLevStart(weather->start_sound_effect);
}
weather->stop_sound_effect = 0;
@@ -61,25 +55,24 @@ static void aWeather_SysLevCall_MoveEnd(WEATHER_ACTOR* weather){
}
}
static void aWeather_SysLevStart(u8 flag){
static void aWeather_SysLevStart(u8 flag) {
Common_Get(clip.weather_clip)->actor->start_sound_effect = flag;
}
}
static void aWeather_SysLevStop(u8 flag){
static void aWeather_SysLevStop(u8 flag) {
int stopFlag = flag;
WEATHER_ACTOR* weather = Common_Get(clip.weather_clip)->actor;
if(weather->start_sound_effect == stopFlag){
if (weather->start_sound_effect == stopFlag) {
weather->start_sound_effect = 0;
}
else{
} else {
weather->stop_sound_effect = stopFlag;
}
}
static void aWeather_weatherinfo_CommonSet(s16 type, s16 intensity){
static void aWeather_weatherinfo_CommonSet(s16 type, s16 intensity) {
if(type >= mEnv_WEATHER_LEAVES){
if (type >= mEnv_WEATHER_LEAVES) {
type = 0;
}
@@ -87,71 +80,72 @@ static void aWeather_weatherinfo_CommonSet(s16 type, s16 intensity){
Common_Set(weather_intensity, intensity);
}
static void aWeather_RequestChangeWeather(ACTOR* actor, s16 status, s16 level){
static void aWeather_RequestChangeWeather(ACTOR* actor, s16 status, s16 level) {
WEATHER_ACTOR* weather = (WEATHER_ACTOR*)actor;
if(mEnv_ReqeustChangeWeatherEnviroment(weather->current_status, status) != 0){
if(status != weather->current_status){
if (mEnv_ReqeustChangeWeatherEnviroment(weather->current_status, status) != 0) {
if (status != weather->current_status) {
weather->next_status = status;
weather->next_level = level;
weather->request_change = TRUE;
weather->current_aim_level = 0;
}
else{
} else {
weather->current_aim_level = level;
}
}
}
extern void aWeather_RequestChangeWeatherToIsland(){
aWeather_RequestChangeWeather(&Common_Get(clip.weather_clip)->actor->actor_class,Common_Get(island_weather),Common_Get(island_weather_intensity));
extern void aWeather_RequestChangeWeatherToIsland() {
aWeather_RequestChangeWeather(&Common_Get(clip.weather_clip)->actor->actor_class, Common_Get(island_weather),
Common_Get(island_weather_intensity));
}
extern void aWeather_RequestChangeWeatherFromIsland(){
aWeather_RequestChangeWeather(&Common_Get(clip.weather_clip)->actor->actor_class, mEnv_SAVE_GET_WEATHER_TYPE(Save_Get(weather)) , mEnv_SAVE_GET_WEATHER_INTENSITY(Save_Get(weather)));
extern void aWeather_RequestChangeWeatherFromIsland() {
aWeather_RequestChangeWeather(&Common_Get(clip.weather_clip)->actor->actor_class,
mEnv_SAVE_GET_WEATHER_TYPE(Save_Get(weather)),
mEnv_SAVE_GET_WEATHER_INTENSITY(Save_Get(weather)));
}
int aWeather_GetWeatherPrvNum(ACTOR* actor){
int aWeather_GetWeatherPrvNum(ACTOR* actor) {
WEATHER_ACTOR* weather = (WEATHER_ACTOR*)actor;
aWeather_Priv* priv = weather->priv;
int i;
int num = 0;
for(i = 100; i != 0; i--, priv++, num++){
if(priv->use == 0){
for (i = 100; i != 0; i--, priv++, num++) {
if (priv->use == 0) {
return num;
}
}
return -1;
return -1;
}
void aWeather_AbolishPrivate(ACTOR* actor, int num){
void aWeather_AbolishPrivate(ACTOR* actor, int num) {
WEATHER_ACTOR* weather = (WEATHER_ACTOR*)actor;
aWeather_Priv* priv = weather->priv;
if(priv != NULL){
if (priv != NULL) {
priv = &priv[num];
if(priv->use != 0){
if (priv->use != 0) {
priv->use = 0;
}
}
}
aWeather_Priv* aWeather_GetWeatherPrv(u8 status, s16 timer, xyz_t* pos, xyz_t* speed, ACTOR* actor, int id){
aWeather_Priv* aWeather_GetWeatherPrv(u8 status, s16 timer, xyz_t* pos, xyz_t* speed, ACTOR* actor, int id) {
WEATHER_ACTOR* weather = (WEATHER_ACTOR*)actor;
aWeather_Priv* priv = weather->priv;
if((id != -1) && (id < 100)){
if(priv[id].use == 0){
if ((id != -1) && (id < 100)) {
if (priv[id].use == 0) {
priv[id].use = 1;
priv[id].status = status;
priv[id].status = status;
priv[id].timer = timer;
priv[id].id = id;
if(pos != NULL){
priv[id].pos = *pos;
if (pos != NULL) {
priv[id].pos = *pos;
}
if(speed != NULL){
if (speed != NULL) {
priv[id].speed = *speed;
}
return &priv[id];
@@ -161,47 +155,44 @@ aWeather_Priv* aWeather_GetWeatherPrv(u8 status, s16 timer, xyz_t* pos, xyz_t* s
return NULL;
}
int aWeather_StopSysLevSE(){
int aWeather_StopSysLevSE() {
WEATHER_ACTOR* weather = Common_Get(clip.weather_clip)->actor;
u8 current = weather->current_sound_effect;
if(weather->sound_flag == 0){
if(((u8)(current - 7) <= 2U) || (u8)(current - 18) <= 1U ||
current == 20){
aWeather_SysLevStop(current);
}
if (weather->sound_flag == 0) {
if (((u8)(current - 7) <= 2U) || (u8)(current - 18) <= 1U || current == 20) {
aWeather_SysLevStop(current);
}
weather->sound_flag = 1;
return 1;
}
else{
} else {
return 0;
}
}
int aWeather_StartSysLevSE(){
int aWeather_StartSysLevSE() {
WEATHER_ACTOR* weather = Common_Get(clip.weather_clip)->actor;
u8 current = weather->current_sound_effect;
if(weather->sound_flag == 1){
if(mEnv_SAVE_GET_WEATHER_TYPE(Save_Get(weather)) == 1){
switch(mEnv_SAVE_GET_WEATHER_INTENSITY(Save_Get(weather))){
if (weather->sound_flag == 1) {
if (mEnv_SAVE_GET_WEATHER_TYPE(Save_Get(weather)) == 1) {
switch (mEnv_SAVE_GET_WEATHER_INTENSITY(Save_Get(weather))) {
case 1:
aWeather_SysLevStart(7);
weather->current_sound_effect = 7;
break;
case 2:
aWeather_SysLevStart(8);
weather->current_sound_effect = 8;
break;
case 3:
aWeather_SysLevStart(9);
weather->current_sound_effect = 9;
break;
aWeather_SysLevStart(7);
weather->current_sound_effect = 7;
break;
case 2:
aWeather_SysLevStart(8);
weather->current_sound_effect = 8;
break;
case 3:
aWeather_SysLevStart(9);
weather->current_sound_effect = 9;
break;
}
}
weather->sound_flag = 2;
@@ -209,99 +200,99 @@ int aWeather_StartSysLevSE(){
return 0;
}
void aWeather_ChangeWeatherInstance(WEATHER_ACTOR* weather, s16 status, s16 level){
void aWeather_ChangeWeatherInstance(WEATHER_ACTOR* weather, s16 status, s16 level) {
weather->next_status = status;
weather->next_level = level;
weather->next_level = level;
weather->current_status = status;
weather->current_level = 0;
weather->current_level = 0;
weather->request_change = TRUE;
if(!aWeather_CountWeatherPrivate(weather)){
if (!aWeather_CountWeatherPrivate(weather)) {
weather->current_status = weather->next_status;
aWeather_SetNowProfile(weather, weather->current_status);
aWeather_weatherinfo_CommonSet(weather->current_status, weather->next_level);
weather->current_level = level;
weather->current_level = level;
weather->current_aim_level = weather->next_level;
weather->request_change = FALSE;
}
}
int aWeather_IsLand_Event_Check(){
int aWeather_IsLand_Event_Check() {
if(((mFI_CheckBeforeScenePerpetual() != 0) || (mFI_GetClimate() == 1)) &&
(Common_Get(island_weather) != (s16)mEnv_SAVE_GET_WEATHER_TYPE(Save_Get(weather)))){
return 1;
}
return 0;
}
int aWeather_Basement_Event_Check(WEATHER_ACTOR* weather){
if((weather->basement_event == 1) || (weather->basement_event == 2)){
if (((mFI_CheckBeforeScenePerpetual() != 0) || (mFI_GetClimate() == 1)) &&
(Common_Get(island_weather) != (s16)mEnv_SAVE_GET_WEATHER_TYPE(Save_Get(weather)))) {
return 1;
}
return 0;
}
static void aWeather_ChangeEnvSE(WEATHER_ACTOR* weather, GAME_PLAY* play, s16 status, s16 level){
int aWeather_Basement_Event_Check(WEATHER_ACTOR* weather) {
if ((weather->basement_event == 1) || (weather->basement_event == 2)) {
return 1;
}
return 0;
}
static void aWeather_ChangeEnvSE(WEATHER_ACTOR* weather, GAME_PLAY* play, s16 status, s16 level) {
u8 current = weather->current_sound_effect;
if(weather->sound_flag == 1 || weather->sound_flag == 2)
if (weather->sound_flag == 1 || weather->sound_flag == 2)
return;
if(((u8)(current - 7) <= 2U) || (u8)(current - 18) <= 1U || current == 20){
aWeather_SysLevStop(current);
if (((u8)(current - 7) <= 2U) || (u8)(current - 18) <= 1U || current == 20) {
aWeather_SysLevStop(current);
weather->current_sound_effect = -1000;
}
if (mEv_CheckTitleDemo() <= 0) {
if (Save_Get(scene_no) == SCENE_START_DEMO || Save_Get(scene_no) == SCENE_START_DEMO2 || Save_Get(scene_no) == SCENE_START_DEMO3) {
if (Save_Get(scene_no) == SCENE_START_DEMO || Save_Get(scene_no) == SCENE_START_DEMO2 ||
Save_Get(scene_no) == SCENE_START_DEMO3) {
return;
}
if((status == 1) && (weather->current_sound_effect == -1000)){
if ((status == 1) && (weather->current_sound_effect == -1000)) {
switch (level) {
case 1:
if (mPlib_check_player_open_umbrella(play) != 0) {
aWeather_SysLevStart(0x12);
weather->current_sound_effect = 0x12;
return;
}
aWeather_SysLevStart(7);
weather->current_sound_effect = 7;
break;
case 2:
if (mPlib_check_player_open_umbrella(play) != 0) {
aWeather_SysLevStart(0x13);
weather->current_sound_effect = 0x13;
return;
}
aWeather_SysLevStart(8);
weather->current_sound_effect = 8;
break;
case 3:
if (mPlib_check_player_open_umbrella(play) != 0) {
aWeather_SysLevStart(0x14);
weather->current_sound_effect = 0x14;
return;
}
aWeather_SysLevStart(9);
weather->current_sound_effect = 9;
break;
case 1:
if (mPlib_check_player_open_umbrella(play) != 0) {
aWeather_SysLevStart(0x12);
weather->current_sound_effect = 0x12;
return;
}
aWeather_SysLevStart(7);
weather->current_sound_effect = 7;
break;
case 2:
if (mPlib_check_player_open_umbrella(play) != 0) {
aWeather_SysLevStart(0x13);
weather->current_sound_effect = 0x13;
return;
}
aWeather_SysLevStart(8);
weather->current_sound_effect = 8;
break;
case 3:
if (mPlib_check_player_open_umbrella(play) != 0) {
aWeather_SysLevStart(0x14);
weather->current_sound_effect = 0x14;
return;
}
aWeather_SysLevStart(9);
weather->current_sound_effect = 9;
break;
}
}
}
}
}
}
static void aWeather_EndEnvSE(ACTOR* actor){
static void aWeather_EndEnvSE(ACTOR* actor) {
WEATHER_ACTOR* weather = (WEATHER_ACTOR*)actor;
u8 current = weather->current_sound_effect;
if ((sAdo_GameframeEnd_Check() == 1) || ((sAdo_GameframeEnd_Check() == 2) &&
((aWeather_IsLand_Event_Check() != 0) || (aWeather_Basement_Event_Check(weather) != 0)))) {
if (((u8)(current - 7) <= 2) || ( (u8)(current - 0x12) <= 1) || (u8)(current == 0x14)) {
if ((sAdo_GameframeEnd_Check() == 1) ||
((sAdo_GameframeEnd_Check() == 2) &&
((aWeather_IsLand_Event_Check() != 0) || (aWeather_Basement_Event_Check(weather) != 0)))) {
if (((u8)(current - 7) <= 2) || ((u8)(current - 0x12) <= 1) || (u8)(current == 0x14)) {
aWeather_SysLevStop(current);
weather->current_sound_effect = -1000;
Common_Set(current_sound_effect, -1000);
@@ -312,50 +303,48 @@ static void aWeather_EndEnvSE(ACTOR* actor){
aWeather_SysLevCall_MoveEnd(weather);
}
void aWeather_SetNowProfile(WEATHER_ACTOR* weather, s16 id){
void aWeather_SetNowProfile(WEATHER_ACTOR* weather, s16 id) {
if(!mFI_GET_TYPE(mFI_GetFieldId())){
if (!mFI_GET_TYPE(mFI_GetFieldId())) {
weather->current_profile = profile_tbl[id];
}
else{
} else {
weather->current_profile = NULL;
}
}
void aWeather_SecureWeatherPrivateWork(WEATHER_ACTOR* weather){
void aWeather_SecureWeatherPrivateWork(WEATHER_ACTOR* weather) {
int i;
weather->priv = zelda_malloc(sizeof(aWeather_Priv) * 100);
if(weather->priv != NULL){
for(i = 0; i < 100; i++){
if (weather->priv != NULL) {
for (i = 0; i < 100; i++) {
bzero(&weather->priv[i], sizeof(aWeather_Priv));
}
}
}
static void aWeather_SetClip(WEATHER_ACTOR* weather, int flag){
static void aWeather_SetClip(WEATHER_ACTOR* weather, int flag) {
aWeather_Clip_c* clip;
if(flag != 0){
if (flag != 0) {
Common_Set(clip.weather_clip, NULL);
}
else{
} else {
clip = &weather->clip;
clip->actor = weather;
clip->change_weather = aWeather_RequestChangeWeather;
clip->get_priv_num = aWeather_GetWeatherPrvNum;
clip->remove_priv = aWeather_AbolishPrivate;
clip->remove_priv = aWeather_AbolishPrivate;
clip->get_priv = aWeather_GetWeatherPrv;
clip->stop_sound = aWeather_StopSysLevSE;
clip->start_sound = aWeather_StartSysLevSE;
clip->change_weather_instance = aWeather_ChangeWeatherInstance;
Common_Set(clip.weather_clip, clip);
Common_Set(clip.weather_clip, clip);
}
}
void aWeather_RenewWindInfo(WEATHER_ACTOR* weather){
void aWeather_RenewWindInfo(WEATHER_ACTOR* weather) {
s_xyz pos = Common_Get(wind); // multiply by 1 means inline ?
f32 speed = Common_Get(wind_speed) * 0.01f;
f32 factor = 1.0f;
@@ -365,49 +354,42 @@ void aWeather_RenewWindInfo(WEATHER_ACTOR* weather){
weather->wind_info.z = pos.z * speed * factor;
}
void aWeather_SnowInAdvance(WEATHER_ACTOR* weather, GAME_PLAY* play, int moves){
void aWeather_SnowInAdvance(WEATHER_ACTOR* weather, GAME_PLAY* play, int moves) {
int i;
for(i = 0; i < moves; i++){
Weather_Actor_move(&weather->actor_class, &play->game);
for (i = 0; i < moves; i++) {
Weather_Actor_move(&weather->actor_class, &play->game);
}
}
void Weather_Actor_ct(ACTOR* actor, GAME* game){
void Weather_Actor_ct(ACTOR* actor, GAME* game) {
static s16 DemoWeatherTbl[5][2] = {
3,1,
1,2,
0,0,
0,0,
2,1,
3, 1, 1, 2, 0, 0, 0, 0, 2, 1,
};
WEATHER_ACTOR* weather = (WEATHER_ACTOR*)actor;
GAME_PLAY* play = (GAME_PLAY*)game;
int cur;
xyz_t* pos = Camera2_getCenterPos_p();
aWeather_SetClip(weather, 0);
if(mEv_CheckTitleDemo() > 0){
cur = mEv_CheckTitleDemo() -1;
if (mEv_CheckTitleDemo() > 0) {
cur = mEv_CheckTitleDemo() - 1;
weather->current_status = DemoWeatherTbl[cur][0];
weather->next_status = DemoWeatherTbl[cur][0];
weather->current_level = DemoWeatherTbl[cur][1];
weather->current_aim_level = DemoWeatherTbl[cur][1];
}
else if(mFI_GetClimate() == 1){
} else if (mFI_GetClimate() == 1) {
weather->current_status = Common_Get(island_weather);
weather->next_status = Common_Get(island_weather);
weather->current_level = Common_Get(island_weather_intensity);
weather->current_aim_level = Common_Get(island_weather_intensity);
}
else{
} else {
weather->current_status = mEnv_SAVE_GET_WEATHER_TYPE(Save_Get(weather));
weather->next_status = weather->current_status;
weather->next_status = weather->current_status;
weather->current_level = mEnv_SAVE_GET_WEATHER_INTENSITY(Save_Get(weather));
weather->current_aim_level = Common_Get(weather_intensity);
}
@@ -416,7 +398,7 @@ void Weather_Actor_ct(ACTOR* actor, GAME* game){
weather->priv = NULL;
weather->request_change = FALSE;
weather->pos = *pos;
weather->pos = *pos;
weather->timer = 0;
weather->timer2 = 0;
@@ -425,102 +407,106 @@ void Weather_Actor_ct(ACTOR* actor, GAME* game){
weather->sound_flag = 0;
aWeather_RenewWindInfo(weather);
if(!mFI_GET_TYPE(mFI_GetFieldId())){
if (!mFI_GET_TYPE(mFI_GetFieldId())) {
aWeather_SecureWeatherPrivateWork(weather);
}
aWeather_SetNowProfile(weather, weather->current_status);
if((weather->current_status == 2) || (weather->current_status == 3)){
if ((weather->current_status == 2) || (weather->current_status == 3)) {
weather->pos.y -= 50.0f;
aWeather_SnowInAdvance(weather, play, 0x28);
aWeather_SnowInAdvance(weather, play, 0x28);
weather->pos.y += 50.0f;
}
weather->stop_sound_effect = 0;
weather->start_sound_effect = 0;
if ((Save_Get(scene_no) == SCENE_MY_ROOM_BASEMENT_S) || ( (Save_Get(scene_no) - SCENE_MY_ROOM_BASEMENT_M) <= 1U) || (Save_Get(scene_no) == SCENE_MY_ROOM_BASEMENT_LL1)) {
if ((Save_Get(scene_no) == SCENE_MY_ROOM_BASEMENT_S) || ((Save_Get(scene_no) - SCENE_MY_ROOM_BASEMENT_M) <= 1U) ||
(Save_Get(scene_no) == SCENE_MY_ROOM_BASEMENT_LL1)) {
weather->basement_event = 1;
} else if (((Common_Get(last_scene_no) == SCENE_MY_ROOM_BASEMENT_S) || ((Common_Get(last_scene_no) - SCENE_MY_ROOM_BASEMENT_M) <= 1U) || (Common_Get(last_scene_no) == SCENE_MY_ROOM_BASEMENT_LL1)) && ( play->fb_wipe_type == 6)) {
} else if (((Common_Get(last_scene_no) == SCENE_MY_ROOM_BASEMENT_S) ||
((Common_Get(last_scene_no) - SCENE_MY_ROOM_BASEMENT_M) <= 1U) ||
(Common_Get(last_scene_no) == SCENE_MY_ROOM_BASEMENT_LL1)) &&
(play->fb_wipe_type == 6)) {
weather->basement_event = 2;
} else {
weather->basement_event = 0;
weather->basement_event = 0;
}
if ((play->fb_wipe_type == 6) && (aWeather_IsLand_Event_Check() == 0) && (aWeather_Basement_Event_Check(weather) == 0)) {
if ((play->fb_wipe_type == 6) && (aWeather_IsLand_Event_Check() == 0) &&
(aWeather_Basement_Event_Check(weather) == 0)) {
weather->current_sound_effect = Common_Get(current_sound_effect);
} else {
weather->current_sound_effect = -1000;
aWeather_ChangeEnvSE(weather, play, weather->current_status, weather->current_level);
aWeather_SysLevCall_MoveEnd(weather);
}
else{
weather->current_sound_effect = -1000;
aWeather_ChangeEnvSE(weather, play, weather->current_status, weather->current_level);
aWeather_SysLevCall_MoveEnd(weather);
}
}
}
static void Weather_Actor_dt(ACTOR* actor, GAME* game){
static void Weather_Actor_dt(ACTOR* actor, GAME* game) {
WEATHER_ACTOR* weather = (WEATHER_ACTOR*)actor;
if(weather->priv != NULL){
if (weather->priv != NULL) {
zelda_free(weather->priv);
}
aWeather_SetClip(weather, 1);
}
static void aWeather_DrawWeatherPrv(ACTOR* actor, GAME* game){
static void aWeather_DrawWeatherPrv(ACTOR* actor, GAME* game) {
WEATHER_ACTOR* weather = (WEATHER_ACTOR*)actor;
aWeather_Priv* priv = weather->priv;
aWeather_Profile_c* profile;
int i;
_texture_z_light_fog_prim_xlu(game->graph);
if((weather->current_profile != NULL) && (priv != NULL)){
if(weather->current_profile->set != NULL){
weather->current_profile->set(game);
}
if(weather->current_profile->draw != NULL){
for(i = 0; i < 100; i++, priv++){
if(priv->use != 0){
if ((weather->current_profile != NULL) && (priv != NULL)) {
if (weather->current_profile->set != NULL) {
weather->current_profile->set(game);
}
if (weather->current_profile->draw != NULL) {
for (i = 0; i < 100; i++, priv++) {
if (priv->use != 0) {
weather->current_profile->draw(priv, game);
}
}
}
}
}
static void Weather_Actor_draw(ACTOR* actor, GAME* game){
aWeather_DrawWeatherPrv(actor,game);
}
}
void aWeather_MakeWeatherPrv(ACTOR* actor, GAME* game){
static void Weather_Actor_draw(ACTOR* actor, GAME* game) {
aWeather_DrawWeatherPrv(actor, game);
}
void aWeather_MakeWeatherPrv(ACTOR* actor, GAME* game) {
WEATHER_ACTOR* weather = (WEATHER_ACTOR*)actor;
if(weather->current_level != 0){
if(weather->current_profile != NULL){
if(weather->current_profile->make != NULL){
if (weather->current_level != 0) {
if (weather->current_profile != NULL) {
if (weather->current_profile->make != NULL) {
weather->current_profile->make(actor, game);
}
}
}
}
static void aWeather_MoveWeatherPrv(WEATHER_ACTOR* weather, GAME* game){
static void aWeather_MoveWeatherPrv(WEATHER_ACTOR* weather, GAME* game) {
aWeather_Priv* priv;
int i;
priv = weather->priv;
if((weather->current_profile != NULL) && (priv != NULL) && (weather->current_profile->move != NULL)) {
priv = weather->priv;
for(i = 0; i < 100; i++, priv++){
if(priv->use != 0){
if ((weather->current_profile != NULL) && (priv != NULL) && (weather->current_profile->move != NULL)) {
for (i = 0; i < 100; i++, priv++) {
if (priv->use != 0) {
weather->current_profile->move(priv, game);
if(priv->timer != -100){
if (priv->timer != -100) {
priv->timer--;
if(priv->timer <= 0){
if (priv->timer <= 0) {
aWeather_AbolishPrivate(&weather->actor_class, i);
}
}
@@ -529,35 +515,34 @@ static void aWeather_MoveWeatherPrv(WEATHER_ACTOR* weather, GAME* game){
}
}
int aWeather_CountWeatherPrivate(WEATHER_ACTOR* weather){
int aWeather_CountWeatherPrivate(WEATHER_ACTOR* weather) {
int i;
int count;
aWeather_Priv* priv = weather->priv;
count = 0;
for(i = 0; i < 100; i++, priv++){
if(priv->use != 0){
count++;
for (i = 0; i < 100; i++, priv++) {
if (priv->use != 0) {
count++;
}
}
return count;
}
static void aWeather_ChangeWeather(WEATHER_ACTOR* weather, GAME_PLAY* play){
static void aWeather_ChangeWeather(WEATHER_ACTOR* weather, GAME_PLAY* play) {
if((weather->request_change == TRUE) && (weather->current_level == 0)){
if(mFI_GET_TYPE(mFI_GetFieldId())){
if ((weather->request_change == TRUE) && (weather->current_level == 0)) {
if (mFI_GET_TYPE(mFI_GetFieldId())) {
weather->current_status = weather->next_status;
aWeather_weatherinfo_CommonSet(weather->current_status, weather->next_level);
weather->current_level = 1;
weather->current_aim_level = weather->next_level;
aWeather_ChangeEnvSE(weather, play, weather->current_status, weather->current_level);
weather->request_change = FALSE;
}
else if(aWeather_CountWeatherPrivate(weather) == 0){
} else if (aWeather_CountWeatherPrivate(weather) == 0) {
weather->current_status = weather->next_status;
aWeather_SetNowProfile(weather, weather->current_status);
aWeather_weatherinfo_CommonSet(weather->current_status, weather->next_level);
@@ -569,87 +554,87 @@ static void aWeather_ChangeWeather(WEATHER_ACTOR* weather, GAME_PLAY* play){
}
}
void aWeather_CheckWeatherTimer(){
void aWeather_CheckWeatherTimer() {
s_xyz dir;
mEnv_DecideWindDirect(&dir, 0x3000, 0x3000);
}
void aWeather_RenewWeatherLevel(WEATHER_ACTOR* weather, GAME_PLAY* play){
void aWeather_RenewWeatherLevel(WEATHER_ACTOR* weather, GAME_PLAY* play) {
s16 level;
if(weather->current_level != weather->current_aim_level){
if (weather->current_level != weather->current_aim_level) {
weather->counter++;
if(weather->counter >= 180){
if (weather->counter >= 180) {
weather->counter = 0;
level = weather->current_level;
if (weather->current_aim_level < level)
weather->current_level--;
else
level = weather->current_level;
if (weather->current_aim_level < level)
weather->current_level--;
else
weather->current_level++;
aWeather_ChangeEnvSE(weather, play, weather->current_status, weather->current_level);
}
}
}
static void aWeather_ChangeWeatherTime0(WEATHER_ACTOR* weather){
static void aWeather_ChangeWeatherTime0(WEATHER_ACTOR* weather) {
s16 rndWeather, rndIntensity;
s16 evWeather, evIntensity;
s16 save_weather;
if ((mEv_CheckTitleDemo() <= 0)){
if ((Save_Get(scene_no) == SCENE_START_DEMO) || (Save_Get(scene_no) == SCENE_START_DEMO2) || Save_Get(scene_no) == SCENE_START_DEMO3) {
return;
}
if(!(mFI_CheckPlayerBlockInfo() & 0x400000) && (mTM_check_renew_time(0) != 0)){
mEnv_RandomWeather(&rndWeather, &rndIntensity);
mEv_GetEventWeather(&evWeather, &evIntensity);
if(evWeather != -1){
rndWeather = evWeather;
rndIntensity = evIntensity;
}
if((mEv_CheckRealArbeit() == 1) && (rndWeather == 1)){
rndWeather = 0;
rndIntensity = 0;
}
mTM_off_renew_time(0);
save_weather = mEnv_SAVE_GET_WEATHER_TYPE(Save_Get(weather));
if (rndWeather == 0 || rndWeather == 3) {
if (save_weather == 2 || save_weather == 1) {
mEnv_PreRainNowFine_Init();
}
}
Save_Set(weather, rndIntensity | (rndWeather * 16));
if(((mEv_CheckTitleDemo() != -9) || ( weather->sound_flag != 1))
&& (mFI_CheckInIsland() == 0)){
aWeather_RequestChangeWeather(&weather->actor_class, rndWeather, rndIntensity);
}
Common_Set(weather_time, Common_Get(time.rtc_time));
}
}
}
static void aWeather_MakeKaminari(WEATHER_ACTOR* weather){
lbRTC_time_c time = Common_Get(time.rtc_time);
u8 month = time.month;
s16 timer;
if (( weather->basement_event != 1)) {
if (( Save_Get(scene_no) == SCENE_START_DEMO) || (Save_Get(scene_no) == SCENE_START_DEMO2) || Save_Get(scene_no) == SCENE_START_DEMO3) {
if ((mEv_CheckTitleDemo() <= 0)) {
if ((Save_Get(scene_no) == SCENE_START_DEMO) || (Save_Get(scene_no) == SCENE_START_DEMO2) ||
Save_Get(scene_no) == SCENE_START_DEMO3) {
return;
}
if ((month >= lbRTC_JUNE) && (month <= lbRTC_AUGUST) && (weather->current_status == 1) && ( weather->current_level == 3)){
timer = weather->lightning_timer % 1000;
if (((timer == weather->lightning_timer2) || (timer == (weather->lightning_timer2 + 20))) &&
(Common_Get(clip.effect_clip) != NULL) && ( (Save_Get(scene_no) - SCENE_MY_ROOM_BASEMENT_S) > 3U) &&
( (Save_Get(scene_no) - SCENE_MUSEUM_ROOM_PAINTING) > 1U) && ( Save_Get(scene_no) != SCENE_MUSEUM_ROOM_FISH)) {
f32 effect[] = { 12712.249f };
Common_Get(clip.effect_clip)->regist_effect_light(effect, 2, 0x23, 0);
if (!(mFI_CheckPlayerBlockInfo() & 0x400000) && (mTM_check_renew_time(0) != 0)) {
mEnv_RandomWeather(&rndWeather, &rndIntensity);
mEv_GetEventWeather(&evWeather, &evIntensity);
if (evWeather != -1) {
rndWeather = evWeather;
rndIntensity = evIntensity;
}
if ((mEv_CheckRealArbeit() == 1) && (rndWeather == 1)) {
rndWeather = 0;
rndIntensity = 0;
}
mTM_off_renew_time(0);
save_weather = mEnv_SAVE_GET_WEATHER_TYPE(Save_Get(weather));
if (rndWeather == 0 || rndWeather == 3) {
if (save_weather == 2 || save_weather == 1) {
mEnv_PreRainNowFine_Init();
}
}
Save_Set(weather, rndIntensity | (rndWeather * 16));
if (((mEv_CheckTitleDemo() != -9) || (weather->sound_flag != 1)) && (mFI_CheckInIsland() == 0)) {
aWeather_RequestChangeWeather(&weather->actor_class, rndWeather, rndIntensity);
}
Common_Set(weather_time, Common_Get(time.rtc_time));
}
}
}
static void aWeather_MakeKaminari(WEATHER_ACTOR* weather) {
lbRTC_time_c time = Common_Get(time.rtc_time);
u8 month = time.month;
s16 timer;
if ((weather->basement_event != 1)) {
if ((Save_Get(scene_no) == SCENE_START_DEMO) || (Save_Get(scene_no) == SCENE_START_DEMO2) ||
Save_Get(scene_no) == SCENE_START_DEMO3) {
return;
}
if ((month >= lbRTC_JUNE) && (month <= lbRTC_AUGUST) && (weather->current_status == 1) &&
(weather->current_level == 3)) {
timer = weather->lightning_timer % 1000;
if (((timer == weather->lightning_timer2) || (timer == (weather->lightning_timer2 + 20))) &&
(Common_Get(clip.effect_clip) != NULL) && ((Save_Get(scene_no) - SCENE_MY_ROOM_BASEMENT_S) > 3U) &&
((Save_Get(scene_no) - SCENE_MUSEUM_ROOM_PAINTING) > 1U) &&
(Save_Get(scene_no) != SCENE_MUSEUM_ROOM_FISH)) {
rgba_t kaminari_color = { 70, 70, 160, 255 };
Common_Get(clip.effect_clip)->regist_effect_light(kaminari_color, 2, 35, FALSE);
}
if (timer == (weather->lightning_timer2 + 65)) {
sAdo_SysTrgStart(0x424);
@@ -660,53 +645,51 @@ static void aWeather_MakeKaminari(WEATHER_ACTOR* weather){
}
}
static void Weather_Actor_move(ACTOR* actor, GAME* game){
static void Weather_Actor_move(ACTOR* actor, GAME* game) {
GAME_PLAY* play = (GAME_PLAY*)game;
WEATHER_ACTOR* weather = (WEATHER_ACTOR*)actor;
xyz_t* pos;
Camera2* camera;
s16 angle;
s16 umbrella;
pos = Camera2_getCenterPos_p();
camera = &play->camera;
angle = search_position_angleY(&camera->lookat.center, &camera->lookat.eye);
camera = &play->camera;
angle = search_position_angleY(&camera->lookat.center, &camera->lookat.eye);
aWeather_MakeKaminari(weather);
aWeather_CheckWeatherTimer(weather);
aWeather_MakeWeatherPrv(actor, game);
aWeather_RenewWeatherLevel(weather, play);
aWeather_MoveWeatherPrv(weather,game);
aWeather_RenewWeatherLevel(weather, play);
aWeather_MoveWeatherPrv(weather, game);
aWeather_ChangeWeather(weather, play);
weather->pos = *pos;
aWeather_ChangeWeatherTime0(weather);
aWeather_ChangeWeatherTime0(weather);
if(Common_Get(weather) == 1){
if (Common_Get(weather) == 1) {
umbrella = mPlib_check_player_open_umbrella(play);
if(umbrella != weather->umbrella_flag){
if (umbrella != weather->umbrella_flag) {
aWeather_ChangeEnvSE(weather, play, weather->current_status, weather->current_level);
}
weather->umbrella_flag = umbrella;
weather->current_yAngle = angle;
}
if(weather->sound_flag == 2){
if (weather->sound_flag == 2) {
weather->sound_flag = 0;
}
aWeather_EndEnvSE(actor);
aWeather_EndEnvSE(actor);
}
extern int aWeather_ChangingWeather() {
extern int aWeather_ChangingWeather(){
if(Common_Get(clip.weather_clip) != NULL){
if(Common_Get(clip.weather_clip->actor) != NULL){
if (Common_Get(clip.weather_clip) != NULL) {
if (Common_Get(clip.weather_clip->actor) != NULL) {
return Common_Get(clip.weather_clip->actor)->request_change == TRUE;
}
}