Weight Equip System and Limit
V 1.0
By Samo, the thief.
Jan 29 2007
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
Simulating the Black isle games (like Icewind Dale, Baldur's Gate), this
script makes weapons and armors have his own weight, and actors have a
limit of weight depending on their strenght.
SCREENIES:
----------
No, because it doesn't needs too much. It only has two more window that shows weight, and limit.
CODE:
-----
here it is:
CODE
Code:
#============================================================
#============================================================
#============================================================
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Weight Equip System and Limit
# V 1.0
# By Samo, the thief.
#
# -PLace this script above main to work.
# -Search these lines:
#
# @WEAPONS_WEIGHT = {
#
# and another one:
# @ARMORS_WEIGHT = {
#
# Complete the hash(this variable) with these things:
#
#
# item_id => weight
# either weapon or armor.
#
#
#
# -Search this another line:
#
# plus_str = 0.5
#
# put the number you want there. the strenght of the actor will be
# multiplied by this number. EX:
# actor's strenght = 30
# 30 * 0.5 = 15 KG of limit.
#
#<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
# Features:
#
# - Each armor and weapon has his own weight. In this way, you can
# limit the items the actor wear, depending on his strenght.
#
#<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
#
#
# Possible Bugs:
# --------------
# -Let's say you put like initial items to an actor that are too heavy for him,
# but he wears them instead. Try to only give but don't equip the items. let the
# player equip the items instead.
#
# -Decreasing strenght in battle will make a problem. Try to cure the states at the
# final of the battle.
#
#
# -This script won't work with equip battle system.
#
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Enjoy the script and give me the credit.
# Samo, the thief.
#============================================================
#============================================================
#============================================================
#==================================================
#WEAPONS_WEIGHT and ARMORS_WEIGHT
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Class hash that defines the weight of each armor
# and weapon.
#
# {
# item_id => kg
# }
# item depends of weapons or armors
#==================================================
@WEAPONS_WEIGHT = {
1 => 3,
5 => 4,
25 => 1,
29 => 0.7
}
@ARMORS_WEIGHT = {
1 => 3,
5 => 1,
9 => 0.3,
13 => 5,
17 => 2,
21 => 0.7,
32 => 30 #Too heavy ROCK!
}
#--------------------------------------------------
@actor_index = actor_index
@equip_index = equip_index
@actor = $game_party.actors[@actor_index]
$actual_weight = 0
weapon = $data_weapons[@actor.weapon_id]
armor1 = $data_armors[@actor.armor1_id]
armor2 = $data_armors[@actor.armor2_id]
armor3 = $data_armors[@actor.armor3_id]
armor4 = $data_armors[@actor.armor4_id]
w_w = @WEAPONS_WEIGHT[weapon.id]
a1_w = @ARMORS_WEIGHT[armor1.id]
a2_w = @ARMORS_WEIGHT[armor2.id]
a3_w = @ARMORS_WEIGHT[armor3.id]
a4_w = @ARMORS_WEIGHT[armor4.id]
@data = []
@data.push(w_w)
@data.push(a1_w)
@data.push(a2_w)
@data.push(a3_w)
@data.push(a4_w)
for i in 0..@data.size
if @data[i] == nil
@data[i] = 0
end
end
$actual_weight = @data[1] + @data[2] + @data[3] + @data[4] + @data[0]
end
# ------------------------------------
def main
@help_window = Window_Help.new
@left_window = Window_EquipLeft.new(@actor)
@right_window = Window_EquipRight.new(@actor)
@item_window1 = Window_EquipItem.new(@actor, 0)
@item_window2 = Window_EquipItem.new(@actor, 1)
@item_window3 = Window_EquipItem.new(@actor, 2)
@item_window4 = Window_EquipItem.new(@actor, 3)
@item_window5 = Window_EquipItem.new(@actor, 4)
@window_weight = Window_Weight.new
@window_weight_max = Window_Weight_Max.new (@actor_index)
@right_window.help_window = @help_window
@item_window1.help_window = @help_window
@item_window2.help_window = @help_window
@item_window3.help_window = @help_window
@item_window4.help_window = @help_window
@item_window5.help_window = @help_window
@right_window.index = @equip_index
refresh
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@help_window.dispose
@left_window.dispose
@right_window.dispose
@item_window1.dispose
@item_window2.dispose
@item_window3.dispose
@item_window4.dispose
@item_window5.dispose
@window_weight_max.dispose
@window_weight.dispose
end
# ------------------------------------
def refresh
@item_window1.visible = (@right_window.index == 0)
@item_window2.visible = (@right_window.index == 1)
@item_window3.visible = (@right_window.index == 2)
@item_window4.visible = (@right_window.index == 3)
@item_window5.visible = (@right_window.index == 4)
item1 = @right_window.item
case @right_window.index
when 0
@item_window = @item_window1
when 1
@item_window = @item_window2
when 2
@item_window = @item_window3
when 3
@item_window = @item_window4
when 4
@item_window = @item_window5
end
if @right_window.active
@left_window.set_new_parameters(nil, nil, nil)
end
if @item_window.active
item2 = @item_window.item
@actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
new_atk = @actor.atk
new_pdef = @actor.pdef
new_mdef = @actor.mdef
@actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
@left_window.set_new_parameters(new_atk, new_pdef, new_mdef)
end
end
# ------------------------------------
def update
@left_window.update
@right_window.update
@item_window.update
refresh
if @right_window.active
update_right
return
end
if @item_window.active
update_item
return
end
end
# ------------------------------------
def update_right
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(2)
return
end
if Input.trigger?(Input::C)
if @actor.equip_fix?(@right_window.index)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
@window_weight_max.refresh
@window_weight.refresh
@right_window.active = false
@item_window.active = true
@item_window.index = 0
return
end
if Input.trigger?(Input::R)
$game_system.se_play($data_system.cursor_se)
@actor_index += 1
@actor_index %= $game_party.actors.size
$scene = Scene_Equip.new(@actor_index, @right_window.index)
return
end
if Input.trigger?(Input::L)
$game_system.se_play($data_system.cursor_se)
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
$scene = Scene_Equip.new(@actor_index, @right_window.index)
return
end
end
def refresh_weight
$actual_weight = 0
weapon = $data_weapons[@actor.weapon_id]
armor1 = $data_armors[@actor.armor1_id]
armor2 = $data_armors[@actor.armor2_id]
armor3 = $data_armors[@actor.armor3_id]
armor4 = $data_armors[@actor.armor4_id]
w_w = @WEAPONS_WEIGHT[weapon.id]
a1_w = @ARMORS_WEIGHT[armor1.id]
a2_w = @ARMORS_WEIGHT[armor2.id]
a3_w = @ARMORS_WEIGHT[armor3.id]
a4_w = @ARMORS_WEIGHT[armor4.id]
@data = []
@data.push(w_w)
@data.push(a1_w)
@data.push(a2_w)
@data.push(a3_w)
@data.push(a4_w)
for i in 0..@data.size
if @data[i] == nil
@data[i] = 0
end
end
$actual_weight = @data[1] + @data[2] + @data[3] + @data[4] + @data[0]
end
# ------------------------------------
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)
item = @item_window.item
@new_weight = 0
@new_weight = $actual_weight
case item
when RPG::Weapon
@new_weight += @WEAPONS_WEIGHT[item.id]
when RPG::Armor
@new_weight += @ARMORS_WEIGHT[item.id]
end
if @new_weight > $actual_weight_max
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.equip_se)
$actual_weight = @new_weight
@actor.equip(@right_window.index, item == nil ? 0 : item.id)
@right_window.active = true
@item_window.active = false
@item_window.index = -1
@right_window.refresh
@item_window.refresh
refresh_weight
@window_weight_max.refresh
@window_weight.refresh
end
return
end
end
end
#==============================================================================
# ■ Window_Weight
#------------------------------------------------------------------------------
# Esta es la venta que muestra el dinero
#==============================================================================
#==============================================================================
# ■ Window_Weight
#------------------------------------------------------------------------------
# Esta es la venta que muestra el dinero
#==============================================================================
Possible Bugs:
--------------
-Let's say you put like initial items to an actor that are too heavy for him,
but he wears them instead. Try to only give but don't equip the items. let the
player equip the items instead.
-The script Takes base strenght , so states don't bug it.