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.
Items with weight

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 83
As requested by MR_Wiggles:
Items with weight - script

What does this script do?
  • with '\w<VALUE>' in the description you allocat a weight with an item/weapon/armor
  • when the party exceeds the MAX-limit it gets slowed down and a certain switch will be set if wanted
  • when the party exceeds the CARRY_OVER_MAX-limit no more items may be picked up, but a switch will be set for further processing everytime you try to pick something to heavy up
  • you cannot buy more than you can carry
  • items with no allocated weight will have the weight '0'
  • you may change the MAX and CARRY_OVER_MAX-limits whenever you want with script commands
  • you may drop an item anytime you want to lose weight
  • weight can be decimal

Simply enter it above main, everything is aliased, so it should work with nearly every script that doesn't replace any of those routines.
If so, then just enter it beneath those scripts ;)
The little adjustments you have to do within the script are in the first lines after the header in the first lines of the script  :)

Code:
Spoiler for:
Code: [Select]
################################################################################
#   Item Weight V 1.1                                                          #
#         by Tidloc                                                            #
################################################################################
#   This script allows the player to carry only a limited ammount of weight.   #
#   To define the weight of an item, weapon or armor simply enter \w<*VALUE*>  #
#   in the description box of that item. If left out the weight will be 0!     #
################################################################################
#   Definition of the constants:                                               #
#    TIDLOC_GROUPWEIGHT_MAX ................. limit of weight, where the       #
#                                             player will be slowed down.      #
#    TIDLOC_GROUPWEIGHT_SHOW_MAX ............ true if GROUPWEIGHT_MAX shall be #
#                                             used  for max weight, not        #
#                                             CARRY_OVER_MAX.                  #
#    TIDLOC_GROUPWEIGHT_CARRY_OVER_MAX ...... maximum weight, if exceeding     #
#                                             this limit, no more items can be #
#                                             picked up.                       #
#    TIDLOC_GROUPWEIGHT_MAT_POWER ........... mathematicaly negative power of  #
#                                             tens used in display window for  #
#                                             weigth                           #
#    TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH .... the number of the global switch  #
#                                             which shall be turned true if    #
#                                             the max-limit is exceeded.       #
#    TIDLOC_GROUPWEIGHT_OVERWEIGHT_SWITCH ... the number of the global switch  #
#                                             which shall be turned true if    #
#                                             you cannot carry any more.       #
#                   if a switch is 0, it's not used                            #
################################################################################
#   To alter this limits in game use the following script-commads:             #
#    $game_temp._tidloc_pweight(*VALUE*) for GROUPWEIGHT_MAX                   #
#    $game_temp._tidloc_pmax(*VALUE*) for CARRY_OVER_MAX                       #
#   You may leave Value empty to reset to the constants.                       #
################################################################################
#  You are free to use this script in what ever game you want, but please      #
#  credit me for this hell of work ^_^                                         #
#       Credits also to Albertfish for his help when it was needed!            #
################################################################################


TIDLOC_GROUPWEIGHT_MAX               = 5
TIDLOC_GROUPWEIGHT_SHOW_MAX          = false
TIDLOC_GROUPWEIGHT_CARRY_OVER_MAX    = 10
TIDLOC_GROUPWEIGHT_MAT_POWER         = 0
TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH  = 1
TIDLOC_GROUPWEIGHT_OVERWEIGHT_SWITCH = 2



