Is there a way I can streamline HP and chance of MP recover into the formula

So I have an item called an "Unknown Vial" that recovers HP and a chance to recover MP

Currently, I have the item set as "HP Recover" with the formula "[250,650,1500].sample" and I have it call a common event that rolls a random number between 1-10 and if the number is 7 or higher, the party member also recovers 450 MP

And I use target actor ID in this as a variable.


Is there a way to include that 40% chance to recover 450 MP into that HP recover formula?
Calculating the chance and adding the MP could be done with one of these calls:
Ruby:
a.mp += rand(100) < 30 ? 450 : 0;
a.mp += rand(10) < 3? 450 : 0;

You can edit the values, 3 or 30, to fit your needs. Keep in mind it that random numbers begin with 0 and omit the last value (100). So the actual range of results ends up being 0-99 here.

The semicolon ; should come BEFORE the rest of your item or skill formula. The last value set should be the HP.
I will try this out. Thanks.

Can this also be used to have a move that heals yourself while dealing damage to a monster that is not necessarily a drain move?

Original thread: https://forums.rpgmakerweb.com/threads/is-there-a-way-i-can-streamline-hp-and-chance-of-mp-recover-into-the-formula.180138/