@@ -22,7 +22,7 @@ class ConditionHelper {
2222 return condition .checkFn ();
2323 }
2424 public static var Everywhere = ConditionHelper .create (function (): Bool { return true ; }, ConditionType . Everywhere );
25- public static var PlayState = ConditionHelper .create (function (): Bool { return Std .is (FlxG .state , states. PlayState ); }, ConditionType . PlayState );
25+ public static var PlayState = ConditionHelper .create (function (): Bool { return Std .is (FlxG .state , states. PlayState );}, ConditionType . PlayState );
2626 public static var Freeplay = ConditionHelper .create (function (): Bool { return Std .is (FlxG .state , states. FreeplayState ); }, ConditionType . Freeplay );
2727}
2828
@@ -103,18 +103,15 @@ class APItem {
103103 this .isException = true ;
104104 }
105105
106- if (APGameState .isSync && this .toSync ) {
107- allItems .push (this ); trace (' Item to sync: ${this .name }' );
108- } else if (! APGameState .isSync ) {
109- allItems .push (this ); trace (' Item: ${this .name }' );
110- }
111-
106+ allItems .push (this );
112107 }
113108
114109 public static function popup (desc : String ): Void {
115- archipelago. ArchPopup .startPopupCustom (" AP Item!" , desc , " archColor" , function () {
116- FlxG .sound .playMusic (Paths .sound (' secret' ));
117- });}
110+ if (! APGameState .haventranyet ) {
111+ archipelago. ArchPopup .startPopupCustom (" AP Item!" , desc , " archColor" , function () {
112+ FlxG .sound .playMusic (Paths .sound (' secret' ));});
113+ }
114+ }
118115
119116 public static function createItemByName (name : String ): APItem {
120117 switch (name ) {
@@ -123,6 +120,7 @@ class APItem {
123120 // Check if shields are available
124121 if (shields > 0 ) {
125122 shields -- ;
123+ ArchPopup .startPopupCustom (" Death Avoided!" , ' Shields left: $shields ' , " archWhite" );
126124 return ; // Do nothing else if shields are consumed
127125 }
128126
@@ -135,7 +133,7 @@ class APItem {
135133 // Wait for PlayState's startedCountdown to become active
136134 haxe. Timer .delay (function checkCountdown () {
137135 var playState : archipelago. APPlayState = cast states. PlayState .instance ;
138- if (playState != null && playState .startedCountdown ) {
136+ if (playState != null && playState .startedCountdown && ! playState . endingSong && ! playState . paused ) {
139137 // Call the die() function once the countdown has started
140138 // HOW AND WHY DOES THIS WORK THE WAY IT DOES???? - Yuta
141139 // Welcome back old friend - Z11
@@ -156,9 +154,31 @@ class APItem {
156154 archipelago. APInfo .ticketCount ++ ;}
157155 );
158156 case " SvC Effect" :
159- return new APItem (name , ConditionHelper . PlayState , function () trace ("SvC Effect triggered !"));
157+ return new APItem (name , ConditionHelper . PlayState , function () {
158+ // Wait for PlayState's startedCountdown to become active
159+ haxe. Timer .delay (function checkCountdown () {
160+ var playState : archipelago. APPlayState = cast states. PlayState .instance ;
161+ if (playState != null && playState .startedCountdown && ! playState .endingSong && ! playState .paused ) {
162+ APPlayState .instance .doEffect (APPlayState .instance .effectArray [APPlayState .instance .curEffect ]);
163+ } else {
164+ // Retry after a short delay if countdown hasn't started
165+ haxe. Timer .delay (checkCountdown , 100 );
166+ }
167+ }, 100 );
168+ }, false , false );
160169 case " Ghost Chat" :
161- return new APItem (name , ConditionHelper . PlayState , function () trace ("Ghost Chat triggered !"));
170+ return new APItem (name , ConditionHelper . PlayState , function () {
171+ // Wait for PlayState's startedCountdown to become active
172+ haxe. Timer .delay (function checkCountdown () {
173+ var playState : archipelago. APPlayState = cast states. PlayState .instance ;
174+ if (playState != null && playState .startedCountdown && ! playState .endingSong && ! playState .paused ) {
175+ APPlayState .instance .triggerGhostChat ();
176+ } else {
177+ // Retry after a short delay if countdown hasn't started
178+ haxe. Timer .delay (checkCountdown , 100 );
179+ }
180+ }, 100 );
181+ }, false , false );
162182 case " Shield" :
163183 return new APItem (name , ConditionHelper . Everywhere , function () {
164184 shields ++ ;
@@ -172,7 +192,18 @@ class APItem {
172192 popup (" You got a max HP up!" );
173193 });
174194 case " Tutorial Trap" :
175- return new APItem (name , ConditionHelper . PlayState , function () trace ("Tutorial Trap triggered !"), true );
195+ return new APItem (name , ConditionHelper . PlayState , function () {
196+ // Wait for PlayState's startedCountdown to become active
197+ haxe. Timer .delay (function checkCountdown () {
198+ var playState : archipelago. APPlayState = cast states. PlayState .instance ;
199+ if (playState != null && playState .startedCountdown && ! playState .endingSong && ! playState .paused ) {
200+ APPlayState .instance .doEffect (' songSwitch' );
201+ } else {
202+ // Retry after a short delay if countdown hasn't started
203+ haxe. Timer .delay (checkCountdown , 100 );
204+ }
205+ }, 100 );
206+ }, true , false );
176207 default :
177208 throw " Unknown item name: " + name ;
178209 }
0 commit comments