The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Fan Games > Binary ROM Hacking
Reload this Page Script NPC position reverts to original even with map script

Notices
For all updates, view the main page.

Binary ROM Hacking Need a helping hand or just want to talk about binary ROM hacks? Get comments and answers to any ROM Hacking-related problems, questions or thoughts you have here.

Ad Content
Reply
 
Thread Tools
  #1   Link to this post, but load the entire thread.  
Old October 17th, 2020 (12:24 PM).
wcbvei234's Avatar
wcbvei234 wcbvei234 is offline
 
Join Date: Dec 2019
Posts: 19
I currently have two guards blocking the path out of Pallet Town in Fire Red. I have a variable in place so once the player receives his starter, the guards apologize for the blockade and step out of the way. My goal is to have them permanently be out of the way and no longer blocking the entrance to Route 1 after they initially apologize and move. I have the following script set (correctly) in the Pallet Town map script section:

Code:
#dynamic 0x800000

#org @start
compare 0x5007 0x1
if 0x1 call @position
end

#org @position
movesprite2 0x8 0x0B 0x02
movesprite2 0x9 0x0E 0x02
return
Seems simple, right? The 0x5007 variable is set to 0x1 once the player receives his starter. If it's set to 0x1, the guards should be permanently moved (by means of movesprite2) out of the way. I tried this code, and it just doesn't work. If I walk further down into Pallet Town (regardless of entering a building or not) or further up into Route 1, and the guards go offscreen, they move back to their original position and block the passageway when I return. I figured maybe their script was reset somehow? But the variable 0x5007 is still set to 0x1 because they give me the dialogue set in place after they move out of the way. I have the map script above ^ set as option 03 "On entering map/not on menu close." I tried the "Validates values" option 02, but that didn't seem to work either. Is there something I'm missing? Do I need to set some special value to the NPCs in AdvanceMap? My only other idea (that I'd be a little peeved in having to do so) is to fade the screen to black and remove the NPCs from the map entirely, but I sorta wanted them to be there permanently and have it feel natural and organic.

Entaro Ceraphenine, if you come to my rescue again, I'll have to add you on Discord or something for quicker help 😂 Thanks for reading! I appreciate your guys' help as always.
Reply With Quote
  #2   Link to this post, but load the entire thread.  
Old October 17th, 2020 (1:26 PM).
mcferaligatr's Avatar
mcferaligatr mcferaligatr is offline
 
Join Date: Nov 2018
Posts: 120
I can suggest using movesprite2 with the script event as well as type 3 level script, making sure that the movesprite2 command uses appropriate person id numbers of the npc's you're trying to move, deleting all existing scripts in Pallet Town, and possibly using another variable as I'm not certain but that variable may be overlapping some ram data. There are certain safe variables from 4011 to 40FF (even there are some unsafe exceptions, taking a look at the list would be recommended to avoid using unknown variables). I can also say that checking the compiled offset again wouldn't be a bad idea. Pallet Town by default has a level script that moves some npc's across the map, so that could probably be the culprit here.
Reply With Quote
  #3   Link to this post, but load the entire thread.  
Old October 18th, 2020 (1:05 AM).
Pyxal's Avatar
Pyxal Pyxal is offline
It's pronounced pixel.
 
Join Date: Jul 2019
Location: Pakistan
Age: 17
Posts: 987
Quote:
Originally Posted by wcbvei234 View Post
<snip>
Easiest way is to assign a person flag to a guard and just hidesprite them, then use setflag to permanently hide them.
__________________
Reply With Quote
  #4   Link to this post, but load the entire thread.  
Old October 18th, 2020 (3:28 AM).
Entaro Ceraphenine's Avatar
Entaro Ceraphenine Entaro Ceraphenine is offline
 
Join Date: Sep 2016
Location: Katones City
Gender: Male
Nature: Quiet
Posts: 48
There are a few things I can assume that might have gone wrong here. But mcferaligatr has really covered most of it.

Let's get the easy thing out of the way: variable 0x5007 is not safe, unless you are using CFRU. Try using one of the variables mentioned here: List of safe Vars and Flags
But mcferaligatr has already said this in short. 0x4011 - 0x40FF are safe to use.

Now, there is already a level script in Pallet Town that uses the movesprite2 command to move NPCs around. And I dont think FireRed ROM likes it when there are two level script of the same type in the same map. What you can do is either remove all the other existing scripts like mcferaligatr said (if you think the other level scripts are not important to be there) or merge your script with the existing one (if you think the other level scripts are important to be there). A script like:
Spoiler:
#dynamic 0x800000

#org @start
setworldmapflag 0x890
compare 0x5007 0x1
if 0x1 call @position
end

checkflag 0x291
if 0x1 call @snippet1
compare 0x4070 0x0
if 0x1 call @snippet2
compare 0x4070 0x1
if 0x1 call @snippet3
end

#org @position
movesprite2 0x8 0x0B 0x02
movesprite2 0x9 0x0E 0x02
return


#org @snippet1
checkflag 0x83E
if 0x0 goto @snippet4
compare 0x4070 0x1
if 0x4 goto @snippet4
setvar 0x4070 0x1
return

#org @snippet2
checkflag 0x291
if 0x1 goto @snippet5
movesprite2 0x1 0x5 0xF
spritebehave 0x1 0x7
return

#org @snippet3
setvar 0x4070 0x2
return

#org @snippet4
return

#org @snippet5
movesprite2 0x1 0xC 0x2
spritebehave 0x1 0x8
setvar 0x4002 0x1
return


The parts in the bold are your script and the rest is the default Pallet Town script. Compile it and replace the existing Level Script Type 03.

Another thing you need to remember is that Pallet Town has multiple types of Level Scripts, if you removed all of them for your own level script, then its fine. But if you decided to keep multiple types of level scripts, make sure you add/keep them in this order: Type 1 > Type 7 > Type 5 > Type 3 > Type 4 > Type 2 (Source: this video)
You can see this in Oak's Lab map. Type 3 script is script no. 0, Type 4 is script no. 1 and Type 2 is script no. 2.

Another thing I have noticed about movesprite2 command is that, the variable or the flag that you are using to condition of whether to the move the sprite MUST BE MANIPULATED OUTSIDE THE MAP. But I think you are okay in this regard, since you said 0x5007 becomes 0x1 when receiving the starter that takes place inside Oak's lab i.e. different map from Pallet Town's outside.

But if you are using something like, you get the starter and then you talk to the guards and they set 0x5007 to be equal to 0x1, then there might be a little problem and you might wanna rework some scripts.

That's all I got and sure, PM me in PokeCommunity, I'll give you my Discord ID if you want to get added xD
__________________
Reply With Quote
Reply

Quick Reply

Join the conversation!

Create an account to post a reply in this thread, participate in other discussions, and more!

Create a PokéCommunity Account
Ad Content

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 9:16 AM.