Improve cheats (#169)

Cheats suck less now I guess.
This commit is contained in:
Agent X 2022-08-25 20:41:04 -04:00 committed by GitHub
parent 4da8343253
commit 4c429c17a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 37 additions and 44 deletions

View File

@ -29,6 +29,7 @@
#include "pc/configfile.h"
#include "pc/network/network.h"
#include "pc/lua/smlua_hooks.h"
#include "pc/cheats.h"
enum InteractionFlag {
INT_GROUND_POUND_OR_TWIRL = (1 << 0), // 0x01
@ -2249,7 +2250,7 @@ void check_death_barrier(struct MarioState *m) {
}
void check_lava_boost(struct MarioState *m) {
if (m->action == ACT_BUBBLED) { return; }
if (m->action == ACT_BUBBLED || (Cheats.enabled && Cheats.godMode)) { return; }
if (!(m->action & ACT_FLAG_RIDING_SHELL) && m->pos[1] < m->floorHeight + 10.0f) {
if (!(m->flags & MARIO_METAL_CAP)) {
m->hurtCounter += (m->flags & MARIO_CAP_ON_HEAD) ? 12 : 18;

View File

@ -1542,12 +1542,11 @@ void update_mario_inputs(struct MarioState *m) {
debug_print_speed_action_normal(m);
/* Moonjump cheat */
while (Cheats.MoonJump == true && Cheats.EnableCheats == true && m->controller->buttonDown & L_TRIG ){
m->vel[1] = 25;
break; // TODO: Unneeded break?
if (Cheats.enabled && Cheats.moonJump && m->controller->buttonDown & L_TRIG) {
set_mario_action(m, ACT_FREEFALL, 0);
m->faceAngle[1] = m->intendedYaw - approach_s32((s16)(m->intendedYaw - m->faceAngle[1]), 0, 0x800, 0x800);
m->vel[1] = 30;
}
/*End of moonjump cheat */
/* Developer stuff */
#ifdef DEVELOPMENT
@ -1874,7 +1873,7 @@ static void debug_update_mario_cap(u16 button, s32 flags, u16 capTimer, u16 capM
}
}
void func_sh_8025574C(void) {
void queue_particle_rumble(void) {
if (gMarioState->particleFlags & PARTICLE_HORIZONTAL_STAR) {
queue_rumble_data_mario(gMarioState, 5, 80);
} else if (gMarioState->particleFlags & PARTICLE_VERTICAL_STAR) {
@ -1992,22 +1991,13 @@ s32 execute_mario_action(UNUSED struct Object *o) {
}
}
/**
* Cheat stuff
*/
if (Cheats.EnableCheats) {
if (Cheats.GodMode)
gMarioState->health = 0x880;
if (Cheats.enabled) {
if (Cheats.godMode) { gMarioState->health = 0x880; }
if (Cheats.InfiniteLives && gMarioState->numLives < 99)
gMarioState->numLives += 1;
if (Cheats.infiniteLives && gMarioState->numLives < 100) { gMarioState->numLives = 100; }
if (Cheats.SuperSpeed && gMarioState->controller->stickMag > 0.5f)
gMarioState->forwardVel += 100;
if (Cheats.superSpeed && gMarioState->controller->stickMag > 0.5f) { gMarioState->forwardVel += 100; }
}
/**
* End of cheat stuff
*/
if (gMarioState->action) {
if (gMarioState->action != ACT_BUBBLED) {
@ -2122,7 +2112,7 @@ s32 execute_mario_action(UNUSED struct Object *o) {
play_infinite_stairs_music();
gMarioState->marioObj->oInteractStatus = 0;
func_sh_8025574C();
queue_particle_rumble();
return gMarioState->particleFlags;
}

View File

@ -22,6 +22,7 @@
#include "pc/configfile.h"
#include "pc/network/network.h"
#include "pc/lua/smlua.h"
#include "pc/cheats.h"
void play_flip_sounds(struct MarioState *m, s16 frame1, s16 frame2, s16 frame3) {
s32 animFrame = m->marioObj->header.gfx.animInfo.animFrame;
@ -68,6 +69,8 @@ s32 lava_boost_on_wall(struct MarioState *m) {
}
s32 check_fall_damage(struct MarioState *m, u32 hardFallAction) {
if (Cheats.enabled && Cheats.godMode) { return FALSE; }
f32 fallHeight;
f32 damageHeight;

View File

@ -467,13 +467,11 @@ void update_walking_speed(struct MarioState *m) {
m->forwardVel = 48.0f;
}
/* Handles the "Super responsive controls" cheat. The content of the "else" is Mario's original code for turning around.*/
if (Cheats.Responsive == true && Cheats.EnableCheats == true ) {
// handles the "Super responsive controls" cheat. The content of the "else" is Mario's original code for turning around.
if (Cheats.enabled && Cheats.responsive) {
m->faceAngle[1] = m->intendedYaw;
}
else {
m->faceAngle[1] = m->intendedYaw - approach_s32((s16)(m->intendedYaw - m->faceAngle[1]), 0, 0x800, 0x800);
} else {
m->faceAngle[1] = m->intendedYaw - approach_s32((s16)(m->intendedYaw - m->faceAngle[1]), 0, 0x800, 0x800);
}
apply_slope_accel(m);
}

View File

@ -10,6 +10,7 @@
#include "mario_step.h"
#include "pc/lua/smlua.h"
#include "game/hardcoded.h"
#include "pc/cheats.h"
static s16 sMovingSandSpeeds[] = { 12, 8, 4, 0 };
@ -108,7 +109,7 @@ void mario_bonk_reflection(struct MarioState *m, u32 negateSpeed) {
}
u32 mario_update_quicksand(struct MarioState *m, f32 sinkingSpeed) {
if (m->action & ACT_FLAG_RIDING_SHELL) {
if (m->action & ACT_FLAG_RIDING_SHELL || (Cheats.enabled && Cheats.godMode)) {
m->quicksandDepth = 0.0f;
} else {
if (m->quicksandDepth < 1.1f) {

View File

@ -4,12 +4,12 @@
#include <stdbool.h>
struct CheatList {
bool EnableCheats;
bool MoonJump;
bool GodMode;
bool InfiniteLives;
bool SuperSpeed;
bool Responsive;
bool enabled;
bool moonJump;
bool godMode;
bool infiniteLives;
bool superSpeed;
bool responsive;
};
extern struct CheatList Cheats;

View File

@ -67,7 +67,7 @@ void parse_cli_opts(int argc, char* argv[]) {
arg_uint("--client <port>", argv[++i], &gCLIOpts.NetworkPort);
} else if (strcmp(argv[i], "--cheats") == 0) // Enable cheats menu
Cheats.EnableCheats = true;
Cheats.enabled = true;
else if (strcmp(argv[i], "--poolsize") == 0) // Main pool size
arg_uint("--poolsize", argv[++i], &gCLIOpts.PoolSize);

View File

@ -10,28 +10,28 @@ void djui_panel_cheats_create(struct DjuiBase* caller) {
{
{
struct DjuiCheckbox* checkbox = djui_checkbox_create(&body->base, "Moon jump", &Cheats.MoonJump);
struct DjuiCheckbox* checkbox = djui_checkbox_create(&body->base, "Moon jump", &Cheats.moonJump);
djui_base_set_size_type(&checkbox->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&checkbox->base, 1.0f, 32);
defaultBase = &checkbox->base;
}
{
struct DjuiCheckbox* checkbox = djui_checkbox_create(&body->base, "God mode", &Cheats.GodMode);
struct DjuiCheckbox* checkbox = djui_checkbox_create(&body->base, "God mode", &Cheats.godMode);
djui_base_set_size_type(&checkbox->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&checkbox->base, 1.0f, 32);
}
{
struct DjuiCheckbox* checkbox = djui_checkbox_create(&body->base, "Infinite lives", &Cheats.InfiniteLives);
struct DjuiCheckbox* checkbox = djui_checkbox_create(&body->base, "Infinite lives", &Cheats.infiniteLives);
djui_base_set_size_type(&checkbox->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&checkbox->base, 1.0f, 32);
}
{
struct DjuiCheckbox* checkbox = djui_checkbox_create(&body->base, "Super speed", &Cheats.SuperSpeed);
struct DjuiCheckbox* checkbox = djui_checkbox_create(&body->base, "Super speed", &Cheats.superSpeed);
djui_base_set_size_type(&checkbox->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&checkbox->base, 1.0f, 32);
}
{
struct DjuiCheckbox* checkbox = djui_checkbox_create(&body->base, "Responsive controls", &Cheats.Responsive);
struct DjuiCheckbox* checkbox = djui_checkbox_create(&body->base, "Responsive controls", &Cheats.responsive);
djui_base_set_size_type(&checkbox->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&checkbox->base, 1.0f, 32);
}

View File

@ -36,7 +36,7 @@ void djui_panel_pause_create(struct DjuiBase* caller) {
if (gDjuiChatBoxFocus) { djui_chat_box_toggle(); }
f32 bodyHeight = 64 * 5 + 16 * 4;
if (Cheats.EnableCheats) { bodyHeight += 64 + 16; }
if (Cheats.enabled) { bodyHeight += 64 + 16; }
struct DjuiBase* defaultBase = NULL;
struct DjuiThreePanel* panel = djui_panel_menu_create(bodyHeight, "\\#ff0800\\P\\#1be700\\A\\#00b3ff\\U\\#ffef00\\S\\#ff0800\\E");
@ -66,7 +66,7 @@ void djui_panel_pause_create(struct DjuiBase* caller) {
djui_interactable_hook_click(&button1->base, djui_panel_options_create);
defaultBase = &button1->base;
if (Cheats.EnableCheats) {
if (Cheats.enabled) {
struct DjuiButton* button1 = djui_button_create(&body->base, "Cheats");
djui_base_set_size_type(&button1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button1->base, 1.0f, 64);

View File

@ -101,7 +101,7 @@ bool network_init(enum NetworkType inNetworkType) {
#else
gServerSettings.headlessServer = 0;
#endif
Cheats.EnableCheats = gServerSettings.enableCheats;
Cheats.enabled = gServerSettings.enableCheats;
// initialize the network system
gNetworkSentJoin = false;

View File

@ -174,7 +174,7 @@ void network_receive_join(struct Packet* p) {
packet_read(p, eeprom, sizeof(u8) * 512);
packet_read(p, &modCount, sizeof(u8));
Cheats.EnableCheats = gServerSettings.enableCheats;
Cheats.enabled = gServerSettings.enableCheats;
struct StringLinkedList head = { 0 };
for (s32 i = 0; i < modCount; i++) {