class Game_Temp
  attr_accessor :_tidloc_itemweight
  attr_accessor :_tidloc_weaponweight
  attr_accessor :_tidloc_armorweight
  attr_accessor :_tidloc_groupweight
  attr_accessor :_tidloc_groupweight_max
  attr_accessor :_tidloc_groupweight_carry_over_max
  attr_accessor :_tidloc_iweight_slow
  
  alias wo_weight_initialize initialize
  def initialize
    wo_weight_initialize
    self._tidloc_itemweight                  = []
    self._tidloc_weaponweight                = []
    self._tidloc_armorweight                 = []
    self._tidloc_groupweight                 = 0
    self._tidloc_groupweight_max             = TIDLOC_GROUPWEIGHT_MAX
    self._tidloc_groupweight_carry_over_max  = TIDLOC_GROUPWEIGHT_CARRY_OVER_MAX
    self._tidloc_iweight_slow                = false
    
    for i in 1...$data_items.size
      if $data_items[i].description[0] != nil
        text  = $data_items[i].description
        text2 = ""
        text.gsub!(/\\w<([0-9]+)>/) {"\1[#{$1}]"}
        while ((c = text.slice!(/./m)) != nil)
          if c != "\1"
            text2 += c
          else
            text.sub!(/\[([_A-Za-z0-9-]+)\]/, "")
            self._tidloc_itemweight[i]=$1.to_i
          end
        end
        $data_items[i].description = text2
      end
      self._tidloc_itemweight[i] = 0 if self._tidloc_itemweight[i].nil?
    end
    for i in 1...$data_weapons.size
      if $data_weapons[i].description[0] != nil
        text  = $data_weapons[i].description
        text2 = ""
        text.gsub!(/\\w<([0-9]+)>/) {"\1[#{$1}]"}
        while ((c = text.slice!(/./m)) != nil)
          if c != "\1"
            text2 += c
          else
            text.sub!(/\[([_A-Za-z0-9-]+)\]/, "")
            self._tidloc_weaponweight[i]=$1.to_i
          end
        end
        $data_weapons[i].description = text2
      end
      self._tidloc_weaponweight[i] = 0 if self._tidloc_weaponweight[i].nil?
    end
    for i in 1...$data_armors.size
      if $data_armors[i].description[0] != nil
        text  = $data_armors[i].description
        text2 = ""
        text.gsub!(/\\w<([0-9]+)>/) {"\1[#{$1}]"}
        while ((c = text.slice!(/./m)) != nil)
          if c == "\1"
            text.sub!(/\[([_A-Za-z0-9-]+)\]/, "")
            self._tidloc_armorweight[i]=$1.to_i
          else
            text2 += c
          end
        end
        $data_armors[i].description = text2
      end
      self._tidloc_armorweight[i] = 0 if self._tidloc_armorweight[i].nil?
    end
  end
  
  def _tidloc_pweight(new_weight=TIDLOC_GROUPWEIGHT_MAX)
    self._tidloc_groupweight_max = new_weight
  end
  
  def _tidloc_pmax(new_max=TIDLOC_GROUPWEIGHT_CARRY_OVER_MAX)
    self._tidloc_groupweight_carry_over_max = new_max
  end
end

