Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2017-06-24 05:15:49

rbroab
Member
Registered: 2017-06-13
Post 20/86

Creating Events Without Sprites

My goal here is to create an event to start a Pokemon battle without using a sprite.

Exactly like Rotom in DPPt; talk to the TV and Rotom comes out
Is this within the realm of possibility in pokecrystal.

My plan is remove the Hidden Power TM guy from the house on Lake of Rage, move TM 10 elsewhere, and make it a room with just a TV. Talk to the TV and initiate a battle with Rotom.
All encounters I've found involve a sprite within the map.

Thoughts or ideas on how to make this happen?

Offline

#2 2017-06-24 11:58:26

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

Re: Creating Events Without Sprites

Use a signpost event on the TV, and call the battle from inside its script.

Offline

#3 2017-06-24 17:22:11

rbroab
Member
Registered: 2017-06-13
Post 22/86

Re: Creating Events Without Sprites

Thanks for the help! Got it working perfectly. I'll add a bit more detail to the text later, but in case anyone ever wants to do something similar, here's the script:

MapLakeofRageHiddenPowerHouseSignpost1Script: ; 0x7a5f0
checkevent EVENT_FOUGHT_ROTOM
iftrue .DontAppear
loadfont
writetext Text_InTV
yesorno
iffalse .no
writetext Text_ThumpTV
closetext
cry ROTOM
pause 15
loadpokedata ROTOM, 35
startbattle
writebyte ROTOM
special SpecialMonCheck
iffalse DontKillRotom
setevent EVENT_FOUGHT_ROTOM
returnafterbattle
pause 10
loadfont
writetext Text_NormalTV
waitbutton
closetext
end

.DontAppear
loadfont
writetext Text_RegularTV
waitbutton
closetext
end

.no
closetext
end

DontKillRotom:
returnafterbattle
end



Text_InTV: ; 0x7aad0
text "There's a #MON"
line "in the TV!"

para "Give it a thump?"
done
; 0x7ab31

Text_ThumpTV:
text "<PLAYER> thumped"
line "the TV!"
done

Text_NormalTV:
text "The TV returned"
line "to normal!"
done

Text_RegularTV:
text "There's a movie on"
line "TV: Stars dot the"

para "sky as two boys"
line "ride on a train<...>"

para "I'd better get"
line "rolling too!"
done

Offline

#4 2017-06-24 19:23:26

rbroab
Member
Registered: 2017-06-13
Post 24/86

Re: Creating Events Without Sprites

Does anyone know of a way to make the map music not play until the pokemon is beat or captured?
It'd be great to only have silence when you enter the room to give it a more eerie feel.

Offline

#5 2017-06-25 06:39:38

Rangi
Member
Registered: 2016-05-09
Post 738/870

Re: Creating Events Without Sprites

rbroab wrote:

Does anyone know of a way to make the map music not play until the pokemon is beat or captured?
It'd be great to only have silence when you enter the room to give it a more eerie feel.

One other map that changes its BGM according to an event is the souvenir shop in Mahogany Town. It uses MUSIC_MAHOGANY_MART. Now look at home/map.asm:GetMapHeaderMusic. It special-cases MUSIC_MAHOGANY_MART and loads MUSIC_ROCKET_HIDEOUT or MUSIC_CHERRYGROVE_CITY depending on whether bit 7 of StatusFlags2 is set. You can do the same for a new constant like MUSIC_EERIE_MAP, loading MUSIC_NONE or MUSIC_WHATEVER depending on whether EVENT_BATTLED_THE_MON is set.

To check whether an event is set in assembly, as opposed to the script command "checkevent", do this:

.eeriemap
    ld de, EVENT_BATTLED_THE_MON
    ld b, CHECK_FLAG
    call EventFlagAction
    ld a, c
    and a
    jr z, .not_yet_battled
    ld de, MUSIC_WHATEVER
    jr .done

.not_yet_battled
    ld de, MUSIC_NONE
    jr .done

