• 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] X Candy (Rare Candy that increases EXP instead of level)

Amyrakunejo

Philosophical Pagan Femme Fair Gynesexual Gamer
20
Posts
5
Years
  • Age 28
  • Seen Jul 24, 2020
To be honest, I've always wondered why there was never an item that just increased EXP rather than increasing a Pok?mon's level...

Anyway, say I wanted to incorporate this type of item in my fangame; how would I go about setting the specific effects for the item?

I can figure out the item definitions and such on my own; just setting the effect to increase a Pok?mon's EXP by let's say, fifty (or any arbitrary number), is something I'd like to know how to do.

Thanks much in advance for a swift reply.
 

Amyrakunejo

Philosophical Pagan Femme Fair Gynesexual Gamer
20
Posts
5
Years
  • Age 28
  • Seen Jul 24, 2020
All you need is pokemon.exp+=x.
That's it. That adds x amount of exp.

Mmm.

Unfortunately, it's far less simple.
It does seem that it would work, if I knew how to code the part that changes a Pokémon's EXP.

In Items, I see where I could potentially copy code for Changing EXP this way, but I know that it wouldn't work without making tweaks that I don't even know where to begin on.

...Yeah. I'm a novice at Ruby.
 
1,677
Posts
8
Years
  • Age 23
  • Seen today
Mmm.

Unfortunately, it's far less simple.
It does seem that it would work, if I knew how to code the part that changes a Pokémon's EXP.

In Items, I see where I could potentially copy code for Changing EXP this way, but I know that it wouldn't work without making tweaks that I don't even know where to begin on.

...Yeah. I'm a novice at Ruby.

Ah don't worry about being a beginner, everyone starts somewhere.

Since you're making a new Item, you'll need to start at PItem_ItemEffects. since this works similar to a rare candy we're gonna check that handler. there are many types of handler but the one we are interested in is UseOnPokemon. now I don't have the code in front of me but the proc, the bit of runnable code we are good to add as the effect for our item should have 3 arguments, the item, the Pokemon, and the scene. we don't need to worry about scene right now, nor item as this handler only deals with o e, the X candy (Its possible to make handlers thgat apply to a wide variety of items, like the evo stones but we can also ignore that.)
in the curly brackets of our proc, we put our effect, the exp += whatever. I think rare candy passes it off to another method to raise the level because of all the variables involved, like making sure the Pokemon can't go over the maximum level.
why don't you give it a shot, and if you still don't have it, come back with what you tried so we can go over it together. (I promise I will be on my computer by then)
 

Amyrakunejo

Philosophical Pagan Femme Fair Gynesexual Gamer
20
Posts
5
Years
  • Age 28
  • Seen Jul 24, 2020
Ah don't worry about being a beginner, everyone starts somewhere.

Since you're making a new Item, you'll need to start at PItem_ItemEffects. since this works similar to a rare candy we're gonna check that handler. there are many types of handler but the one we are interested in is UseOnPokemon. now I don't have the code in front of me but the proc, the bit of runnable code we are good to add as the effect for our item should have 3 arguments, the item, the Pokemon, and the scene. we don't need to worry about scene right now, nor item as this handler only deals with o e, the X candy (Its possible to make handlers thgat apply to a wide variety of items, like the evo stones but we can also ignore that.)
in the curly brackets of our proc, we put our effect, the exp += whatever. I think rare candy passes it off to another method to raise the level because of all the variables involved, like making sure the Pokemon can't go over the maximum level.
why don't you give it a shot, and if you still don't have it, come back with what you tried so we can go over it together. (I promise I will be on my computer by then)

Code:
ItemHandlers::UseOnPokemon.add(:XP50,proc{|item,pokemon,scene|
   if pokemon.level>=PBExperience::MAXLEVEL || (pokemon.isShadow? rescue false)
     scene.pbDisplay(_INTL("It won't have any effect."))
     next false
   else
     pbChangeExp(pokemon,pokemon.exp+=50,scene)
     scene.pbHardRefresh
     next true
   end
})#end

