Random Damage Money attack

Hello Community! Yet another question!

I need some help making a certain skill.

So, my character has a skill wich does from 0-9999 damage to all enemies and spends that much money, subtracting it from your pocket.

I also wanted it to say something like "You don't have enough money!", when it's higher than what you have, rendering the skill useless.

I know this must be made with variables but I really suck working with those. 🙁

Any help aprecciated, and please tell me if this isn't enough info.
This is a little different from what you asked, hope it helps anyway, you could put this in the skill damage formula 

if $game_party.gold > 10000; rand(10000); else; rand($game_party.gold); end;and then call a common event to remove a random quantity of money, maybe based on a percentage (I don't know how to set it to the exact damage you dealt with the skill  >_>  , hope someone can help you with this)

In the common event put this script(substitute variable_id with a free variable index):

$game_variables[variable_id] = rand($game_party.gold/10) + $game_party.gold/100$game_party.gain_gold(-$game_variables[variable_id])if $game_variables[variable_id] > 0$game_message.add("You lost \\V[variable_id] gold")endThis would remove a random value between 1% and 10% of your total gold, if someone knows what is the script call for the exact damage inflicted write it instead of "rand($game_party.gold/10) + $game_party.gold/100"
I think I'd use something like this as the damage formula:

m = rand(10000).to_i; if $game_party.gold >= m; $game_party.gold -= m; else; m = 0; end; mYou could also push a message to the battle log that the player doesn't have enough money but it requires scripting outside of the formula (and inside the Script Editor).

I rather like Eat's idea of simply not letting it pick a damage number that's bigger than your current gold; here's a formula that would implement it:

m = [rand(10000).to_i, $game_party.gold].min; $game_party.gold -= m; mAs a cute little sidenote, in one of my games ("How Badly") there is a merchant enemy that uses a similar attack, damaging you for a highly variable amount.  When they use this skill, your characters gain a skill called "Pick Up The Money" that lets you use your turn to collect the money they threw at you, gaining an amount of Gold proportional to the damage their attack did!
The common event works and the formula for the variable.

If I use Wavelenghts formula, It says the value of gold lost but doesn't do actual damage and if I have o gold they say a float number like 0.493848374, etc.

But thanks anyway 🙂

EDIT:

If I use EatYourBeetS formula, it will do damage but the message will say another value.
Ok I got it, put this in the damage formula (choose a free variable id)

if $game_party.gold > 10000; v[id]=rand(10000); else; v[id]=rand($game_party.gold); end; v[id];and this in the common event:

$game_party.gain_gold(-$game_variables[id])if $game_variables[id] > 0$game_message.add("You lost \\V[id] gold")endTell me if it works!
I think I'd use something like this as the damage formula:

m = rand(10000).to_i; if $game_party.gold >= m; $game_party.gold -= m; else; m = 0; end; mYou could also push a message to the battle log that the player doesn't have enough money but it requires scripting outside of the formula (and inside the Script Editor).

I rather like Eat's idea of simply not letting it pick a damage number that's bigger than your current gold; here's a formula that would implement it:

m = [rand(10000).to_i, $game_party.gold].min; $game_party.gold -= m; m
If I use Wavelenghts formula, It says the value of gold lost but doesn't do actual damage and if I have o gold they say a float number like 0.493848374, etc.
But thanks anyway 🙂
Are you sure you put the last m in there?  That would be my best guess for why you're getting gold loss but zero damage.

And I think the float is because you had created a float value for gold with one of your other tries to make this work.  It shouldn't happen on a clean file.
Are you sure you put the last m in there?  That would be my best guess for why you're getting gold loss but zero damage.

And I think the float is because you had created a float value for gold with one of your other tries to make this work.  It shouldn't happen on a clean file.
Yes, I've put it in order but it still says no damage, even on a clean project. Maybe I'm doing it wrong?

Ok I got it, put this in the damage formula (choose a free variable id)

if $game_party.gold > 10000; v[id]=rand(10000); else; v[id]=rand($game_party.gold); end; v[id];and this in the common event:

$game_party.gain_gold(-$game_variables[id])if $game_variables[id] > 0$game_message.add("You lost \\V[id] gold")endTell me if it works!
It works altought the float number is still zero, but the player will never have 0 gold(I think...-_-')

I think this can be closed now!

Thanks for the help!

Original thread: https://forums.rpgmakerweb.com/threads/random-damage-money-attack.37814/