Update thaw chances and sleep turns to generation 7 - pret/pokecrystal GitHub Wiki

Update thaw chances and sleep turns to generation 7

Sleep turns in Crystal are determined in BattleCommand_SleepTarget:

        ld b, SLP_MASK
	ld a, [wInBattleTowerBattle]
	and a
	jr z, .random_loop
	ld b, %011

.random_loop
	call BattleRandom
	and b
	jr z, .random_loop
	cp SLP_MASK
	jr z, .random_loop
	inc a
	ld [de], a
	...

When determining how many turns to sleep, first it loads %0111 (SLP_MASK) as the default sleep mask, but in the battle tower the mask will be 3. After loading the correct bitmask, then it will generate a random 8 bit number, and then and it with the mask, so that the random number is capped at 7 or 3. If it is 0 or 7 (which is SLP_MASK), it will go back and regenerate the random number. Then it will increment it so that the sleep turns are between 2-7, but this is likely because on the turn its used the sleep counter will go down anyways.

To update the sleep turns to generation 7, change the following:

-       ld b, SLP_MASK
-	ld a, [wInBattleTowerBattle]
-	and a
-	jr z, .random_loop
	ld b, %011

.random_loop
	call BattleRandom
	and b
	jr z, .random_loop
-	cp SLP_MASK
-	jr z, .random_loop
	inc a
	ld [de], a
	...

This makes sleep in generation 2 much less annoying by making the sleep duration 1-3 turns.

Defrost turns are handled in core.asm under handledefrost. Each turn a pokemon is frozen there is a 10% chance to defrost.

        call BattleRandom
	cp 10 percent
	ret nc
	xor a
	ld [wBattleMonStatus], a

To update it to later generations, change 10 percent with 20 percent for both .do_enemy_turn and .do_player_turn

.do_player_turn

        ...

        call BattleRandom
-	cp 10 percent
+       cp 20 percent
	ret nc
	xor a
	ld [wBattleMonStatus], a
       
        ...

.do_enemy_turn

        ...

        call BattleRandom
-	cp 10 percent
+       cp 20 percent
	ret nc
	xor a
	ld [wEnemyMonStatus], a