• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • 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
6
Years
  • Age 34
  • 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
 
188
Posts
9
Years
  • Age 39
  • Seen Jan 21, 2024
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:
29
Posts
6
Years
  • Age 34
  • Seen Feb 8, 2024
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:
 
188
Posts
9
Years
  • Age 39
  • Seen Jan 21, 2024
It'll be even easier when you involve the other stats as they are not separated by category.
 
Back
Top