This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
forked from FunkinCrew/Funkin
-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathPlayState.hx
4483 lines (3585 loc) · 130 KB
/
PlayState.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package states;
import flixel.group.FlxSpriteGroup;
#if sys
import sys.FileSystem;
#end
#if discord_rpc
import utilities.Discord.DiscordClient;
#end
#if polymod
import polymod.backends.PolymodAssets;
#end
#if VIDEOS_ALLOWED
import hxcodec.VideoHandler;
#end
#if MODCHARTING_TOOLS
import modcharting.ModchartFuncs;
import modcharting.NoteMovement;
import modcharting.PlayfieldRenderer;
import modcharting.ModchartEditorState;
#end
import modding.HScript;
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
import utilities.Options;
import flixel.util.FlxStringUtil;
import openfl.display.BitmapData;
import flixel.graphics.FlxGraphic;
import flixel.system.FlxAssets.FlxShader;
import flixel.addons.display.FlxShaderMaskCamera;
import substates.ResultsScreenSubstate;
import haxe.Json;
import game.Replay;
import lime.utils.Assets;
import game.StrumNote;
import game.Cutscene;
import game.NoteSplash;
import flixel.graphics.frames.FlxFramesCollection;
import flixel.tweens.misc.VarTween;
import modding.ModchartUtilities;
import lime.app.Application;
import utilities.NoteVariables;
import flixel.input.FlxInput.FlxInputState;
import flixel.group.FlxGroup;
import utilities.Ratings;
import debuggers.ChartingState;
import game.Section.SwagSection;
import flixel.FlxBasic;
import flixel.FlxCamera;
import flixel.FlxG;
import flixel.FlxObject;
import flixel.FlxSprite;
import flixel.FlxSubState;
import flixel.addons.transition.FlxTransitionableState;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.math.FlxMath;
import flixel.math.FlxPoint;
import flixel.math.FlxRect;
import flixel.system.FlxSound;
import flixel.text.FlxText;
import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween;
import flixel.ui.FlxBar;
import flixel.util.FlxColor;
import flixel.util.FlxSort;
import flixel.util.FlxTimer;
import game.Note;
import ui.HealthIcon;
import ui.DialogueBox;
import game.Character;
import game.Boyfriend;
import game.StageGroup;
import game.Conductor;
import game.Song;
import utilities.CoolUtil;
import substates.PauseSubState;
import substates.GameOverSubstate;
import game.Highscore;
import openfl.utils.Assets as OpenFlAssets;
using StringTools;
/**
The main gameplay state.
**/
class PlayState extends MusicBeatState {
/**
Current instance of `PlayState`.
**/
public static var instance:PlayState = null;
/**
The current stage in `PlayState`.
**/
public static var curStage:String = '';
/**
Current song data in `PlayState`.
**/
public static var SONG:SwagSong;
/**
`Bool` for whether we are currently in Story Mode.
**/
public static var isStoryMode:Bool = false;
/**
Current Story Mode week as an `Int`.
(Generally unused / deprecated).
**/
public static var storyWeek:Int = 0;
/**
`Array` of all the songs that you are going
to play next in Story Mode as `Strings`.
**/
public static var storyPlaylist:Array<String> = [];
/**
`String` representation of the current Story Mode difficulty.
**/
public static var storyDifficultyStr:String = "NORMAL";
/**
Total score over your current run in Story Mode.
**/
public static var campaignScore:Int = 0;
/**
Vocal track for the current song as a `FlxSound`.
**/
public var vocals:FlxSound;
/**
Your current opponent.
**/
public static var dad:Character;
/**
The current character in the middle of the 3 main characters.
**/
public static var gf:Character;
/**
The current player character.
**/
public static var boyfriend:Boyfriend;
/**
The current stage.
**/
public var stage:StageGroup;
/**
`FlxTypedGroup` of all currently active notes in the game.
**/
public var notes:FlxTypedGroup<Note>;
/**
`Array` of all the notes waiting to be spawned into the game (when their time comes to prevent lag).
**/
public var unspawnNotes:Array<Note> = [];
/**
Simple `FlxSprite` to help represent the strum line the strums initially spawn at.
**/
public var strumLine:FlxSprite;
/**
`FlxTypedGroup` of all current strums (enemy strums are first).
**/
public static var strumLineNotes:FlxTypedGroup<StrumNote>;
/**
`FlxTypedGroup` of all current player strums.
**/
public static var playerStrums:FlxTypedGroup<StrumNote>;
/**
`FlxTypedGroup` of all current enemy strums.
**/
public static var enemyStrums:FlxTypedGroup<StrumNote>;
/**
Simple `FlxObject` to store the camera's current position that it's following.
**/
public var camFollow:FlxObject;
/**
Copy of `camFollow` used for transitioning between songs smoother.
**/
public static var prevCamFollow:FlxObject;
/**
`Bool` for whether or not the camera is currently zooming in and out to the song's beat.
**/
public var camZooming:Bool = false;
/**
Shortner for `SONG.song`.
**/
public var curSong:String = "";
/**
The interval of beats the current `gf` waits till their `dance` function gets called. (as an `Int`)
Example:
1 = Every Beat,
2 = Every Other Beat,
etc.
**/
public var gfSpeed:Int = 1;
/**
Current `health` of the player (stored as a range from `minHealth` to `maxHealth`, which is by default 0 to 2).
**/
public var health:Float = 1;
/**
Current `health` being shown on the `healthBar`. (Is inverted from normal when playing as opponent)
**/
public var healthShown:Float = 1;
/**
Minimum `health` value. (Defaults to 0)
**/
public var minHealth:Float = 0;
/**
Maximum `health` value. (Defaults to 2)
**/
public var maxHealth:Float = 2;
/**
Current combo (or amount of notes hit in a row without a combo break).
**/
public var combo:Int = 0;
/**
Current score for the player.
**/
public var songScore:Int = 0;
/**
Current miss count for the player.
**/
public var misses:Int = 0;
/**
Current accuracy for the player (0 - 100).
**/
public var accuracy:Float = 100.0;
/**
Background sprite for the health bar.
**/
public var healthBarBG:FlxSprite;
/**
The health bar.
**/
public var healthBar:FlxBar;
/**
Background sprites for the progress bar.
**/
public var timeBarBG:FlxSprite;
/**
The progress bar.
**/
public var timeBar:FlxBar;
/**
Variable for if `generateSong` has been called successfully yet.
**/
public var generatedMusic:Bool = false;
/**
Whether or not the player has started the song yet.
**/
public var startingSong:Bool = false;
/**
The icon for the player character (`bf`).
**/
public var iconP1:HealthIcon;
/**
The icon for the opponent character (`dad`).
**/
public var iconP2:HealthIcon;
/**
`FlxCamera` for all HUD/UI elements.
**/
public var camHUD:FlxCamera;
/**
`FlxCamera` for all elements part of the main scene.
**/
public var camGame:FlxCamera;
/**
Current text under the health bar (displays score and other stats).
**/
public var scoreTxt:FlxText;
/**
Current text near the progress / time bar.
**/
public var infoTxt:FlxText;
/**
Total notes interacted with. (Includes missing and hitting)
**/
public var totalNotes:Int = 0;
/**
Total notes hit (is a `Float` because it's used for accuracy calculations).
**/
public var hitNotes:Float = 0.0;
/**
`FlxGroup` for all the sprites that should go above the characters in a stage.
**/
public var foregroundSprites:FlxGroup = new FlxGroup();
/**
The default camera zoom (used for camera zooming properly).
**/
public var defaultCamZoom:Float = 1.05;
/**
The default hud camera zoom (used for zoom the hud properly).
**/
public var defaultHudCamZoom:Float = 1.0;
/**
Current alt animation for any characters that may be using it (should just be `dad`).
**/
public var altAnim:String = "";
/**
how big to stretch the pixel art assets
@author ninjamuffin99 probably
**/
public static var daPixelZoom:Float = 6;
/**
Whether or not you are currently in a cutscene.
**/
public var inCutscene:Bool = false;
/**
Current group of weeks you are playing from.
**/
public static var groupWeek:String = "";
// Discord RPC variables
/**
Difficulty name in RPC.
**/
public var storyDifficultyText:String = "";
/**
Small Icon to use in RPC.
**/
public var iconRPC:String = "";
/**
Details to use in RPC.
**/
public var detailsText:String = "";
/**
Paused Details to use in RPC.
**/
public var detailsPausedText:String = "";
/**
Whether or not there is currently a lua modchart active.
**/
public var executeModchart:Bool = false;
#if linc_luajit
/**
The current lua modchart.
**/
public static var luaModchart:ModchartUtilities = null;
#end
/**
Length of the current song's instrumental track in milliseconds.
**/
public var songLength:Float = 0;
/**
Your current key bindings stored as `Strings`.
**/
public var binds:Array<String>;
// wack ass ui shit i need to fucking change like oh god i hate this shit mate
public var ui_settings:Array<String>;
public var mania_size:Array<String>;
public var mania_offset:Array<String>;
public var mania_gap:Array<String>;
public var types:Array<String>;
// this sucks too, sorry i'm not documentating this bullshit that ima replace at some point with nice clean yummy jsons
// - leather128
public var arrow_Configs:Map<String, Array<String>> = new Map<String, Array<String>>();
public var type_Configs:Map<String, Array<String>> = new Map<String, Array<String>>();
/**
`Array` of cached miss sounds.
**/
public var missSounds:Array<FlxSound> = [];
/**
Current song multiplier. (Should be minimum 0.25)
**/
public static var songMultiplier:Float = 1;
/**
Variable that stores the original scroll speed before being divided by `songMultiplier`.
Usage: ChartingState
**/
public static var previousScrollSpeedLmao:Float = 0;
/**
Current `Cutscene` data.
**/
public var cutscene:Cutscene;
/**
Whether or not to play cutscenes.
**/
public static var playCutscenes:Bool = false;
/**
Current time of the song in milliseconds used for the progress bar.
**/
public var time:Float = 0.0;
/**
A `Map` of the `String` names of the ratings to the amount of times you got them.
**/
public var ratings:Map<String, Int> = ["marvelous" => 0, "sick" => 0, "good" => 0, "bad" => 0, "shit" => 0];
/**
Current text that displays your ratings (plus misses and MA/PA).
**/
public var ratingText:FlxText;
/**
Variable used by Lua Modcharts to stop the song midway.
**/
public var stopSong:Bool = false;
/**
Current `Replay` data.
**/
public var replay:Replay;
/**
List of inputs that are still waiting to be processed from the current replay.
**/
public var inputs:Array<Array<Dynamic>> = [];
/**
Whether or not the player is currently playing in a replay.
**/
public static var playingReplay:Bool = false;
/**
`Array` of current events used by the song.
**/
public var events:Array<Array<Dynamic>> = [];
/**
Original `Array` of the current song's events.
**/
public var baseEvents:Array<Array<Dynamic>> = [];
public function new(?_replay:Replay) {
super();
if (_replay != null) {
replay = _replay;
playingReplay = true;
} else
replay = new Replay();
}
/**
Current character you are playing as stored as an `Int`.
Values:
0 = bf
1 = opponent
-1 = both
**/
public static var characterPlayingAs:Int = 0;
/**
The current hitsound the player is using. (By default is 'none')
**/
public var hitSoundString:String = Options.getData("hitsound");
/**
`Map` of `Strings` to `Boyfriends` for changing `bf`'s character.
**/
public var bfMap:Map<String, Boyfriend> = [];
/**
`Map` of `Strings` to `Characters` for changing `gf`'s character.
**/
public var gfMap:Map<String, Character> = [];
/**
`Map` of `Strings` to `Characters` for changing `dad`'s character.
**/
public var dadMap:Map<String, Character> = [];
/**
`Map` of `Strings` to `StageGroups` for changing the `stage`.
**/
public var stageMap:Map<String, StageGroup> = [];
/**
Whether the game will or will not load events from the chart's `events.json` file.
(Disabled while charting as the events are already loaded)
**/
public static var loadChartEvents:Bool = true;
/**
Current time bar style selected by the player.
**/
public var funnyTimeBarStyle:String = Options.getData("timeBarStyle");
/**
Keeps track of the original player key count.
(Used when playing as opponent).
**/
public var ogPlayerKeyCount:Int = 4;
/**
Keeps track of the original opponent (or both if not specified for player) key count.
(Used when playing as opponent).
**/
public var ogKeyCount:Int = 4;
#if linc_luajit
/**
`Map` of `Strings` to Lua Modcharts used for custom events.
**/
public var event_luas:Map<String, ModchartUtilities> = [];
#end
/**
`FlxTypedGroup` of `NoteSplash`s used to contain all note splashes
and make performance better as a result by using `.recycle`.
**/
public var splash_group:FlxTypedSpriteGroup<NoteSplash> = new FlxTypedSpriteGroup<NoteSplash>();
// unused for now ;)
// public var scripts:Array<HScript> = [];
public var ratingsGroup:FlxSpriteGroup = new FlxSpriteGroup();
override public function create() {
// set instance because duh
instance = this;
// preload pause music
new FlxSound().loadEmbedded(Paths.music('breakfast'));
if (SONG == null) // this should never happen, but just in case
SONG = Song.loadFromJson('tutorial');
// gaming time
curSong = SONG.song;
#if linc_luajit
// clear dumb lua stuffs
ModchartUtilities.lua_Characters.clear();
ModchartUtilities.lua_Sounds.clear();
ModchartUtilities.lua_Sprites.clear();
#end
// if we have a hitsound, preload it nerd
if (hitSoundString != "none")
hitsound = FlxG.sound.load(Paths.sound("hitsounds/" + Std.string(hitSoundString).toLowerCase()));
// set the character we playing as
switch (Options.getData("playAs")) {
case "bf":
characterPlayingAs = 0;
case "opponent":
characterPlayingAs = 1;
case "both":
characterPlayingAs = -1;
default:
characterPlayingAs = 0;
}
// key count flipping
ogPlayerKeyCount = SONG.playerKeyCount;
ogKeyCount = SONG.keyCount;
if (characterPlayingAs == 1) {
var oldRegKeyCount = SONG.keyCount;
var oldPlrKeyCount = SONG.playerKeyCount;
SONG.keyCount = oldPlrKeyCount;
SONG.playerKeyCount = oldRegKeyCount;
}
// check for invalid settings
if (Options.getData("botplay") || Options.getData("noDeath") || characterPlayingAs != 0 || playingReplay)
SONG.validScore = false;
// make things as accurate to the og replay as we can
if (playingReplay) {
Conductor.offset = replay.offset;
Options.setData(replay.judgementTimings, "judgementTimings");
Options.setData(replay.ghostTapping, "ghostTapping");
Options.setData(replay.antiMash, "antiMash");
inputs = replay.inputs.copy();
}
// preload the miss sounds
for (i in 0...2) {
var sound = FlxG.sound.load(Paths.sound('missnote' + Std.string((i + 1))), 0.2);
missSounds.push(sound);
}
// load our binds
binds = Options.getData("binds", "binds")[SONG.playerKeyCount - 1];
// remove old insts and destroy them
if (FlxG.sound.music != null) {
FlxG.sound.music.stop();
FlxG.sound.music.destroy();
}
// setup the cameras
camGame = new FlxCamera();
camHUD = new FlxCamera();
FlxG.cameras.reset(camGame);
FlxG.cameras.add(camHUD, false); // false so it's not a default camera
camHUD.bgColor.alpha = 0;
persistentUpdate = true;
persistentDraw = true;
#if sys
// minimum of 0.25
songMultiplier = FlxMath.bound(songMultiplier, 0.25);
#else
// this shouldn't happen, but just in case
songMultiplier = 1;
#end
// this is broken btw
Conductor.timeScale = SONG.timescale;
// bpm shits
Conductor.mapBPMChanges(SONG, songMultiplier);
Conductor.changeBPM(SONG.bpm, songMultiplier);
previousScrollSpeedLmao = SONG.speed;
SONG.speed /= songMultiplier;
// just in case haxe does something weird af
if (SONG.speed < 0)
SONG.speed = 0;
speed = SONG.speed;
// custom scroll speed pog
if (Options.getData("useCustomScrollSpeed"))
speed = Options.getData("customScrollSpeed") / songMultiplier;
Conductor.recalculateStuff(songMultiplier);
Conductor.safeZoneOffset *= songMultiplier; // makes the game more fair
// not sure why this is here and not later but sure
noteBG = new FlxSprite(0, 0);
noteBG.cameras = [camHUD];
noteBG.makeGraphic(1, 1000, FlxColor.BLACK);
add(noteBG);
// set stage lol (yes im too lazy to put the stage in the jsons for base game)
if (SONG.stage == null) {
SONG.stage = 'stage';
switch (curSong.toLowerCase()) {
case 'spookeez' | 'south' | 'monster':
SONG.stage = 'spooky';
case 'pico' | 'philly nice' | 'blammed':
SONG.stage = 'philly';
case 'satin panties' | 'high' | 'm.i.l.f':
SONG.stage = 'limo';
case 'cocoa' | 'eggnog':
SONG.stage = 'mall';
case 'winter horrorland':
SONG.stage = 'evil-mall';
case 'senpai':
SONG.stage = 'school';
case 'roses':
SONG.stage = 'school-mad';
case 'thorns':
SONG.stage = 'evil-school';
}
}
// null ui skin
if (SONG.ui_Skin == null)
SONG.ui_Skin = SONG.stage == "school" || SONG.stage == "school-mad" || SONG.stage == "evil-school" ? "pixel" : "default";
// yo poggars
if (SONG.ui_Skin == "default")
SONG.ui_Skin = Options.getData("uiSkin");
// bull shit
ui_settings = CoolUtil.coolTextFile(Paths.txt("ui skins/" + SONG.ui_Skin + "/config"));
mania_size = CoolUtil.coolTextFile(Paths.txt("ui skins/" + SONG.ui_Skin + "/maniasize"));
mania_offset = CoolUtil.coolTextFile(Paths.txt("ui skins/" + SONG.ui_Skin + "/maniaoffset"));
// if the file exists, use it dammit
if (Assets.exists(Paths.txt("ui skins/" + SONG.ui_Skin + "/maniagap")))
mania_gap = CoolUtil.coolTextFile(Paths.txt("ui skins/" + SONG.ui_Skin + "/maniagap"));
else
mania_gap = CoolUtil.coolTextFile(Paths.txt("ui skins/default/maniagap"));
types = CoolUtil.coolTextFile(Paths.txt("ui skins/" + SONG.ui_Skin + "/types"));
arrow_Configs.set("default", CoolUtil.coolTextFile(Paths.txt("ui skins/" + SONG.ui_Skin + "/default")));
type_Configs.set("default", CoolUtil.coolTextFile(Paths.txt("arrow types/default")));
// preload ratings
uiMap.set("marvelous", FlxGraphic.fromAssetKey(Paths.image("ui skins/" + SONG.ui_Skin + "/ratings/" + "marvelous")));
uiMap.set("sick", FlxGraphic.fromAssetKey(Paths.image("ui skins/" + SONG.ui_Skin + "/ratings/" + "sick")));
uiMap.set("good", FlxGraphic.fromAssetKey(Paths.image("ui skins/" + SONG.ui_Skin + "/ratings/" + "good")));
uiMap.set("bad", FlxGraphic.fromAssetKey(Paths.image("ui skins/" + SONG.ui_Skin + "/ratings/" + "bad")));
uiMap.set("shit", FlxGraphic.fromAssetKey(Paths.image("ui skins/" + SONG.ui_Skin + "/ratings/" + "shit")));
// preload numbers
for (i in 0...10)
uiMap.set(Std.string(i), FlxGraphic.fromAssetKey(Paths.image("ui skins/" + SONG.ui_Skin + "/numbers/num" + Std.string(i))));
curStage = SONG.stage;
// set gf lol
if (SONG.gf == null) {
switch (curStage) {
case 'limo':
SONG.gf = 'gf-car';
case 'mall' | 'evil-mall':
SONG.gf = 'gf-christmas';
case 'school' | 'school-mad' | 'evil-school':
SONG.gf = 'gf-pixel';
default:
SONG.gf = 'gf';
}
}
/* character time :) */
// create the characters nerd
if (!Options.getData("charsAndBGs")) {
gf = new Character(400, 130, "");
gf.scrollFactor.set(0.95, 0.95);
dad = new Character(100, 100, "");
boyfriend = new Boyfriend(770, 450, "");
} else {
gf = new Character(400, 130, SONG.gf);
gf.scrollFactor.set(0.95, 0.95);
dad = new Character(100, 100, SONG.player2);
boyfriend = new Boyfriend(770, 450, SONG.player1);
bfMap.set(SONG.player1, boyfriend);
dadMap.set(SONG.player2, dad);
gfMap.set(SONG.gf, gf);
}
/* end of character time */
#if discord_rpc
// weird ass rpc stuff from muffin man
storyDifficultyText = storyDifficultyStr;
iconRPC = dad.icon;
// String that contains the mode defined here so it isn't necessary to call changePresence for each mode
if (isStoryMode)
detailsText = "Story Mode";
else
detailsText = "Freeplay";
// String for when the game is paused
detailsPausedText = "Paused - " + detailsText;
// Updating Discord Rich Presence.
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC);
#end
// stage maker
stage = new StageGroup(Options.getData("charsAndBGs") ? curStage : "");
stageMap.set(stage.stage, stage);
add(stage);
defaultCamZoom = stage.camZoom;
var camPos:FlxPoint = new FlxPoint(dad.getGraphicMidpoint().x, dad.getGraphicMidpoint().y);
if (dad.curCharacter.startsWith("gf")) {
dad.setPosition(gf.x, gf.y);
gf.visible = false;
if (isStoryMode) {
camPos.x += 600;
tweenCamIn();
}
}
// REPOSITIONING PER STAGE
if (Options.getData("charsAndBGs"))
stage.setCharOffsets();
if (gf.otherCharacters == null) {
if (gf.coolTrail != null)
add(gf.coolTrail);
add(gf);
} else {
for (character in gf.otherCharacters) {
if (character.coolTrail != null)
add(character.coolTrail);
add(character);
}
}
if (!dad.curCharacter.startsWith("gf"))
add(stage.infrontOfGFSprites);
if (dad.otherCharacters == null) {
if (dad.coolTrail != null)
add(dad.coolTrail);
add(dad);
} else {
for (character in dad.otherCharacters) {
if (character.coolTrail != null)
add(character.coolTrail);
add(character);
}
}
if (dad.curCharacter.startsWith("gf"))
add(stage.infrontOfGFSprites);
/* we do a little trolling */
var midPos = dad.getMidpoint();
camPos.set(midPos.x + 150 + dad.cameraOffset[0], midPos.y - 100 + dad.cameraOffset[1]);
switch (dad.curCharacter) {
case 'mom':
camPos.y = midPos.y;
case 'senpai':
camPos.y = midPos.y - 430;
camPos.x = midPos.x - 100;
case 'senpai-angry':
camPos.y = midPos.y - 430;
camPos.x = midPos.x - 100;
}
if (boyfriend.otherCharacters == null) {
if (boyfriend.coolTrail != null)
add(boyfriend.coolTrail);
add(boyfriend);
} else {
for (character in boyfriend.otherCharacters) {
if (character.coolTrail != null)
add(character.coolTrail);
add(character);
}
}
add(stage.foregroundSprites);
Conductor.songPosition = -5000;
strumLine = new FlxSprite(0, 100).makeGraphic(FlxG.width, 10);
if (Options.getData("downscroll"))
strumLine.y = FlxG.height - 100;
strumLine.scrollFactor.set();
strumLineNotes = new FlxTypedGroup<StrumNote>();
playerStrums = new FlxTypedGroup<StrumNote>();
enemyStrums = new FlxTypedGroup<StrumNote>();
generateSong(SONG.song);
generateEvents();
camFollow = new FlxObject(0, 0, 1, 1);
camFollow.setPosition(camPos.x, camPos.y);
if (prevCamFollow != null) {
camFollow = prevCamFollow;
prevCamFollow = null;
}
if (Options.getData("charsAndBGs")) {
FlxG.camera.follow(camFollow, LOCKON, 0.04);
FlxG.camera.zoom = defaultCamZoom;
FlxG.camera.focusOn(camFollow.getPosition());
}
FlxG.fixedTimestep = false;
var healthBarPosY = FlxG.height * 0.9;
if (Options.getData("downscroll"))
healthBarPosY = 60;
#if linc_luajit
executeModchart = !(PlayState.SONG.modchartPath == '' || PlayState.SONG.modchartPath == null);
if (executeModchart) {
if (Assets.exists(Paths.lua("modcharts/" + PlayState.SONG.modchartPath))) {
luaModchart = new ModchartUtilities();
executeALuaState("create", [PlayState.SONG.song.toLowerCase()], MODCHART);
} else if (Assets.exists(Paths.lua("scripts/" + PlayState.SONG.modchartPath))) {
luaModchart = new ModchartUtilities(PolymodAssets.getPath(Paths.lua("scripts/" + PlayState.SONG.modchartPath)));
executeALuaState("create", [PlayState.SONG.song.toLowerCase()], MODCHART);
}
}
if (luaModchart == null && generatedSomeDumbEventLuas)
executeALuaState("create", [PlayState.SONG.song.toLowerCase()], MODCHART);
stage.createLuaStuff();
executeALuaState("create", [stage.stage], STAGE);
#end
ratingsGroup.cameras = [camHUD];
add(ratingsGroup);
add(strumLineNotes);
var cache_splash = new NoteSplash();
cache_splash.kill();
splash_group.add(cache_splash);
#if (MODCHARTING_TOOLS && linc_luajit)
if (executeModchart || generatedSomeDumbEventLuas || stage.stageScript != null) {
playfieldRenderer = new PlayfieldRenderer(strumLineNotes, notes, this);
playfieldRenderer.cameras = [camHUD];
add(playfieldRenderer);
}
#end
add(splash_group);
splash_group.cameras = [camHUD];
add(camFollow);
add(notes);
// health bar
healthBarBG = new FlxSprite(0, healthBarPosY).loadGraphic(Paths.image('ui skins/' + SONG.ui_Skin + '/other/healthBar'));
healthBarBG.screenCenter(X);
healthBarBG.scrollFactor.set();
healthBarBG.pixelPerfectPosition = true;
add(healthBarBG);