- 19
- Posts
- 5
- Years
- Seen Jan 9, 2022
Hey all =] Coming back to romhacking after a long hiatus. For this issue, I have a piece of code. It detects whether the player has received their starter Pokemon. If they have, these two guards will move to new permanent positions to let them out of Pallet Town and into yonder world. I finally cracked the code for this--well--code to work: flags. I set the flags for the guards' new positions (new NPCs entirely on AdvanceMap) when the game begins. After the guards see the player has a Pokemon, I set the flags for the guards' OLD positions so they disappear from the map (this is all using the "person ID" box in AdvanceMap) and clear the flags for the guards' NEW positions so they appear permanently in these new positions. I'm super happy to have come this far, as it's been a project of mine to figure it out on my own. Sadly now I reach out to the community to see if anyone can polish this code.
My issue with it right now is that, while the code works completely well, the guards at the new positions after setting/clearing flags are invisible until the player takes a step in any direction. Of course this breaks the immersion, so I'm wondering if anyone has any insight. I thought maybe adding some movement to the NPCs after clearing and setting flags? I made it so after the old guards disappear and the new ones (should) appear that the new guards face right or left and then the direction they should be facing, but that didn't help as they are still invisible until the player takes a step. Thoughts? As always I appreciate you guys!
Here's the code:
My issue with it right now is that, while the code works completely well, the guards at the new positions after setting/clearing flags are invisible until the player takes a step in any direction. Of course this breaks the immersion, so I'm wondering if anyone has any insight. I thought maybe adding some movement to the NPCs after clearing and setting flags? I made it so after the old guards disappear and the new ones (should) appear that the new guards face right or left and then the direction they should be facing, but that didn't help as they are still invisible until the player takes a step. Thoughts? As always I appreciate you guys!
Here's the code:
Spoiler:
#dynamic 0x800000
#org @start
lock
checkflag 0x200
if 0x1 goto @goAhead
goto @sorry
#org @sorry
msgbox @text 0x6
release
end
#org @text
= Hey, no sneaking out of town!\nYou should know how dangerous\lit can be out there.\pYou're allowed out once you\nhave your own Pokémon.
#org @goAhead
msgbox @textInterrupted 0x6
getplayerpos 0x5005 0x5006
compare 0x5005 0x0C
if 0x1 goto @sorryLeft
compare 0x5005 0x0D
if 0x1 goto @sorryRight
#org @textInterrupted
= Hey, no sneaking out of town!\nYou should--
#org @sorryLeft
applymovement 0x8 @sorryPoint
waitmovement 0x0
pause 0x060
msgbox @passage 0x6
closeonkeypress
applymovement MOVE_PLAYER @moveBack
waitmovement 0x0
applymovement 0x8 @moveOut
waitmovement 0x0
applymovement 0x9 @moveOutToo
waitmovement 0x0
setflag 0x253
goto @nextFlag
#org @sorryRight
applymovement 0x9 @sorryPoint
waitmovement 0x0
pause 0x060
msgbox @passage 0x6
closeonkeypress
applymovement MOVE_PLAYER @moveBack
waitmovement 0x0
applymovement 0x8 @moveOut
waitmovement 0x0
applymovement 0x9 @moveOutToo
waitmovement 0x0
goto @nextFlag
#org @sorryPoint
#raw 0x62
#raw 0xFE
#org @passage
= Holy shit! Nice GROWLITHE!\nYou're free to go.\pJust don't get yourself hurt\nout there, okay?
#org @moveBack
#raw 0x10
#raw 0x01
#raw 0xFE
#org @moveOut
#raw 0x10
#raw 0x12
#raw 0x03
#raw 0x60
#raw 0xFE
#org @moveOutToo
#raw 0x10
#raw 0x13
#raw 0x02
#raw 0x60
#raw 0xFE
#org @nextFlag
setflag 0x254
goto @nextNextFlag
#org @nextNextFlag
clearflag 0x251
goto @finalFlag
#org @finalFlag
clearflag 0x252
applymovement 0x10 @faceRight
waitmovement 0x0
applymovement 0x11 @faceLeft
waitmovement 0x0
release
end
#org @faceRight
#raw 0x02
#raw 0x03
#raw 0xFE
#org @faceLeft
#raw 0x03
#raw 0x02
#raw 0xFE
#org @start
lock
checkflag 0x200
if 0x1 goto @goAhead
goto @sorry
#org @sorry
msgbox @text 0x6
release
end
#org @text
= Hey, no sneaking out of town!\nYou should know how dangerous\lit can be out there.\pYou're allowed out once you\nhave your own Pokémon.
#org @goAhead
msgbox @textInterrupted 0x6
getplayerpos 0x5005 0x5006
compare 0x5005 0x0C
if 0x1 goto @sorryLeft
compare 0x5005 0x0D
if 0x1 goto @sorryRight
#org @textInterrupted
= Hey, no sneaking out of town!\nYou should--
#org @sorryLeft
applymovement 0x8 @sorryPoint
waitmovement 0x0
pause 0x060
msgbox @passage 0x6
closeonkeypress
applymovement MOVE_PLAYER @moveBack
waitmovement 0x0
applymovement 0x8 @moveOut
waitmovement 0x0
applymovement 0x9 @moveOutToo
waitmovement 0x0
setflag 0x253
goto @nextFlag
#org @sorryRight
applymovement 0x9 @sorryPoint
waitmovement 0x0
pause 0x060
msgbox @passage 0x6
closeonkeypress
applymovement MOVE_PLAYER @moveBack
waitmovement 0x0
applymovement 0x8 @moveOut
waitmovement 0x0
applymovement 0x9 @moveOutToo
waitmovement 0x0
goto @nextFlag
#org @sorryPoint
#raw 0x62
#raw 0xFE
#org @passage
= Holy shit! Nice GROWLITHE!\nYou're free to go.\pJust don't get yourself hurt\nout there, okay?
#org @moveBack
#raw 0x10
#raw 0x01
#raw 0xFE
#org @moveOut
#raw 0x10
#raw 0x12
#raw 0x03
#raw 0x60
#raw 0xFE
#org @moveOutToo
#raw 0x10
#raw 0x13
#raw 0x02
#raw 0x60
#raw 0xFE
#org @nextFlag
setflag 0x254
goto @nextNextFlag
#org @nextNextFlag
clearflag 0x251
goto @finalFlag
#org @finalFlag
clearflag 0x252
applymovement 0x10 @faceRight
waitmovement 0x0
applymovement 0x11 @faceLeft
waitmovement 0x0
release
end
#org @faceRight
#raw 0x02
#raw 0x03
#raw 0xFE
#org @faceLeft
#raw 0x03
#raw 0x02
#raw 0xFE
Last edited: