赞 | 0 |
VIP | 11 |
好人卡 | 4 |
积分 | 1 |
经验 | 5543 |
最后登录 | 2017-7-12 |
在线时间 | 56 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 56 小时
- 注册时间
- 2012-6-23
- 帖子
- 156
|
“整队”这个功能放着也没关系的吧。
给你个任务脚本好了,说明在注释中~- =begin
- 领取任务:$game_party.get_task(任意数字,任务名称,任务描述)
- 完成任务:$game_party.finish_task(领取任务时设定的数字)
- 对已有任务追加说明:$game_party.add_task(任务编号,任务追加描述)
- 如:
- 前面有事件$game_party.get_task(1,"测试","只是测试")
- 此时任务1的说明为
- >只是测试
- 后面完成任务的脚本就是$game_party.finish_task(1)
- 追加说明$game_party.add_task(1,"真的只是测试哦")
- 此时任务1的说明为:
- >只是测试
- >真的只是测试哦
- 召唤任务界面:SceneManager.call(Scene_Task)
- 该脚本来自66rpg,发布者:韩云溪
- 改进:工藤由纪(论坛ID:zyyczp)
- =end
- #===========================================================
- #●任务系统
- #===========================================================
- class Task
- attr_reader :desc
- attr_reader :finished
- def initialize(origin_name,desc)
- @origin_name = origin_name
- @desc = desc
- @finished = false
- end
- def name
- if @finished
- return @origin_name + "(完成)"
- else
- return @origin_name
- end
- end
- def desc=(desc)
- @desc = desc
- end
-
- def finish
- @finished = true
- end
-
- end
- class Game_Party < Game_Unit
- alias old_init initialize
- def initialize
- old_init
- @tasks = {}
- end
- def add_task(i,desc)
- @tasks[i].desc = @tasks[i].desc + "\n" + desc
- end
- def get_task(i,name,desc)
- @tasks[i]=Task.new(name,desc)
- end
- def have_task?(i)
- @tasks[i] != nil
- end
- def finish_task(i)
- @tasks[i].finish if have_task?(i)
- end
- def unfinished_tasks
- n = []
- for i in @tasks.values
- next if i.finished
- n.push(i)
- end
- return n
- end
- def finished_tasks
- n = []
- for i in @tasks.values
- next unless i.finished
- n.push(i)
- end
- return n
- end
- end
- class Window_Task_Type < Window_HorzCommand
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0)
- activate
- end
- def window_width
- return Graphics.width
- end
- def col_max
- return 3
- end
- #--------------------------------------------------------------------------
- # ● コマンドリストの作成
- #--------------------------------------------------------------------------
- def make_command_list
- add_command("未完成任务", :unfinished_task)
- add_command("已完成任务", :finished_task)
- add_command("取消", :cancel)
- end
- end
- class Window_TaskLeft < Window_Selectable
- attr_reader :finished
- def initialize
- super(0,48,160,Graphics.height - 48)
- create_contents
- @finished = false
- @index = 0
- refresh
- deactivate
- end
- def set_finish(finish)
- @finished = finish
- set_item_max
- end
- def item_max
- return @item_max != nil ? @item_max : 0
- end
- def set_item_max
- if @finished
- @item_max = $game_party.finished_tasks.size
- else
- @item_max = $game_party.unfinished_tasks.size
- end
- end
- def refresh
- set_item_max
- super
- end
- #--------------------------------------------------------------------------
- # ● 項目の描画
- #--------------------------------------------------------------------------
- def draw_item(index)
- text = ""
- unless @finished
- if $game_party.unfinished_tasks[index] != nil
- text = $game_party.unfinished_tasks[index].name
- end
- else
- if $game_party.finished_tasks[index] != nil
- text = $game_party.finished_tasks[index].name
- end
- end
- draw_text(item_rect_for_text(index), text)
- end
- end
- class Window_TaskRight < Window_Base
- attr_reader :left_index
- def initialize
- super(160,48,Graphics.width - 160,Graphics.height - 48)
- create_contents
- @left_index = 0
- @finished = false
- refresh
- end
- def set_index(i)
- @left_index = i
- refresh
- end
- def set_finish(i)
- @finished = i
- end
-
- def refresh
- contents.clear
- draw_desc
- end
- def draw_desc
- if @finished
- if $game_party.finished_tasks[@left_index] != nil
- draw_text_ex(0,0,$game_party.finished_tasks[@left_index].desc)
- end
- else
- if $game_party.unfinished_tasks[@left_index] != nil
- draw_text_ex(0,0,$game_party.unfinished_tasks[@left_index].desc)
- end
- end
- end
-
- end
- class Scene_Task < Scene_Base
- def start
- super
- create_task_type_window
- create_left_window
- create_right_window
- end
- def update
- super
- if @left_window.active
- if Input.trigger?(:B)
- @left_window.deactivate
- @task_type_window.activate
- end
- if Input.trigger?(:UP) || Input.trigger?(:DOWN)
- @right_window.set_finish(@left_window.finished)
- @right_window.set_index(@left_window.index)
- end
- end
- end
-
- def terminate
- super
- end
- def create_task_type_window
- @task_type_window = Window_Task_Type.new
- @task_type_window.set_handler(:unfinished_task,method(:view_unfinished_task))
- @task_type_window.set_handler(:finished_task,method(:view_finished_task))
- @task_type_window.set_handler(:cancel,method(:return_scene))
- end
- def create_left_window
- @left_window = Window_TaskLeft.new
- @left_window.set_finish(false)
- @left_window.refresh
- end
- def create_right_window
- @right_window = Window_TaskRight.new
- @right_window.refresh
- end
- def view_unfinished_task
- @left_window.set_finish(false)
- @left_window.refresh
- @left_window.activate
- @task_type_window.deactivate
- @right_window.set_finish(false)
- @right_window.set_index(@left_window.index)
- end
- def view_finished_task
- @left_window.set_finish(true)
- @left_window.refresh
- @left_window.activate
- @task_type_window.deactivate
- @right_window.set_finish(true)
- @right_window.set_index(@left_window.index)
- end
-
- end
复制代码 接下说一下主菜单添加查看任务命令的方法:
1、先打开脚本窗口(废话 = =)
2、找到Windows_MenuCommand
在 def add_main_commands 下方end之前插入- add_command("任务", :task, main_commands_enabled)
复制代码 3、找到Scene_Menu
在 def create_command_window 下方end之前插入- @command_window.set_handler(:task, method(:command_task))
复制代码 4、在- #--------------------------------------------------------------------------
- # ● 指令“结束游戏”
- #--------------------------------------------------------------------------
- def command_game_end
- SceneManager.call(Scene_End)
- end
复制代码 前面加入- #--------------------------------------------------------------------------
- # ● 指令“任务”
- #--------------------------------------------------------------------------
- def command_task
- SceneManager.call(Scene_Task)
- end
-
复制代码 即可。使用方法:
具体判定某个任务是否完成只需要:$game_party.tasks(编号).finished(完成的情况下返回真,未完成返回假,说白了,就是完成的情况下条件成立)如:
$game_party.tasks(1).finished #=> 完成时为true,没有完成为false
在条件分歧的情况下,只需要在脚本里面填上这样一行就了。
=============================================
以上摘自http://rpg.blue/forum.php?mod=viewthread&tid=221055
=============================================
使用这个脚本任务栏里就会多出“任务”按钮了。具体的任务追加方法在脚本注释里有,我就不多说了 |
|