RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Key Equipment Removal by Lytanathan

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 82
Living proof that paradoxes exist in reality.
I've lurked on this forum long enough, it's time I actually contribute something. Thus:

Key Equipment Removal
Version: 1.0
Author: Lytanathan

Description

Basically, all this script does is remove weapons or armor with a price of 0 from an actor before the actor is removed from your party. This could be useful if you have a piece of equipment that acts as a key item in your game, and there is the potential that a character may have it equipped when he or she leaves your party for any reason. It would not be good to find yourself in a dungeon, only to discover that your cleric had the Staff of Power equipped when she was kidnapped, and you needed it to open the sealed door barring the way to rescue her, now would it?

Instructions

Simply copy and paste the script above Main and below Materials in the Script Editor. No configuration in the code is necessary.
To make a weapon or armor that is unequipped when an actor is removed from the party, simply make it unsellable (set the price to 0)

Code: [Select]
#==============================================================================
# Key Equipment Removal by Lytanathan
# -----------------------------------------------------------------------------
# If you have any equipment that is unsellable (aka equippable key items), you
# probably don't want the player to lose the item if an actor is removed from
# your party. This script overrides the remove_actor function of Game_Party so
# that any weapon or armor with a price of 0 is removed from the actor before
# he/she/it is removed from the party.
# -----------------------------------------------------------------------------
# Instructions
# -----------------------------------------------------------------------------
# Copy and paste this script into the Script Editor above Main and below
# Materials.
# To make a weapon or armor that is unequipped when an actor is removed, assign
# its price to 0 (make it unsellable).
# -----------------------------------------------------------------------------
# Compatability
# -----------------------------------------------------------------------------
# I haven't done a lot of testing on this script, other than to see if it works.
# Compatibility problems may occur, especially with scripts that change the
# party or the equipment systems.
#==============================================================================

class Game_Party < Game_Unit

  #--------------------------------------------------------------------------
  # * Remove Actor
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  def remove_actor(actor_id)

    for i in 0..$game_actors[actor_id].equips.size
      if $game_actors[actor_id].equips[i] != nil
        if $game_actors[actor_id].equips[i].price == 0
          $game_actors[actor_id].change_equip(i, nil)
        end
      end
    end
   
    @actors.delete(actor_id)
    $game_player.refresh
  end
 
end

Potential Issues

I haven't done a lot of testing on this script, other than to see if it works. Compatibility problems may occur, especially with scripts that change the party or the equipment systems.

Credit

Lytanathan
« Last Edit: October 11, 2010, 06:43:54 PM by Lytanathan »

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
This looks like a cool script.  The only thing that I would recommend is using the equips definition instead of making your own array, which is more efficient and would be more compatible with custom equipment scripts. Also, instead of the 0..4, you should use 0..@item.size. But these are just small nitpicks.
« Last Edit: October 07, 2010, 11:19:25 PM by cozziekuns »

**
Rep:
Level 82
Living proof that paradoxes exist in reality.
Thanks for the advice! Pretty much cut the code in half, and it still works!
As you could probably tell, I'm not a very good scripter yet. But I'm working on it!
« Last Edit: October 11, 2010, 06:51:01 PM by Lytanathan »