• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.

A couple of script questions

Nova Ozuka

Trainer
Member
Joined
Apr 15, 2022
Posts
54
First question, is it possible to assign ratios to an array? I've got a script event that has several Pokemon in an array, but I want some Pokemon to have a higher rate than the others.

Second question, how do I assign a specific game variable to a script? Would it be as simple as BLANK = 30, or would that just set a variable called BLANK to have a value of 30 instead of whatever is stored in variable 30? I have to ask this because I'm trying to setup a script to track a variable, but I've also realized that if I simply did something like BLANK = 30 and then do "if BLANK < 2" then the script might actually think that BLANK is supposed to be 30 and not whatever is stored in variable 30. I was going to test this myself, but I'm stuck redoing a bunch of stuff before that script comes into play.
 
First question, is it possible to assign ratios to an array? I've got a script event that has several Pokemon in an array, but I want some Pokemon to have a higher rate than the others.

Second question, how do I assign a specific game variable to a script? Would it be as simple as BLANK = 30, or would that just set a variable called BLANK to have a value of 30 instead of whatever is stored in variable 30? I have to ask this because I'm trying to setup a script to track a variable, but I've also realized that if I simply did something like BLANK = 30 and then do "if BLANK < 2" then the script might actually think that BLANK is supposed to be 30 and not whatever is stored in variable 30. I was going to test this myself, but I'm stuck redoing a bunch of stuff before that script comes into play.
1) Just do an array of arrays.
array = [[:PIKACHU, 50], [:ENTEI, 30], [:MEW, 20]]
Depending on what you're trying to do, you'd likely generate a random number, then run through a loop of array.length, and at each step subtract the index 1 value. If the value is < 0, it returns the index 0 value (the Pokemon). Else, move on to the next iteration and repeat until it returns a Pokemon. That's how wild encounter selection happens as an example

2) pbGet(30) gives you the value of variable 30. Or $game_variables[30]. So just do "if pbGet(30) < 2"
 
Last edited:
1) Just do an array of arrays.
array = [[:PIKACHU, 50], [:ENTEI, 30], [:MEW, 20]]
Depending on what you're trying to do, you'd likely generate a random number, then run through a loop of array.length, and at each step subtract the index 1 value. If the value is < 0, it returns the index 0 value (the Pokemon). Else, move on to the next iteration and repeat until it returns a Pokemon. That's how wild encounter selection happens as an example

2) pbGet(30) gives you the value of variable 30. Or $game_variables[30]. So just do "if pbGet(30) < 2"
I'll try that solution. Hopefully it doesn't just end up giving me Pokemon of that level instead.

