Halve money at game over

Ina00

Veteran
Veteran
Joined
Oct 10, 2020
Messages
38
Reaction score
0
First Language
Italian
Primarily Uses
RMVXA
I want to make that if the player dies, after game over screen, when the save is loaded money are halved. I don't know if i need scripts or not.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,660
Reaction score
563
First Language
English
Primarily Uses
RMVXA
I don't think there is a way to completely prevent the player from recovering their gold after losing/dying.
In battle -> player dies -> loads save file -> take half gold.
But then if the player starts a saved game it would do the same.
run game -> select continue -> loads save file -> take half gold.
This is even if they didn't lose the battle or die.

When the game is at the title screen there is no code running to check what gold the party has.
After loading the game the gold value can be checked.

There are a few scripts that can do what you want

but if the player quit the game and started again it would not have any effect. And that is only for retrying battles.

What you would need to do is edit the save file, that's a totally different script.

There is this script
you could change it to half the players gold and resave the save file so that the half gold is saved.
this script is for non-commercial only.

but as I said, if the player quit and loaded again the gold would be the same.
However it looks like you could set this script to option 0 so that it loads the last save file no matter what.
Then half the gold and resave. but as I said if the player clicks on the x to close the game before loading the saved game, then this does nothing.
So there is no perfect solution.

Would you want a script that loads the last save file automatically after dying? If so then taking gold away and resaving is not hard.
 

Kuro DCupu

Trust me, I'm a veteran RMer
Veteran
Joined
Jul 6, 2014
Messages
480
Reaction score
1,467
First Language
Indonesia
Primarily Uses
RMMV
If you are using the "Game Over" from the system, yea.

One way is that your "Game Over" is evented (fake).
If there's battle in your game, make sure it's also evented.
This evented game over is just showing a picture and transfer the player to the last save point.
Basically, you do not actually load the game, but just return to the last checkpoint.
But only if you don't mind that all switches / variables and everything system related are not resetting.

Another way requires scripting...
You call a script that save the game in an unused slot directly after game over. (example, save9)
After save screen, you put a condition to check wether save9 exist or not.
If yes, call a script that load only your gold.
Halven that gold then delete save9.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,367
Reaction score
7,676
First Language
German
Primarily Uses
RMMV
yes, that needs scripts - and several of them in fact, because if you load a default save then the save won't know that the player died since the last save.

minimum is a script for persistent variables, and probably a script to replace game over with a game oveer common event. Both of those exist already.

EDIT:
ninja'd - but contrary to what the posters above think there is a way to make this happen.
store gold in one persistent variable
store number of game-overs in another persistent variable
store number of saves in third persistent variable
have a death common event count up the number of deaths but not the saves
have a parallel process once per second or so check the number of deaths and compare it with a NON-persistent number storing the same. If the number of deaths is higher, halve gold and update the non-persistent number.

it's abit more complex than described, but you can identify deaths this way and have them affect the current game.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,660
Reaction score
563
First Language
English
Primarily Uses
RMVXA
Just wrote this. Let me know if it works for what you want.
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Lose gold on Death           ║  Version: 1.00     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║    Date Created    ║
# ║                                     ╠════════════════════╣
# ║ permanently lose gold on death      ║    03 Dec 2020     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Set option to use party gold before death or             ║
# ║ use the party gold from the save file                    ║
# ║ Specify value to determine how much gold to lose (%)     ║
# ║ Specify to allow player to press a button on Game Over   ║
# ║ screen. If true, this will allow player to close the game║
# ║ in order to prevent this script from cutting the gold    ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝

module R2
  module Gameover
    Goldcut = 0.75 # 75% of current gold in party is kept
    Use_Party_Gold = true
    # will use the current party gold not the saved gold if true
    Wait_for_Button = true
  end
end

class Scene_Gameover < Scene_Base
  def update
    super
    if R2::Gameover::Wait_for_Button == true
      goto_gold_cut if Input.trigger?(:C) || Input.trigger?(:B)
    else
      goto_gold_cut
    end
  end
  def fadeout_speed
    return 60
  end
  def fadein_speed
    return 30
  end
  #--------------------------------------------------------------------------
  # * Transition to saved game
  #--------------------------------------------------------------------------
  def goto_gold_cut
    if DataManager.save_file_exists?
      if R2::Gameover::Use_Party_Gold == true
        current = $game_party.gold
        DataManager.load_game(DataManager.last_savefile_index)
      else
        DataManager.load_game(DataManager.last_savefile_index)
        current = $game_party.gold
      end
      Sound.play_load
      fadeout_all
      $game_system.on_after_load
      SceneManager.goto(Scene_Map)
      cut = (current * R2::Gameover::Goldcut).to_i
      $game_party.lose_gold(current)
      $game_party.gain_gold(cut)
      $game_system.on_before_save
      DataManager.save_game(DataManager.last_savefile_index)
    else
      goto_title
    end
  end
end
 

Ina00

Veteran
Veteran
Joined
Oct 10, 2020
Messages
38
Reaction score
0
First Language
Italian
Primarily Uses
RMVXA
Just wrote this. Let me know if it works for what you want.
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Lose gold on Death           ║  Version: 1.00     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║    Date Created    ║
# ║                                     ╠════════════════════╣
# ║ permanently lose gold on death      ║    03 Dec 2020     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Set option to use party gold before death or             ║
# ║ use the party gold from the save file                    ║
# ║ Specify value to determine how much gold to lose (%)     ║
# ║ Specify to allow player to press a button on Game Over   ║
# ║ screen. If true, this will allow player to close the game║
# ║ in order to prevent this script from cutting the gold    ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝

module R2
  module Gameover
    Goldcut = 0.75 # 75% of current gold in party is kept
    Use_Party_Gold = true
    # will use the current party gold not the saved gold if true
    Wait_for_Button = true
  end
end

class Scene_Gameover < Scene_Base
  def update
    super
    if R2::Gameover::Wait_for_Button == true
      goto_gold_cut if Input.trigger?(:C) || Input.trigger?(:B)
    else
      goto_gold_cut
    end
  end
  def fadeout_speed
    return 60
  end
  def fadein_speed
    return 30
  end
  #--------------------------------------------------------------------------
  # * Transition to saved game
  #--------------------------------------------------------------------------
  def goto_gold_cut
    if DataManager.save_file_exists?
      if R2::Gameover::Use_Party_Gold == true
        current = $game_party.gold
        DataManager.load_game(DataManager.last_savefile_index)
      else
        DataManager.load_game(DataManager.last_savefile_index)
        current = $game_party.gold
      end
      Sound.play_load
      fadeout_all
      $game_system.on_after_load
      SceneManager.goto(Scene_Map)
      cut = (current * R2::Gameover::Goldcut).to_i
      $game_party.lose_gold(current)
      $game_party.gain_gold(cut)
      $game_system.on_before_save
      DataManager.save_game(DataManager.last_savefile_index)
    else
      goto_title
    end
  end
end
This do EXACTLY do what I wanted. Thank you very much! I love this community <3
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,090
Members
137,587
Latest member
Usagiis
Top