You are not logged in.
Basically, there's something I'm doing in a Pokemon Crystal hack and I need to update a ram address everytime the player sends out a new Pokemon. I stumbled upon BattleMonEntrance: ; 3e40b, but it's only called when the player switches Pokemon, and not when a Pokemon is sent out after another one faints or when the first pokemon is sent out right after the battle starts. So basically, I'm looking for [one of] the routine(s) that load(s) the pokemon in these last two scenarios, in order to cover all possible ways of the player sending a pokemon (outside of baton pass).
Hopefully someone can help. Thanks in advance.
Off-hand I notice:
BattleMonEntrance: ; 3e40b ... ld a, [CurBattleMon] ld [CurPartyMon], a call Function3d581 call Function3da0d ... ; 3e459
PassedBattleMonEntrance: ; 3e459 ... ld a, [CurPartyMon] ld [CurBattleMon], a call Function3d581 call Function3da0d ... ; 3e489
Function3d581 is called when loading a new mon (this excludes the first mon an enemy sends out). Notably, it's called an extra time when an opponent is sending out a mon in shift mode (to get the name of the mon they're about to send out).
Function3da0d applies player-only stuff like badge stat boosts. I think that's the one you're looking for.
Hmm, are you sure? I set a breakpoint at PC=640b and I only got results when the pokemon was being loaded as a result of a switch, but not after a faint.
But 3da0d may be called more than once for the same pokemon, right? (I mean, I suppose it's called once per turn; whenever you attack). I was looking for a routine that is only called once per pokemon sent out by the player.
Anyway, let me explain briefly what I want this for, in case it helps.
I want that 'X items' (like X attack) can only be used once per pokemon at the same time (so for example if I use X attack on my totodile, I can't use another 'X item' until totodile is switched out or the battle finishes.
Thus, I modified the routine where the four X items point to so that they set ram address DEFF to 0x01, whenever they are used. When DEFF is 0x01, the item can't be used. For this reason, I need the DEFF to be reseted to 00 every time a new pokemon is loaded by the player (this assumes that opponents never use X items themselves, which is true).
I got everything working except for the fact that DEFF is only reseted when the player switches pokemon, as I worked over the battleMonEntrance routine. For this reason, I am looking for another routine that covers every other possibilitie of sending out a pokemon (except for baton pass). This is, I think, the only thing I need help with; on finding the apprpriate routine.
Hopefully, I have been clear enough.
But 3da0d may be called more than once for the same pokemon, right? (I mean, I suppose it's called once per turn; whenever you attack).
Once per mon.
If you don't want it to reset for Baton Pass, you want NewBattleMonStatus.