• 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] Pickup - a few scripting questions

55
Posts
10
Years
  • Seen Oct 8, 2019
Hey guys,

slowly but surely I am finishing my game. There are only a few things to fix/edit. The last three years I learned a lot about scripting and ruby itself, but not enough to solve the following questions.

1. Pickup-Ability:
Spoiler:


2. Increase Catchrate of a Rocketball
Spoiler:



3. Change startitem on the PC:
Spoiler:


I hope there is anybody can answer my questions!

Thank you very much in advance!

Cheers Hargatio
 
Last edited by a moderator:

Zeak6464

Zeak #3205 - Discord
1,101
Posts
11
Years
  • Age 31
  • USA
  • Seen Oct 9, 2023
1: "rnd<cumnumber" this is the number equation that figures out if you picked something up
Change Rnd to "0" and test it out from there

2:All you have to do is Remove the "pokemon.makeShodow" to make it not be shadow when caught .
Code:
BallHandlers::ModifyCatchRate.add(:ROCKETBALL,proc{|ball,catchRate,battle,battler|
   next (catchRate*3/2).floor

this is your catch rate
(catchRate*3/2)
so if you change it to "(catchRate*3)" 3x better then normal catch rate

3: # Start storage with a Potion <--- search for that
PScreen_Bag - line - 1022
 
55
Posts
10
Years
  • Seen Oct 8, 2019
Okay, thank you very much for the quick reply.

So, just to understand, to improve the catchrate for the snagball, I can use the following code?
Code:
BallHandlers::OnCatch.add(:SNAGBALL,proc{|ball,battle,pokemon|
   next (catchRate*3).floor
I deleted the shadow-part and insert the catchrate instead.

---

I'm not sure, if I got your point for pickup.

This is the code excerpt from PField_Field:
Code:
  items.push(pickupListRare[itemstart+1])
[B][COLOR=Red]  rnd=rand(100)[/COLOR] ----->   [COLOR=Lime]rnd=rand(0)[/COLOR][/B]
  cumnumber=0
  for i in 0...11
So I change the highlighted part?

And what's with the number of pickable items? There are more than in the originally game now. But I just added items and didn't change anything else. Is there something I need to do?
 

Zeak6464

Zeak #3205 - Discord
1,101
Posts
11
Years
  • Age 31
  • USA
  • Seen Oct 9, 2023
Okay, thank you very much for the quick reply.

So, just to understand, to improve the catchrate for the snagball, I can use the following code?
Code:
BallHandlers::OnCatch.add(:SNAGBALL,proc{|ball,battle,pokemon|
   next (catchRate*3).floor
I deleted the shadow-part and insert the catchrate instead.

---

I'm not sure, if I got your point for pickup.

This is the code excerpt from PField_Field:
Code:
  items.push(pickupListRare[itemstart+1])
[B][COLOR=Red]  rnd=rand(100)[/COLOR] ----->   [COLOR=Lime]rnd=rand(0)[/COLOR][/B]
  cumnumber=0
  for i in 0...11
So I change the highlighted part?

And what's with the number of pickable items? There are more than in the originally game now. But I just added items and didn't change anything else. Is there something I need to do?

if rnd<cumnumber
^this is saying the "Random Number Digit" must be less then "CunNumber" inorder to work

randlist=[30,10,10,10,10,10,10,4,4,1,1]
^this is your items gained

yes this should work :
Code:
BallHandlers::ModifyCatchRate.add(:SNAGBALL,proc{|ball,catchRate,battle,battler|
   next (catchRate*3/2).floor
 
55
Posts
10
Years
  • Seen Oct 8, 2019
Hm, it still doesn't work. Which line in detail I have to change?
I tried it like this:
Code:
  )
  return if pickupList.length!=18
  return if pickupListRare.length!=11
  randlist=[30,10,10,10,10,10,10,4,4,1,1]
  items=[]
  plevel=[100,pokemon.level].min
  itemstart=(plevel-1)/10
  itemstart=0 if itemstart<0
  for i in 0...9
    items.push(pickupList[itemstart+i])
  end
  items.push(pickupListRare[itemstart])
  items.push(pickupListRare[itemstart+1])
[B][COLOR=Red]  rnd=rand(100)  ------>   rnd=rand(0)
  cumnumber=0  ------>   cumnumber=100[/COLOR][/B]
  for i in 0...11
    cumnumber+=randlist[i]
    if rnd<cumnumber
      pokemon.setItem(items[i])
      break
    end
Can I change them, add more prohabilities or change the numbers? Or do other scripts/codes referring to that line?
For example:
Code:
randlist=[50,50]
randlist=[10,10,10,10,10,10,10,5,5,5,5,4,4,1,1]
randlist=[20,20,10,10,10,10,10,4,4,1,1]
Would that work?

How the script decides whether it is a normal or a rare item?
 
Last edited:

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
The wiki has information about how the ability Pickup works. It's not the easiest code to understand and modify.

The list of common items has 18 items in it for a reason, and that reason is that there are 10 different level ranges (1-10, 11-20, etc.) and the game takes 9 items from that list (the one listed next to the appropriate level range plus the next 8 items). Similarly, the list of rare items has 11 items in it because there are 10 different level ranges and the game takes 2 items from that list (the one listed next to the appropriate level range plus the next 1 item).

Changing the lengths of these item lists alone isn't enough.

Code:
  for i in 0...[COLOR=Red]9[/COLOR]
    items.push(pickupList[itemstart+i])
  end
  items.push(pickupListRare[itemstart])
  items.push(pickupListRare[itemstart+1])
Notice that I coloured in the 9 in my text above, as well as the 9 in the code I just wrote. This is the same number. If you want to take more items out of the common list, you'll need to change this number. Similarly, I coloured in a 2 when I talked about the rare items list, and there are two items.push lines that mention pickupListRare. The latter can be a little confusing because it's written differently. Really, you could replace the above code with the following, and it'd work exactly the same and be clearer and easier to modify:

Code:
  for i in 0...[COLOR=Red]9[/COLOR]
    items.push(pickupList[itemstart+i])
  end
  for i in 0...[COLOR=Red]2[/COLOR]
    items.push(pickupListRare[itemstart+i])
  end
There's another line of code a little further down, which says this:

Code:
  for i in 0...11
11 is 9 plus 2. If you change the 9 or the 2, you'll need to change the 11 accordingly.



Those are the miscellaneous code changes you'll need. But before that, and most importantly, you'll need to decide on your items and percentages. Why are 9 items chosen from the common list and 2 from the rare list? Well, it's because of this line:

Code:
  randlist = [30,10,10,10,10,10,10,4,4,1,1]
This array has 11 numbers in it. As mentioned above, 11 is 9 plus 2. Why not 8+3, or 5+6? That's just how Pickup works in Pokémon games. You can indeed have 8+3 or 10+1 if you want, as long as you change the code accordingly.

Anyway, the game calculates 11 items, and then chooses one of them to be picked up. The 11 numbers in the array are the percentage chances of choosing each item in turn - the last two items each have a probability of 1%, and those two items also happen to come from the list of rare items. You can change how many items you want to calculate (and then randomly choose from those items) by changing this array. For example:

Code:
  randlist = [40,20,20,10,4,4,1,1]
I'm still going with 2 rare items here (both 1% chance), which means this array lets me have 6 items from the common list (rather than 9). These probabilities still add up to 100, which is good. Any code which uses the number 9 (see above) should be changed to use 6 instead. Because I choose 6 items from the common list, that means pickupList only needs to contain 15 items (10 different level ranges, one of which is the first item calculated, plus the next 5 items). The list can be longer, but it's pointless as the 16th, 17th and so on items can never be chosen. Might as well keep the list only as long as it needs to be.

That's how I decided how many items should be in my lists. Thus I can change the numbers in these lines of code accordingly:

Code:
  return if pickupList.length!=18
  return if pickupListRare.length!=11



Ultimately, I don't think there's a point to changing how many items are available via Pickup. You can certainly change which items are available, but given that Pickup by default can choose from 29 different items, surely that's enough to be getting on with?
 
55
Posts
10
Years
  • Seen Oct 8, 2019
Hi Maruno,

this is exactly what I was looking for!! It's a way more complex than I thought.
I probably gonna make some simple changes just to practice a little bit.

For me all questions are answered! Thanks a lot to you guys!
 
Back
Top