fork/training-mode-ce
git clone https://git.julia.blue/fork/training-mode-ce
569ae8b
nix
1#include "../MexTK/mex.h" 2#include "events.h" 3 4void Exit (GOBJ * menu ); 5 6enum options_main { 7OPT_BARREL , 8OPT_EXIT , 9 10OPT_COUNT 11}; 12 13static EventOption Options_Main [OPT_COUNT ]= { 14 { 15 .kind = OPTKIND_TOGGLE , 16 .name = "Target" , 17 .desc = {"Enable a target to attack" }, 18 }, 19 { 20 .kind = OPTKIND_FUNC , 21 .name = "Exit" , 22 .desc = {"Return to the Event Select Screen." }, 23 .OnSelect = Exit , 24 }, 25}; 26 27static EventMenu Menu_Main = { 28 .name = "Float Cancel Training" , 29 .option_num = countof (Options_Main ), 30 .options = Options_Main , 31}; 32 33enum PeachActionStates { 34ASID_FLOAT = 341 , 35ASID_FLOATENDF , 36ASID_FLOATENDB , 37ASID_FLOATATTACKN , 38ASID_FLOATATTACKF , 39ASID_FLOATATTACKB , 40ASID_FLOATATTACKU , 41ASID_FLOATATTACKD , 42}; 43 44enum Action { 45Action_None , 46Action_Wait , 47Action_Float , 48Action_FloatNeutral , 49Action_FloatAttack , 50Action_Hitlag , 51Action_FloatAttackFall , 52Action_FloatAttackFastFall , 53Action_Landing , 54 55Action_Count 56}; 57static char * action_names []= { 58"None" , 59"Wait" , 60"Float" , 61"Deadzone" , 62"Attack" , 63"Hitlag" , 64"Fall" , 65"Fastfall" , 66"Landing" , 67}; 68 69static u32 action_log_cur ; 70static u8 action_log [30 ]; 71 72static GXColor action_colors [Action_Count ]= { 73 {40 ,40 ,40 ,180 },// dark gray - none 74 {80 ,80 ,80 ,180 },// light gray - wait 75 {255 ,128 ,128 ,180 },// red - float 76 {230 ,22 ,198 ,180 },// magenta - deadzone 77 {52 ,202 ,228 ,180 },// cyan - attack 78 {70 ,40 ,60 ,180 },// hitlag 79 {128 ,128 ,255 ,180 },// blue - fall 80 {128 ,255 ,128 ,180 },// green - fastfall 81 {220 ,220 ,70 ,180 },// yellow - landing 82}; 83 84void GX (GOBJ * gobj ,int pass ) { 85// hitbox GX 86if (pass == 1 ) { 87GOBJ * ft = Fighter_GetGObj (0 ); 88FighterData * ft_data = ft -> userdata ; 89 90static GXColor diffuse = {255 ,0 ,0 ,100 }; 91static GXColor ambient = {255 ,255 ,255 ,255 }; 92for (u32 i = 0 ;i < countof (ft_data -> hitbox );++ i ) { 93ftHit * hit = & ft_data -> hitbox [i ]; 94if (hit -> active ) 95Develop_DrawSphere (hit -> size ,& hit -> pos ,& hit -> pos_prev ,& diffuse ,& ambient ); 96 } 97 } 98 99// action log gx 100if (pass == 2 ) { 101event_vars -> HUD_DrawActionLogBar ( 102action_log , 103action_colors , 104countof (action_log ) 105 ); 106 107// skip none and wait states 108event_vars -> HUD_DrawActionLogKey ( 109& action_names [2 ], 110& action_colors [2 ], 111countof (action_names )- 2 112 ); 113 } 114} 115 116void Exit (GOBJ * menu ) { 117stc_match -> state = 3 ; 118Match_EndVS (); 119} 120 121void Event_Init (GOBJ * menu ) { 122// init display gobj 123GOBJ * gobj = GObj_Create (0 ,0 ,0 ); 124GObj_AddGXLink (gobj ,GX ,5 ,0 ); 125} 126 127// prevent action log from filling until first jump. 128static bool started = false; 129 130static GOBJ * barrel ; 131 132void Barrel_Spawn (void ) { 133Vec3 pos = {0 }; 134SpawnItem spawn = { 135 .it_kind = ITEM_BARREL , 136 .pos = pos , 137 .pos2 = pos , 138 .facing_direction = 1 , 139 .is_raycast_below = 1 , 140 }; 141barrel = Item_CreateItem2 (& spawn ); 142} 143 144int Barrel_OnTakeDamage (GOBJ * _ ) { 145GOBJ * ft = Fighter_GetGObj (0 ); 146FighterData * ft_data = ft -> userdata ; 147int state = ft_data -> state_id ; 148 149if (ASID_FLOATATTACKN <=state && state <=ASID_FLOATATTACKD ) { 150ItemData * data = barrel -> userdata ; 151Effect_SpawnSync (1063 ,barrel ,& data -> pos ); 152 } 153return false; 154} 155void Barrel_OnDestroy (GOBJ * _ ) { 156if (Options_Main [OPT_BARREL ].val ) 157Barrel_Spawn (); 158} 159 160void Event_Think (GOBJ * menu ) { 161// barrel ------------------------------------------------------------------ 162 163if (Options_Main [OPT_BARREL ].val ) { 164if (barrel == 0 ) 165Barrel_Spawn (); 166 167// Some internal functions adjust these in think functions, 168// so we need to set it every frame. 169ItemData * data = barrel -> userdata ; 170data -> it_func -> OnTakeDamage = Barrel_OnTakeDamage ; 171data -> it_func -> OnDestroy = Barrel_OnDestroy ; 172data -> can_hold = false; 173 } 174 175if (!Options_Main [OPT_BARREL ].val && barrel != 0 ) { 176GObj_Destroy (barrel ); 177barrel = 0 ; 178 } 179 180// action log -------------------------------------------------------------- 181 182 { 183GOBJ * ft = Fighter_GetGObj (0 ); 184FighterData * ft_data = ft -> userdata ; 185 186int state = ft_data -> state_id ; 187int is_fastfall = ft_data -> flags .is_fastfall ; 188 189// determine current action 190int cur_action ; 191bool reset = false; 192if (ft_data -> flags .hitlag ) { 193cur_action = Action_Hitlag ; 194 }else if (state == ASID_JUMPF || state == ASID_JUMPB ) { 195started = true; 196cur_action = Action_None ; 197 198// reset action log on the final frame of jumpsquat 199reset = ft_data -> TM .state_frame == 2 ; 200 }else if (state == ASID_FLOAT ) { 201if (ft_data -> input .lstick .X == 0.f && ft_data -> input .lstick .Y == 0.f ) 202cur_action = Action_FloatNeutral ; 203else 204cur_action = Action_Float ; 205 }else if (state >=ASID_FLOATATTACKN && state <=ASID_FLOATATTACKD ) { 206if (ft_data -> phys .self_vel .Y == 0.f ) 207cur_action = Action_FloatAttack ; 208else 209cur_action = is_fastfall ?Action_FloatAttackFastFall :Action_FloatAttackFall ; 210 }else if (state == ASID_LANDING || state == ASID_SQUAT || state == ASID_SQUATWAIT || state == ASID_SQUATRV ) { 211cur_action = Action_Landing ; 212 }else { 213cur_action = Action_Wait ; 214 } 215 216if (!started )return ; 217 218if (reset ) { 219memset (action_log ,Action_None ,sizeof (action_log )); 220action_log_cur = 0 ; 221 }else if (action_log_cur < countof (action_log )) { 222action_log [action_log_cur ++ ]= cur_action ; 223 } 224 } 225} 226 227EventMenu * Event_Menu = & Menu_Main ;