赞 | 153 |
VIP | 10 |
好人卡 | 39 |
积分 | 93 |
经验 | 146191 |
最后登录 | 2024-5-6 |
在线时间 | 2504 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 9280
- 在线时间
- 2504 小时
- 注册时间
- 2011-5-20
- 帖子
- 15389
|
1105659784 发表于 2013-10-20 09:11
和6楼的差不多,我不强求有强化,有合成就可以了 - =begin
- ==============================================================================
- ★ Item_Transmute
- ------------------------------------------------------------------------------
- 配方不公开的物品合成(加强版)
- 原作者 Summoner
- By Chd114
- ------------------------------------------------------------------------------
- 注:该脚本具有至高权威性,可以覆盖任何此脚本的前身脚本!
- ==============================================================================
- 本脚本以知识共享署名-非商业性使用 3.0 Unported 许可协议进行许可。
- 详见 http://creativecommons.org/licenses/by-nc/3.0/
- ==============================================================================
- 原作者的话:
- 这是一个配方不公开的物品合成,也就是说什么材料可以合成什么物品玩家在
- 游戏中的合成界面是不能直接看到的。由于物品的合成配方不是公开的,所以
- 玩家需要通过自己探索或从NPC处得到合成配方(当然看攻略也是一种可能)
- 例如M&M中的配药水,Diablo II的盒子,NWV中的铁匠铺、Wizard Lab……
- 可扩展性:可以加强、扩展的东西应该很多。
- 例如:合成需要花费GP、SP甚至XP,合成需要特定器具,合成失败受到伤害,
- 某些物品的几率合成、物品图鉴等等。
- 有的东西已经注释清楚了,搞懂原理的话,根据自己需要改起来也不会很麻烦。
- 个人一下子没时间实现这些,欢迎大家多多修改分享。
- Chd114的话:
- 其实这个脚本的改进思路早在去年此脚本出来之前就有想法了···只不过那个
- 时候本人的技术还差了一点所以就没有盲目去弄今天(2013年6月9日 9:33:40)
- 花了2小时左右的时间鼓捣了下最后把大部分东西都弄好了
- 此脚本冲突可能性:与装备耐久度、随即装备属性之类会导致装备具有独立性的
- 脚本功能冲突,其他脚本基本上不冲突
- 使用方法:在事件中使用脚本$scene = Scene_Compose.new,然后等待2帧
- ==============================================================================
- 若合成失败(无匹配的配方、因合成概率低而失败)物品是否失去
- =end
- $Ingredient_Lost_When_Fail = true#false
- # 合成成功/失败SE
- # 若不使用SE请设置为“""”(不含外引号)
- $SE_Compose_Successful = ""
- $SE_Compose_Failed = ""
-
- #=============================================================================
- # ■ 配方及补充的定义
- #-----------------------------------------------------------------------------
- # Game_System
- #=============================================================================
- class Game_System
- attr_accessor :formulas
- attr_accessor :products
- attr_accessor :sproducts
- attr_accessor :fproducts
- attr_accessor :probability
- alias formulas_initialize initialize
- def initialize
- formulas_initialize
- @formulas = []
- @products = []
- @sproducts = []
- @fproducts = []
- @probability = []
- =begin
- ===========================配方表===========================================
-
- 配方格式
- @formulas[i] = [[材料种类,材料编号,数量],[材料种类,材料编号,数量]……]
- @products[i] = [[成品种类,成品编号,数量],[成品种类,成品编号,数量]……]
- @sproducts[i] = [[成功额外产物种类,编号,数量],[成功额外产物种类,编号,数量]]
- @fproducts[i] = [[失败额外产物种类,编号,数量],[失败额外产物种类,编号,数量]]
- @probability[i] = [合成成功率,成功额外产物概率,失败额外产物概率]
- 种类:物品 0 武器 1 防具 2
- 1.如果有两个配方材料相同,理论上会按编号较小的处理
- 2.配方材料的顺序与合成是无关的(当然如果你想改成有关肯定也不会太麻烦)
- 3.允许某个材料拆成多件成品(可能就不叫物品合成,应该叫物品分解了)
- 4.产物数量神马的理论上你可以无限写,只要你不怕麻烦加手抽筋。
- 5.暂时不支持多步合并为一步的合成
- 例如 A + B = C,C + D = E,如果不存在A + B + D = E的配方
- A + B + D无法合成 E
- 6.暂时不支持将配方逆向使用(本功能会尝试完善)
- 例如 A + B = C,C = A + B,如果不存在C = A + B的配方
- C无法拆解成A + B
- 7.暂时不支持花费金钱的合成与配方学习(本功能会尝试完善)
- 例如A + B = C,作者设定成合成此配方的成品需要花费5000金币之类的
- 8.成功额外产物出现的概率与失败额外产物出现的概率会导致所有成功额外
- 产物或所有失败额外产物同时出现,比如失败额外产物有大药膏和艾西非远
- 古祭祀,则在合成失败后若出现失败的额外产物时同时出现大药膏和艾西非
- 远古祭祀。
- 9.成功额外产物和失败额外产物的设定和配方材料、配方成品设定格式是一致的。
- =end
- #初始化模板
- @formulas[0] = []
- @products[0] = []
- @sproducts[0] = []
- @fproducts[0] = []
- @probability[0] = []
- #这个才是样例!!!
- @formulas[1] = [[1,1,1]]
- @products[1] = [[2,29,1]]
- @sproducts[1] = [[1,2,1]]
- @fproducts[1] = [[0,2,1]]
- @probability[1] = [50,50,50]
- end
- end
-
- class Game_Temp
- attr_accessor :forge
- alias forge_item_initialize initialize
- def initialize
- forge_item_initialize
- # 定义合成窗口中的物品储存区
- [url=home.php?mod=space&uid=14254]@Forge[/url] = []
- end
- end
-
- #==============================================================================
- # ■ Window_ForgeCommand
- #------------------------------------------------------------------------------
- # 合成画面、选择要做的事的窗口
- #==============================================================================
-
- class Window_ComposeCommand < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(0, 64, 640, 64)
- self.contents = Bitmap.new(width - 32, height - 32)
- @item_max = 4
- @column_max = 4
- @commands = ["更改材料", "合成", "放弃合成", "离开"]
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- for i in 0...@item_max
- draw_item(i)
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘项目
- # index : 项目编号
- #--------------------------------------------------------------------------
- def draw_item(index)
- x = 4 + index * 160
- self.contents.draw_text(x, 0, 128, 32, @commands[index])
- end
- end
-
- #==============================================================================
- # ■ Window_ForgeLeft
- #------------------------------------------------------------------------------
- # 合成画面中显示拥有的物品的窗口
- #==============================================================================
-
- class Window_ComposeLeft < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(0, 128, 320, 352)
- @column_max = 1
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 获取物品
- #--------------------------------------------------------------------------
- def item
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- self.update_cursor_rect
- @data = []
- for i in 1...$data_items.size
- if $game_party.item_number(i) > 0
- @data.push($data_items[i])
- end
- end
- for i in 1...$data_weapons.size
- if $game_party.weapon_number(i) > 0
- @data.push($data_weapons[i])
- end
- end
- for i in 1...$data_armors.size
- if $game_party.armor_number(i) > 0
- @data.push($data_armors[i])
- end
- end
- # 如果项目数不是 0 就生成位图、描绘全部项目
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘项目
- # index : 项目标号
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- case item
- when RPG::Item
- number = $game_party.item_number(item.id)
- when RPG::Weapon
- number = $game_party.weapon_number(item.id)
- when RPG::Armor
- number = $game_party.armor_number(item.id)
- end
- self.contents.font.color = text_color(item.name_color_66RPG)
- x = 4
- y = index * 32
- rect = Rect.new(x, y, self.width / @column_max - 32, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- bitmap = RPG::Cache.icon(item.icon_name)
- opacity = self.contents.font.color == text_color(item.name_color_66RPG) ? 255 : 128
- self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 32, 32), opacity)
- self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
- self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
- self.contents.draw_text(x + 256, y, 32, 32, number.to_s, 2)
- end
- #--------------------------------------------------------------------------
- # ● 刷新帮助文本
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_text(self.item == nil ? "" : self.item.description)
- end
- end
-
- #==============================================================================
- # ■ Window_ForgeRight
- #------------------------------------------------------------------------------
- # 合成画面中的合成区窗口
- #==============================================================================
-
- class Window_ComposeRight < Window_Selectable
- attr_accessor :forge_item
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize(forge_item)
- super(320, 128, 320, 352)
- @column_max = 1
- @forge_item = []
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 获取物品
- #--------------------------------------------------------------------------
- def item
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- # ● 获取物品
- #--------------------------------------------------------------------------
- def item_number
- return @data_number[self.index]
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- @data_number = []
- @forge_item = $game_temp.forge
- for item_forge in @forge_item
- case item_forge[0]
- when 0
- item = $data_items[item_forge[1]]
- when 1
- item = $data_weapons[item_forge[1]]
- when 2
- item = $data_armors[item_forge[1]]
- end
- if (item != nil) and (item_forge[2] != 0)
- @data.push(item)
- @data_number.push(item_forge[2])
- else
- @data.delete(item)
- end
- end
- # 如果项目数不是 0 就生成位图、描绘全部项目
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘项目
- # index : 项目标号
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- case item
- when RPG::Item
- number = $game_temp.forge[index][2]
- when RPG::Weapon
- number = $game_temp.forge[index][2]
- when RPG::Armor
- number = $game_temp.forge[index][2]
- end
- self.contents.font.color = text_color(item.name_color_66RPG)
- x = 4
- y = index * 32
- rect = Rect.new(x, y, self.width / @column_max - 32, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- bitmap = RPG::Cache.icon(item.icon_name)
- opacity = self.contents.font.color == text_color(item.name_color_66RPG) ? 255 : 128
- self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 32, 32), opacity)
- self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
- self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
- self.contents.draw_text(x + 256, y, 32, 32, number.to_s, 2)
- end
- #--------------------------------------------------------------------------
- # ● 刷新帮助文本
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_text(self.item == nil ? "" : self.item.description)
- end
- end
-
- #==============================================================================
- # ■ Scene_Compose
- #------------------------------------------------------------------------------
- # 处理物品合成画面的类
- #==============================================================================
-
- class Scene_Compose
- #--------------------------------------------------------------------------
- # ● 初始化
- #--------------------------------------------------------------------------
- def initialize
- # 生成帮助窗口
- @help_window = Window_Help.new
- # 生成命令窗口
- @command_window = Window_ComposeCommand.new
- @command_window.active = false
- # 生成左方窗口
- @item_window = Window_ComposeLeft.new
- @item_window.active = true
- @item_window.help_window = @help_window
- # 生成右方窗口
- @forge_window = Window_ComposeRight.new([])
- @forge_window.active = false
- @forge_window.help_window = @help_window
- # 初始化配方与合成区
- @formulas = $game_system.formulas
- @products = $game_system.products
- @sproducts = $game_system.sproducts
- @fproducts = $game_system.fproducts
- @probability = $game_system.probability
- @forge = []
- @products_temp = []
- @sproducts_temp = []
- @fproducts_temp = []
- @probability_temp = []
- end
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- def main
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入情报
- Input.update
- # 刷新画面
- update
- # 如果画面被切换的话就中断循环
- if $scene != self
- break
- end
- end
- # 准备过渡
- Graphics.freeze
- # 释放窗口
- @help_window.dispose
- @command_window.dispose
- @item_window.dispose
- @forge_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- @help_window.update
- @command_window.update
- @item_window.update
- @forge_window.update
- if @command_window.active
- update_command
- return
- end
- if @item_window.active
- update_item
- return
- end
- if @forge_window.active
- update_forge
- return
- end
- return
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面(指令窗口激活的情况下)
- #--------------------------------------------------------------------------
- def update_command
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- abort
- # 切换到地图画面
- $scene = Scene_Map.new
- return
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 命令窗口光标位置分支
- case @command_window.index
- when 0 # 更改材料
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 窗口状态转向物品窗口
- @command_window.active = false
- @item_window.active = true
- @forge_window.active = false
- when 1 # 合成
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 执行合成命令
- if $game_temp.forge != []
- compose
- end
- when 2 # 放弃合成
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 放弃合成
- abort
- when 3 # 离开
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 放弃合成
- abort
- # 切换到地图画面
- $scene = Scene_Map.new
- end
- return
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面(物品窗口激活的情况下)
- #--------------------------------------------------------------------------
- def update_item
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 切换到指令窗口
- @item_window.active = false
- @command_window.active = true
- @help_window.set_text("")
- return
- end
- # 按下 C 键的情况
- if Input.trigger?(Input::C)
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 获取物品
- @item = @item_window.item
- # 获取物品的所持数
- case @item
- when RPG::Item
- number = $game_party.item_number(@item.id)
- typetemp = 0
- when RPG::Weapon
- number = $game_party.weapon_number(@item.id)
- typetemp = 1
- when RPG::Armor
- number = $game_party.armor_number(@item.id)
- typetemp = 2
- end
- if number != nil
- # 更改合成窗口的物品
- case @item
- when RPG::Item
- $game_party.lose_item(@item.id, 1)
- when RPG::Weapon
- $game_party.lose_weapon(@item.id, 1)
- when RPG::Armor
- $game_party.lose_armor(@item.id, 1)
- end
- forge_change(typetemp, @item.id, 1)
- # 刷新各窗口
- @item_window.update
- @help_window.update
- @forge_window.update
- @item_window.refresh
- @forge_window.refresh
- end
- end
- # 按下 右方向键 的情况
- if Input.trigger?(Input::RIGHT)
- # 切换到合成窗口
- @item_window.active = false
- @forge_window.active = true
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面(合成窗口激活的情况下)
- #--------------------------------------------------------------------------
- def update_forge
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 切换到指令窗口
- @forge_window.active = false
- @command_window.active = true
- @help_window.set_text("")
- return
- end
- # 按下 C 键的情况
- if Input.trigger?(Input::C)
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 获取物品
- @item = @forge_window.item
- # 获取物品的所持数
- case @item
- when RPG::Item
- number = @forge_window.item_number
- typetemp = 0
- when RPG::Weapon
- number = @forge_window.item_number
- typetemp = 1
- when RPG::Armor
- number = @forge_window.item_number
- typetemp = 2
- end
- if number != nil
- # 更改合成窗口的物品
- case @item
- when RPG::Item
- $game_party.gain_item(@item.id, 1)
- when RPG::Weapon
- $game_party.gain_weapon(@item.id, 1)
- when RPG::Armor
- $game_party.gain_armor(@item.id, 1)
- end
- #p number
- forge_change(typetemp, @item.id, -1)
- # 刷新各窗口
- @item_window.refresh
- @forge_window.refresh
- @help_window.update
- @item_window.update
- @forge_window.update
- end
- end
- # 按下 左方向键 的情况下
- if Input.trigger?(Input::LEFT)
- # 切换到合成窗口
- @forge_window.active = false
- @item_window.active = true
- end
- end
- #--------------------------------------------------------------------------
- # ● 更改合成窗口物品
- #--------------------------------------------------------------------------
- def forge_change(type,id,number)
- quantity = number
- for item in $game_temp.forge
- if (item[0]==type) and (item[1]==id)
- item[2] = [item[2] += quantity,99].min
- if item[2] == 0
- $game_temp.forge.delete(item)
- end
- return
- end
- end
- $game_temp.forge.push([type,id,number])
- end
- #--------------------------------------------------------------------------
- # ● 放弃合成
- #--------------------------------------------------------------------------
- def abort
- # 将合成窗口中的物品转移至物品窗口中
- for item in $game_temp.forge
- # 判断物品类型并归还
- case item[0]
- when 0
- $game_party.gain_item(item[1], item[2])
- when 1
- $game_party.gain_weapon(item[1], item[2])
- when 2
- $game_party.gain_armor(item[1], item[2])
- end
- end
- $game_temp.forge = []
- # 刷新各窗口
- @item_window.refresh
- @forge_window.refresh
- end
- #--------------------------------------------------------------------------
- # ● 检测是否有符合的配方
- #--------------------------------------------------------------------------
- def match
- match_one = false
- match_this = false
- # 检测每一个配方
- for i in [email protected]
- # 将合成窗口中的物品复制到合成缓存区
- # 注意: 直接使用"="将传引用 导致检测配方是否匹配时合成窗口中物品被删除
- @forge = $game_temp.forge.dup
- # 检测这个配方中每一项材料
- for ingredient in @formulas[i]
- match_this = true
- # 合成区中没有此项材料的情况
- unless @forge.include?(ingredient)
- match_this = false
- break
- end
- # 从合成区中暂时删除这项材料
- @forge.delete(ingredient)
- end
- if match_this == false
- next
- end
- # 检测合成区中是否还有配方外的材料剩余
- unless @forge == []
- match_this = false
- end
- # 满足这一个配方的情况
- if match_this == true
- match_one = true
- # 获取配方的成品、成功额外产物、失败额外产物、合成各种概率
- @products_temp = @products[i]
- @sproducts_temp = @sproducts[i]
- @fproducts_temp = @fproducts[i]
- @probability_temp = @probability[i]
- $g=i
- break
- end
- end
- return match_one
- end
- #--------------------------------------------------------------------------
- # ● 合成
- #--------------------------------------------------------------------------
- def compose
- # 如果有符合的配方
- if match
- # 将合成窗口中的材料改变为成品
- $game_temp.forge = []
- p @probability_temp[$g]
- if @probability_temp[$g-1]==100
- @pro1=0#当成功率为100%时随机概率是0
- else
- @pro1=rand(99)#当成功率不为100%时随即概率为0-99
- end
- if @pro1<@probability_temp[$g-1]
- for i in 0...@products_temp.size
- forge_change(@products_temp[i][0], @products_temp[i][1], @products_temp[i][2])
- end
- if @probability_temp[$g]==100
- @pro2=0#成功额外产率为100%时随即概率为0
- elsif @probability_temp[$g]<100
- @pro2=rand(99)#成功额外产率为0-99%时随即概率为0-99%
- else
- @pro2=0#成功额外产率为0%时没有成功额外产物
- end
- if @pro2<@probability_temp[$g]
- for i in 0...@sproducts_temp.size
- forge_change(@sproducts_temp[i][0], @sproducts_temp[i][1], @sproducts_temp[i][2])
- end
- end
- else
- if @probability_temp[$g+1]==100
- @pro3=0#成功额外产率为100%时随即概率为0
- elsif @probability_temp[$g+1]<100
- @pro3=rand(99)#成功额外产率为0-99%时随即概率为0-99%
- else
- @pro3=0#成功额外产率为0%时没有成功额外产物
- end
- if @pro3<@probability_temp[$g+1]
- for i in 0...@fproducts_temp.size
- forge_change(@fproducts_temp[i][0], @fproducts_temp[i][1], @fproducts_temp[i][2])
- end
- end
- end
- if $SE_Compose_Successful != ""
- Audio.se_play($SE_Compose_Successful)
- end
- # 合成失败的情况
- else
- if $SE_Compose_Failed != ""
- Audio.se_play($SE_Compose_Failed)
- end
- if $Ingredient_Lost_When_Fail
- $game_temp.forge = []
- end
- end
- # 刷新各窗口
- @item_window.refresh
- @forge_window.refresh
- end
- end
复制代码 这个就可以了 |
评分
-
查看全部评分
|