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

465
Posts
7
Years
  • Age 24
  • Seen Apr 22, 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
kmRqECp.png

5f40775a6d2ef967289f6326190f87cd.gif


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