Project1
标题:
我弄了那个仓库载重整合神马的东西···然后删掉合成
[打印本页]
作者:
chd114
时间:
2013-6-6 19:11
标题:
我弄了那个仓库载重整合神马的东西···然后删掉合成
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
# 欢迎访问www.66RPG.com
# 梦想世界,在你手中
#==============================================================================
#
# Sample master list for crafting script (物品分类增强版)
# written by Deke
# 增强:叶子
# 增强版编写日期:12-30-2005
#============================================================================================
# 简介:
# 这是一个很不错的合成物品系统,可以通过游戏的过程,不断学习可以合成的
# 物品方法。
# ------
# 增强版补充说明:
# 在这个增强版中,可以对成品进行手动分类。
# 成品增加了一个分类属性。
# 这个分类纯粹是按自己的意愿,没有规定第几类必须是什么。
# 召唤特定分类的界面,就只会看到特定分类的成品。
#
# 例如:
# 使用脚本$scene = Scene_Craft.new(1),
# 出来的界面就只会显示成品分类为1的东西
# 同样道理,使用脚本$scene = Scene_Craft.new(2),
# 出来的界面就只会显示成品分类为2的东西
#
# 如果使用脚本$scene = Scene_Craft.new或$scene = Scene_Craft.new(0)来召唤界面
# 就可以看到所有成品。
#
# 注意:不要弄混淆“成品种类”和“成品分类”
# 成品种类是指成品是普通物品(0),防具(1)或武器(2)
# 成品分类是指此物品的自定义分类
#
#
# 使用方法:
# 1、召唤界面:使用脚本$scene = Scene_Craft.new(分类的数字)
# 例如:使用脚本$scene = Scene_Craft.new(1),出来分类1的界面
#
# 2、学习合成:$game_party.learn_recipe(合成项目)
#
# 2.1、其实这个脚本可以使同一成品有不同配方
#
# 就这样说可能解释得不清楚,先来解释一下脚本学习配方的原理:
# $game_party.learn_recipe(合成项目)的处理过程并不是直接学习这个配方,
# 而是在配方库中找到和合成项目成品相同的配方。
#
# 如果配方库中有两个配方成品相同的话,配方版本就变得重要。
# $game_party.learn_recipe(合成项目,配方版本)
# 配方版本为1的话,学到的配方就是@recipe_list[xx]中与合成项目成品相同且数字最小的配方
# 配方版本为2的话,学到的配方就是数字第二小的配方
# 在上面这个脚本语句中,不填配方版本的话就默认为1
#
# 2.2、忘记配方:$game_party.forget_recipe(合成项目)
# 2.21、同样道理,这个语句也可以写配方版本
# $game_party.forget_recipe(合成项目,配方版本)
# 配方版本定义见2.1
#
# 2.3、配方版本不能乱填!例如游戏中某一个配方的成品是唯一的,与所有其它配方的成品都不相同
# 那么学习的时候就不用填配方版本。
# 如果这时在配方版本填了2的话,就有可能学不到或者忘不了(-_-||)
#
#
# 3、合成定义:
# 这个合成脚本可以定义两种合成物品。一种是预先定义好了的,就像下面这样,
# 直接写在这里就可以,另一种是在学习之前现场定义。
#
# 4、举例
# 4.1、学会recipe_list[1]定义的合成:$game_party.learn_recipe($game_temp.recipe_list[1])
# 注意,一行如果输入不下,在(的后面或[的后面按回车换行,否则可能出错
#
# 4.2、在游戏中临时定义一种合成,让玩家学会。使用事件中的脚本如下,
# 脚本:
# 材料 = [$game_variables[1],$game_variables[2]] #——材料编号是变量1、2的编号
# 材料种类 = [0,0] #——材料是物品
# 材料数量 = [$game_variables[3],$game_variables[4]] #——需要材料数量是变量3、4的编号
# 成品 = $game_variables[5] #——获得结果编号是5
# 成品种类 = 1 #——成品是防具类
# 成品分类 = 1 #——这一项不写的话默认为0
# $game_party.learn_recipe(Game_Recipe.new(材料,材料种类,材料数量,成品,成品种类,成品分类))
# 上面这条语句的成品分类这一项不写也行,这样它就默认为0了。
# (也就是此物品没有分类,不会在分类菜单中出现)
# 省略成品分类的脚本语句可以像下面这样写:
# $game_party.learn_recipe(Game_Recipe.new(材料,材料种类,材料数量,成品,成品种类))
#
#===========================================================================================
$VAR_NUMBER = 14
#================================
# CRAFTING PROGRAM
#----------------------------------------------------------------
#-written by Deke
#-yes_no window code created by Phsylomortis
#----------------------------------------------------------------
#================================
#updates to Game_Party class
=begin
负重系统v0.1
作者:秀秀
功能:物品 武器 防具都多了重量属性
增加了背包负重 超过负重最大值 则不能获得
使用方法:在(物品,武器,防具)数据库中设置名称
方式为:名称+n+重量
比如 铜剑n1.5 表示铜剑重量为1.5
回复剂n0.5 表示回复剂重量为0.5
设置背包重量:默认为变量1,一定要在游戏开始设置好
搜索 VAR_NUMBER 可以改变存放背包负重的变量
当然也可以随时改变这个数值
获取背包最大负重:
$game_variables[VAR_NUMBER]
获取背包当前负重:
$gane_party.weight
获取物品重量:
$data_items[id].weight
获取武器重量:
$data_weapons[id].weight
获取防具重量:
$data_armors[id].weight
=end
module RPG
class Item
def name
return @name.split(/,/)[0] # w 代表重量
end
def weight
return @name.split(/,/)[2].to_i # w 代表重量
end
end
class Weapon
def name
return @name.split(/,/)[0] # w 代表重量
end
def weight
return @name.split(/,/)[2].to_i # w 代表重量
end
end
class Armor
def name
return @name.split(/,/)[0] # w 代表重量
end
def weight
return @name.split(/,/)[3].to_i # w 代表重量
end
end
end
class Game_Party
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :weight
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
alias wt_initialize initialize
def initialize
wt_initialize
@weight = 0
end
#--------------------------------------------------------------------------
# ● 增加物品 (减少)
# item_id : 物品 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_item(item_id, n)
# 更新 hash 的个数数据
if item_id > 0
temp = @weight + $data_items[item_id].weight * n
return if (n < 0 and @items[item_id] == nil)
if temp > max_weight
return
end
if temp < 0
a = @weight
for i in 1..n.abs
a -= $data_items[item_id].weight
if a < 0
return
else
# 数量-1
@items[item_id] = [[item_number(item_id) - i, 0].max, 99].min
# 负重-1
@weight -= $data_items[item_id].weight
# p @weight
end
end
# p @weight
return
end
if @items[item_id] != nil
b = @items[item_id] - n.abs
if b < 0 and n < 0
c = @items[item_id]
@items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
@weight -= $data_items[item_id].weight * c
# p @weight
return
end
end
@items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
@weight = temp
# p @weight
end
end
#--------------------------------------------------------------------------
# ● 增加武器 (减少)
# weapon_id : 武器 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_weapon(weapon_id, n)
# 更新 hash 的个数数据
if weapon_id > 0
temp = @weight + $data_weapons[weapon_id].weight * n
return if (n < 0 and @weapons[weapon_id] == nil)
if temp > max_weight
return
end
if temp < 0
a = @weight
for i in 1..n.abs
a -= $data_weapons[weapon_id].weight
if a < 0
return
else
# 数量-1
@weapons[weapon_id] = [[weapon_number(weapon_id) - i, 0].max, 99].min
# 负重-1
@weight -= $data_weapons[weapon_id].weight
# p @weight
end
end
# p @weight
return
end
if @weapons[weapon_id] != nil
b = @weapons[weapon_id] - n.abs
if b < 0 and n < 0
c = @weapons[weapon_id]
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
@weight -= $data_weapons[weapon_id].weight * c
# p @weight
return
end
end
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
@weight = temp
# p @weight
end
end
#--------------------------------------------------------------------------
# ● 增加防具 (减少)
# armor_id : 防具 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_armor(armor_id, n)
# 更新 hash 的个数数据
if armor_id > 0
temp = @weight + $data_armors[armor_id].weight * n
return if (n < 0 and @armors[armor_id] == nil)
if temp > max_weight
return
end
if temp < 0
a = @weight
for i in 1..n.abs
a -= $data_armors[armor_id].weight
if a < 0
return
else
# 数量-1
@armors[armor_id] = [[armor_number(armor_id) - i, 0].max, 99].min
# 负重-1
@weight -= $data_armors[armor_id].weight
# p @weight
end
end
# p @weight
return
end
if @armors[armor_id] != nil
b = @armors[armor_id] - n.abs
if b < 0 and n < 0
c = @armors[armor_id]
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
@weight -= $data_armors[armor_id].weight * c
# p @weight
return
end
end
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
@weight = temp
# p @weight
end
end
def max_weight
return $game_variables[$VAR_NUMBER]
end
def check_weight
end
end
#================================================================================
#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
# 处理物品画面的类。
#==============================================================================
class Scene_Item
alias ori_main main
def main
@weight_window = Window_Weight.new
@weight_window.x = 0
@weight_window.y = 416
@weight_window.z = 9999
ori_main
@weight_window.dispose
end
alias ori_update update
#特殊
def update
case @item_window.item
when RPG::Item
@weight_window.refresh($data_items[@item_window.item.id].weight)
when RPG::Weapon
@weight_window.refresh($data_weapons[@item_window.item.id].weight)
when RPG::Armor
@weight_window.refresh($data_armors[@item_window.item.id].weight)
end
ori_update
end
end
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 64, 640, 352)
@column_max = 2
refresh
self.index = 0
# 战斗中的情况下将窗口移至中央并将其半透明化
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
end
class Window_Weight < Window_Base
def initialize
super(0,0,640,64)
self.opacity = 128
self.contents = Bitmap.new(width-32,height-32)
refresh(nil)
end
def refresh(weight)
self.contents.clear
if weight != nil
self.contents.draw_text(0,0,256,32,"物品重量:#{weight}")
end
self.contents.draw_text(256,0,320,32,"背包重量:"+$game_party.weight.to_s + "/" + $game_variables[$VAR_NUMBER].to_s , 0)
end
end
class Game_Party
attr_accessor :recipes
alias crafting_party_initialize initialize
def initialize
crafting_party_initialize
@recipes=[]
end
#----------------------------------------------------------------------
def know?(recipe, version = 1)
unless recipe.is_a?(Game_Recipe)
recipe = get_recipe_from_master_list(recipe, version)
end
return $game_party.recipes.include?(recipe)
end
#----------------------------------------------------------------------
def learn_recipe(recipe , version = 1)
unless recipe.is_a?(Game_Recipe)
recipe = get_recipe_from_master_list(recipe, version)
end
if recipe.is_a?(Game_Recipe)
unless know?(recipe)
@recipes.push(recipe)
end
end
end
#----------------------------------------------------------------------
def forget_recipe(recipe , version = 1)
if !recipe.is_a?(Game_Recipe)
recipe = get_recipe_from_master_list(recipe, version)
end
if recipe.is_a?(Game_Recipe)
for i in
[email protected]
if recipe == @recipes[i]
index = i
break
end
end
if index != nil
@recipes.delete(@recipes[index])
end
end
end
#----------------------------------------------------------------------
def get_recipe_from_master_list(item, version)
index = nil
for i in 0...$game_temp.recipe_list.size
#print $game_temp.recipe_list.size
if item[0] == $game_temp.recipe_list[i].result and item[1] ==$game_temp.recipe_list[i].result_type
version -= 1
if version == 0
index = i
break
end
end
end
if index.is_a?(Integer)
return ($game_temp.recipe_list[index])
else
return false
end
end
end # of Game_Party updates
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
# 欢迎访问www.66RPG.com
# 梦想世界,在你手中
#==============================================================================
复制代码
现在这样应该没有任何问题了吧?求检查···
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1