• 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.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Trading Card Game 2 protagonist in the poll by clicking here.
  • 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.

[Question] How do I check the opponent's type via code, with a branch for if it is Poison and a branch for if it's not?

  • 428
    Posts
    5
    Years
    My goal is to edit the code that runs when a Pokemon is poisoned, so it will check if the foe is Poison Type and replace the ordinary poison effect with Toxic Poison if this is true.

    def pbPoison(user = nil, msg = nil, toxic = false)
    pbInflictStatus(:POISON, (toxic) ? 1 : 0, msg, user)
    end

    I need to turn it into this

    def pbPoison(user = nil, msg = nil, toxic = false)
    If FoeType=Poison
    pbInflictStatus(:TOXIC)
    If FoeType!=Poison
    pbInflictStatus(:Poison)
    end

    When this code is functional, I will then proceed to make Toxic and the Toxic Orb inflict ordinary poison.

    This change to the code of Pokemon ensures Poison-types gain a unique niche as the ONLY types able to inflict toxic-poison, AND the type guaranteed to inflict it with ANY method they have to poison the foe (even by Tricking a Toxic Orb onto the foe), so you'll never have to experience a poison-type STAB move accidentally inflicting normal-poison when you wanted to toxic-poison the foe.
     
    My goal is to edit the code that runs when a Pokemon is poisoned, so it will check if the foe is Poison Type and replace the ordinary poison effect with Toxic Poison if this is true.

    def pbPoison(user = nil, msg = nil, toxic = false)
    pbInflictStatus(:POISON, (toxic) ? 1 : 0, msg, user)
    end

    I need to turn it into this

    def pbPoison(user = nil, msg = nil, toxic = false)
    If FoeType=Poison
    pbInflictStatus(:TOXIC)
    If FoeType!=Poison
    pbInflictStatus(:Poison)
    end

    When this code is functional, I will then proceed to make Toxic and the Toxic Orb inflict ordinary poison.

    This change to the code of Pokemon ensures Poison-types gain a unique niche as the ONLY types able to inflict toxic-poison, AND the type guaranteed to inflict it with ANY method they have to poison the foe (even by Tricking a Toxic Orb onto the foe), so you'll never have to experience a poison-type STAB move accidentally inflicting normal-poison when you wanted to toxic-poison the foe.

    Idk if this will really work in all situations, or at all, but I'd try adding this one line of code before the "pbInflictStatus" line in def pbPoison:
    Code:
    toxic = (user && user.pbHasType?(:POISON)) ? true : false

    This *should* make it so that the inputted user of the poison effect is checked for the Poison-type. If it has the type, the flag for Toxic is set to true, if not, it's set to false. However, this will not work in all situations. This is because not all Poison-inducing effects in the script check for the user. In which case, this script will have no type to check for, and will thus be ignored. A quick glance through the script seems to indicate that these specific situations are limited to: Synchronize, Toxic Orb, and Toxic Spikes. But there are likely more niche situations that are harder to determine.
     
    Back
    Top