From a67cf3deaaf46f22cc1698eb517d70984ca3d1dd Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Sat, 28 Mar 2026 15:00:06 +0000 Subject: [PATCH] impl console cheats --- src/Console.hx | 24 ++++++++++++++++++++++++ src/Marble.hx | 31 +++++++++++++++++++++++++++++++ src/MarbleWorld.hx | 2 ++ src/gui/EndGameGui.hx | 35 ++++++++++++++++++++--------------- 4 files changed, 77 insertions(+), 15 deletions(-) diff --git a/src/Console.hx b/src/Console.hx index 7a14204f..8245807b 100644 --- a/src/Console.hx +++ b/src/Console.hx @@ -1,5 +1,6 @@ package src; +import net.Net; #if !js import sys.FileSystem; #end @@ -113,6 +114,29 @@ class Console { } public static function eval(cmd:String) { + var cmdLower = cmd.toLowerCase(); + if (StringTools.startsWith(cmdLower, "defaultmarble")) { + // parse regex DefaultMarble. = + var regex = ~/defaultmarble\.(\w+)\s*=\s*(.+)/; + var matched = regex.match(cmdLower); + if (matched) { + var attribName = regex.matched(1); + var valueStr = regex.matched(2); + var numValue = Std.parseFloat(valueStr); + if (Math.isNaN(numValue)) + numValue = 0; + if (MarbleGame.instance.world != null && !Net.isMP && MarbleGame.instance.world.marble != null) { + MarbleGame.instance.world.marble.setMarbleAttribute(attribName, numValue); + MarbleGame.instance.world.cheatsUsed = true; + log("Set DefaultMarble." + attribName + " to " + numValue); + return; + } + } else { + error("Invalid command format. Expected: DefaultMarble. = "); + return; + } + } + var cmdSplit = cmd.split(" "); if (cmdSplit.length != 0) { var cmdType = cmdSplit[0]; diff --git a/src/Marble.hx b/src/Marble.hx index aa3a3960..75daebcd 100644 --- a/src/Marble.hx +++ b/src/Marble.hx @@ -700,6 +700,37 @@ class Marble extends GameObject { this._bounceKineticFriction = MisParser.parseNumber(attribs.get("bouncekineticfriction")); } + public function setMarbleAttribute(attr:String, value:Float) { + switch (attr.toLowerCase()) { + case "maxrollvelocity": + this._maxRollVelocity = value; + case "angularacceleration": + this._angularAcceleration = value; + case "jumpimpulse": + this._jumpImpulse = value; + case "kineticfriction": + this._kineticFriction = value; + case "staticfriction": + this._staticFriction = value; + case "brakingacceleration": + this._brakingAcceleration = value; + case "gravity": + this._gravity = value; + case "airaccel": + this._airAccel = value; + case "maxdotslide": + this._maxDotSlide = value; + case "minbouncevel": + this._minBounceVel = value; + case "minbouncespeed": + this._minBounceSpeed = value; + case "mintrailvel": + this._minTrailVel = value; + case "bouncekineticfriction": + this._bounceKineticFriction = value; + } + } + function findContacts(collisiomWorld:CollisionWorld, timeState:TimeState) { this.contacts = queuedContacts; CollisionPool.clear(); diff --git a/src/MarbleWorld.hx b/src/MarbleWorld.hx index 084d93ce..46828851 100644 --- a/src/MarbleWorld.hx +++ b/src/MarbleWorld.hx @@ -218,6 +218,8 @@ class MarbleWorld extends Scheduler { public var rewinding:Bool = false; public var rewindUsed:Bool = false; + public var cheatsUsed:Bool = false; + public var inputRecorder:InputRecorder; public var isReplayingMovement:Bool = false; public var currentInputMoves:Array; diff --git a/src/gui/EndGameGui.hx b/src/gui/EndGameGui.hx index 87e3e59c..cc293be8 100644 --- a/src/gui/EndGameGui.hx +++ b/src/gui/EndGameGui.hx @@ -394,6 +394,7 @@ class EndGameGui extends GuiControl { Settings.save(); var rewindUsed = MarbleGame.instance.world.rewindUsed; + var cheatsUsed = MarbleGame.instance.world.cheatsUsed; if (idx <= 4) { setButtonStates(false); @@ -424,15 +425,17 @@ class EndGameGui extends GuiControl { } } - Settings.saveScore(mission.path, myScore); - var lbPath = mission.path; - if (mission.isClaMission) - lbPath = 'custom/${mission.id}'; - Leaderboards.submitScore(lbPath, myScore.time, rewindUsed, (sendReplay, rowId) -> { - if (sendReplay && !mission.isClaMission) { - Leaderboards.submitReplay(rowId, replayData); - } - }); + if (!cheatsUsed) { // dont submit or save if we have cheated + Settings.saveScore(mission.path, myScore); + var lbPath = mission.path; + if (mission.isClaMission) + lbPath = 'custom/${mission.id}'; + Leaderboards.submitScore(lbPath, myScore.time, rewindUsed, (sendReplay, rowId) -> { + if (sendReplay && !mission.isClaMission) { + Leaderboards.submitReplay(rowId, replayData); + } + }); + } scoreSubmitted = true; }); @@ -452,12 +455,14 @@ class EndGameGui extends GuiControl { break; } } - if (!hasMyScore || (hasMyScore && myTopScoreLB > timeState.gameplayClock)) { - Leaderboards.submitScore(lbPath, timeState.gameplayClock, rewindUsed, (sendReplay, rowId) -> { - if (sendReplay && !mission.isClaMission) { - Leaderboards.submitReplay(rowId, replayData); - } - }); + if (!cheatsUsed) { + if (!hasMyScore || (hasMyScore && myTopScoreLB > timeState.gameplayClock)) { + Leaderboards.submitScore(lbPath, timeState.gameplayClock, rewindUsed, (sendReplay, rowId) -> { + if (sendReplay && !mission.isClaMission) { + Leaderboards.submitReplay(rowId, replayData); + } + }); + } } }); }