class Game_Party
  def tidloc_slowing(slow=true)
    if slow
      $game_player.tidloc_alt_speed -1
    else
      $game_player.tidloc_alt_speed 1
    end
  end
  
  alias tidloc_iweight_item gain_item
  def gain_item(item_id, n, equip=false)
    if item_id > 0 && !equip
      $game_temp._tidloc_groupweight += $game_temp._tidloc_itemweight[item_id] * ([[item_number(item_id) + n, 0].max, 99].min - item_number(item_id))
    end
    if $game_temp._tidloc_groupweight > $game_temp._tidloc_groupweight_carry_over_max
      $game_switches.[]=(TIDLOC_GROUPWEIGHT_OVERWEIGHT_SWITCH, true) if TIDLOC_GROUPWEIGHT_OVERWEIGHT_SWITCH != -1
      if !$game_temp._tidloc_iweight_slow
        $game_temp._tidloc_iweight_slow = true
        tidloc_slowing
      end
    elsif $game_temp._tidloc_groupweight > $game_temp._tidloc_groupweight_max && !$game_temp._tidloc_iweight_slow
      $game_temp._tidloc_iweight_slow = true
      $game_switches.[]=(TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH, true) if TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH != -1
      tidloc_slowing
      tidloc_iweight_item(item_id, n)
    elsif $game_temp._tidloc_groupweight <= $game_temp._tidloc_groupweight_max && $game_temp._tidloc_iweight_slow
      $game_temp._tidloc_iweight_slow = false
      $game_switches.[]=(TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH, false) if TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH != -1
      tidloc_slowing false
      tidloc_iweight_item(item_id, n)
    else
      tidloc_iweight_item(item_id, n)
    end
  end
  
  alias tidloc_iweight_weap gain_weapon
  def gain_weapon(weapon_id, n, equip=false)
    if weapon_id > 0 && !equip
      $game_temp._tidloc_groupweight += $game_temp._tidloc_weaponweight[weapon_id] * ([[weapon_number(weapon_id) + n, 0].max, 99].min - weapon_number(weapon_id))
    end
    if $game_temp._tidloc_groupweight > $game_temp._tidloc_carry_over_max
      $game_switches.[]=(TIDLOC_GROUPWEIGHT_OVERWEIGHT_SWITCH, true) if TIDLOC_GROUPWEIGHT_OVERWEIGHT_SWITCH != -1
      if !$game_temp._tidloc_iweight_slow
        $game_temp._tidloc_iweight_slow = true
        tidloc_slowing
      end
    elsif $game_temp._tidloc_groupweight > $game_temp._tidloc_groupweight_max && !$game_temp._tidloc_iweight_slow
      $game_temp._tidloc_iweight_slow = true
      $game_switches.[]=(TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH, true) if TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH != -1
      tidloc_slowing
      tidloc_iweight_weap(weapon_id, n) if TIDLOC_GROUPWEIGHT_CARRY_OVER_MAX
      $game_switches.[]=(TIDLOC_GROUPWEIGHT_OVERWEIGHT_SWITCH, true) if !TIDLOC_GROUPWEIGHT_CARRY_OVER_MAX
    elsif $game_temp._tidloc_groupweight <= $game_temp._tidloc_groupweight_max && $game_temp._tidloc_iweight_slow
      $game_temp._tidloc_iweight_slow = false
      $game_switches.[]=(TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH, false) if TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH != -1
      tidloc_slowing false
      tidloc_iweight_weap(weapon_id, n)
    else
      tidloc_iweight_weap(weapon_id, n)
    end
  end
  
  alias tidloc_iweight_arm gain_armor
  def gain_armor(armor_id, n, equip=false)
    if armor_id > 0 && !equip
      $game_temp._tidloc_groupweight += $game_temp._tidloc_armorweight[armor_id] * ([[armor_number(armor_id) + n, 0].max, 99].min - armor_number(armor_id))
    end
    if $game_temp._tidloc_groupweight > $game_temp._tidloc_groupweight_carry_over_max
      $game_switches.[]=(TIDLOC_GROUPWEIGHT_OVERWEIGHT_SWITCH, true) if TIDLOC_GROUPWEIGHT_OVERWEIGHT_SWITCH != -1
      if !$game_temp._tidloc_iweight_slow
        $game_temp._tidloc_iweight_slow = true
        tidloc_slowing
      end
    elsif $game_temp._tidloc_groupweight > $game_temp._tidloc_groupweight_max && !$game_temp._tidloc_iweight_slow
      $game_temp._tidloc_iweight_slow = true
      $game_switches.[]=(TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH, true) if TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH != -1
      tidloc_slowing
      tidloc_iweight_arm(armor_id, n) if TIDLOC_GROUPWEIGHT_CARRY_OVER_MAX
      $game_switches.[]=(TIDLOC_GROUPWEIGHT_OVERWEIGHT_SWITCH, true) if !TIDLOC_GROUPWEIGHT_CARRY_OVER_MAX
    elsif $game_temp._tidloc_groupweight <= $game_temp._tidloc_groupweight_max && $game_temp._tidloc_iweight_slow
      $game_temp._tidloc_iweight_slow = false
      $game_switches.[]=(TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH, false) if TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH != -1
      tidloc_slowing false
      tidloc_iweight_arm(armor_id, n)
    else
      tidloc_iweight_arm(armor_id, n)
    end
  end
end

class Window_Weight < Window_Base
  def initialize
    super(0, 0, 160, 80)
    self.z = 250
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $defaultfonttype
    self.contents.font.size = 20
    refresh
  end
  
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 120, 20, "Weight total:\n")
    self.contents.font.color = normal_color
    a = 1
    for i in 0...TIDLOC_GROUPWEIGHT_MAT_POWER
      a*=10.0
    end
    if TIDLOC_GROUPWEIGHT_SHOW_MAX
      self.contents.draw_text(4, 25, 118, 20, ($game_temp._tidloc_groupweight/a).to_s + " / " + ($game_temp._tidloc_groupweight_max/a).to_s, 2)
    else
      self.contents.draw_text(4, 25, 118, 20, ($game_temp._tidloc_groupweight/a).to_s + " / " + ($game_temp._tidloc_groupweight_carry_over_max/a).to_s, 2)
    end
  end
  
