Skip to content
This repository was archived by the owner on Aug 29, 2022. It is now read-only.

Commit 4236586

Browse files
ShadowMarionotweuz
authored andcommitted
Some improvements for Lua scripts that add another strum note since its a common thing
1 parent 18334ce commit 4236586

3 files changed

Lines changed: 43 additions & 32 deletions

File tree

source/Note.hx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class Note extends FlxSprite
3737

3838
public var tail:Array<Note> = []; // for sustains
3939
public var parent:Note;
40+
public var blockHit:Bool = false; // only works for player
4041

4142
public var shouldbehidden:Bool = false;
4243
public var charSkin:String = null;
@@ -124,9 +125,12 @@ class Note extends FlxSprite
124125

125126
private function set_noteType(value:String):String {
126127
noteSplashTexture = PlayState.SONG.splashSkin;
127-
colorSwap.hue = ClientPrefs.arrowHSV[noteData % 4][0] / 360;
128-
colorSwap.saturation = ClientPrefs.arrowHSV[noteData % 4][1] / 100;
129-
colorSwap.brightness = ClientPrefs.arrowHSV[noteData % 4][2] / 100;
128+
if (noteData > -1 && noteData < ClientPrefs.arrowHSV.length)
129+
{
130+
colorSwap.hue = ClientPrefs.arrowHSV[noteData][0] / 360;
131+
colorSwap.saturation = ClientPrefs.arrowHSV[noteData][1] / 100;
132+
colorSwap.brightness = ClientPrefs.arrowHSV[noteData][2] / 100;
133+
}
130134

131135
if(noteData > -1 && noteType != value) {
132136
switch(value) {
@@ -208,8 +212,8 @@ class Note extends FlxSprite
208212
colorSwap = new ColorSwap();
209213
shader = colorSwap.shader;
210214

211-
x += swagWidth * (noteData % 4);
212-
if(!isSustainNote) { //Doing this 'if' check to fix the warnings on Senpai songs
215+
x += swagWidth * (noteData);
216+
if(!isSustainNote && noteData > -1 && noteData < 4) { //Doing this 'if' check to fix the warnings on Senpai songs
213217
var animToPlay:String = '';
214218
switch (noteData % 4)
215219
{
@@ -241,7 +245,7 @@ class Note extends FlxSprite
241245
offsetX += width / 2;
242246
copyAngle = false;
243247

244-
switch (noteData)
248+
switch (noteData % 4)
245249
{
246250
case 0:
247251
animation.play('purpleholdend');
@@ -262,7 +266,7 @@ class Note extends FlxSprite
262266

263267
if (prevNote.isSustainNote)
264268
{
265-
switch (prevNote.noteData)
269+
switch (prevNote.noteData % 4)
266270
{
267271
case 0:
268272
prevNote.animation.play('purplehold');

source/PlayState.hx

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3453,12 +3453,12 @@ class PlayState extends MusicBeatState
34533453
opponentNoteHit(daNote);
34543454
}
34553455

3456-
if(daNote.mustPress && cpuControlled) {
3456+
if(!daNote.blockHit && daNote.mustPress && cpuControlled && daNote.canBeHit) {
34573457
if(daNote.isSustainNote) {
34583458
if(daNote.canBeHit) {
34593459
goodNoteHit(daNote);
34603460
}
3461-
} else if(daNote.strumTime <= Conductor.songPosition || (daNote.isSustainNote && daNote.canBeHit && daNote.mustPress)) {
3461+
} else if(daNote.strumTime <= Conductor.songPosition || daNote.isSustainNote) {
34623462
goodNoteHit(daNote);
34633463
}
34643464
}
@@ -4545,7 +4545,7 @@ class PlayState extends MusicBeatState
45454545
var sortedNotesList:Array<Note> = [];
45464546
notes.forEachAlive(function(daNote:Note)
45474547
{
4548-
if (daNote.canBeHit && daNote.mustPress && !daNote.tooLate && !daNote.wasGoodHit && !daNote.isSustainNote)
4548+
if (daNote.canBeHit && daNote.mustPress && !daNote.tooLate && !daNote.wasGoodHit && !daNote.isSustainNote && !daNote.blockHit)
45494549
{
45504550
if(daNote.noteData == key)
45514551
{
@@ -4688,7 +4688,7 @@ class PlayState extends MusicBeatState
46884688
{
46894689
// hold note functions
46904690
if (daNote.isSustainNote && controlHoldArray[daNote.noteData] && daNote.canBeHit
4691-
&& daNote.mustPress && !daNote.tooLate && !daNote.wasGoodHit) {
4691+
&& daNote.mustPress && !daNote.tooLate && !daNote.wasGoodHit && !daNote.blockHit) {
46924692
goodNoteHit(daNote);
46934693
}
46944694
});
@@ -4904,7 +4904,7 @@ class PlayState extends MusicBeatState
49044904
if(note.isSustainNote && !note.animation.curAnim.name.endsWith('end')) {
49054905
time += 0.15;
49064906
}
4907-
StrumPlayAnim(true, Std.int(Math.abs(note.noteData)) % 4, time);
4907+
StrumPlayAnim(true, Std.int(Math.abs(note.noteData)), time);
49084908
note.hitByOpponent = true;
49094909

49104910
callOnLuas('opponentNoteHit', [notes.members.indexOf(note), Math.abs(note.noteData), note.noteType, note.isSustainNote]);
@@ -5022,15 +5022,13 @@ class PlayState extends MusicBeatState
50225022
if(note.isSustainNote && !note.animation.curAnim.name.endsWith('end')) {
50235023
time += 0.15;
50245024
}
5025-
StrumPlayAnim(false, Std.int(Math.abs(note.noteData)) % 4, time);
5025+
StrumPlayAnim(false, Std.int(Math.abs(note.noteData)), time);
50265026
} else {
5027-
playerStrums.forEach(function(spr:StrumNote)
5027+
var spr = playerStrums.members[note.noteData];
5028+
if(spr != null)
50285029
{
5029-
if (Math.abs(note.noteData) == spr.ID)
5030-
{
5031-
spr.playAnim('confirm', true);
5032-
}
5033-
});
5030+
spr.playAnim('confirm', true);
5031+
}
50345032
}
50355033
note.wasGoodHit = true;
50365034
vocals.volume = 1;
@@ -5063,14 +5061,20 @@ class PlayState extends MusicBeatState
50635061
var skin:String = 'noteSplashes';
50645062
if(PlayState.SONG.splashSkin != null && PlayState.SONG.splashSkin.length > 0) skin = PlayState.SONG.splashSkin;
50655063

5066-
var hue:Float = ClientPrefs.arrowHSV[data % 4][0] / 360;
5067-
var sat:Float = ClientPrefs.arrowHSV[data % 4][1] / 100;
5068-
var brt:Float = ClientPrefs.arrowHSV[data % 4][2] / 100;
5069-
if(note != null) {
5070-
skin = note.noteSplashTexture;
5071-
hue = note.noteSplashHue;
5072-
sat = note.noteSplashSat;
5073-
brt = note.noteSplashBrt;
5064+
var hue:Float = 0;
5065+
var sat:Float = 0;
5066+
var brt:Float = 0;
5067+
if (data > -1 && data < ClientPrefs.arrowHSV.length)
5068+
{
5069+
hue = ClientPrefs.arrowHSV[data][0] / 360;
5070+
sat = ClientPrefs.arrowHSV[data][1] / 100;
5071+
brt = ClientPrefs.arrowHSV[data][2] / 100;
5072+
if(note != null) {
5073+
skin = note.noteSplashTexture;
5074+
hue = note.noteSplashHue;
5075+
sat = note.noteSplashSat;
5076+
brt = note.noteSplashBrt;
5077+
}
50745078
}
50755079

50765080
var splash:NoteSplash = grpNoteSplashes.recycle(NoteSplash);

source/StrumNote.hx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class StrumNote extends FlxSprite
9595
animation.add('red', [7]);
9696
animation.add('blue', [5]);
9797
animation.add('purple', [4]);
98-
switch (Math.abs(noteData))
98+
switch (Math.abs(noteData) % 4)
9999
{
100100
case 0:
101101
animation.add('static', [0]);
@@ -126,7 +126,7 @@ class StrumNote extends FlxSprite
126126
antialiasing = ClientPrefs.globalAntialiasing;
127127
setGraphicSize(Std.int(width * 0.7));
128128

129-
switch (Math.abs(noteData))
129+
switch (Math.abs(noteData) % 4)
130130
{
131131
case 0:
132132
animation.addByPrefix('static', 'arrowLEFT');
@@ -188,9 +188,12 @@ class StrumNote extends FlxSprite
188188
colorSwap.saturation = 0;
189189
colorSwap.brightness = 0;
190190
} else {
191-
colorSwap.hue = ClientPrefs.arrowHSV[noteData % 4][0] / 360;
192-
colorSwap.saturation = ClientPrefs.arrowHSV[noteData % 4][1] / 100;
193-
colorSwap.brightness = ClientPrefs.arrowHSV[noteData % 4][2] / 100;
191+
if (noteData > -1 && noteData < ClientPrefs.arrowHSV.length)
192+
{
193+
colorSwap.hue = ClientPrefs.arrowHSV[noteData][0] / 360;
194+
colorSwap.saturation = ClientPrefs.arrowHSV[noteData][1] / 100;
195+
colorSwap.brightness = ClientPrefs.arrowHSV[noteData][2] / 100;
196+
}
194197

195198
if(animation.curAnim.name == 'confirm' && !PlayState.isPixelStage) {
196199
centerOrigin();

0 commit comments

Comments
 (0)