forked from fofix/fofix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Instrument.py
2384 lines (1941 loc) · 91.3 KB
/
Instrument.py
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
#####################################################################
# -*- coding: iso-8859-1 -*- #
# #
# Frets on Fire #
# Copyright (C) 2009 Blazingamer #
# #
# This program is free software; you can redistribute it and/or #
# modify it under the terms of the GNU General Public License #
# as published by the Free Software Foundation; either version 2 #
# of the License, or (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, #
# MA 02110-1301, USA. #
#####################################################################
from Song import Note, Tempo
from Mesh import Mesh
from Shader import shaders
from OpenGL.GL import *
import Song
import Log
import math
import os #myfingershurt: needed for multi-OS file fetching
import cmgl
import numpy as np
class Instrument(object):
def __init__(self, engine, playerObj, player = 0):
self.engine = engine
self.starPowerDecreaseDivisor = 200.0/self.engine.audioSpeedFactor
self.bigRockEndingMarkerSeen = False
self.isStarPhrase = False
self.finalStarSeen = False
self.selectedString = 0
self.time = 0.0
self.pickStartPos = 0
self.leftyMode = False
self.drumFlip = False
self.freestyleActive = False
self.drumFillsActive = False
self.incomingNeckMode = self.engine.config.get("game", "incoming_neck_mode")
self.guitarSoloNeckMode = self.engine.config.get("game", "guitar_solo_neck")
self.bigRockEndings = self.engine.config.get("game", "big_rock_endings")
#For Animated notes
self.noteSpinFrames = 16
self.Animspeed = 30 #Lower value = Faster animations
self.indexCount = 0
self.noteSpinFrameIndex = 0
# Volshebnyi - BRE scoring variables
self.freestyleEnabled = False
self.freestyleStart = 0
self.freestyleFirstHit = 0
self.freestyleLength = 0
self.freestyleLastHit = 0
self.freestyleBonusFret = -2
self.freestyleLastFretHitTime = range(5)
self.freestyleBaseScore = 750
self.freestylePeriod = 1000
self.freestylePercent = 50
self.freestyleReady = False
self.freestyleOffset = 5
self.freestyleSP = False
#empty variables for class compatibility
self.totalPhrases = 0
self.accThresholdWorstLate = 0
self.accThresholdVeryLate = 0
self.accThresholdLate = 0
self.accThresholdSlightlyLate = 0
self.accThresholdExcellentLate = 0
self.accThresholdPerfect = 0
self.accThresholdExcellentEarly = 0
self.accThresholdSlightlyEarly = 0
self.accThresholdEarly = 0
self.accThresholdVeryEarly = 0
self.tempoBpm = 120 #MFH - default is NEEDED here...
self.beatsPerBoard = 5.0
self.boardWidth = self.engine.theme.neckWidth
self.boardLength = self.engine.theme.neckLength
self.beatsPerUnit = self.beatsPerBoard / self.boardLength
self.fretColors = self.engine.theme.noteColors
self.spColor = self.engine.theme.spNoteColor
self.killColor = self.engine.theme.killNoteColor
self.useFretColors = self.engine.theme.use_fret_colors
self.playedNotes = []
self.missedNotes = []
self.useMidiSoloMarkers = False
self.canGuitarSolo = False
self.guitarSolo = False
self.sameNoteHopoString = False
self.hopoProblemNoteNum = -1
self.currentGuitarSoloHitNotes = 0
self.cappedScoreMult = 0
self.battleSuddenDeath = False
self.battleObjectsEnabled = []
self.battleSDObjectsEnabled = []
if self.engine.config.get("game", "battle_Whammy") == 1:
self.battleObjectsEnabled.append(4)
if self.engine.config.get("game", "battle_Diff_Up") == 1:
self.battleObjectsEnabled.append(2)
if self.engine.config.get("game", "battle_String_Break") == 1:
self.battleObjectsEnabled.append(3)
if self.engine.config.get("game", "battle_Double") == 1:
self.battleObjectsEnabled.append(7)
if self.engine.config.get("game", "battle_Death_Drain") == 1:
self.battleObjectsEnabled.append(1)
if self.engine.config.get("game", "battle_Amp_Overload") == 1:
self.battleObjectsEnabled.append(8)
if self.engine.config.get("game", "battle_Switch_Controls") == 1:
self.battleObjectsEnabled.append(6)
if self.engine.config.get("game", "battle_Steal") == 1:
self.battleObjectsEnabled.append(5)
Log.debug("Battle Objects Enabled: "+str(self.battleObjectsEnabled))
self.battleNextObject = 0
self.battleObjects = [0] * 3
self.battleBeingUsed = [0] * 2
self.battleStatus = [False] * 9
self.battleStartTimes = [0] * 9
self.battleGetTime = 0
self.battleTarget = 0
self.battleLeftyLength = 8000#
self.battleDiffUpLength = 15000
self.battleDiffUpValue = playerObj.getDifficultyInt()
self.battleDoubleLength = 8000
self.battleAmpLength = 8000
self.battleWhammyLimit = 6#
self.battleWhammyNow = 0
self.battleWhammyDown = False
self.battleBreakLimit = 8.0
self.battleBreakNow = 0.0
self.battleBreakString = 0
self.battleObjectGained = 0
self.battleSuddenDeath = False
self.battleDrainStart = 0
self.battleDrainLength = 8000
self.currentBpm = 120.0 #MFH - need a default 120BPM to be set in case a custom song has no tempo events.
self.currentPeriod = 60000.0 / self.currentBpm
self.targetBpm = self.currentBpm
self.targetPeriod = 60000.0 / self.targetBpm
self.lastBpmChange = -1.0
self.baseBeat = 0.0
self.indexFps = self.engine.config.get("video", "fps")
self.Animspeed = 30#Lower value = Faster animations
#For Animated Starnotes
self.indexCount = 0
#myfingershurt: to keep track of pause status here as well
self.paused = False
self.spEnabled = True
self.starPower = 0
self.starPowerGained = False
self.starpowerMode = self.engine.config.get("game", "starpower_mode") #MFH
self.killPoints = False
#get difficulty
self.difficulty = playerObj.getDifficultyInt()
self.controlType = playerObj.controlType
self.scoreMultiplier = 1
#MFH - I do not understand fully how the handicap scorecard works at the moment, nor do I have the time to figure it out.
#... so for now, I'm just writing some extra code here for the early hitwindow size handicap.
self.earlyHitWindowSizeFactor = 0.5
self.hitw = self.engine.config.get("game", "note_hit_window") #this should be global, not retrieved every BPM change.
if self.hitw == 0:
self.hitw = 2.3
elif self.hitw == 1:
self.hitw = 1.9
elif self.hitw == 2:
self.hitw = 1.2
elif self.hitw == 3:
self.hitw = 1.0
elif self.hitw == 4:
self.hitw = 0.70
else:
self.hitw = 1.2
#myfingershurt: need a separate variable to track whether or not hopos are actually active
self.wasLastNoteHopod = False
self.hopoLast = -1
self.hopoColor = (0, .5, .5)
self.player = player
self.hit = [False, False, False, False, False]
self.freestyleHit = [False, False, False, False, False]
#myfingershurt: this should be retrieved once at init, not repeatedly in-game whenever tails are rendered.
self.notedisappear = self.engine.config.get("game", "notedisappear")
self.fretsUnderNotes = self.engine.config.get("game", "frets_under_notes")
self.staticStrings = self.engine.config.get("performance", "static_strings")
self.muteSustainReleases = self.engine.config.get("game", "sustain_muting") #MFH
self.twoChord = 0
self.twoChordApply = False
self.hopoActive = 0
self.LastStrumWasChord = False
self.vbpmLogicType = self.engine.config.get("debug", "use_new_vbpm_beta")
#Get theme
themename = self.engine.data.themeLabel
#now theme determination logic is only in data.py:
self.theme = self.engine.data.theme
self.spRefillMode = self.engine.config.get("game","sp_notes_while_active")
self.hitglow_color = self.engine.config.get("video", "hitglow_color") #this should be global, not retrieved every fret render.
#check if BRE enabled
if self.bigRockEndings == 2 or (self.theme == 2 and self.bigRockEndings == 1):
self.freestyleEnabled = True
#blazingamer
self.nstype = self.engine.config.get("game", "nstype")
self.twoDnote = self.engine.theme.twoDnote
self.twoDkeys = self.engine.theme.twoDkeys
self.threeDspin = self.engine.theme.threeDspin
self.noterotate = self.engine.config.get("coffee", "noterotate")
#MFH- fixing neck speed
if self.nstype < 3: #not constant mode:
self.speed = self.engine.config.get("coffee", "neckSpeed")*0.01
else: #constant mode
self.speed = 410 - self.engine.config.get("coffee", "neckSpeed") #invert this value
self.boardScaleX = self.boardWidth/3.0
self.boardScaleY = self.boardLength/9.0
self.fretPress = self.engine.theme.fret_press
#akedrou
self.coOpFailed = False
self.coOpRestart = False
self.coOpRescueTime = 0.0
self.setBPM(self.currentBpm)
if self.starpowerMode == 1:
self.starNotesSet = False
else:
self.starNotesSet = True
self.maxStars = []
self.starNotes = []
self.totalNotes = 0
self.keys = []
self.actions = []
self.soloKey = []
self.disableVBPM = self.engine.config.get("game", "disable_vbpm")
self.disableNoteSFX = self.engine.config.get("video", "disable_notesfx")
self.disableFretSFX = self.engine.config.get("video", "disable_fretsfx")
self.disableFlameSFX = self.engine.config.get("video", "disable_flamesfx")
self.meshColor = self.engine.theme.meshColor
self.hopoColor = self.engine.theme.hopoColor
self.spotColor = self.engine.theme.spotColor
self.keyColor = self.engine.theme.keyColor
self.key2Color = self.engine.theme.key2Color
fC = [(.84, 1, .51), (1, .53, .5), (.98, .96, .42), (.64, .97, 1), (1, .87, .55)]
if not self.engine.theme.glowColor == "frets":
gC = self.engine.theme.glowColor
fC = [gC, gC, gC, gC, gC]
self.flameColors = [fC,fC,fC,fC]
self.gh3flameColor = (.75,.36,.02)
fS = [.075]*5
self.flameSizes = [fS,fS,fS,fS]
self.glowColor = self.engine.theme.glowColor
self.twoChordMax = False
self.canGuitarSolo = False
self.guitarSolo = False
self.fretboardHop = 0.00 #stump
self.scoreMultiplier = 1
self.coOpFailed = False #akedrou
self.coOpRestart = False #akedrou
self.starPowerActive = False
#this checks to see if there is a "drum" or "bass" folder
#inside the subdirectory for image replacement
def checkPath(self, subdirectory, file, lastResort = False):
# parameters
# @subdirectory the folder in the theme to search
# if the instrument is drum or bass it will extend this
# @file the file to search for
# @lastResort if the file isn't even found in the default path then
# resort to using the file in the data folder
#Get theme
themename = self.engine.data.themeLabel
defaultpath = os.path.join("themes", themename, subdirectory)
themepath = os.path.join("themes", themename, subdirectory)
if self.isDrum:
themepath = os.path.join(themepath, "drum")
elif self.isBassGuitar:
themepath = os.path.join(themepath, "bass")
if self.engine.fileExists(os.path.join(themepath, file)):
return os.path.join(themepath, file)
else:
if lastResort and not self.engine.fileExists(os.path.join(defaultpath, file)):
return file
Log.debug("Image not found: " + themepath + "/" + file)
return os.path.join(defaultpath, file)
def loadFlames(self):
engine = self.engine
themename = self.engine.data.themeLabel
self.HCount = 0
self.HCount2 = 0
self.HFrameLimit = self.engine.theme.HoldFlameFrameLimit
self.HFrameLimit2 = self.engine.theme.HitFlameFrameLimit
self.Hitanim = True
self.Hitanim2 = True
self.HCountAni = False
if self.disableFretSFX != False:
self.glowDrawing = None
else:
engine.loadImgDrawing(self, "glowDrawing", os.path.join("themes",themename,"glow.png"), textureSize = (128, 128))
if not self.glowDrawing:
engine.loadImgDrawing(self, "glowDrawing", "glow.png")
self.hitFlamesPresent = False
if self.disableFlameSFX == True:
self.hitFlamesPresent = True
self.hitglow2Drawing = None
self.hitglowDrawing = None
self.hitglowAnim = None
self.hitflamesAnim = None
self.hitflames2Drawing = None
self.hitflames1Drawing = None
else:
if engine.loadImgDrawing(self, "hitflames1Drawing", os.path.join("themes",themename,"hitflames1.png"), textureSize = (128, 128)):
if engine.loadImgDrawing(self, "hitflames2Drawing", os.path.join("themes",themename,"hitflames2.png"), textureSize = (128, 128)):
self.hitFlamesPresent = True
else:
self.hitflames2Drawing = None
else:
self.hitflames1Drawing = None
self.hitflames2Drawing = None
if not engine.loadImgDrawing(self, "hitflamesAnim", os.path.join("themes",themename,"hitflamesanimation.png"), textureSize = (128, 128)):
self.Hitanim2 = False
if not engine.loadImgDrawing(self, "hitglowAnim", os.path.join("themes",themename,"hitglowanimation.png"), textureSize = (128, 128)):
if engine.loadImgDrawing(self, "hitglowDrawing", os.path.join("themes",themename,"hitglow.png"), textureSize = (128, 128)):
if not engine.loadImgDrawing(self, "hitglow2Drawing", os.path.join("themes",themename,"hitglow2.png"), textureSize = (128, 128)):
self.hitglow2Drawing = None
self.hitFlamesPresent = False
else:
self.hitglowDrawing = None
self.hitFlamesPresent = False
self.Hitanim = False
engine.loadImgDrawing(self, "hitlightning", os.path.join("themes",themename,"lightning.png"), textureSize = (128, 128))
def loadNotes(self):
engine = self.engine
get = lambda file: self.checkPath("notes", file)
self.noteSpin = self.engine.config.get("performance", "animated_notes")
self.spActTex = None
self.noteTex = None
self.noteButtons = None
if self.twoDnote == True:
if self.noteSpin:
self.starSpinFrames = 16
engine.loadImgDrawing(self, "noteAnimatedNormal", get("animated_normal.png"))
engine.loadImgDrawing(self, "noteAnimatedHOPO", get("animated_hopo.png"))
engine.loadImgDrawing(self, "noteAnimatedPower", get("animated_power.png"))
engine.loadImgDrawing(self, "noteAnimatedPowerHOPO", get("animated_power_hopo.png"))
engine.loadImgDrawing(self, "noteAnimatedPowerActive", get("animated_power_active.png"))
engine.loadImgDrawing(self, "noteAnimatedPowerActiveHOPO", get("animated_power_active_hopo.png"))
if self.gameMode2p == 6: #battle multiplayer
if engine.loadImgDrawing(self, "noteButtons", get("spinnotesbattle.png")):
self.starSpinFrames = 8
if not self.isDrum and self.gameMode2p == 6: #battle multiplayer
if not self.engine.loadImgDrawing(self, "noteButtons", get("notesbattle.png")):
engine.loadImgDrawing(self, "noteButtons", get("notes.png"))
else:
engine.loadImgDrawing(self, "noteButtons", get("notes.png"))
else:
defaultNote = False
#MFH - can't use IOError for fallback logic for a Mesh() call...
if self.engine.fileExists(get("note.dae")): #look in the notes folder for files
self.engine.resource.load(self, "noteMesh", lambda: Mesh(engine.resource.fileName(get("note.dae"))))
else: #default to files in data folder
self.engine.resource.load(self, "noteMesh", lambda: Mesh(engine.resource.fileName("note.dae")))
defaultNote = True
if self.engine.fileExists(get("star.dae")): #look in the notes folder for files
self.engine.resource.load(self, "starMesh", lambda: Mesh(self.engine.resource.fileName(get("star.dae"))))
else: #No mesh for star notes
self.starMesh = None
if defaultNote:
self.notetex = False
else:
self.notetex = True
self.startex = True
self.staratex = True
for i in range(5):
if not engine.loadImgDrawing(self, "notetex"+chr(97+i), get("notetex_"+chr(97+i)+".png")):
self.notetex = False
break
for i in range(5):
if not self.engine.loadImgDrawing(self, "startex"+chr(97+i), get("startex_"+chr(97+i)+".png")):
self.startex = False
break
for i in range(5):
if not self.engine.loadImgDrawing(self, "staratex"+chr(97+i), get("staratex_"+chr(97+i)+".png")):
self.staratex = False
break
def loadFrets(self):
engine = self.engine
themename = self.engine.data.themeLabel
get = lambda file: self.checkPath("frets", file)
if self.twoDkeys == True: #death_au
if self.gameMode2p == 6:
engine.loadImgDrawing(self, "battleFrets", get("battle_frets.png"))
engine.loadImgDrawing(self, "fretButtons", get("fretbuttons.png"))
else:
defaultKey = False
#MFH - can't use IOError for fallback logic for a Mesh() call...
if self.engine.fileExists(get("key.dae")): #look in the frets folder for files
engine.resource.load(self, "keyMesh", lambda: Mesh(engine.resource.fileName(get("key.dae"))))
else: #default to files in data folder
engine.resource.load(self, "keyMesh", lambda: Mesh(engine.resource.fileName("key.dae")))
defaultKey = True
if defaultKey:
self.keytex = False
else:
self.keytex = True
for i in range(5):
if not engine.loadImgDrawing(self, "keytex"+chr(97+i), get("keytex_"+chr(97+i)+".png")):
self.keytex = False
break
def loadTails(self):
engine = self.engine
get = lambda file: self.checkPath("tails", file)
getD = lambda file: self.checkPath("tails", file, True) #resorts to checking data
#MFH - freestyle tails (for drum fills & BREs)
engine.loadImgDrawing(self, "freestyle1", getD("freestyletail1.png"), textureSize = (128, 128))
engine.loadImgDrawing(self, "freestyle2", getD("freestyletail2.png"), textureSize = (128, 128))
if self.tailsEnabled == True:
self.simpleTails = False
for i in range(0,7):
if not engine.loadImgDrawing(self, "tail"+str(i), get("tail"+str(i)+".png"), textureSize = (128, 128)):
self.simpleTails = True
break
if not engine.loadImgDrawing(self, "taile"+str(i), get("taile"+str(i)+".png"), textureSize = (128, 128)):
self.simpleTails = True
break
if not engine.loadImgDrawing(self, "btail"+str(i), get("btail"+str(i)+".png"), textureSize = (128, 128)):
self.simpleTails = True
break
if not engine.loadImgDrawing(self, "btaile"+str(i), get("btaile"+str(i)+".png"), textureSize = (128, 128)):
self.simpleTails = True
break
if self.simpleTails:
Log.debug("Simple tails used; complex tail loading error...")
engine.loadImgDrawing(self, "tail1", getD("tail1.png"), textureSize = (128, 128))
engine.loadImgDrawing(self, "tail2", getD("tail2.png"), textureSize = (128, 128))
engine.loadImgDrawing(self, "bigTail1", getD("bigtail1.png"), textureSize = (128, 128))
engine.loadImgDrawing(self, "bigTail2", getD("bigtail2.png"), textureSize = (128, 128))
engine.loadImgDrawing(self, "kill1", getD("kill1.png"), textureSize = (128, 128))
engine.loadImgDrawing(self, "kill2", getD("kill2.png"), textureSize = (128, 128))
else:
self.tail1 = None
self.tail2 = None
self.bigTail1 = None
self.bigTail2 = None
self.kill1 = None
self.kill2 = None
def loadImages(self):
self.loadFrets()
self.loadNotes()
self.loadTails()
self.loadFlames()
def selectPreviousString(self):
self.selectedString = (self.selectedString - 1) % self.strings
def selectString(self, string):
self.selectedString = string % self.strings
def selectNextString(self):
self.selectedString = (self.selectedString + 1) % self.strings
def setMultiplier(self, multiplier):
self.scoreMultiplier = multiplier
self.neck.scoreMultiplier = multiplier
def hitNote(self, time, note):
self.pickStartPos = max(self.pickStartPos, time)
self.playedNotes = [(time, note)]
note.played = True
return True
def endPick(self, pos):
if not self.isDrum:
for time, note in self.playedNotes:
if time + note.length > pos + self.noteReleaseMargin:
self.playedNotes = []
return False
self.playedNotes = []
return True
def setBPM(self, bpm):
if bpm > 200:
bpm = 200
#MFH - Filter out unnecessary BPM settings (when currentBPM is already set!)
self.currentBpm = bpm #update current BPM as well
#MFH - Neck speed determination:
if self.nstype == 0: #BPM mode
self.neckSpeed = (340 - bpm)/self.speed
elif self.nstype == 1: #Difficulty mode
if self.difficulty == 0: #expert
self.neckSpeed = 220/self.speed
elif self.difficulty == 1:
self.neckSpeed = 250/self.speed
elif self.difficulty == 2:
self.neckSpeed = 280/self.speed
else: #easy
self.neckSpeed = 300/self.speed
elif self.nstype == 2: #BPM & Diff mode
if self.difficulty == 0: #expert
self.neckSpeed = (226-(bpm/10))/self.speed
elif self.difficulty == 1:
self.neckSpeed = (256-(bpm/10))/self.speed
elif self.difficulty == 2:
self.neckSpeed = (286-(bpm/10))/self.speed
else: #easy
self.neckSpeed = (306-(bpm/10))/self.speed
else: #Percentage mode - pre-calculated
self.neckSpeed = self.speed
self.earlyMargin = 250 - bpm/5 - 70*self.hitw
self.lateMargin = 250 - bpm/5 - 70*self.hitw
if self.muteSustainReleases == 4: #tight
self.noteReleaseMargin = (200 - bpm/5 - 70*1.2)
elif self.muteSustainReleases == 3: #standard
self.noteReleaseMargin = (200 - bpm/5 - 70*1.0)
elif self.muteSustainReleases == 2: #wide
self.noteReleaseMargin = (200 - bpm/5 - 70*0.7)
else: #ultra-wide
self.noteReleaseMargin = (200 - bpm/5 - 70*0.5)
#MFH - TODO - only calculate the below values if the realtime hit accuracy feedback display is enabled - otherwise this is a waste!
self.accThresholdWorstLate = (0-self.lateMargin)
self.accThresholdVeryLate = (0-(3*self.lateMargin/4))
self.accThresholdLate = (0-(2*self.lateMargin/4))
self.accThresholdSlightlyLate = (0-(1*self.lateMargin/4))
self.accThresholdExcellentLate = -1.0
self.accThresholdPerfect = 1.0
self.accThresholdExcellentEarly = (1*self.lateMargin/4)
self.accThresholdSlightlyEarly = (2*self.lateMargin/4)
self.accThresholdEarly = (3*self.lateMargin/4)
self.accThresholdVeryEarly = (4*self.lateMargin/4)
#MFH - corrected and optimized:
def getRequiredNotesMFH(self, song, pos, hopoTroubleCheck = False):
if self.battleStatus[2] and self.difficulty != 0:
if pos < self.battleStartTimes[2] + self.currentPeriod * self.beatsPerBoard or pos > self.battleStartTimes[2] - self.currentPeriod * self.beatsPerBoard + self.battleDiffUpLength:
song.difficulty[self.player] = Song.difficulties[self.battleDiffUpValue]
else:
song.difficulty[self.player] = Song.difficulties[self.battleDiffUpValue - 1]
track = song.track[self.player]
if hopoTroubleCheck:
notes = [(time, event) for time, event in track.getEvents(pos, pos + (self.earlyMargin*2)) if isinstance(event, Note)]
notes = [(time, event) for time, event in notes if not time==pos] #MFH - filter out the problem note that caused this check!
else:
notes = [(time, event) for time, event in track.getEvents(pos - self.lateMargin, pos + self.earlyMargin) if isinstance(event, Note)]
notes = [(time, event) for time, event in notes if not (event.hopod or event.played or event.skipped)]
notes = [(time, event) for time, event in notes if (time >= (pos - self.lateMargin)) and (time <= (pos + self.earlyMargin))]
sorted(notes, key=lambda x: x[0])
if self.battleStatus[7]:
notes = self.getDoubleNotes(notes)
return sorted(notes, key=lambda x: x[0]) #MFH - what the hell, this should be sorted by TIME not note number....
#MFH - corrected and optimized:
def getRequiredNotesForJurgenOnTime(self, song, pos):
track = song.track[self.player]
notes = [(time, event) for time, event in track.getEvents(pos - self.lateMargin, pos + 30) if isinstance(event, Note)]
notes = [(time, event) for time, event in notes if not (event.hopod or event.played or event.skipped)]
if not self.isDrum:
if self.battleStatus[7]:
notes = self.getDoubleNotes(notes)
return sorted(notes, key=lambda x: x[0]) #MFH - what the hell, this should be sorted by TIME not note number....
def areNotesTappable(self, notes):
if not notes:
return
for time, note in notes:
if note.tappable > 1:
return True
return False
def getMissedNotesMFH(self, song, pos, catchup = False):
if not song:
return
if not song.readyToGo:
return
m1 = self.lateMargin
m2 = self.lateMargin * 2
track = song.track[self.player]
notes = [(time, event) for time, event in track.getEvents(pos - m2, pos - m1) if isinstance(event, Note)] #was out of order
#MFH - this additional filtration step removes sustains whose Note On event time is now outside the hitwindow.
notes = [(time, event) for time, event in notes if (time >= (pos - m2)) and (time <= (pos - m1))]
notes = [(time, event) for time, event in notes if not event.played and not event.hopod and not event.skipped]
if catchup:
for time, event in notes:
event.skipped = True
return sorted(notes, key=lambda x: x[0]) #MFH - what the hell, this should be sorted by TIME not note number....
def getRequiredNotesForRender(self, song, pos):
if self.battleStatus[2] and self.difficulty != 0:
Log.debug(self.battleDiffUpValue)
song.difficulty[self.player] = Song.difficulties[self.battleDiffUpValue]
track0 = song.track[self.player]
notes0 = [(time, event) for time, event in track0.getEvents(pos - self.currentPeriod * 2, pos + self.currentPeriod * self.beatsPerBoard)]
song.difficulty[self.player] = Song.difficulties[self.battleDiffUpValue - 1]
track1 = song.track[self.player]
notes1 = [(time, event) for time, event in track1.getEvents(pos - self.currentPeriod * 2, pos + self.currentPeriod * self.beatsPerBoard)]
notes = []
for time,note in notes0:
if time < self.battleStartTimes[2] + self.currentPeriod * self.beatsPerBoard or time > self.battleStartTimes[2] - self.currentPeriod * self.beatsPerBoard + self.battleDiffUpLength:
notes.append((time,note))
for time,note in notes1:
if time > self.battleStartTimes[2] + self.currentPeriod * self.beatsPerBoard and time < self.battleStartTimes[2] - self.currentPeriod * self.beatsPerBoard + self.battleDiffUpLength:
notes.append((time,note))
notes0 = None
notes1 = None
track0 = None
track1 = None
notes = sorted(notes, key=lambda x: x[0])
else:
track = song.track[self.player]
notes = [(time, event) for time, event in track.getEvents(pos - self.currentPeriod * 2, pos + self.currentPeriod * self.beatsPerBoard)]
if self.battleStatus[7]:
notes = self.getDoubleNotes(notes)
return notes
def coOpRescue(self, pos):
self.coOpRestart = True #initializes Restart Timer
self.coOpRescueTime = pos
self.starPower = 0
Log.debug("Rescued at " + str(pos))
def noteBeingHeld(self):
noteHeld = False
if self.isDrum:
return noteHeld
for i in range(0,5):
if self.hit[i] == True:
noteHeld = True
return noteHeld
def isKillswitchPossible(self):
possible = False
if self.isDrum:
return possible
for i in range(0,5):
if self.hit[i] == True:
possible = True
return possible
#Renders the tail glow hitflame
def renderHitTrails(self, visibility, song, pos, controls):
if not song or self.flameColors[0][0][0] == -1 or self.disableFlameSFX == True:
return
w = self.boardWidth / self.strings
v = 1.0 - visibility
if (self.HCountAni == True and self.HCount2 >= self.HFrameLimit2):
for n in range(self.strings):
f = self.fretWeight[n]
if f and (controls.getState(self.actions[0]) or controls.getState(self.actions[1])):
f += 0.25
y = v + f / 6
x = (self.strings / 2 - n) * w
f = self.fretActivity[n]
ms = math.sin(self.time) * .25 + 1
ff = f
ff += 1.2
#myfingershurt: need to cap flameSizes use of scoreMultiplier to 4x, the 5x and 6x bass groove mults cause crash:
self.cappedScoreMult = min(self.scoreMultiplier,4)
flameSize = self.flameSizes[self.cappedScoreMult - 1][n]
if self.theme == 0 or self.theme == 1: #THIS SETS UP GH3 COLOR, ELSE ROCKBAND(which is DEFAULT in Theme.py)
flameColor = self.gh3flameColor
else:
flameColor = self.flameColors[self.cappedScoreMult - 1][n]
flameColorMod = (1.19, 1.97, 10.59)
flamecol = tuple([flameColor[ifc]*flameColorMod[ifc] for ifc in range(3)])
if self.starPowerActive:
if self.theme == 0 or self.theme == 1: #GH3 starcolor
flamecol = self.spColor
else: #Default starcolor (Rockband)
flamecol = (.9,.9,.9)
#Alarian: Animated hitflames
if self.Hitanim:
self.HCount = self.HCount + 1
if self.HCount > self.Animspeed-1:
self.HCount = 0
HIndex = (self.HCount * self.HFrameLimit - (self.HCount * self.HFrameLimit) % self.Animspeed) / self.Animspeed
if HIndex >= self.HFrameLimit:
HIndex = 0
texX = (HIndex*(1.0/self.HFrameLimit), HIndex*(1.0/self.HFrameLimit)+(1.0/self.HFrameLimit))
self.engine.draw3Dtex(self.hitglowAnim, coord = (x, y + .225, 0), rot = (90, 1, 0, 0), scale = (2.4, 1, 3.3),
vertex = (-flameSize * ff,-flameSize * ff,flameSize * ff,flameSize * ff),
texcoord = (texX[0],0.0,texX[1],1.0), multiples = True, alpha = True, color = (1,1,1))
else:
ff += .3
flameColorMod = (1.19, 1.78, 12.22)
flamecol = tuple([flameColor[ifc]*flameColorMod[ifc] for ifc in range(3)])
if self.starPowerActive:
if self.theme == 0 or self.theme == 1: #GH3 starcolor
flamecol = self.spColor
else: #Default starcolor (Rockband)
flamecol = (.8,.8,.8)
self.engine.draw3Dtex(self.hitglowDrawing, coord = (x, y + .125, 0), rot = (90, 1, 0, 0),
scale = (0.5 + .6 * ms * ff, 1.5 + .6 * ms * ff, 1 + .6 * ms * ff),
vertex = (-flameSize * ff,-flameSize * ff,flameSize * ff,flameSize * ff),
texcoord = (0.0,0.0,1.0,1.0), multiples = True, alpha = True, color = flamecol)
self.engine.draw3Dtex(self.hitglow2Drawing, coord = (x, y + .25, .05), rot = (90, 1, 0, 0),
scale = (.40 + .6 * ms * ff, 1.5 + .6 * ms * ff, 1 + .6 * ms * ff),
vertex = (-flameSize * ff,-flameSize * ff,flameSize * ff,flameSize * ff),
texcoord = (0.0,0.0,1.0,1.0), multiples = True, alpha = True, color = flamecol)
#renders the flames that appear when a note is struck
def renderFlames(self, visibility, song, pos, controls):
if not song or self.flameColors[0][0][0] == -1:
return
w = self.boardWidth / self.strings
v = 1.0 - visibility
if (self.HCountAni == True and self.HCount2 >= self.HFrameLimit2):
for n in range(self.strings):
f = self.fretWeight[n]
if f and (controls.getState(self.actions[0]) or controls.getState(self.actions[1])):
f += 0.25
y = v + f / 6
x = (self.strings / 2 - n) * w
f = self.fretActivity[n]
if f:
ms = math.sin(self.time) * .25 + 1
ff = f
ff += 1.2
#myfingershurt: need to cap flameSizes use of scoreMultiplier to 4x, the 5x and 6x bass groove mults cause crash:
self.cappedScoreMult = min(self.scoreMultiplier,4)
flameSize = self.flameSizes[self.cappedScoreMult - 1][n]
if self.theme == 0 or self.theme == 1: #THIS SETS UP GH3 COLOR, ELSE ROCKBAND(which is DEFAULT in Theme.py)
flameColor = self.gh3flameColor
else:
flameColor = self.flameColors[self.cappedScoreMult - 1][n]
flameColorMod = (1.19, 1.97, 10.59)
flamecol = tuple([flameColor[ifc]*flameColorMod[ifc] for ifc in range(3)])
if self.starPowerActive:
if self.theme == 0 or self.theme == 1: #GH3 starcolor
flamecol = self.spColor
else: #Default starcolor (Rockband)
flamecol = (.9,.9,.9)
if self.Hitanim != True and self.disableFlameSFX != True:
self.engine.draw3Dtex(self.hitglowDrawing, coord = (x, y + .125, 0), rot = (90, 1, 0, 0),
scale = (0.5 + .6 * ms * ff, 1.5 + .6 * ms * ff, 1 + .6 * ms * ff),
vertex = (-flameSize * ff,-flameSize * ff,flameSize * ff,flameSize * ff),
texcoord = (0.0,0.0,1.0,1.0), multiples = True, alpha = True, color = flamecol)
#Alarian: Animated hitflames
else:
self.HCount = self.HCount + 1
if self.HCount > self.Animspeed-1:
self.HCount = 0
HIndex = (self.HCount * self.HFrameLimit - (self.HCount * self.HFrameLimit) % self.Animspeed) / self.Animspeed
if HIndex >= self.HFrameLimit:
HIndex = 0
texX = (HIndex*(1.0/self.HFrameLimit), HIndex*(1.0/self.HFrameLimit)+(1.0/self.HFrameLimit))
if self.disableFlameSFX != True:
self.engine.draw3Dtex(self.hitglowAnim, coord = (x, y + .225, 0), rot = (90, 1, 0, 0), scale = (2.4, 1, 3.3),
vertex = (-flameSize * ff,-flameSize * ff,flameSize * ff,flameSize * ff),
texcoord = (texX[0],0.0,texX[1],1.0), multiples = True, alpha = True, color = (1,1,1))
ff += .3
flameColorMod = (1.19, 1.78, 12.22)
flamecol = tuple([flameColor[ifc]*flameColorMod[ifc] for ifc in range(3)])
if self.starPowerActive:
if self.theme == 0 or self.theme == 1: #GH3 starcolor
flamecol = self.spColor
else: #Default starcolor (Rockband)
flamecol = (.8,.8,.8)
if self.Hitanim != True and self.disableFlameSFX != True:
self.engine.draw3Dtex(self.hitglow2Drawing, coord = (x, y + .25, .05), rot = (90, 1, 0, 0),
scale = (.40 + .6 * ms * ff, 1.5 + .6 * ms * ff, 1 + .6 * ms * ff),
vertex = (-flameSize * ff,-flameSize * ff,flameSize * ff,flameSize * ff),
texcoord = (0.0,0.0,1.0,1.0), multiples = True, alpha = True, color = flamecol)
flameLimit = 10.0
flameLimitHalf = round(flameLimit/2.0)
renderedNotes = self.getRequiredNotesForRender(song,pos)
for time, event in renderedNotes:
if isinstance(event, Tempo):
continue
if not isinstance(event, Note):
continue
if (event.played or event.hopod) and event.flameCount < flameLimit:
ms = math.sin(self.time) * .25 + 1
x = (self.strings / 2 - event.number) * w
xlightning = (self.strings / 2 - event.number)*2.2*w
ff = 1 + 0.25
y = v + ff / 6
if self.theme == 2:
y -= 0.5
flameSize = self.flameSizes[self.cappedScoreMult - 1][event.number]
if self.theme == 0 or self.theme == 1: #THIS SETS UP GH3 COLOR, ELSE ROCKBAND(which is DEFAULT in Theme.py)
flameColor = self.gh3flameColor
else:
flameColor = self.flameColors[self.cappedScoreMult - 1][event.number]
if flameColor[0] == -2:
flameColor = self.fretColors[event.number]
ff += 1.5 #ff first time is 2.75 after this
if self.Hitanim2 == True:
self.HCount2 = self.HCount2 + 1
self.HCountAni = False
if self.HCount2 >= self.HFrameLimit2:
if not event.length > (1.4 * (60000.0 / event.noteBpm) / 4):
self.HCount2 = 0
else:
self.HCountAni = True
if event.flameCount < flameLimitHalf:
HIndex = (self.HCount2 * self.HFrameLimit2 - (self.HCount2 * self.HFrameLimit2) % self.HFrameLimit2) / self.HFrameLimit2
if HIndex >= self.HFrameLimit2 and self.HCountAni != True:
HIndex = 0
texX = (HIndex*(1.0/self.HFrameLimit2), HIndex*(1.0/self.HFrameLimit2)+(1.0/self.HFrameLimit2))
if self.disableFlameSFX != True:
self.engine.draw3Dtex(self.hitflamesAnim, coord = (x, y + .665, 0), rot = (90, 1, 0, 0), scale = (1.6, 1.6, 4.9),
vertex = (-flameSize * ff,-flameSize * ff,flameSize * ff,flameSize * ff),
texcoord = (texX[0],0.0,texX[1],1.0), multiples = True, alpha = True, color = (1,1,1))
else:
flameColorMod = 0.1 * (flameLimit - event.flameCount)
flamecol = tuple([ifc*flameColorMod for ifc in flameColor])
scaleChange = (3.0,2.5,2.0,1.7)
yOffset = (.35, .405, .355, .355)
vtx = flameSize * ff
scaleMod = .6 * ms * ff
for step in range(4):
#draw lightning in GH themes on SP gain
if step == 0 and event.finalStar and self.spEnabled and self.disableFlameSFX != True and self.hitlightning:
self.engine.draw3Dtex(self.hitlightning, coord = (xlightning, y, 3.3), rot = (90, 1, 0, 0),
scale = (.15 + .5 * ms * ff, event.flameCount / 3.0 + .6 * ms * ff, 2), vertex = (.4,-2,-.4,2),
texcoord = (0.0,0.0,1.0,1.0), multiples = True, alpha = True, color = (1,1,1))
continue
if step == 0:
yzscaleMod = event.flameCount/ scaleChange[step]
else:
yzscaleMod = (event.flameCount + 1)/ scaleChange[step]
if self.starPowerActive:
if self.theme == 0 or self.theme == 1:
spcolmod = .7+step*.1
flamecol = tuple([isp*spcolmod for isp in self.spColor])
else:
flamecol = (.4+step*.1,)*3#Default starcolor (Rockband)
if self.hitFlamesPresent == True and self.disableFlameSFX != True:
self.engine.draw3Dtex(self.hitflames1Drawing, coord = (x - .005, y + yOffset[step], 0), rot = (90, 1, 0, 0),
scale = (.25 + step*.05 + scaleMod, yzscaleMod + scaleMod, yzscaleMod + scaleMod),
vertex = (-vtx,-vtx,vtx,vtx), texcoord = (0.0,0.0,1.0,1.0),
multiples = True, alpha = True, color = flamecol)
elif self.hitFlamesPresent == True and self.Hitanim2 == False:
self.HCount2 = self.HFrameLimit2
self.HCountAni = True