Reduce gold with every step?

Hello,

how can I make it that I lose a certain amount of gold with every step I take when a specific switch is on?

I tried with a conditional branch but the gold is dropping to 0 without me moving.

I tried to make a loop but the game screen stays black (music is playing).

I created a variable set to steps already but I have no idea how to continue.

Thank you very much for any help!
if : script: $gameSwitch.value(3) && $gamePlayer.isMoving()
gold -1
end

I dont know the ruby syntax to check if the player if moving.
but you can search those 2 up and it should work 🙂

this checks if switch 3 is on and player is moving, if they do, lose 1 gold.
if : script: $gameSwitch.value(3) && $gamePlayer.isMoving()
gold -1
end

I dont know the ruby syntax to check if the player if moving.
but you can search those 2 up and it should work 🙂

this checks if switch 3 is on and player is moving, if they do, lose 1 gold.
A stupid question but how do I add the "if" part? I can add a conditional branch but this is different, right?
I just tried it with some javascript:

Ok, forget everything. I totally missed that we are in the RMVXA forum. Sorry for the confusion
I just tried it with some javascript:

(() => {
'use strict';
Game_Player.prototype.increaseSteps = function() {
Game_Character.prototype.increaseSteps.call(this);

if($gameParty._gold > 0) {
$gameParty._gold -= 1;
}
};
})();
1725185945337.png

I added this in the scripts but I get this error.

I think I lack the knowledge to get this request to work.

The idea was to recruit sellswords but have them charging with time or else steps on the worldmap
but oh well I need to find another way to do this.

Thank you for helping me out but I can't do this, I lack the basics to understand what you are telling me to do XD
You should just event it, in a parallel process.

Create 4 variables, "Pos X", "Pos Y", "Last Pos X" and "Last Pos Y".

Code:
Pos X = Player Pos X
Pos Y = Player Pos Y
IF Pos X is not Last Pos X:
  Remove Gold
  Last Pos X = Pos X
End IF
IF Pos Y is not Last Pos Y:
  Remove Gold
  Last Pos Y = Pos Y
End IF

I just tried it with some javascript:

Game_Player.prototype.increaseSteps = function() {
Game_Character.prototype.increaseSteps.call(this);

if($gameParty._gold > 0) {
$gameParty._gold -= 1;
}
};


That's a better solution:
JavaScript:
if ($gamePlayer.isMovementSucceeded() && $gameParty._gold > 0) {
    $gameParty._gold -= 1;
}
JavaScript does not work in RM VX Ace
You should just event it, in a parallel process.

Create 4 variables, "Pos X", "Pos Y", "Last Pos X" and "Last Pos Y".

Code:
Pos X = Player Pos X
Pos Y = Player Pos Y
IF Pos X is not Last Pos X:
  Remove Gold
  Last Pos X = Pos X
End IF
IF Pos Y is not Last Pos Y:
  Remove Gold
  Last Pos Y = Pos Y
End IF


JavaScript does not work in RM VX Ace
Hi I will try this thanks

Silly question, but when you type if is this the conditional branch? Or how do I say if?

Thank you!
Hi I will try this thanks

Silly question, but when you type if is this the conditional branch? Or how do I say if?

Thank you!

Ja 🙂
Ok danke :LZSjoy:
Ruby:
class Game_Party < Game_Unit
  alias r2_lose_gold_step_switch  increase_steps
  def increase_steps
    r2_lose_gold_step_switch
    lose_gold_step
  end
  def lose_gold_step
    if $game_switches[3] == true
      lose_gold(1)
    end
  end
end
Ron, I'd prefer you to let the OP choose the game variable that will hold the amount of gold to be deducted after every step...
Ron, I'd prefer you to let the OP choose the game variable that will hold the amount of gold to be deducted after every step...
HAHAHA!!!

You replied to my code snippet stating that the OP doesn't know enough to change a number.
And if they don't understand they would eventually ask.
But you singled me out as I simply duplicated what ShadowDragon did. Go look.
Seriously, stay out of my help.
I didn't want to be mean, I just gave you a piece of advice so I wouldn't end up posting a slightly modified version of the code that you were working on. I mean, I was trying to respect your work instead of "hijacking it" somehow.

Original thread: https://forums.rpgmakerweb.com/threads/reduce-gold-with-every-step.171584/