• 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] Add to variable/metadata upon encounter?

zephadus

Trainer upset about # of PKMN
  • 93
    Posts
    20
    Years
    I'm sorry for the vague title, I can't think of how else to sum up what I'm asking.
    Basically, whenever I encounter a Pokémon, whether it be wild, or in a trainer battle, I'd like to increase a variable by 1 for that specific Pokémon.
    So for example:
    I defeat 3 wild Pidgey.
    I encounter a Bird Keeper who sends out Spearow.
    I defeat Spearow, and he sends out Pidgey.
    His Pidgey defeats me.
    Variable [021] (Spearow) should read '1', and despite my loss, variable [016] (Pidgey) should read '4' (as I'm counting encounters, not wins).
    Of course, that would be a lot of variables if I do it for every Pokémon, so ideally I'd like it to be stored in metadata, but I've not a clue as how to do that.
    Anyone out there more knowledgeable than I and willing to point me in the right direction? :)
     

    Maruno

    Lead Dev of Pokémon Essentials
  • 5,286
    Posts
    16
    Years
    • Seen May 3, 2024
    Pokémon are recorded as "seen" when they're sent out in battle. What you want is much the same, except it increments a value rather than setting a boolean, and it shouldn't count if the Pokémon sent out belongs to the player (I presume). Have a look for pbSetSeen - note that you cannot tell inside that def whether the Pokémon belongs to the player or not; the simplest solution is to pass the battler's index into that def as a new parameter.
     

    zephadus

    Trainer upset about # of PKMN
  • 93
    Posts
    20
    Years
    That's quite a lot of jargon that I only half-understand...
    Code:
      def pbSendOut(index,pokemon)
        pbSetSeen(pokemon)
        @peer.pbOnEnteringBattle(self,pokemon)
        if pbIsOpposing?(index)
          @scene.pbTrainerSendOut(index,pokemon)
        else
          @scene.pbSendOut(index,pokemon)
        end
        @scene.pbResetMoveIndex(index)
      end
    I found this bit here at line 1357 in PokeBattle_Battle.
    I feel like somewhere in here I wanna put something with $game_variables[____] += 1, where the blank space would be some parameter telling me the Pokémon's ID.
    The only problem is that I'm kind of new to Ruby, and I'm not sure quite how all this code works.
    So far as I can tell, upon sending out a Pokémon, the game checks to set that Pokémon as "seen".
    It also seems to check whether it's your own Pokémon, or an opposing Pokémon, I think.
    Am I understanding this right?
    What should I do from this point?
     
    Back
    Top