赞 | 1 |
VIP | 0 |
好人卡 | 13 |
积分 | 5 |
经验 | 33457 |
最后登录 | 2024-8-8 |
在线时间 | 1409 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 457
- 在线时间
- 1409 小时
- 注册时间
- 2010-9-23
- 帖子
- 557
|
任务系统之二:
zhangchi5大大的任务系统:
使用方法如下:
任务系统使用方法:- 任务系统使用方法:
- 地图提示篇:
- 在事件里插入脚本 如下
- ---Script Begin---
- $game_maphint.clear
- str="地图提示功能"
- $game_maphint.setText(0,str)
- str="测试"
- $game_maphint.setText(1,str)
- str="第三行了"
- $game_maphint.setText(2,str)
- str="这是最后一行"
- $game_maphint.setText(3,str)
- ----Script End----
-
- 脚本功能:
- $game_maphint.clear
- ——清除之前地图提示的文字。
- $game_maphint.setText(<行号>,<文字>)
- ——设定指定行号上的文字。
-
-
-
- 任务篇:
- 在事件里插入脚本(添加任务) 如下
- ---Script Begin---
- @p=$game_missions.getNoMission
- str="搞定这个游戏"
- $game_missions.mission(@p).setTitle(str)
- str="慢慢享受游戏的乐趣吧~~"
- $game_missions.mission(@p).setText(0,str)
- str="不是人干的。。。"
- $game_missions.mission(@p).setText(1,str)
- str="奖励:游戏结束"
- $game_missions.mission(@p).setImText(str)
- s1="游戏系统";s2="最终结界";
- $game_missions.mission(@p).setNPC(s1,s2)
- $game_missions.mission(@p).setStatus(true)
- ----Script End----
-
- 在事件里插入脚本(交付任务) 如下
- ---Script Begin---
- @p=$game_missions.serMission("搞定这个游戏")
- $game_missions.mission(@p).clear
- $game_missions.mission(@p).setStatus(false)
- ----Script End----
-
- 脚本功能:
- * @p指用$game_missions.getNoMission获取的任务代码。
-
-
- $game_missions.mission(@p).clear
- ——清除之前任务的文字。
-
- $game_missions.mission(@p).setText(<行号>,<文字>)
- ——设定指定行号上的任务介绍。
-
- $game_missions.mission(@p).setImText(<文字>)
- ——设定任务重要信息/奖励。
-
- $game_missions.mission(@p).setNPC(<NPC1>,<NPC2>)
- ——设定任务接任务NPC,交付任务NPC。
-
- $game_missions.mission(@p).setStatus(<状态>)
- ——设定任务状态(True/False)。
-
- $game_missions.getNoMission
- ——找到一个可用的任务代码。
-
- $game_missions.serMission(<任务标题>)
- ——找到对应任务编码。
- * $game_missions.serMission(<任务标题>)的返回值为-1时说明任务不存在,否则返回此任务编码。
- * 在条件分歧中插入脚本$game_missions.serMission(<任务标题>)!=-1可判断任务是否正在进行。
复制代码 这个才是任务系统的脚本:- #==============================================================================
- # ■ 任务系统 By SkyZH
- # Version 2
- # bbs.66RPG.com
- #------------------------------------------------------------------------------
- # 任务系统使用方法:
- =begin
- 地图提示篇:
- 在事件里插入脚本 如下
- ---Script Begin---
- $game_maphint.clear
- str="地图提示功能"
- $game_maphint.setText(0,str)
- str="测试"
- $game_maphint.setText(1,str)
- str="第三行了"
- $game_maphint.setText(2,str)
- str="这是最后一行"
- $game_maphint.setText(3,str)
- ----Script End----
-
- 脚本功能:
- $game_maphint.clear
- ——清除之前地图提示的文字。
- $game_maphint.setText(<行号>,<文字>)
- ——设定指定行号上的文字。
-
-
-
- 任务篇:
- 在事件里插入脚本(添加任务) 如下
- ---Script Begin---
- @p=$game_missions.getNoMission
- str="搞定这个游戏"
- $game_missions.mission(@p).setTitle(str)
- str="慢慢享受游戏的乐趣吧~~"
- $game_missions.mission(@p).setText(0,str)
- str="不是人干的。。。"
- $game_missions.mission(@p).setText(1,str)
- str="奖励:游戏结束"
- $game_missions.mission(@p).setImText(str)
- s1="游戏系统";s2="最终结界";
- $game_missions.mission(@p).setNPC(s1,s2)
- $game_missions.mission(@p).setStatus(true)
- ----Script End----
-
- 在事件里插入脚本(交付任务) 如下
- ---Script Begin---
- @p=$game_missions.serMission("搞定这个游戏")
- $game_missions.mission(@p).clear
- $game_missions.mission(@p).setStatus(false)
- ----Script End----
-
- 脚本功能:
- * @p指用$game_missions.getNoMission获取的任务代码。、
-
-
- $game_missions.mission(@p).clear
- ——清除之前任务的文字。
-
- $game_missions.mission(@p).setText(<行号>,<文字>)
- ——设定指定行号上的任务介绍。
-
- $game_missions.mission(@p).setImText(<文字>)
- ——设定任务重要信息/奖励。
-
- $game_missions.mission(@p).setNPC(<NPC1>,<NPC2>)
- ——设定任务接任务NPC,交付任务NPC。
-
- $game_missions.mission(@p).setStatus(<状态>)
- ——设定任务状态(True/False)。
-
- $game_missions.getNoMission
- ——找到一个可用的任务代码。
-
- $game_missions.serMission(<任务标题>)
- ——找到对应任务编码。
- * $game_missions.serMission(<任务标题>)的返回值为-1时说明任务不存在,否则返回此任
- 务编码。
- * 在条件分歧中插入脚本$game_missions.serMission(<任务标题>)!=-1可判断任务是否正在
- 进行。
-
-
-
- =end
- #==============================================================================
- #==============================================================================
- # ■ Game_MapHint
- #------------------------------------------------------------------------------
- # 地图提示信息显示。
- #==============================================================================
- class Game_MapHint
-
- def initialize
- @texts = []
- end
-
- def visible_line
- @texts.size
- end
-
- def text(line)
- @texts[line]
- end
-
- def setText(line , text)
- @texts[line]=text
- end
-
- def clear
- for i in [email protected]
- @texts.delete_at(i)
- end
- end
-
- end
- #==============================================================================
- # ■ Game_Mission
- #------------------------------------------------------------------------------
- # 任务信息显示。
- #==============================================================================
- class Game_Mission
-
- def initialize
- @texts = Array.new
- @texts[0] = ""
- @titletext = ""
- @imtext = ""
- @NPC1 = ""
- @NPC2 = ""
- @bool_mission = false
- end
-
- def setText(line, text)
- @texts[line]=text
- end
-
- def setTitle(text)
- @tetlitext=text
- end
-
- def setImText(text)
- @imtext=text
- end
-
- def setNPC(t1, t2)
- @NPC1=t1
- @NPC2=t2
- end
- def setStatus(b)
- @bool_mission=b
- end
- def getText(line)
- @texts[line]
- end
-
- def visible_line
- @texts.size
- end
- def getTitle
- @tetlitext
- end
-
- def getImText
- @imtext
- end
-
- def getNPC1
- @NPC1
- end
-
- def getNPC2
- @NPC2
- end
- def getStatus
- @bool_mission
- end
-
-
- def clear
- for i in [email protected]
- @texts.delete_at(i)
- end
-
- @titletext = ""
- @imtext = ""
- @NPC1 = ""
- @NPC2 = ""
- @bool_mission = false
- end
-
- end
- #==============================================================================
- # ■ Game_Missions
- #------------------------------------------------------------------------------
- # 任务信息包装。
- #==============================================================================
- class Game_Missions
-
- def initialize
- @mission_array=Array.new
- for i in 0...100
- @mission_array[i]=Game_Mission.new
- end
- end
-
- def mission(t)
- return @mission_array[t]
- end
-
- def getNoMission
- for i in 0...100
- if @mission_array[i].getStatus==false
- return i
- end
- end
-
- end
-
- def clear
- for i in 0...100
- @mission_array[i].clear
- end
- end
-
- def serMission(titletext)
- for i in 0...100
- if @mission_array[i].getTitle==titletext && @mission_array[i].getStatus==true then
- return i
- end
- end
- return -1
-
- end
-
- def getMissionNum
- @r=0
- for i in 99..0
- if @mission_array[i].getStatus==true
- @r=@r+1
- end
- end
- return @r
- end
- end
- #==============================================================================
- # ■ Window_MapHint
- #------------------------------------------------------------------------------
- # 显示地图信息。 By SkyZH
- #==============================================================================
- class Window_MapHint < Window_Base
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize(x, y)
- super(x, y, window_width, Graphics.height)
- self.openness = 0
- open
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 获取窗口的宽度
- #--------------------------------------------------------------------------
- def window_width
- return Graphics.width - 256
- end
-
- def draw_title
- self.contents.font.color=system_color
- self.contents.font.size=48
- if $game_map.display_name.empty?
- draw_text(4, 0, window_width-40, self.contents.font.size,"提示",1)
- else
- draw_text(4, 0, window_width-40, self.contents.font.size,"提示 - " + $game_map.display_name,1)
- end
-
- self.contents.font.color=normal_color
- self.contents.font.size=Font.default_size
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- draw_title
- for i in 0...$game_maphint.visible_line
- @tempn=$game_maphint.text(i)
- draw_text(4, line_height*(i)+48, window_width-40, self.contents.font.size ,@tempn,1)
- end
- end
- end
- #==============================================================================
- # ■ Window_MissionShow
- #------------------------------------------------------------------------------
- # 显示任务信息。 By SkyZH
- #==============================================================================
- class Window_MissionShow < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize(x, y)
- super(x, y, window_width, Graphics.height)
- self.openness = 0
- open
- end
-
- def setNumber(numbers)
- @Mnumber=numbers
- refresh
- end
-
- #--------------------------------------------------------------------------
- # ● 获取窗口的宽度
- #--------------------------------------------------------------------------
- def window_width
- return Graphics.width
- end
-
- def draw_title(text, line, size ,dwhere ,color)
- self.contents.font.color=color
- self.contents.font.size=size
-
- draw_text(4, line*line_height , window_width-40, size, text ,dwhere)
- self.contents.font.color=normal_color
- self.contents.font.size=Font.default_size
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- @texts= $game_missions.mission(@Mnumber).getTitle
- @vl= $game_missions.mission(@Mnumber).visible_line
- draw_title(@texts,0,48,1,Color.new(255,100,100))
- draw_title("任务介绍",2,22,0,Color.new(100,255,255))
- for i in 0...@vl
- draw_title($game_missions.mission(@Mnumber).getText(i),3+i,18,0,Color.new(255,255,255))
- end
- draw_title("任务奖励/重要信息",4 + @vl,22,0,Color.new(100,255,255))
- draw_title($game_missions.mission(@Mnumber).getImText,5 + @vl,18,0,Color.new(255,255,255))
- draw_title("领取任务NPC",7 + @vl,22,0,Color.new(100,255,255))
- draw_title($game_missions.mission(@Mnumber).getNPC1,8 + @vl,18,0,Color.new(255,255,255))
- draw_title("交接任务NPC",10 + @vl,22,0,Color.new(100,255,255))
- draw_title($game_missions.mission(@Mnumber).getNPC2,11 + @vl,18,0,Color.new(255,255,255))
-
- end
-
- end
- #==============================================================================
- # ■ Window_MenuCommand
- #------------------------------------------------------------------------------
- # 任务画面中显示指令的窗口 By SkyZH
- #==============================================================================
- class Window_MissionCommand < Window_Command
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0)
- end
- #--------------------------------------------------------------------------
- # ● 获取窗口的宽度
- #--------------------------------------------------------------------------
- def window_width
- return 256
- end
- #--------------------------------------------------------------------------
- # ● 获取显示行数
- #--------------------------------------------------------------------------
- def visible_line_number
- (Graphics.height-standard_padding*2)/line_height
- end
- #--------------------------------------------------------------------------
- # ● 生成指令列表
- #--------------------------------------------------------------------------
- def make_command_list
- add_original_commands
- add_return_command
- end
- #--------------------------------------------------------------------------
- # ● 独自添加指令用
- #--------------------------------------------------------------------------
- def add_original_commands
- for i in 0...100
- @r=i+1
- @t="mission" + i.to_s
- if $game_missions.mission(i).getStatus==true
- add_command($game_missions.mission(i).getTitle, @t.to_sym)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 结束指令用
- #--------------------------------------------------------------------------
- def add_return_command
- add_command("返回", :returnsc)
- end
- #--------------------------------------------------------------------------
- # ● 按下确定键时的处理
- #--------------------------------------------------------------------------
- def process_ok
- super
- end
-
- def call_handler(symbol)
- @handler[symbol].call(symbol.id2name[7,symbol.id2name.size-7].to_i) if handle?(symbol)
- end
- end
- #encoding:utf-8
- #==============================================================================
- # ■ Scene_Mission
- #------------------------------------------------------------------------------
- # 任务
- #==============================================================================
- class Scene_Mission < Scene_MenuBase
- #--------------------------------------------------------------------------
- # ● 开始处理
- #--------------------------------------------------------------------------
- def start
- super
- create_command_window
- end
- #--------------------------------------------------------------------------
- # ● 生成指令窗口
- #--------------------------------------------------------------------------
- def create_command_window
- @maphint_window= Window_MapHint.new(256,0)
- @command_window = Window_MissionCommand.new
- @window_missionShow=Window_MissionShow.new(0,0)
- @window_missionShow.hide
- @command_window.set_handler(:returnsc, method(:scenereturns))
- @command_window.set_handler(:cancel, method(:scenereturns))
- @window_missionShow.set_handler(:cancel, method(:missionHide))
- @window_missionShow.set_handler(:ok, method(:missionHide))
- for i in 0...100
- @r=i
- @t="mission" + i.to_s
- @command_window.set_handler(@t.to_sym, method(:missionShow))
- end
-
- end
-
- def scenereturns( t)
- SceneManager.return
- end
- def missionShow( t)
- @window_missionShow.setNumber(t)
- @command_window.deactivate
- @window_missionShow.activate
- @window_missionShow.openness=0
- @window_missionShow.show
- @window_missionShow.open
- end
-
- def missionHide
- @command_window.activate
- @window_missionShow.deactivate
- @window_missionShow.close
- update until @window_missionShow.close?
- @window_missionShow.hide
- end
- end
- #==============================================================================
- # ■ DataManager
- #------------------------------------------------------------------------------
- # 数据库和游戏实例的管理器。所有在游戏中使用的全局变量都在这里初始化。
- #==============================================================================
- module DataManager
- #--------------------------------------------------------------------------
- # ● 生成各种游戏对象
- #--------------------------------------------------------------------------
- def self.create_game_objects
- $game_temp = Game_Temp.new
- $game_system = Game_System.new
- $game_timer = Game_Timer.new
- $game_message = Game_Message.new
- $game_switches = Game_Switches.new
- $game_variables = Game_Variables.new
- $game_self_switches = Game_SelfSwitches.new
- $game_actors = Game_Actors.new
- $game_party = Game_Party.new
- $game_troop = Game_Troop.new
- $game_map = Game_Map.new
- $game_player = Game_Player.new
- $game_maphint = Game_MapHint.new
- $game_missions = Game_Missions.new
- end
- #--------------------------------------------------------------------------
- # ● 生成存档内容
- #--------------------------------------------------------------------------
- def self.make_save_contents
- contents = {}
- contents[:system] = $game_system
- contents[:timer] = $game_timer
- contents[:message] = $game_message
- contents[:switches] = $game_switches
- contents[:variables] = $game_variables
- contents[:self_switches] = $game_self_switches
- contents[:actors] = $game_actors
- contents[:party] = $game_party
- contents[:troop] = $game_troop
- contents[:map] = $game_map
- contents[:player] = $game_player
- contents[:maphint] = $game_maphint
- contents[:missions] = $game_missions
- contents
- end
- #--------------------------------------------------------------------------
- # ● 展开存档内容
- #--------------------------------------------------------------------------
- def self.extract_save_contents(contents)
- $game_system = contents[:system]
- $game_timer = contents[:timer]
- $game_message = contents[:message]
- $game_switches = contents[:switches]
- $game_variables = contents[:variables]
- $game_self_switches = contents[:self_switches]
- $game_actors = contents[:actors]
- $game_party = contents[:party]
- $game_troop = contents[:troop]
- $game_map = contents[:map]
- $game_player = contents[:player]
- $game_maphint = contents[:maphint]
- $game_missions = contents[:missions]
- end
- end
- #==============================================================================
- # ■ Window_MenuCommand
- #------------------------------------------------------------------------------
- # 菜单画面中显示指令的窗口
- #==============================================================================
- class Window_MenuCommand < Window_Command
- #--------------------------------------------------------------------------
- # ● 独自添加指令用
- #--------------------------------------------------------------------------
- def add_original_commands
- add_command("地图提示", :maphint)
- end
- end
- #==============================================================================
- # ■ Scene_Menu
- #------------------------------------------------------------------------------
- # 菜单画面
- #==============================================================================
- class Scene_Menu < Scene_MenuBase
- #--------------------------------------------------------------------------
- # ● 生成指令窗口
- #--------------------------------------------------------------------------
- def create_command_window
- @command_window = Window_MenuCommand.new
- @command_window.set_handler(:item, method(:command_item))
- @command_window.set_handler(:skill, method(:command_personal))
- @command_window.set_handler(:equip, method(:command_personal))
- @command_window.set_handler(:status, method(:command_personal))
- @command_window.set_handler(:formation, method(:command_formation))
- @command_window.set_handler(:save, method(:command_save))
- @command_window.set_handler(:game_end, method(:command_game_end))
- @command_window.set_handler(:cancel, method(:return_scene))
-
- @command_window.set_handler(:maphint, method(:command_maphint))
- end
-
- #--------------------------------------------------------------------------
- # ● 指令“地图提示”
- #--------------------------------------------------------------------------
- def command_maphint
- SceneManager.call(Scene_Mission)
- end
-
- end
复制代码 |
|