Skip to content

Commit

Permalink
added anticheat for botplay
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanSantiagoYT committed Aug 18, 2023
1 parent ee09cae commit e81cc71
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
19 changes: 19 additions & 0 deletions source/GameplayChangersSubstate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ class GameplayChangersSubstate extends MusicBeatSubstate

var option:GameplayOption = new GameplayOption('Practice Mode', 'practice', 'bool', false);
optionsArray.push(option);
option.onChange = onChangePractice; //Changing onChange is only needed if you want to make a special interaction after it changes the value

var option:GameplayOption = new GameplayOption('Botplay', 'botplay', 'bool', false);
optionsArray.push(option);
option.onChange = onChangeBotplay; //Changing onChange is only needed if you want to make a special interaction after it changes the value

var option:GameplayOption = new GameplayOption('Play as Opponent', 'opponentplay', 'bool', false);
optionsArray.push(option);
Expand Down Expand Up @@ -434,6 +436,23 @@ class GameplayChangersSubstate extends MusicBeatSubstate
}
holdTime = 0;
}

function onChangePractice()
{
if(inThePauseMenu)
{
trace ("you really thought you would get away with it, invalidated your score");
PlayState.playerIsCheating = true;
}
}
function onChangeBotplay()
{
if(inThePauseMenu)
{
trace ("you really thought you would get away with it, invalidated your score");
PlayState.playerIsCheating = true;
}
}

function changeSelection(change:Int = 0)
{
Expand Down
7 changes: 4 additions & 3 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ class PlayState extends MusicBeatState
private var updateThePercent:Bool = true;
public static var changedDifficulty:Bool = false;
public static var chartingMode:Bool = false;
public static var playerIsCheating:Bool = false; //Whether the player is cheating. Enables if you change BOTPLAY or Practice Mode in the Pause menu

//Gameplay settings
public var healthGain:Float = 1;
Expand Down Expand Up @@ -4271,7 +4272,7 @@ class PlayState extends MusicBeatState
// playerCounter += 1;

unspawnNotes.sort(sortByTime);
if (trollingMode) unspawnNotesCopy = unspawnNotes.copy();
unspawnNotesCopy = unspawnNotes.copy();
generatedMusic = true;
maxScore = totalNotes * (ClientPrefs.noMarvJudge ? 350 : 500);
}
Expand Down Expand Up @@ -4323,7 +4324,7 @@ class PlayState extends MusicBeatState
loadOtherEventNotes();

unspawnNotes.sort(sortByTime);
if (trollingMode) unspawnNotesCopy = unspawnNotes.copy();
unspawnNotesCopy = unspawnNotes.copy();
generatedMusic = true;
maxScore = totalNotes * (ClientPrefs.noMarvJudge ? 350 : 500);
generatedMusic = true;
Expand Down Expand Up @@ -6630,7 +6631,7 @@ class PlayState extends MusicBeatState

var ret:Dynamic = callOnLuas('onEndSong', [], false);
if(ret != FunkinLua.Function_Stop && !transitioning) {
if (SONG.validScore && !cpuControlled)
if (SONG.validScore && !cpuControlled && !playerIsCheating)
{
#if !switch
var percent:Float = ratingPercent;
Expand Down

0 comments on commit e81cc71

Please sign in to comment.