Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2016-09-20 03:34:57

MechanicalPen
Member
Registered: 2016-06-22
Post 14/28

[pokered] Change overworld sprite appearance.

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?

Offline

#2 2016-09-20 04:17:39

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,394/3,456

Re: [pokered] Change overworld sprite appearance.

What I did was this, followed immediately by this to optimize the original commit a bit.

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

call DisableLCD
callba InitMapSprites
call EnableLCD

; 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).

Offline

#3 2016-09-20 13:11:10

MechanicalPen
Member
Registered: 2016-06-22
Post 15/28

Re: [pokered] Change overworld sprite appearance.

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.

Offline

#4 2016-09-20 14:02:58

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,395/3,456

Re: [pokered] Change overworld sprite appearance.

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)

Offline

#5 2016-09-20 16:05:46

MechanicalPen
Member
Registered: 2016-06-22
Post 16/28

Re: [pokered] Change overworld sprite appearance.

Updating a person instantly with

call DisableLCD
callba InitMapSprites
call EnableLCD

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.

Offline

#6 2016-09-20 16:23:20

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,396/3,456

Re: [pokered] Change overworld sprite appearance.

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.

Offline

#7 2016-09-20 18:38:30

MechanicalPen
Member
Registered: 2016-06-22
Post 17/28

Re: [pokered] Change overworld sprite appearance.

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.)
1vfREKN.png

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.

Offline

Board footer

Powered by FluxBB