Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2020-06-11 21:19:42

rbroab
Member
Registered: 2017-06-13
Post 91/101

Pokecrystal Pokeflute Small Glitch

So I added functionality to the Pokeflute in pokecrystal. It wakes all sleeping Pokemon in battle, and doesn't wake up any Pokemon outside of battle. However, if a wild Pokemon is sleeping and the Pokeflute is used, instead of saying "All sleeping Pokemon woke up!" it says "Player played the Pokeflute.... Now that's a catchy tune!" The last messaged is displayed only a very quick moment and then you get returned into the battle without needing to press any button. How can I get it to say "All sleeping Pokemon woke up!" as if it were my own Pokemon or  trainer battle?

Could someone take a peak at what I've got?

_PokeFlute:
    ld a, [wBattleMode]
    and a
    jr z, .not_in_battle
    xor a
    ld [wd002], a

    ld b, $ff ^ SLP

    ld hl, PartyMon1Status
    call .CureSleep

    ld a, [wBattleMode]
    cp WILD_BATTLE
    jr z, .skip_otrainer
    ld hl, OTPartyMon1Status    
    call .CureSleep
.skip_otrainer

    ld hl, BattleMonStatus
    ld a, [hl]
    and b
    ld [hl], a
    ld hl, EnemyMonStatus    
    ld a, [hl]
    and b
    ld [hl], a

    ld hl, .PlayedTheFlute
    call PrintText
    push de
    ld de, SFX_POKEFLUTE
    call WaitPlaySFX
    call WaitSFX
    pop de
    ld a, [wd002]
    and a
    jp nz, .sleeping

    ld hl, .CatchyTune
    call PrintText
    ret

.sleeping
    ld hl, .AllSleepingMonWokeUp
    jp PrintText

.CureSleep:
    ld de, PARTYMON_STRUCT_LENGTH
    ld c, PARTY_LENGTH

.loop
    ld a, [hl]
    push af
    and SLP
    jr z, .not_asleep
    ld a, 1
    ld [wd002], a
.not_asleep
    pop af
    and b
    ld [hl], a
    add hl, de
    dec c
    jr nz, .loop
    ret

.not_in_battle:
    ld hl, .PokefluteScript
    call QueueScript
    ld a, $1
    ld [wItemEffectSucceeded], a
    ret

.PokefluteScript:
    reloadmappart
    special UpdateTimePals
    callasm .CheckCanUsePokeflute
    iffalse .NothingHappenedScript

.NothingHappenedScript:
    opentext
    writetext PokefluteText1
    playsound SFX_POKEFLUTE
    waitsfx
    buttonsound
    writetext PokefluteText2
    waitbutton
    closetext
    end

.CheckCanUsePokeflute:
    farcall GetFacingObject
    jr c, .nope
    
.nope
    xor a
    ld [ScriptVar], a    
    ret
    
.CatchyTune: 
    ; Now, that's a catchy tune!
    text_jump PokefluteText2
    db "@"

.AllSleepingMonWokeUp:
    ; All sleeping #MON woke up.
    text_jump PokefluteText3
    db "@"

.PlayedTheFlute:
    ; played the # FLUTE.@ @
    text_jump PokefluteText1
    start_asm
    ld a, [wBattleMode]
    and a
    jr nz, .battle

    push de
    ld de, SFX_POKEFLUTE
    call WaitPlaySFX
    call WaitSFX
    pop de
    
.battle
    ld hl, .stop
    ret

.stop    db "@"


PokefluteText1:
    text "<PLAYER> played the"
    line "# FLUTE."
    done
    
PokefluteText2:
    text "Now, that's a"
    line "catchy tune!"
    done
    
PokefluteText3:
    text "All sleeping"
    line "#MON woke up."
    prompt

Last edited by rbroab (2020-06-11 21:21:06)

Offline

Board footer

Powered by FluxBB