2018-06-24 07:09:41 -07:00
|
|
|
DoPoisonStep::
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPartyCount]
|
2015-11-11 20:38:57 -08:00
|
|
|
and a
|
|
|
|
jr z, .no_faint
|
|
|
|
|
|
|
|
xor a
|
2019-04-08 15:50:10 -07:00
|
|
|
ld c, wPoisonStepDataEnd - wPoisonStepData
|
|
|
|
ld hl, wPoisonStepData
|
|
|
|
.loop_clearPoisonStepData
|
2015-11-11 20:38:57 -08:00
|
|
|
ld [hli], a
|
|
|
|
dec c
|
2019-04-08 15:50:10 -07:00
|
|
|
jr nz, .loop_clearPoisonStepData
|
2015-11-11 20:38:57 -08:00
|
|
|
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurPartyMon], a
|
2015-11-11 20:38:57 -08:00
|
|
|
.loop_check_poison
|
|
|
|
call .DamageMonIfPoisoned
|
|
|
|
jr nc, .not_poisoned
|
2019-04-08 15:50:10 -07:00
|
|
|
; the output flag is stored in c, copy it to [wPoisonStepPartyFlags + [wCurPartyMon]]
|
|
|
|
; and set the corresponding flag in wPoisonStepFlagSum
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
2015-11-11 20:38:57 -08:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2019-04-08 15:50:10 -07:00
|
|
|
ld hl, wPoisonStepPartyFlags
|
2015-11-11 20:38:57 -08:00
|
|
|
add hl, de
|
|
|
|
ld [hl], c
|
2019-04-08 15:50:10 -07:00
|
|
|
ld a, [wPoisonStepFlagSum]
|
2015-11-11 20:38:57 -08:00
|
|
|
or c
|
2019-04-08 15:50:10 -07:00
|
|
|
ld [wPoisonStepFlagSum], a
|
2015-11-11 20:38:57 -08:00
|
|
|
|
|
|
|
.not_poisoned
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPartyCount]
|
|
|
|
ld hl, wCurPartyMon
|
2015-11-11 20:38:57 -08:00
|
|
|
inc [hl]
|
|
|
|
cp [hl]
|
|
|
|
jr nz, .loop_check_poison
|
|
|
|
|
2019-04-08 15:50:10 -07:00
|
|
|
ld a, [wPoisonStepFlagSum]
|
2015-11-11 20:38:57 -08:00
|
|
|
and %10
|
|
|
|
jr nz, .someone_has_fainted
|
2019-04-08 15:50:10 -07:00
|
|
|
ld a, [wPoisonStepFlagSum]
|
2015-11-11 20:38:57 -08:00
|
|
|
and %01
|
|
|
|
jr z, .no_faint
|
|
|
|
call .PlayPoisonSFX
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.someone_has_fainted
|
|
|
|
ld a, BANK(.Script_MonFaintedToPoison)
|
|
|
|
ld hl, .Script_MonFaintedToPoison
|
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.no_faint
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.DamageMonIfPoisoned:
|
2015-11-11 20:38:57 -08:00
|
|
|
; check if mon is poisoned, return if not
|
|
|
|
ld a, MON_STATUS
|
|
|
|
call GetPartyParamLocation
|
|
|
|
ld a, [hl]
|
|
|
|
and 1 << PSN
|
|
|
|
ret z
|
|
|
|
|
|
|
|
; check if mon is already fainted, return if so
|
|
|
|
ld a, MON_HP
|
|
|
|
call GetPartyParamLocation
|
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
|
|
|
or c
|
|
|
|
ret z
|
|
|
|
|
|
|
|
; do 1 HP damage
|
|
|
|
dec bc
|
|
|
|
ld [hl], c
|
|
|
|
dec hl
|
|
|
|
ld [hl], b
|
|
|
|
|
|
|
|
; check if mon has fainted as a result of poison damage
|
|
|
|
ld a, b
|
|
|
|
or c
|
|
|
|
jr nz, .not_fainted
|
|
|
|
|
|
|
|
; the mon has fainted, reset its status, set carry, and return %10
|
|
|
|
ld a, MON_STATUS
|
|
|
|
call GetPartyParamLocation
|
|
|
|
ld [hl], 0
|
|
|
|
ld c, %10
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.not_fainted
|
|
|
|
; set carry and return %01
|
|
|
|
ld c, %01
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.PlayPoisonSFX:
|
2015-11-11 20:38:57 -08:00
|
|
|
ld de, SFX_POISON
|
|
|
|
call PlaySFX
|
|
|
|
ld b, $2
|
2015-12-01 12:35:28 -08:00
|
|
|
predef LoadPoisonBGPals
|
2015-11-11 20:38:57 -08:00
|
|
|
call DelayFrame
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.Script_MonFaintedToPoison:
|
2015-11-11 20:38:57 -08:00
|
|
|
callasm .PlayPoisonSFX
|
2015-12-09 15:25:44 -08:00
|
|
|
opentext
|
2015-11-11 20:38:57 -08:00
|
|
|
callasm .CheckWhitedOut
|
|
|
|
iffalse .whiteout
|
2015-11-25 07:16:29 -08:00
|
|
|
closetext
|
2015-11-11 20:38:57 -08:00
|
|
|
end
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.whiteout
|
2019-03-10 13:39:31 -07:00
|
|
|
farsjump Script_OverworldWhiteout
|
2015-11-11 20:38:57 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.CheckWhitedOut:
|
2015-11-11 20:38:57 -08:00
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurPartyMon], a
|
2019-04-08 15:50:10 -07:00
|
|
|
ld de, wPoisonStepPartyFlags
|
2015-11-11 20:38:57 -08:00
|
|
|
.party_loop
|
|
|
|
push de
|
|
|
|
ld a, [de]
|
|
|
|
and %10
|
|
|
|
jr z, .mon_not_fainted
|
|
|
|
ld c, HAPPINESS_POISONFAINT
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall ChangeHappiness
|
|
|
|
farcall GetPartyNick
|
2015-11-11 20:38:57 -08:00
|
|
|
ld hl, .PoisonFaintText
|
|
|
|
call PrintText
|
|
|
|
|
|
|
|
.mon_not_fainted
|
|
|
|
pop de
|
|
|
|
inc de
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurPartyMon
|
2015-11-11 20:38:57 -08:00
|
|
|
inc [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPartyCount]
|
2015-11-11 20:38:57 -08:00
|
|
|
cp [hl]
|
|
|
|
jr nz, .party_loop
|
2018-02-22 08:13:29 -08:00
|
|
|
predef CheckPlayerPartyForFitMon
|
2015-11-11 20:38:57 -08:00
|
|
|
ld a, d
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wScriptVar], a
|
2015-11-11 20:38:57 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.PoisonFaintText:
|
2019-10-20 15:24:17 -07:00
|
|
|
text_far _PoisonFaintText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-11-11 20:38:57 -08:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.PoisonWhiteoutText:
|
|
|
|
text_far _PoisonWhiteoutText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|