Project1
标题:
【求助】技能选择框
[打印本页]
作者:
杂兵天下
时间:
2012-3-28 16:38
标题:
【求助】技能选择框
就是类似VA自带物品选择处理的技能选择处理。首先给出角色ID,然后选择,最后可以把技能编号赋值到变量的这样的脚本。 dsu_plus_rewardpost_czw
作者:
消失的三千
时间:
2012-3-28 16:52
本帖最后由 消失的三千 于 2012-3-28 18:40 编辑
这貌似用来制作地图技能的吧?
我试写个看看……
原本想要仿物品选择处理,不过太困难了= =所以转用界面来选择了(原谅我吧OTL)
用法
:
62行可以更改控制ID(A变量)
然后变更A变量为保存技能ID的变量ID(B变量)
SceneManager.call(Scene_SkillChoice)
复制代码
这语句用来打开界面
打开界面前请把B变量归零
class Window_Skill < Window_Selectable
def initialize(x, y, width, height)
super
@actor = nil
@stype_id = 0
@data = []
end
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
self.oy = 0
end
def stype_id=(stype_id)
return if @stype_id == stype_id
@stype_id = stype_id
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 include?(item)
item && item.stype_id == @stype_id
end
def make_item_list
@data = @actor ? @actor.skills.select {|skill| include?(skill) } : []
end
def draw_item(index)
skill = @data[index]
if skill
rect = item_rect(index)
rect.width -= 4
draw_item_name(skill, rect.x, rect.y)
end
end
def update_help
@help_window.set_item(item)
end
def refresh
make_item_list
create_contents
draw_all_items
end
def process_ok
Sound.play_ok
Input.update
deactivate
call_ok_handler
end
end
class Scene_SkillChoice < Scene_MenuBase
def start
super
@vid = $game_variables[10]
create_background
create_command_window
create_item_window
@status_window = Window_MenuStatus.new(80, 0)
@status_window.select_last
@status_window.activate
@status_window.set_handler(:ok, method(:select_actor))
@status_window.set_handler(:cancel, method(:return_scene))
end
def create_command_window
@command_window = Window_SkillCommand.new(0, 0)
@command_window.viewport = @viewport
@command_window.help_window = @help_window
@command_window.openness = 0
@command_window.set_handler(:skill, method(:select_skill))
@command_window.set_handler(:cancel, method(:return_select_actor))
@command_window.set_handler(:pagedown, method(:next_actor))
@command_window.set_handler(:pageup, method(:prev_actor))
end
def create_item_window
@skill_window = Window_Skill.new(64, 64, 416, 288)
@skill_window.help_window = @help_window
@skill_window.index = 0
@skill_window.openness = 0
@skill_window.set_handler(:ok, method(:choice_skill))
@skill_window.set_handler(:cancel, method(:return_select_skill))
@command_window.skill_window = @skill_window
end
def select_actor
@status_window.close
@skill_window.actor = $game_party.members[@status_window.index]
@skill_window.open
@command_window.actor = $game_party.members[@status_window.index]
@command_window.open
@command_window.activate
end
def return_select_actor
@command_window.close
@skill_window.close
@status_window.open
@status_window.activate
end
def select_skill
@command_window.close
@skill_window.actor = $game_party.members[@status_window.index]
@skill_window.activate
end
def return_select_skill
@command_window.actor = $game_party.members[@status_window.index]
@command_window.open
@command_window.activate
end
def choice_skill
$game_variables[@vid] = @skill_window.item.id
p $game_variables[@vid]
SceneManager.return
end
end
复制代码
好吧我这渣渣在前辈面前献丑了……Orz
作者:
杂兵天下
时间:
2012-3-28 19:06
消失的三千 发表于 2012-3-28 20:52
这貌似用来制作地图技能的吧?
我试写个看看……
稍微找一个BUG吧
class Scene_SkillChoice < Scene_MenuBase
def choice_skill
begin
$game_variables[@vid] = @skill_window.item.id
SceneManager.return
rescue
#选择空技能的SKIP处理
end
end
end
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1