Making an "Special Item" grant *random* MaxHP points

I was trying to figure out how to grant at least "everyone" in the party (to keep it simpler atm) a random 'selection' of maxHP points from 1 to 10. I can at least generate the random amount of MaxHP points through a control variable. The rest, I don't know. I tried to do the "Change Parameter" to increase the amount of MaxHP by the variable's 'amount', but no matter what I do, the character's HP is stuck on their current MaxHP for their level. However, if I set the command to 'decrease' the MaxHP, it will do it.

I'm not sure if it's a bug, or if I'm doing it wrong.

I have an item created, called the "Mysterious Leaf", which is supposed to grant a character a *random* pool of 1-10 MaxHP. But since the normal Effects don't allow a range of points when you "Grow Max HP" I decided to try to resort to having the item call a Common Event called "Random Effects".

Inside the CE, I have it set to None (For the trigger). Then I put "Control Variable: Random Growth 1..10", then put in an If condition:

If Party has Mysterious Leaf
Flash Screen (etc etc)
If Random Growth >= 1 (ensuring that it has to be at least 1)
Change Parameter: Entire Party, Max HP + {Random Growth}
Change Item: Mysterious Leaf -1
End
End

The point is: The CE does get called. The Random Growth Variable does get a random "value" but if the character's HP is already filled to the max (ex: 100/100 HP) this appears not to work?

Any suggestions would be appreciated. I hope this is clear enough.
I was trying to figure out how to grant at least "everyone" in the party (to keep it simpler atm) a random 'selection' of maxHP points from 1 to 10. I can at least generate the random amount of MaxHP points through a control variable. The rest, I don't know. I tried to do the "Change Parameter" to increase the amount of MaxHP by the variable's 'amount', but no matter what I do, the character's HP is stuck on their current MaxHP for their level. However, if I set the command to 'decrease' the MaxHP, it will do it.

I'm not sure if it's a bug, or if I'm doing it wrong.

I have an item created, called the "Mysterious Leaf", which is supposed to grant a character a *random* pool of 1-10 MaxHP. But since the normal Effects don't allow a range of points when you "Grow Max HP" I decided to try to resort to having the item call a Common Event called "Random Effects".

Inside the CE, I have it set to None (For the trigger). Then I put "Control Variable: Random Growth 1..10", then put in an If condition:

If Party has Mysterious Leaf
Flash Screen (etc etc)
If Random Growth >= 1 (ensuring that it has to be at least 1)
Change Parameter: Entire Party, Max HP + {Random Growth}
Change Item: Mysterious Leaf -1
End
End

The point is: The CE does get called. The Random Growth Variable does get a random "value" but if the character's HP is already filled to the max (ex: 100/100 HP) this appears not to work?

Any suggestions would be appreciated. I hope this is clear enough.
Maybe its the item parameters, scope, consumable, etc.

Scope should be all allies, consumable should be yes.

Other than that, I can't say without seeing screen shots of your event and item setup.
Well, this is how I've set it up. I'm not sure what I'm missing. I had it also set to User, and Key Item instead.
1628919402751.png


1628919446483.png


Hope that helps?
From what I see, you have a conditional branch that checks if the party has a mysterious leaf in their inventory. But if you set that item to "Consumable: Yes" you lose one of these items before the Common Event gets called. And since you remove a leaf in your common event aswell, you essentially lose 2 leafs per use.

And maybe this problem occurs because you only have 1 of these items when you use it. So the conditional Branch of your common event sees "This player has no leaf, so skip this".

Try the following:
Use the item when you have atleast 2 of these leafs in your inventory.
If the common events works then, try either of the following with just 1 leaf in your inventory:

#1 Make the item "Consumable: No" and leave everything else.
OR
#2 Remove the Conditional Branch and the "Change Items" command from the Common Event
OR
#2 Remove the Conditional Branch from the Common Event and leave everything else.
#2 Remove the Conditional Branch /and the Change Item/ from the Common Event and leave everything else.

option 1 better for when the if check needs to check something different to make sure you can even use the item correctly.
like 'if x has state' (used for single target CEs) '>if x knows skill' you get the "already known text" and you still have item to try on a different actor.

option 2 better for when theres no chance to fail. stat growth would usually fall into option 2.

my only concern is the change param: 'Entire Party' because doesnt this only do active party?
if get any of these items before you have all party members they would miss out wouldnt they?
if these items are something you can just farm for then not much issue, but if only like 10 in the whole game (kind i always use but i dont normally do party wide stat growth) would want to ensure the event does every actor not just the party.
#2 Remove the Conditional Branch /and the Change Item/ from the Common Event and leave everything else.

option 1 better for when the if check needs to check something different to make sure you can even use the item correctly.
like 'if x has state' (used for single target CEs) '>if x knows skill' you get the "already known text" and you still have item to try on a different actor.

option 2 better for when theres no chance to fail. stat growth would usually fall into option 2.

my only concern is the change param: 'Entire Party' because doesnt this only do active party?
if get any of these items before you have all party members they would miss out wouldnt they?
if these items are something you can just farm for then not much issue, but if only like 10 in the whole game (kind i always use but i dont normally do party wide stat growth) would want to ensure the event does every actor not just the party.
The thing is I'm not sure how to target specific members through a Change Parameter thing, unless it does an if condition to see if this person is in the party, etc, etc. (I am aware that you can pick specific members for the Change Parameter, I did it for "Entire Party" to keep it simpler). I ended up removing the If Condition. It still works on the initial member I have. I don't plan to have very many party members join. Hm.

Now that I think about it, I could just do If Condition: If so-and-so is in Party, then trigger the condition? Maybe? I only foresee one to maybe three party members total for this game.
Try using this script in the common event that is called when the item is used:
Spoiler: Event
1629000056080.png

Here's the code:
Spoiler: Code
JavaScript:
$gameParty.members().forEach(function(m){
 m.addParam(0, 10);
});

If you want to change the amount gained, change the '10' to another value.
If you want to change the parameter raised, change the '0' to another value, 0 - 7 are the primary stats.
Check out the comment of entry 46 for more info on the parameter numbers

Here's a link to the script call documentation. I used a combination of entries 43 and 46.

Note: If you use this in battle, it might only work on the members in your current party, which may not be what you want. I'd test it out and see if it works on reserve members when out of battle just in case.

-EDIT- @Gryphbear

I just Remembered that you were looking for a random parameter gain. Substitute the above code for this:
Spoiler: Random Value
JavaScript:
$gameParty.members().forEach(function(m){
 m.addParam(0, Math.floor(Math.random() * max));
});

Change the 'max' to the maximum value you'd like to raise a parameter by. This should give each actor a random bonus to Max Hp.
single target common events (without knowing script) is done with a 'target' state from the skill/item.
the event would then check each actor for the state to know who the item was used on, and then just remove the state as part of the CE.
Wow, thank you for the replies! I found something that works for me. It was the script - it seemed the most elegant way to do it.
If you also don't want to exit the menu when running the event I thiiiink you can use this plugin by Triacontane: https://plugin-mz.fungamemake.com/archives/2584
If you also don't want to exit the menu when running the event I thiiiink you can use this plugin by Triacontane: https://plugin-mz.fungamemake.com/archives/2584
Thank you, but I'm already covered. Maybe someone else will find this useful 🙂
Thread closed

Original thread: https://forums.rpgmakerweb.com/threads/making-an-special-item-grant-random-maxhp-points.139582/