Pokémon Polished Crystal (GitHub) — version 2.2.0 released
Pokémon Red★ and Blue★: Space World Edition (GitHub) — updated August 19!
Polished Map: pokered+pokecrystal map, tileset, and palette editor — version 3.5.1 released!

Offline

#6 2017-06-25 15:03:55

rbroab
Member
Registered: 2017-06-13
Post 30/86

Re: Creating Events Without Sprites

Sorry, seeing all that is really confusing for me haha.
What's the difference between that and "checkevent EVENT_FOUGHT_ROTOM" ?

Also, would it look like this

.eeriemap
    ld de, EVENT_FOUGHT_ROTOM
    ld b, CHECK_FLAG
    call EventFlagAction
    ld a, c
    and a
    jr z, .not_yet_battled
    ld de, MUSIC_LAKE_OF_RAGE
    jr .done

.not_yet_battled
    ld de, MUSIC_NONE
    jr .done

Offline

#7 2017-06-25 15:32:45

Rangi
Member
Registered: 2016-05-09
Post 743/870

Re: Creating Events Without Sprites

rbroab wrote:

Sorry, seeing all that is really confusing for me haha.
What's the difference between that and "checkevent EVENT_FOUGHT_ROTOM"

"checkevent EVENT_FOUGHT_ROTOM" is a script command. It goes in map scripts. If you study engine/scripting.asm and macros/event.asm, you'll see that script commands get compiled into IDs followed by parameter bytes, and the scripting engine reads a series of command IDs and executes the corresponding assembly routines from ScriptCommandTable.

What I gave you is direct assembly code that you can add to GetMapHeaderMusic.


Pokémon Polished Crystal (GitHub) — version 2.2.0 released
Pokémon Red★ and Blue★: Space World Edition (GitHub) — updated August 19!
Polished Map: pokered+pokecrystal map, tileset, and palette editor — version 3.5.1 released!

Offline

#8 2017-06-26 01:08:46

rbroab
Member
Registered: 2017-06-13
Post 32/86

Re: Creating Events Without Sprites

This is going to sound stupid, so please bear with me while I try and learn
But you're telling me I can just add your code to " home/map.asm:GetMapHeaderMusic" ?
I feel like there are changes I need to make in order for it to fit into my assembly, but I'm not sure what they would be.
Sorry

Offline

#9 2017-06-26 03:29:30

Rangi
Member
Registered: 2016-05-09
Post 744/870

Re: Creating Events Without Sprites

rbroab wrote:

This is going to sound stupid, so please bear with me while I try and learn
But you're telling me I can just add your code to " home/map.asm:GetMapHeaderMusic" ?
I feel like there are changes I need to make in order for it to fit into my assembly, but I'm not sure what they would be.
Sorry

Did you find the GetMapHeaderMusic routine in home/map.asm, or wherever TPP Crystal may have put it? Can you see how it checks for the special MUSIC_MAHOGANY_MART value and jumps to a different block of code for it? You'll need to (a) add the MUSIC_EERIE_MAP constant to constants/music_constants.asm, and (b) check for it in GetMapHeaderMusic and jump to the .eeriemap code block.


Pokémon Polished Crystal (GitHub) — version 2.2.0 released
Pokémon Red★ and Blue★: Space World Edition (GitHub) — updated August 19!
Polished Map: pokered+pokecrystal map, tileset, and palette editor — version 3.5.1 released!

Offline

#10 2017-06-26 04:33:17

rbroab
Member
Registered: 2017-06-13
Post 33/86

Re: Creating Events Without Sprites

Yeah, I got all that, I guess my confusion comes from where to place in to place the start of ".eeriemap" that it would make the jump to

GetMapHeaderMusic:: ; 2cbd
RADIO_TOWER_MUSIC EQU 7

    push hl
    push bc
    ld de, 6 ; music
    call GetMapHeaderMember
    ld a, c
    cp MUSIC_MAHOGANY_MART
    jr z, .mahoganymart
    bit RADIO_TOWER_MUSIC, c
    jr nz, .radiotower
    ; callba Function8b342
    ld e, c
    ld d, 0
