• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Conquest protagonist in the poll by clicking here.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Pokeemerald] Scripting Tutorial

It was a dumb mistake, i was miss a reference in text part of the script
 
How do map scripts work? I can't really figure it out by looking at other maps and all my tests end in a black screen when i enter the map.
Thanks in advance
 
How do map scripts work? I can't really figure it out by looking at other maps and all my tests end in a black screen when i enter the map.
Thanks in advance

You can try looking at this one as base, it has two types of scripts. One loading before transition and one after: https://pastebin.com/raw/YfS3twh3
Also this:
Code:
#define MAP_SCRIPT_ON_LOAD 1 // Stuff that player isn't supposed to see, like setmaptiles
#define MAP_SCRIPT_ON_FRAME_TABLE 2 // Runs after fadein finishes
#define MAP_SCRIPT_ON_TRANSITION 3
#define MAP_SCRIPT_ON_WARP_INTO_MAP_TABLE 4 // Runs before fadein finishes
#define MAP_SCRIPT_ON_RESUME 5
#define MAP_SCRIPT_ON_DIVE_WARP 6
#define MAP_SCRIPT_ON_RETURN_TO_FIELD 7
 
You can try looking at this one as base, it has two types of scripts. One loading before transition and one after: https://pastebin.com/raw/YfS3twh3
Also this:
Code:
#define MAP_SCRIPT_ON_LOAD 1 // Stuff that player isn't supposed to see, like setmaptiles
#define MAP_SCRIPT_ON_FRAME_TABLE 2 // Runs after fadein finishes
#define MAP_SCRIPT_ON_TRANSITION 3
#define MAP_SCRIPT_ON_WARP_INTO_MAP_TABLE 4 // Runs before fadein finishes
#define MAP_SCRIPT_ON_RESUME 5
#define MAP_SCRIPT_ON_DIVE_WARP 6
#define MAP_SCRIPT_ON_RETURN_TO_FIELD 7

thanks for the help, i didn't get the notation at first and i couldnt remember the types, but now i do!
 
i still seem to be confused because im trying to add the megastones around the region and i used the giveitem_std command so when i put it in for the venusaurite and i tried to make the rom i got an error bad intrusion for it not sure where im supposed to put it and do i need to find free space myself for the rom to put it in or does it automatically do it for me???

i want to know more about this as well because i do want to add legendaries as well in these routes so it would be helpful if i can understanding it better
 
giveitem_std has been renamed to giveitem so "Error bad instruction" means the command isn't a valid one.

Also no free space management is required for decomps! It automatically moves everything around to fit your new added stuff.
 
Is givepcitem <item>, <quantity> still a valid command? I'm getting
Code:
Error: bad instruction `givepcitem 254,1'
when I compile.
 
Last edited:
Is givepcitem <item>, <quantity> still a valid command? I'm getting
Code:
Error: bad instruction `givepcitem 254,1'
when I compile.

It's probably called addpcitem now, based on asm/macros/event.inc.
 
Note that in January of 2020 some of the commands were renamed in this commit and this commit. The upshot is the command names are add/remove instead of give/take in many cases now. So for example if takeitem doesn't work, try removeitem and vice-versa.
 
When i try to draw a sprite on screen i get a compiler error
data/maps/LittlerootTown/scripts.inc:1082: Error: bad instruction `drawmonpic 147,10,3'
data/maps/LittlerootTown/scripts.inc:1087: Error: bad instruction `erasemonpic'
Heres what my script looks like that has the drawmonpic
Script_OgSS_1::
lock
faceplayer
goto_if_set FLAG_UNUSED_0x2BB , Script_OgSS_Off
goto_if_set FLAG_UNUSED_0x2BA , Script_OgSS_Off
drawmonpic SPECIES_DRATINI, 10, 3
msgbox Text_OgSS_1_YN, MSGBOX_YESNO
compare VAR_RESULT, 0
goto_if_eq Script_TakePkmn_1_No
goto_if_ne Script_TakePkmn_1_Yes
erasemonpic
release
end
 
When i try to draw a sprite on screen i get a compiler error
data/maps/LittlerootTown/scripts.inc:1082: Error: bad instruction `drawmonpic 147,10,3'
data/maps/LittlerootTown/scripts.inc:1087: Error: bad instruction `erasemonpic'

Heres what my script looks like that has the drawmonpic
Script_OgSS_1::
lock
faceplayer
goto_if_set FLAG_UNUSED_0x2BB , Script_OgSS_Off
goto_if_set FLAG_UNUSED_0x2BA , Script_OgSS_Off
drawmonpic SPECIES_DRATINI, 10, 3
msgbox Text_OgSS_1_YN, MSGBOX_YESNO
compare VAR_RESULT, 0
goto_if_eq Script_TakePkmn_1_No
goto_if_ne Script_TakePkmn_1_Yes
erasemonpic
release
end
At some point after Avara wrote this tutorial, those commands were renamed. In Pokeemerald, they're showmonpic and hidemonpic now.
https://github.com/pret/pokeemerald/blob/master/asm/macros/event.inc#L906
https://github.com/pret/pokeemerald/blob/master/asm/macros/event.inc#L914
 
