Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2020-05-31 19:07:59

noobimodder
Member
Registered: 2020-05-16
Post 6/10

Scripting Troubles

Okay, so in my starting town, there are two different ways to go. However, I have both sides blocked off until the Player can complete the events displayed in the code. (Get a starter, and get the Pokedex)

The code actually works in game! But it is not without its glitches.
PalletTownScript1 works perfectly as intended.

However, PalletTownScript3 "works". (It doesn't crash the game.) When I enter the specified coordinates, (CoordsData_PalletTown2) the game begins to play a bunch of spooky glitch sounds, and then when its done, it gives some glitch text, ending with "ERROR", changes the music, and then executes PalletTownScript4. Also, talking to the second guard NPC also executes PalletTownScript4, but there are no other strange effects related to it. (This is not what I want. I just want it to display his dialog, like the Guard 1 NPC does.) When I leave the map, and come back, the music is back to normal.

PalletTown_Script:
    call EnableAutoTextBoxDrawing
    ld hl, PalletTown_ScriptPointers
    ld a, [wPalletTownCurScript]
    jp CallFunctionInTable

PalletTown_ScriptPointers:
    dw PalletTownScript0
    dw PalletTownScript1
    dw PalletTownScript3
    dw PalletTownScript5

PalletTownScript0:
    call PalletTownScript3
    
PalletTownScript1:
    CheckEvent EVENT_GOT_POKEDEX
    ret nz
    ld hl, CoordsData_PalletTown1
    call ArePlayerCoordsInArray
    ret nc
    ld [hSpriteIndexOrTextID], a
    call DisplayTextID ; You can't go out
    xor a
    ld [hJoyHeld], a
    call PalletTownScript2
    ;ld a, $1 ;HAD TO REMOVE THIS LINE TO MAKE THE CODE WORK
    ld [wPalletTownCurScript], a
    ret
    
PalletTownScript2: ; Move player right
    call StartSimulatingJoypadStates
    ld a, $1 ;moves $1 to A registry
    ld [wSimulatedJoypadStatesIndex], a ; in A registry you activate [wSimulatedJoypadStatesIndex]
    ld a, D_RIGHT ; Moves you right
    ld [wSimulatedJoypadStatesEnd], a ;It crashes here. It crashes after moving 1 step.
    xor a
    ld [wSpriteStateData1 + 9], a
    ld [wJoyIgnore], a
    ret
    
PalletTownScript3:
    CheckEvent EVENT_GOT_STARTER
    ret nz
    ld hl, CoordsData_PalletTown2
    call ArePlayerCoordsInArray ;standing in these coordinates makes the game play a bunch of glitch noises
    ret nc
    ld [hSpriteIndexOrTextID], a
    call DisplayTextID ; It doesn't display the text
    xor a
    ld [hJoyHeld], a
    call PalletTownScript4 ; When its done, it changes the music, and executes PalletTownScript4
    ;ld a, $1 ;HAD TO REMOVE THIS LINE TO MAKE THE CODE WORK
    ld [wPalletTownCurScript], a ; 
    ret
    
PalletTownScript4: ; Move player right
    call StartSimulatingJoypadStates
    ld a, $1 ;moves $1 to A registry
    ld [wSimulatedJoypadStatesIndex], a ; in A registry you activate [wSimulatedJoypadStatesIndex]
    ld a, D_LEFT ; Moves you right
    ld [wSimulatedJoypadStatesEnd], a ;
    xor a
    ld [wSpriteStateData1 + 9], a
    ld [wJoyIgnore], a
    ret
    
PalletTownScript5:
    ld a, [wSimulatedJoypadStatesIndex]
    and a
    ret nz
    call Delay3
    ld a, 0
    ld [wPalletTownCurScript], a
    ret

CoordsData_PalletTown1:
    db 9,1
    db 10,1
    db 11,1
    db $ff
    
CoordsData_PalletTown2:
    db 8,16
    db 9,16
    db 10,16
    db $ff

PalletTown_TextPointers:
    dw PalletTownText0
    dw PalletTownText1
    dw PalletTownText2
    dw PalletTownText3

PalletTownText0: ;Guard 1
    TX_ASM
    ld hl, PalletTownText1
    call PrintText
    call PalletTownScript2
    ld a, $3
    ld [wPalletTownCurScript], a
    jp TextScriptEnd
    
PalletTownText1: ; You can't go out without a pokemon
    TX_FAR _PalletTownText4
    db "@"

PalletTownText2: ; Guard 2
    TX_ASM
    ld hl, PalletTownText3
    call PrintText
    call PalletTownScript4 ; Just talking to him triggers PalletTownScript4?
    ld a, $3
    ld [wPalletTownCurScript], a
    jp TextScriptEnd

PalletTownText3: ; Test
    TX_FAR _PalletTownText7
    db "@"

Offline

#2 2020-05-31 21:33:05

Danny-E 33
Administrator
Registered: 2012-06-09
Post 1,188/1,193

Offline

#3 2020-06-01 03:29:54

noobimodder
Member
Registered: 2020-05-16
Post 7/10

Re: Scripting Troubles

Danny-E 33 wrote:

h0tp3ngu1n and I already addressed the problem with PalletTownScript3 here.

Um, I'm really sorry but I don't quite understand how that will fix this issue. I did what you said I should do in that post, and I haven't experienced any crashes. However, my issue is has not changed. It does not display the text it should display, (PalletTownText3), and instead plays a bunch of glitch noises, changes the music, and then displays some glitched text that ends with "ERROR", before executing PalletTownScript4.

Offline

#4 2020-06-01 16:23:08

noobimodder
Member
Registered: 2020-05-16
Post 8/10

Re: Scripting Troubles

Update!

So I managed to fix the glitch I was having by commenting out some lines related to displaying the text. I suppose I just need to figure out a way to now display some text. How it is now, it just pushes the player back and wont let them pass, without any text to explain why.

PalletTownScript3:
    CheckEvent EVENT_GOT_STARTER
    ret nz
    ld hl, CoordsData_PalletTown2
    call ArePlayerCoordsInArray ;standing in these coordinates makes the game play a bunch of glitch noises
    ret nc
    ;ld [hSpriteIndexOrTextID], a
    ;call DisplayTextID ; It doesn't display the text
    ;call 
    ;xor a
    ld [hJoyHeld], a
    call PalletTownScript4 ; moves the player back
    ;ld a, $1 
    ;ld [wPalletTownCurScript], a 
    ret
    
PalletTownScript4: ; Move player left
    call StartSimulatingJoypadStates
    ld a, $1 ;moves $1 to A registry
    ld [wSimulatedJoypadStatesIndex], a ; in A registry you activate [wSimulatedJoypadStatesIndex]
    ld a, D_LEFT ; Moves you left
    ld [wSimulatedJoypadStatesEnd], a ;
    xor a
    ld [wSpriteStateData1 + 9], a
    ld [wJoyIgnore], a
    ret

Offline

#5 2020-06-01 23:17:17

Mateo
Member
Registered: 2009-11-25
Post 3,640/3,659

Re: Scripting Troubles

Looking at the part you commented out, the issue with the glitchy text was almost certainly because you were not actually telling it a valid text ID to load, and just loading whatever value was already in "a" into hSpriteIndexOrTextID. Try putting back the part you commented out, but make sure to add

ld a, $1

(or the index of whichever textpointer you want it to be loading there) above the lines you commented out. So that it looks like:

PalletTownScript3:
    CheckEvent EVENT_GOT_STARTER
    ret nz
    ld hl, CoordsData_PalletTown2
    call ArePlayerCoordsInArray ;standing in these coordinates makes the game play a bunch of glitch noises
    ret nc
    ld a, $1 ; or some other valid text ID for it to display
    ld [hSpriteIndexOrTextID], a
    call DisplayTextID ; It doesn't display the text
    call 
    xor a
    ld [hJoyHeld], a
    call PalletTownScript4 ; moves the player back
    ;ld a, $1 
    ;ld [wPalletTownCurScript], a 
    ret

I am not very active on this forum. I only pop in from time to time.

Offline

#6 2020-06-02 11:23:52

noobimodder
Member
Registered: 2020-05-16
Post 10/10

Re: Scripting Troubles

Mateo wrote:

Looking at the part you commented out, the issue with the glitchy text was almost certainly because you were not actually telling it a valid text ID to load, and just loading whatever value was already in "a" into hSpriteIndexOrTextID. Try putting back the part you commented out, but make sure to add

ld a, $1

(or the index of whichever textpointer you want it to be loading there) above the lines you commented out. So that it looks like:

PalletTownScript3:
    CheckEvent EVENT_GOT_STARTER
    ret nz
    ld hl, CoordsData_PalletTown2
    call ArePlayerCoordsInArray ;standing in these coordinates makes the game play a bunch of glitch noises
    ret nc
    ld a, $1 ; or some other valid text ID for it to display
    ld [hSpriteIndexOrTextID], a
    call DisplayTextID ; It doesn't display the text
    call 
    xor a
    ld [hJoyHeld], a
    call PalletTownScript4 ; moves the player back
    ;ld a, $1 
    ;ld [wPalletTownCurScript], a 
    ret

Thank you, thank you!! This is perfect! I didn't understand what the ld a, $1 was for when I was just looking at the code myself so thank you so much for finally telling me what that means! You are my hero!

Offline

#7 2020-06-02 16:54:40

Mateo
Member
Registered: 2009-11-25
Post 3,641/3,659

Re: Scripting Troubles

Glad to help. I know scripting in Pokered can be a mess, and I know that asm is not always easy to pick up on if you're not familiar with it.


I am not very active on this forum. I only pop in from time to time.

Offline

Board footer

Powered by FluxBB