Tsukihime's Corpse Retrieval

Status
Not open for further replies.

Mawichan

Veteran
Veteran
Joined
Jan 24, 2018
Messages
55
Reaction score
6
First Language
Spanish
Primarily Uses
RMVXA
Hello there, I hope everyone's doing okay.
I just stumbled upon this old script for VX ace by Tsukihime.

The script creates an event after the player dies. The party loses all their equipment upon death but if they return to the spot where they died last time and interact with the event, they will retrieve their equipment.
However, for my project I'd rather the player lost gold while their equipment is left untouched.
Is that doable, though? If it is, could somebody help me achieve that?
Or are there any alternative scripts that do what I'm describing? So far this is the only one of its kind I've seen. This one is pretty much what I want, its only flaw is taking equipment instead of gold.

Any kind of help would be much appreciated, even an "I don't think it's possible" would do, at least I could just move on in peace.

Thank you for your time~
 

Harosata

Dramatic Lightning's BFF
Veteran
Joined
Aug 20, 2015
Messages
246
Reaction score
70
First Language
English
Primarily Uses
RMVXA
Let's see...

collect_corpse_armors and collect_corpse_weapons both make an array of the equipment under collect_corpse_items, which in turn is used in create_party_corpse under Game_Party. That in turn is used under the Game_Interpreter's create_corpse_event (Which should be the script call) to create a corpse event and then setup a corpse event, which uses Event_Commands to do the things.

So it could be possible as Event_Commands seem to use the same number as the Game_Interpreter. However, I would have to see how that works, but this is what I guess until I can work on it:

---

module's self.setup_event_commands - This is currently written to loop the arrays of weapons and armors. Gold's number should be 125.

Game_Interpreter's create_party_corpse - This creates an array from Game_Party. Might be possible to replace this with the party gold.

Game_Party's create_party_corpse - This currently handles the weapons, so if you want gold to be handled here instead...
 

Mawichan

Veteran
Veteran
Joined
Jan 24, 2018
Messages
55
Reaction score
6
First Language
Spanish
Primarily Uses
RMVXA
Wow so it could be possible.
Then could you help me with it please?
If so, take your time of course. It's not like it's urgent and the last thing I want is to be annoying.
Thanks for taking the time to look into this and kinda explaining what some of the things in the script do.
 

Harosata

Dramatic Lightning's BFF
Veteran
Joined
Aug 20, 2015
Messages
246
Reaction score
70
First Language
English
Primarily Uses
RMVXA
Alright, here's a code for gold loss instead of armor loss. Change Corpse_Gold_Percent (50% default) to alter how much you will lose/regain. Please be aware that this script hasn't correct any errors with the original script.

Code:
=begin
#===============================================================================
 Title: Corpse Retrieval Gold Edition
 Author: Hime/Harosata
 Date: Aug 17, 2013
--------------------------------------------------------------------------------
 ** Change log
February 22, 2018
 - Changed to allow gold loss and removed equipment loss
 Aug 17, 2013
   - bug fix: game crashes when creating corpse on map with no events
 Mar 28, 2013
   - Initial release
--------------------------------------------------------------------------------   
 ** Terms of Use
 * Free to use in non-commercial projects
 * Contact me for commercial use
 * No real support. The script is provided as-is
 * Will do bug fixes, but no compatibility patches
 * Features may be requested but no guarantees, especially if it is non-trivial
 * Credits to Hime Works in your project
 * Preserve this header
--------------------------------------------------------------------------------
 ** Description
 
 This script adds "corpse retrieval" functionality to your project.
 
 It provides a script call that allows you to create a "corpse" of your
 current active party. All of the equips that are equipped will be removed
 from the members and placed in an event. When you retrieve your corpse,
 you will recover all of those equips.
 
--------------------------------------------------------------------------------
 ** Installation
 
 Place this script below Materials and above Main

--------------------------------------------------------------------------------
 ** Usage
 
 To create a corpse, make a script call

    create_party_corpse
    
 Then perform any other commands as needed. When the player returns to pick up
 the corpse all lost equips will be recovered.
 
#===============================================================================
=end
$imported = {} if $imported.nil?
$imported["TH_CorpseRetrieval"] = true
#===============================================================================
# ** Configuration
#===============================================================================
module TH
  module Corpse_Retrieval

    # Character name and index to use for the corpse
    Corpse_Name = "$Coffin"
    Corpse_Index = 0
    
    Corpse_Gold_Percent = 0.5
    
#===============================================================================
# ** Rest of script
#===============================================================================

    #---------------------------------------------------------------------------
    #
    #---------------------------------------------------------------------------
    def self.create_corpse_event(corpse_items, x, y)
      ev = RPG::Event.new(x, y)
      setup_event_page(ev.pages[0])
      ev.pages[0].list = []
      setup_event_commands(corpse_items, ev.pages[0].list)
      return ev
    end
    
    #---------------------------------------------------------------------------
    #
    #---------------------------------------------------------------------------
    def self.setup_event_page(page)
      page.trigger = 0
      page.direction_fix = true
      page.priority_type = 1
      page.graphic.character_name = Corpse_Name
      page.graphic.character_index = Corpse_Index
    end
    
    #---------------------------------------------------------------------------
    #
    #---------------------------------------------------------------------------
    def self.setup_event_commands(corpse_items, list)
      list << RPG::EventCommand.new(101, 0, ["", 0, 0, 2])
      list << RPG::EventCommand.new(401, 0, ["Corpse retrieved"])
        list << RPG::EventCommand.new(125, 0, [0, 0, corpse_items])


      list << RPG::EventCommand.new("delete_corpse_event")
      list << RPG::EventCommand.new
    end
  end
