Skip to content

Commit 4921cf9

Browse files
committed
eeeeeeeeeeeeeeeeeee
1 parent 2f64016 commit 4921cf9

File tree

4 files changed

+157
-39
lines changed

4 files changed

+157
-39
lines changed

source/archipelago/APItem.hx

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class APItem {
108108
public static var maxHPUp:Int = 0;
109109

110110
private var toSync:Bool = true;
111+
public var triggered:Bool = false;
111112

112113
public static var nonSongItemCounts:Map<String, Int> = new Map<String, Int>();
113114

@@ -245,8 +246,21 @@ class APItem {
245246
}
246247
}
247248
public function trigger():Void {
249+
if (this != APItem.activeItem && !this.isException && this.triggered) {
250+
return; // Only the active item can trigger unless it's an exception
251+
}
252+
253+
if (this.isException && (APItem.activeItem == null || APItem.activeItem.name != this.name)) {
254+
// Push the current active item back into the queue
255+
if (APItem.activeItem != null) {
256+
allItems.unshift(APItem.activeItem);
257+
}
258+
// Swap out the active item for the exception
259+
APItem.activeItem = this;
260+
}
261+
262+
// Check conditions before triggering
248263
if (this.condition.checkFn(this) && APItem.allowedToTrigger) {
249-
// Check extraConditions if they exist
250264
if (this.condition.extraConditions != null) {
251265
for (extraCondition in this.condition.extraConditions) {
252266
if (!extraCondition(this)) {
@@ -255,14 +269,9 @@ class APItem {
255269
}
256270
}
257271

258-
// Set active item if conditions are met and it's not an Everywhere item
259-
if (!this.isException && this.condition.type != ConditionType.Everywhere) {
260-
APItem.activeItem = this;
261-
}
262-
263-
// Execute the onTrigger function and remove the item from the list
264-
onTrigger();
265-
allItems.remove(this);
272+
// Trigger the item without removing it from the queue
273+
this.onTrigger();
274+
this.triggered = true;
266275
}
267276
}
268277

@@ -300,19 +309,25 @@ class APItem {
300309
public static function checkAndTrigger(items:Array<APItem>):Void {
301310
var triggered:Bool = false;
302311

312+
// Remove triggered items from the list.
313+
allItems = new ActiveArray(allItems.getItems().filter(function(item:APItem) {
314+
return !item.triggered;
315+
}));
316+
303317
for (item in items) {
304-
if (!allowedToTrigger && !item.isException) {
318+
if (!APItem.allowedToTrigger && !item.isException) {
305319
continue;
306320
}
321+
307322
if (item.condition.checkFn(item)) {
308-
// Check extraConditions if they exist
309323
if (item.condition.extraConditions != null) {
310324
for (extraCondition in item.condition.extraConditions) {
311325
if (!extraCondition(item)) {
312326
continue; // Skip this item if any extra condition fails
313327
}
314328
}
315329
}
330+
316331
if (!triggered || item.isException) {
317332
item.trigger();
318333
if (!item.isException) {
@@ -332,12 +347,12 @@ class APChartModifier extends APItem {
332347
if (yutautil.AprilFools.allowAF) {
333348
modifiers.push("SpeedRando");
334349
}
335-
this.chartModifier = modifiers[Std.random(modifiers.length)];
350+
do { // Until ManiaConverter is fixed, reroll if selected.
351+
this.chartModifier = modifiers[Std.random(modifiers.length)];
352+
} while (this.chartModifier == "ManiaConverter"); // Reroll if ManiaConverter is selected
353+
336354
super("Chart Modifier Trap (" + this.chartModifier + ")", ConditionHelper.PlayState(), function() {
337355
ClientPrefs.data.gameplaySettings.set("chartModifier", this.chartModifier);
338-
if (this.chartModifier == "ManiaConverter") {
339-
ClientPrefs.data.gameplaySettings.set("convertMania", 4 + Std.random(5));
340-
}
341356
APItem.popup("Chart Modifier Trap (" + this.chartModifier + ")");
342357
if (archipelago.APPlayState.instance?.startingSong) {
343358
MusicBeatState.switchState(new states.PlayState()); // Don't ask why I had to do this. - Yuta
@@ -352,7 +367,8 @@ class APChartModifier extends APItem {
352367
class APrilFools extends APItem {
353368
private static var options:Map<Int, Void->Void> = new Map();
354369
private static var initialized:Bool = false;
355-
private var triggered:Bool = false;
370+
371+
356372
static function initializeOptions():Void {
357373
options = [
358374
0 => function() {

source/archipelago/Client.hx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,7 @@ class Client {
14151415

14161416
trace(players);
14171417
ArchPopup.startPopupCustom("Please wait...", "Fetching data for games...", "archColor");
1418+
ArchPopup.startPopupCustom("The game can now be played!", "Loading Data", "archColor");
14181419

14191420
function data():Void {
14201421
var gamePackages:Map<String, DataPackageObject> = [];
@@ -1503,7 +1504,7 @@ class Client {
15031504
} catch (e:Dynamic) {
15041505
backend.MusicBeatState.resetState();
15051506
}
1506-
return ArchPopup.startPopupCustom("The game can now be played!", "You are now connected to the server. Have fun!", "archColor");
1507+
return ArchPopup.startPopupCustom("All Game Data has been fetched! Refreshing local info, just in case!", "Refresh", "archColor");
15071508
}
15081509

15091510
yutautil.Threader.runInThread(dataNew(), "DataPackageFetcher"); // Hopefully more optimal.

source/objects/playfields/PlayField.hx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -259,64 +259,64 @@ class PlayField extends FlxTypedGroup<FlxBasic>
259259

260260
// spawns a note
261261
public function spawnNote(note:Note){
262-
trace("Attempting to spawn note: " + note);
262+
// trace("Attempting to spawn note: " + note);
263263
if(note.spawned) {
264-
trace("Note already spawned, skipping: " + note);
264+
// trace("Note already spawned, skipping: " + note);
265265
return;
266266
}
267267

268268
if (noteQueue[note.column] != null) {
269-
trace("Removing note from queue for column: " + note.column);
269+
// trace("Removing note from queue for column: " + note.column);
270270
noteQueue[note.column].remove(note);
271-
trace("Sorting note queue for column: " + note.column);
271+
// trace("Sorting note queue for column: " + note.column);
272272
noteQueue[note.column].sort((a, b) -> Std.int(a.strumTime - b.strumTime));
273273
}
274274

275275
if (spawnedByData[note.column] != null) {
276-
trace("Adding note to spawnedByData for column: " + note.column);
276+
// trace("Adding note to spawnedByData for column: " + note.column);
277277
spawnedByData[note.column].push(note);
278278
} else {
279-
trace("spawnedByData for column " + note.column + " is null, aborting spawn.");
279+
// trace("spawnedByData for column " + note.column + " is null, aborting spawn.");
280280
return;
281281
}
282282

283283
if(note.holdType == HEAD || note.holdType == TAP) {
284-
trace("Note is of type HEAD or TAP: " + note);
284+
// trace("Note is of type HEAD or TAP: " + note);
285285
if(note.requiresTap) {
286-
trace("Note requires tap.");
286+
// trace("Note requires tap.");
287287
if (tapsByData[note.column] != null) {
288-
trace("Adding note to tapsByData for column: " + note.column);
288+
// trace("Adding note to tapsByData for column: " + note.column);
289289
tapsByData[note.column].push(note);
290290
} else {
291-
trace("tapsByData for column " + note.column + " is null.");
291+
// trace("tapsByData for column " + note.column + " is null.");
292292
}
293293
} else {
294-
trace("Note does not require tap.");
294+
// trace("Note does not require tap.");
295295
if (noTapsByData[note.column] != null) {
296-
trace("Adding note to noTapsByData for column: " + note.column);
296+
// trace("Adding note to noTapsByData for column: " + note.column);
297297
noTapsByData[note.column].push(note);
298298
} else {
299-
trace("noTapsByData for column " + note.column + " is null.");
299+
// trace("noTapsByData for column " + note.column + " is null.");
300300
}
301301
}
302302
}
303303

304-
trace("Dispatching noteSpawned event for note: " + note);
304+
// trace("Dispatching noteSpawned event for note: " + note);
305305
noteSpawned.dispatch(note, this);
306-
trace("Adding note to spawnedNotes.");
306+
// trace("Adding note to spawnedNotes.");
307307
spawnedNotes.push(note);
308308
note.handleRendering = false;
309309

310310
if (note is archipelago.APNote) {
311311
trace("APNote spawned: " + note);
312312
}
313313

314-
trace("Marking note as spawned.");
314+
// trace("Marking note as spawned.");
315315
note.spawned = true;
316316

317-
trace("Inserting note into PlayField.");
317+
// trace("Inserting note into PlayField.");
318318
insert(0, note);
319-
trace("Note successfully spawned: " + note);
319+
// trace("Note successfully spawned: " + note);
320320
}
321321

322322
// gets all notes in the playfield, spawned or otherwise.

source/states/PlayState.hx

Lines changed: 105 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,8 @@ class PlayState extends MusicBeatState
631631
if (mania > Note.maxMania)
632632
mania = Note.defaultMania;
633633

634+
trace("Mania set: " + mania);
635+
634636
Conductor.mapBPMChanges(SONG);
635637
Conductor.bpm = SONG.bpm;
636638

@@ -2259,7 +2261,8 @@ class PlayState extends MusicBeatState
22592261
var caseExecutionCount:Int = FlxG.random.int(-50, 50);
22602262
var currentModifier:Int = -1;
22612263
var stair:Int = 0;
2262-
public static function getNumberFromAnims(note:Int, mania:Int):Int {
2264+
2265+
public static inline function getNumberFromAnimsSmall(note:Int, mania:Int):Int {
22632266
var anims:Array<String> = Note.keysShit.get(mania).get("anims");
22642267
var animMap:Map<String, Int> = ["LEFT" => 0, "DOWN" => 1, "UP" => 2, "RIGHT" => 3];
22652268

@@ -2280,6 +2283,101 @@ class PlayState extends MusicBeatState
22802283
return animMap.exists(anim) ? animMap.get(anim) : note % mania;
22812284
}
22822285

2286+
public static inline function getNumberFromAnims(note:Int, mania:Int):Int
2287+
{
2288+
var animMap:Map<String, Int> = new Map<String, Int>();
2289+
animMap.set("LEFT", 0);
2290+
animMap.set("DOWN", 1);
2291+
animMap.set("UP", 2);
2292+
animMap.set("RIGHT", 3);
2293+
2294+
var anims:Array<String> = Note.keysShit.get(mania).get("anims");
2295+
var animKeys:Array<String> = [
2296+
for (key in animMap.keys())
2297+
if (key == "LEFT") "RIGHT" else if (key == "RIGHT") "LEFT" else key
2298+
];
2299+
2300+
var result:Int;
2301+
2302+
if (mania > 3)
2303+
{
2304+
var anim = animKeys[note];
2305+
var matchingIndices:Array<Int> = [];
2306+
if (note < animKeys.length)
2307+
{
2308+
for (i in 0...anims.length)
2309+
{
2310+
if (anims[i] == anim)
2311+
{
2312+
matchingIndices.push(i);
2313+
}
2314+
}
2315+
if (matchingIndices.length > 0)
2316+
{
2317+
var randomIndex = Std.int(Math.random() * matchingIndices.length);
2318+
result = matchingIndices[randomIndex];
2319+
}
2320+
else
2321+
{
2322+
var randomIndex = Std.int(Math.random() * mania);
2323+
result = randomIndex;
2324+
}
2325+
}
2326+
else
2327+
{
2328+
if (matchingIndices.length > 0)
2329+
{
2330+
var randomIndex = Std.int(Math.random() * matchingIndices.length);
2331+
result = matchingIndices[randomIndex];
2332+
}
2333+
else
2334+
{
2335+
var randomIndex = Std.int(Math.random() * mania);
2336+
result = randomIndex;
2337+
}
2338+
}
2339+
}
2340+
else
2341+
{ // mania == 3
2342+
var anim = anims[note];
2343+
if (note < anims.length)
2344+
{
2345+
if (animMap.exists(anim))
2346+
{
2347+
result = animMap.get(anim);
2348+
}
2349+
else
2350+
{
2351+
throw 'No matching animation found';
2352+
}
2353+
}
2354+
else
2355+
{
2356+
result = animMap.get(anim);
2357+
}
2358+
}
2359+
2360+
// Ensure result is within bounds
2361+
if (result < 0 || result > mania)
2362+
{
2363+
trace("OOB NOtE: " + note + " MANIA: " + mania + " RESULT: " + result);
2364+
var foundValidAnimation = false;
2365+
while (!foundValidAnimation)
2366+
{
2367+
var randomIndex = Std.int(Math.random() * anims.length);
2368+
var randomAnim = anims[randomIndex];
2369+
if (animMap.exists(randomAnim))
2370+
{
2371+
result = animMap.get(randomAnim);
2372+
foundValidAnimation = true;
2373+
}
2374+
}
2375+
}
2376+
2377+
return result;
2378+
}
2379+
2380+
22832381
private function generateSong():Void
22842382
{
22852383
// FlxG.log.add(ChartParser.parse());
@@ -2400,7 +2498,7 @@ class PlayState extends MusicBeatState
24002498
{
24012499
final songNotes: Array<Dynamic> = section.sectionNotes[i];
24022500
var spawnTime:Float = songNotes[0];
2403-
var noteColumn:Int = Std.int(songNotes[1] % totalColumns);
2501+
var noteColumn:Int = Std.int(songNotes[1]);
24042502
var noteStartColumn:Int = Std.int(songNotes[1] % Note.ammo[SONG.mania != null ? SONG.mania : 3]);
24052503
var holdLength:Float = songNotes[2];
24062504
var noteType:String = !Std.isOfType(songNotes[3], String) ? Note.defaultNoteTypes[songNotes[3]] : songNotes[3];
@@ -2542,8 +2640,11 @@ class PlayState extends MusicBeatState
25422640
case "Pain":
25432641
noteColumn = noteColumn - Std.int(songNotes[1] % Note.ammo[mania]);
25442642
case "4K Only":
2545-
noteColumn = getNumberFromAnims(noteColumn, 3);
2643+
trace("4K Only: " + noteColumn);
2644+
noteColumn = getNumberFromAnimsSmall(noteColumn, 3);
2645+
trace("Note: " + noteColumn + " Mania: " + mania + "GottaHit: " + gottaHitNote);
25462646
case "ManiaConverter":
2647+
trace("ManiaConverter: " + noteColumn);
25472648
noteColumn = getNumberFromAnims(noteColumn, mania);
25482649
trace("Note: " + noteColumn + " Mania: " + mania + "GottaHit: " + gottaHitNote);
25492650
case "Stairs":
@@ -2854,7 +2955,7 @@ class PlayState extends MusicBeatState
28542955
if (swagNote.field != null)
28552956
swagNote.fieldIndex = playfields.members.indexOf(swagNote.field);
28562957

2857-
trace("Note: " + swagNote.noteData + " GottaHit: " + swagNote.mustPress + " Field: " + swagNote.fieldIndex + " NoteType: " + swagNote.noteType);
2958+
// trace("Note: " + swagNote.noteData + " GottaHit: " + swagNote.mustPress + " Field: " + swagNote.fieldIndex + " NoteType: " + swagNote.noteType);
28582959

28592960
var playfield:PlayField = playfields.members[swagNote.fieldIndex];
28602961
//notes.insert(swagNote.ID, swagNote); // just for the sake of convenience

0 commit comments

Comments
 (0)