Implemented GameData::Nature, improved registration of GameData entries

This commit is contained in:
Maruno17
2021-01-31 22:43:51 +00:00
parent 168a1e5df7
commit 9fe14395c0
18 changed files with 384 additions and 224 deletions

View File

@@ -270,17 +270,22 @@ def pbRandomPokemonFromRule(rule,trainer)
break
end
ev=rand(63)+1
nature=0
nature = nil
keys = GameData::Nature::DATA.keys
loop do
nature = rand(25)
nd5 = PBNatures.getStatRaised(nature)
nm5 = PBNatures.getStatLowered(nature)
if nd5==nm5 || nature==PBNatures::LAX || nature==PBNatures::GENTLE
# Neutral nature, Lax, or Gentle
next if rand(20)<19
nature = keys[rand(keys.length)]
nature_data = GameData::Nature.get(nature)
if [:LAX, :GENTLE].include?(nature_data.id) || nature_data.stat_changes.length == 0
next if rand(20) < 19
else
next if rand(10)<6 if ((ev>>nd5)&1)==0 # If stat to increase isn't emphasized
next if rand(10)<9 if ((ev>>nm5)&1)!=0 # If stat to decrease is emphasized
raised_emphasis = false
lowered_emphasis = false
nature_data.stat_changes.each do |change|
raised_emphasis = true if change[1] > 0 && ((ev >> change[0]) & 1) != 0
lowered_emphasis = true if change[1] < 0 && ((ev >> change[0]) & 1) != 0
end
next if rand(10) < 6 && !raised_emphasis
next if rand(10) < 9 && lowered_emphasis
end
break
end