• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Foul Play/variation

  • 29
    Posts
    7
    Years
    • Seen Feb 8, 2024
    I may be late to the party, but has anybody figured out how to properly code Foul Play? In my version of Pokemon Essentials (which I think is not too old) it says it's handled in a Super Class but I can't find it. I'm trying to find the code so I could switch it from instead of using the opponent's attack stat it uses the attacker's defense stat in the calculation instead of it's own attack stat. Basically a move uses the defense stat and any modifiers of the defense stat, so a Pokemon that uses Iron Defense then the move does more damage, instead of a Swords Dance boost.

    I hope I didn't confuse anybody lol
     
    Locate this code in PokeBattle_Move, pbCalcDamage:
    Code:
        if @function==0x121 # Foul Play
          atk=opponent.attack
          atkstage=opponent.stages[PBStats::ATTACK]+6
        end
        if type>=0 && pbIsSpecial?(type)
          atk=attacker.spatk
          atkstage=attacker.stages[PBStats::SPATK]+6
          if @function==0x121 # Foul Play
            atk=opponent.spatk
            atkstage=opponent.stages[PBStats::SPATK]+6
          end
        end

    Add the following immediately after it:
    Code:
        if @function==0x[COLOR="Blue"]nnn[/COLOR] [COLOR="Green"]# Foul Play Defense variant[/COLOR]
          atk=attacker.defense
          atkstage=attacker.stages[PBStats::DEFENSE]+6
        end
        if type>=0 && pbIsSpecial?(type)
          atk=attacker.spatk
          atkstage=attacker.stages[PBStats::SPATK]+6
          if @function==0x[COLOR="Blue"]nnn[/COLOR] [COLOR="green"]# Foul Play Defense variant[/COLOR]
            atk=attacker.spdef
            atkstage=attacker.stages[PBStats::SPDEF]+6
          end
        end
    Change the code in blue to your move's function code.
     
    Last edited:
    Ok thanks man, I tried it out and it seems to work the way it's supposed to. Now I should be able to make more variants involving the other stats

    :nod:
     
    It'll be even easier when you involve the other stats as they are not separated by category.
     
    Back
    Top