赞 | 153 |
VIP | 10 |
好人卡 | 39 |
积分 | 93 |
经验 | 146191 |
最后登录 | 2024-5-6 |
在线时间 | 2504 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 9280
- 在线时间
- 2504 小时
- 注册时间
- 2011-5-20
- 帖子
- 15389
|
- #==============================================================================
- # 本脚本来自www.66RPG.com,使用和转载请保留此信息
- #==============================================================================
- # Sample master list for crafting script
- # written by Deke
- #============================================================================================
- # 简介:
- # 这是一个很不错的合成物品系统,可以通过游戏的过程,不断学习可以合成的
- # 物品方法,也可以制作高级的兑换物品系统。
- #
- # 使用方法:
- # 1、召唤界面:使用脚本$scene = Scene_Craft.new
- #
- # 2、学习合成:$game_party.learn_recipe(合成项目)
- #
- # 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 #——成品是防具类
- # $game_party.learn_recipe(Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类))
- #===========================================================================================
- class Game_Temp
- attr_reader :recipe_list
- alias crafting_temp_initialize initialize
- def initialize
- crafting_temp_initialize
- @recipe_list=[]
- get_recipe_list
- end
- def get_recipe_list
- ##########################################################################
- # 0 号合成物品设定 (黄钥匙×2 + 兰钥匙 = 兰钥匙)
- ##########################################################################
- 材料 = [1, 2] # 需要材料的数据库编号
- 材料种类 = [0, 0] # 需要材料的种类,0是普通物品,1是防具,2是武器
- 材料数量 = [2, 1] # 需要材料的数量
- 成品 = 3 # 获得物品编号
- 成品种类 = 0 # 获得物品种类,0是普通物品,1是防具,2是武器
- 合成成功率 = 30 #合成成功率,百分比。
- 成品分类 = 1 # 获得成品分类
- @recipe_list[1] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类,合成成功率)
- ##########################################################################
- ##########################################################################
- # 0 号合成物品设定 (物品小药水×3 = 中药水 )
- ##########################################################################
- 材料 = [1] # 需要材料的数据库编号
- 材料种类 = [0] # 需要材料的种类,0是普通物品,1是防具,2是武器
- 材料数量 = [3] # 需要材料的数量
- 成品 = 2 # 获得物品编号
- 成品种类 = 2 # 获得物品种类,0是普通物品,1是防具,2
- 合成成功率 = 80 #合成成功率,百分比。
- 成品分类 = 1 # 获得成品分类
- @recipe_list[2] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类,合成成功率)
-
- ##########################################################################
- ##########################################################################
- # 0 号合成物品设定 (物品小药水×3 = 中药水 )
- ##########################################################################
- 材料 = [7,9,10] # 需要材料的数据库编号
- 材料种类 = [0,0,0] # 需要材料的种类,0是普通物品,1是防具,2是武器
- 材料数量 = [2,1,1] # 需要材料的数量
- 成品 =3 # 获得物品编号
- 成品种类 = 0 # 获得物品种类,0是普通物品,1是防具,2是武器
- 合成成功率 = 70 #合成成功率,百分比。
- 成品分类 = 1 # 获得成品分类
- @recipe_list[3] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类,合成成功率)
-
- ##########################################################################
- ##########################################################################
- 材料 = [8,9,10] # 需要材料的数据库编号
- 材料种类 = [0,0,0] # 需要材料的种类,0是普通物品,1是防具,2是武器
- 材料数量 = [2,1,1] # 需要材料的数量
- 成品 = 4 # 获得物品编号
- 成品种类 = 0 # 获得物品种类,0是普通物品,1是防具,2是武器
- 合成成功率 = 60 #合成成功率,百分比。
- 成品分类 = 1 # 获得成品分类
- @recipe_list[4] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类,合成成功率)
-
- ##########################################################################
-
-
-
-
-
- end # of get_recipe_list method
- end # of updates to Game_Temp Class
- #================================
- # CRAFTING PROGRAM
- #----------------------------------------------------------------
- #-written by Deke
- #-yes_no window code created by Phsylomortis
- #----------------------------------------------------------------
- #================================
- #updates to Game_Party class
- 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
- 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
- #================================
- class Game_Recipe
- attr_reader :ingredients
- attr_reader :quantities
- attr_reader :result
- attr_reader :result_type
- attr_reader :ingredient_types
- attr_reader :success_rate#成功几率
- attr_reader :craft_type #物品分类
- #----------------------------------------------------------------------
- def initialize( ingredients, ingredient_types, quantities, result, result_type,success_rate, craft_type=0)
- @ingredients = ingredients
- @ingredient_types = ingredient_types
- @quantities = quantities
- @result = result
- @result_type = result_type
- @craft_type = craft_type
- @success_rate = success_rate
- end
-
- #----------------------------------------------------------------------
- def name
- case @result_type
- when 0
- name = $data_items[@result].name
- when 1
- name = $data_armors[@result].name
- when 2
- name = $data_weapons[@result].name
- end
- return name
- end
- #----------------------------------------------------------------------
- def item
- case @result_type
- when 0
- item = $data_items[@result]
- when 1
- item = $data_armors[@result]
- when 2
- item = $data_weapons[@result]
- end
- return item
- end
- #----------------------------------------------------------------------
- #----------------------------------------------------------------------
- def have
- have_all = true
- for i in [email protected]
- case @ingredient_types[i]
- when 0
- if $game_party.item_number(@ingredients[i]) < @quantities[i]
- have_all=false
- end
- when 1
- if $game_party.armor_number(@ingredients[i]) < @quantities[i]
- have_all=false
- end
- when 2
- if $game_party.weapon_number(@ingredients[i]) < @quantities[i]
- have_all=false
- end
- end
- end
- return have_all
- end
- #----------------------------------------------------------------------
- def decrement
- for i in [email protected]
- case @ingredient_types[i]
- when 0
- $game_party.lose_item(@ingredients[i], @quantities[i])
- when 1
- $game_party.lose_armor(@ingredients[i], @quantities[i])
- when 2
- $game_party.lose_weapon(@ingredients[i], @quantities[i])
- end
- end
- end
- #----------------------------------------------------------------------
- def make
- if have
- @fortune = rand(100) #☆新增脚本☆
- if @fortune <= @success_rate then #☆新增脚本☆
- case @result_type
- when 0
- $game_party.gain_item(@result, 1)
- when 1
- $game_party.gain_armor(@result, 1)
- when 2
- $game_party.gain_weapon(@result, 1)
- end
- else #☆新增脚本☆
-
-
-
-
- i = rand(3)
- case i
- when 0
- $game_party.gain_item(11, 1) #失败产物,11为编号,1为类型
- when 1
- $game_party.gain_item(11, 1) #碎屑
- when 2
- $game_party.gain_item(11, 1) #粉尘
- end
-
- end #☆新增脚本☆
- decrement
- end
- end
-
- #----------------------------------------------------------------------
- def == (recipe)
- if recipe.is_a?(Game_Recipe)
- equal = true
- if recipe.ingredients != self.ingredients
- equal = false
- end
- if recipe.ingredient_types != self.ingredient_types
- equal = false
- end
- if recipe.quantities != self.quantities
- equal = false
- end
- if recipe.result != self.result
- equal=false
- end
- if recipe.result_type != self.result_type
- equal = false
- end
- else
- equal = false
- end
- return equal
- end
-
- end # of Game_Recipe class
- #===================================
- class Window_Craft < Window_Selectable
- attr_reader :data #声明数据
- #--------------------------------------------------------------------------
- def initialize(craft_type=0)
- @craft_type = craft_type
- super(0, 64, 240, 416)
- @column_max = 1
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- def recipe
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- for i in 0...$game_party.recipes.size
- #@craft_type为0时就显示全部物品
- #不为0时就显示对应物品
- if @craft_type == 0
- @data.push($game_party.recipes[i])
- elsif $game_party.recipes[i].craft_type == @craft_type
- @data.push($game_party.recipes[i])
- end
- end
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- self.contents.font.name = "黑体" # = "黑体"
- self.contents.font.size = 18 # = 18
- for i in 0...@item_max
- x = 16
- y = i * 32
- able = true
- for ingredient in 0...@data[i].ingredients.size
- case @data[i].ingredient_types[ingredient]
- when 0
- count = $game_party.item_number(@data[i].ingredients[ingredient])
- when 1
- count = $game_party.armor_number(@data[i].ingredients[ingredient])
- when 2
- count = $game_party.weapon_number(@data[i].ingredients[ingredient])
- end
- if count < @data[i].quantities[ingredient]
- able = false
- break
- end
- end
- draw_item_name(@data[i].item, x, y, able)
- end
- end
- end
- #--------------------------------------------------------------------------
- # def draw_item(index)
- # recipe = @data[index]
- # self.contents.font.color = recipe.have ? normal_color : disabled_color
- # x = 16
- #y = index * 32
- # self.contents.draw_text(x , y, self.width-32, 32, recipe.name, 0)
- # end
- def draw_item_name(item, x, y, able = true)
- if item == nil
- return
- end
- if !able
- self.contents.font.color = disabled_color
- end
- bitmap = RPG::Cache.icon(item.icon_name)
- self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 32, 32))
- self.contents.draw_text(x + 28, y, 212, 32, item.name)
- self.contents.font.color = normal_color
- end
-
- #--------------------------------------------------------------------------
- def update_help
- current_recipe = recipe
- if current_recipe.is_a?(Game_Recipe)
- case current_recipe.result_type
- when 0
- description = $data_items[current_recipe.result].description
- when 1
- description = $data_armors[current_recipe.result].description
- when 2
- description = $data_weapons[current_recipe.result].description
- end
- else
- description = ""
- end
- @help_window.set_text(description)
- @help_window.update
- end
-
- end # of Window_Craft
- #=======================================
- class Window_CraftResult < Window_Base
-
-
-
- #--------------------------------------------------------------------------
- def initialize
- super(240, 64, 400, 184)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
- self.contents.font.size = 15 # = 20
- @result = nil
- @type = nil
- end
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- case @type
- when 0
- item = $data_items[@result]
- js_string = "介绍"
- @strings = [js_string]
- @stats = [$game_party.item_number(@result)]
- @bitmap = RPG::Cache.icon(item.icon_name)
- when 1
- item = $data_armors[@result]
- js_string = "介绍"
- @strings = [js_string]
- @stats = [$game_party.armor_number(@result)]
- @bitmap = RPG::Cache.icon(item.icon_name)
- when 2
- item = $data_weapons[@result]
- js_string = "介绍"
- @strings = [js_string]
- @stats = [$game_party.weapon_number(@result)]
- @bitmap = RPG::Cache.icon(item.icon_name)
- end
- for i in [email protected]
- x = i%2 * 184
- y = i /2 *28 +32
- self.contents.font.color = normal_color
- self.contents.draw_text(x,y,100, 28,@strings[i])
- self.contents.font.color = system_color
- end
- self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, 32, 32), 255)
- self.contents.font.color= normal_color
- self.contents.draw_text(40, 0, 300, 28, "待合成物品的现有数量:")
- self.contents.draw_text(0, 116, 300, 28, "成功率:")
- self.contents.font.color = system_color
- count = @stats[@stats.size - 1].to_s
- case @type
- when 0
- js2 = $data_items[@item.id - 1].description
- when 1
- js2 = $data_armors[@armor.id - 2].description
- when 2
- js2 = $data_weapons[@weapon.id - 2].description
- end
- self.contents.draw_text(294, 0, 45, 28, count )
- self.contents.draw_text(40, 30, 500, 28, js2 )
- self.contents.draw_text(110, 116, 300, 28,$success_rate.to_s+"%") #改
-
- end
-
- #----------------------------------------------------------------------
- def set_result(result , type)
- @result = result
- @type = type
- refresh
- end
- end #of Window_CraftResult
- #=======================================
- class Window_CraftIngredients < Window_Base
- #--------------------------------------------------------------------------
- def initialize
- super(240, 248, 400, 232)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
- self.contents.font.size = 15 # = 20
- @ingredients = []
- @types = []
- @quantities = []
- @item = nil
- @count = 0
- @counter = 0
- @real_oy = 0
- end
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- for i in [email protected]
- case @types[i]
- when 0
- @item = $data_items[@ingredients[i]]
- @count = $game_party.item_number(@ingredients[i])
- when 1
- @item = $data_armors[@ingredients[i]]
- @count = $game_party.armor_number(@ingredients[i])
- when 2
- @item = $data_weapons[@ingredients[i]]
- @count = $game_party.weapon_number(@ingredients[i])
- end
- y = i *26
- self.contents.blt(0, y, RPG::Cache.icon(@item.icon_name), Rect.new(0, 0, 32, 32), 255)
- self.contents.font.color = @count >= @quantities[i] ? normal_color : disabled_color
- self.contents.draw_text(30, y, 280, 28, @item.name)
- self.contents.draw_text(300, y, 45, 28, @quantities[i].to_s)
- self.contents.font.color = system_color
- self.contents.draw_text(245, y, 45, 28, @count.to_s )
- end
- end
-
- #--------------------------------------------------------------------------
- def set_ingredients(ingredients , types, quantities,success_rate) #改
- @ingredients = ingredients
- @types = types
- @quantities = quantities
- $success_rate = success_rate #改
- refresh
- end
- end # of Window_CraftIngredients
- #======================================
- class Scene_Craft
- #--------------------------------------------------------------------------
- # @craft_type:物品种类,0就是全部
- def initialize(craft_type=0,craft_index=0)
- @craft_index=craft_index
- @craft_type = craft_type
- end
-
- #--------------------------------------------------------------------------
- def main
- @craft_window = Window_Craft.new
- @craft_window.index=@craft_index
- @confirm_window = Window_Base.new(120, 188, 400, 64)
- @confirm_window.contents = Bitmap.new(368, 32)
- @confirm_window.contents.font.name = "黑体"
- @confirm_window.contents.font.size = 20
- @help_window = Window_Help.new
- @craft_window.help_window = @help_window
- @result_window=Window_CraftResult.new
- @ingredients_window=Window_CraftIngredients.new
- @yes_no_window = Window_Command.new(100, ["确定", "放弃"])
- @confirm_window.visible = false
- @confirm_window.z = 10000
- @yes_no_window.visible = false
- @yes_no_window.active = false
- @yes_no_window.index = 1
- @yes_no_window.x = 270
- @yes_no_window.y = 252
- @yes_no_window.z = 10000
- @label_window = Window_Base.new(450,200,190,52)
- @label_window.contents=Bitmap.new(@label_window.width - 32,@label_window.height - 32)
- @label_window.contents.font.size=15
- @label_window.contents.font.color = @label_window.normal_color
- @label_window.contents.font.name = "黑体"
- @label_window.contents.draw_text(0, 0, @label_window.contents.width, 15, " 现有 需要")
- Graphics.transition
- loop do
- Graphics.update
- Input.update
- update
- if $scene != self
- break
- end
- end
- Graphics.freeze
- @help_window.dispose
- @craft_window.dispose
- @result_window.dispose
- @ingredients_window.dispose
- @confirm_window.dispose
- @yes_no_window.dispose
- @label_window.dispose
- end
- #--------------------------------------------------------------------------
- def update
- @craft_window.update
- @ingredients_window.update
- if @craft_window.active
- update_craft
- return
- end
- if @yes_no_window.active
- confirm_update
- return
- end
- end
- #--------------------------------------------------------------------------
- def update
- @craft_window.update
- @ingredients_window.update
- if $game_party.recipes.size > 0
- @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
- @ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
- @craft_window.recipe.ingredient_types,
- @craft_window.recipe.quantities,
- @craft_window.recipe.success_rate)#改
- end
- if @craft_window.active
- update_craft
- return
- end
- if @yes_no_window.active
- confirm_update
- return
- end
- end
- #--------------------------------------------------------------------------
- def update_craft
- if Input.dir4 != 0
- if @craft_window.data.size > 0 #本类窗口物品大于0的话
- @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
- @ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
- @craft_window.recipe.ingredient_types,
- @craft_window.recipe.quantities)
- end
- end
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- $scene = Scene_Map.new
- return
- end
- if Input.trigger?(Input::C) and $game_party.recipes.size != 0
- @recipe = @craft_window.recipe
- if @recipe != nil
- if @recipe.have
- @yes_no_window.active = true
- @craft_window.active = false
- else
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- else
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- end
- end
- #--------------------------------------------------------------------------
- def confirm_update
- @craft_index = @craft_window.index
- @confirm_window.visible = true
- @confirm_window.z = 10000
- @yes_no_window.visible = true
- @yes_no_window.active = true
- @yes_no_window.z = 10000
- @yes_no_window.update
- string = "合成 " + @recipe.name + "?"
- cw = @confirm_window.contents.text_size(string).width
- center = @confirm_window.contents.width/2 - cw /2
- unless @drawn
- @confirm_window.contents.draw_text(center, 0, cw, 30, string)
- @drawn = true
- end
- if Input.trigger?(Input::C)
- if @yes_no_window.index == 0
- $game_system.se_play($data_system.decision_se)
- @recipe.make
- $game_system.se_play($data_system.save_se)
- $scene=Scene_Craft.new(@craft_index)
- else
- $game_system.se_play($data_system.cancel_se)
- $scene=Scene_Craft.new(@craft_index)
- end
- end
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- $scene=Scene_Craft.new(@craft_index)
- end
- end
- end # of Scene_Craft
- #==============================================================================
- # 本脚本来自www.66RPG.com,使用和转载请保留此信息
- #==============================================================================
复制代码 657行发生Argumenterror wrong number of arguments(3 for 4) |
|