Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Pokemon encounter problem

b00n90

Member

Heya guys, i finally figured how this battle system works...
its encounter system ... im not very good at scripting so if some1 wanna help me i can gave him full scripts for Pokedex pokegear
all pokemons in system , working Pokecenter, working PokePC with withdraw and deposit, TM´s and HM´s inside and much more
i just dont understand that encounter thingy for wild pokemons appear on grass, water and caves.
Would be cool if sum1 is up to help and get the files also.^^
Just answer here or PN me ur MSN adress for chatting better.
Sorry for the title it sounds a bit arrogant^^


Code:
class PokemonEncounters
  EnctypeChances=[
   [20,20,10,10,10,10,5,5,4,4,1,1],
   [20,20,10,10,10,10,5,5,4,4,1,1],
   [60,30,5,4,1],
   [60,30,5,4,1],
   [70,30],
   [60,20,20],
   [40,40,15,4,1],
   [30,25,20,10,5,5,4,1],
   [30,25,20,10,5,5,4,1],
   [20,20,10,10,10,10,5,5,4,4,1,1],
   [20,20,10,10,10,10,5,5,4,4,1,1],
   [20,20,10,10,10,10,5,5,4,4,1,1]
  ]
 def initialize
  @enctypes=[]
  @density=nil
 end
 def clearStepCount
  @stepcount=0
 end
 def hasEncounter?(enc)
  return false if @density==nil
  return @enctypes[enc] ? true : false  
 end
 def isCave?
  return false if @density==nil
  return @enctypes[1] ? true : false
 end
 def isGrass?
  return false if @density==nil
  return (@enctypes[0] || @enctypes[9] || @enctypes[10] || @enctypes[11]) ? true : false
 end
 def setup(mapID)
  @density=nil
  @stepcount=0
  @enctypes=[]
  begin
   data=load_data("Data/encounters.dat")
   if data.is_a?(Hash) && data[mapID]
    @density=data[mapID][0]
    @enctypes=data[mapID][1]
   else
    @density=nil
    @enctypes=[]
   end
  rescue
   @density=nil
   @enctypes=[]
  end
 end
 def pbEncounteredPokemon(enctype)
  if enctype<0 || enctype>EnctypeChances.length
   raise ArgumentError.new(_INTL("Encounter type out of range"))
  end
  return nil if @enctypes[enctype]==nil
  chances=EnctypeChances[enctype]
  rnd=rand(100)
  chosenpkmn=0
  chance=0
  for i in 0...chances.length
   chance+=chances[i]
   if rnd<chance
    chosenpkmn=i
    break
   end
  end
  encounter=@enctypes[enctype][chosenpkmn]
  level=encounter[1]+rand(1+encounter[2]-encounter[1])
  return [encounter[0],level]
 end
 def pbGenerateEncounter(enctype)
  if enctype<0 || enctype>EnctypeChances.length
   raise ArgumentError.new(_INTL("Encounter type out of range"))
  end
  return nil if @density==nil
  return nil if @density[enctype]==0 || !@density[enctype]
  return nil if @enctypes[enctype]==nil
  @stepcount+=1
  return nil if @stepcount<=3 # Check three steps after battle ends
  encount=@density[enctype]*16
  if $PokemonGlobal.bicycle
   encount=(encount*4/5)
  end
  if $PokemonMap.blackFluteUsed
   encount/=2
  end
  if $PokemonMap.whiteFluteUsed
   encount=(encount*3/2)
  end
  if $Trainer.party.length>0
   if $Trainer.party[0].item==PBItems::CLEANSETAG
    encount=(encount*2/3)
   else
    if $Trainer.party[0].ability==PBAbilities::STENCH
     encount=(encount*1/2)
    elsif $Trainer.party[0].ability==PBAbilities::ILLUMINATE
     encount=(encount*2/3)
    end
   end
  end
  return nil if rand(2874)>=encount
  encpoke=pbEncounteredPokemon(enctype)
  return nil if !encpoke
  if $PokemonGlobal.repel>0 && $Trainer.party.length>0
   return nil if encpoke[1]<=$Trainer.party[0].level
  end
  return encpoke
 end
end

And the read me of this scripts says:
To generate a wild Pokemon battle, call pbWildBattle(X,Y,V,C) where X is the species number of the Pokemon, and Y is its level. See PBSpecies for species IDs. The optional parameter V represents the number of a variable to store the result of the battle (1=won; 3=escaped; 4=caught), and the optional parameter C is true if the player can escape from the battle.

To change the kinds of wild Pokemon found in an area, you can modify the file PBS/encounters.txt. After doing so, it is enough to put grass tiles (or other tiles with terrain tag 2) on the map for wild Pokemon to appear there -- no events are necessary. The file encounters.txt supports two different encounter types: Land and Cave. For Land encounter types, wild Pokemon will appear only on the grass. For Cave encounter types, wild Pokemon will appear anywhere. Several other encounter types are also supported; see the "PBS/encounters.txt" section for details.

and:
PBS/encounters.txt

This text file is for placing encounter data for each map. This file will be converted to a runtime format when you run a playtest of the game from RPG Maker XP.

For each section of the file:

    * The section begins with a line consisting of the ID of the map (check the middle of the status bar)
    * Then there is a line containing the densities for land, caves, and water. This line is optional. If it doesn't exist, then it is set to "25,10,10".
    * Then there are one or more subsections. The first line of each subsection is one of the following:
          o Land - For grass, etc. For this encounter type, Pokemon will appear only on grass.
          o Cave - For caves, etc. For this encounter type, Pokemon will appear anywhere.
          o Water - For water.
          o RockSmash - Encounters after smashing a rock
          o OldRod - Fished with Old Rod
          o GoodRod - Fished with Good Rod
          o SuperRod - Fished with Super Rod
          o HeadbuttLow - Encounters after using Headbutt on low-density trees (rarer)
          o HeadbuttHigh - Encounters after using Headbutt on high-density trees (commoner)
          o LandMorning - For grass, etc. From 6 a.m. to 12 noon.
          o LandDay - For grass, etc. From 12 noon to 8 p.m.
          o LandNight - For grass, etc. From 8 p.m. to 6 a.m.

      The rest of the subsection is a number of lines that make up the encounter data. For Land and Cave encounter types, each entry in the subsection has a species and level, separated by commas. Rarer species should be placed lower in the list. For all other encounter types, each entry must have a species, minimum level, and optionally a maximum level, separated by commas. Each species entered must be capitalized with no spaces. Note in particular the following cases:

      NIDORANmA, NIDORANfE, FARFETCHD, MR_MIME, PORYGON2

Depending on the encounter type, the number of entries required varies:

    * Land/Cave: 12 entries (20, 20, 10, 10, 10, 10, 5, 5, 4,4,1,1)
    * Water/RockSmash: 5 entries (60,30,5,4,1)
    * OldRod: 2 entries (70, 30)
    * GoodRod: 3 entries (60, 20, 20)
    * SuperRod: 5 entries (40, 40, 15, 4, 1)
    * HeadbuttHigh/HeadbuttLow: 8 entries (30,25,20,10,5,5,4,1)



maybe a scripter with more experience can help me .
Thanx

P.S: Mod or Admin can close my other Topic about this problem.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top