.done
    pop bc
    pop hl
    ret

.radiotower
    and $7f
    cp MUSIC_S_S_ANNE
    jr z, .ssanne
    ld a, [StatusFlags2]
    bit 0, a
    jr z, .clearedradiotower
.rocket
    ld de, MUSIC_ROCKET_OVERTURE
    jr .done

.clearedradiotower
    ; the rest of the byte
    ld a, c
    and 1 << RADIO_TOWER_MUSIC - 1
    ld e, a
    ld d, 0
    jr .done

.mahoganymart
    ld a, [StatusFlags2]
    bit 7, a
    jr z, .clearedmahogany
    ld de, MUSIC_ROCKET_HIDEOUT
    jr .done

.clearedmahogany
    ld de, MUSIC_CHERRYGROVE_CITY
    jr .done
; 2cff
.ssanne
    push bc
    ld de, EVENT_ROCKET_TAKEOVER_OF_SS_ANNE
    ld b, CHECK_FLAG
    call EventFlagAction
    ld a, c
    pop bc
    and a
    jr nz, .rocket
    jr .clearedradiotower

Also, don't I need to make reference to LakeofRageHiddenPowerHouse somewhere?

Last edited by rbroab (2017-06-26 04:34:23)

Offline

#11 2017-06-26 08:58:25

Rangi
Member
Registered: 2016-05-09
Post 746/870

Re: Creating Events Without Sprites

rbroab wrote:

Yeah, I got all that, I guess my confusion comes from where to place in to place the start of ".eeriemap" that it would make the jump to

Also, don't I need to make reference to LakeofRageHiddenPowerHouse somewhere?

