Advertiser Content

Script NPC Requests to See a Specific Pokemon Script?

Started by thugtality September 23rd, 2019 10:41 PM
  • 969 views
  • 5 replies
Midwest, USA
Seen 3 Weeks Ago
Posted 3 Weeks Ago
6 posts
71 Days
Hey guys,

I've been looking everywhere to try and figure out how I can implement a simple script into my Rom Hack that would play out like this, for example:

NPC: "I think Onix is the coolest! If you show me one, I'll give you something special."

*Player has Onix in party*

NPC: "Oh, wow, an Onix, thanks! Here you go, as promised!"

*NPC gives player Metal Coat or other item*

I'm fairly certain that these types of scripts exist even in the base game (Fire Red), and I've tried looking at some of the scripts in Pokemon Gaia, but they're already compiled and it's hard for me to make sense of them. Can anyone explain how to implement this and give me an example to go with it? I would really appreciate it.

DrFuji

Heiki Hecchara‌‌

Age 26
Male
Aussie
Seen 1 Day Ago
Posted 6 Days Ago
1,620 posts
10.2 Years
In FR, the command 'special2 0xYYYY 0x147' will return the ID number of a Pokemon in your party to variable 0xYYYY. It takes the value of 0x8004, ranging between values 0x0 and 0x5 to determine which party member's ID number it should return. Knowing this, you can make a script with a simple loop which will gradually increment the value of 0x8004 until it has checked every party member's ID and branch out when the game finds an Onix. Here's a quick one that I whipped up for you with some comments to explain how it works:

Spoiler:
#dynamic 0x800000

#org @start
checkflag 0x200 // Flag check to see if the player has already gotten the reward
if 0x1 goto @AlreadyDone
msgbox @Coolest 0x2
setvar 0x8004 0x0 // Setting variable 0x8004 to 0x0, this will make special2 0x147 check the first Pokemon in the party
goto @Loop

#org @Loop
special2 0x8000 0x147 // The Pokemon in variable 0x8004's party slot's ID is put into variable 0x8000
compare 0x8000 0x5F // Checking if the ID in variable 0x8000 is equal to that of Onix
if 0x1 goto @HaveOnix // If the value is equal, branch off to the part of the script where you get the metal coat
addvar 0x8004 0x1 // Add 1 to variable 0x8004, this will change the party slot to check if we go back to the start of the loop
compare 0x8004 0x6 // If variable 0x8004 is equal to 0x6 at this stage, then we've checked every Pokemon in the party
if 0x5 goto @Loop // The script will go back to @Loop if 0x8004 has any value other than 0x6
msgbox @NoOnix 0x2
release
end

#org @HaveOnix
msgbox @OhWow 0x2
giveitem 0xC7 0x1 0x0
setflag 0x200 // Setting a flag to make sure the player can't get infinite Metal Coats
release
end

#org @AlreadyDone
msgbox @Thanks 0x2
release
end

#org @Coolest
= I think Onix is the coolest!\nIf you show me one, I'll give\lyou something special.

#org @NoOnix
= Sorry, you don't have an Onix...

#org @OhWow
= Oh, wow, an Onix, thanks!\nHere you go, as promised!

#org @Thanks
= Thanks for showing me that Onix!


Hopefully that helps.

DrFuji

Heiki Hecchara‌‌

Age 26
Male
Aussie
Seen 1 Day Ago
Posted 6 Days Ago
1,620 posts
10.2 Years
Yup, in Emerald special 0x149 works in exactly the same way as 0x147 in FR.
Midwest, USA
Seen 3 Weeks Ago
Posted 3 Weeks Ago
6 posts
71 Days
In FR, the command 'special2 0xYYYY 0x147' will return the ID number of a Pokemon in your party to variable 0xYYYY. It takes the value of 0x8004, ranging between values 0x0 and 0x5 to determine which party member's ID number it should return. Knowing this, you can make a script with a simple loop which will gradually increment the value of 0x8004 until it has checked every party member's ID and branch out when the game finds an Onix. Here's a quick one that I whipped up for you with some comments to explain how it works:

Spoiler:
#dynamic 0x800000

#org @start
checkflag 0x200 // Flag check to see if the player has already gotten the reward
if 0x1 goto @AlreadyDone
msgbox @Coolest 0x2
setvar 0x8004 0x0 // Setting variable 0x8004 to 0x0, this will make special2 0x147 check the first Pokemon in the party
goto @Loop

#org @Loop
special2 0x8000 0x147 // The Pokemon in variable 0x8004's party slot's ID is put into variable 0x8000
compare 0x8000 0x5F // Checking if the ID in variable 0x8000 is equal to that of Onix
if 0x1 goto @HaveOnix // If the value is equal, branch off to the part of the script where you get the metal coat
addvar 0x8004 0x1 // Add 1 to variable 0x8004, this will change the party slot to check if we go back to the start of the loop
compare 0x8004 0x6 // If variable 0x8004 is equal to 0x6 at this stage, then we've checked every Pokemon in the party
if 0x5 goto @Loop // The script will go back to @Loop if 0x8004 has any value other than 0x6
msgbox @NoOnix 0x2
release
end

#org @HaveOnix
msgbox @OhWow 0x2
giveitem 0xC7 0x1 0x0
setflag 0x200 // Setting a flag to make sure the player can't get infinite Metal Coats
release
end

#org @AlreadyDone
msgbox @Thanks 0x2
release
end

#org @Coolest
= I think Onix is the coolest!\nIf you show me one, I'll give\lyou something special.

#org @NoOnix
= Sorry, you don't have an Onix...

#org @OhWow
= Oh, wow, an Onix, thanks!\nHere you go, as promised!

#org @Thanks
= Thanks for showing me that Onix!


Hopefully that helps.
Sorry for the late reply, but holy muk, thank you! This was extremely helpful, I appreciate it so much!
Advertiser Content