PoisonEffect: ; 3f24f (f:724f)
ld hl, wEnemyMonStatus
ld de, wPlayerMoveEffect
ld a, [H_WHOSETURN]
and a
jr z, .poisonEffect
ld hl, wBattleMonStatus
ld de, wEnemyMoveEffect
.poisonEffect
call CheckTargetSubstitute
jr nz, .noEffect ; can't posion a substitute target
ld a, [hli]
ld b, a
and a
jr nz, .noEffect ; miss if target is already statused
ld a, [hli]
cp POISON ; can't posion a poison-type target
jr z, .versusPoison
ld a, [hld]
cp POISON ; can't posion a poison-type target
jr z, .noEffect
ld a, [de]
cp POISON_SIDE_EFFECT1
ld b, $34 ; ~20% chance of poisoning
jr z, .sideEffectTest
cp POISON_SIDE_EFFECT2
ld b, $67 ; ~40% chance of poisoning
jr z, .sideEffectTest
push hl
push de
call MoveHitTest ; apply accuracy tests
pop de
pop hl
ld a, [wMoveMissed]
and a
jr nz, .didntAffect
jr .inflictPoison
.sideEffectTest
call BattleRandom
cp b ; was side effect successful?
ret nc
.inflictPoison
dec hl
set 3, [hl] ; mon is now poisoned
push de
dec de
ld a, [H_WHOSETURN]
and a
ld b, ANIM_C7
ld hl, wPlayerBattleStatus3
ld a, [de]
ld de, wPlayerToxicCounter
jr nz, .ok
ld b, ANIM_A9
ld hl, wEnemyBattleStatus3
ld de, wEnemyToxcCounter
.ok
cp TOXIC
jr nz, .normalPoison ; done if move is not Toxic
set BadlyPoisoned, [hl] ; else set Toxic battstatus
xor a
ld [de], a
ld hl, BadlyPoisonedText
jr .asm_3f2c0
.normalPoison
ld hl, PoisonedText
.asm_3f2c0
pop de
ld a, [de]
cp POISON_EFFECT
jr z, .asm_3f2cd
ld a, b
call PlayBattleAnimation2
jp PrintText
.asm_3f2cd
call PlayCurrentMoveAnimation2
jp PrintText
.noEffect
ld a, [de]
cp POISON_EFFECT
ret nz
.didntAffect
ld c, 50
call DelayFrames
jp PrintDidntAffectText
.versusPoison
ld c, 50
call DelayFrames
jp PrintDoesntAffectText