You are not logged in.
Pages: 1
I am attempting to make something similar to a fusion of White Treehollow and Mystery Dungeons
I'd like to get a second opinion on what I'm doing before I go any further and actually type out more code
I have a 3x3 Grid of maps and have setup all the map connections, theres no problem here they all work fine
map_header_2 MysteryDungeon_Room1, MYSTERYDUNGEON_ROOM1, 5, NORTH | EAST
connection north, MYSTERYDUNGEON_ROOM4, MysteryDungeon_Room4, 0, 0, 10, MYSTERYDUNGEON_ROOM1
connection east, MYSTERYDUNGEON_ROOM2, MysteryDungeon_Room2, 0, 0, 10, MYSTERYDUNGEON_ROOM1
map_header_2 MysteryDungeon_Room2, MYSTERYDUNGEON_ROOM2, 5, NORTH | WEST | EAST
connection north, MYSTERYDUNGEON_ROOM5, MysteryDungeon_Room5, 0, 0, 10, MYSTERYDUNGEON_ROOM2
connection west, MYSTERYDUNGEON_ROOM1, MysteryDungeon_Room1, 0, 0, 10, MYSTERYDUNGEON_ROOM2
connection east, MYSTERYDUNGEON_ROOM3, MysteryDungeon_Room3, 0, 0, 10, MYSTERYDUNGEON_ROOM2
map_header_2 MysteryDungeon_Room3, MYSTERYDUNGEON_ROOM3, 5, NORTH | WEST
connection north, MYSTERYDUNGEON_ROOM6, MysteryDungeon_Room6, 0, 0, 10, MYSTERYDUNGEON_ROOM3
connection west, MYSTERYDUNGEON_ROOM2, MysteryDungeon_Room2, 0, 0, 10, MYSTERYDUNGEON_ROOM3
map_header_2 MysteryDungeon_Room4, MYSTERYDUNGEON_ROOM4, 5, NORTH | SOUTH | EAST
connection north, MYSTERYDUNGEON_ROOM7, MysteryDungeon_Room7, 0, 0, 10, MYSTERYDUNGEON_ROOM4
connection south, MYSTERYDUNGEON_ROOM1, MysteryDungeon_Room1, 0, 0, 10, MYSTERYDUNGEON_ROOM4
connection east, MYSTERYDUNGEON_ROOM5, MysteryDungeon_Room5, 0, 0, 10, MYSTERYDUNGEON_ROOM4
map_header_2 MysteryDungeon_Room5, MYSTERYDUNGEON_ROOM5, 5, NORTH | SOUTH | WEST | EAST
connection north, MYSTERYDUNGEON_ROOM8, MysteryDungeon_Room8, 0, 0, 10, MYSTERYDUNGEON_ROOM5
connection south, MYSTERYDUNGEON_ROOM2, MysteryDungeon_Room2, 0, 0, 10, MYSTERYDUNGEON_ROOM5
connection west, MYSTERYDUNGEON_ROOM4, MysteryDungeon_Room4, 0, 0, 10, MYSTERYDUNGEON_ROOM5
connection east, MYSTERYDUNGEON_ROOM6, MysteryDungeon_Room6, 0, 0, 10, MYSTERYDUNGEON_ROOM5
map_header_2 MysteryDungeon_Room6, MYSTERYDUNGEON_ROOM6, 5, NORTH | SOUTH | WEST
connection north, MYSTERYDUNGEON_ROOM9, MysteryDungeon_Room9, 0, 0, 10, MYSTERYDUNGEON_ROOM6
connection south, MYSTERYDUNGEON_ROOM3, MysteryDungeon_Room3, 0, 0, 10, MYSTERYDUNGEON_ROOM6
connection west, MYSTERYDUNGEON_ROOM5, MysteryDungeon_Room5, 0, 0, 10, MYSTERYDUNGEON_ROOM6
map_header_2 MysteryDungeon_Room7, MYSTERYDUNGEON_ROOM7, 5, SOUTH | EAST
connection south, MYSTERYDUNGEON_ROOM4, MysteryDungeon_Room4, 0, 0, 10, MYSTERYDUNGEON_ROOM7
connection east, MYSTERYDUNGEON_ROOM8, MysteryDungeon_Room8, 0, 0, 10, MYSTERYDUNGEON_ROOM7
map_header_2 MysteryDungeon_Room8, MYSTERYDUNGEON_ROOM8, 5, SOUTH | WEST | EAST
connection south, MYSTERYDUNGEON_ROOM5, MysteryDungeon_Room5, 0, 0, 10, MYSTERYDUNGEON_ROOM8
connection west, MYSTERYDUNGEON_ROOM7, MysteryDungeon_Room7, 0, 0, 10, MYSTERYDUNGEON_ROOM8
connection east, MYSTERYDUNGEON_ROOM9, MysteryDungeon_Room9, 0, 0, 10, MYSTERYDUNGEON_ROOM8
map_header_2 MysteryDungeon_Room8, MYSTERYDUNGEON_ROOM8, 5, SOUTH | WEST
connection south, MYSTERYDUNGEON_ROOM6, MysteryDungeon_Room6, 0, 0, 10, MYSTERYDUNGEON_ROOM9
connection west, MYSTERYDUNGEON_ROOM8, MysteryDungeon_Room8, 0, 0, 10, MYSTERYDUNGEON_ROOM9
with maps like the pokemon center there are multiple maps that read the same blockdata, are there maps that chooses from multiple blockdata anywhere? If I put multiple Blockdata like I did below for a map I assume it ignores the second and just takes the first, or does it also load the second into memory somewhere and can I have a script redirect the blockdata to the second
MysteryDungeon_Room1_Blockdata:
INCBIN "MysteryDungeon_4Paths_Stairs.blk"
INCBIN "MysteryDungeon_3Paths_NoUp.blk"
I want to create a script that lets the maps choose from a pool of blockdata I've created and need a little guidance on how I can have the map choose from multiple blockdata
Or am I overcomplicating this
Last edited by Ketchup_Raptor (2017-05-05 02:19:23)
Offline
You'll need the changemap command.
Declare the default and alternate block data:
MysteryDungeon_Room1_BlockData:
INCBIN "MysteryDungeon_4Paths_Stairs.blk"
MysteryDungeon_Room1_Alt_BlockData:
INCBIN "MysteryDungeon_3Paths_NoUp.blk"
Then in MysteryDungeon_Room1.asm, add a callback to load the correct block data:
MysteryDungeon_Room1_MapScriptHeader:
.MapTriggers:
db 0
.MapCallbacks:
db 1
; callbacks
dbw MAPCALLBACK_TILES, MysteryDungeon_Room1_ChangeBlockDataScript
MysteryDungeon_Room1_ChangeBlockDataScript:
checkevent EVENT_USE_MD1_ALT_BLOCKDATA
iftrue .UseAlternateBlockData
changemap BANK(MysteryDungeon_Room1_BlockData), MysteryDungeon_Room1_BlockData
return
.UseAlternateBlockData
changemap BANK(MysteryDungeon_Room1_Alt_BlockData), MysteryDungeon_Room1_Alt_BlockData
return
You can also set or clear events to make different NPCs show up in the different cases.
My projects on GitHub:
• Polished Map 4.7.1 or 2.7.1++
• Tilemap Studio 4.0.1
• Pokémon Polished Crystal 2.2.0 or 3.0.0 beta
• Pokémon Red★/Blue★: Space World Edition 2020-11-01
Offline
I don't know exactly how you want your maps to work, but there's another technique that might be useful: variable warps. Elevators use them to determine which floor to exit on.
Here's an example. Warp #1 of MysteryDungeonRoom1 is set to go to warp #255 of some other map (doesn't matter which). The 255 is a flag to instead use the destination stored in BackupWarpNumber. Then there's a callback which stores the appropriate destination depending on whatever conditions you want (here it checks EVENT_USE_MD1_ALT_BLOCKDATA). You could even put "callasm MysteryDungeonRoom1_Warp1_SetNormal" or "callasm MysteryDungeonRoom1_Warp1_SetAlternate" in some other map script, like if you want to talk to an NPC to change the destination or something.
MysteryDungeonRoom1_MapScriptHeader:
.MapTriggers:
db 0
.MapCallbacks:
db 1
; callbacks
dbw MAPCALLBACK_OBJECTS, MysteryDungeonRoom1_Warp1Script
MysteryDungeonRoom1_Warp1Script:
checkevent EVENT_USE_MD1_ALT_BLOCKDATA
iftrue .UseAlternateWarp
callasm MysteryDungeonRoom1_Warp1_SetNormal
return
.UseAlternateWarp:
callasm MysteryDungeonRoom1_Warp1_SetAlternate
return
MysteryDungeonRoom1_MapEventHeader:
; filler
db 0, 0
.Warps:
db 1
warp_def $5, $f, 255, MYSTERY_DUNGEON_ROOM_2
.XYTriggers:
db 0
.Signposts:
db 0
.PersonEvents:
db 0
MysteryDungeonRoom1_Warp1_SetNormal:
ld hl, MysteryDungeonRoom1_Warp1_NormalData
jr SetMysteryDungeonRoom1Warp1
MysteryDungeonRoom1_Warp1_SetAlternate:
ld hl, MysteryDungeonRoom1_Warp1_AlternateData
SetMysteryDungeonRoom1Warp1:
ld de, BackupWarpNumber
ld a, BANK(MysteryDungeonRoom1_Warp1_NormalData)
ld bc, 3
call FarCopyBytes
ret
MysteryDungeonRoom1_Warp1_NormalData:
db 1, GROUP_MYSTERY_DUNGEON_ROOM_2, MAP_MYSTERY_DUNGEON_ROOM_2
MysteryDungeonRoom1_Warp1_AlternateData:
db 5, GROUP_MYSTERY_DUNGEON_ROOM_3, MAP_MYSTERY_DUNGEON_ROOM_3
You can only have one variable destination per map, since there's only one BackupWarpNumber.
Last edited by Rangi (2017-05-05 02:45:37)
My projects on GitHub:
• Polished Map 4.7.1 or 2.7.1++
• Tilemap Studio 4.0.1
• Pokémon Polished Crystal 2.2.0 or 3.0.0 beta
• Pokémon Red★/Blue★: Space World Edition 2020-11-01
Offline
Thanks!
Offline
@Rangi
I really appreciate the help you gave me
The elevator script was actually the first one I looked at and fiddled with but abandoned it when I found it could only choose one variable destination when I needed at least 2
my plan was to have a 3x3 grid of maps all connected to eachother and 18 maps with different sides open and closed, 9 of the maps will have stairs that will have a script that asks if you want to proceed to the next floor and randomize the variables before warping you to it and if your floornumber is equal to the floorstotal then you exit the dungeon, to enter the dungeon there will be a script that randomizes the variables and resets the floornumber and warps you into a random room
I wrote out more of the code for having the map choose from a pool of map blockdata
MysteryDungeon_Room1_MapScriptHeader:
.MapTriggers:
db 0
.MapCallbacks:
db 1
; callbacks
dbw MAPCALLBACK_TILES, MysteryDungeon_Room1_ChangeMap
MysteryDungeon_Room1_ChangeMap:
;check if it is the room with stairs
checkcode VAR_MD_ROOM_WITH_STAIRS
if_equal 1, .MysteryDungeon_Room1_Stairs
if_not_equal 1, .MysteryDungeon_Room1_NoStairs
return
;choose map with stairs
MysteryDungeon_Room1_Stairs:
checkcode VAR_MD_ROOM1
if_equal 1, .4Paths_Stairs
if_equal 2, .3Paths_NoLeft_Stairs
if_equal 3, .3Paths_NoUp_Stairs
if_equal 4, .3Paths_NoRight_Stairs
if_equal 5, .3Paths_NoDown_Stairs
if_equal 6, .2Paths_NoUp_NoRight_Stairs
if_equal 7, .2Paths_NoRight_NoDown_Stairs
if_equal 8, .2Paths_NoDown_NoLeft_Stairs
if_equal 9, .2Paths_NoLeft_NoUp_Stairs
return
;choose map without stairs
MysteryDungeon_Room1_NoStairs:
checkcode VAR_MD_ROOM1
if_equal 1, .4Paths
if_equal 2, .3Paths_NoLeft
if_equal 3, .3Paths_NoUp
if_equal 4, .3Paths_NoRight
if_equal 5, .3Paths_NoDown
if_equal 6, .2Paths_NoRight_NoUp
if_equal 7, .2Paths_NoDown_NoRight
if_equal 8, .2Paths_NoDown_NoLeft
if_equal 9, .2Paths_NoLeft_NoUp
return
;map is chosen
4Paths_Stairs:
changemap BANK(MysteryDungeon_4Paths_Stairs_BlockData), MysteryDungeon_4Paths_Stairs_BlockData
return
4Paths:
changemap BANK(MysteryDungeon_4Paths_BlockData), MysteryDungeon_4Paths_BlockData
return
3Paths_NoLeft_Stairs:
changemap BANK(MysteryDungeon_3Paths_NoLeft_Stairs_BlockData), MysteryDungeon_3Paths_NoLeft_Stairs_BlockData
return
3Paths_NoUp_Stairs:
changemap BANK(MysteryDungeon_3Paths_NoUp_Stairs_BlockData), MysteryDungeon_3Paths_NoUp_Stairs_BlockData
return
3Paths_NoRight_Stairs:
changemap BANK(MysteryDungeon_3Paths_NoRight_Stairs_BlockData), MysteryDungeon_3Paths_NoRight_Stairs_BlockData
return
3Paths_NoDown_Stairs:
changemap BANK(MysteryDungeon_3Paths_NoDown_Stairs_BlockData), MysteryDungeon_3Paths_NoDown_Stairs_BlockData
return
3Paths_NoUp:
changemap BANK(MysteryDungeon_3Paths_NoUp_BlockData), MysteryDungeon_3Paths_NoUp_BlockData
return
3Paths_NoRight:
changemap BANK(MysteryDungeon_3Paths_NoRight_BlockData), MysteryDungeon_3Paths_NoRight_BlockData
return
3Paths_NoLeft:
changemap BANK(MysteryDungeon_3Paths_NoLeft_BlockData), MysteryDungeon_3Paths_NoLeft_BlockData
return
3Paths_NoDown:
changemap BANK(MysteryDungeon_3Paths_NoDown_BlockData), MysteryDungeon_3Paths_NoDown_BlockData
return
2Paths_NoUp_NoRight_Stairs:
changemap BANK(MysteryDungeon_2Paths_NoUp_NoRight_Stairs_BlockData), MysteryDungeon_2Paths_NoUp_NoRight_Stairs_BlockData
return
2Paths_NoRight_NoDown_Stairs:
changemap BANK(MysteryDungeon_2Paths_NoRight_NoDown_Stairs_BlockData), MysteryDungeon_2Paths_NoRight_NoDown_Stairs_BlockData
return
2Paths_NoDown_NoLeft_Stairs:
changemap BANK(MysteryDungeon_2Paths_NoDown_NoLeft_Stairs_BlockData), MysteryDungeon_2Paths_NoDown_NoLeft_Stairs_BlockData
return
2Paths_NoLeft_NoUp_Stairs:
changemap BANK(MysteryDungeon_2Paths_NoLeft_NoUp_Stairs_BlockData), MysteryDungeon_2Paths_NoLeft_NoUp_Stairs_BlockData
return
2Paths_NoDown_NoLeft:
changemap BANK(MysteryDungeon_2Paths_NoDown_NoLeft_BlockData), MysteryDungeon_2Paths_NoDown_NoLeft_BlockData
return
2Paths_NoLeft_NoUp:
changemap BANK(MysteryDungeon_2Paths_NoLeft_NoUp_BlockData), MysteryDungeon_2Paths_NoLeft_NoUp_BlockData
return
2Paths_NoRight_NoUp:
changemap BANK(MysteryDungeon_2Paths_NoRight_NoUp_BlockData), MysteryDungeon_2Paths_NoRight_NoUp_BlockData
return
2Paths_NoDown_NoRight:
changemap BANK(MysteryDungeon_2Paths_NoDown_NoRight_BlockData), MysteryDungeon_2Paths_NoDown_NoRight_BlockData
return
I currently have the variables defined in map_constants.asm have I defined them correctly or do they need to be elsewhere?
;MysteryDungeon Layout
const_value SET 1
const VAR_MD_ROOM1
const VAR_MD_ROOM2
const VAR_MD_ROOM3
const VAR_MD_ROOM4
const VAR_MD_ROOM5
const VAR_MD_ROOM6
const VAR_MD_ROOM7
const VAR_MD_ROOM8
const VAR_MD_ROOM9
const VAR_MD_ROOMS_SET
const VAR_MD_LAST_ROOM_SET
const VAR_MD_ROOM_WITH_STAIRS
const VAR_MD_FLOORNUMBER
const VAR_MD_FLOORSTOTAL
Last edited by Ketchup_Raptor (2017-05-05 15:26:35)
Offline
I currently have the variables defined in map_constants.asm have I defined them correctly or do they need to be elsewhere?
;MysteryDungeon Layout const_value SET 1 const VAR_MD_ROOM1 const VAR_MD_ROOM2 const VAR_MD_ROOM3 const VAR_MD_ROOM4 const VAR_MD_ROOM5 const VAR_MD_ROOM6 const VAR_MD_ROOM7 const VAR_MD_ROOM8 const VAR_MD_ROOM9 const VAR_MD_ROOMS_SET const VAR_MD_LAST_ROOM_SET const VAR_MD_ROOM_WITH_STAIRS const VAR_MD_FLOORNUMBER const VAR_MD_FLOORSTOTAL
I'm not reviewing your algorithm for the rooms themselves, but I can help with how to use variables.
First add your constants in constants/script_constants.asm with all the other VAR_*s. Then add them to .VarActionTable in engine/variables.asm. Here are a few such lines for reference:
.VarActionTable: ; 80671
; RETVAR_STRBUF2: copy [de] to StringBuffer2
; RETVAR_ADDR_DE: return address in de
; RETVAR_EXECUTE: call function
dwb wKurtApricornQuantity, RETVAR_STRBUF2 ; VAR_KURT_APRICORNS ; 16
dwb BattleType, RETVAR_ADDR_DE ; VAR_BATTLETYPE ; 03
dwb .CountBadges, RETVAR_EXECUTE ; VAR_BADGES ; 07
The nth line of .VarActionTable corresponds to the nth VAR_* constant. If a variable just needs to store and retrieve a single byte, then it looks like RETVAR_STRBUF2 or RETVAR_ADDR_DE will both work, but I see that "writecode" is only used on RETVAR_ADDR_DE variables (specifically VAR_BATTLETYPE and VAR_CALLERID), so use that. For example:
dwb wMDRoom1, RETVAR_ADDR_DE ; VAR_MD_ROOM1 ; 1b
The second column there is for the address in wram.asm that actually stores the value in question. Now, you have 14 variables, so you need to find 14 free bytes in wram.asm. It's full of "ds N" declarations that declare N bytes of memory, and sometimes you can just add more of those, but (a) it might lead to bank overflow compile errors, and (b) if there's already unused space declared you might as well use that. Anyway, I see this:
wBuenasPassword:: ds 1
wBlueCardBalance:: ds 1
wDailyRematchFlags:: ds 4
wDailyPhoneItemFlags:: ds 4
wDailyPhoneTimeOfDayFlags:: ds 4
wKenjiBreakTimer:: ds 2 ; Kenji
wYanmaMapGroup:: ds 1 ; dc5a
wYanmaMapNumber:: ds 1
wPlayerMonSelection:: ds 3
wdc5f:: ds 1
wdc60:: ds 19
That last line looks suspicious—"wdc60:: ds 19" has no meaningful label, an arbitrary number of bytes, and it's at the very end. It looks like Game Freak just reserved a bunch of bytes and ended up not using the last ones. To make sure, I searched for all uses of wdc60 (you can do "grep -r wdc60 *"). It's just used a few times in misc/mobile_40.asm by some Battle Tower routines. So you can safely change it to this:
wdc60:: ds 1
wMDRoom1:: ds 1
wMDRoom2:: ds 1
wMDRoom3:: ds 1
wMDRoom4:: ds 1
wMDRoom5:: ds 1
wMDRoom6:: ds 1
wMDRoom7:: ds 1
wMDRoom8:: ds 1
wMDRoom9:: ds 1
wMDRoomsSet:: ds 1
wMDLastRoomSet:: ds 1
wMDRoomWithStairs:: ds 1
wMDFloorNumber:: ds 1
wMDFloorsTotal:: ds 1
ds 4 ; 4 of the 19 still unused
In scripts, you would use variables like this:
writecode VAR_MD_ROOM1, 42
...
checkcode VAR_MD_ROOM1
if_equal 42, .it_is_42_now
In assembly routines, you can use the WRAM addresses directly:
ld a, 42
ld [wMDRoom1], a
...
ld a, [wMDRoom1]
cp 42
jr z, .it_is_42_now
Last edited by Rangi (2017-05-05 19:24:20)
My projects on GitHub:
• Polished Map 4.7.1 or 2.7.1++
• Tilemap Studio 4.0.1
• Pokémon Polished Crystal 2.2.0 or 3.0.0 beta
• Pokémon Red★/Blue★: Space World Edition 2020-11-01
Offline
Pages: 1