• 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!
  • Which Pokémon Masters protagonist do you like most? Let us know by casting a vote in our Masters favorite protagonist poll here!
  • Red, Hilda, Paxton, or Kellyn - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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
    21
    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? :)
     
    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.
     
    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