• 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] Event when a certain wild Pokemon is defeated

72
Posts
5
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
     
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    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:
    72
    Posts
    5
    Years
    • Seen Jan 24, 2021
    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