| 赞 | 9 |
| VIP | |
| 好人卡 | |
| 积分 | 29 |
| 经验 | |
| 最后登录 | 2023-12-28 |
| 在线时间 | 713 小时 |
- 梦石
- 0
- 星屑
- 2920
- 在线时间
- 713 小时
- 注册时间
- 2010-7-25
- 回帖
- 659

|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 jianyulei 于 2017-8-21 11:52 编辑
本体
- =begin
- 使用物品/装备后触发公共事件 by:老香蕉
-
- 插入后菜单将新增一个选项,点选进入道具选择界面,当选择任一一个道具后自动将道具
- 的ID保存到变量并激活公共事件,你可以在公共事件里面设定一切你想做的东西,根据需
- 求这个脚本会产生不同的作用。
-
- SceneManager.call(Scene_Item_hc) 也可以呼出菜单,另外,因为没有制作战斗中的
- 使用方法,不想报错的话就不要在战斗中使用这个命令。
-
- 使用例:
- 你拥有武器ID3的PPK手枪和物品ID6的手枪用瞄准镜,你在公共事件121(武器公共事件)
- 里写入分歧:如果变量11(接收物品ID的变量)等于3(PPK的ID号),则进入2个选项:
- 选项1为加装瞄准镜,选项2为拆卸武器,在1选项里判断是否拥有手枪瞄准镜,是的话就
- 删除手枪和瞄准镜得到“带有瞄准镜的PPK”,如果选2就失去武器,得到机器零件X3
- 当然,实际使用的时候你可以随意设定,因为是使用公共事件,所以非常灵活和简单,
- 缺点是不太方便,而且需要一定的脚本知识。
-
- =end
- #===============================================================
- module LX20170818
- TXT = "改造" #这里设定菜单显示的选项名称
- BIANL = 11 #这里设定占用的变量,用于接收物品ID
- GGSJ1 = 120 #道具的公共事件
- GGSJ2 = 121 #武器的公共事件
- GGSJ3 = 122 #防具的公共事件
- XXKG = 21 #菜单中是否显示选项的开关的ID
- end
- #===============================================================
- class Scene_Item_hc < Scene_ItemBase
- def start
- super
- create_help_window
- create_category1_window
- create_item1_window
- end
- def create_category1_window #新的分类
- @category_window = Window_ItemCategory.new
- @category_window.viewport = @viewport
- @category_window.help_window = @help_window
- @category_window.y = @help_window.height
- @category_window.set_handler(:ok, method(:on_category1_ok))
- @category_window.set_handler(:cancel, method(:return_scene))
- end
- def create_item1_window #新的物品
- wy = @category_window.y + @category_window.height
- wh = Graphics.height - wy
- @item_window = Window_ItemList_hc.new(0, wy, Graphics.width, wh)
- @item_window.viewport = @viewport
- @item_window.help_window = @help_window
- @item_window.set_handler(:ok, method(:on_item1_ok))
- @item_window.set_handler(:cancel, method(:on_item1_cancel))
- @category_window.item_window = @item_window
- end
- def on_category1_ok #新的分类“确定”
- @item_window.activate
- @item_window.select_last
- end
- def on_item1_ok #新的物品“确定”
- $game_party.last_item.object = item
- determine_item_hc
- end
- def on_item1_cancel #新的物品“取消”
- @item_window.unselect
- @category_window.activate
- end
- def play_se_for_item #音效
- Sound.play_use_item
- end
- def use_item #使用物品
- super
- @item_window.redraw_current_item
- end
-
- end
- #===============================================================
- class Window_ItemList_hc < Window_Selectable
- def initialize(x, y, width, height) #初始化对象
- super
- @category = :none
- @data = []
- end
- def category=(category) #设置分类
- return if @category == category
- @category = category
- refresh
- self.oy = 0
- end
- def col_max #获取列数
- return 2
- end
- def item_max #获取项目数
- @data ? @data.size : 1
- end
- def item #获取物品
- @data && index >= 0 ? @data[index] : nil
- end
- def current_item_enabled? #获取选择项目的有效状态
- enable?(@data[index])
- end
- def include?(item) #查询列表中是否含有此物品
- case @category
- when :item
- item.is_a?(RPG::Item) && !item.key_item?
- when :weapon
- item.is_a?(RPG::Weapon)
- when :armor
- item.is_a?(RPG::Armor)
- when :key_item
- item.is_a?(RPG::Item) && item.key_item?
- else
- false
- end
- end
- def enable?(item) #查询此物品是否可用
- return true
- end
- def make_item_list #生成物品列表
- @data = $game_party.all_items.select {|item| include?(item) }
- @data.push(nil) if include?(nil)
- end
- def select_last #返回上一个选择的位置
- select(@data.index($game_party.last_item.object) || 0)
- end
- def draw_item(index) #绘制项目
- item = @data[index]
- if item
- rect = item_rect(index)
- rect.width -= 4
- draw_item_name(item, rect.x, rect.y, enable?(item))
- draw_item_number(rect, item)
- end
- end
- def draw_item_number(rect, item) #绘制物品个数
- draw_text(rect, sprintf(":%2d", $game_party.item_number(item)), 2)
- end
- def update_help #更新帮助内容
- @help_window.set_item(item)
- end
- def refresh #刷新
- make_item_list
- create_contents
- draw_all_items
- end
- end
- #===============================================================
- class Scene_ItemBase < Scene_MenuBase
- def determine_item_hc #确定物品
- $game_variables[LX20170818::BIANL] = item.id
- if item.is_a?(RPG::Item) #道具判定
- SceneManager.goto(Scene_Map);$game_temp.reserve_common_event(LX20170818::GGSJ1);end
- if item.is_a?(RPG::Weapon) #武器判定
- SceneManager.goto(Scene_Map);$game_temp.reserve_common_event(LX20170818::GGSJ2);end
- if item.is_a?(RPG::Armor) #防具判定
- SceneManager.goto(Scene_Map);$game_temp.reserve_common_event(LX20170818::GGSJ3);end
- end
- end
- #===============================================================
- class Window_MenuCommand < Window_Command
- def add_main_commands #为了位置上的美观,没有重命名
- add_command(Vocab::item, :item, main_commands_enabled)
- add_command(LX20170818::TXT, :hc_gz, main_commands_enabled) if $game_switches[LX20170818::XXKG]
- add_command(Vocab::skill, :skill, main_commands_enabled)
- add_command(Vocab::equip, :equip, main_commands_enabled)
- add_command(Vocab::status, :status, main_commands_enabled)
- end
- end
- #===============================================================
- class Scene_Menu < Scene_MenuBase
- alias hcck_create_command_window create_command_window
- def create_command_window
- hcck_create_command_window
- @command_window.set_handler(:hc_gz, method(:command_hc))
- end
- def command_hc
- SceneManager.call(Scene_Item_hc)
- end
- end
复制代码
一些分歧判断用的函数:(使用方法:分歧-脚本)
$game_party.members.size >= 3 队伍人物是否大于等于3
$game_party.members.include?($game_actors[3]) 3号角色在不在队伍中
$game_party.members[0].armors.include?($data_armors[107]) 领队角色是否装备有107号防具,武器的话将armors改为weapons
$game_player.y == 14 玩家在地图上的Y值是否是14
$game_switches[2] 2号开关是否开启
$game_self_switches[[21,14,"龙傲天"]] 21号地图的14号事件的“龙傲天”独立开关是否打开
(独立开关游戏中只给了ABCD,其实一个事件你可以设定无数个独立开关)
$game_variables[4] > $game_actors[1].hp 4号变量是否大于1号角色的HP
$game_actors[4].state?(857) 4号角色是否存在857号状态
$game_actors[1].usable?($data_skills[946]) 1号角色的946号技能是否可用
$game_actors[1].movable? 1号角色是否可以行动
$game_actors[1].class_id == 12 1号角色是否是12号职业
$game_party.item_number($data_items[56]) > 8 56号道具的数量是否大于8(用此脚本来合成的话,这个方法我估计你们会经常用到)武器和防具的写法见上方
$game_map.events[7].region_id == 5 判断7号事件是否在5号区域
$game_player.region_id == 5 判断玩家是否在5号区域
$game_party.members.any? {|actor| actor.state?(2)} 判断所有队员中是否有人存在2号状态
其实这脚本的内容是对着原始脚本直接复制粘贴过来的,界面类的脚本我自己都看不懂,但是已经尽可能的自定义以增加兼容性了,至少在我的用了无数脚本的大工程里没有发现兼容问题,我不对其他脚本的兼容问题负责
麻烦版主帮下忙将帖子移动到发布版吧 |
|