
;█▀ █▀█ █▀█ █▀ █▀█ █▀█   █▀█ █▄▄   █▀█ █▀▀ ▄▀█ █▀▀ ▀█▀ █ █▀█ █▄ █
;▄█ █▀▀ █▄█ ▄█ █▀▀ █▄█   █▀▀ █▄█   █▀▄ ██▄ █▀█ █▄▄  █  █ █▄█ █ ▀█
;Simple v1.0
;Power bomb explosions prompt Spore Spawn to open up.
;Requires manually setting PB Reaction AI in enemy header, and setting PB vulnerability.
;Requires Improved Power Bomb Explosion by MFreak
;https://metroidconstruction.com/resource.php?id=588
;Uses 30 bytes in $A5


{;Defines
    ;Bank $A5: Spore Spawn AI
    !A5 = $A50000
    !A5Freespace = $F95A ;Set SpoSpo's PB reaction to the same value.
    !StartOpening = $E6E3;Instruction list pointer to begin opening


    ;RAM addresses
    !EnemyIndex     = $0E54
    !EnemyInst      = $0F92
    !EnemyInstTimer = $0F94
    !SporeFlag      = $7E9000
}

lorom 
org !A5+!A5Freespace

SpoSpoPowerBombAI: print pc, " - Set to Powerbomb reaction"
    LDA !EnemyIndex
    LDA !EnemyInst,x : CMP #!StartOpening : BMI + 
        ;Prevents PB from interuppting Start/End of fight
    LDA !SporeFlag : BNE + 
        ;1h = Stop Spawning; Check prevents immediate repetition. 
    LDA #!StartOpening : STA !EnemyInst,x
    LDA #$0001 : STA !EnemyInstTimer,x
 +  RTL 
    print pc, " - End of SpoSpoPBReaction_Simple.asm used space"