![]() |
Var Mathematics For FireRed
In NPC scripting, there exist commands to add/subtract an integer value to a variable (AddVar an SubtractVar). However, these commands may be a little bit limited. It may be that you want to multiply or divide a var, or add two vars together. In that case, you can use these: What To Do First First, you will want to find two half-words of free RAM. It does not need to be permanent RAM (RAM that is saved with the game). However, you will need to know what number var that RAM corresponds to. I recommend NOT using the 0x8000+ temp vars, since then you will be unable to manipulate values stored into them. These routines use the vars 0x4074 and 0x4075 by default, but these can be changed in the following way. 1. Figure out the difference between the var you want to use and 0x4074. Keep in mind this is in hexadecimal. 2. Multiply that value by two. 3. Add (or subtract if your var is less than 0x4074) from 0x02026614. This is still in hexadecimal. You should then get the RAM address of the var you want to use. 4. Repeat for the second var if desired. 5. Change the addresses after .Var4074 and .Var4075. The Actual Routines The routines below perform the following operations: 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. AND 6. OR For the AND and OR operations, I'll explain them a little for those who are not familiar with them. If you AND two binary numbers, the resulting number has the bit equal to one if the corresponding bits of the input numbers are the same, and zero if they were different. For example, 1011 AND 1100 = 1000. For the OR operation, if both bits of the input numbers are zero, it returns zero. Otherwise it returns one. In other words, if one OR the other number has a bit equal to one, the resulting number's bit is set equal to one. For example, 0010 OR 1000 = 1010. Add Vars Spoiler:
Subtract Vars Spoiler:
Multiply Vars Spoiler:
Divide Vars Spoiler:
AND Vars Spoiler:
OR Vars Spoiler:
How To Use Them These are meant to be used in NPC scripts. You use them as follows: #org @Script setvar 0x8000 0xAAAA ' Whatever value you want setvar 0x8001 0xBBBB ' Whatever value you want setvar 0x4074 0x8000 setvar 0x4075 0x8001 callasm 0x8AABBCC+1 ' AABBCC is the offset where you inserted the routine. Add one for THUMB. ... The result is stored into LASTRESULT. The original vars are not changed by the routine at all. |
how did you edit the IV values for hidden power types?
|
Quote:
These super low prices that are offered for each item appear to actually be the internal item ID number for each thing, converted to decimal format. One Potion, for instance, costs $13. It's item ID value is 0xD. Anyone have any ideas what's going on here? Did I do something wrong? |
Can anyone please help me add the Everstone 100% chance nature inheriting mechanism to the IV inheriting posted by FBI ?
Spoiler:
|
Hi, there! I've been making Pokémon FireRed hack roms for some time now, but never got to understand ASM, so I have a few requests about problems I've been facing. First of all, I'm familiar with XSE scripts and hexadecial numbers and HxD (hex editor), but not with how ASM works. The furthest I've reached is executing my custom menus (normal XSE scripts) via a key item using the "use of select" option in complete item editor. However this only works in overworld mode... I've miserably failed to run anything custom in-battle. I know battle scripts are different than XSE scripts, and have also downloaded the battle script pro tool, but that's about it. I have the thumb ASM compiler too. Well, I should go to the point now.
I'll start with the biggest issue. If flag 0x301 is set then receive all Pokémon from trainers upon trainer defeat (thief mode) Now I have a few questions here. Is there a way to call an ASM routine every time a trainer has been defeated? (or a battle ends, for that matter?) Trainer party data is located at ram offset 0x0202402C, is this data automatically cleared upon battle finish? I would need this data to be taken and then given to the player in the same way givepokemon works. What I mean by this is, first use the player's party slots then send the remaining Pokémon to the PC. In other words I need the party at said address to be given to the player as is (save maybe bug fixes?) If this being done automatically is not possible then I can script every single NPC in the game a callasm. That'd be more work, but it'd still be doable without having to manually script every single Pokémon from every single trainer in the game via givepokemon, special(s) and JPAN's hacks. That's a lot of work to do, you got the idea. Plus, in such a way it'd be impossible to replicate the IVs (and EVs as well?) from the stolen Pokémon, since I can't know their values during battle. Again, I know nothing of ASM but I guess just copying data from one ram location to another must not be too hard to script. But that's not my only concern. I also need a way to make battles against 1 Pokémon, fully customizable except for moves (default attacks), that you can't run away from, that you can't catch the Pokémon by any means and that you earn an also customizable amount of price money for. I'm unsure as to whether I can already do this with what's already on the internet. I used to "do this" by creating 386 new trainers with a single Pokémon each, but that's a lot of work to do and also "ugly" if you get my meaning. Unprofessional. Last but not least, we hear a lot about XSE scripts calling ASM, but what about it in reverse? Is it possible? (Guessing it is, since "virtually anything" is possible with ASM) I ask this because I want to change the exit option of the start menu to one that runs my XSE script with custom multichoice menus and submenus, instead of having to use a key item to be able to run the script from anywhere. Or even better, cancel button select "register" feature and call my script whenever select is pressed (without a custom item) Is it possible? Or even better, if I'm allowed to request, whenever you press the L and R buttons both at the same time in overworld mode (I have already disabled the annoying help system that takes priority over everything else, but had no luck with JPAN's key scripts nor walking scripts, changed default game settings as well) Thank you very much in advance for your help and please have a nice day ^^ If someone could lend me a hand with JPAN's key scripts and/or walking scripts, that would be a great plus. Edit: Oh, I almost forgot, JPAN's species changer leaves the name intact so I'd need code to set a Pokémon name to the default for its species, too. Edit2: Oh my God, I can't believe it but I managed to find the pointer to the script that runs when select is pressed and no item is registered, it's at offset 0x10ADA8! |
Quote:
Edit: After some more testing I found out neither of them worked because I was using a variable under 0x8000.. |
Nature Changing Before I begin, I should mention that this only works for FireRed at the moment. This is because it uses the Lustre stat, which in FireRed is unused but in Emerald is not. If you can find another stat to use, (or you don't have contests in your Emerald hack), then you can use this.Offsets listed here are for FireRed, though, so keep that in mind if you decide to port it. Anyway, without further ado, I present Nature Changing! How Does It Work? Skip this if you don't care about the behind the scenes stuff. Basically, this hijacks the GetNature function. It first checks the Lustre stat of the Pokemon in question. If it's equal to zero, then it gets the Nature form the PID as usual. If it's not zero, then it uses the Lustre value as the Nature, effectively changing the Pokemon's Nature without messing with the PID (and potentially messing up other stuff like the Pokemon's gender, Shininess, etc.). This does mean you can't set the Nature to Hardy, but this is not that big of a deal since there are other neutral Natures you can use. The Main Event I have written an instruction manual that explains how to use the hack in detail. It also contains links to download everything.The link presented below is the link to download the folder with the Instruction Manual and all the routines. Not every routine in the folder is one you need to insert, as there are a couple of optional add-ons to make changed Natures compatible with other hacks. Download: Here! |
Quote:
|
Quote:
A Timer System This is mainly for Fire Red, but it could also work for Emerald if you have enough Free RAM. More on that as we go.Anyway, this is a way to allow yourself to have timed events in Fire Red. As you may already know, FireRed does not have a Real Time Clock like Ruby/Sapphire/Emerald does. It does, however, have an internal clock that keeps track of how long you have been playing the game. You could, if you wanted, try to use it to have timed events. For example, if you wanted to have something occur every ten minutes, and you knew the RAM for where the time you've been playing is, then you could theoretically do something like this:
This is obnoxious for a variety of reasons. One, it kind depends on having a script run to end the event. Two, what happens if you've somehow been playing for 999 hours and 59 minutes. Then all your timed events break. Sure, that is a ridiculously long time, but still. Then, I came across a few hacks that other people had made, which when brought together, opened a whole new world for me. What You Need Before we get started, there are a few things that you will need to have in your game first.
Now, you may be wondering, what on Earth is this dubious, unnamed patch and what on Earth is it doing to my ROM? The answer to that is is disables the "Previously On Your Quest" feature (the little slideshow that happens when you boot up the game). Now why would this be required for a Timer System? The answer is that it frees up a TON of RAM. Like seriously, a TON. Like sooooooooo many bytes of RAM it's ridiculous. The best part? This RAM is saved by the game. Basically, if you want to expand your bag size, you don't need to use JPAN's Save Block anymore. If you have a hack in progress, this is objectively the better way to free up RAM because now you don't need to restart any save files. In fact, I would just do this anyway, unless you REEEEEEALLY need the "Previously On Your Quest" thing for some reason. What To Do First, you will need to create a table. This table will have all the RAM Addresses of all the timers that you will want to use. You are really only limited by the amount of free RAM you can use for Vars. You could have one timer, or 100! I personally have 96. Each entry of the table is four bytes long and is simply a pointer to the RAM addresss. If you want some help with figuring out what RAM addresses to use, click on the spoiler. The table needs to be terminated with FF FF FF FF. Spoiler:
If you are lazy and you applied the patch above, then you can use this table. It has 100 timers (you can use only part of it if you need less). It starts at 0x0202752C and ends at 0x020275F4. In Var terms, this is 0x4800 to 0x4864. Spoiler:
The second table you will need to insert is a table that has the time limits for all your timers. Each entry is a half-word (two bytes long) and you will need one for each timer that you have in the previous table. There are two options you have for each entry. If you enter in a number other than 0xFFFE, then it will function as a typical timer. For example, if you set it to 0x5, then after five minutes, it will be reset. If you use 0xFFFE, then it turns your timer into a stopwatch. This will make the timer keep going until it reaches 0xFFFF minutes. How long is that? 0xFFFF = 65,535 minutes = 1092.25 hours = 45.5 days = long enough that you probably won't get to that point. Okay, now you're ready to insert this routine somewhere and then add a pointer to it in the Minute Routine table (see FBI's Minute Routine post). Add the addresses of the tables after where it says .VarRAMTable and .TimeLimits. Advance Timer Routine Spoiler:
How To Use Now that we have it all inserted, how do we use it? In order to start a timer, just set the corresponding Var equal to 0x1. If it's a timer, the Var will reset itself when it reaches the limit. If it's a stopwatch, you will have to set it back to zero yourself.Here's an example script showing the basics. It uses the Subtract Var routine that I linked above. In the script, the player is asked if they want some Lemonade. If they accept, they are given a Lemonade item and the timer is set. They can come back after fifteen minutes and get another. If they talk to the NPC before 15 minutes have elapsed, the NPC will tell the player how long they have to wait. Note that this is fifteen minutes of in-game time. Turning off/pausing the game and coming back fifteen minutes later will not count. Spoiler:
Ideas Here are some ideas of what you can use this for.
|
Heyo, i really like the 80x80 Mugshot Routine jiangzhengwenjzw has made and try atm to make it work on emerald, but unfortunately, i couldn´t achieve this.
I already tried to research the offsets for emerald but i couldn´t find the correct offsets for this. So i would like to ask for some help. Can somebody of you help me with the routine, please? It would be awesome, because my knowledge is not the greatest. I also searched a lot on google, but the results, i found, aren´t really useful. |
The following development is done by DoesntKnowHowToPlay, and I have no part in it. This has been re-posted as the original link had died.
[FR] Displaying IV's on the stat screen A small piece of ASM that allows you to view IV's in the Pokémon stat screen. • Step 1 - Image insert First, insert the following image using NSE or TileMolester. Remember the address where you put it: Spoiler:
• Step 2 - Actual ASM Next you will need to insert the following ASM. It doesn't matter where, but do remember where you put it. Code:
Replace the 0x08XXXXXXwith the address of the image you just inserted (no +1 or reverse needed). • Step 3 - Byte changes
Ending notes With that, you should be good to go. In typical Pokémon fashion, this code does not give you the specific values; it instead gives you a unique two-value range. If you want to change that it's rather easy; cut every line starting with lsr in the code and reassemble it, then adjust the image so it has 32 meaningful values instead of 16. Credits DoesntKnowHowToPlay - Actual code, image Lunos - He did the actual Google cache magic too find it Again, this is done by DoesntKnowHowToPlay, and it is not done by me. Any credit should go DoesntKnowHowToPlay, and not me. |
Hey Upsurge,
First, thanks for the feedback at the other thread. Second, I have some questions (I told I was green)... 1) The image you kindly provided was saved at 71C000 (used Free Space Finder to find this spot). Should I replace the XXXXXX in your routine as 0x0871C000 or as 0x71C000? I guess it is the first option but I think it is best to ask. 2) I've copied your routine using Notepad++ and saved as IVRanking.asm but I have no idea about what I do with this file. So, I used a Thumb to turn this .asm into a .bin, opened this .bin file and my rom using HxD and pasted the bin's code inside the ROM starting at 71B500, I think this covers this step - let me know if I'm wrong, please. 3) Quote:
Thanks in advance. |
Quote:
1) This image was by DonestKnowHowToPlay, and yes, like this: 71C000. As an example, the routine would become: Spoiler:
2) Yes, it covers this step. To automagically insert routines into your ROM, use this tool. 3) Basically you go to address's 0x137BF0 and 0x137BE4 in any hex editor, and replace (Ctrl+B) them with the said bytes. |
Thanks for linking the tool, this will make my life easier in the future, I suppose.
Quote:
In your example 0x800000 became 00 80 08 and that is the part that I'm failing to understand. Can you please explain this further? My case is 71B500, would the final input be 00 49 08 47 01 00 71 B5 08? Again, thanks for taking the time to guide me through this. |
Quote:
|
1 Attachment(s)
Quote:
Looks like it is almost done but apparently I messed up somehow. The attached image shows the ranking boxes are there but no value inside though. Edit: This was how I've inserted the image NSE -> Load ROM -> Open Sprite -> Selected the one from the image above -> File -> Insert -> Image Data -> FreeSpaceFinder (checking from the beginning of the ROM and telling the size is 2048 bytes) -> 71C000 - Save It is working perfectly, I was dumb and using an old backup without the inserted image. Thanks for guiding me through this. Cheers! |
Does anyone know how to alter the ASM routine to use a 256x8 image instead of a 128x32 one?
Thanks! |
Quote:
I made all the changes but I can still sell TMs (they are reusable already). On top of your changes I've used HexManiacAdvance to alter the Mystery Byte of TMs to "1" (the same way that HMs are displayed). I'm using CFRU, by the way, but didn't set the flag for reusable TMs while installing that - everything achieved was through this thread (so far: reusable and no number display). Thanks! |
modulate experience with two scripting vars
https://cdn.discordapp.com/attachments/642222929312088065/756675053831323708/help.gif take your experience and multiply it by the "var numerator" and then divide it by the "var denominator" strongly suggest using higher numbers, i.e. if you want a 60% experience thing then set the numerator to 60 and the denominator to 100 so that the processor generates slightly more accurate numbers also make sure that you can't really get more than about 56,000 experience, as that causes interesting errors credit me and akamethebulbasaur for fire red: Spoiler:
|
not to double post but
give your opposing trainers evs and ivs based on a var each https://cdn.discordapp.com/attachments/642222929312088065/757336539675230296/help.gif this primarily to make difficulty hacks where there can be multiple difficulties put a value in one var that you want the opponents ivs to be and another value in another var that you want your opponent's evs to be (and yes, all of them will be the same) the pokemon has to have just a custom item (at least that check mark ticked in your favorite trainer editor) then all of their values will be set. custom moveset doesn't have to be defined :P pastebin right here credit me and doesntknowhowtoplay for fire red: Spoiler:
EDIT: new and improved! only needs you to check the custom item instead of going all in on the moveset too |
Quote:
While I know the CFRU engine exists and likely has these elements, I'm not looking to completely overhaul the game or re-do everything to use that base. I'm also unsure if these could be extracted from CFRU or not. My thinking is that the routines in the quoted post have not been written for FireRed, and a port of them are what I'd need. If someone out there is able to help me with this, please reach out to me on Discord or reply here. Thank you! :) |
Quote:
|
Quote:
- make the trainer's pokémon have a custom held item (moveset optional) - insert the routine - in any script, set the variables that you chose to the evs and ivs you desire i recommend using vars from 0x4012-0x40FF, or if you don't want to clean the rom of its scripts then 0x40C0-0x40FF si quieres un entrenador que tiene evs y ivs que cambian con dificultad, pues necesitas - hacer que el pokemon del entrenador tiene un objeto (moveset no es necesario) - insertar la rutina - en un script, carga las variables que escoges para tener los evs y los ivs a los valores que deseas recomiendo que uses vars desde 0x4012-0x40FF, o si no quieres borrar la rom de sus scripts 0x40C0-0x40FF |
It's been a long time since the main post was updated, so after a few hours I finished to update the index for you to easily find any ASM routine posted in this thread.
If a link is not properly working or I missed a routine feel free to PM me or any mod to add it to the index |
Quote:
Quote:
for fire red: Spoiler:
EDIT: added species requirements and now it doesn't crash wholly tested now basically EDIT: updated it to include gen 7's soul dew updates. note that it can't use the same held effect as the normal soul dew |
| All times are GMT -8. The time now is 8:46 AM. |
![]()
© 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.