end

class Game_Player
  def tidloc_set_speed(speed=4)
    @move_speed = speed
  end
  
  def tidloc_alt_speed(speed=0)
    @move_speed += speed
  end
end

class Scene_Item
  alias _tidloc_iweight_main main
  def main
    @weight_window   = Window_Weight.new
    @weight_window.x = 0
    @weight_window.y = 0
    @todo_window = Window_Command.new(100, ["use", "drop"])
    @todo_window.x   = 160
    @todo_window.active = false
    @todo_window.visible = false
    @todo_window.z = 300
    _tidloc_iweight_main
    @todo_window.dispose
    @weight_window.dispose
  end
  
  alias _tidloc_iweight_update update
  def update
    @weight_window.update
    @todo_window.update
    if @todo_window.active == true
      update_todo
      @weight_window.refresh
      return
    end
    _tidloc_iweight_update
  end
  
  alias _tidloc_iweight_item update_item
  def update_item
    if Input.trigger?(Input::C)
      @item = @item_window.item
      @item_window.active  = false
      @todo_window.visible = true
      @todo_window.active  = true
      return
    end
    _tidloc_iweight_item
  end
  
  def update_todo
    if Input.trigger?(Input::B)
      @todo_window.active  = false
      @todo_window.visible = false
      @item_window.active  = true
      return
    end
    if Input.trigger?(Input::C)
      @todo_window.active  = false
      @todo_window.visible = false
      @item_window.active  = true
      if @todo_window.index == 0
        unless @item.is_a?(RPG::Item)
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        unless $game_party.item_can_use?(@item.id)
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        if @item.scope >= 3
          @item_window.active = false
          @target_window.x = (@item_window.index + 1) % 2 * 304
          @target_window.visible = true
          @target_window.active = true
          if @item.scope == 4 || @item.scope == 6
            @target_window.index = -1
          else
            @target_window.index = 0
          end
        else
          if @item.common_event_id > 0
            $game_temp.common_event_id = @item.common_event_id
            $game_system.se_play(@item.menu_se)
            if @item.consumable
              $game_party.lose_item(@item.id, 1)
              @item_window.draw_item(@item_window.index)
            end
            $scene = Scene_Map.new
            return
          end
        end
        return
      else
        if @item.is_a?(RPG::Item)
          $game_party.gain_item(@item.id,-1)
        elsif @item.is_a?(RPG::Weapon)
          $game_party.gain_weapon(@item.id,-1)
        elsif @item.is_a?(RPG::Armor)
          $game_party.gain_armor(@item.id,-1)
        end
        @weight_window.refresh
        @item_window.refresh
        return
      end
    end
  end
end

class Scene_Shop
  alias _tidloc_iweight_buy update_buy
  def update_buy
    _tidloc_iweight_buy
    if Input.trigger?(Input::C)
      @item = @buy_window.item
      if @item == nil or @item.price > $game_party.gold
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      case @item
      when RPG::Item
        number = $game_party.item_number(@item.id)
        max2 = $game_temp._tidloc_itemweight[@item.id]
      when RPG::Weapon
        number = $game_party.weapon_number(@item.id)
        max2 = $game_temp._tidloc_weaponweight[@item.id]
      when RPG::Armor
        number = $game_party.armor_number(@item.id)
        max2 = $game_temp._tidloc_armorweight[@item.id]
      end
      if number == 99
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      max = @item.price == 0 ? 99 : $game_party.gold / @item.price
      if TIDLOC_GROUPWEIGHT_SHOW_MAX
        max2 = ($game_temp._tidloc_groupweight_max - $game_temp._tidloc_groupweight) / max2
      else
        max2 = ($game_temp._tidloc_groupweight_carry_over_max - $game_temp._tidloc_groupweight) / max2
      end
      max = [max, 99 - number, max2].min
      @buy_window.active = false
      @buy_window.visible = false
      @number_window.set(@item, max, @item.price)
      @number_window.active = true
      @number_window.visible = true
    end
  end
end

