• 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.
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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] Event when a certain wild Pokemon is defeated

  • 72
    Posts
    6
    Years
    • Seen Jan 24, 2021
    Hello. I am trying to make a small script that runs when certain wild Pokemon is defeated.
    To clarify, when a wild Pokémon of a certain species is defeated, something happens.
    An example: When you defeat a wild Audino, all Pokémon in your party are healed.

    The codes below are simple versions of what I was trying to do. The goal is when a Pachirisu is defeated, the message "You caught a Pachirisu." will appear. If not, "You did not catch a Pachirisu." will appear instead. But I do not know how exactly to ask that. The code I have tried to make is either ignored or returns an error. I was wondering if anyone could tell me what I am doing wrong. The help is greatly appreciated.

    Code:
            if PBSpecies.getName(:PACHIRISU)
              pbDisplay(_INTL("You caught a Pachirisu."))
            else
              pbDisplay(_INTL("You did not catch a Pachirisu."))
            end

    Code:
            if pokemon.name = "Pachirisu"
              pbDisplay(_INTL("You caught a Pachirisu."))
            else
              pbDisplay(_INTL("You did not catch a Pachirisu."))
            end

    Code:
            if pokemon.species=(:PACHIRISU)
              pbDisplay(_INTL("You caught a Pachirisu."))
            else
              pbDisplay(_INTL("You did not catch a Pachirisu."))
            end
     
    EDIT: Fixed the order of arguments to isConst? based on Arachnee's response.

    Assuming that pokemon exists I guess you want
    Code:
    if isConst?(pokemon.species,PBSpecies,:PACHIRISU)
      pbDisplay(...) # Pachirisu.
    else
      pbDisplay(...) # Not pachirisu.
    end

    But if you're going to care about many species then I'd probably try writing it like this:
    Code:
    case pokemon.species
    when getConst(PBSpecies,:PACHIRISU)
      ... # Pachirisu
    when getConst(PBSpecies,:AUDINO)
      ... # Audino
    else
      ... # Something else.
    end
     
    Last edited:
    Thank you, mgriffin! That was definitely the correct method. It works completely fine now. Thank You!

    For anyone else who is interested, "pokemon.species" goes first in the isConst? arguments.

    Code:
    if isConst?(pokemon.species,PBSpecies,:PACHIRISU)
     
    Back
    Top