1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-13 02:02:46 +00:00
Funkin/source/funkin/play/PlayState.hx

2307 lines
60 KiB
Haxe
Raw Normal View History

package funkin.play;
2020-10-03 06:50:15 +00:00
import funkin.play.Strumline.StrumlineStyle;
import flixel.addons.effects.FlxTrail;
import flixel.addons.transition.FlxTransitionableState;
2020-10-25 20:51:06 +00:00
import flixel.FlxCamera;
2020-10-04 06:42:58 +00:00
import flixel.FlxObject;
2020-10-03 06:50:15 +00:00
import flixel.FlxSprite;
import flixel.FlxState;
2020-10-09 21:24:20 +00:00
import flixel.FlxSubState;
2021-04-08 00:19:49 +00:00
import flixel.group.FlxGroup;
2020-10-05 09:48:30 +00:00
import flixel.math.FlxMath;
2020-11-01 01:11:14 +00:00
import flixel.math.FlxPoint;
2021-01-16 22:21:06 +00:00
import flixel.math.FlxRect;
2020-10-03 06:50:15 +00:00
import flixel.text.FlxText;
2020-10-05 18:24:51 +00:00
import flixel.tweens.FlxEase;
2020-10-03 19:32:15 +00:00
import flixel.tweens.FlxTween;
2020-10-05 20:32:41 +00:00
import flixel.ui.FlxBar;
2020-10-04 06:42:58 +00:00
import flixel.util.FlxColor;
2020-10-05 05:13:12 +00:00
import flixel.util.FlxSort;
2020-10-03 19:32:15 +00:00
import flixel.util.FlxTimer;
2022-03-09 15:29:03 +00:00
import funkin.charting.ChartingState;
import funkin.modding.events.ScriptEvent;
import funkin.modding.events.ScriptEvent.SongTimeScriptEvent;
import funkin.modding.events.ScriptEvent.UpdateScriptEvent;
import funkin.modding.events.ScriptEventDispatcher;
import funkin.modding.module.ModuleHandler;
import funkin.Note;
import funkin.play.stage.Stage;
import funkin.play.stage.StageData;
import funkin.Section.SwagSection;
import funkin.shaderslmfao.ColorSwap;
import funkin.SongLoad.SwagSong;
import funkin.ui.PopUpStuff;
import funkin.ui.PreferencesMenu;
import funkin.util.Constants;
import funkin.util.SortUtil;
2022-03-09 15:29:03 +00:00
import lime.ui.Haptic;
2020-10-03 06:50:15 +00:00
2020-10-04 06:42:58 +00:00
using StringTools;
2021-03-22 14:09:46 +00:00
#if discord_rpc
import Discord.DiscordClient;
#end
class PlayState extends MusicBeatState
2020-10-03 06:50:15 +00:00
{
/**
* STATIC VARIABLES
* Static variables should be used for information that must be persisted between states or between resets,
* such as the active song or song playlist.
*/
/**
* The currently active PlayState.
* Since there is only one PlayState in existance at a time, we can use a singleton.
*/
public static var instance:PlayState = null;
/**
* The currently active song. Includes data about what stage should be used, what characters,
* and the notes to be played.
*/
public static var currentSong:SwagSong = null;
/**
* Whether the game is currently in Story Mode. If false, we are in Free Play Mode.
*/
2020-11-01 01:11:14 +00:00
public static var isStoryMode:Bool = false;
/**
* Whether the game is currently in Practice Mode.
* If true, player will not lose gain or lose score from notes.
*/
public static var isPracticeMode:Bool = false;
/**
* The current "Blueball Counter" to display in the pause menu.
* Resets when you beat a song or go back to the main menu.
*/
2021-03-04 19:30:35 +00:00
public static var deathCounter:Int = 0;
2020-11-01 01:11:14 +00:00
/**
* Used to persist the position of the `cameraFollowPosition` between resets.
*/
private static var previousCameraFollowPoint:FlxObject = null;
2020-10-03 17:36:39 +00:00
/**
* PUBLIC INSTANCE VARIABLES
* Public instance variables should be used for information that must be reset or dereferenced
* every time the state is reset, such as the currently active stage, but may need to be accessed externally.
*/
/**
* The currently active Stage. This is the object containing all the props.
*/
public var currentStage:Stage = null;
2020-10-03 06:50:15 +00:00
2021-09-24 14:56:05 +00:00
/**
* The internal ID of the currently active Stage.
* Used to retrieve the data required to build the `currentStage`.
2021-09-24 14:56:05 +00:00
*/
public var currentStageId:String = '';
2021-09-24 14:56:05 +00:00
/**
* The player's current health.
* The default maximum health is 2.0, and the default starting health is 1.0.
*/
public var health:Float = 1;
2020-10-03 06:50:15 +00:00
/**
* PRIVATE INSTANCE VARIABLES
* Private instance variables should be used for information that must be reset or dereferenced
* every time the state is reset, but should not be accessed externally.
*/
/**
* The Array containing the notes that are not currently on the screen.
* The `update()` function regularly shifts these out to add new notes to the screen.
*/
private var inactiveNotes:Array<Note>;
2020-10-03 19:32:15 +00:00
/**
* An empty FlxObject contained in the scene.
* The current gameplay camera will be centered on this object. Tween its position to move the camera smoothly.
*/
private var cameraFollowPoint:FlxObject;
2021-02-02 09:13:28 +00:00
/**
* An object which the strumline (and its notes) are positioned relative to.
*/
private var strumlineAnchor:FlxObject;
2021-02-02 09:13:28 +00:00
/**
* If true, the player is allowed to pause the game.
* Disabled during the ending of a song.
*/
private var mayPauseGame:Bool = true;
/**
* The displayed value of the player's health.
* Used to provide smooth animations based on linear interpolation of the player's health.
*/
private var healthLerp:Float = 1;
/**
* RENDER OBJECTS
*/
/**
* The SpriteGroup containing the notes that are currently on the screen or are about to be on the screen.
*/
private var activeNotes:FlxTypedGroup<Note> = null;
2020-10-04 06:42:58 +00:00
/**
* The FlxText which displays the current score.
*/
private var scoreText:FlxText;
2020-10-05 09:48:30 +00:00
/**
* The bar which displays the player's health.
* Dynamically updated based on the value of `healthLerp` (which is based on `health`).
*/
private var healthBar:FlxBar;
2022-03-01 04:04:55 +00:00
/**
* The background image used for the health bar.
* Emma says the image is slightly skewed so I'm leaving it as an image instead of a `createGraphic`.
*/
public var healthBarBG:FlxSprite;
2022-03-01 04:04:55 +00:00
/**
* The sprite group containing active player's strumline notes.
*/
public var playerStrumline:Strumline;
2020-10-05 12:55:39 +00:00
/**
* The sprite group containing opponent's strumline notes.
*/
public var enemyStrumline:Strumline;
/**
* PROPERTIES
*/
/**
* If a substate is rendering over the PlayState, it is paused and normal update logic is skipped.
* Examples include:
* - The Pause screen is open.
* - The Game Over screen is open.
* - The Chart Editor screen is open.
*/
private var isGamePaused(get, never):Bool;
function get_isGamePaused():Bool
{
// Note: If there is a substate which requires the game to act unpaused,
// this should be changed to include something like `&& Std.isOfType()`
return this.subState != null;
}
// TODO: Reorganize these variables (maybe there should be a separate class like Conductor just to hold them?)
public static var storyWeek:Int = 0;
public static var storyPlaylist:Array<String> = [];
public static var storyDifficulty:Int = 1;
public static var needsReset:Bool = false;
public static var seenCutscene:Bool = false;
public static var campaignScore:Int = 0;
private var vocals:VoicesGroup;
private var vocalsFinished:Bool = false;
2020-10-05 20:32:41 +00:00
private var playerStrums:FlxTypedGroup<FlxSprite>;
private var camZooming:Bool = false;
private var gfSpeed:Int = 1;
private var combo:Int = 0;
2020-10-05 18:24:51 +00:00
private var generatedMusic:Bool = false;
2020-10-23 23:12:38 +00:00
private var startingSong:Bool = false;
2020-12-24 23:24:11 +00:00
private var iconP1:HealthIcon;
private var iconP2:HealthIcon;
private var camHUD:FlxCamera;
private var camGame:FlxCamera;
2021-09-21 19:39:30 +00:00
var dialogue:Array<String>;
var startedCountdown:Bool = false;
2020-11-01 01:11:14 +00:00
var talking:Bool = true;
2020-11-01 19:16:22 +00:00
var songScore:Int = 0;
2021-09-21 19:39:30 +00:00
var doof:DialogueBox;
2021-04-10 05:49:57 +00:00
var grpNoteSplashes:FlxTypedGroup<NoteSplash>;
2020-12-27 02:46:22 +00:00
var defaultCamZoom:Float = 1.05;
2021-02-02 07:35:35 +00:00
var inCutscene:Bool = false;
var camPos:FlxPoint;
var comboPopUps:PopUpStuff;
var startTimer:FlxTimer = new FlxTimer();
var perfectMode:Bool = false;
var previousFrameTime:Int = 0;
var songTime:Float = 0;
var cameraRightSide:Bool = false;
2021-02-02 07:35:35 +00:00
2021-03-22 14:09:46 +00:00
#if discord_rpc
// Discord RPC variables
var storyDifficultyText:String = "";
var iconRPC:String = "";
var songLength:Float = 0;
2021-02-27 23:23:50 +00:00
var detailsText:String = "";
var detailsPausedText:String = "";
#end
2020-10-03 06:50:15 +00:00
override public function create()
{
super.create();
instance = this;
// Reduce physics accuracy (who cares!!!) to improve animation quality.
FlxG.fixedTimestep = false;
// This state receives update() even when a substate is active.
this.persistentUpdate = true;
// This state receives draw calls even when a substate is active.
this.persistentDraw = true;
2022-03-01 04:04:55 +00:00
Conductor.songPosition = -5000;
2020-10-05 18:24:51 +00:00
if (currentSong == null)
currentSong = SongLoad.loadFromJson('tutorial');
2020-10-13 08:37:19 +00:00
Conductor.mapBPMChanges(currentSong);
Conductor.changeBPM(currentSong.bpm);
2020-10-30 23:47:19 +00:00
// dialogue init shit, just for week 5 really (for now...?)
switch (currentSong.song.toLowerCase())
2020-11-01 01:11:14 +00:00
{
2021-02-01 06:50:30 +00:00
case 'senpai':
2022-03-01 04:04:55 +00:00
dialogue = CoolUtil.coolTextFile(Paths.txt('songs/senpai/senpaiDialogue'));
2021-02-01 10:52:10 +00:00
case 'roses':
2022-03-01 04:04:55 +00:00
dialogue = CoolUtil.coolTextFile(Paths.txt('songs/roses/rosesDialogue'));
2021-02-02 09:54:36 +00:00
case 'thorns':
2022-03-01 04:04:55 +00:00
dialogue = CoolUtil.coolTextFile(Paths.txt('songs/thorns/thornsDialogue'));
2020-11-01 01:11:14 +00:00
}
// Initialize stage stuff.
initCameras();
2021-03-31 17:08:55 +00:00
#if discord_rpc
initDiscord();
2021-03-31 17:08:55 +00:00
#end
2021-02-26 12:27:32 +00:00
2022-03-06 08:33:12 +00:00
initStage();
initCharacters();
if (dialogue != null)
{
doof = new DialogueBox(false, dialogue);
doof.scrollFactor.set();
doof.finishThing = startCountdown;
doof.cameras = [camHUD];
}
// fake notesplash cache type deal so that it loads in the graphic?
comboPopUps = new PopUpStuff();
add(comboPopUps);
grpNoteSplashes = new FlxTypedGroup<NoteSplash>();
var noteSplash:NoteSplash = new NoteSplash(100, 100, 0);
grpNoteSplashes.add(noteSplash);
noteSplash.alpha = 0.1;
add(grpNoteSplashes);
playerStrums = new FlxTypedGroup<FlxSprite>();
generateSong();
cameraFollowPoint = new FlxObject(0, 0, 1, 1);
cameraFollowPoint.setPosition(camPos.x, camPos.y);
if (previousCameraFollowPoint != null)
{
cameraFollowPoint = previousCameraFollowPoint;
previousCameraFollowPoint = null;
}
add(cameraFollowPoint);
resetCamera();
FlxG.worldBounds.set(0, 0, FlxG.width, FlxG.height);
var healthBarYPos:Float = PreferencesMenu.getPref('downscroll') ? FlxG.height * 0.1 : FlxG.height * 0.9;
healthBarBG = new FlxSprite(0, healthBarYPos).loadGraphic(Paths.image('healthBar'));
healthBarBG.screenCenter(X);
healthBarBG.scrollFactor.set(0, 0);
add(healthBarBG);
healthBar = new FlxBar(healthBarBG.x + 4, healthBarBG.y + 4, RIGHT_TO_LEFT, Std.int(healthBarBG.width - 8), Std.int(healthBarBG.height - 8), this,
'healthLerp', 0, 2);
healthBar.scrollFactor.set();
healthBar.createFilledBar(Constants.HEALTH_BAR_RED, Constants.HEALTH_BAR_GREEN);
add(healthBar);
scoreText = new FlxText(healthBarBG.x + healthBarBG.width - 190, healthBarBG.y + 30, 0, "", 20);
scoreText.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, RIGHT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
scoreText.scrollFactor.set();
add(scoreText);
iconP1 = new HealthIcon(currentSong.player1, true);
iconP1.y = healthBar.y - (iconP1.height / 2);
add(iconP1);
iconP2 = new HealthIcon(currentSong.player2, false);
iconP2.y = healthBar.y - (iconP2.height / 2);
add(iconP2);
// Attach the groups to the HUD camera so they are rendered independent of the stage.
grpNoteSplashes.cameras = [camHUD];
activeNotes.cameras = [camHUD];
healthBar.cameras = [camHUD];
healthBarBG.cameras = [camHUD];
iconP1.cameras = [camHUD];
iconP2.cameras = [camHUD];
scoreText.cameras = [camHUD];
// if (SONG.song == 'South')
// FlxG.camera.alpha = 0.7;
// UI_camera.zoom = 1;
// cameras = [FlxG.cameras.list[1]];
startingSong = true;
if (isStoryMode && !seenCutscene)
{
seenCutscene = true;
switch (currentSong.song.toLowerCase())
{
case "winter-horrorland":
var blackScreen:FlxSprite = new FlxSprite(0, 0).makeGraphic(Std.int(FlxG.width * 2), Std.int(FlxG.height * 2), FlxColor.BLACK);
add(blackScreen);
blackScreen.scrollFactor.set();
camHUD.visible = false;
new FlxTimer().start(0.1, function(tmr:FlxTimer)
{
remove(blackScreen);
FlxG.sound.play(Paths.sound('Lights_Turn_On'));
cameraFollowPoint.y = -2050;
cameraFollowPoint.x += 200;
FlxG.camera.focusOn(cameraFollowPoint.getPosition());
FlxG.camera.zoom = 1.5;
new FlxTimer().start(0.8, function(tmr:FlxTimer)
{
camHUD.visible = true;
remove(blackScreen);
FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom}, 2.5, {
ease: FlxEase.quadInOut,
onComplete: function(twn:FlxTween)
{
startCountdown();
}
});
});
});
case 'senpai' | 'roses' | 'thorns':
schoolIntro(doof); // doof is assumed to be non-null, lol!
case 'ugh':
ughIntro();
case 'stress':
stressIntro();
case 'guns':
gunsIntro();
default:
startCountdown();
}
}
else
{
startCountdown();
}
}
/**
* Initializes the position of the camera.
*/
function initCameras()
{
defaultCamZoom = FlxCamera.defaultZoom;
defaultCamZoom *= 1.05;
if (FlxG.sound.music != null)
FlxG.sound.music.stop();
FlxG.sound.cache(Paths.inst(currentSong.song));
FlxG.sound.cache(Paths.voices(currentSong.song));
// var gameCam:FlxCamera = FlxG.camera;
camGame = new SwagCamera();
camHUD = new FlxCamera();
camHUD.bgColor.alpha = 0;
FlxG.cameras.reset(camGame);
FlxG.cameras.add(camHUD, false);
}
2022-03-06 08:33:12 +00:00
function initStage()
{
2022-03-01 16:29:01 +00:00
// TODO: Move stageId to the song file.
switch (currentSong.song.toLowerCase())
2020-11-01 01:11:14 +00:00
{
case 'spookeez' | 'monster' | 'south':
currentStageId = "spookyMansion";
case 'pico' | 'blammed' | 'philly':
currentStageId = 'phillyTrain';
case "milf" | 'satin-panties' | 'high':
currentStageId = 'limoRide';
case "cocoa" | 'eggnog':
currentStageId = 'mallXmas';
case 'winter-horrorland':
currentStageId = 'mallEvil';
2022-03-01 04:04:55 +00:00
case 'pyro':
currentStageId = 'pyro';
case 'senpai' | 'roses':
currentStageId = 'school';
2022-03-01 16:29:01 +00:00
case "darnell":
currentStageId = 'phillyStreets';
case 'thorns':
currentStageId = 'schoolEvil';
2021-03-07 20:34:21 +00:00
case 'guns' | 'stress' | 'ugh':
currentStageId = 'tankmanBattlefield';
default:
currentStageId = "mainStage";
2020-11-01 01:11:14 +00:00
}
// Loads the relevant stage based on its ID.
loadStage(currentStageId);
}
2020-10-05 20:55:48 +00:00
function initCharacters()
{
2021-09-14 21:12:11 +00:00
// all dis is shitty, redo later for stage shit
2021-01-15 04:33:12 +00:00
var gfVersion:String = 'gf';
switch (currentStageId)
2021-01-20 02:09:47 +00:00
{
2022-03-06 07:37:38 +00:00
case 'limoRide':
2021-01-20 02:09:47 +00:00
gfVersion = 'gf-car';
2022-03-06 07:37:38 +00:00
case 'mallXmas' | 'mallEvil':
2021-01-20 09:03:49 +00:00
gfVersion = 'gf-christmas';
2021-04-22 02:17:00 +00:00
case 'school' | 'schoolEvil':
2021-02-02 05:48:22 +00:00
gfVersion = 'gf-pixel';
2022-03-06 07:37:38 +00:00
case 'tankmanBattlefield':
2021-04-10 02:49:25 +00:00
gfVersion = 'gf-tankmen';
2021-01-20 02:09:47 +00:00
}
if (currentSong.player1 == "pico")
2021-09-14 21:12:11 +00:00
{
gfVersion = "nene";
}
if (currentSong.song.toLowerCase() == 'stress')
2021-03-14 01:53:57 +00:00
gfVersion = 'pico-speaker';
var gf = new Character(400, 130, gfVersion);
2020-10-05 11:46:57 +00:00
gf.scrollFactor.set(0.95, 0.95);
2021-03-14 01:53:57 +00:00
switch (gfVersion)
{
case 'pico-speaker':
gf.x -= 50;
gf.y -= 200;
}
var dad = new Character(100, 100, currentSong.player2);
2020-10-03 06:50:15 +00:00
2021-04-09 20:37:54 +00:00
camPos = new FlxPoint(dad.getGraphicMidpoint().x, dad.getGraphicMidpoint().y);
2020-11-01 01:11:14 +00:00
switch (currentSong.player2)
2020-10-19 00:59:53 +00:00
{
2020-10-23 23:12:38 +00:00
case 'gf':
dad.setPosition(gf.x, gf.y);
gf.visible = false;
2020-11-01 01:11:14 +00:00
if (isStoryMode)
{
camPos.x += 600;
tweenCamIn();
}
2020-10-23 23:12:38 +00:00
case "spooky":
dad.y += 200;
2020-10-30 23:47:19 +00:00
case "monster":
dad.y += 100;
2021-01-20 06:38:39 +00:00
case 'monster-christmas':
dad.y += 130;
2020-11-01 01:11:14 +00:00
case 'dad':
camPos.x += 400;
2020-12-09 22:46:47 +00:00
case 'pico':
2020-12-10 23:23:53 +00:00
camPos.x += 600;
2020-12-09 22:46:47 +00:00
dad.y += 300;
2021-01-20 02:09:47 +00:00
case 'parents-christmas':
dad.x -= 500;
2021-04-22 02:17:00 +00:00
case 'senpai' | 'senpai-angry':
2021-02-02 08:24:34 +00:00
dad.x += 150;
dad.y += 360;
camPos.set(dad.getGraphicMidpoint().x + 300, dad.getGraphicMidpoint().y);
2021-02-02 05:48:22 +00:00
case 'spirit':
dad.x -= 150;
dad.y += 100;
camPos.set(dad.getGraphicMidpoint().x + 300, dad.getGraphicMidpoint().y);
2021-03-04 19:30:35 +00:00
case 'tankman':
dad.y += 180;
2020-10-19 00:59:53 +00:00
}
var boyfriend = new Boyfriend(770, 450, currentSong.player1);
2020-10-03 06:50:15 +00:00
2020-12-27 02:46:22 +00:00
// REPOSITIONING PER STAGE
switch (currentStageId)
2020-12-27 02:46:22 +00:00
{
2021-02-02 05:48:22 +00:00
case 'schoolEvil':
var evilTrail = new FlxTrail(dad, null, 4, 24, 0.3, 0.069);
2022-03-09 15:36:13 +00:00
// Go behind Spirit.
evilTrail.zIndex = 190;
2021-02-02 05:48:22 +00:00
add(evilTrail);
2021-04-01 23:39:03 +00:00
case "tank":
2021-04-10 05:49:57 +00:00
gf.y += 10;
gf.x -= 30;
2021-04-02 01:35:10 +00:00
boyfriend.x += 40;
boyfriend.y += 0;
dad.y += 60;
2021-04-01 23:39:03 +00:00
dad.x -= 80;
2021-04-02 01:43:53 +00:00
2021-04-10 05:49:57 +00:00
if (gfVersion != 'pico-speaker')
2021-04-02 01:43:53 +00:00
{
2021-04-10 05:49:57 +00:00
gf.x -= 170;
gf.y -= 75;
2021-04-02 01:43:53 +00:00
}
2020-12-27 02:46:22 +00:00
}
if (currentStage != null)
2022-02-23 21:49:54 +00:00
{
// We're using Eric's stage handler.
// Characters get added to the stage, not the main scene.
currentStage.addCharacter(gf, GF);
currentStage.addCharacter(boyfriend, BF);
currentStage.addCharacter(dad, DAD);
2022-02-25 07:02:06 +00:00
// Redo z-indexes.
currentStage.refresh();
2022-02-23 21:49:54 +00:00
}
else
{
add(gf);
add(dad);
add(boyfriend);
}
2020-10-23 23:12:38 +00:00
}
2021-04-08 00:19:49 +00:00
function ughIntro()
{
inCutscene = true;
2021-04-18 10:53:23 +00:00
2021-04-19 06:46:02 +00:00
var blackShit:FlxSprite = new FlxSprite(-200, -200).makeGraphic(FlxG.width * 2, FlxG.height * 2, FlxColor.BLACK);
blackShit.scrollFactor.set();
add(blackShit);
2021-04-08 00:19:49 +00:00
2022-03-02 06:20:27 +00:00
#if html5
2021-04-19 06:46:02 +00:00
var vid:FlxVideo = new FlxVideo('music/ughCutscene.mp4');
vid.finishCallback = function()
{
remove(blackShit);
FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom}, (Conductor.crochet / 1000) * 5, {ease: FlxEase.quadInOut});
startCountdown();
cameraMovement();
};
2022-03-02 06:20:27 +00:00
#else
remove(blackShit);
FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom}, (Conductor.crochet / 1000) * 5, {ease: FlxEase.quadInOut});
startCountdown();
cameraMovement();
#end
2021-04-08 00:19:49 +00:00
2021-04-19 06:46:02 +00:00
FlxG.camera.zoom = defaultCamZoom * 1.2;
2021-04-08 00:19:49 +00:00
cameraFollowPoint.x += 100;
cameraFollowPoint.y += 100;
2021-04-08 00:19:49 +00:00
2021-04-19 06:46:02 +00:00
/*
FlxG.sound.playMusic(Paths.music('DISTORTO'), 0);
FlxG.sound.music.fadeIn(5, 0, 0.5);
2021-04-18 03:19:33 +00:00
2021-04-19 06:46:02 +00:00
dad.visible = false;
var tankCutscene:TankCutscene = new TankCutscene(-20, 320);
tankCutscene.frames = Paths.getSparrowAtlas('cutsceneStuff/tankTalkSong1');
tankCutscene.animation.addByPrefix('wellWell', 'TANK TALK 1 P1', 24, false);
tankCutscene.animation.addByPrefix('killYou', 'TANK TALK 1 P2', 24, false);
tankCutscene.animation.play('wellWell');
tankCutscene.antialiasing = true;
gfCutsceneLayer.add(tankCutscene);
2021-04-18 03:19:33 +00:00
2021-04-19 06:46:02 +00:00
camHUD.visible = false;
2021-04-08 00:19:49 +00:00
2021-04-19 06:46:02 +00:00
FlxG.camera.zoom *= 1.2;
2021-04-18 20:54:21 +00:00
camFollow.y += 100;
2021-04-18 03:19:33 +00:00
2021-04-19 06:46:02 +00:00
tankCutscene.startSyncAudio = FlxG.sound.load(Paths.sound('wellWellWell'));
new FlxTimer().start(3, function(tmr:FlxTimer)
2021-04-08 00:19:49 +00:00
{
2021-04-19 06:46:02 +00:00
camFollow.x += 800;
camFollow.y += 100;
FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom * 1.2}, 0.27, {ease: FlxEase.quadInOut});
new FlxTimer().start(1.5, function(bep:FlxTimer)
2021-04-18 03:19:33 +00:00
{
2021-04-19 06:46:02 +00:00
boyfriend.playAnim('singUP');
// play sound
FlxG.sound.play(Paths.sound('bfBeep'), function()
{
boyfriend.playAnim('idle');
});
});
2021-04-08 00:19:49 +00:00
2021-04-19 06:46:02 +00:00
new FlxTimer().start(3, function(swaggy:FlxTimer)
2021-04-08 00:19:49 +00:00
{
2021-04-19 06:46:02 +00:00
camFollow.x -= 800;
camFollow.y -= 100;
FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom * 1.2}, 0.5, {ease: FlxEase.quadInOut});
tankCutscene.animation.play('killYou');
FlxG.sound.play(Paths.sound('killYou'));
new FlxTimer().start(6.1, function(swagasdga:FlxTimer)
{
FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom}, (Conductor.crochet / 1000) * 5, {ease: FlxEase.quadInOut});
2021-04-08 00:19:49 +00:00
2021-04-19 06:46:02 +00:00
FlxG.sound.music.fadeOut((Conductor.crochet / 1000) * 5, 0);
2021-04-08 21:31:08 +00:00
2021-04-19 06:46:02 +00:00
new FlxTimer().start((Conductor.crochet / 1000) * 5, function(money:FlxTimer)
{
dad.visible = true;
gfCutsceneLayer.remove(tankCutscene);
});
2021-04-08 00:19:49 +00:00
2021-04-19 06:46:02 +00:00
cameraMovement();
2021-04-08 00:19:49 +00:00
2021-04-19 06:46:02 +00:00
startCountdown();
camHUD.visible = true;
});
2021-04-08 00:19:49 +00:00
});
2021-04-19 06:46:02 +00:00
});*/
2021-04-08 00:19:49 +00:00
}
2022-02-26 14:06:49 +00:00
/**
* Removes any references to the current stage, then clears the stage cache,
* then reloads all the stages.
*
* This is useful for when you want to edit a stage without reloading the whole game.
* Reloading works on both the JSON and the HXC, if applicable.
2022-03-06 08:33:12 +00:00
*
* Call this by pressing F5 on a debug build.
2022-02-26 14:06:49 +00:00
*/
function debug_refreshStages()
{
// Remove the current stage. If the stage gets deleted while it's still in use,
// it'll probably crash the game or something.
if (this.currentStage != null)
2022-02-26 14:06:49 +00:00
{
remove(currentStage);
var event:ScriptEvent = new ScriptEvent(ScriptEvent.DESTROY, false);
ScriptEventDispatcher.callEvent(currentStage, event);
currentStage = null;
2022-02-26 14:06:49 +00:00
}
ModuleHandler.clearModuleCache();
2022-02-26 14:06:49 +00:00
// Forcibly reload scripts so that scripted stages can be edited.
polymod.hscript.PolymodScriptClass.clearScriptClasses();
polymod.hscript.PolymodScriptClass.registerAllScriptClasses();
// Reload the stages in cache. This might cause a lag spike but who cares this is a debug utility.
StageDataParser.loadStageCache();
ModuleHandler.loadModuleCache();
2022-02-26 14:06:49 +00:00
// Reload the level. This should use new data from the assets folder.
LoadingState.loadAndSwitchState(new PlayState());
}
2022-02-23 21:49:54 +00:00
/**
* Loads stage data from cache, assembles the props,
* and adds it to the state.
* @param id
*/
function loadStage(id:String)
{
currentStage = StageDataParser.fetchStage(id);
2022-02-23 21:49:54 +00:00
if (currentStage != null)
2022-02-23 21:49:54 +00:00
{
// Actually create and position the sprites.
var event:ScriptEvent = new ScriptEvent(ScriptEvent.CREATE, false);
ScriptEventDispatcher.callEvent(currentStage, event);
2022-02-23 21:49:54 +00:00
// Apply camera zoom.
defaultCamZoom *= currentStage.camZoom;
2022-02-23 21:49:54 +00:00
// Add the stage to the scene.
this.add(currentStage);
2022-02-23 21:49:54 +00:00
}
}
2021-04-08 16:33:19 +00:00
function gunsIntro()
{
inCutscene = true;
2021-04-18 10:53:23 +00:00
var blackShit:FlxSprite = new FlxSprite(-200, -200).makeGraphic(FlxG.width * 2, FlxG.height * 2, FlxColor.BLACK);
blackShit.scrollFactor.set();
add(blackShit);
2022-03-02 06:20:27 +00:00
#if html5
2021-04-18 08:09:56 +00:00
var vid:FlxVideo = new FlxVideo('music/gunsCutscene.mp4');
vid.finishCallback = function()
{
2021-04-18 10:53:23 +00:00
remove(blackShit);
2021-04-18 08:09:56 +00:00
FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom}, (Conductor.crochet / 1000) * 5, {ease: FlxEase.quadInOut});
startCountdown();
cameraMovement();
};
2022-03-02 06:20:27 +00:00
#else
remove(blackShit);
FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom}, (Conductor.crochet / 1000) * 5, {ease: FlxEase.quadInOut});
startCountdown();
cameraMovement();
#end
2021-04-09 20:37:54 +00:00
2021-04-18 17:23:09 +00:00
/* camFollow.setPosition(camPos.x, camPos.y);
2021-04-08 21:31:08 +00:00
2021-04-18 08:09:56 +00:00
camHUD.visible = false;
2021-04-08 21:31:08 +00:00
2021-04-18 08:09:56 +00:00
FlxG.sound.playMusic(Paths.music('DISTORTO'), 0);
FlxG.sound.music.fadeIn(5, 0, 0.5);
2021-04-08 16:33:19 +00:00
2021-04-18 08:09:56 +00:00
camFollow.y += 100;
2021-04-08 16:33:19 +00:00
2021-04-18 08:09:56 +00:00
FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom * 1.3}, 4, {ease: FlxEase.quadInOut});
2021-04-08 16:33:19 +00:00
2021-04-18 08:09:56 +00:00
dad.visible = false;
var tankCutscene:TankCutscene = new TankCutscene(20, 320);
tankCutscene.frames = Paths.getSparrowAtlas('cutsceneStuff/tankTalkSong2');
tankCutscene.animation.addByPrefix('tankyguy', 'TANK TALK 2', 24, false);
tankCutscene.animation.play('tankyguy');
tankCutscene.antialiasing = true;
gfCutsceneLayer.add(tankCutscene); // add();
2021-04-08 16:33:19 +00:00
2021-04-18 08:09:56 +00:00
tankCutscene.startSyncAudio = FlxG.sound.load(Paths.sound('tankSong2'));
2021-04-08 21:31:08 +00:00
2021-04-18 08:09:56 +00:00
new FlxTimer().start(4.1, function(ugly:FlxTimer)
{
FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom * 1.4}, 0.4, {ease: FlxEase.quadOut});
FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom * 1.3}, 0.7, {ease: FlxEase.quadInOut, startDelay: 0.45});
2021-04-08 16:33:19 +00:00
2021-04-18 08:09:56 +00:00
gf.playAnim('sad');
});
2021-04-08 21:31:08 +00:00
2021-04-18 08:09:56 +00:00
new FlxTimer().start(11, function(tmr:FlxTimer)
2021-04-08 16:33:19 +00:00
{
2021-04-18 08:09:56 +00:00
FlxG.sound.music.fadeOut((Conductor.crochet / 1000) * 5, 0);
FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom}, (Conductor.crochet * 5) / 1000, {ease: FlxEase.quartIn});
startCountdown();
new FlxTimer().start((Conductor.crochet * 25) / 1000, function(daTim:FlxTimer)
{
dad.visible = true;
gfCutsceneLayer.remove(tankCutscene);
});
2021-04-08 21:31:08 +00:00
2021-04-18 08:09:56 +00:00
camHUD.visible = true;
});*/
2021-04-08 16:33:19 +00:00
}
2021-04-10 00:34:25 +00:00
/**
* [
* [0, function(){blah;}],
* [4.6, function(){blah;}],
* [25.1, function(){blah;}],
* [30.7, function(){blah;}]
* ]
* SOMETHING LIKE THIS
*/
// var cutsceneFunctions:Array<Dynamic> = [];
2021-04-08 00:19:49 +00:00
function stressIntro()
{
inCutscene = true;
2021-04-18 10:53:23 +00:00
var blackShit:FlxSprite = new FlxSprite(-200, -200).makeGraphic(FlxG.width * 2, FlxG.height * 2, FlxColor.BLACK);
blackShit.scrollFactor.set();
add(blackShit);
2022-03-02 06:20:27 +00:00
#if html5
2021-04-18 09:25:44 +00:00
var vid:FlxVideo = new FlxVideo('music/stressCutscene.mp4');
vid.finishCallback = function()
{
2021-04-18 10:53:23 +00:00
remove(blackShit);
2021-04-18 09:25:44 +00:00
FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom}, (Conductor.crochet / 1000) * 5, {ease: FlxEase.quadInOut});
startCountdown();
cameraMovement();
};
2022-03-02 06:20:27 +00:00
#else
remove(blackShit);
FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom}, (Conductor.crochet / 1000) * 5, {ease: FlxEase.quadInOut});
startCountdown();
cameraMovement();
#end
2021-04-08 00:19:49 +00:00
}
function initDiscord():Void
{
2021-03-22 14:09:46 +00:00
#if discord_rpc
2021-04-10 05:49:57 +00:00
storyDifficultyText = difficultyString();
iconRPC = currentSong.player2;
// To avoid having duplicate images in Discord assets
switch (iconRPC)
{
case 'senpai-angry':
iconRPC = 'senpai';
case 'monster-christmas':
iconRPC = 'monster';
case 'mom-car':
iconRPC = 'mom';
}
// String that contains the mode defined here so it isn't necessary to call changePresence for each mode
detailsText = isStoryMode ? "Story Mode: Week " + storyWeek : "Freeplay";
detailsPausedText = "Paused - " + detailsText;
// Updating Discord Rich Presence.
DiscordClient.changePresence(detailsText, currentSong.song + " (" + storyDifficultyText + ")", iconRPC);
#end
}
2021-02-01 06:50:30 +00:00
function schoolIntro(?dialogueBox:DialogueBox):Void
2021-01-25 09:18:44 +00:00
{
var black:FlxSprite = new FlxSprite(-100, -100).makeGraphic(FlxG.width * 2, FlxG.height * 2, FlxColor.BLACK);
black.scrollFactor.set();
add(black);
2021-02-02 10:46:17 +00:00
var red:FlxSprite = new FlxSprite(-100, -100).makeGraphic(FlxG.width * 2, FlxG.height * 2, 0xFFff1b31);
red.scrollFactor.set();
var senpaiEvil:FlxSprite = new FlxSprite();
2021-02-08 21:34:48 +00:00
senpaiEvil.frames = Paths.getSparrowAtlas('weeb/senpaiCrazy');
2021-02-02 10:46:17 +00:00
senpaiEvil.animation.addByPrefix('idle', 'Senpai Pre Explosion', 24, false);
senpaiEvil.setGraphicSize(Std.int(senpaiEvil.width * Constants.PIXEL_ART_SCALE));
2021-02-12 06:20:20 +00:00
senpaiEvil.scrollFactor.set();
2021-02-02 10:46:17 +00:00
senpaiEvil.updateHitbox();
senpaiEvil.screenCenter();
2021-04-15 01:56:42 +00:00
senpaiEvil.x += senpaiEvil.width / 5;
cameraFollowPoint.setPosition(camPos.x, camPos.y);
2021-02-02 10:46:17 +00:00
if (currentSong.song.toLowerCase() == 'roses' || currentSong.song.toLowerCase() == 'thorns')
2021-02-02 10:46:17 +00:00
{
2021-02-02 09:13:28 +00:00
remove(black);
if (currentSong.song.toLowerCase() == 'thorns')
2021-02-02 10:46:17 +00:00
{
add(red);
2021-04-15 01:56:42 +00:00
camHUD.visible = false;
2021-02-02 10:46:17 +00:00
}
2021-04-22 02:17:00 +00:00
else
FlxG.sound.play(Paths.sound('ANGRY'));
// moved senpai angry noise in here to clean up cutscene switch case lol
2021-02-02 10:46:17 +00:00
}
2021-01-25 09:18:44 +00:00
new FlxTimer().start(0.3, function(tmr:FlxTimer)
{
black.alpha -= 0.15;
if (black.alpha > 0)
tmr.reset(0.3);
else
{
2021-02-01 06:50:30 +00:00
if (dialogueBox != null)
{
2021-02-02 07:35:35 +00:00
inCutscene = true;
2021-02-02 10:46:17 +00:00
if (currentSong.song.toLowerCase() == 'thorns')
2021-02-02 10:46:17 +00:00
{
add(senpaiEvil);
senpaiEvil.alpha = 0;
new FlxTimer().start(0.3, function(swagTimer:FlxTimer)
{
senpaiEvil.alpha += 0.15;
if (senpaiEvil.alpha < 1)
swagTimer.reset();
else
{
senpaiEvil.animation.play('idle');
2021-02-08 21:34:48 +00:00
FlxG.sound.play(Paths.sound('Senpai_Dies'), 1, false, null, true, function()
2021-02-02 10:46:17 +00:00
{
remove(senpaiEvil);
remove(red);
FlxG.camera.fade(FlxColor.WHITE, 0.01, true, function()
{
add(dialogueBox);
2021-04-15 01:56:42 +00:00
camHUD.visible = true;
2021-02-02 10:46:17 +00:00
}, true);
});
new FlxTimer().start(3.2, function(deadTime:FlxTimer)
{
FlxG.camera.fade(FlxColor.WHITE, 1.6, false);
});
}
});
}
else
add(dialogueBox);
2021-02-01 06:50:30 +00:00
}
else
startCountdown();
2021-01-25 09:18:44 +00:00
remove(black);
}
});
}
2020-10-23 23:12:38 +00:00
function startCountdown():Void
{
2021-02-02 07:35:35 +00:00
inCutscene = false;
2021-04-18 09:25:44 +00:00
camHUD.visible = true;
2021-02-02 07:35:35 +00:00
buildStrumlines();
2020-11-01 01:11:14 +00:00
talking = false;
2021-09-24 14:56:05 +00:00
restartCountdownTimer();
}
function restartCountdownTimer():Void
{
2020-10-23 23:12:38 +00:00
startedCountdown = true;
2021-09-24 14:56:05 +00:00
2020-10-05 22:29:59 +00:00
Conductor.songPosition = 0;
2020-10-05 20:32:41 +00:00
Conductor.songPosition -= Conductor.crochet * 5;
2020-10-05 18:24:51 +00:00
2020-10-23 23:12:38 +00:00
var swagCounter:Int = 0;
startTimer.start(Conductor.crochet / 1000, function(tmr:FlxTimer)
2020-10-05 18:24:51 +00:00
{
// this just based on beatHit stuff but compact
if (swagCounter % gfSpeed == 0)
currentStage.getGirlfriend().dance();
if (swagCounter % 2 == 0)
{
if (currentStage.getBoyfriend().animation != null)
2022-03-01 04:04:55 +00:00
{
if (!currentStage.getBoyfriend().animation.curAnim.name.startsWith("sing"))
currentStage.getBoyfriend().playAnim('idle');
2022-03-01 04:04:55 +00:00
}
if (currentStage.getDad().animation != null)
2022-03-01 04:04:55 +00:00
{
if (!currentStage.getDad().animation.curAnim.name.startsWith("sing"))
currentStage.getDad().dance();
2022-03-01 04:04:55 +00:00
}
}
else if (currentStage.getDad().curCharacter == 'spooky' && !currentStage.getDad().animation.curAnim.name.startsWith("sing"))
currentStage.getDad().dance();
if (generatedMusic)
activeNotes.sort(SortUtil.byStrumtime, FlxSort.DESCENDING);
2020-10-30 23:47:19 +00:00
2021-04-22 02:17:00 +00:00
var introSprPaths:Array<String> = ["ready", "set", "go"];
2021-01-25 20:56:42 +00:00
var altSuffix:String = "";
2021-01-25 09:18:44 +00:00
if (currentStageId.startsWith("school"))
2021-01-25 09:18:44 +00:00
{
2021-04-22 02:17:00 +00:00
altSuffix = '-pixel';
introSprPaths = ['weeb/pixelUI/ready-pixel', 'weeb/pixelUI/set-pixel', 'weeb/pixelUI/date-pixel'];
2021-01-25 09:18:44 +00:00
}
2021-06-05 04:01:15 +00:00
var introSndPaths:Array<String> = [
"intro3" + altSuffix, "intro2" + altSuffix,
"intro1" + altSuffix, "introGo" + altSuffix
];
2021-04-22 02:17:00 +00:00
if (swagCounter > 0)
readySetGo(introSprPaths[swagCounter - 1]);
FlxG.sound.play(Paths.sound(introSndPaths[swagCounter]), 0.6);
2021-01-25 09:18:44 +00:00
2021-04-22 02:17:00 +00:00
swagCounter += 1;
}, 4);
}
2021-01-25 09:18:44 +00:00
2021-04-22 02:17:00 +00:00
function readySetGo(path:String):Void
{
var spr:FlxSprite = new FlxSprite().loadGraphic(Paths.image(path));
spr.scrollFactor.set();
2021-01-25 09:18:44 +00:00
if (currentStageId.startsWith('school'))
spr.setGraphicSize(Std.int(spr.width * Constants.PIXEL_ART_SCALE));
2021-04-22 02:17:00 +00:00
spr.updateHitbox();
spr.screenCenter();
add(spr);
FlxTween.tween(spr, {y: spr.y += 100, alpha: 0}, Conductor.crochet / 1000, {
ease: FlxEase.cubeInOut,
onComplete: function(twn:FlxTween)
{
spr.destroy();
2020-10-05 18:24:51 +00:00
}
2021-04-22 02:17:00 +00:00
});
2020-10-03 06:50:15 +00:00
}
2020-10-05 18:24:51 +00:00
function startSong():Void
{
startingSong = false;
2020-10-24 09:19:13 +00:00
previousFrameTime = FlxG.game.ticks;
if (!isGamePaused)
2021-09-24 14:56:05 +00:00
{
2021-11-02 14:28:26 +00:00
// if (FlxG.sound.music != null)
// FlxG.sound.music.play(true);
// else
FlxG.sound.playMusic(Paths.inst(currentSong.song), 1, false);
2021-09-24 14:56:05 +00:00
}
2020-11-01 01:11:14 +00:00
FlxG.sound.music.onComplete = endSong;
2020-10-05 18:24:51 +00:00
vocals.play();
2021-03-22 14:09:46 +00:00
#if discord_rpc
// Song duration in a float, useful for the time left feature
songLength = FlxG.sound.music.length;
// Updating Discord Rich Presence (with Time Left)
DiscordClient.changePresence(detailsText, currentSong.song + " (" + storyDifficultyText + ")", iconRPC, true, songLength);
#end
2020-10-05 18:24:51 +00:00
}
2021-03-29 17:24:49 +00:00
private function generateSong():Void
2020-10-03 06:50:15 +00:00
{
2020-10-04 06:42:58 +00:00
// FlxG.log.add(ChartParser.parse());
Conductor.changeBPM(currentSong.bpm);
2020-10-04 06:42:58 +00:00
currentSong.song = currentSong.song;
2020-10-05 09:48:30 +00:00
if (currentSong.needsVoices)
vocals = new VoicesGroup(currentSong.song, currentSong.voiceList);
2020-10-14 08:30:54 +00:00
else
vocals = new VoicesGroup(currentSong.song, null, false);
2020-10-14 08:30:54 +00:00
2021-09-20 15:50:52 +00:00
vocals.members[0].onComplete = function()
2021-04-09 20:37:54 +00:00
{
vocalsFinished = true;
};
2020-10-03 06:50:15 +00:00
activeNotes = new FlxTypedGroup<Note>();
activeNotes.zIndex = 1000;
add(activeNotes);
2020-10-03 06:50:15 +00:00
2021-09-24 14:56:05 +00:00
regenNoteData();
generatedMusic = true;
}
function regenNoteData():Void
{
// make unspawn notes shit def empty
inactiveNotes = [];
2021-09-24 14:56:05 +00:00
activeNotes.forEach(function(nt)
2021-09-24 14:56:05 +00:00
{
2021-12-07 03:35:14 +00:00
nt.followsTime = false;
2021-12-07 03:39:03 +00:00
FlxTween.tween(nt, {y: FlxG.height + nt.y}, 0.5, {
2021-12-07 03:35:14 +00:00
ease: FlxEase.expoIn,
onComplete: function(twn)
{
nt.kill();
activeNotes.remove(nt, true);
2021-12-07 03:35:14 +00:00
nt.destroy();
}
});
2021-09-24 14:56:05 +00:00
});
2020-10-24 09:19:13 +00:00
var noteData:Array<SwagSection>;
2020-10-04 06:42:58 +00:00
2020-10-13 08:37:19 +00:00
// NEW SHIT
noteData = SongLoad.getSong();
2020-10-13 08:37:19 +00:00
for (section in noteData)
2020-10-03 06:50:15 +00:00
{
2020-10-19 00:59:53 +00:00
for (songNotes in section.sectionNotes)
{
2022-01-21 22:23:12 +00:00
var daStrumTime:Float = songNotes.strumTime;
var daNoteData:Int = Std.int(songNotes.noteData % 4);
2020-10-18 01:47:59 +00:00
var gottaHitNote:Bool = section.mustHitSection;
2022-02-10 01:31:36 +00:00
if (songNotes.highStakes)
2020-10-18 01:47:59 +00:00
gottaHitNote = !section.mustHitSection;
2020-10-13 08:37:19 +00:00
var oldNote:Note;
if (inactiveNotes.length > 0)
oldNote = inactiveNotes[Std.int(inactiveNotes.length - 1)];
else
oldNote = null;
2020-10-05 05:13:12 +00:00
var swagNote:Note = new Note(daStrumTime, daNoteData, oldNote);
2022-03-01 04:04:55 +00:00
swagNote.data = songNotes;
swagNote.scrollFactor.set(0, 0);
2020-10-03 06:50:15 +00:00
2022-01-22 21:53:38 +00:00
var susLength:Float = swagNote.data.sustainLength;
2020-10-20 01:59:00 +00:00
susLength = susLength / Conductor.stepCrochet;
inactiveNotes.push(swagNote);
2020-10-05 09:48:30 +00:00
for (susNote in 0...Math.round(susLength))
2020-10-20 01:59:00 +00:00
{
oldNote = inactiveNotes[Std.int(inactiveNotes.length - 1)];
2020-10-20 01:59:00 +00:00
2020-10-21 20:12:32 +00:00
var sustainNote:Note = new Note(daStrumTime + (Conductor.stepCrochet * susNote) + Conductor.stepCrochet, daNoteData, oldNote, true);
2020-10-20 01:59:00 +00:00
sustainNote.scrollFactor.set();
inactiveNotes.push(sustainNote);
2020-10-20 01:59:00 +00:00
sustainNote.mustPress = gottaHitNote;
if (sustainNote.mustPress)
sustainNote.x += FlxG.width / 2; // general offset
}
2020-10-18 01:47:59 +00:00
swagNote.mustPress = gottaHitNote;
2020-10-03 06:50:15 +00:00
if (swagNote.mustPress)
2020-10-16 11:15:17 +00:00
swagNote.x += FlxG.width / 2; // general offset
2020-10-03 06:50:15 +00:00
}
}
2020-10-05 09:48:30 +00:00
inactiveNotes.sort(function(a:Note, b:Note):Int
2020-10-04 08:38:21 +00:00
{
return SortUtil.byStrumtime(FlxSort.ASCENDING, a, b);
});
2020-10-04 08:38:21 +00:00
}
2020-11-01 01:11:14 +00:00
function tweenCamIn():Void
{
2021-08-22 00:45:03 +00:00
FlxTween.tween(FlxG.camera, {zoom: 1.3 * FlxCamera.defaultZoom}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut});
2020-11-01 01:11:14 +00:00
}
2021-03-22 14:09:46 +00:00
#if discord_rpc
2021-02-27 23:49:53 +00:00
override public function onFocus():Void
{
if (health > 0 && !paused && FlxG.autoPause)
2021-02-27 23:49:53 +00:00
{
if (Conductor.songPosition > 0.0)
DiscordClient.changePresence(detailsText, currentSong.song + " (" + storyDifficultyText + ")", iconRPC, true,
songLength - Conductor.songPosition);
2021-02-27 23:49:53 +00:00
else
DiscordClient.changePresence(detailsText, currentSong.song + " (" + storyDifficultyText + ")", iconRPC);
2021-02-27 23:49:53 +00:00
}
super.onFocus();
}
2021-02-27 23:49:53 +00:00
override public function onFocusLost():Void
{
if (health > 0 && !paused && FlxG.autoPause)
DiscordClient.changePresence(detailsPausedText, currentSong.song + " (" + storyDifficultyText + ")", iconRPC);
2021-02-27 23:49:53 +00:00
super.onFocusLost();
}
2021-03-22 14:09:46 +00:00
#end
2021-02-27 23:49:53 +00:00
2020-12-13 06:42:48 +00:00
function resyncVocals():Void
{
if (_exiting)
2021-04-09 20:37:54 +00:00
return;
2020-12-13 06:42:48 +00:00
vocals.pause();
2020-12-13 06:42:48 +00:00
FlxG.sound.music.play();
2021-04-18 20:54:21 +00:00
Conductor.songPosition = FlxG.sound.music.time + Conductor.offset;
if (vocalsFinished)
2021-04-09 20:37:54 +00:00
return;
vocals.time = FlxG.sound.music.time;
2020-12-13 06:42:48 +00:00
vocals.play();
}
2020-10-03 06:50:15 +00:00
override public function update(elapsed:Float)
{
super.update(elapsed);
updateHealthBar();
2021-09-24 15:21:34 +00:00
if (needsReset)
{
resetCamera();
persistentUpdate = true;
persistentDraw = true;
2021-09-24 14:56:05 +00:00
startingSong = true;
FlxG.sound.music.pause();
vocals.pause();
var event:ScriptEvent = new ScriptEvent(ScriptEvent.SONG_RESET, false);
ScriptEventDispatcher.callEvent(currentStage, event);
ModuleHandler.callEvent(event);
2022-03-09 15:29:03 +00:00
2021-09-24 14:56:05 +00:00
FlxG.sound.music.time = 0;
2021-09-28 02:30:38 +00:00
regenNoteData(); // loads the note data from start
2021-09-24 15:21:34 +00:00
health = 1;
2021-09-24 14:56:05 +00:00
restartCountdownTimer();
needsReset = false;
}
2021-09-28 02:30:38 +00:00
#if !debug
perfectMode = false;
#else
if (FlxG.keys.justPressed.H)
camHUD.visible = !camHUD.visible;
2020-12-23 01:55:03 +00:00
#end
// do this BEFORE super.update() so songPosition is accurate
if (startingSong)
{
if (startedCountdown)
{
Conductor.songPosition += FlxG.elapsed * 1000;
if (Conductor.songPosition >= 0)
startSong();
}
}
else
{
2021-09-23 01:09:28 +00:00
if (Paths.SOUND_EXT == 'mp3')
Conductor.offset = -13; // DO NOT FORGET TO REMOVE THE HARDCODE! WHEN I MAKE BETTER OFFSET SYSTEM!
2021-04-18 20:54:21 +00:00
Conductor.songPosition = FlxG.sound.music.time + Conductor.offset; // 20 is THE MILLISECONDS??
// Conductor.songPosition += FlxG.elapsed * 1000;
if (!isGamePaused)
{
songTime += FlxG.game.ticks - previousFrameTime;
previousFrameTime = FlxG.game.ticks;
// Interpolation type beat
if (Conductor.lastSongPos != Conductor.songPosition)
{
songTime = (songTime + Conductor.songPosition) / 2;
Conductor.lastSongPos = Conductor.songPosition;
// Conductor.songPosition += FlxG.elapsed * 1000;
// trace('MISSED FRAME');
}
}
// Conductor.lastSongPos = FlxG.sound.music.time;
}
2021-08-22 20:54:22 +00:00
var androidPause:Bool = false;
#if android
androidPause = FlxG.android.justPressed.BACK;
#end
if ((controls.PAUSE || androidPause) && startedCountdown && mayPauseGame)
2020-10-09 21:24:20 +00:00
{
persistentUpdate = false;
persistentDraw = true;
2022-03-06 08:33:12 +00:00
// There is a 1/1000 change to use a special pause menu.
// This prevents the player from resuming, but that's the point.
// It's a reference to Gitaroo Man, which doesn't let you pause the game.
2022-02-26 14:06:49 +00:00
if (FlxG.random.bool(1 / 1000))
{
FlxG.switchState(new GitarooPause());
}
else
2021-03-14 03:41:12 +00:00
{
var boyfriendPos = currentStage.getBoyfriend().getScreenPosition();
2021-03-14 03:41:12 +00:00
var pauseSubState = new PauseSubState(boyfriendPos.x, boyfriendPos.y);
openSubState(pauseSubState);
pauseSubState.camera = camHUD;
boyfriendPos.put();
}
2021-03-22 14:09:46 +00:00
#if discord_rpc
DiscordClient.changePresence(detailsPausedText, currentSong.song + " (" + storyDifficultyText + ")", iconRPC);
2021-02-27 23:23:50 +00:00
#end
2020-10-09 21:24:20 +00:00
}
2020-11-07 02:17:27 +00:00
if (FlxG.keys.justPressed.SEVEN)
2020-10-14 01:44:07 +00:00
{
2020-11-07 02:17:27 +00:00
FlxG.switchState(new ChartingState());
2021-03-22 14:09:46 +00:00
#if discord_rpc
DiscordClient.changePresence("Chart Editor", null, null, true);
#end
2020-10-14 01:44:07 +00:00
}
2021-09-10 14:07:55 +00:00
if (FlxG.keys.justPressed.EIGHT)
FlxG.switchState(new funkin.ui.animDebugShit.DebugBoundingState());
2021-09-10 14:07:55 +00:00
2022-02-26 14:06:49 +00:00
if (FlxG.keys.justPressed.F5)
debug_refreshStages();
2021-04-22 02:17:00 +00:00
if (FlxG.keys.justPressed.NINE)
iconP1.swapOldIcon();
2021-05-15 21:39:13 +00:00
iconP1.setGraphicSize(Std.int(CoolUtil.coolLerp(iconP1.width, 150, 0.15)));
iconP2.setGraphicSize(Std.int(CoolUtil.coolLerp(iconP2.width, 150, 0.15)));
2020-12-24 23:24:11 +00:00
iconP1.updateHitbox();
iconP2.updateHitbox();
2021-01-05 12:53:42 +00:00
2020-12-24 23:24:11 +00:00
var iconOffset:Int = 26;
2021-09-24 15:21:34 +00:00
iconP1.x = healthBar.x + (healthBar.width * (FlxMath.remapToRange(healthBar.value, 0, 2, 100, 0) * 0.01) - iconOffset);
iconP2.x = healthBar.x + (healthBar.width * (FlxMath.remapToRange(healthBar.value, 0, 2, 100, 0) * 0.01)) - (iconP2.width - iconOffset);
2020-10-05 20:32:41 +00:00
2020-11-01 19:16:22 +00:00
if (health > 2)
health = 2;
2020-10-24 09:19:13 +00:00
if (healthBar.percent < 20)
2020-12-24 23:24:11 +00:00
iconP1.animation.curAnim.curFrame = 1;
2020-10-05 22:29:59 +00:00
else
2020-12-24 23:24:11 +00:00
iconP1.animation.curAnim.curFrame = 0;
2021-01-14 03:38:31 +00:00
if (healthBar.percent > 80)
2021-01-15 04:33:12 +00:00
iconP2.animation.curAnim.curFrame = 1;
2021-01-01 05:39:58 +00:00
else
2021-01-15 04:33:12 +00:00
iconP2.animation.curAnim.curFrame = 0;
2021-01-05 12:53:42 +00:00
2020-11-02 06:46:37 +00:00
#if debug
2021-04-21 20:58:36 +00:00
if (FlxG.keys.justPressed.ONE)
endSong();
2021-06-05 04:01:15 +00:00
if (FlxG.keys.justPressed.PAGEUP)
changeSection(1);
if (FlxG.keys.justPressed.PAGEDOWN)
changeSection(-1);
2020-11-02 06:46:37 +00:00
#end
2020-10-04 06:42:58 +00:00
if (generatedMusic && SongLoad.getSong()[Std.int(curStep / 16)] != null)
2020-10-03 19:32:15 +00:00
{
cameraRightSide = SongLoad.getSong()[Std.int(curStep / 16)].mustHitSection;
2020-10-18 07:27:39 +00:00
cameraMovement();
2020-10-03 06:50:15 +00:00
}
2020-10-05 09:48:30 +00:00
if (camZooming)
{
2020-12-27 02:46:22 +00:00
FlxG.camera.zoom = FlxMath.lerp(defaultCamZoom, FlxG.camera.zoom, 0.95);
2021-08-22 00:45:03 +00:00
camHUD.zoom = FlxMath.lerp(1 * FlxCamera.defaultZoom, camHUD.zoom, 0.95);
2020-10-05 09:48:30 +00:00
}
FlxG.watch.addQuick("beatShit", curBeat);
FlxG.watch.addQuick("stepShit", curStep);
if (currentSong.song == 'Fresh')
2020-10-05 09:48:30 +00:00
{
switch (curBeat)
2020-10-05 12:55:39 +00:00
{
case 16:
camZooming = true;
gfSpeed = 2;
case 48:
gfSpeed = 1;
case 80:
gfSpeed = 2;
case 112:
gfSpeed = 1;
2020-10-05 22:29:59 +00:00
}
}
if (!inCutscene && !_exiting)
2020-12-02 17:28:28 +00:00
{
// RESET = Quick Game Over Screen
if (controls.RESET)
{
health = 0;
trace("RESET = True");
}
#if CAN_CHEAT // brandon's a pussy
if (controls.CHEAT)
{
health += 1;
trace("User is cheating!");
}
#end
if (health <= 0 && !isPracticeMode)
{
persistentUpdate = false;
persistentDraw = false;
2020-10-30 23:47:19 +00:00
vocals.pause();
FlxG.sound.music.pause();
2020-10-30 23:47:19 +00:00
deathCounter += 1;
2021-03-04 19:30:35 +00:00
openSubState(new GameOverSubstate());
2020-10-30 23:47:19 +00:00
#if discord_rpc
// Game Over doesn't get his own variable because it's only used here
DiscordClient.changePresence("Game Over - " + detailsText, currentSong.song + " (" + storyDifficultyText + ")", iconRPC);
#end
}
2020-10-05 22:29:59 +00:00
}
while (inactiveNotes[0] != null && inactiveNotes[0].data.strumTime - Conductor.songPosition < 1800 / SongLoad.getSpeed())
2020-10-05 09:48:30 +00:00
{
var dunceNote:Note = inactiveNotes[0];
activeNotes.add(dunceNote);
2020-10-05 10:25:14 +00:00
inactiveNotes.shift();
2020-10-05 09:48:30 +00:00
}
2020-10-03 06:50:15 +00:00
2020-10-05 18:24:51 +00:00
if (generatedMusic)
2020-10-03 06:50:15 +00:00
{
activeNotes.forEachAlive(function(daNote:Note)
2020-10-04 06:42:58 +00:00
{
if ((PreferencesMenu.getPref('downscroll') && daNote.y < -daNote.height)
|| (!PreferencesMenu.getPref('downscroll') && daNote.y > FlxG.height))
2020-10-04 06:42:58 +00:00
{
2020-10-05 18:24:51 +00:00
daNote.active = false;
daNote.visible = false;
}
else
{
daNote.visible = true;
daNote.active = true;
2020-10-04 06:42:58 +00:00
}
var strumLineMid = playerStrumline.offset.y + Note.swagWidth / 2;
2021-12-07 03:35:14 +00:00
if (daNote.followsTime)
2022-01-22 21:53:38 +00:00
daNote.y = (Conductor.songPosition - daNote.data.strumTime) * (0.45 * FlxMath.roundDecimal(SongLoad.getSpeed(),
2) * daNote.noteSpeedMulti);
2021-03-30 22:10:15 +00:00
if (PreferencesMenu.getPref('downscroll'))
{
daNote.y += playerStrumline.offset.y;
2021-03-31 17:11:05 +00:00
if (daNote.isSustainNote)
{
2021-03-31 17:11:05 +00:00
if (daNote.animation.curAnim.name.endsWith("end") && daNote.prevNote != null)
daNote.y += daNote.prevNote.height;
else
2021-04-15 02:24:32 +00:00
daNote.y += daNote.height / 2;
2021-03-31 17:11:05 +00:00
if ((!daNote.mustPress || (daNote.wasGoodHit || (daNote.prevNote.wasGoodHit && !daNote.canBeHit)))
2021-03-31 19:41:45 +00:00
&& daNote.y - daNote.offset.y * daNote.scale.y + daNote.height >= strumLineMid)
2021-03-31 17:11:05 +00:00
{
applyClipRect(daNote);
2021-03-31 17:11:05 +00:00
}
}
}
2021-03-30 22:10:15 +00:00
else
{
2021-12-07 03:35:14 +00:00
if (daNote.followsTime)
daNote.y = playerStrumline.offset.y - daNote.y;
2021-03-31 04:25:41 +00:00
if (daNote.isSustainNote
&& (!daNote.mustPress || (daNote.wasGoodHit || (daNote.prevNote.wasGoodHit && !daNote.canBeHit)))
&& daNote.y + daNote.offset.y * daNote.scale.y <= strumLineMid)
{
applyClipRect(daNote);
}
2021-02-13 22:39:31 +00:00
}
2020-10-05 18:24:51 +00:00
if (!daNote.mustPress && daNote.wasGoodHit)
{
if (currentSong.song != 'Tutorial')
2020-11-02 06:46:37 +00:00
camZooming = true;
2021-01-17 09:16:02 +00:00
var altAnim:String = "";
if (SongLoad.getSong()[Math.floor(curStep / 16)] != null)
2021-01-17 09:16:02 +00:00
{
if (SongLoad.getSong()[Math.floor(curStep / 16)].altAnim)
2021-01-17 09:16:02 +00:00
altAnim = '-alt';
}
2022-01-22 21:58:59 +00:00
if (daNote.data.altNote)
2021-04-10 22:23:56 +00:00
altAnim = '-alt';
if (!daNote.isSustainNote)
2020-10-05 18:24:51 +00:00
{
currentStage.getDad().playAnim('sing' + daNote.dirNameUpper + altAnim, true);
2020-10-05 18:24:51 +00:00
}
2020-10-04 06:42:58 +00:00
currentStage.getDad().holdTimer = 0;
2020-11-11 10:00:13 +00:00
if (currentSong.needsVoices)
2020-10-30 23:47:19 +00:00
vocals.volume = 1;
2020-10-05 18:24:51 +00:00
daNote.kill();
activeNotes.remove(daNote, true);
2020-10-05 18:24:51 +00:00
daNote.destroy();
}
2020-10-05 05:13:12 +00:00
// WIP interpolation shit? Need to fix the pause issue
2021-11-30 03:12:18 +00:00
// daNote.y = (strumLine.y - (songTime - daNote.strumTime) * (0.45 * SONG.speed[SongLoad.curDiff]));
2020-10-05 10:25:14 +00:00
// removing this so whether the note misses or not is entirely up to Note class
// var noteMiss:Bool = daNote.y < -daNote.height;
2021-03-30 22:10:15 +00:00
// if (PreferencesMenu.getPref('downscroll'))
2021-06-05 04:01:15 +00:00
// noteMiss = daNote.y > FlxG.height;
2021-03-30 22:10:15 +00:00
if (daNote.isSustainNote && daNote.wasGoodHit)
{
if ((!PreferencesMenu.getPref('downscroll') && daNote.y < -daNote.height)
|| (PreferencesMenu.getPref('downscroll') && daNote.y > FlxG.height))
{
daNote.active = false;
daNote.visible = false;
daNote.kill();
activeNotes.remove(daNote, true);
daNote.destroy();
}
}
else if (daNote.tooLate || daNote.wasGoodHit)
2020-10-05 18:24:51 +00:00
{
2022-03-01 04:04:55 +00:00
// TODO: Why the hell is the noteMiss logic in two different places?
if (daNote.tooLate)
2020-10-05 22:29:59 +00:00
{
if (currentStage != null)
2022-03-01 04:04:55 +00:00
{
var event:NoteScriptEvent = new NoteScriptEvent(ScriptEvent.NOTE_MISS, daNote, true);
ScriptEventDispatcher.callEvent(currentStage, event);
ModuleHandler.callEvent(event);
2022-03-01 04:04:55 +00:00
}
2021-09-22 20:04:34 +00:00
health -= 0.0775;
2022-03-06 08:33:12 +00:00
vocals.volume = 0;
killCombo();
2020-10-05 22:29:59 +00:00
}
2020-10-05 10:25:14 +00:00
daNote.active = false;
daNote.visible = false;
2020-10-05 10:25:14 +00:00
daNote.kill();
activeNotes.remove(daNote, true);
daNote.destroy();
2020-10-05 18:24:51 +00:00
}
});
}
2020-10-05 10:25:14 +00:00
2021-02-02 07:35:35 +00:00
if (!inCutscene)
keyShit();
2022-02-26 14:06:49 +00:00
var event:UpdateScriptEvent = new UpdateScriptEvent(elapsed);
if (currentStage != null)
2022-02-26 14:06:49 +00:00
{
// We're using Eric's stage handler.
ScriptEventDispatcher.callEvent(currentStage, event);
2022-02-26 14:06:49 +00:00
}
ModuleHandler.callEvent(event);
2020-10-03 17:36:39 +00:00
}
function applyClipRect(daNote:Note):Void
{
// clipRect is applied to graphic itself so use frame Heights
var swagRect:FlxRect = new FlxRect(0, 0, daNote.frameWidth, daNote.frameHeight);
var strumLineMid = playerStrumline.offset.y + Note.swagWidth / 2;
if (PreferencesMenu.getPref('downscroll'))
{
swagRect.height = (strumLineMid - daNote.y) / daNote.scale.y;
swagRect.y = daNote.frameHeight - swagRect.height;
}
else
{
swagRect.y = (strumLineMid - daNote.y) / daNote.scale.y;
swagRect.height -= swagRect.y;
}
daNote.clipRect = swagRect;
}
function killCombo():Void
{
if (combo > 5 && currentStage.getGirlfriend().animOffsets.exists('sad'))
currentStage.getGirlfriend().playAnim('sad');
2021-04-20 18:38:07 +00:00
if (combo != 0)
{
combo = comboPopUps.displayCombo(0);
2021-04-20 18:38:07 +00:00
}
}
#if debug
function changeSection(sec:Int):Void
{
FlxG.sound.music.pause();
var daBPM:Float = currentSong.bpm;
var daPos:Float = 0;
for (i in 0...(Std.int(curStep / 16 + sec)))
{
if (SongLoad.getSong()[i].changeBPM)
{
daBPM = SongLoad.getSong()[i].bpm;
}
daPos += 4 * (1000 * 60 / daBPM);
}
Conductor.songPosition = FlxG.sound.music.time = daPos;
Conductor.songPosition += Conductor.offset;
updateCurStep();
resyncVocals();
}
#end
2020-11-01 01:11:14 +00:00
function endSong():Void
{
2021-04-09 20:37:54 +00:00
seenCutscene = false;
2021-03-04 19:30:35 +00:00
deathCounter = 0;
mayPauseGame = false;
2021-01-20 09:03:49 +00:00
FlxG.sound.music.volume = 0;
vocals.volume = 0;
if (currentSong.validScore)
2020-12-04 17:32:35 +00:00
{
Highscore.saveScore(currentSong.song, songScore, storyDifficulty);
2020-12-04 17:32:35 +00:00
}
2020-11-01 09:55:02 +00:00
2020-11-01 01:11:14 +00:00
if (isStoryMode)
{
2020-11-07 02:17:27 +00:00
campaignScore += songScore;
2020-11-01 01:11:14 +00:00
storyPlaylist.remove(storyPlaylist[0]);
if (storyPlaylist.length <= 0)
{
2021-02-08 21:34:48 +00:00
FlxG.sound.playMusic(Paths.music('freakyMenu'));
2020-11-01 19:16:22 +00:00
2021-02-12 06:20:20 +00:00
transIn = FlxTransitionableState.defaultTransIn;
transOut = FlxTransitionableState.defaultTransOut;
switch (storyWeek)
2021-04-10 06:53:23 +00:00
{
case 7:
FlxG.switchState(new VideoState());
default:
FlxG.switchState(new StoryMenuState());
}
2020-11-01 01:11:14 +00:00
2020-12-04 17:36:28 +00:00
// if ()
2020-12-11 22:22:22 +00:00
StoryMenuState.weekUnlocked[Std.int(Math.min(storyWeek + 1, StoryMenuState.weekUnlocked.length - 1))] = true;
2020-11-01 19:16:22 +00:00
if (currentSong.validScore)
2020-12-04 17:36:28 +00:00
{
NGio.unlockMedal(60961);
Highscore.saveWeekScore(storyWeek, campaignScore, storyDifficulty);
}
2020-11-01 09:55:02 +00:00
2020-11-01 19:16:22 +00:00
FlxG.save.data.weekUnlocked = StoryMenuState.weekUnlocked;
FlxG.save.flush();
2020-11-01 01:11:14 +00:00
}
else
{
var difficulty:String = "";
if (storyDifficulty == 0)
difficulty = '-easy';
if (storyDifficulty == 2)
2020-11-10 18:08:18 +00:00
difficulty = '-hard';
2020-11-01 01:11:14 +00:00
2020-11-07 21:59:25 +00:00
trace('LOADING NEXT SONG');
2021-04-10 05:49:57 +00:00
trace(storyPlaylist[0].toLowerCase() + difficulty);
2020-11-07 21:59:25 +00:00
FlxTransitionableState.skipNextTransIn = true;
FlxTransitionableState.skipNextTransOut = true;
FlxG.sound.music.stop();
vocals.stop();
if (currentSong.song.toLowerCase() == 'eggnog')
2021-01-20 09:03:49 +00:00
{
var blackShit:FlxSprite = new FlxSprite(-FlxG.width * FlxG.camera.zoom,
-FlxG.height * FlxG.camera.zoom).makeGraphic(FlxG.width * 3, FlxG.height * 3, FlxColor.BLACK);
blackShit.scrollFactor.set();
add(blackShit);
camHUD.visible = false;
inCutscene = true;
2021-01-20 09:03:49 +00:00
FlxG.sound.play(Paths.sound('Lights_Shut_off'), function()
{
// no camFollow so it centers on horror tree
currentSong = SongLoad.loadFromJson(storyPlaylist[0].toLowerCase() + difficulty, storyPlaylist[0]);
LoadingState.loadAndSwitchState(new PlayState());
});
2021-01-20 09:03:49 +00:00
}
else
{
previousCameraFollowPoint = cameraFollowPoint;
2021-01-20 09:03:49 +00:00
currentSong = SongLoad.loadFromJson(storyPlaylist[0].toLowerCase() + difficulty, storyPlaylist[0]);
LoadingState.loadAndSwitchState(new PlayState());
}
2020-11-01 01:11:14 +00:00
}
}
else
{
2020-12-27 02:46:22 +00:00
trace('WENT BACK TO FREEPLAY??');
2021-04-10 05:49:57 +00:00
// unloadAssets();
2020-11-01 01:11:14 +00:00
FlxG.switchState(new FreeplayState());
}
}
2021-04-20 18:38:07 +00:00
// gives score and pops up rating
2021-03-26 07:51:39 +00:00
private function popUpScore(strumtime:Float, daNote:Note):Void
2020-10-03 19:32:15 +00:00
{
2020-10-19 00:59:53 +00:00
var noteDiff:Float = Math.abs(strumtime - Conductor.songPosition);
// boyfriend.playAnim('hey');
2020-10-30 23:47:19 +00:00
vocals.volume = 1;
2020-10-04 06:42:58 +00:00
2020-11-01 19:16:22 +00:00
var score:Int = 350;
2020-10-19 00:59:53 +00:00
var daRating:String = "sick";
2022-02-16 21:57:08 +00:00
var isSick:Bool = false;
2021-09-22 19:09:32 +00:00
var healthMulti:Float = 1;
2022-02-16 21:57:08 +00:00
healthMulti *= daNote.lowStakes ? 0.002 : 0.033;
2021-09-22 19:09:32 +00:00
if (noteDiff > Note.HIT_WINDOW * Note.BAD_THRESHOLD)
2020-10-19 00:59:53 +00:00
{
2021-09-22 19:09:32 +00:00
healthMulti *= 0; // no health on shit note
2020-10-19 00:59:53 +00:00
daRating = 'shit';
2020-11-01 19:16:22 +00:00
score = 50;
2020-10-19 00:59:53 +00:00
}
else if (noteDiff > Note.HIT_WINDOW * Note.GOOD_THRESHOLD)
2020-10-19 00:59:53 +00:00
{
2021-09-22 19:33:30 +00:00
healthMulti *= 0.2;
2020-10-05 14:03:38 +00:00
daRating = 'bad';
2020-11-01 19:16:22 +00:00
score = 100;
2020-10-19 00:59:53 +00:00
}
else if (noteDiff > Note.HIT_WINDOW * Note.SICK_THRESHOLD)
2020-10-19 00:59:53 +00:00
{
2021-09-22 20:04:34 +00:00
healthMulti *= 0.78;
2020-10-19 00:59:53 +00:00
daRating = 'good';
2020-11-01 19:16:22 +00:00
score = 200;
2021-03-26 07:51:39 +00:00
}
2022-02-16 21:57:08 +00:00
else
isSick = true;
2021-03-26 07:51:39 +00:00
2021-09-22 19:09:32 +00:00
health += healthMulti;
2022-03-01 04:04:55 +00:00
// TODO: Redo note hit logic to make sure this always gets called
if (currentStage != null)
2022-03-01 04:04:55 +00:00
{
var event:NoteScriptEvent = new NoteScriptEvent(ScriptEvent.NOTE_HIT, daNote, true);
ScriptEventDispatcher.callEvent(currentStage, event);
ModuleHandler.callEvent(event);
2022-03-01 04:04:55 +00:00
}
2021-03-26 07:51:39 +00:00
if (isSick)
{
2021-04-10 05:49:57 +00:00
var noteSplash:NoteSplash = grpNoteSplashes.recycle(NoteSplash);
noteSplash.setupNoteSplash(daNote.x, daNote.y, daNote.data.noteData);
2021-04-10 05:49:57 +00:00
// new NoteSplash(daNote.x, daNote.y, daNote.noteData);
grpNoteSplashes.add(noteSplash);
2020-10-19 00:59:53 +00:00
}
2021-04-10 02:49:25 +00:00
// Only add the score if you're not on practice mode
if (!isPracticeMode)
2021-04-10 02:49:25 +00:00
songScore += score;
2020-11-01 19:16:22 +00:00
comboPopUps.displayRating(daRating);
2021-01-25 10:04:31 +00:00
2021-04-20 18:38:07 +00:00
if (combo >= 10 || combo == 0)
comboPopUps.displayCombo(combo);
2020-10-03 19:32:15 +00:00
}
function cameraMovement()
{
if (currentStage == null)
return;
if (cameraFollowPoint.x != currentStage.getDad().getMidpoint().x + 150 && !cameraRightSide)
{
cameraFollowPoint.setPosition(currentStage.getDad().getMidpoint().x + 150, currentStage.getDad().getMidpoint().y - 100);
// camFollow.setPosition(lucky.getMidpoint().x - 120, lucky.getMidpoint().y + 210);
switch (currentStage.getDad().curCharacter)
{
case 'mom':
cameraFollowPoint.y = currentStage.getDad().getMidpoint().y;
2021-04-15 01:56:42 +00:00
case 'senpai' | 'senpai-angry':
cameraFollowPoint.y = currentStage.getDad().getMidpoint().y - 430;
cameraFollowPoint.x = currentStage.getDad().getMidpoint().x - 100;
}
if (currentStage.getDad().curCharacter == 'mom')
vocals.volume = 1;
if (currentSong.song.toLowerCase() == 'tutorial')
tweenCamIn();
}
if (cameraRightSide && cameraFollowPoint.x != currentStage.getBoyfriend().getMidpoint().x - 100)
{
cameraFollowPoint.setPosition(currentStage.getBoyfriend().getMidpoint().x - 100, currentStage.getBoyfriend().getMidpoint().y - 100);
switch (currentStageId)
{
case 'limo':
cameraFollowPoint.x = currentStage.getBoyfriend().getMidpoint().x - 300;
case 'mall':
cameraFollowPoint.y = currentStage.getBoyfriend().getMidpoint().y - 200;
2021-04-22 02:17:00 +00:00
case 'school' | 'schoolEvil':
cameraFollowPoint.x = currentStage.getBoyfriend().getMidpoint().x - 200;
cameraFollowPoint.y = currentStage.getBoyfriend().getMidpoint().y - 200;
}
if (currentSong.song.toLowerCase() == 'tutorial')
2021-08-22 00:45:03 +00:00
FlxTween.tween(FlxG.camera, {zoom: 1 * FlxCamera.defaultZoom}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut});
}
}
2020-10-05 10:53:10 +00:00
private function keyShit():Void
2020-10-03 17:36:39 +00:00
{
// control arrays, order L D R U
var holdArray:Array<Bool> = [controls.NOTE_LEFT, controls.NOTE_DOWN, controls.NOTE_UP, controls.NOTE_RIGHT];
2021-03-30 20:58:05 +00:00
var pressArray:Array<Bool> = [
controls.NOTE_LEFT_P,
controls.NOTE_DOWN_P,
controls.NOTE_UP_P,
controls.NOTE_RIGHT_P
];
var releaseArray:Array<Bool> = [
controls.NOTE_LEFT_R,
controls.NOTE_DOWN_R,
controls.NOTE_UP_R,
controls.NOTE_RIGHT_R
];
// HOLDS, check for sustain notes
if (holdArray.contains(true) && generatedMusic)
2020-10-03 17:36:39 +00:00
{
activeNotes.forEachAlive(function(daNote:Note)
{
if (daNote.isSustainNote && daNote.canBeHit && daNote.mustPress && holdArray[daNote.data.noteData])
goodNoteHit(daNote);
});
}
// PRESSES, check for note hits
if (pressArray.contains(true) && generatedMusic)
{
2021-08-22 20:54:22 +00:00
Haptic.vibrate(100, 100);
2021-08-22 14:37:06 +00:00
currentStage.getBoyfriend().holdTimer = 0;
2020-11-11 10:00:13 +00:00
var possibleNotes:Array<Note> = []; // notes that can be hit
var directionList:Array<Int> = []; // directions that can be hit
var dumbNotes:Array<Note> = []; // notes to kill later
2021-01-18 02:23:40 +00:00
activeNotes.forEachAlive(function(daNote:Note)
2020-10-03 17:36:39 +00:00
{
if (daNote.canBeHit && daNote.mustPress && !daNote.tooLate && !daNote.wasGoodHit)
2020-10-05 03:29:35 +00:00
{
2022-01-22 21:53:38 +00:00
if (directionList.contains(daNote.data.noteData))
2021-01-18 02:23:40 +00:00
{
2021-01-18 02:36:23 +00:00
for (coolNote in possibleNotes)
2021-01-18 02:23:40 +00:00
{
2022-01-22 21:53:38 +00:00
if (coolNote.data.noteData == daNote.data.noteData
&& Math.abs(daNote.data.strumTime - coolNote.data.strumTime) < 10)
2021-03-30 20:58:05 +00:00
{ // if it's the same note twice at < 10ms distance, just delete it
// EXCEPT u cant delete it in this loop cuz it fucks with the collection lol
dumbNotes.push(daNote);
break;
}
2022-01-22 21:53:38 +00:00
else if (coolNote.data.noteData == daNote.data.noteData && daNote.data.strumTime < coolNote.data.strumTime)
2021-03-30 20:58:05 +00:00
{ // if daNote is earlier than existing note (coolNote), replace
possibleNotes.remove(coolNote);
possibleNotes.push(daNote);
break;
2021-01-18 02:36:23 +00:00
}
2021-01-18 02:23:40 +00:00
}
}
2021-01-20 02:09:47 +00:00
else
{
possibleNotes.push(daNote);
2022-01-22 21:53:38 +00:00
directionList.push(daNote.data.noteData);
2021-01-20 02:09:47 +00:00
}
2021-01-18 02:36:23 +00:00
}
});
2021-03-04 19:30:35 +00:00
for (note in dumbNotes)
2020-10-05 03:29:35 +00:00
{
2022-01-22 21:53:38 +00:00
FlxG.log.add("killing dumb ass note at " + note.data.strumTime);
note.kill();
activeNotes.remove(note, true);
note.destroy();
2020-10-05 03:29:35 +00:00
}
2020-10-04 21:44:52 +00:00
2022-01-22 21:53:38 +00:00
possibleNotes.sort((a, b) -> Std.int(a.data.strumTime - b.data.strumTime));
if (perfectMode)
goodNoteHit(possibleNotes[0]);
else if (possibleNotes.length > 0)
2020-10-05 07:49:53 +00:00
{
for (shit in 0...pressArray.length)
2021-03-30 20:58:05 +00:00
{ // if a direction is hit that shouldn't be
if (pressArray[shit] && !directionList.contains(shit))
noteMiss(shit);
}
for (coolNote in possibleNotes)
2020-10-05 07:49:53 +00:00
{
2022-01-22 21:53:38 +00:00
if (pressArray[coolNote.data.noteData])
goodNoteHit(coolNote);
2020-10-05 07:49:53 +00:00
}
}
else
{
for (shit in 0...pressArray.length)
if (pressArray[shit])
noteMiss(shit);
}
2020-10-05 07:49:53 +00:00
}
if (currentStage.getBoyfriend().holdTimer > Conductor.stepCrochet * 4 * 0.001 && !holdArray.contains(true))
2020-10-23 23:12:38 +00:00
{
if (currentStage.getBoyfriend().animation != null
&& currentStage.getBoyfriend().animation.curAnim.name.startsWith('sing')
&& !currentStage.getBoyfriend().animation.curAnim.name.endsWith('miss'))
2020-10-23 23:12:38 +00:00
{
currentStage.getBoyfriend().playAnim('idle');
2020-10-23 23:12:38 +00:00
}
}
2020-10-04 21:44:52 +00:00
playerStrums.forEach(function(spr:FlxSprite)
{
if (pressArray[spr.ID] && spr.animation.curAnim.name != 'confirm')
spr.animation.play('pressed');
if (!holdArray[spr.ID])
spr.animation.play('static');
2020-10-05 10:53:10 +00:00
if (spr.animation.curAnim.name == 'confirm' && !currentStageId.startsWith('school'))
2020-10-04 21:44:52 +00:00
{
spr.centerOffsets();
spr.offset.x -= 13;
spr.offset.y -= 13;
}
else
spr.centerOffsets();
});
2020-10-03 17:36:39 +00:00
}
2022-02-10 01:31:36 +00:00
function noteMiss(direction:NoteDir = 1):Void
2020-10-05 03:29:35 +00:00
{
// whole function used to be encased in if (!boyfriend.stunned)
2021-09-22 20:04:34 +00:00
health -= 0.07;
killCombo();
2020-10-05 14:03:38 +00:00
if (!isPracticeMode)
songScore -= 10;
2020-11-01 19:16:22 +00:00
2022-03-06 08:33:12 +00:00
vocals.volume = 0;
FlxG.sound.play(Paths.soundRandom('missnote', 1, 3), FlxG.random.float(0.1, 0.2));
2020-10-05 07:49:53 +00:00
currentStage.getBoyfriend().playAnim('sing' + direction.nameUpper + 'miss', true);
2020-10-05 03:29:35 +00:00
}
2020-10-03 17:36:39 +00:00
function goodNoteHit(note:Note):Void
{
2020-10-03 19:32:15 +00:00
if (!note.wasGoodHit)
{
2020-10-30 23:47:19 +00:00
if (!note.isSustainNote)
{
combo += 1;
2022-01-22 21:53:38 +00:00
popUpScore(note.data.strumTime, note);
2020-10-30 23:47:19 +00:00
}
currentStage.getBoyfriend().playAnim('sing' + note.dirNameUpper, true);
2020-10-04 06:42:58 +00:00
2020-10-04 18:50:12 +00:00
playerStrums.forEach(function(spr:FlxSprite)
{
2022-01-22 21:53:38 +00:00
if (Math.abs(note.data.noteData) == spr.ID)
2020-10-04 18:50:12 +00:00
{
spr.animation.play('confirm', true);
}
});
2020-10-03 19:32:15 +00:00
note.wasGoodHit = true;
2020-10-04 06:42:58 +00:00
vocals.volume = 1;
2020-10-05 22:29:59 +00:00
2021-02-13 22:39:31 +00:00
if (!note.isSustainNote)
{
note.kill();
activeNotes.remove(note, true);
2021-02-13 22:39:31 +00:00
note.destroy();
}
2020-10-03 19:32:15 +00:00
}
2020-10-03 06:50:15 +00:00
}
2020-10-10 03:22:07 +00:00
override function stepHit()
{
super.stepHit();
2021-04-18 20:54:21 +00:00
if (Math.abs(FlxG.sound.music.time - (Conductor.songPosition - Conductor.offset)) > 20
|| (currentSong.needsVoices && Math.abs(vocals.time - (Conductor.songPosition - Conductor.offset)) > 20))
2020-10-10 03:22:07 +00:00
{
2021-02-08 17:47:15 +00:00
resyncVocals();
2020-10-30 23:47:19 +00:00
}
2020-10-10 03:22:07 +00:00
if (currentStage != null)
2022-02-25 07:02:06 +00:00
{
// We're using Eric's stage handler. The stage should know that a step has been hit.
var event:SongTimeScriptEvent = new SongTimeScriptEvent(ScriptEvent.SONG_BEAT_HIT, curBeat, curStep);
ScriptEventDispatcher.callEvent(currentStage, event);
ModuleHandler.callEvent(event);
2022-02-25 07:02:06 +00:00
}
}
2020-11-02 06:46:37 +00:00
override function beatHit()
2020-10-03 06:50:15 +00:00
{
super.beatHit();
2020-10-05 09:48:30 +00:00
2020-10-24 09:19:13 +00:00
if (generatedMusic)
{
activeNotes.sort(SortUtil.byStrumtime, FlxSort.DESCENDING);
2020-10-24 09:19:13 +00:00
}
if (SongLoad.getSong()[Math.floor(curStep / 16)] != null)
2020-10-30 23:47:19 +00:00
{
if (SongLoad.getSong()[Math.floor(curStep / 16)].changeBPM)
2020-11-01 01:11:14 +00:00
{
Conductor.changeBPM(SongLoad.getSong()[Math.floor(curStep / 16)].bpm);
2020-11-01 01:11:14 +00:00
FlxG.log.add('CHANGED BPM!');
}
2020-10-30 23:47:19 +00:00
}
2020-12-23 01:55:03 +00:00
// HARDCODING FOR MILF ZOOMS!
2021-03-27 01:28:04 +00:00
if (PreferencesMenu.getPref('camera-zoom'))
2020-11-02 06:46:37 +00:00
{
if (currentSong.song.toLowerCase() == 'milf' && curBeat >= 168 && curBeat < 200 && camZooming && FlxG.camera.zoom < 1.35)
2021-03-27 01:28:04 +00:00
{
2021-08-22 00:45:03 +00:00
FlxG.camera.zoom += 0.015 * FlxCamera.defaultZoom;
2021-03-27 01:28:04 +00:00
camHUD.zoom += 0.03;
}
2021-08-22 00:45:03 +00:00
if (camZooming && FlxG.camera.zoom < (1.35 * FlxCamera.defaultZoom) && curBeat % 4 == 0)
2021-03-27 01:28:04 +00:00
{
2021-08-22 00:45:03 +00:00
FlxG.camera.zoom += 0.015 * FlxCamera.defaultZoom;
2021-03-27 01:28:04 +00:00
camHUD.zoom += 0.03;
}
2020-11-02 06:46:37 +00:00
}
2020-10-03 17:36:39 +00:00
2020-12-24 23:24:11 +00:00
iconP1.setGraphicSize(Std.int(iconP1.width + 30));
iconP2.setGraphicSize(Std.int(iconP2.width + 30));
iconP1.updateHitbox();
iconP2.updateHitbox();
2020-10-05 12:55:39 +00:00
2022-02-04 16:58:24 +00:00
var song = SongLoad.getSong();
var step = Math.floor(curStep / 16);
2021-07-15 00:32:09 +00:00
if (curBeat % 8 == 7
2022-02-04 16:58:24 +00:00
&& song[step].mustHitSection
2021-07-15 00:32:09 +00:00
&& combo > 5
&& song.length > step + 1 // GK: this fixes an error on week 1 where song[step + 1] was null
2022-02-04 16:58:24 +00:00
&& !song[step + 1].mustHitSection)
2021-07-15 00:32:09 +00:00
{
var animShit:ComboCounter = new ComboCounter(-100, 300, combo);
2021-07-15 22:22:15 +00:00
animShit.scrollFactor.set(0.6, 0.6);
var frameShit:Float = (1 / 24) * 2; // equals 2 frames in the animation
new FlxTimer().start(((Conductor.crochet / 1000) * 1.25) - frameShit, function(tmr)
{
animShit.forceFinish();
});
2021-07-15 00:32:09 +00:00
}
if (curBeat % gfSpeed == 0)
currentStage.getGirlfriend().dance();
2020-10-04 06:42:58 +00:00
if (curBeat % 2 == 0)
2021-01-20 06:38:39 +00:00
{
if (currentStage.getBoyfriend().animation != null && !currentStage.getBoyfriend().animation.curAnim.name.startsWith("sing"))
currentStage.getBoyfriend().playAnim('idle');
if (currentStage.getDad().animation != null && !currentStage.getDad().animation.curAnim.name.startsWith("sing"))
currentStage.getDad().dance();
}
else if (currentStage.getDad().curCharacter == 'spooky')
{
if (!currentStage.getDad().animation.curAnim.name.startsWith("sing"))
currentStage.getDad().dance();
2021-01-20 06:38:39 +00:00
}
2020-10-30 23:47:19 +00:00
if (curBeat % 8 == 7 && currentSong.song == 'Bopeebo')
2020-10-30 23:47:19 +00:00
{
currentStage.getBoyfriend().playAnim('hey', true);
2021-02-26 23:43:20 +00:00
}
2020-10-30 23:47:19 +00:00
if (curBeat % 16 == 15
&& currentSong.song == 'Tutorial'
&& currentStage.getDad().curCharacter == 'gf'
&& curBeat > 16
&& curBeat < 48)
2021-02-26 23:43:20 +00:00
{
currentStage.getBoyfriend().playAnim('hey', true);
currentStage.getDad().playAnim('cheer', true);
2020-10-30 23:47:19 +00:00
}
2020-11-02 06:46:37 +00:00
if (currentStage != null)
2022-02-25 07:02:06 +00:00
{
// We're using Eric's stage handler. The stage should know that a beat has been hit.
var event:SongTimeScriptEvent = new SongTimeScriptEvent(ScriptEvent.SONG_STEP_HIT, curBeat, curStep);
ScriptEventDispatcher.callEvent(currentStage, event);
ModuleHandler.callEvent(event);
2022-02-25 07:02:06 +00:00
}
2020-10-03 06:50:15 +00:00
}
2020-12-10 23:23:53 +00:00
function buildStrumlines():Void
{
var strumlineStyle:StrumlineStyle = NORMAL;
2021-08-27 22:08:01 +00:00
// TODO: Put this in the chart or something?
switch (currentStageId)
{
case 'school':
strumlineStyle = PIXEL;
case 'schoolEvil':
strumlineStyle = PIXEL;
}
2021-08-27 22:08:01 +00:00
var strumlineYPos = Strumline.getYPos();
2021-08-28 16:41:15 +00:00
playerStrumline = new Strumline(0, strumlineStyle, 4);
playerStrumline.offset = new FlxPoint(50 + FlxG.width / 2, strumlineYPos);
playerStrumline.zIndex = 100;
add(playerStrumline);
playerStrumline.cameras = [camHUD];
enemyStrumline = new Strumline(1, strumlineStyle, 4);
enemyStrumline.offset = new FlxPoint(50, strumlineYPos);
enemyStrumline.zIndex = 100;
add(enemyStrumline);
enemyStrumline.cameras = [camHUD];
this.refresh();
}
/**
* Function called before opening a new substate.
* @param subState The substate to open.
*/
override function openSubState(subState:FlxSubState)
{
// If there is a substate which requires the game to continue,
// then make this a condition.
var shouldPause = true;
if (shouldPause)
{
// Pause the music.
if (FlxG.sound.music != null)
{
FlxG.sound.music.pause();
if (vocals != null)
vocals.pause();
}
// Pause the restart timer.
if (!startTimer.finished)
startTimer.active = false;
}
super.openSubState(subState);
}
/**
* Function called before closing the current substate.
* @param subState
*/
override function closeSubState()
{
if (isGamePaused)
{
if (FlxG.sound.music != null && !startingSong)
resyncVocals();
if (!startTimer.finished)
startTimer.active = true;
#if discord_rpc
if (startTimer.finished)
DiscordClient.changePresence(detailsText, currentSong.song + " (" + storyDifficultyText + ")", iconRPC, true,
songLength - Conductor.songPosition);
else
DiscordClient.changePresence(detailsText, currentSong.song + " (" + storyDifficultyText + ")", iconRPC);
#end
}
super.closeSubState();
}
/**
* Updates the position and contents of the score display.
*/
function updateScoreText():Void
{
// TODO: Add functionality for modules to update the score text.
scoreText.text = "Score:" + songScore;
}
/**
* Updates the values of the health bar.
*/
function updateHealthBar():Void
{
healthLerp = FlxMath.lerp(healthLerp, health, 0.15);
}
/**
* Resets the camera's zoom level and focus point.
*/
function resetCamera():Void
{
FlxG.camera.follow(cameraFollowPoint, LOCKON, 0.04);
FlxG.camera.zoom = defaultCamZoom;
FlxG.camera.focusOn(cameraFollowPoint.getPosition());
}
/**
* Perform necessary cleanup before leaving the PlayState.
*/
function performCleanup()
{
// Uncache the song.
openfl.utils.Assets.cache.clear(Paths.inst(currentSong.song));
openfl.utils.Assets.cache.clear(Paths.voices(currentSong.song));
// Remove reference to stage and remove sprites from it to save memory.
if (currentStage != null)
{
remove(currentStage);
currentStage.kill();
currentStage = null;
}
// Clear the static reference to this state.
instance = null;
}
/**
* Refreshes the state, by redoing the render order of all elements.
* It does this based on the `zIndex` of each element.
*/
public function refresh()
{
sort(SortUtil.byZIndex, FlxSort.ASCENDING);
trace('Stage sorted by z-index');
}
/**
* This function is called whenever Flixel switches switching to a new FlxState.
*/
override function switchTo(nextState:FlxState):Bool
{
performCleanup();
return super.switchTo(nextState);
}
2021-08-27 22:08:01 +00:00
}