class Scene_Equip
  def update_item
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @right_window.active = true
      @item_window.active = false
      @item_window.index = -1
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.equip_se)
      item = @item_window.item
      @actor.equip(@right_window.index, item == nil ? 0 : item.id, true)
      @right_window.active = true
      @item_window.active = false
      @item_window.index = -1
      @right_window.refresh
      @item_window.refresh
      return
    end
  end
end

class Game_Actor < Game_Battler
 def equip(equip_type, id, equip = false)
    case equip_type
    when 0  # ??
      if id == 0 or $game_party.weapon_number(id) > 0
        $game_party.gain_weapon(@weapon_id, 1, equip)
        @weapon_id = id
        $game_party.lose_weapon(id, 1)
      end
    when 1  # ?
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor1_id], $data_armors[id])
        $game_party.gain_armor(@armor1_id, 1, equip)
        @armor1_id = id
        $game_party.lose_armor(id, 1)
      end
    when 2  # ?
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor2_id], $data_armors[id])
        $game_party.gain_armor(@armor2_id, 1, equip)
        @armor2_id = id
        $game_party.lose_armor(id, 1)
      end
    when 3  # ??
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor3_id], $data_armors[id])
        $game_party.gain_armor(@armor3_id, 1, equip)
        @armor3_id = id
        $game_party.lose_armor(id, 1)
      end
    when 4  # ???
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor4_id], $data_armors[id])
        $game_party.gain_armor(@armor4_id, 1, equip)
        @armor4_id = id
        $game_party.lose_armor(id, 1)
      end
    end
  end
end

Hope it's usefull, have fun with the script! ;D

If any questions/opinions/ideas come up, feel free to post them  ;)

Edit: encountered problems when equiping items, now solved ^^
« Last Edit: April 06, 2010, 09:55:38 PM by tidloc »
[...]And they feared him.
He understands that cruelty arises from opportunity![...]

****
Rep:
Level 83
This script it great, thanks for making it.

there is an error how ever,

undefined method '_tidloc_groupweight_carry_over_max' for # <Game_Temp:0x3a13f58>

[edit] never mind, i had to paste it above every add script and bellow all the defaults... sorry
« Last Edit: December 25, 2009, 06:22:43 AM by Mr_Wiggles »
Spoiler for:
METALFRESH is a paint contractor that specializes in refinishing metal and vinyl siding. We paint metal buildings as well as siding on homes.

We also

    Refinish decks
    Do custom interior painting
    Strip wallpaper
    Refinish cedar siding
    Metal front doors and sidelights
    Metal garage and service doors
    Grained fiberglass doors

    If your structure is *RUSTED *FADED *CHALKING *IN NEED OF COLOR CHANGE, we can fix it with a guarentee!

northern Illinois and southern Wisconsin.

http://metalfreshcoatings.com


**
Rep:
Level 83
no problem ^^

the main point is, it's working!  ;D
[...]And they feared him.
He understands that cruelty arises from opportunity![...]

****
Rep:
Level 83
Items that drop to the game map.

i put something together to do this Here.

Oh and by the way I still love this script.
« Last Edit: March 18, 2010, 08:45:02 AM by Mr_Wiggles »
Spoiler for:
METALFRESH is a paint contractor that specializes in refinishing metal and vinyl siding. We paint metal buildings as well as siding on homes.

We also

    Refinish decks
    Do custom interior painting
    Strip wallpaper
    Refinish cedar siding
    Metal front doors and sidelights
    Metal garage and service doors
    Grained fiberglass doors

    If your structure is *RUSTED *FADED *CHALKING *IN NEED OF COLOR CHANGE, we can fix it with a guarentee!

northern Illinois and southern Wisconsin.

http://metalfreshcoatings.com


**
Rep:
Level 83
As requested I enabled decimal weights  ;D
[...]And they feared him.
He understands that cruelty arises from opportunity![...]

**
Rep: +0/-0Level 82
Hi tidloc! Great script, but i've noticed a bug. When you equip equipment it takes the weight value out of the inventory, but when you unequip it it doesn't add it back on again.
Out of interest, how could the script be modified so that when you equip weapons or armour it doesn't remove the item weight from the inventory?

EDIT: Never mind. Found another thread about it.
« Last Edit: April 20, 2010, 04:03:35 PM by CountVlad »