You are not logged in.
Let's say I need to change a SPRITE_GAMBLER into a SPRITE_ROCKET based on a value in RAM, when the map loads. What's the easiest way to do something like that?
Just assign one of the variable sprite IDs as one of the sprite IDs in the spriteset, assign a person to use the variable sprite ID, and it will use whatever sprite is stored at the appropriate RAM address.
; To update a var sprite, use
ld a, SPRITE_MOM ; or whatever
ld [wVarSprite1], a ; or whatever var sprite they use
; After you update a var sprite, run this from the map script, and it will update the person instantly
; Don't try to do it while talking to the person though, it will freeze haha
I'm sure there are other ways to do it, but that's how I added the functionality. If you just update the Sprite ID in RAM, the sprite will change the next time you reload the map. The extra bit of code is there if you want it to change without having to leave the map in between (like how the trainers in Janine's gym all look like her, then swap to look like their actual sprite before battle, for example).
I didn't think to copy how pokecrystal did it. Thanks!
I needed to know because I am trying to write some script to make the link trade partner the correct gender. I'll share the code with you if I get it working.
It's not a direct port of the code from Pokecrystal, but the functionality ends up being the same. While I've tested it to know that it works, I haven't actually had to use it yet, but the linked player's gender is one place I figured I would use it. Might also use a couple for decorating the player's room or secret base in a future version. I originally added it thinking I would need to do something like Crystal did with swimmer sprites (have one default to Oak for the very start, then become the female swimmer sprite for later, but I ended up getting it working without having to swap sprites in that case).
But yeah, I'd love to see your code once you get that implemented.
Last edited by Mateo (2016-09-20 14:05:15)
Updating a person instantly with
causes the screen to flicker white every other frame. Luckily I can update that sprite before the map loads but if you are trying to do such a thing in the future, be aware that re-initing map sprites might not be the best way to go about it.
Don't just leave it looping in the background constantly or yeah it will flicker like that. Just run it when you need it by having it run once and stop by using a temp flag or a different map script number (like the Oak event in Pallet uses). Even doing it once the screen will blink when it updates but that isn't a very big deal.
Oh do map scripts just run forever? I didn't know that!
I just set it up pre-map load, so it didn't end up mattering. Look it works! (I borrowed your Leaf sprite for testing, hope you don't mind. I'll replace it before I release my hack.)
Instead of exchanging 0 at the cable club's Serial_SyncAndExchangeNybble, I exchanged two different numbers (both non-zero because I think the sync checks for that??) depending on the player's gender. Then the other game reads [wSerialSyncAndExchangeNybbleReceiveData] in Func_72a8 and sets the variable sprite based on that.