The PokéCommunity Forums

The PokéCommunity Forums (https://www.pokecommunity.com/index.php)
-   Binary ROM Hacking (https://www.pokecommunity.com/forumdisplay.php?f=284)
-   -   Other How to add script event? (https://www.pokecommunity.com/showthread.php?t=361287)

matharoo January 14th, 2016 7:57 AM

How to add script event?
 
I am working on my first hack and am using FR.
I want to add a script, on which when the player walks, some things happen (applymovement to some npc and msgbox). I put a script event with the correct script but it didn't work. Nothing happened. Then I clicked on another script event (which is already there by the game) and I saw this is using a variable for it. So then I searched for safe variables and as I read in some thread, the safe ones are 0x4011 to 0x40FF. So I used 0x4020 and added a setvar command in the script so it doesn't happen again. It worked! It did. But... after my code in the script, the 'end' command got removed (ofc after I compiled it) and some other commands (something like comparebytetobyte and another one called nop1 and some more) took place. The code worked, but I think I must be messing with a variable that is already used that is causing this thing to happen in my script. I asked here because I don't think this should happen and i think this can do something wrong. I don't even know if I'm doing the right thing for putting a script event. I didn't change anything in AdvanceMap for the script (like unknown) I just changed the variable space.
I hope I find a solution here. Thanks. Sorry for thitlong post. :)

Vendily January 14th, 2016 3:55 PM

Quote:

Originally Posted by matharoo (Post 9075714)
I am working on my first hack and am using FR.
I want to add a script, on which when the player walks, some things happen (applymovement to some npc and msgbox). I put a script event with the correct script but it didn't work. Nothing happened. Then I clicked on another script event (which is already there by the game) and I saw this is using a variable for it. So then I searched for safe variables and as I read in some thread, the safe ones are 0x4011 to 0x40FF. So I used 0x4020 and added a setvar command in the script so it doesn't happen again. It worked! It did. But... after my code in the script, the 'end' command got removed (ofc after I compiled it) and some other commands (something like comparebytetobyte and another one called nop1 and some more) took place. The code worked, but I think I must be messing with a variable that is already used that is causing this thing to happen in my script. I asked here because I don't think this should happen and i think this can do something wrong. I don't even know if I'm doing the right thing for putting a script event. I didn't change anything in AdvanceMap for the script (like unknown) I just changed the variable space.
I hope I find a solution here. Thanks. Sorry for thitlong post. :)

Did you recompile on top of your old script? There might not be enough room.
Try to compile to a new spot in the rom and try that offset instead.

matharoo January 14th, 2016 8:57 PM

I did and XSE automatically assigned a new offset to my script so I used it. I think it might've done that because the previous offset didn't have enough memory, but ok I'll try using a bigger place. I'll find it in FSF using 512b needed than the default 256. Thanks.

matharoo January 14th, 2016 11:32 PM

That worked, now the code doesn't mess up.
Now I want to make an npc disappear permanently after it has done its job. How can I do that?
Using hidesprite doesn't work. It just resets to its original location (before applymovement). Using #raw 0x60 makes it invisible only for that time. Is there any good (written) tutorial for this or can I get help here? Thanks.

Le pug January 15th, 2016 2:01 AM

Quote:

Originally Posted by matharoo (Post 9076829)
That worked, now the code doesn't mess up.
Now I want to make an npc disappear permanently after it has done its job. How can I do that?
Using hidesprite doesn't work. It just resets to its original location (before applymovement). Using #raw 0x60 makes it invisible only for that time. Is there any good (written) tutorial for this or can I get help here? Thanks.

For the OW you want to get rid of, you need to give it a flag. So for FR the safe flags you can use are between 200-2FF. More info here: click
Here is where you'd put the flag for the OW:

So in the above image the flag is 372. So in order to hide the sprite permanently, you'd have to do:

#org @example
setflag 0x372
hidesprite 30
release
end

... as you can see in the Person event no. box, he's event 30. If you just put 30 without the 0x, it registers it as decimal and you don't have to convert it to hex (fun thing to know). So that is why I have it as "hidesprite 30"


You can expand the amount of safe flags to use in FR by applying this ASM here: click me.

matharoo January 15th, 2016 7:48 AM

Oh cool thanks. :)


All times are GMT -8. The time now is 2:30 AM.


Like our Facebook Page Follow us on Twitter © 2002 - 2018 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2016 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.

Acknowledgements
Use of PokéCommunity Assets
vB Optimise by DragonByte Technologies Ltd © 2023.