You are not logged in.
Is there a way to check level of player' s pokemon?
I only found this
003F Check level of Pokémon; 1 Pokémon needs to have at least the given level
What I need is player can only use pokemons whose level are under the given value in some battles.
So I'll need to check level first.
Sorry for my poor English :P
Last edited by bobie (2012-04-22 09:15:00)
That code (0F 3F 00) doesn't work properly in a situation like this.
You'll have to do it manually; (either with assembly or) by using code 19 (Copy variable code1).
Basically, here is Pokemon Gold RAM Map.
By taking a look at the RAM Map, you'll notice that the levels of the pokemon in your party are stored in addresses DA49, DA79, ..., DB39.
What you've gotta do is to make the script jump to another main script of this kind:
19 22 DA 06 06 [pointer] 06 05 [pointer] 06 04 [pointer] 06 03 [pointer] 06 02 [pointer] 06 01 [pointer]
The script above checks the byte in RAM address DA22 (with code 19 22 DA), 06 AA (AA = 01, 02, ..., 06) checks the value of the byte in RAM that was loaded there from DA22. If the byte is for example 06 (= 6 pokemon in party), the main script is followed by 19 39 DB 0B XX.
If the value is for example 02, the main script is followed by 19 79 DA 0B XX.
So basically this is the next command set that's gone through:
19 39 DB 0B XX yyyy...19 79 DA 0B XX yyyy 19 49 DA 0B XX 03 zzzz
0B XX stands for checking whether the value that was moved with command 19 to RAM is bigger than XX.
If it is, the script is continued by following the pointer yyyy --> "I'm sorry but at least one of your pokemon has higher level than XX..."
If 03 zzzz is reached, the script will continue interpreting after pointer zzzz. How we get here is by checking the number of pokemon in party, comparing their level values to the wanted level value XX and if no pokemon is at that level or more, we get here.
Last edited by Miksy91 (2012-04-22 10:51:33)
Thanks for your exhaustive reply!!
It works very fine!
By the way, is it possible to change this to a function?
It will be more convenient if so. :)
Glad I could help :)
I'm not sure about being able to change it into a function or not - coding it would be something I don't wanna think of doing :D
Why are you doing such complicated things?
Just have the following:
A flag for every special trainer (you have to have a flag anyway)
Up to 7 special trainers per map that use bit flags 0x0000 - 0x0006 instead of the actual flags reserved for them.
Then have the check once in the map header and set flags 0x0000 - 0x0006 accordingly.
For instance, Trainer A is special in that way, that he requires at least one level 60 Pokemon. Have his event structure check for flag 0x0000 (1 = beaten, 0 = not beaten). Use flag 0x06DE for his actual status (1 = beaten, 0 = not beaten). When the player enters the map, check for level 60 in the header, set 0x0000 when a) no Poke is available or b) 0x06DE is set (the trainer was actually beaten before). Change the script after the trainer is beaten to set flag 0x06DE. Change his post-beaten dialog to check for the actual flag 0x06DE and include different text whether the trainer was actually beaten or the player's Pokemon are just too weak.
You will have a special trainer like you desire. The only thing I'm currently unsure about is, if you need to do a map reload at the end of the trainer script to make sure flags 0x0000 - 0x0006 were not reset after you exited the trainer fight. However, I think they shouldn't be. If that happens to be the case (which, again, it shouldn't), you will have to sacrifice an additional flag and use it instead of the 0x0000 - 0x0006 range flag.
Last edited by Tauwasser (2012-04-22 22:49:37)