From b2929d9ab8c3cff995c982c45da5cc4f9701c8e0 Mon Sep 17 00:00:00 2001 From: Detoria <44783518+theDetourist@users.noreply.github.com> Date: Thu, 6 May 2021 17:16:28 -0300 Subject: [PATCH] free skill option --- source/Highscore.hx | 34 +++++---- source/KadeEngineData.hx | 153 ++++++++++++++++++++------------------- source/Options.hx | 22 +++++- source/OptionsMenu.hx | 8 +- source/PlayState.hx | 83 ++++++++++++++++----- source/Ratings.hx | 16 ++-- 6 files changed, 195 insertions(+), 121 deletions(-) diff --git a/source/Highscore.hx b/source/Highscore.hx index 5fbc732..78a6d30 100644 --- a/source/Highscore.hx +++ b/source/Highscore.hx @@ -20,14 +20,16 @@ class Highscore NGio.postScore(score, song); #end - - if (songScores.exists(daSong)) + if(!FlxG.save.data.botplay) { - if (songScores.get(daSong) < score) + if (songScores.exists(daSong)) + { + if (songScores.get(daSong) < score) + setScore(daSong, score); + } + else setScore(daSong, score); - } - else - setScore(daSong, score); + }else trace('BotPlay detected. Score saving is disabled.'); } public static function saveWeekScore(week:Int = 1, score:Int = 0, ?diff:Int = 0):Void @@ -37,16 +39,18 @@ class Highscore NGio.postScore(score, "Week " + week); #end - - var daWeek:String = formatSong('week' + week, diff); - - if (songScores.exists(daWeek)) + if(!FlxG.save.data.botplay) { - if (songScores.get(daWeek) < score) + var daWeek:String = formatSong('week' + week, diff); + + if (songScores.exists(daWeek)) + { + if (songScores.get(daWeek) < score) + setScore(daWeek, score); + } + else setScore(daWeek, score); - } - else - setScore(daWeek, score); + }else trace('BotPlay detected. Score saving is disabled.'); } /** @@ -95,4 +99,4 @@ class Highscore songScores = FlxG.save.data.songScores; } } -} +} \ No newline at end of file diff --git a/source/KadeEngineData.hx b/source/KadeEngineData.hx index 925eb3d..9ab281d 100644 --- a/source/KadeEngineData.hx +++ b/source/KadeEngineData.hx @@ -1,75 +1,78 @@ -import openfl.Lib; -import flixel.FlxG; - -class KadeEngineData -{ - public static function initSave() - { - if (FlxG.save.data.newInput == null) - FlxG.save.data.newInput = true; - - if (FlxG.save.data.downscroll == null) - FlxG.save.data.downscroll = false; - - if (FlxG.save.data.dfjk == null) - FlxG.save.data.dfjk = false; - - if (FlxG.save.data.accuracyDisplay == null) - FlxG.save.data.accuracyDisplay = true; - - if (FlxG.save.data.offset == null) - FlxG.save.data.offset = 0; - - if (FlxG.save.data.songPosition == null) - FlxG.save.data.songPosition = false; - - if (FlxG.save.data.fps == null) - FlxG.save.data.fps = false; - - if (FlxG.save.data.changedHit == null) - { - FlxG.save.data.changedHitX = -1; - FlxG.save.data.changedHitY = -1; - FlxG.save.data.changedHit = false; - } - - if (FlxG.save.data.fpsRain == null) - FlxG.save.data.fpsRain = false; - - if (FlxG.save.data.fpsCap == null) - FlxG.save.data.fpsCap = 120; - - if (FlxG.save.data.fpsCap > 285 || FlxG.save.data.fpsCap < 60) - FlxG.save.data.fpsCap = 120; // baby proof so you can't hard lock ur copy of kade engine - - if (FlxG.save.data.scrollSpeed == null) - FlxG.save.data.scrollSpeed = 1; - - if (FlxG.save.data.npsDisplay == null) - FlxG.save.data.npsDisplay = false; - - if (FlxG.save.data.frames == null) - FlxG.save.data.frames = 10; - - if (FlxG.save.data.accuracyMod == null) - FlxG.save.data.accuracyMod = 1; - - if (FlxG.save.data.watermark == null) - FlxG.save.data.watermark = true; - - if (FlxG.save.data.ghost == null) - FlxG.save.data.ghost = true; - - if (FlxG.save.data.distractions == null) - FlxG.save.data.distractions = true; - - if (FlxG.save.data.flashing == null) - FlxG.save.data.flashing = true; - - Conductor.recalculateTimings(); - - Main.watermarks = FlxG.save.data.watermark; - - (cast (Lib.current.getChildAt(0), Main)).setFPSCap(FlxG.save.data.fpsCap); - } -} +import openfl.Lib; +import flixel.FlxG; + +class KadeEngineData +{ + public static function initSave() + { + if (FlxG.save.data.newInput == null) + FlxG.save.data.newInput = true; + + if (FlxG.save.data.downscroll == null) + FlxG.save.data.downscroll = false; + + if (FlxG.save.data.dfjk == null) + FlxG.save.data.dfjk = false; + + if (FlxG.save.data.accuracyDisplay == null) + FlxG.save.data.accuracyDisplay = true; + + if (FlxG.save.data.offset == null) + FlxG.save.data.offset = 0; + + if (FlxG.save.data.songPosition == null) + FlxG.save.data.songPosition = false; + + if (FlxG.save.data.fps == null) + FlxG.save.data.fps = false; + + if (FlxG.save.data.changedHit == null) + { + FlxG.save.data.changedHitX = -1; + FlxG.save.data.changedHitY = -1; + FlxG.save.data.changedHit = false; + } + + if (FlxG.save.data.fpsRain == null) + FlxG.save.data.fpsRain = false; + + if (FlxG.save.data.fpsCap == null) + FlxG.save.data.fpsCap = 120; + + if (FlxG.save.data.fpsCap > 285 || FlxG.save.data.fpsCap < 60) + FlxG.save.data.fpsCap = 120; // baby proof so you can't hard lock ur copy of kade engine + + if (FlxG.save.data.scrollSpeed == null) + FlxG.save.data.scrollSpeed = 1; + + if (FlxG.save.data.npsDisplay == null) + FlxG.save.data.npsDisplay = false; + + if (FlxG.save.data.frames == null) + FlxG.save.data.frames = 10; + + if (FlxG.save.data.accuracyMod == null) + FlxG.save.data.accuracyMod = 1; + + if (FlxG.save.data.watermark == null) + FlxG.save.data.watermark = true; + + if (FlxG.save.data.ghost == null) + FlxG.save.data.ghost = true; + + if (FlxG.save.data.distractions == null) + FlxG.save.data.distractions = true; + + if (FlxG.save.data.flashing == null) + FlxG.save.data.flashing = true; + + if (FlxG.save.data.botplay == null) + FlxG.save.data.botplay = false; + + Conductor.recalculateTimings(); + + Main.watermarks = FlxG.save.data.watermark; + + (cast (Lib.current.getChildAt(0), Main)).setFPSCap(FlxG.save.data.fpsCap); + } +} \ No newline at end of file diff --git a/source/Options.hx b/source/Options.hx index c7cfa54..6bc4522 100644 --- a/source/Options.hx +++ b/source/Options.hx @@ -553,6 +553,22 @@ class OffsetMenu extends Option return "Time your offset"; } } - - - +class BotPlay extends Option +{ + public function new(desc:String) + { + super(); + description = desc; + } + + public override function press():Bool + { + FlxG.save.data.botplay = !FlxG.save.data.botplay; + trace('BotPlay : ' + FlxG.save.data.botplay); + display = updateDisplay(); + return true; + } + + private override function updateDisplay():String + return "BotPlay " + (FlxG.save.data.botplay ? "on" : "off"); +} \ No newline at end of file diff --git a/source/OptionsMenu.hx b/source/OptionsMenu.hx index 5c31e56..f818f50 100644 --- a/source/OptionsMenu.hx +++ b/source/OptionsMenu.hx @@ -58,8 +58,8 @@ class OptionsMenu extends MusicBeatState new FPSOption("Toggle the FPS Counter"), new ReplayOption("View replays"), #end - new WatermarkOption("Turn off all watermarks from the engine.") - + new WatermarkOption("Turn off all watermarks from the engine."), + new BotPlay("Showcase your charts and mods with autoplay.") ]) ]; @@ -239,7 +239,7 @@ class OptionsMenu extends MusicBeatState if (isCat) currentDescription = currentSelectedCat.getOptions()[curSelected].getDescription(); else - currentDescription = "Please select a catagory"; + currentDescription = "Please select a category"; versionShit.text = "Offset (Left, Right, Shift for slow): " + HelperFunctions.truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription; // selector.y = (70 * curSelected) + 30; @@ -261,4 +261,4 @@ class OptionsMenu extends MusicBeatState } } } -} +} \ No newline at end of file diff --git a/source/PlayState.hx b/source/PlayState.hx index 6d7d5cf..df66df9 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -201,6 +201,8 @@ class PlayState extends MusicBeatState private var allowedToHeadbang:Bool = false; // Per song additive offset public static var songOffset:Float = 0; + // BotPlay text + private var botPlayState:FlxText; private var executeModchart = false; @@ -299,7 +301,7 @@ class PlayState extends MusicBeatState Conductor.mapBPMChanges(SONG); Conductor.changeBPM(SONG.bpm); - trace('INFORMATION ABOUT WHAT U PLAYIN WIT:\nFRAMES: ' + Conductor.safeFrames + '\nZONE: ' + Conductor.safeZoneOffset + '\nTS: ' + Conductor.timeScale); + trace('INFORMATION ABOUT WHAT U PLAYIN WIT:\nFRAMES: ' + Conductor.safeFrames + '\nZONE: ' + Conductor.safeZoneOffset + '\nTS: ' + Conductor.timeScale + '\nBotPlay : ' + FlxG.save.data.botplay); switch (SONG.song.toLowerCase()) { @@ -921,15 +923,22 @@ class PlayState extends MusicBeatState scoreTxt.scrollFactor.set(); if (offsetTesting) scoreTxt.x += 300; + if(FlxG.save.data.botplay) scoreTxt.x = FlxG.width / 2 - 20; add(scoreTxt); replayTxt = new FlxText(healthBarBG.x + healthBarBG.width / 2 - 75, healthBarBG.y + (FlxG.save.data.downscroll ? 100 : -100), 0, "REPLAY", 20); replayTxt.setFormat(Paths.font("vcr.ttf"), 42, FlxColor.WHITE, RIGHT, FlxTextBorderStyle.OUTLINE,FlxColor.BLACK); replayTxt.scrollFactor.set(); if (loadRep) - { - add(replayTxt); - } + { + add(replayTxt); + } + // Literally copy-paste of the above, fu + botPlayState = new FlxText(healthBarBG.x + healthBarBG.width / 2 - 75, healthBarBG.y + (FlxG.save.data.downscroll ? 100 : -100), 0, "BOTPLAY", 20); + botPlayState.setFormat(Paths.font("vcr.ttf"), 42, FlxColor.WHITE, RIGHT, FlxTextBorderStyle.OUTLINE,FlxColor.BLACK); + botPlayState.scrollFactor.set(); + + if(FlxG.save.data.botplay) add(botPlayState); iconP1 = new HealthIcon(SONG.player1, true); iconP1.y = healthBar.y - (iconP1.height / 2); @@ -2141,9 +2150,19 @@ class PlayState extends MusicBeatState else daNote.y += daNote.height / 2; - if((!daNote.mustPress || daNote.wasGoodHit || daNote.prevNote.wasGoodHit && !daNote.canBeHit) && daNote.y - daNote.offset.y * daNote.scale.y + daNote.height >= (strumLine.y + Note.swagWidth / 2)) + // If not in botplay, only clip sustain notes when properly hit, botplay gets to clip it everytime + if(!FlxG.save.data.botplay) { - // Clip to strumline + if((!daNote.mustPress || daNote.wasGoodHit || daNote.prevNote.wasGoodHit && !daNote.canBeHit) && daNote.y - daNote.offset.y * daNote.scale.y + daNote.height >= (strumLine.y + Note.swagWidth / 2)) + { + // Clip to strumline + var swagRect = new FlxRect(0, 0, daNote.frameWidth * 2, daNote.frameHeight * 2); + swagRect.height = (strumLineNotes.members[Math.floor(Math.abs(daNote.noteData))].y + Note.swagWidth / 2 - daNote.y) / daNote.scale.y; + swagRect.y = daNote.frameHeight - swagRect.height; + + daNote.clipRect = swagRect; + } + }else { var swagRect = new FlxRect(0, 0, daNote.frameWidth * 2, daNote.frameHeight * 2); swagRect.height = (strumLineNotes.members[Math.floor(Math.abs(daNote.noteData))].y + Note.swagWidth / 2 - daNote.y) / daNote.scale.y; swagRect.y = daNote.frameHeight - swagRect.height; @@ -2161,9 +2180,18 @@ class PlayState extends MusicBeatState { daNote.y -= daNote.height / 2; - if((!daNote.mustPress || daNote.wasGoodHit || daNote.prevNote.wasGoodHit && !daNote.canBeHit) && daNote.y + daNote.offset.y * daNote.scale.y <= (strumLine.y + Note.swagWidth / 2)) + if(!FlxG.save.data.botplay) { - // Clip to strumline + if((!daNote.mustPress || daNote.wasGoodHit || daNote.prevNote.wasGoodHit && !daNote.canBeHit) && daNote.y + daNote.offset.y * daNote.scale.y <= (strumLine.y + Note.swagWidth / 2)) + { + // Clip to strumline + var swagRect = new FlxRect(0, 0, daNote.width / daNote.scale.x, daNote.height / daNote.scale.y); + swagRect.y = (strumLineNotes.members[Math.floor(Math.abs(daNote.noteData))].y + Note.swagWidth / 2 - daNote.y) / daNote.scale.y; + swagRect.height -= swagRect.y; + + daNote.clipRect = swagRect; + } + }else { var swagRect = new FlxRect(0, 0, daNote.width / daNote.scale.x, daNote.height / daNote.scale.y); swagRect.y = (strumLineNotes.members[Math.floor(Math.abs(daNote.noteData))].y + Note.swagWidth / 2 - daNote.y) / daNote.scale.y; swagRect.height -= swagRect.y; @@ -2197,7 +2225,7 @@ class PlayState extends MusicBeatState dad.playAnim('singDOWN' + altAnim, true); case 0: dad.playAnim('singLEFT' + altAnim, true); - } + } #if windows if (luaModchart != null) @@ -2497,9 +2525,9 @@ class PlayState extends MusicBeatState rating.acceleration.y = 550; rating.velocity.y -= FlxG.random.int(140, 175); rating.velocity.x -= FlxG.random.int(0, 10); - var msTiming = HelperFunctions.truncateFloat(noteDiff, 3); + if(FlxG.save.data.botplay) msTiming = 0; if (currentTimingShown != null) remove(currentTimingShown); @@ -2545,10 +2573,8 @@ class PlayState extends MusicBeatState if (currentTimingShown.alpha != 1) currentTimingShown.alpha = 1; - add(currentTimingShown); + if(!FlxG.save.data.botplay) add(currentTimingShown); - - var comboSpr:FlxSprite = new FlxSprite().loadGraphic(Paths.image(pixelShitPart1 + 'combo' + pixelShitPart2)); comboSpr.screenCenter(); comboSpr.x = rating.x; @@ -2564,7 +2590,7 @@ class PlayState extends MusicBeatState comboSpr.velocity.x += FlxG.random.int(1, 10); currentTimingShown.velocity.x += comboSpr.velocity.x; - add(rating); + if(!FlxG.save.data.botplay) add(rating); if (!curStage.startsWith('school')) { @@ -2701,6 +2727,13 @@ class PlayState extends MusicBeatState controls.RIGHT_R ]; + // Prevent player input if botplay is on + if(FlxG.save.data.botplay) + { + holdArray = [false, false, false, false]; + pressArray = [false, false, false, false]; + releaseArray = [false, false, false, false]; + } // HOLDS, check for sustain notes if (holdArray.contains(true) && /*!boyfriend.stunned && */ generatedMusic) { @@ -2798,7 +2831,7 @@ class PlayState extends MusicBeatState noteMiss(shit, null); } - if (dontCheck && possibleNotes.length > 0 && FlxG.save.data.ghost) + if(dontCheck && possibleNotes.length > 0 && FlxG.save.data.ghost && !FlxG.save.data.botplay) { if (mashViolations > 4) { @@ -2811,13 +2844,25 @@ class PlayState extends MusicBeatState } } - + + notes.forEachAlive(function(daNote:Note) + { + if(FlxG.save.data.downscroll && daNote.y > strumLine.y || + !FlxG.save.data.downscroll && daNote.y < strumLine.y) + { + // Force good note hit regardless if it's too late to hit it or not as a fail safe + if(FlxG.save.data.botplay && daNote.canBeHit && daNote.mustPress || + FlxG.save.data.botplay && daNote.tooLate && daNote.mustPress) + { + goodNoteHit(daNote); + boyfriend.holdTimer = daNote.sustainLength; + } + } + }); if (boyfriend.holdTimer > Conductor.stepCrochet * 4 * 0.001 && !holdArray.contains(true)) { if (boyfriend.animation.curAnim.name.startsWith('sing') && !boyfriend.animation.curAnim.name.endsWith('miss')) - { boyfriend.playAnim('idle'); - } } playerStrums.forEach(function(spr:FlxSprite) @@ -3333,4 +3378,4 @@ class PlayState extends MusicBeatState } var curLight:Int = 0; -} +} \ No newline at end of file diff --git a/source/Ratings.hx b/source/Ratings.hx index f8be3ed..a4f40cf 100644 --- a/source/Ratings.hx +++ b/source/Ratings.hx @@ -5,6 +5,8 @@ class Ratings public static function GenerateLetterRank(accuracy:Float) // generate a letter ranking { var ranking:String = "N/A"; + if(FlxG.save.data.botplay) + ranking = "BotPlay"; if (PlayState.misses == 0 && PlayState.bads == 0 && PlayState.shits == 0 && PlayState.goods == 0) // Marvelous (SICK) Full Combo ranking = "(MFC)"; @@ -84,6 +86,8 @@ class Ratings if (accuracy == 0) ranking = "N/A"; + else if(FlxG.save.data.botplay) + ranking = "BotPlay"; return ranking; } @@ -119,16 +123,18 @@ class Ratings return "shit"; else if (noteDiff < -166 * customTimeScale) // so god damn late its a miss return "miss"; + else if (FlxG.save.data.botplay) + return "sick"; return "sick"; } public static function CalculateRanking(score:Int,scoreDef:Int,nps:Int,accuracy:Float):String { return - (FlxG.save.data.npsDisplay ? "NPS: " + nps + " | " : "") + // NPS Toggle - "Score:" + (Conductor.safeFrames != 10 ? score + " (" + scoreDef + ")" : "" + score) + // Score - " | Combo Breaks:" + PlayState.misses + // Misses/Combo Breaks - " | Accuracy:" + HelperFunctions.truncateFloat(accuracy, 2) + // Accuracy - "% | " + GenerateLetterRank(accuracy); // Letter Rank + (FlxG.save.data.npsDisplay ? "NPS: " + nps + (!FlxG.save.data.botplay ? " | " : "") : "") + (!FlxG.save.data.botplay ? // NPS Toggle + "Score:" + (Conductor.safeFrames != 10 ? score + " (" + scoreDef + ")" : "" + score) + // Score + " | Combo Breaks:" + PlayState.misses + // Misses/Combo Breaks + " | Accuracy:" + (FlxG.save.data.botplay ? "N/A" : HelperFunctions.truncateFloat(accuracy, 2) + " %") + // Accuracy + " | " + GenerateLetterRank(accuracy) : ""); // Letter Rank } } \ No newline at end of file