Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2016-02-26 23:27:33

Fotomac
Member
Registered: 2015-10-25
Post 153/297

Poison glitch

I don't know if it happens all the time since I only tried it once in my test of the latest compile of the TCNS (Beta 2), but I just came across this strange glitch where when the enemy attacks a Poison-type with Poison Sting, after damage is calculated and the "not very effective" ("super effective" for dual-type Bug/Poison) message is shown, the "doesn't affect" message is then shown. I only intend for the "doesn't affect" message to be shown when a non-damaging poisoning move is used on a Poison-type or when any Poison-type move is used on a Steel-type. How do I make sure of that?

(BTW I intend to fix that glitch as early as Beta 2.1.)

Offline

#2 2016-02-27 04:00:46

Danny-E 33
Administrator
Registered: 2012-06-09
Post 936/1,026

Re: Poison glitch

By using BGB's debugger to trace the bug.


Red Hack: Pokémon Prototype

Total number of registered users: 7000+
Total number of active users: ~12

Offline

#3 2016-02-27 05:19:59

Fotomac
Member
Registered: 2015-10-25
Post 155/297

Re: Poison glitch

Right, well, here's the portion of the code that's going to be relevant here:

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 poison a poison-type target
    jr z, .versusPoison
    ld a, [hld]
    cp POISON ; can't poison a poison-type target
    jr z, .versusPoison
    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

.versusPoison, obviously, is supposed to point to the "doesn't affect" text, while .noEffect is supposed to point to the "didn't affect" text. Out of the two which currently direct to .versusPoison, does the one that should've stayed .noEffect (i.e. the one relating to damaging moves) go under [hli] or [hld]?

Offline

#4 2016-03-24 17:25:36

Fotomac
Member
Registered: 2015-10-25
Post 179/297

Re: Poison glitch

I've just isolated the problem. Now to get rid of that annoying "doesn't affect" message for when it's not supposed to appear...

Last edited by Fotomac (2016-03-24 17:28:05)

Offline

#5 2016-04-09 07:55:57

Fotomac
Member
Registered: 2015-10-25
Post 198/297

Re: Poison glitch

I was only partly successful; if a damaging-type Poison-type move hits a Pokémon with Poison as its primary type, the message appears, but not if the Pokémon has Poison as its secondary type.

Here's the piece of code we must focus on now:

.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

Offline

Board footer

Powered by FluxBB