impl console cheats

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

View file

@ -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.<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(" ");
if (cmdSplit.length != 0) {
var cmdType = cmdSplit[0];

View file

@ -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();

View file

@ -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<InputRecorderFrame>;

View file

@ -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);
}
});
}
}
});
}