As for the second question, I ended up finding the answer on my own today. Unfortunately, my attempts to edit a script have been less than successful, and I don't really know ruby script well enough to get my edits working. It acts like I'm missing an "end" line, but I can't see anywhere I'm missing one. All I know is that it has something to do with my edit. All I know is that whatever I'm really missing, it's in this section of code.
Ruby:
Expand Collapse Copy
if $game_variables[30] < 2
        ratio=[247,247,247,247,10,1,1]
        craft=items[rand(items.length)]
        case craft
        when :BLACKAPRICORN
          table=[:POKEBALL,:GREATBALL,:DUSKBALL,:LUXURYBALL,:HEAVYBALL,:SAFARIBALL,:SPORTBALL]
        when :BLUEAPRICORN
          table=[:POKEBALL,:GREATBALL,:DIVEBALL,:NETBALL,:LUREBALL,:SAFARIBALL,:SPORTBALL]
        when :GREENAPRICORN
          table=[:POKEBALL,:GREATBALL,:ULTRABALL,:NESTBALL,:FRIENDBALL,:SAFARIBALL,:SPORTBALL]
        when :PINKAPRICORN
          table=[:POKEBALL,:GREATBALL,:ULTRABALL,:HEALBALL,:LOVEBALL,:SAFARIBALL,:SPORTBALL]
        when :REDAPRICORN
          table=[:POKEBALL,:GREATBALL,:ULTRABALL,:REPEATBALL,:LEVELBALL,:SAFARIBALL,:SPORTBALL]
        when :WHITEAPRICORN
          table=[:POKEBALL,:GREATBALL,:PREMIERBALL,:TIMERBALL,:FASTBALL,:SAFARIBALL,:SPORTBALL]
        when :YELLOWAPRICORN
          table=[:POKEBALL,:GREATBALL,:ULTRABALL,:QUICKBALL,:MOONBALL,:SAFARIBALL,:SPORTBALL]
      if $game_variables[30] >= 2 and $game_variables[30] < 4
        ratio=[123,247,247,247,120,8,8]
        craft=items[rand(items.length)]
        case craft
        when :BLACKAPRICORN
          table=[:POKEBALL,:GREATBALL,:DUSKBALL,:LUXURYBALL,:HEAVYBALL,:SAFARIBALL,:SPORTBALL]
        when :BLUEAPRICORN
          table=[:POKEBALL,:GREATBALL,:DIVEBALL,:NETBALL,:LUREBALL,:SAFARIBALL,:SPORTBALL]
        when :GREENAPRICORN
          table=[:POKEBALL,:GREATBALL,:ULTRABALL,:NESTBALL,:FRIENDBALL,:SAFARIBALL,:SPORTBALL]
        when :PINKAPRICORN
          table=[:POKEBALL,:GREATBALL,:ULTRABALL,:HEALBALL,:LOVEBALL,:SAFARIBALL,:SPORTBALL]
        when :REDAPRICORN
          table=[:POKEBALL,:GREATBALL,:ULTRABALL,:REPEATBALL,:LEVELBALL,:SAFARIBALL,:SPORTBALL]
        when :WHITEAPRICORN
          table=[:POKEBALL,:GREATBALL,:PREMIERBALL,:TIMERBALL,:FASTBALL,:SAFARIBALL,:SPORTBALL]
        when :YELLOWAPRICORN
          table=[:POKEBALL,:GREATBALL,:ULTRABALL,:QUICKBALL,:MOONBALL,:SAFARIBALL,:SPORTBALL]
      if $game_variables[30] >= 4 and $game_variables[30] < 6
        ratio=[247,123,247,247,67,67,1]
        craft=items[rand(items.length)]
        case craft
        when :BLACKAPRICORN
          table=[:HEAVYBALL,:GREATBALL,:DUSKBALL,:LUXURYBALL,:SAFARIBALL,:SPORTBALL,:MASTERBALL]
        when :BLUEAPRICORN
          table=[:LUREBALL,:GREATBALL,:DIVEBALL,:NETBALL,:SAFARIBALL,:SPORTBALL,:MASTERBALL]
        when :GREENAPRICORN
          table=[:FRIENDBALL,:GREATBALL,:ULTRABALL,:NESTBALL,:SAFARIBALL,:SPORTBALL,:MASTERBALL]
        when :PINKAPRICORN
          table=[:LOVEBALL,:GREATBALL,:ULTRABALL,:HEALBALL,:SAFARIBALL,:SPORTBALL,:MASTERBALL]
        when :REDAPRICORN
          table=[:LEVELBALL,:GREATBALL,:ULTRABALL,:REPEATBALL,:SAFARIBALL,:SPORTBALL,:MASTERBALL]
        when :WHITEAPRICORN
          table=[:FASTBALL,:GREATBALL,:PREMIERBALL,:TIMERBALL,:SAFARIBALL,:SPORTBALL,:MASTERBALL]
        when :YELLOWAPRICORN
          table=[:MOONBALL,:GREATBALL,:ULTRABALL,:QUICKBALL,:MOONBALL,:SAFARIBALL,:SPORTBALL,:MASTERBALL]
      if $game_variables[30] >= 6 and $game_variables[30] < 8
        ratio=[247,247,247,119,119,10,1]
        craft=items[rand(items.length)]
        case craft
        when :BLACKAPRICORN
          table=[:HEAVYBALL,:DUSKBALL,:LUXURYBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :BLUEAPRICORN
          table=[:LUREBALL,:DIVEBALL,:NETBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :GREENAPRICORN
          table=[:FRIENDBALL,:ULTRABALL,:NESTBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :PINKAPRICORN
          table=[:LOVEBALL,:ULTRABALL,:HEALBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :REDAPRICORN
          table=[:LEVELBALL,:ULTRABALL,:REPEATBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :WHITEAPRICORN
          table=[:FASTBALL,:PREMIERBALL,:TIMERBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :YELLOWAPRICORN
          table=[:MOONBALL,:ULTRABALL,:QUICKBALL,:MOONBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
      if $game_variables[30] >= 8
        ratio=[247,247,247,119,119,10,1]
        craft=items[rand(items.length)]
        case craft
        when :BLACKAPRICORN
          table=[:HEAVYBALL,:DUSKBALL,:LUXURYBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :BLUEAPRICORN
          table=[:LUREBALL,:DIVEBALL,:NETBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :GREENAPRICORN
          table=[:FRIENDBALL,:ULTRABALL,:NESTBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :PINKAPRICORN
          table=[:LOVEBALL,:ULTRABALL,:HEALBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :REDAPRICORN
          table=[:LEVELBALL,:ULTRABALL,:REPEATBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :WHITEAPRICORN
          table=[:FASTBALL,:PREMIERBALL,:TIMERBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :YELLOWAPRICORN
          table=[:MOONBALL,:ULTRABALL,:QUICKBALL,:MOONBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
 
Last edited:
I'll try that solution. Hopefully it doesn't just end up giving me Pokemon of that level instead.

As for the second question, I ended up finding the answer on my own today. Unfortunately, my attempts to edit a script have been less than successful, and I don't really know ruby script well enough to get my edits working. It acts like I'm missing an "end" line, but I can't see anywhere I'm missing one. All I know is that it has something to do with my edit. All I know is that whatever I'm really missing, it's in this section of code.
Ruby:
Expand Collapse Copy
if $game_variables[30] < 2
        ratio=[247,247,247,247,10,1,1]
        craft=items[rand(items.length)]
        case craft
        when :BLACKAPRICORN
          table=[:POKEBALL,:GREATBALL,:DUSKBALL,:LUXURYBALL,:HEAVYBALL,:SAFARIBALL,:SPORTBALL]
        when :BLUEAPRICORN
          table=[:POKEBALL,:GREATBALL,:DIVEBALL,:NETBALL,:LUREBALL,:SAFARIBALL,:SPORTBALL]
        when :GREENAPRICORN
          table=[:POKEBALL,:GREATBALL,:ULTRABALL,:NESTBALL,:FRIENDBALL,:SAFARIBALL,:SPORTBALL]
        when :PINKAPRICORN
          table=[:POKEBALL,:GREATBALL,:ULTRABALL,:HEALBALL,:LOVEBALL,:SAFARIBALL,:SPORTBALL]
        when :REDAPRICORN
          table=[:POKEBALL,:GREATBALL,:ULTRABALL,:REPEATBALL,:LEVELBALL,:SAFARIBALL,:SPORTBALL]
        when :WHITEAPRICORN
          table=[:POKEBALL,:GREATBALL,:PREMIERBALL,:TIMERBALL,:FASTBALL,:SAFARIBALL,:SPORTBALL]
        when :YELLOWAPRICORN
          table=[:POKEBALL,:GREATBALL,:ULTRABALL,:QUICKBALL,:MOONBALL,:SAFARIBALL,:SPORTBALL]
      if $game_variables[30] >= 2 and $game_variables[30] < 4
        ratio=[123,247,247,247,120,8,8]
        craft=items[rand(items.length)]
        case craft
        when :BLACKAPRICORN
          table=[:POKEBALL,:GREATBALL,:DUSKBALL,:LUXURYBALL,:HEAVYBALL,:SAFARIBALL,:SPORTBALL]
        when :BLUEAPRICORN
          table=[:POKEBALL,:GREATBALL,:DIVEBALL,:NETBALL,:LUREBALL,:SAFARIBALL,:SPORTBALL]
        when :GREENAPRICORN
          table=[:POKEBALL,:GREATBALL,:ULTRABALL,:NESTBALL,:FRIENDBALL,:SAFARIBALL,:SPORTBALL]
        when :PINKAPRICORN
          table=[:POKEBALL,:GREATBALL,:ULTRABALL,:HEALBALL,:LOVEBALL,:SAFARIBALL,:SPORTBALL]
        when :REDAPRICORN
          table=[:POKEBALL,:GREATBALL,:ULTRABALL,:REPEATBALL,:LEVELBALL,:SAFARIBALL,:SPORTBALL]
        when :WHITEAPRICORN
          table=[:POKEBALL,:GREATBALL,:PREMIERBALL,:TIMERBALL,:FASTBALL,:SAFARIBALL,:SPORTBALL]
        when :YELLOWAPRICORN
          table=[:POKEBALL,:GREATBALL,:ULTRABALL,:QUICKBALL,:MOONBALL,:SAFARIBALL,:SPORTBALL]
      if $game_variables[30] >= 4 and $game_variables[30] < 6
        ratio=[247,123,247,247,67,67,1]
        craft=items[rand(items.length)]
        case craft
        when :BLACKAPRICORN
          table=[:HEAVYBALL,:GREATBALL,:DUSKBALL,:LUXURYBALL,:SAFARIBALL,:SPORTBALL,:MASTERBALL]
        when :BLUEAPRICORN
          table=[:LUREBALL,:GREATBALL,:DIVEBALL,:NETBALL,:SAFARIBALL,:SPORTBALL,:MASTERBALL]
        when :GREENAPRICORN
          table=[:FRIENDBALL,:GREATBALL,:ULTRABALL,:NESTBALL,:SAFARIBALL,:SPORTBALL,:MASTERBALL]
        when :PINKAPRICORN
          table=[:LOVEBALL,:GREATBALL,:ULTRABALL,:HEALBALL,:SAFARIBALL,:SPORTBALL,:MASTERBALL]
        when :REDAPRICORN
          table=[:LEVELBALL,:GREATBALL,:ULTRABALL,:REPEATBALL,:SAFARIBALL,:SPORTBALL,:MASTERBALL]
        when :WHITEAPRICORN
          table=[:FASTBALL,:GREATBALL,:PREMIERBALL,:TIMERBALL,:SAFARIBALL,:SPORTBALL,:MASTERBALL]
        when :YELLOWAPRICORN
          table=[:MOONBALL,:GREATBALL,:ULTRABALL,:QUICKBALL,:MOONBALL,:SAFARIBALL,:SPORTBALL,:MASTERBALL]
      if $game_variables[30] >= 6 and $game_variables[30] < 8
        ratio=[247,247,247,119,119,10,1]
        craft=items[rand(items.length)]
        case craft
        when :BLACKAPRICORN
          table=[:HEAVYBALL,:DUSKBALL,:LUXURYBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :BLUEAPRICORN
          table=[:LUREBALL,:DIVEBALL,:NETBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :GREENAPRICORN
          table=[:FRIENDBALL,:ULTRABALL,:NESTBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :PINKAPRICORN
          table=[:LOVEBALL,:ULTRABALL,:HEALBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :REDAPRICORN
          table=[:LEVELBALL,:ULTRABALL,:REPEATBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :WHITEAPRICORN
          table=[:FASTBALL,:PREMIERBALL,:TIMERBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :YELLOWAPRICORN
          table=[:MOONBALL,:ULTRABALL,:QUICKBALL,:MOONBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
      if $game_variables[30] >= 8
        ratio=[247,247,247,119,119,10,1]
        craft=items[rand(items.length)]
        case craft
        when :BLACKAPRICORN
          table=[:HEAVYBALL,:DUSKBALL,:LUXURYBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :BLUEAPRICORN
          table=[:LUREBALL,:DIVEBALL,:NETBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :GREENAPRICORN
          table=[:FRIENDBALL,:ULTRABALL,:NESTBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :PINKAPRICORN
          table=[:LOVEBALL,:ULTRABALL,:HEALBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :REDAPRICORN
          table=[:LEVELBALL,:ULTRABALL,:REPEATBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :WHITEAPRICORN
          table=[:FASTBALL,:PREMIERBALL,:TIMERBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
        when :YELLOWAPRICORN
          table=[:MOONBALL,:ULTRABALL,:QUICKBALL,:MOONBALL,:SAFARIBALL,:SPORTBALL,:DREAMBALL,:MASTERBALL]
You need an end after each case/when block, and one to close off the if/elsif/else block.Though you seem to have multiple if statements rather than if/elsif/else, so if you want to keep it that way, each if needs an end too.
not much of a fan of using a global game variable when a local one would do
Is that the Cram-o-matic? If it's my script, just below that block there's the same weighted ratio random selection that Wrigty described.
 
You need an end after each case/when block, and one to close off the if/elsif/else block.Though you seem to have multiple if statements rather than if/elsif/else, so if you want to keep it that way, each if needs an end too.
not much of a fan of using a global game variable when a local one would do
Is that the Cram-o-matic? If it's my script, just below that block there's the same weighted ratio random selection that Wrigty described.
I believe it is, in fact, your Cram-O-Matic script that I've been tweaking, yes. I've tried adding end after every if block, but that didn't seem to make any difference. elsif does seem to fix my edits. Unfortunately, the script still isn't working since it's taking me to the bag screen and not displaying any items even with the original. Other than that, I'm just struggling with understanding how to set up the weighted random.
 
I believe it is, in fact, your Cram-O-Matic script that I've been tweaking, yes. I've tried adding end after every if block, but that didn't seem to make any difference. elsif does seem to fix my edits. Unfortunately, the script still isn't working since it's taking me to the bag screen and not displaying any items even with the original. Other than that, I'm just struggling with understanding how to set up the weighted random.
I would recommend looking up some videos or websites to learn some of the basics of Ruby. Things like if/else statements and case/when statements are basic coding skills to know. Array manipulation can get more intense, but you can learn some basics first.
 
1) Just do an array of arrays.
array = [[:PIKACHU, 50], [:ENTEI, 30], [:MEW, 20]]
Depending on what you're trying to do, you'd likely generate a random number, then run through a loop of array.length, and at each step subtract the index 1 value. If the value is < 0, it returns the index 0 value (the Pokemon). Else, move on to the next iteration and repeat until it returns a Pokemon. That's how wild encounter selection happens as an example
Tried this, got a game crash.
Is that the Cram-o-matic? If it's my script, just below that block there's the same weighted ratio random selection that Wrigty described.
Also, I'm looking this rn, and I'm having trouble finding it. Having said that, I have tried this and actually gotten somewhere.
ratio=[15,15,15,11,11,11,11,7,1,1]
raidpool = [:IGGLYBUFF, :CLEFFA, :GASTLY, :BLIPBUG, :TEDDIURSA, :MAGNEMITE, :DUSKULL, :DEERLING_1, :DRATINI,
:GOOMY_2]
pkmn = raidpool[rand(raidpool.length)]
The problem is that nothing seems to have the intended rate except for Igglybuff. I've also shortened this to four Pokemon while using ratio = [40,40,19,1] and ended up running into Dratini far more than intended. I also tried adding an encounter table to the game script and then just calling pbEncounter instead, but I needed to be able to apply a battle rule that wasn't getting applied.
 
Tried this, got a game crash.

Also, I'm looking this rn, and I'm having trouble finding it. Having said that, I have tried this and actually gotten somewhere.
ratio=[15,15,15,11,11,11,11,7,1,1]
raidpool = [:IGGLYBUFF, :CLEFFA, :GASTLY, :BLIPBUG, :TEDDIURSA, :MAGNEMITE, :DUSKULL, :DEERLING_1, :DRATINI,
:GOOMY_2]
pkmn = raidpool[rand(raidpool.length)]
The problem is that nothing seems to have the intended rate except for Igglybuff. I've also shortened this to four Pokemon while using ratio = [40,40,19,1] and ended up running into Dratini far more than intended. I also tried adding an encounter table to the game script and then just calling pbEncounter instead, but I needed to be able to apply a battle rule that wasn't getting applied.
I can't really help unless you give information about the crash (the entire crash log) and the code you added 🙃
 
Last edited:
I can't really help unless you give information about the crash (the entire crash log) and the code you added 🙃
I can't remember or find the exact error in the error logs, but I remember it being along the lines of expecting "[Symbol, GameData::Species, String], but got array."
 
I can't remember or find the exact error in the error logs, but I remember it being along the lines of expecting "[Symbol, GameData::Species, String], but got array."
Right, then you likely didn't do all of what I said to do, and you're just passing the array of [species, chance] instead of also adding the stuff that makes it just take the species. Again, it will be hard to help if you don't share the code you added.
 
Right, then you likely didn't do all of what I said to do, and you're just passing the array of [species, chance] instead of also adding the stuff that makes it just take the species. Again, it will be hard to help if you don't share the code you added.
That's pretty much exactly what I did, and if this isn't proof that I don't know what I'm doing very well, I don't know what is.
Ruby:
Expand Collapse Copy
[Pokémon Essentials version 21.1]
[v21.1 Hotfixes 1.0.9]

Script error in event 11 (coords 37,4), map 10 (Route 1)
Exception: NameError
Message: undefined local variable or method `pkmn' for #<Interpreter @event_id: 11>

***Full script:
ratio=[40,40,19,1]
raidpool = [:IGGLYBUFF, :CLEFFA, :BLIPBUG, :DRATINI]
total=0
      ratio.each{|r| total+=r}
      num=rand(total)
      cumtotal=0
      raidpool.length.times do |i|
        cumtotal+=ratio[i]
        if num<cumtotal
          pkmn=i
          break
        end
      end
index = [0, 1, 2]
x = index.sample
index2 = [1, 2]
y = index2.sample
setBattleRule("backdrop", "cave1")
setBattleRule("base", "cave1")
setBattleRule("base", "cave1")
setBattleRule("battleBGM", "doopliss-pkmncolosseum-vsbat2")
setBattleRule("databoxStyle", [:Long])
setBattleRule("2V1")
setBattleRule("raidStyleCapture", {:capture_chance => 75, :capture_bgm => "Cornered",
:flee_msg => "{1} disappeared somewhere..."})
setBattleRule("editWildPokemon", {:hp_level => 2, :ability_index => x, :dynamax_lvl => y, :immunities => [:OHKO, 
:ITEMREMOVAL]})
setBattleRule("cannotRun")
setBattleRule("canLose")
setBattleRule("outcome", 42)
setBattleRule("wildDynamax")
setBattleRule("midbattleScript", :MAXRAID1)
WildBattle.start(pkmn, 15)
pbDeregisterPartner

Backtrace:
(eval):33:in `execute_script'
033:Interpreter:138:in `eval'
033:Interpreter:138:in `execute_script'
034:Interpreter_Commands:1177:in `command_355'
034:Interpreter_Commands:116:in `execute_command'
033:Interpreter:130:in `block in update'
033:Interpreter:86:in `loop'
033:Interpreter:86:in `update'
033:Interpreter:99:in `block in update'
033:Interpreter:86:in `loop'
I pretty much copied how the PokeBall crafting worked from the Cram-O-Matic script and changed ball to pkmn. I'm definitely missing something here, but at this point I'm starting to wonder if I'm better off using a conversion hash. I could set a variable randomly 1-100 and still get what I'm trying to achieve. It would be nice if I knew a way to store the variable somewhere besides the game variables if I did that, because then I would have a way of saving the spawned Pokemon without it getting overwritten the next time the event is called.
 
In my FLUtil plugin, I made a class just to make it easier and clear, since I had the same issue several times.

Using your example, I changed Deerling chance do 9, to make everything sum 100 (it was 98).

Ruby:
Expand Collapse Copy
helper = PokemonRandomHelper.new
# Gives error if your total isn't 100
helper.require_weight = 100
helper.add_copying_weight(15, [:IGGLYBUFF, :CLEFFA, :GASTLY])
helper.add_copying_weight(11, [:BLIPBUG, :TEDDIURSA, :MAGNEMITE, :DUSKULL])
helper.add(9, :DEERLING_1)
helper.add_copying_weight(1, [:DRATINI,:GOOMY_2])
pkmn = helper.get
WildBattle.start(pkmn, 15)

Another version below, this time using a seed. Same value = same result. Use $game_variables[30] = rand(100) before.

Ruby:
Expand Collapse Copy
helper = PokemonRandomHelper.new
# Gives error if your total isn't 100
helper.require_weight = 100
helper.add_copying_weight(15, [:IGGLYBUFF, :CLEFFA, :GASTLY])
helper.add_copying_weight(11, [:BLIPBUG, :TEDDIURSA, :MAGNEMITE, :DUSKULL])
helper.add(9, :DEERLING_1)
helper.add_copying_weight(1, [:DRATINI,:GOOMY_2])
pkmn = helper.get($game_variables[30]/100.0)
WildBattle.start(pkmn, 15)
 
Last edited:
Back
Top