赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 1425 |
最后登录 | 2013-5-26 |
在线时间 | 46 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 46 小时
- 注册时间
- 2011-9-13
- 帖子
- 55
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 最后的信徒 于 2012-10-24 16:47 编辑
Project1.zip
(257.68 KB, 下载次数: 255)
本脚本可以和【怪物图鉴+掉宝扩张】同用
关于自由合成的失败惩罚(没有相应的配方时):在1007行设置- #============================================================================
- # 物品合成
- #============================================================================
- # 作者:最后的信徒
- # 时间:2012/10/24
- #============================================================================
- #使用方法:呼出合成菜单,在事件脚本中输入(6个中文):呼出合成菜单
- # 增加配方,在事件脚本中输入:增加配方(序号)
- #
- #配方的设置:请修改下面星星之间的的 配方
- # 如:$配方[序号] = [1, #类型(1为物品,2为武器,3为防具)
- # 1, #成品的id
- # [1,1,1], #材料1的类型、id和数量
- # [2,2,1], #材料2的类型、id和数量
- # [3,3,1], #材料3的类型、id和数量
- # [3,4,1], #材料4的类型、id和数量
- # 100] #成功率
- #
- #规格说明:序号最好由0开始,填大于或等于0的整数;
- # $配方[0]第1个元素为所合成的物品的类型;
- # 第2个元素为所合成的物品的id;
- # 第3至倒数第2个是材料,是一个数组,数组有3个元素,
- # 数组的第1个元素是材料的类型,第2个是材料的id,
- # 第3个是需要的数量;注意材料不要重复,种类最多可以设10个
- # 最后一个元素是成功率
- #
- # 全局变量 $拥有的配方 中的元素为 配方的 序号
- # 请按需设置
- #
- #============================================================================
- #============================================================================
- $拥有的配方 = []
- $配方 = []
- #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
- #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
- $配方[0] = [1, #类型(1为物品,2为武器,3为防具)
- 3, #成品的id
- [1,1,1], #材料1的类型、id和数量
- 100] #成功率
-
-
- #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
- #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
- #==============================================================================
- #------------------------------------------------------------------------------
- # 拥有光标的移动以及滚动功能的命令窗口类。
- #==============================================================================
- class Window_滚动命令1 < Window_Base
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_accessor :item_max # 选项数
- attr_accessor :column_max # 行数
- attr_accessor :index # 光标位置
- attr_accessor :命令组
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # x : 窗口 X 座标
- # y : 窗口 Y 座标
- # width : 窗口宽度
- # height : 窗口高度
- # 命令组 :按钮数组
- # spacing : 横向排列时栏间空格
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height, 命令组, spacing = 32)
- @item_max = 命令组.size
- @column_max = 1
- @index = 0
- @spacing = spacing
- @命令组 = 命令组
- super(x, y, width, height)
- end
- #--------------------------------------------------------------------------
- # ● 生成窗口内容
- #--------------------------------------------------------------------------
- def create_contents
- self.contents.dispose
- self.contents = Bitmap.new(width - 32, [height - 32, row_max * WLH].max)
- end
- #--------------------------------------------------------------------------
- # ● 设置光标位置
- # index : 新光标位置
- #--------------------------------------------------------------------------
- def index=(index)
- @index = index
- update_cursor
- end
- #--------------------------------------------------------------------------
- # ● 计算行数
- #--------------------------------------------------------------------------
- def row_max
- return (@item_max + @column_max - 1) / @column_max
- end
- #--------------------------------------------------------------------------
- # ● 获取首行
- #--------------------------------------------------------------------------
- def top_row
- return self.oy / WLH
- end
- #--------------------------------------------------------------------------
- # ● 设置首行
- # row : 显示在最上的行
- #--------------------------------------------------------------------------
- def top_row=(row)
- row = 0 if row < 0
- row = row_max - 1 if row > row_max - 1
- self.oy = row * WLH
- end
- #--------------------------------------------------------------------------
- # ● 获取一页能显示的行数
- #--------------------------------------------------------------------------
- def page_row_max
- return (self.height - 32) / WLH
- end
- #--------------------------------------------------------------------------
- # ● 获取一页能显示的选项
- #--------------------------------------------------------------------------
- def page_item_max
- return page_row_max * @column_max
- end
- #--------------------------------------------------------------------------
- # ● 获取末行
- #--------------------------------------------------------------------------
- def bottom_row
- return top_row + page_row_max - 1
- end
- #--------------------------------------------------------------------------
- # ● 设置末行
- # row : 显示在最底的行
- #--------------------------------------------------------------------------
- def bottom_row=(row)
- self.top_row = row - (page_row_max - 1)
- end
- #--------------------------------------------------------------------------
- # ● 设置选项矩形
- # index : 项目编号
- #--------------------------------------------------------------------------
- def item_rect(index)
- rect = Rect.new(0, 0, 0, 0)
- rect.width = (contents.width + @spacing) / @column_max - @spacing
- rect.height = WLH
- rect.x = index % @column_max * (rect.width + @spacing)
- rect.y = index / @column_max * WLH
- return rect
- end
- #--------------------------------------------------------------------------
- # ● 判断光标是否能够移动
- #--------------------------------------------------------------------------
- def cursor_movable?
- return false if (not visible or not active)
- return false if (index < 0 or index > @item_max or @item_max == 0)
- return false if (@opening or @closing)
- return true
- end
- #--------------------------------------------------------------------------
- # ● 光标下移
- # wrap : 允许循环
- #--------------------------------------------------------------------------
- def cursor_down(wrap = false)
- if (@index < @item_max - @column_max) or (wrap and @column_max == 1)
- @index = (@index + @column_max) % @item_max
- end
- end
- #--------------------------------------------------------------------------
- # ● 光标上移
- # wrap : 允许循环
- #--------------------------------------------------------------------------
- def cursor_up(wrap = false)
- if (@index >= @column_max) or (wrap and @column_max == 1)
- @index = (@index - @column_max + @item_max) % @item_max
- end
- end
- #--------------------------------------------------------------------------
- # ● 光标右移
- # wrap : 允许循环
- #--------------------------------------------------------------------------
- def cursor_right(wrap = false)
- if (@column_max >= 2) and
- (@index < @item_max - 1 or (wrap and page_row_max == 1))
- @index = (@index + 1) % @item_max
- end
- end
- #--------------------------------------------------------------------------
- # ● 光标左移
- # wrap : 允许循环
- #--------------------------------------------------------------------------
- def cursor_left(wrap = false)
- if (@column_max >= 2) and
- (@index > 0 or (wrap and page_row_max == 1))
- @index = (@index - 1 + @item_max) % @item_max
- end
- end
- #--------------------------------------------------------------------------
- # ● 光标移至下一页
- #--------------------------------------------------------------------------
- def cursor_pagedown
- if top_row + page_row_max < row_max
- @index = [@index + page_item_max, @item_max - 1].min
- self.top_row += page_row_max
- end
- end
- #--------------------------------------------------------------------------
- # ● 光标移至上一页
- #--------------------------------------------------------------------------
- def cursor_pageup
- if top_row > 0
- @index = [@index - page_item_max, 0].max
- self.top_row -= page_row_max
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- if cursor_movable?
- last_index = @index
- if Input.repeat?(Input::DOWN)
- cursor_down(Input.trigger?(Input::DOWN))
- end
- if Input.repeat?(Input::UP)
- cursor_up(Input.trigger?(Input::UP))
- end
- if Input.repeat?(Input::RIGHT)
- cursor_right(Input.trigger?(Input::RIGHT))
- end
- if Input.repeat?(Input::LEFT)
- cursor_left(Input.trigger?(Input::LEFT))
- end
- if Input.repeat?(Input::R)
- cursor_pagedown
- end
- if Input.repeat?(Input::L)
- cursor_pageup
- end
- if @index != last_index
- Sound.play_cursor
- end
- end
- update_cursor
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- if @column_max == 1
- for i in top_row..bottom_row
- draw_item(i)
- end
- else
- for i in 0..@item_max-1
- draw_item(i)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 绘制项目
- # index : 项目位置
- #
- #--------------------------------------------------------------------------
- def draw_item(index)
- rect = item_rect(index)
- rect.x += 4
- rect.width -= 8
- self.contents.clear_rect(rect)
- self.contents.font.color = normal_color
- if @column_max == 1
- self.contents.draw_text(rect, @命令组[index])
- else
- self.contents.draw_text(rect, @命令组[index],1)
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新光标
- #--------------------------------------------------------------------------
- def update_cursor
- if @index < 0 # 当光标位置小于0
- self.cursor_rect.empty # 隐藏光标
- else # 当光标位置为0或大于
- row = @index / @column_max # 获取当前行
- if row < top_row # 若先于首行
- self.top_row = row # 向上滚动
- end
- if row > bottom_row # 若後于末行
- self.bottom_row = row # 向下滚动
- end
- rect = item_rect(@index) # 获取所选项目矩形
- rect.y -= self.oy # 设矩形为滚动位置
- self.cursor_rect = rect # 更新光标矩形
- end
- refresh
- end
- end
- class Window_合成物品 < Window_Base
- attr_accessor :左边的物品 #数组,物品类型、id和持有数量
- attr_accessor :右边的物品 #数组,物品类型、id和数量
- #==========================================================================
- # ● 初始化对象
- #==========================================================================
- def initialize(x,y,n,m)
- super(x, y, n, m)
- @左边的物品 = []
- @右边的物品 = []
- end
-
- def 清除配方信息
- self.contents.clear
- end
-
- def 显示加入的材料
- self.contents.clear
- self.contents.font.color = Color.new(255, 0, 0, 255)
- self.contents.font.size = 25
- self.contents.draw_text(0,0,240,25, "按左、右键增减材料", 1)
- #====================================================================
- # ● 材料
- #====================================================================
- y = 0
- 材料=[]
- self.contents.font.size = 15
- self.contents.font.color = Color.new(255, 255, 0, 255)
- self.contents.draw_text(0,50,240,15, "加入的材料", 0)
- self.contents.draw_text(0,50,240,15, "数量", 2)
- self.contents.font.color = Color.new(0, 255, 0, 255)
- if @右边的物品.size > 0
- for i in 0..@右边的物品.size-1
- if @右边的物品[i] != nil
- 材料=@右边的物品[i]
- case 材料[0]
- when 1
- text = $data_items[材料[1]].name.to_s
- self.contents.draw_text(0,70+y*20,240,15, text, 0)
- self.contents.draw_text(0,70+y*20,240,15, 材料[2].to_s, 2)
- when 2
- text = $data_weapons[材料[1]].name.to_s
- self.contents.draw_text(0,70+y*20,240,15, text, 0)
- self.contents.draw_text(0,70+y*20,240,15, 材料[2].to_s, 2)
- when 3
- text = $data_armors[材料[1]].name.to_s
- self.contents.draw_text(0,70+y*20,240,15, text, 0)
- self.contents.draw_text(0,70+y*20,240,15, 材料[2].to_s, 2)
- end
- y += 1
- end
- end
- end
- end
-
-
- def 显示配方信息 (id)
- if id >= 0
- 临时配方 = []
- 临时配方 = $配方[$拥有的配方[id]]
- self.contents.clear
- #====================================================================
- # ● 配方名称
- #====================================================================
- case 临时配方[0]
- when 1 #物品
- text = $data_items[临时配方[1]].name.to_s
- self.contents.font.color = Color.new(255, 0, 0, 255)
- self.contents.font.size = 25
- self.contents.draw_text(0,0,240,25, text, 1)
- when 2 #武器
- text = $data_weapons[临时配方[1]].name.to_s
- self.contents.font.color = Color.new(255, 0, 0, 255)
- self.contents.font.size = 25
- self.contents.draw_text(0,0,240,25, text, 1)
- when 3 #防具
- text = $data_armors[临时配方[1]].name.to_s
- self.contents.font.color = Color.new(255, 0, 0, 255)
- self.contents.font.size = 25
- self.contents.draw_text(0,0,240,25, text, 1)
- end
- #====================================================================
- # ● 材料
- #====================================================================
- y = 0
- 材料=[]
- self.contents.font.size = 15
- self.contents.font.color = Color.new(255, 255, 0, 255)
- self.contents.draw_text(0,50,240,15, "所需材料", 0)
- self.contents.draw_text(0,50,240,15, "数量", 2)
- for i in 2..临时配方.size-2
- 材料=临时配方[i]
- case 材料[0]
- when 1
- if $game_party.item_number($data_items[材料[1]]) < 材料[2]
- self.contents.font.color = Color.new(128, 128, 128, 255)
- else
- self.contents.font.color = Color.new(0, 255, 0, 255)
- end
- text = $data_items[材料[1]].name.to_s
- self.contents.draw_text(0,70+y*20,240,15, text, 0)
- text=$game_party.item_number($data_items[材料[1]]).to_s+"/"+材料[2].to_s
- self.contents.draw_text(0,70+y*20,240,15, text, 2)
- when 2
- if $game_party.item_number($data_weapons[材料[1]]) < 材料[2]
- self.contents.font.color = Color.new(128, 128, 128, 255)
- else
- self.contents.font.color = Color.new(0, 255, 0, 255)
- end
- text = $data_weapons[材料[1]].name.to_s
- self.contents.draw_text(0,70+y*20,240,15, text, 0)
- text=$game_party.item_number($data_weapons[材料[1]]).to_s+"/"+材料[2].to_s
- self.contents.draw_text(0,70+y*20,240,15, text, 2)
- when 3
- if $game_party.item_number($data_armors[材料[1]]) < 材料[2]
- self.contents.font.color = Color.new(128, 128, 128, 255)
- else
- self.contents.font.color = Color.new(0, 255, 0, 255)
- end
- text = $data_armors[材料[1]].name.to_s
- self.contents.draw_text(0,70+y*20,240,15, text, 0)
- text=$game_party.item_number($data_armors[材料[1]]).to_s+"/"+材料[2].to_s
- self.contents.draw_text(0,70+y*20,240,15, text, 2)
- end
- y += 1
- end
- #====================================================================
- # ● 成功率
- #====================================================================
- text = "成功率:"+临时配方[临时配方.size-1].to_s+"%"
- self.contents.font.color = Color.new(255, 255, 0, 255)
- self.contents.font.size = 15
- self.contents.draw_text(0,30,240,15, text, 2)
- end
- end
- end
- #============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # ● 呼出合成菜单
- #--------------------------------------------------------------------------
- def 呼出合成菜单
- return if $game_temp.in_battle #判断是否战斗中
- return if $game_map.interpreter.running? # 判断是否有事件正在执行
- return if $game_player.moving? # 判断主角是否移动中
- $scene = Scene_合成物品.new
- end
-
- def 增加配方(配方的序号)
- #--------------------------------------------------------------------
- # 增加配方
- #--------------------------------------------------------------------
- n = 0
- for i in $拥有的配方
- n += 1
- if i == 结果[1]
- n = false
- break
- else
- if n == $拥有的配方.size
- n = true
- end
- end
- end
- if n
- $拥有的配方.push(结果[1])
- 临时配方=[]
- 临时配方=$配方[结果[1]]
- 临时=[]
- 临时=临时配方[0]
- case 临时
- when 1
- 临时=临时配方[1]
- text = "发现 " + $data_items[临时].name + "配方"
- when 2
- text = "发现 " + $data_weapons[临时].name + "配方"
- when 3
- text = "发现 " + $data_armors[临时].name + "配方"
- end
- $game_message.texts.push(text)
- end
- end
- end
- #============================================================================
- # ● 处理
- #============================================================================
- class Scene_合成物品 < Scene_Base
- #--------------------------------------------------------------------------
- # ● 开始处理
- #--------------------------------------------------------------------------
- def start
- super
- 生成顶部窗口
- @无用窗口_window = Window_合成物品.new(0, 56, 272, 360)
- @右边窗口_window = Window_合成物品.new (272, 56, 272, 360-56)
- 生成确认窗口
- @左边窗口激活 = false
- end
- #--------------------------------------------------------------------------
- # ● 结束处理
- #--------------------------------------------------------------------------
- def terminate
- super
- @顶部窗口_window.dispose
- @右边窗口_window.dispose
- @无用窗口_window.dispose
- @确认窗口_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- @顶部窗口_window.update
- @左边窗口_window.update if @左边窗口激活
- @确认窗口_window.update
-
-
- if @确认窗口_window.active
- 更新确认窗口
-
- elsif @左边窗口激活
- 更新左边窗口 if @左边窗口_window.active
-
- elsif @顶部窗口_window.active
- 更新顶部窗口
-
- end
- end
- #--------------------------------------------------------------------------
- # ● 生成顶部窗口
- #--------------------------------------------------------------------------
- def 生成顶部窗口
- @顶部窗口_window = Window_滚动命令1.new(0, 0, 544, 56,["自由合成","配方合成"])
- @顶部窗口_window.index = 0
- @顶部窗口_window.column_max = 2
- end
- #--------------------------------------------------------------------------
- # ● 更新顶部窗口
- #--------------------------------------------------------------------------
- def 更新顶部窗口
- if Input.trigger?(Input::B)
- Sound.play_cancel
- $scene = Scene_Map.new
- elsif Input.trigger?(Input::C)
- Sound.play_decision
-
- if @顶部窗口_window.index == 1
- 配方列表 = []
- 临时配方 = []
- for i in $拥有的配方
- 临时配方 = $配方[i]
- case 临时配方[0]
- when 1
- 配方列表.push($data_items[临时配方[1]].name.to_s)
- when 2
- 配方列表.push($data_weapons[临时配方[1]].name.to_s)
- when 3
- 配方列表.push($data_armors[临时配方[1]].name.to_s)
- end
- end
- if 配方列表.size > 0
- @顶部窗口_window.active = false
- 生成左边窗口(配方列表)
- @右边窗口_window.显示配方信息 (@左边窗口_window.index)
- @右边窗口_window.update
- end
- else
- #--------------------------------------------------------------------
- # 获取物品资料
- #--------------------------------------------------------------------
- 命令组=获取物品资料
- #--------------------------------------------------------------------
- # 将物品在左边窗口显示
- #--------------------------------------------------------------------
- if 命令组.size > 0
-
- @顶部窗口_window.active = false
- 生成左边窗口(命令组)
- @右边窗口_window.右边的物品 = []
- @右边窗口_window.显示加入的材料
- @右边窗口_window.update
- end
-
-
-
- end
- elsif Input.trigger?(Input::DOWN) or Input.trigger?(Input::UP)
-
- end
- end
- #--------------------------------------------------------------------------
- # ● 生成左边窗口
- #--------------------------------------------------------------------------
- def 生成左边窗口(命令组)
- @左边窗口_window = Window_滚动命令1.new(0, 56, 272, 360,命令组)
- @左边窗口_window.index = 0
- @左边窗口_window.active = true
- @左边窗口激活 = true
- end
- #--------------------------------------------------------------------------
- # ● 释放左边窗口
- #--------------------------------------------------------------------------
- def 释放左边窗口
- @左边窗口激活 = false
- @左边窗口_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● shuaxin
- #--------------------------------------------------------------------------
- def shuaxin
- @左边窗口_window.row_max
- @左边窗口_window.top_row
- @左边窗口_window.bottom_row
- end
- #--------------------------------------------------------------------------
- # ● 更新左边窗口
- #--------------------------------------------------------------------------
- def 更新左边窗口
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @右边窗口_window.清除配方信息
- @右边窗口_window.update
- @顶部窗口_window.active = true
- 释放左边窗口
- @右边窗口_window.左边的物品 = []
- @右边窗口_window.右边的物品 = []
- elsif Input.trigger?(Input::C)
- Sound.play_decision
- @确认窗口_window.active = true
- @左边窗口_window.active = false
- @确认窗口_window.index = 0
- elsif Input.trigger?(Input::DOWN) or Input.trigger?(Input::UP)
- if @顶部窗口_window.index == 1
- @右边窗口_window.显示配方信息 (@左边窗口_window.index)
- @右边窗口_window.update
- end
- elsif Input.trigger?(Input::RIGHT) and @顶部窗口_window.index == 0
- #--------------------------------------------------------------------
- # 加入材料
- #--------------------------------------------------------------------
- 临时1 = []
- 临时2 = []
- 临时1 = @右边窗口_window.左边的物品[@左边窗口_window.index]
- for i in 0..9
- if @右边窗口_window.右边的物品[i]!=nil
- 临时2 = @右边窗口_window.右边的物品[i]
- if 临时1[0] == 临时2[0] and 临时1[1] == 临时2[1]
- if 临时1[2]>临时2[2]
- 临时2[2] += 1
- @右边窗口_window.右边的物品[i] = 临时2
- end
- break
- elsif i == 9
- for i in 0..9
- if @右边窗口_window.右边的物品[i]==nil
- @右边窗口_window.右边的物品[i]=[临时1[0],临时1[1],1]
- break
- end
- end
- end
- elsif i == 9
- for i in 0..9
- if @右边窗口_window.右边的物品[i]==nil
- @右边窗口_window.右边的物品[i]=[临时1[0],临时1[1],1]
- break
- end
- end
- end
- end
- @右边窗口_window.显示加入的材料
- @右边窗口_window.update
- elsif Input.trigger?(Input::LEFT) and @顶部窗口_window.index == 0
- #--------------------------------------------------------------------
- # 减少材料
- #--------------------------------------------------------------------
- 临时1 = []
- 临时2 = []
- 临时1 = @右边窗口_window.左边的物品[@左边窗口_window.index]
- for i in 0..@右边窗口_window.右边的物品.size-1
- if @右边窗口_window.右边的物品[i]!=nil
- 临时2 = @右边窗口_window.右边的物品[i]
- if 临时1[0]==临时2[0] and 临时1[1]==临时2[1] and 0<临时2[2]
- 临时2[2] -= 1
- if 临时2[2]==0
- @右边窗口_window.右边的物品[i] = nil
- else
- @右边窗口_window.右边的物品[i] = 临时2
- end
- break
- end
- end
- end
- @右边窗口_window.显示加入的材料
- @右边窗口_window.update
- end
- end
-
- #--------------------------------------------------------------------
- # 获取物品资料
- #--------------------------------------------------------------------
- def 获取物品资料
- 临时 = []
- 命令组 = []
- for i in 1..$data_items.size-1
- if $game_party.item_number($data_items[i]) > 0
- 临时[0] = 1
- 临时[1] = i
- 临时[2] = $game_party.item_number($data_items[i])
- @右边窗口_window.左边的物品.push([临时[0],临时[1],临时[2]])
- 命令组.push($data_items[i].name.to_s+" X "+临时[2].to_s)
- end
- end
- for i in 1..$data_weapons.size-1
- if $game_party.item_number($data_weapons[i]) > 0
- 临时[0] = 2
- 临时[1] = i
- 临时[2] = $game_party.item_number($data_weapons[i])
- @右边窗口_window.左边的物品.push([临时[0],临时[1],临时[2]])
- 命令组.push($data_weapons[i].name.to_s+" X "+临时[2].to_s)
- end
- end
- for i in 1..$data_armors.size-1
- if $game_party.item_number($data_armors[i]) > 0
- 临时[0] = 3
- 临时[1] = i
- 临时[2] = $game_party.item_number($data_armors[i])
- @右边窗口_window.左边的物品.push([临时[0],临时[1],临时[2]])
- 命令组.push($data_armors[i].name.to_s+" X "+临时[2].to_s)
- end
- end
- return 命令组
- end
- #--------------------------------------------------------------------------
- # ● 生成确认窗口
- #--------------------------------------------------------------------------
- def 生成确认窗口
- @确认窗口_window = Window_滚动命令1.new(272,360,272,56,["确认合成","取消"])
- @确认窗口_window.index = -1
- @确认窗口_window.column_max = 2
- @确认窗口_window.active = false
- end
- #--------------------------------------------------------------------------
- # ● 更新确认窗口
- #--------------------------------------------------------------------------
- def 更新确认窗口
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @左边窗口_window.active = true
- @确认窗口_window.active = false
- @确认窗口_window.index = -1
- elsif Input.trigger?(Input::C)
- Sound.play_decision
- if @确认窗口_window.index == 0
- if @顶部窗口_window.index == 1
- 释放左边窗口
- $scene = Scene_Map.new
- if 判断合成条件(@左边窗口_window.index) == false
- $game_message.texts.push(" 材料不足")
- else
- $game_message.texts.push(执行配方合成(@左边窗口_window.index).to_s)
- end
- else
- for i in 0..@右边窗口_window.右边的物品.size-1
- @右边窗口_window.右边的物品.delete_at(i) if @右边窗口_window.右边的物品[i]==nil
- end
- if @右边窗口_window.右边的物品.size>0
- 释放左边窗口
- $scene = Scene_Map.new
- $game_message.texts.push(执行自由合成(自由合成判断).to_s)
- end
- end
- else
- @确认窗口_window.active = false
- @左边窗口_window.active = true
- @确认窗口_window.index = -1
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 判断合成条件
- #--------------------------------------------------------------------------
- def 判断合成条件(id)
- 临时配方 = []
- 临时配方 = $配方[$拥有的配方[id]]
- 材料 = []
- for i in 2..临时配方.size-2
- 材料=临时配方[i]
- case 材料[0]
- when 1
- if $game_party.item_number($data_items[材料[1]])<材料[2]
- return false
- break
- elsif i == 临时配方.size-2
- return true
- end
- when 2
- if $game_party.item_number($data_weapons[材料[1]])<材料[2]
- return false
- break
- elsif i == 临时配方.size-2
- return true
- end
- when 3
- if $game_party.item_number($data_armors[材料[1]])<材料[2]
- return false
- break
- elsif i == 临时配方.size-2
- return true
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 执行配方合成
- #--------------------------------------------------------------------------
- def 执行配方合成(id)
- 临时配方 = []
- 临时配方 = $配方[$拥有的配方[id]]
- 材料 = []
- for i in 2..临时配方.size-2
- 材料=临时配方[i]
- case 材料[0]
- when 1
- $game_party.gain_item($data_items[材料[1]],-材料[2])
- $game_message.texts.push("失去 "+$data_items[材料[1]].name.to_s+" X "+材料[2].to_s)
- when 2
- $game_party.gain_item($data_weapons[材料[1]],-材料[2])
- $game_message.texts.push("失去 "+$data_weapons[材料[1]].name.to_s+" X "+材料[2].to_s)
- when 3
- $game_party.gain_item($data_armors[材料[1]],-材料[2])
- $game_message.texts.push("失去 "+$data_armors[材料[1]].name.to_s+" X "+材料[2].to_s)
- end
- end
- if rand(100)+1<临时配方[临时配方.size-1]
- case 临时配方[0]
- when 1
- $game_party.gain_item($data_items[临时配方[1]],1)
- $game_message.texts.push("获得 "+$data_items[临时配方[1]].name.to_s+" X 1")
- when 2
- $game_party.gain_item($data_weapons[临时配方[1]],1)
- $game_message.texts.push("获得 "+$data_weapons[临时配方[1]].name.to_s+" X 1")
- when 3
- $game_party.gain_item($data_armors[临时配方[1]],1)
- $game_message.texts.push("获得 "+$data_armors[临时配方[1]].name.to_s+" X 1")
- end
- return " !!!合成成功!!!"
- else
- return " !!!失败!!!"
- end
- end
- #--------------------------------------------------------------------------
- # ● 自由合成判断
- #--------------------------------------------------------------------------
- def 自由合成判断
- 临时配方=[]
- 材料=[]
- 结果=[]
- 结果[0]=false
- 结果[1]= -1
- for i in 0..$配方.size-1
- 循环判断 = true
- 临时配方=$配方[i]
- if 临时配方.size-3 == @右边窗口_window.右边的物品.size
- for a in 2..临时配方.size-2
- 材料=临时配方[a]
- for b in 0..@右边窗口_window.右边的物品.size-1
- if 材料==@右边窗口_window.右边的物品[b]
- break
- else
- 循环判断 = false if b == @右边窗口_window.右边的物品.size-1
- break
- end
- end
- break if 循环判断 == false
- if a == 临时配方.size-2 and 循环判断 == true
- 结果[0]=true
- 结果[1]=i
- end
- end
- else
- 循环判断 = false
- break
- end
- if 结果[1] != -1
- 结果[0]=true
- break
- end
- if i == $配方.size-1 and 结果[1] == -1
- 结果[0]=false
- end
- end
- return 结果
- end
- #--------------------------------------------------------------------------
- # ● 执行自由合成
- #--------------------------------------------------------------------------
- def 执行自由合成(结果)
- if 结果[0] == true
- 临时配方=[]
- 材料=[]
- 临时配方=@右边窗口_window.右边的物品
- for i in 0..临时配方.size-1
- 材料=临时配方[i]
- case 材料[0]
- when 1
- $game_party.gain_item($data_items[材料[1]],-材料[2])
- $game_message.texts.push("失去 "+$data_items[材料[1]].name.to_s+" X "+材料[2].to_s)
- when 2
- $game_party.gain_item($data_weapons[材料[1]],-材料[2])
- $game_message.texts.push("失去 "+$data_weapons[材料[1]].name.to_s+" X "+材料[2].to_s)
- when 3
- $game_party.gain_item($data_armors[材料[1]],-材料[2])
- $game_message.texts.push("失去 "+$data_armors[材料[1]].name.to_s+" X "+材料[2].to_s)
- end
- end
- 临时配方=[]
- 临时配方=$配方[结果[1]]
- if rand(100)+1<临时配方[临时配方.size-1]
- case 临时配方[0]
- when 1
- $game_party.gain_item($data_items[临时配方[1]],1)
- $game_message.texts.push("获得 "+$data_items[临时配方[1]].name.to_s+" X 1")
- when 2
- $game_party.gain_item($data_weapons[临时配方[1]],1)
- $game_message.texts.push("获得 "+$data_weapons[临时配方[1]].name.to_s+" X 1")
- when 3
- $game_party.gain_item($data_armors[临时配方[1]],1)
- $game_message.texts.push("获得 "+$data_armors[临时配方[1]].name.to_s+" X 1")
- end
- #--------------------------------------------------------------------
- # 增加配方
- #--------------------------------------------------------------------
- n = 0
- for i in $拥有的配方
- n += 1
- if i == 结果[1]
- n = false
- break
- else
- if n == $拥有的配方.size
- n = true
- end
- end
- end
- if n
- $拥有的配方.push(结果[1])
- 临时配方=[]
- 临时配方=$配方[结果[1]]
- 临时=[]
- 临时=临时配方[0]
- case 临时
- when 1
- 临时=临时配方[1]
- text = "发现 " + $data_items[临时].name + "配方"
- when 2
- text = "发现 " + $data_weapons[临时].name + "配方"
- when 3
- text = "发现 " + $data_armors[临时].name + "配方"
- end
- $game_message.texts.push(text)
- end
- return " !!!合成成功!!!"
- else
- #--------------------------------------------------------------------
- # 增加配方
- #--------------------------------------------------------------------
- n = 0
- for i in $拥有的配方
- n += 1
- if i == 结果[1]
- n = false
- break
- else
- if n == $拥有的配方.size
- n = true
- end
- end
- end
- if n
- $拥有的配方.push(结果[1])
- 临时配方=[]
- 临时配方=$配方[结果[1]]
- 临时=[]
- 临时=临时配方[0]
- case 临时
- when 1
- 临时=临时配方[1]
- text = "发现 " + $data_items[临时].name + "配方"
- when 2
- text = "发现 " + $data_weapons[临时].name + "配方"
- when 3
- text = "发现 " + $data_armors[临时].name + "配方"
- end
- $game_message.texts.push(text)
- end
- return " !!!失败!!!"
- end
- else
- 合成失败惩罚(@右边窗口_window.右边的物品)
- return " !!!失败!!!"
- end
- end
- #--------------------------------------------------------------------------
- # ● 合成失败惩罚
- #--------------------------------------------------------------------------
- def 合成失败惩罚(材料)
- 惩罚系数=1 # 最多损失多少种材料,0为不损失,填0~10
- if 惩罚系数 > 0
- 材料组=材料
- 损失=[]
- 临时=[]
- for i in 1..惩罚系数
- for i in 0..9
- if 材料组[i] != nil
- 临时.push(i)
- end
- end
- 临时=临时[rand(临时.size-1)]
- 损失=材料组.delete_at(临时)
- case 损失[0]
- when 1
- $game_party.gain_item($data_items[损失[1]],-损失[2])
- $game_message.texts.push("失去 "+$data_items[损失[1]].name.to_s+" X"+损失[2].to_s)
- when 2
- $game_party.gain_item($data_weapons[损失[1]],-损失[2])
- $game_message.texts.push("失去 "+$data_weapons[损失[1]].name.to_s+" X"+损失[2].to_s)
- when 3
- $game_party.gain_item($data_armors[损失[1]],-损失[2])
- $game_message.texts.push("失去 "+$data_armors[损失[1]].name.to_s+" X"+损失[2].to_s)
- end
- break if 材料组.size == 0
- end
- end
- end
-
- end
复制代码 |
|