end

#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
class Game_Interpreter
 
  #-----------------------------------------------------------------------------
  # Call this method to unequip all currently equipped items in the active
  # battle party and place them in an event.
  #-----------------------------------------------------------------------------
  def create_party_corpse(map_id=$game_map.map_id, x=$game_player.x, y=$game_player.y)
    corpse_items = ($game_party.gold * TH::Corpse_Retrieval::Corpse_Gold_Percent).to_i
    corpse_items = 0 if corpse_items < 0
    corpse_items = $game_party.gold if corpse_items > $game_party.gold
    $game_party.lose_gold(corpse_items)
    corpse_event = TH::Corpse_Retrieval.create_corpse_event(corpse_items, x, y)
    $game_system.add_corpse_event(map_id, corpse_event)
    $game_map.setup_corpse_events
  end
 
  #-----------------------------------------------------------------------------
  # Deletes the current corpse event and removes it from the system and map.
  #-----------------------------------------------------------------------------
  def command_delete_corpse_event
    corpse_event = $game_map.events[@event_id].instance_variable_get(:@event)
    $game_system.remove_corpse_event(@map_id, corpse_event)
    $game_map.remove_corpse_event(@event_id)
  end
end

#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
class Game_System
 
  attr_reader :party_corpses  # stores locations of party corpses
 
  alias :th_corpse_retrieval_initialize :initialize
  def initialize
    th_corpse_retrieval_initialize
    @party_corpses = {}
  end
 
  def get_corpse_events(map_id)
    @party_corpses[map_id] ||= []
    @party_corpses[map_id]
  end
 
  def add_corpse_event(map_id, event)
    @party_corpses[map_id] ||= []
    @party_corpses[map_id].push(event)
  end
 
  def remove_corpse_event(map_id, event)
    @party_corpses[map_id].delete(event)
  end
end

#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
class Game_Map
 
  alias :th_corpse_retrieval_setup_events :setup_events
  def setup_events
    th_corpse_retrieval_setup_events
    setup_corpse_events
  end
 
  def setup_corpse_events
    event_id = (@events.keys.max || 0) + 1
    $game_system.get_corpse_events(@map_id).each do |ev|
      ev.id = event_id
      @events[event_id] = Game_Event.new(@map_id, ev)
      event_id += 1
    end
    SceneManager.scene.instance_variable_get(:@spriteset).refresh_characters if SceneManager.scene_is?(Scene_Map)
    @need_refresh = true
  end
 
  def remove_corpse_event(event_id)
    @events.delete(event_id)
    SceneManager.scene.instance_variable_get(:@spriteset).refresh_characters if SceneManager.scene_is?(Scene_Map)
    @need_refresh = true
  end
end
 

Mawichan

Veteran
Veteran
Joined
Jan 24, 2018
Messages
55
Reaction score
6
First Language
Spanish
Primarily Uses
RMVXA
Thank you very much! It works really well.
It's okay if this does not "correct any errors with the original script."
This alone is a lot of help as is (and thankfully so far I haven't encountered any issues with either version of the script).

I just have one more question, if I may ask. Is it possible to remove a corpse event currently on the map with a script call?
Again thank you so much, you are like a godsend.
Best wishes~
 

Harosata

Dramatic Lightning's BFF
Veteran
Joined
Aug 20, 2015
Messages
246
Reaction score
70
First Language
English
Primarily Uses
RMVXA
From what I can see, that corpse event is created and given a list of things said event will do, which includes deleting the event. That should activate Game_Interpreter's command_delete_corpse_event to remove the event from both the system and the map.

I can guess that creating a copy of that command should give us the ability to remove an event by its number (current one takes current event id, so need one to take any id). The difficult part would be finding out what that number is, but it does seem like corpse events will be pushed to the end of the event array, so in most cases, the event to be removed is ideally the last index.
 
Last edited:

Mawichan

Veteran
Veteran
Joined
Jan 24, 2018
Messages
55
Reaction score
6
First Language
Spanish
Primarily Uses
RMVXA
I see. I had been trying to use command_delete_corpse_event as a script call, but it always results in an error. Must be because it needs the event id number, as you say. How do I obtain the number of the last index?
 

Mawichan

Veteran
Veteran
Joined
Jan 24, 2018
Messages
55
Reaction score
6
First Language
Spanish
Primarily Uses
RMVXA
Hey, nevermind my last question. I still haven't figured out how to erase the event with a script call, but I changed some things in my project so I don't need to do that anymore.
Once again thank you very much for helping me with this and for your time.
Everything is going smoothly now, so this thread can be closed now.
Have a nice day!
 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

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.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,019
Members
137,564
Latest member
McFinnaPants
Top