I changed it from pbChangeLevel to pbChangeExp (by keeping it at pbChangeLevel it increased the Pokémon's level by 50); but that leads to a nil:class error.

I had done this before you encouraged me to try this method.

The following is where I am thinking some code needs to be copied and rewritten, if I knew how.
(PItem_Items)
Spoiler:

So, yeah. I'm about to go to bed, so, hopefully, we can discuss this further later.
(For the Record, most of my Ruby skills are in VX Ace. I know the difference between Ace and XP is monumental in this regard.)
 
1,677
Posts
8
Years
  • Age 23
  • Seen today
Code:
ItemHandlers::UseOnPokemon.add(:XP50,proc{|item,pokemon,scene|
   if pokemon.level>=PBExperience::MAXLEVEL || (pokemon.isShadow? rescue false)
     scene.pbDisplay(_INTL("It won't have any effect."))
     next false
   else
     pbChangeExp(pokemon,pokemon.exp+=50,scene)
     scene.pbHardRefresh
     next true
   end
})#end
--snipped-- to get your attention

So when it comes to the handler, you're on the right track, except for this bit
Code:
pbChangeExp(pokemon,pokemon.exp+=50,scene)
while pokemon.exp+=50 works in isolation, in this method call, we want to give the exp unchanged (doing it like that would probably confusingly say that the exp has not changed even though it has because we just changed it). so just pokemon.exp+50 right here (look at the rare candy for example).
When it comes to making your own pbChangeExp method, there are indeed a number of things we need to account for, such as the fact that it's possible to gain a level if the new exp is enough to do that.
I typed one out here, with no testing, preventing you from setting the exp to a negative number, nor greater than the max for the Growth rate.
This is not necessarily the best or only way to do this, but it sure was the easiest for me to implement.
Spoiler:

Now I need to stop typing, because I am sitting on the floor and my butt hurts.
 

Amyrakunejo

Philosophical Pagan Femme Fair Gynesexual Gamer
20
Posts
5
Years
  • Age 28
  • Seen Jul 24, 2020
Well, it works now, but how would I get it to display that the Pokémon's EXP was raised by x amount?

Also, I know how that feels; my payee refuses to get me furniture so I suffer as a result.
(causing me health issues but she doesn't care)
 

Amyrakunejo

Philosophical Pagan Femme Fair Gynesexual Gamer
20
Posts
5
Years
  • Age 28
  • Seen Jul 24, 2020
Suffice to say, I got this to work.
One issue: It throws an error if the Items.txt has numbers in the item description text with digit grouping (i.e. 1,000).
Even still, surely there's a workaround for it. I'll get to that later but for now...
Blue Candy = 50 XP ; 500 cost
Green Candy = 100 XP ; 1,200 cost
Red Candy = 250 XP ; 2,500 cost
Purple Candy = 500 XP ; 5,000 cost
Yellow Candy = 1,000 XP ; 10,000 cost
Yeah, I did make it so they're not easily accessible at the cost level since most of the upper tier healing items are in the 2K to 5K range. This is HP UP territory, lol
 
Last edited:
1,677
Posts
8
Years
  • Age 23
  • Seen today
Suffice to say, I got this to work.
One issue: It throws an error if the Items.txt has numbers in the item description text with digit grouping (i.e. 1,000).
Even still, surely there's a workaround for it. I'll get to that later but for now...
Blue Candy = 50 XP ; 500 cost
Green Candy = 100 XP ; 1,200 cost
Red Candy = 250 XP ; 2,500 cost
Purple Candy = 500 XP ; 5,000 cost
Yellow Candy = 1,000 XP ; 10,000 cost
Yeah, I did make it so they're not easily accessible at the cost level since most of the upper tier healing items are in the 2K to 5K range. This is HP UP territory, lol

the reason you are getting the error from the comma is because the comma technically ends the description section and goes into disabilities, which take numbers not strings.

The Wiki said:
If there are any commas in the description, you must surround the entire description with quote marks. If there are no commas in the description, there's no harm in having those quote marks anyway.

If there are any quote marks in the description itself, you must put a backslash before each of them, e.g. ". The same applies if there are any apostrophes in the description and you haven't surrounded it with quote marks.

glass the whole thing is working for you now th hough.
 
1,396
Posts
10
Years
  • Age 35
  • Seen today
There was no need to bump this ancient thread. Also, none of this even matters anymore because Exp. Candies now exist that do exactly this.
 
Back
Top