impl console cheats

This commit is contained in:
RandomityGuy 2026-03-28 15:00:06 +00:00
parent a5377c37b2
commit a05394648a
4 changed files with 77 additions and 15 deletions

View file

@ -1,5 +1,6 @@
package src; package src;
import net.Net;
#if !js #if !js
import sys.FileSystem; import sys.FileSystem;
#end #end
@ -113,6 +114,29 @@ class Console {
} }
public static function eval(cmd:String) { public static function eval(cmd:String) {
var cmdLower = cmd.toLowerCase();
if (StringTools.startsWith(cmdLower, "defaultmarble")) {
// parse regex DefaultMarble.<attribName> = <value>
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.<attribName> = <value>");
return;
}
}
var cmdSplit = cmd.split(" "); var cmdSplit = cmd.split(" ");
if (cmdSplit.length != 0) { if (cmdSplit.length != 0) {
var cmdType = cmdSplit[0]; var cmdType = cmdSplit[0];

View file

@ -699,6 +699,37 @@ class Marble extends GameObject {
this._bounceKineticFriction = MisParser.parseNumber(attribs.get("bouncekineticfriction")); 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) { function findContacts(collisiomWorld:CollisionWorld, timeState:TimeState) {
this.contacts = queuedContacts; this.contacts = queuedContacts;
CollisionPool.clear(); CollisionPool.clear();

View file

@ -219,6 +219,8 @@ class MarbleWorld extends Scheduler {
public var rewinding:Bool = false; public var rewinding:Bool = false;
public var rewindUsed:Bool = false; public var rewindUsed:Bool = false;
public var cheatsUsed:Bool = false;
public var inputRecorder:InputRecorder; public var inputRecorder:InputRecorder;
public var isReplayingMovement:Bool = false; public var isReplayingMovement:Bool = false;
public var currentInputMoves:Array<InputRecorderFrame>; public var currentInputMoves:Array<InputRecorderFrame>;

View file

@ -395,6 +395,7 @@ class EndGameGui extends GuiControl {
Settings.save(); Settings.save();
var rewindUsed = MarbleGame.instance.world.rewindUsed; var rewindUsed = MarbleGame.instance.world.rewindUsed;
var cheatsUsed = MarbleGame.instance.world.cheatsUsed;
if (idx <= 4) { if (idx <= 4) {
setButtonStates(false); setButtonStates(false);
@ -425,15 +426,17 @@ class EndGameGui extends GuiControl {
} }
} }
Settings.saveScore(mission.path, myScore); if (!cheatsUsed) { // dont submit or save if we have cheated
var lbPath = mission.path; Settings.saveScore(mission.path, myScore);
if (mission.isClaMission) var lbPath = mission.path;
lbPath = 'custom/${mission.id}'; if (mission.isClaMission)
Leaderboards.submitScore(lbPath, myScore.time, rewindUsed, (sendReplay, rowId) -> { lbPath = 'custom/${mission.id}';
if (sendReplay && !mission.isClaMission) { Leaderboards.submitScore(lbPath, myScore.time, rewindUsed, (sendReplay, rowId) -> {
Leaderboards.submitReplay(rowId, replayData); if (sendReplay && !mission.isClaMission) {
} Leaderboards.submitReplay(rowId, replayData);
}); }
});
}
scoreSubmitted = true; scoreSubmitted = true;
}); });
@ -453,12 +456,14 @@ class EndGameGui extends GuiControl {
break; break;
} }
} }
if (!hasMyScore || (hasMyScore && myTopScoreLB > timeState.gameplayClock)) { if (!cheatsUsed) {
Leaderboards.submitScore(lbPath, timeState.gameplayClock, rewindUsed, (sendReplay, rowId) -> { if (!hasMyScore || (hasMyScore && myTopScoreLB > timeState.gameplayClock)) {
if (sendReplay && !mission.isClaMission) { Leaderboards.submitScore(lbPath, timeState.gameplayClock, rewindUsed, (sendReplay, rowId) -> {
Leaderboards.submitReplay(rowId, replayData); if (sendReplay && !mission.isClaMission) {
} Leaderboards.submitReplay(rowId, replayData);
}); }
});
}
} }
}); });
} }