Skeetendo

’Cause all games were better on the GBC

You are not logged in.

  • Index
  • → Help/Question
  • → [pokered] Some confusion adding Stat Increase side-effects

#1 2017-03-08 03:44:53

KeiTaRo
Member
Registered: 2015-12-05
Post 32/56
Website

[pokered] Some confusion adding Stat Increase side-effects

from Gen 2 onwards, attacks like Steel Wing could have a small percentage chance to increase a stat by one stage. I have had some experience with adding new effects, by modifying the stat decrease side effects to include custom percentages outside of the normal odds. Here is an example of how I did that:

First, I started by making a new effect, ACCURACY_DOWN1_SIDE_EFFECT, using StatModifierDownEffect. Then I changed the code for one of the routines in StatModifierDownEffect as such:

.statModifierDownEffect
    call CheckTargetSubstitute ; can't hit through substitute
    jp nz, MoveMissed
    ld a, [de]
    cp ACCURACY_DOWN1_SIDE_EFFECT  ; Added this and line below, for a side effect with 50% odds of an Accuracy decrease, aka Octazooka
    jr z, .accuracySideEffect1  ; I made it specifically for accuracy, in this example. Original code is below this line.
    call BattleRandom
    cp $55 ; 85/256 chance for side effects
    jp nc, CantLowerAnymore
    ld a, [de]
    sub ATTACK_DOWN_SIDE_EFFECT ; map each stat to 0-3
    jr .decrementStatMod

I then created the routine  .accuracySideEffect1

.accuracySideEffect1
    call BattleRandom
    cp $80 ; 128/256 chance for side effects
    jp nc, CantLowerAnymore
    ld a, $4 ; <-- manually load the value for "accuracy"
    jr .decrementStatMod

as you can probably tell, this was basically copied wholesale from the existing code with slight modifications. And, I might add, it worked perfectly! I was hoping that adding a side effect to INCREASE a stat as a side effect would work similarly, but the routines for StatModifierDownEffect and StatModifierUpEffect, while very similar, seem to have some key differences that I can't quite figure out. I did a test by modifying the code as such:

.statModifierUpEffect
    ld a, [de]
    cp DEFENSE_UP_SIDE_EFFECT ; I added this line, and this new effect
    jr z, .defenseUpSideEffect ; this routine should have a 10% chance of increasing your defense, like Steel Wing
    sub ATTACK_UP1_EFFECT
    cp $8
    jr c, .incrementStatMod
    sub ATTACK_UP2_EFFECT - ATTACK_UP1_EFFECT ; map +2 effects to equivalent +1 effect

So far this seemed straightforward...so here is my defenseUpSideEffect code:

.defenseUpSideEffect
    call BattleRandom
    cp $1a ; 26/256 chance for side effects
    ld a, $1 ; loads value for defense manually
    jr .incrementStatMod

This KIND of works, but not really. The attack works and if I remove the two randomization lines at the top for testing purposes, does increase the stat every time....but it seems to be sharply raising it instead of raising it by 1 step. It also is causing the animation to trigger a second time after damage is dealt. Also, I feel like I probably missed something critical, like a check for if you already went up 6 stages. Either way, this seems to be working differently than the decrement code, and I am pretty sure I'm doing this wrong. I really just thought it would be as simple as a few values reversed. I'm stumped. Could someone perhaps better explain to me how the StatModifyerEffectUp code is supposed to be working, and why it seems to work so differently from StatModifyerEffectDown? How would I go about adding a side effect that increases the user's stats? And lastly, how would I go about raising more than one stat at the same time, such as how Ancient Power does it? (to my understanding, the stat to raise is passed through "C", which can obviously only take one value at a time) Ideally, I want to eventually have Metal Claw (10% attack boost), Steel Wing (10% defense boost), and Ancient Power (10% EVERYTHING boost) functioning as they are meant to.

edit: also, not ultra important, but noticing that the default odds for a stat-down side effect are listed as $55 (85/256, or...33% or so?), whereas I had always thought they had 10% odds by default...is the game just calculating this differently than I'm understanding (and thus, leading my later values for custom odds to be wrong) or am I just mistaken and it's always been 33%?

Last edited by KeiTaRo (2017-03-08 19:58:17)

Offline

#2 2017-03-08 04:53:40

Fotomac
Member
Registered: 2015-10-25
Post 289/332

Re: [pokered] Some confusion adding Stat Increase side-effects

I'm having a similar problem, except mine sees the stat rising more than six times per battle only for it to reset to the lowest stage on the seventh time.

Offline

#3 2017-03-28 23:50:47

Crystal_
Member
From: Spain
Registered: 2012-09-16
Post 415/450
Website

Re: [pokered] Some confusion adding Stat Increase side-effects

I don't remember exactly why but it's because the effect handler is called twice. In turn, this makes the animation play twice as well. I remember someone had a similar issue and I was able to find the solution but by now I've mostly forgotten the red/blue battle logic. Anyway, it comes to mind that the effect might need to be added to the SpecialEffects array at the top of core.asm, but if that doesn't work, use a debugger to set a breakpoint at JumpMoveEffect or at your move effect handler to see where does the second call come from.

For multiple stat-affecting effects you can start by creating a new move effects that straight up calls multiple stat up/down handlers and see what needs to be adjusted from there, if anything. Not expanding more since this thread is 20 days old and you may have already found solutions anyway.

Last edited by Crystal_ (2017-03-28 23:52:01)

Offline

  • Index
  • → Help/Question
  • → [pokered] Some confusion adding Stat Increase side-effects

Board footer

Powered by FluxBB