How does the base game handle items in lying on the ground in Pokeballs? I was looking in the base game map scripts, but it looks like those functions are defined elsewhere
 
Actually, I just found where they are!
*\data\scripts\item_ball_scripts.inc

Route104_EventScript_ItemPokeBall:: @ 8290D0C
finditem ITEM_POKE_BALL
end

Do I need to define them here or is it okay for them to hang out in the map script files?
 
Actually, I just found where they are!
*\data\scripts\item_ball_scripts.inc



Do I need to define them here or is it okay for them to hang out in the map script files?

You could put them in map script files if you wanted, personally I leave them in the .inc for tidiness/so I know they're all in the one spot :)
 
How do I tell the game to start a double battle when you're in sight of two trainers at once?
 
How do I tell the game to start a double battle when you're in sight of two trainers at once?

Sorry I'm so late responding to your question! All I did was ensure that the sight view radius was the same on each trainer and then set them up so they were across from each other and that seemed to work fine on its own. You've probably found that out by now but just in case anyone else wanted to know.
 
Time-based Scripts
The gettime command can be used to set the values of variables 0x8000, 0x8001, and 0x8002 to the in-game hour, minute, and second respectively. This is an example script for a NPC who gives different greetings depending on the hour.
Code:
Script_HourDemonstration::
	lock
	faceplayer
	gettime
	compare VAR_0x8000, 4
	goto_if_le Script_Night
	compare VAR_0x8000, 12
	goto_if_lt Script_Morning
	compare VAR_0x8000, 18
	goto_if_ge Script_Night
	msgbox Text_Day, MSGBOX_DEFAULT
	release
	end

Script_Morning::
	msgbox Text_Morning, MSGBOX_DEFAULT
	release
	end

Script_Night::
	msgbox Text_Night, MSGBOX_DEFAULT
	release
	end

Text_Morning:
	.string "Good morning.$"

Text_Day:
	.string "Good day.$"

Text_Night:
	.string "Good evening.$"
You could swap out the values to check for a particular minute or second too, if you wanted to run a very specific event that only occurs at a very specific time!
 
Fanfares

First things first, you can find a list of labels for sound effects and music in "include\constants\songs.h".

In not so many words a fanfare is a short jingle, for example, the healing sound in Pokémon Centers. To use one in your script, use these commands:
Code:
playfanfare [Label]
waitfanfare
waitfanfare means the script will wait for the jingle to finish playing before continuing. So, let's say we wanted to play the fanfare sound for obtaining a Gym Badge.
Code:
playfanfare MUS_OBTAIN_BADGE
waitfanfare
And that's it!

Sound Effects

Sound effects can bring a lot of life to overworld gameplay. For sounds, we'd use the following:
Code:
playse [Label]
That's all. If you want to make the script wait for the sound to finish before continuing, you can add waitse if you want to. For example, if you'd have liked to use a sound effect for an exclamation point emote on your player:
Code:
...
playse SE_PIN
applymovement OBJ_EVENT_ID_PLAYER, Movement_ResidenceHalls_Dorm_Exclamation
waitmovement 0
...

Movement_Exclamation:
	emote_exclamation_mark
	step_end
 
Hello,

Thank you very much for these, they are very useful and easy to understand !

I was moving things around in Littleroot Town inside porymap, and I saw that some npcs seemed to have a tile attributed to them before a specific flag is cleared.

Like for exemple, for the player character. He seems to start at a specific location after jumping out of the truck, either as male or female, and I can't find where I could change his designated tile once he is out of the truck.

I found this segment of the script that seems to be what I'm looking for, but I changed it and it didn't do anything :

LittlerootTown_EventScript_StepOffTruckMale::
lockall
setvar VAR_0x8004, 4 (<--- I changed this value)
setvar VAR_0x8005, 11 (<--- I changed this value)
call LittlerootTown_EventScript_GoInsideWithMom
setflag FLAG_HIDE_LITTLEROOT_TOWN_BRENDANS_HOUSE_TRUCK
warpsilent MAP_LITTLEROOT_TOWN_BRENDANS_HOUSE_1F, 255, 8, 8
waitstate
releaseall
end

LittlerootTown_EventScript_StepOffTruckFemale::
lockall
setvar VAR_0x8004, 22 (<--- I changed this value)
setvar VAR_0x8005, 10 (<--- I changed this value)
call LittlerootTown_EventScript_GoInsideWithMom
setflag FLAG_HIDE_LITTLEROOT_TOWN_MAYS_HOUSE_TRUCK
warpsilent MAP_LITTLEROOT_TOWN_MAYS_HOUSE_1F, 255, 2, 8
waitstate
releaseall
end


I don't know if a tutorial on how to modify the original script would be of interest to anyone besides me, but I couldn't find that info anywhere.
 
Last edited:
Back
Top