• 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] Issues with encounter method (16.2)

  • 465
    Posts
    8
    Years
    • Seen Jun 17, 2024
    So been trying to set up headbutt tree encounters like in HGSS i've got the code for them to trigger all working its the encounter modifier side thats causing issues;

    so the encounters scale to the parties level (with some randomness) and that part works fine; however
    i'm trying to add code for the game to detect evolutions and evolve them;
    Code:
    Events.onWildPokemonCreate+=proc {|sender,e|
      pokemon=e[0]
      terrain=Kernel.pbFacingTerrainTag
      if PBTerrain.isHeadbuttable?(terrain) && 
          !pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
        newlevel=pbBalancedLevel($Trainer.party) - 4 + rand(5)   # For variety
        newlevel=1 if newlevel<1
        newlevel=PBExperience::MAXLEVEL if newlevel>PBExperience::MAXLEVEL
        pokemon.level=newlevel
        pokemon.level=newlevel
        pokemon.calcStats
        pokemon.resetMoves
        terrain=Kernel.pbFacingTerrainTag
        if PBTerrain.isHeadbuttable?(terrain) && 
            !pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
          evos=pbGetEvolvedFormData(pokemon.species)
          if evos && evos.length>0
            species=evos[rand(evos.length)][2]
            newspecies,newform=pbCheckEvolution(pokemon)
            #newspecies,newform=pbGetSpeciesFromSpecies(species)
            level=pbGetMinimumLevel(species)
            level=[level,pokemon.level].max
            #level+=rand(5)
            pokemon.species=newspecies
            pokemon.form=newform
            pokemon.level=level
            pokemon.name=PBSpecies.getName(newspecies)
            pokemon.calcStats
            pokemon.resetMoves
          elsif evos && evos.length==0 # no more evolutions
            for i in 0...6
              pokemon.iv[i]=31
            end
            pokemon.calcStats
          end
        end
      end
    }

    its based off another code (originally for 17.2 and downscaled to 16.2)

    however the issue isn't evolving; as seen here
    [PokeCommunity.com] Issues with encounter method (16.2)

    [PokeCommunity.com] Issues with encounter method (16.2)


    the pokemon can evolve fine its when they cant or dont evolve is the issue; with that latest code; this is the error i get;
    Code:
    Exception: Errno::EINVAL
    Message: Invalid argument - Data/attacksRS.dat
    File_Mixins:65:in `pos='
    File_Mixins:65:in `getOffset'
    PokeBattle_Pokemon:443:in `__mf_getMoveList'
    Pokemon_MultipleForms:91:in `getMoveList'
    PokeBattle_Pokemon:457:in `resetMoves'
    PField_EncounterModifiers:135
    PField_EncounterModifiers:107:in `call'
    Event:54:in `trigger'
    Event:49:in `each'
    Event:49:in `trigger'

    im guessing their is some issue with getting their attacks or something? sorry if its not much info nothing else has been changed towards this except some multiple form code.
     
    Back
    Top