Just put it under the rest of the GetMapHeaderMusic code. (But you don't have to ask me. Just try putting it places and see if it works, glitches, crashes, or doesn't even compile. Chances are you'll figure things out yourself that way.)

And yes, of course you need to assign MUSIC_EERIE_MAP to that map in maps/map_headers.asm.

Last edited by Rangi (2017-06-26 08:59:33)


Pokémon Polished Crystal (GitHub) — version 2.2.0 released
Pokémon Red★ and Blue★: Space World Edition (GitHub) — updated August 19!
Polished Map: pokered+pokecrystal map, tileset, and palette editor — version 3.5.1 released!

Offline

#12 2017-06-26 14:35:11

rbroab
Member
Registered: 2017-06-13
Post 34/86

Re: Creating Events Without Sprites

So this is what I have

GetMapHeaderMusic:: ; 2cbd
RADIO_TOWER_MUSIC EQU 7

    push hl
    push bc
    ld de, 6 ; music
    call GetMapHeaderMember
    ld a, c
    cp MUSIC_MAHOGANY_MART
    jr z, .mahoganymart
    bit RADIO_TOWER_MUSIC, c
    jr nz, .radiotower
    ; callba Function8b342
    ld e, c
    ld d, 0
.done
    pop bc
    pop hl
    ret

.radiotower
    and $7f
    cp MUSIC_S_S_ANNE
    jr z, .ssanne
    ld a, [StatusFlags2]
    bit 0, a
    jr z, .clearedradiotower
.rocket
    ld de, MUSIC_ROCKET_OVERTURE
    jr .done

.clearedradiotower
    ; the rest of the byte
    ld a, c
    and 1 << RADIO_TOWER_MUSIC - 1
    ld e, a
    ld d, 0
    jr .done

.mahoganymart
    ld a, [StatusFlags2]
    bit 7, a
    jr z, .clearedmahogany
    ld de, MUSIC_ROCKET_HIDEOUT
    jr .done

.clearedmahogany
    ld de, MUSIC_CHERRYGROVE_CITY
    jr .done
; 2cff
.ssanne
    push bc
    ld de, EVENT_ROCKET_TAKEOVER_OF_SS_ANNE
    ld b, CHECK_FLAG
    call EventFlagAction
    ld a, c
    pop bc
    and a
    jr nz, .rocket
    jr .clearedradiotower
    
.eeriemap
    ld de, EVENT_FOUGHT_ROTOM
    ld b, CHECK_FLAG
    call EventFlagAction
    ld a, c
    and a
    jr z, .not_yet_battled
    ld de, MUSIC_LAKE_OF_RAGE
    jr .done

.not_yet_battled
    ld de, MUSIC_EERIE
    jr .done

And when I go to compile the ROM it says "Unable to load fixed ROM0 section at $150"

Offline

#13 2017-07-01 20:10:32

comet
Member
Registered: 2012-04-09
Post 677/679

Re: Creating Events Without Sprites

Ideally you could add a new callback type to map setup. Then you could just do this:

.MapCallbacks:
    db 1
    dbw MAPCALLBACK_MUSIC, .Music

.Music:
    checkevent EVENT_FOUGHT_ROTOM
    iftrue .done
    playmusic MUSIC_NONE
.done
    return

Offline

#14 2017-07-01 20:10:41

Rangi
Member
Registered: 2016-05-09
Post 749/870

Re: Creating Events Without Sprites

comet wrote:

Huh? The only reason they did that with GetMapHeaderMusic is that the rocket theme affected multiple maps.

Just add this callback:

.MapCallbacks:
    db 1
    dbw MAPCALLBACK_CMDQUEUE, .Music

.Music:
    checkevent EVENT_FOUGHT_ROTOM
    iftrue .done
    playmusic MUSIC_NONE
.done
    return

Would this work even when returning to the map from a battle, or from getting off the bike? And if any events rely on "playmapmusic" that wouldn't work either. It's definitely simpler than my solution, though, if it works.

Last edited by Rangi (2017-07-01 20:13:38)


Pokémon Polished Crystal (GitHub) — version 2.2.0 released
Pokémon Red★ and Blue★: Space World Edition (GitHub) — updated August 19!
Polished Map: pokered+pokecrystal map, tileset, and palette editor — version 3.5.1 released!

Offline

#15 2017-07-02 04:18:08

rbroab
Member
Registered: 2017-06-13
Post 42/86

Re: Creating Events Without Sprites

I'm afraid to test this. I'm leaving the country for a little over a week tomorrow. Was planning on playing my rom a bit over the trip.
I'd hate for it to alter anything other than the intended event.

Offline

#16 2017-07-02 10:43:00

Rangi
Member
Registered: 2016-05-09
Post 750/870

Re: Creating Events Without Sprites

rbroab wrote:

I'm afraid to test this. I'm leaving the country for a little over a week tomorrow. Was planning on playing my rom a bit over the trip.
I'd hate for it to alter anything other than the intended event.

You should really be using GitHub. Then you'd have an online backup of your project, and you can "commit" code with a descriptive message every time you finish making a change, so you can see the whole history of it and restore any version.


Pokémon Polished Crystal (GitHub) — version 2.2.0 released
Pokémon Red★ and Blue★: Space World Edition (GitHub) — updated August 19!
Polished Map: pokered+pokecrystal map, tileset, and palette editor — version 3.5.1 released!

Offline

#17 2017-07-03 23:37:12

comet
Member
Registered: 2012-04-09
Post 678/679

Re: Creating Events Without Sprites

I rewrote the post because it wouldn't work. None of the callbacks occur after the map music is set, and you're right about battles. What I did to solve this problem in the past was add a 'setmapmusic' command that would override the default music. Adding commands is really simple:

--- a/engine/scripting.asm
+++ b/engine/scripting.asm
@@ -236,6 +236,7 @@ ENDC
     dw Script_name                       ; a7
     dw Script_wait                       ; a8
     dw Script_check_save                 ; a9
+    dw Script_setmapmusic
 
 StartScript:
     ld hl, ScriptFlags
@@ -3043,3 +3044,10 @@ Script_check_save:
 
 .byte
     db 0
+
+Script_setmapmusic:
+    call GetScriptByte
+    ld [wOverrideMapMusic], a
+    call GetScriptByte
+    ld [wOverrideMapMusic + 1], a
+    ret
--- a/macros/event.asm
+++ b/macros/event.asm
@@ -1066,3 +1066,9 @@ wait: macro
 check_save: macro
     db check_save_command
     endm
+
+    enum setmapmusic_command
+setmapmusic: macro
+    db setmapmusic_command
+    dw \1 ; song
+    endm

Then you intercept the regular map music:

--- a/home/audio.asm
+++ b/home/audio.asm
@@ -498,10 +498,26 @@ SpecialMapMusic:: ; 3d62
 GetMapMusic:: ; 3d97
     call SpecialMapMusic
     ret c
+    call OverrideMapMusic
+    ret nz
     call GetMapHeaderMusic
     ret
 ; 3d9f
 
+OverrideMapMusic:
+    ld a, [wOverrideMapMusic]
+    ld e, a
+    ld a, [wOverrideMapMusic + 1]
+    ld d, a
+    or e
+    ret
+
+ResetOverrideMapMusic::
+    xor a
+    ld [wOverrideMapMusic], a
+    ld [wOverrideMapMusic + 1], a
+    ret
+
 Function3d9f:: ; 3d9f
 ; Places a BCD number at the
 ; upper center of the screen.

Then you reset it whenever you enter a new map (which is the same as leaving a map).

--- a/engine/warp_connection.asm
+++ b/engine/warp_connection.asm
@@ -5,6 +5,7 @@ HandleNewMap: ; 1045b0
     call ResetFlashIfOutOfCave
     call GetCurrentMapTrigger
     call ResetBikeFlags
+    call ResetOverrideMapMusic
     ld a, MAPCALLBACK_NEWMAP
     call RunMapCallback
 InitCommandQueue: ; 1045c4

Lastly, the new variable we made has to be stored in the game memory.

--- a/wram.asm
+++ b/wram.asm
@@ -2805,6 +2805,9 @@ XCoord:: ; dcb8
     ds 1 ; current x coordinate relative to top-left corner of current map
 wScreenSave:: ds 6 * 5
 
+wOverrideMapMusic::
+    ds 2
+
 wMapDataEnd::

Then you can use the callback from before:

.MapCallbacks:
    db 1
    dbw MAPCALLBACK_NEWMAP, .Music

.Music:
    checkevent EVENT_FOUGHT_ROTOM
    iftrue .done
    setmapmusic MUSIC_NONE
.done
    return

Last edited by comet (2017-07-03 23:54:47)

Offline

#18 2017-07-13 18:53:12

rbroab
Member
Registered: 2017-06-13
Post 44/86

Re: Creating Events Without Sprites

Thanks for all the help everyone
Keeping on topic of this Rotom event, I was wondering if there was any way to load this map without lights

Meaning, I want this room to operate like an outdoor map; yellow-ish in the morning, regular during the day, dark at night.

Offline

#19 2017-07-13 23:08:43

Rangi
Member
Registered: 2016-05-09
Post 769/870

Re: Creating Events Without Sprites

rbroab wrote:

Thanks for all the help everyone
Keeping on topic of this Rotom event, I was wondering if there was any way to load this map without lights

Meaning, I want this room to operate like an outdoor map; yellow-ish in the morning, regular during the day, dark at night.

In maps/map_headers.asm, give it PALETTE_AUTO instead of PALETTE_DAY.


Pokémon Polished Crystal (GitHub) — version 2.2.0 released
Pokémon Red★ and Blue★: Space World Edition (GitHub) — updated August 19!
Polished Map: pokered+pokecrystal map, tileset, and palette editor — version 3.5.1 released!

Offline

Board footer

Powered by FluxBB