Project1
标题:
脚本问题(2个问题)
[打印本页]
作者:
1587937102
时间:
2012-4-8 08:43
标题:
脚本问题(2个问题)
本帖最后由 iisnow 于 2012-4-8 10:22 编辑
1.
#==============================================================================
# ■ WndProc
#==============================================================================
module WndProc
Graphics.resize_screen(554, 416)
# Graphics.frame_rate = 120
#--------------------------------------------------------------------------
# ● 常量
#--------------------------------------------------------------------------
Enter = 0x0D
Alt = 0x12
F1 = 0x70
F2 = 0x71
F4 = 0x73
F12 = 0x7B
KeyCode = [
# Enter,
# Alt,
# F2,
# F1,
# F12
]
@@FindWindowEx = Win32API.new("user32","FindWindowEx","llpp","l")
@@ShowWindow = Win32API.new("user32", "ShowWindow", "li", "i")
@@FindWindow = Win32API.new("user32", "FindWindow", "pp", "l")
@@ReSetProc = Win32API.new("WndProc", "ReSetProc", "l", "l")
@@SetDLL = Win32API.new("WndProc", "SetDLL", "p", "v")
@@OldProc = Win32API.new("WndProc", "OldProc", "llll", "l")
@@UseRMWndProc = Win32API.new("WndProc", "UseRMWndProc", "", "v")
@@GetPriProStr = Win32API.new("kernel32", "GetPrivateProfileString", "pppplp", "l")
@@SendMessage = Win32API.new("user32", "SendMessage", "llll", "l")
@@Start = Win32API.new("RGSSEx1", "Start", 'V', 'L')
@@Stop = Win32API.new("RGSSEx1", "Stop", 'V', 'L')
@@OnFocus = Win32API.new("RGSSEx1", "OnFocus", 'V', 'L')
WM_PAINT = 0x000f
WM_HELP = 0x0053
WM_CLOSE = 0x0010
WM_CHAR = 0x0102
WM_ACTIVATEAPP = 0x001C
WM_WINDOWPOSCHANGED = 0x0047
WM_SETCURSOR = 0x0020
WM_COMMAND = 0x0111
WM_SYSCOMMAND = 0x0112
# 是否初始化过
@@inid ||= false
# 函数
module_function
#--------------------------------------------------------------------------
# ● 初始化
#--------------------------------------------------------------------------
def init
return if @@inid # 防止重复
@@inid = true
self.re_set_proc # 重置窗口过程
@@reg_back_proc = {} # 注册的消息响应
end
#-------------------------------------------------------------------------
# ● 注册消息响应
#--------------------------------------------------------------------------
def reg_back_msg(message, proc)
@@reg_back_proc[message] ||= []
@@reg_back_proc[message] << proc
end
#--------------------------------------------------------------------------
# ● 注销消息响应
#--------------------------------------------------------------------------
def unreg_back_msg(message, proc)
@@reg_back_proc[message] ||= []
@@reg_back_proc[message].delete(proc)
end
#--------------------------------------------------------------------------
# ● 窗口句柄
#--------------------------------------------------------------------------
def launcher_hwnd
hwnd = @@FindWindowEx.call(0, 0, nil, "6R_City_Launcher".u2s)
return hwnd
end
#--------------------------------------------------------------------------
# ● 窗口句柄
#--------------------------------------------------------------------------
def hwnd
buffer = "\000"*256
@@GetPriProStr.call("Game", "Title", "", buffer, 256, "./Game.ini")
buffer.delete!("\000")
hwnd = @@FindWindow.call("RGSS Player", buffer)
return hwnd
end
#--------------------------------------------------------------------------
# ● 设置连接库
#--------------------------------------------------------------------------
def set_dll
libname = "\000" * 256
@@GetPriProStr.call("Game", "Library", "", buffer, 256, "./Game.ini")
libname.delete!("\000")
@@SetDLL.call(libname)
end
#--------------------------------------------------------------------------
# ● 重置
#--------------------------------------------------------------------------
def re_set_proc
@@ReSetProc.call(self.hwnd)
end
#--------------------------------------------------------------------------
# ● 新的回调函数
#--------------------------------------------------------------------------
def proc(hwnd, message, wParam, lParam)
# 处理消息
case message
when WM_CLOSE
use_rm_proc
when WM_CHAR
use_rm_proc
when WM_ACTIVATEAPP
use_rm_proc
when WM_WINDOWPOSCHANGED
use_rm_proc
when WM_COMMAND
use_rm_proc
when WM_SYSCOMMAND
use_rm_proc
when WM_PAINT
#ShowCursor.call(0)
when WM_HELP
#ShowCursor.call(1)
end
unless @@reg_back_proc[message].nil?
@@reg_back_proc[message].each do |back_proc|
back_proc.call(hwnd, message, wParam, lParam)
end
end
end
#--------------------------------------------------------------------------
# ● 本消息调用RM的过程
#--------------------------------------------------------------------------
def use_rm_proc
@@UseRMWndProc.call()
end
#--------------------------------------------------------------------------
# ● 关闭启动程序
#--------------------------------------------------------------------------
def close_launcher
exit if self.launcher_hwnd == 0
@@SendMessage.call(self.launcher_hwnd, WM_CLOSE, 0, 0)
end
#--------------------------------------------------------------------------
# ● 显示游戏窗口
#--------------------------------------------------------------------------
def show_window
@@ShowWindow.call(self.hwnd, 5)
end
#--------------------------------------------------------------------------
# ● 开始后台运行
#--------------------------------------------------------------------------
def start_bg
@@Start.call
end
#--------------------------------------------------------------------------
# ● 停止后台运行
#--------------------------------------------------------------------------
def stop_bg
@@Stop.call
end
#--------------------------------------------------------------------------
# ● 设置焦点
#--------------------------------------------------------------------------
def bg_on_focus
@@OnFocus.call
end
end
begin
WndProc.close_launcher
WndProc.show_window
WndProc.start_bg
#~ # WndProc.init
rescue
p $!
end
module Input
InputUpdate = method :update
InputTrigger = method :trigger?
InputPress = method :press?
InputRepeat = method :repeat?
InputDir4 = method :dir4
InputDir8 = method :dir8
def self.update
InputUpdate.call if WndProc.bg_on_focus != 0
end
def self.trigger?(num)
return WndProc.bg_on_focus != 0 ? InputTrigger.call(num) : false
end
def self.press?(num)
return WndProc.bg_on_focus != 0 ? InputPress.call(num) : false
end
def self.repeat?(num)
return WndProc.bg_on_focus != 0 ? InputRepeat.call(num) : false
end
def self.dir4
return WndProc.bg_on_focus != 0 ? InputDir4.call : 0
end
def self.dir8
return WndProc.bg_on_focus != 0 ? InputDir8.call : 0
end
end
#==============================================================================
# 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
#==============================================================================
复制代码
怎样后台运行?
2.
=begin
--------------------------------------------------------------------------
详尽任务显示界面 v2.1
--------------------------------------------------------------------------
By 叶子
日期与更新
3-29-2006 -v1.0
4-3-2006 -v2.0
-可以改变文字颜色,显示变量,显示图标,显示图片
-大幅简化了编写任务内容的过程,加入自动换行功能
-精简了窗口,使其还可以用作图鉴系统、日记系统等等
4-6-2006 -v2.1
-增加了获得全部任务与删除全部任务命令
-改正通假字,修改了示例任务3
--------------------------------------------------------------------------
改版 by snstar2006
修改部分:
- 将XP的一些脚本改成VX版的
- 将窗口大小缩放成VX的大小(依照比例)
- 将一些会变成很长的脚本精简
(如:用$game_pary.item_no(物品编号)
代替原来的$game_party.item_number($data_items[物品编号]) = ="好长)
- 精简一些代码,将 Window_Task_Name 和Window_Task 重合部分用继承方式精简
- 依照VX的 RGSS2 规范编写 Scene_Task
- 增加使用16进位颜色代码变换字体颜色功能
- 修改Scene_Menu的召唤方式,使脚本新手使用起来更容易
--------------------------------------------------------------------------
顾名思义,就是显示任务数据的界面
任务数据要预先在这里设定好
下载范例工程,能帮助你更快更好地掌握使用方法
--------------------------------------------------------------------------
使用方法:
1、召唤任务显示界面:$scene = Scene_Task.new
可以在事件中的「脚本」指令加入这段东西,
又或者修改 Scene_Menu 来增加一个显示任务的选项。
如果是修改 Scene_Menu 增加選項的話,请使用
$scene = Scene_Task.new(任务在菜单的index)
例如:$scene = Scene_Task.new(7)
2、设置任务数据
2.1、相关内容解析
所有内容文字必须用双引号括住
名称:任务的名字(显示在左边窗口中),大小为172×32,如果全部为文字的话,
够放九个全角字符
简介:任务的介绍(显示在右边窗口中),宽308,高不限
文字可以自动换行
2.1.1、控制码解析
名称和内容均可用控制码,注意两条反斜杠都要打!
\\v[n] 显示n号变量
\\c[n] 改变字体颜色。n 为窗口外观图片中所设定的颜色,可为0-31
\\c[HRRGGBB]设定字体颜色为RRGGBB色, RRGGBB 为16进位颜色代码
\\n[i] 显示i号角色名字
\\i[图标编号] 显示图标 # 图标编号为图标在IconSet里的顺序
\\p[文件名] 显示图片
2.1.2、高级:内嵌表达式
请参考帮助-脚本入门-字符串-内嵌表达式相关内容。
它可以用来在任务的名称和简介那里显示变量。
常用的表达式(注意不要漏了井号和大括号):
#{$game_variables[n]} ——插入n号变量的值
#{$game_party.item_no(n)} —— 插入持有n号物品数量
同理还有 weapon_no,armor_no
还可以预先定义一个变量,再插入(例子见示例任务3-灵魂线)
2.2、注意事项
2.2.1、括号、逗号和双引号 [ ] , " 必须使用半角符号(英文输入),
引号内的内容则没有关系
2.2.2、单引号 ' 和双引号 " 的区别:
为了不出错误,全部用双引号吧!当然如果你对Ruby很熟悉,那就没所谓了
2.3、开始设置吧!
从107行开始设置任务数据,可以参考示例任务来设置,请仔细阅读附加讲解
3、接受任务
事件里的「脚本」指令输入:get_task(任务ID)
例如 get_task(1) 就是接受1号任务
3.1、获得全部任务
事件里的「脚本」指令输入:get_all_task
这个功能基本上是用来在编写好所有任务数据后测试排版的
4、完成/删除任务
事件里的「脚本」指令输入:finish_task(任务ID)
例如 finish_task(1) 就是完成1号任务
注意:本脚本不负责完成任务后的奖励之类的东西,请自行在事件中判断,
这里的完成任务指的是从任务列表中删去此任务
4.1、删除全部任务
事件里的「脚本」指令输入:finish_all_task
作为获得全部任务的对应功能存在,似乎不会怎么用到
=end
class Scene_Task
# 这里设置任务内容翻页音效
CHANGE_PAGE_SE = "Audio/SE/046-Book01"
end
class Game_Party
#--------------------------------------------------------------------------
# ● 设置任务资料
#--------------------------------------------------------------------------
def get_tasks_info
@tasks_info = []
名称 = "\\c[6]逃"
简介 = "\\c[6]快跑
任务目标:
\\c[9]别管那么多了,快逃吧!'
end
end
#==============================================================================
# ■ Interpreter
#------------------------------------------------------------------------------
# 执行事件命令的解释器。本类在 Game_System 类
# 与 Game_Event 类的内部使用。
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ● 接受任务
#--------------------------------------------------------------------------
def get_task(id)
task = $game_party.tasks_info[id]
return true if (task.nil? or $game_party.current_tasks.include?(task.id))
$game_party.current_tasks.unshift(task.id)
return true
end
#--------------------------------------------------------------------------
# ● 获得全部任务
#--------------------------------------------------------------------------
def get_all_task
# 清空当前任务
$game_party.current_tasks.clear
for task in $game_party.tasks_info
next if task.nil?
$game_party.current_tasks.unshift(task.id)
end
return true
end
#--------------------------------------------------------------------------
# ● 完成/放弃任务
#--------------------------------------------------------------------------
def finish_task(id)
task = $game_party.tasks_info[id]
return true if task.nil?
$game_party.current_tasks.delete(task.id)
return true
end
#--------------------------------------------------------------------------
# ● 删除全部任务
#--------------------------------------------------------------------------
def finish_all_task
$game_party.current_tasks.clear
return true
end
end
#==============================================================================
# ■ Game_Party
#------------------------------------------------------------------------------
# 处理同伴的类。包含金钱以及物品的信息。本类的实例
# 请参考 $game_party。
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_writer :latest_task # 上次查看的任务
#--------------------------------------------------------------------------
# ● 取得任务资料
#--------------------------------------------------------------------------
def tasks_info
if @tasks_info.nil?
get_tasks_info
end
return @tasks_info
end
#--------------------------------------------------------------------------
# ● 取得当前任务
#--------------------------------------------------------------------------
def current_tasks
if @current_tasks.nil?
@current_tasks = []
end
return @current_tasks
end
#--------------------------------------------------------------------------
# ● 上次查看的任务
#--------------------------------------------------------------------------
def latest_task
if !current_tasks.include?(@latest_task)
@latest_task = current_tasks[0]
end
return @latest_task
end
end
#==============================================================================
# ■ Game_Task
#------------------------------------------------------------------------------
# 处理任务的类。包含任务的信息。
#==============================================================================
class Game_Task
attr_accessor :name # 名称
attr_accessor :briefing # 简介
def initialize(name, briefing)
@name = name
@briefing = briefing
end
def height
text = @briefing.clone
x = 0
y = 64
min_y = 0
# 限制文字处理
begin
last_text = text.clone
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until text == last_text
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
# 为了方便、将 "\\\\" 变换为 "\000"
text.gsub!(/\\\\/) { "\000" }
# "\C" 变为 "\001"
text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
# "\I" 变为 "\002"
text.gsub!(/\\[Ii]/) { "\002" }
# "\P" 变为 "\003"
text.gsub!(/\\[Pp]/) { "\003" }
# c 获取 1 个字 (如果不能取得文字就循环)
while ((c = text.slice!(/./m)) != nil)
# \\ 的情况下
if c == "\000"
# 还原为本来的文字
c = "\\"
end
# \C[n] 的情况下
if c == "\001"
# 更改文字色
text.sub!(/\[([0-9a-zA-Z]+)\]/, "")
# 下面的文字
next
end
# 图标的情况下
if c == "\002"
icon_name = ''
while ((cha = text.slice!(/./m)) != ']')
next if cha == '['
icon_name += cha
end
if x + 24 > 368
x = 0
y += [24, min_y].max
min_y = 0
end
x += 28
next
end
# 图片的情况下
if c == "\003"
pic_name = ''
while ((cha = text.slice!(/./m)) != ']')
next if cha == '['
pic_name += cha
end
pic = Cache.picture(pic_name)
if x + pic.width > 368
x = 0
y += [24, min_y].max
min_y = 0
end
x += pic.width
min_y = [pic.height, 24].max
next
end
# 另起一行文字的情况下
if c == "\n"
y += [24, min_y].max
min_y = 0
x = 0
# 下面的文字
next
end
# 自动换行处理
if x + 22 > 368
y += [24, min_y].max
min_y = 0
x = 0
end
# x 为要描绘文字的加法运算
x += 22
end
return (y + [24, min_y].max)
end
def id
return $game_party.tasks_info.index(self)
end
end
#==============================================================================
# ■ Window_Task_Name
#------------------------------------------------------------------------------
# 任务名称显示窗口。
#==============================================================================
class Window_Task_Name < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize(tasks)
super(0, 0, 204, 416)
@tasks = []
for id in tasks
@tasks.push($game_party.tasks_info[id])
end
@item_max = tasks.size
self.contents = Bitmap.new(
self.width - 32, @item_max == 0 ? 32 : @item_max * 32)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
if @tasks != []
for task in @tasks
draw_item(task)
end
else
draw_blank
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
#--------------------------------------------------------------------------
def draw_item(task)
text = task.name.clone
y = @tasks.index(task) * WLH
chenge_special_character(text, 0, y)
end
#--------------------------------------------------------------------------
# ● 描绘空行
#--------------------------------------------------------------------------
def draw_blank
self.contents.font.color = Color.new(255, 255, 255, 128)
rect = Rect.new(4, 0, self.contents.width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, '当前没有任何任务')
end
#--------------------------------------------------------------------------
# ● 获取任务
#--------------------------------------------------------------------------
def task
return @tasks[self.index]
end
end
#==============================================================================
# ■ Window_Task
#------------------------------------------------------------------------------
# 任务内容显示窗口。
#==============================================================================
class Window_Task < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize(task_id)
super(204, 0, 340, 416)
refresh(task_id)
end
#--------------------------------------------------------------------------
# ● 刷新内容
#--------------------------------------------------------------------------
def refresh(task_id)
self.oy = 0
self.visible = true
return if task_id.nil?
task = $game_party.tasks_info[task_id]
if !task.nil?
self.contents = Bitmap.new(self.width - 32, task.height)
else
self.contents = Bitmap.new(self.width - 32, self.height - 32)
return
end
self.contents.font.color = normal_color
# 描绘任务内容
draw_task_info(task)
end
#--------------------------------------------------------------------------
# ● 描绘任务内容
#--------------------------------------------------------------------------
def draw_task_info(task)
self.contents.font.color = normal_color
# 描绘任务简介
chenge_special_character(task.briefing.clone)
end
end
class Window_Base < Window
def chenge_special_character(text, x=0, y=0)
# 记录换行时y坐标最小加值
min_y = 0
# 限制文字处理
begin
last_text = text.clone
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until text == last_text
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
# 为了方便、将 "\\\\" 变换为 "\000"
text.gsub!(/\\\\/) { "\000" }
# "\C" 变为 "\001"
text.gsub!(/\\[Cc]\[([0-9a-zA-Z]+)\]/) { "\001[#{$1}]" }
# "\I" 变为 "\002"
text.gsub!(/\\[Ii]/) { "\002" }
# "\P" 变为 "\003"
text.gsub!(/\\[Pp]/) { "\003" }
# c 获取 1 个字 (如果不能取得文字就循环)
while ((c = text.slice!(/./m)) != nil)
# \\ 的情况下
if c == "\000"
# 还原为本来的文字
c = "\\"
end
# \C[n] 的情況下
if c == "\001"
# 更改文字色
text.sub!(/\[([0-9a-zA-Z]+)\]/, "")
# 如果是设定RGB颜色
if $1[0,1]=="H"
# 先拷贝一下文字
c=$1.dup
# 分3段分别取出R,G,B颜色
c.sub!(/H([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})/, "")
# 设定文字颜色
self.contents.font.color = Color.new($1.to_i(16), $2.to_i(16), $3.to_i(16))
else
color = $1.to_i
if color >= 0 and color <= 31
self.contents.font.color = text_color(color)
elsif color == 32
self.contents.font.color = disabled_color
elsif color == 33
self.contents.font.color = system_color
end
end
# 下面的文字
next
end
# 图标的情况下
if c == "\002"
icon_name = ''
while ((cha = text.slice!(/./m)) != ']')
next if cha == '['
icon_name += cha
end
if x + 24 > self.contents.width
x = 0
y += [WLH, min_y].max
min_y = 0
end
draw_icon(icon_name.to_i, x+4, y+4, true)
x += 28
next
end
# 图片的情况下
if c == "\003"
pic_name = ''
while ((cha = text.slice!(/./m)) != ']')
next if cha == '['
pic_name += cha
end
pic = Cache.picture(pic_name)
if x + pic.width > self.contents.width
x = 0
y += [WLH, min_y].max
min_y = 0
end
self.contents.blt(x + 4, y, pic, Rect.new(0, 0, pic.width, pic.height))
x += pic.width
min_y = [pic.height, WLH].max
next
end
# 另起一行文字的情况下
if c == "\n"
y += [WLH, min_y].max
min_y = 0
x = 0
# 下面的文字
next
end
# 自动换行处理
if x + self.contents.text_size(c).width > self.contents.width
y += [WLH, min_y].max
min_y = 0
x = 0
end
# 描绘文字
self.contents.draw_text(4 + x, y, 40, WLH, c)
# x 为要描绘文字的加法运算
x += self.contents.text_size(c).width
end
end
end
class Game_Party < Game_Unit
def item_no(n)
return item_number($data_items[n])
end
def weapon_no(n)
return item_number($data_weapons[n])
end
def armor_no(n)
return item_number($data_armors[n])
end
end
#==============================================================================
# ■ Scene_Task
#------------------------------------------------------------------------------
# 处理任务画面的类。
#==============================================================================
class Scene_Task < Scene_Base
def initialize(index=nil)
@menu_index = index
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def start
# 刷新任务资料
$game_party.get_tasks_info
# 生成任务名称窗口
@task_names_window = Window_Task_Name.new($game_party.current_tasks)
@task_names_window.active = true
if $game_party.current_tasks != []
@task_names_window.index = $game_party.current_tasks.index($game_party.latest_task)
end
# 生成任务内容窗口
@task_info_window = Window_Task.new($game_party.latest_task)
@task_info_window.active = true
end
def terminate
# 释放窗口
@task_names_window.dispose
@task_info_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@task_names_window.update
@task_info_window.update
update_task_names_window
end
#--------------------------------------------------------------------------
# ● 刷新任务名称窗口
#--------------------------------------------------------------------------
def update_task_names_window
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
Sound.play_cancel
# 这里设置返回的场景,返回地图是Scene_Map.new,菜单是Scene_Menu.new(任务界面index)
if @menu_index == nil
$scene = Scene_Menu.new
else
$scene = Scene_Menu.new(@menu_index)
end
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 无任务可显示的话
if @task_names_window.task == nil
# 演奏冻结 SE
Sound.play_buzzer
return
end
# 如果光标没有移动的话,翻页
if $game_party.latest_task == @task_names_window.task.id
if @task_info_window.oy + @task_info_window.height - 32 > @task_info_window.contents.height
@task_info_window.oy = 0
else
@task_info_window.oy += 480-32
end
if @task_info_window.contents.height > @task_info_window.height - 32
# 演奏翻页 SE
Sound.se_play(CHANGE_PAGE_SE)
end
else
@task_info_window.refresh(@task_names_window.task.id)
$game_party.latest_task = @task_names_window.task.id
# 演奏确定 SE
Sound.play_decision
end
end
end
end
#==============================================================================
# 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
#==============================================================================
# def get_tasks_info
# @tasks_info = []
#-讲解-
# 三个示例任务由浅入深,其实只要看懂第一个就可以使用了。
# 任务的写法多种多样,不限于这三个任务的方法
#----
#-----------------------------
# 示例任务1:沙漠中的五叶花
#-----------------------------
# 名称 = "\\c[6]帮忙拿5瓶药水"
#-讲解-
# 注意!脚本编辑器的变色功能并不是非常完善,所以换行后字变黑了,但仍然是字符
# 串的一部分,所以不要忘记在内容最后打一个双引号
# 按回车是强制换行
#----
# 简介 = "\\c[6]帮忙拿5瓶药水
#\\c[9]任务目标:
#获得5瓶药水,交给任务测试人员
#\\c[0]药水数目:\\v[1]/5
#任务测试人员:
#\\c[Hff0000]快点!我等着你的好消息"
#-讲解-
# 每个任务最后一定要加上:
# @tasks_info[任务ID] = Game_Task.new(名称, 简介)
# 接受任务和完成任务都是用这个任务ID来索引
#----
# @tasks_info[1] = Game_Task.new(名称, 简介)
#-----------------------------
# 示例任务2:克萝莉亚的药瓶
#-----------------------------
# 名称 = "\\c[6]克萝莉亚的药瓶"
#-讲解-
# 这里使用了字符串相加,例如 s = "a" + "b" ,s 就是 "ab"
# 还用了内嵌表达式,$game_party.item_number(38) 就是38号物品的数量
#----
# 简介 = 名称 + "
#\\c[9]任务目标:
#问克萝莉亚要一个药瓶,交给西露达
#\\c[0]药瓶:#{$game_party.item_no(1)}/1
#西露达:
#克萝莉亚就在西边的屋子里"
# @tasks_info[2] = Game_Task.new(名称, 简介)
#-----------------------------
# 示例任务3:灵魂线
#-----------------------------
#-讲解-
# 这里用了条件判断,当3号变量大于等于1时,加上“完成”字样,同时变色
#----
# if $game_variables[3] >= 1
# 名称 = "\\c[8]灵魂线(完成)"
# item = "\\c[8]灵魂线:#{$game_variables[3]}/1 (完成)"
# else
# 名称 = "\\c[2]灵魂线"
# item = "\\c[0]灵魂线:#{$game_variables[3]}/1"
# end
#-讲解-
# 预先定义变量,用内嵌表达式插入
# 最后用了显示图标
#----
# 简介 = "#{名称}
#\\c[9]任务目标:
#找到埋起来的灵魂线,交给克萝莉亚
#{item}
#\\c[0]克萝莉亚:
#灵魂线就埋在其中一棵树下,给我好好找\\i[157]"
# @tasks_info[3] = Game_Task.new(名称, 简介)
# end
#end
#==============================================================================
# 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
#==============================================================================
module RPG
class Weapon
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def desc
desc = @description.split(/@/)[1]
return desc != nil ? desc : "普通物品"
end
end
class Item
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def desc
desc = @description.split(/@/)[1]
return desc != nil ? desc : "普通物品"
end
end
class Armor
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def desc
desc = @description.split(/@/)[1]
return desc != nil ? desc : "普通物品"
end
end
end
class Harts_Window_ItemTitle < Window_Base
def initialize
super(0, 0, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120, 32, Vocab::item, 1)
end
end
class Harts_Window_ItemCommand < Window_Selectable
attr_accessor :commands
def initialize
super(0, 64, 160, 296)
self.index = 0
refresh
end
def addcommand
@commands = []
for i in 1...$data_items.size
if $game_party.item_number($data_items[i]) > 0
push = true
for com in @commands
if com == $data_items[i].desc
push = false
end
end
if push == true
@commands.push($data_items[i].desc)
end
end
end
for i in 1...$data_weapons.size
if $game_party.item_number($data_weapons[i]) > 0
push = true
for com in @commands
if com == $data_weapons[i].desc
push = false
end
end
if push == true
@commands.push($data_weapons[i].desc)
end
end
end
for i in 1...$data_armors.size
if $game_party.item_number($data_armors[i]) > 0
push = true
for com in @commands
if com == $data_armors[i].desc
push = false
end
end
if push == true
@commands.push($data_armors[i].desc)
end
end
end
if @commands == []
@commands.push("其他物品")
end
@item_max = @commands.size
end
def refresh
addcommand
create_contents
for i in 0...@item_max
draw_item(i, normal_color)
end
end
def draw_item(index, color)
y = index * WLH
self.contents.font.color = color
if @commands[index] != nil
self.contents.draw_text(4,y, 172, WLH, @commands[index])
end
end
def update_help
@help_window.set_text(@commands[self.index])
end
end
class Harts_Window_ItemList < Window_Selectable
def initialize
super(160, 0, 384, 360)
self.index = 0
refresh
end
def item
return @data[self.index]
end
def refresh
@data = []
end
def set_item(command)
refresh
for i in 1...$data_items.size
if $game_party.item_number($data_items[i]) > 0 and $data_items[i].desc == command
@data.push($data_items[i])
end
end
for i in 1...$data_weapons.size
if $game_party.item_number($data_weapons[i]) > 0 and $data_weapons[i].desc == command
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.item_number($data_armors[i]) > 0 and $data_armors[i].desc == command
@data.push($data_armors[i])
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
end
def item_number
return @item_max
end
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data[index]
if item != nil
number = $game_party.item_number(item)
enabled = $game_party.item_can_use?(item)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enabled)
self.contents.draw_text(rect, sprintf(":%2d", number), 2)
end
end
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
class Harts_Window_Help < Window_Base
def initialize
super(0, 360, 544, WLH + 32)
end
def set_text(text, align = 0)
if text != @text or align != @align
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.width - 40, WLH , text, align)
@text = text
@align = align
end
end
end
class Harts_Window_MenuStatus < Window_Selectable
def initialize(x, y)
super(x, y, 288, 416)
refresh
self.active = false
self.index = -1
end
def refresh
self.contents.clear
@item_max = $game_party.members.size
for actor in $game_party.members
x = 8
y = actor.index * 96 + WLH / 2
draw_actor_name(actor, x, y)
draw_actor_class(actor, x + 120, y)
draw_actor_level(actor, x, y + WLH * 1)
draw_actor_state(actor, x, y + WLH * 2)
draw_actor_hp(actor, x + 120, y + WLH * 1)
draw_actor_mp(actor, x + 120, y + WLH * 2)
end
end
def update_cursor
if @index < 0
self.cursor_rect.empty
elsif @index < @item_max
self.cursor_rect.set(0, @index * 96, contents.width, 96)
elsif @index >= 100
self.cursor_rect.set(0, (@index - 100) * 96, contents.width, 96)
else
self.cursor_rect.set(0, 0, contents.width, @item_max * 96)
end
end
end
class Scene_Item < Scene_Base
def start
super
create_menu_background
@viewport = Viewport.new(0, 0, 544, 416)
@itemtitle_window = Harts_Window_ItemTitle.new
@itemcommand_window = Harts_Window_ItemCommand.new
@command_index = @itemcommand_window.index
@itemcommand_window.refresh
@itemlist_window = Harts_Window_ItemList.new
@itemlist_window.active = false
@help_window = Harts_Window_Help.new
@help_window.viewport = @viewport
@target_window = Harts_Window_MenuStatus.new(96, 0)
@itemcommand_window.help_window = @help_window
@itemlist_window.help_window = @help_window
@itemlist_window.set_item(@itemcommand_window.commands[@command_index])
hide_target_window
end
def terminate
super
dispose_menu_background
@viewport.dispose
@itemtitle_window.dispose
@itemcommand_window.dispose
@itemlist_window.dispose
@help_window.dispose
@target_window.dispose
end
def return_scene
$scene = Scene_Menu.new(0)
end
def update
super
update_menu_background
@help_window.update
@itemlist_window.update
@itemcommand_window.update
@target_window.update
@itemcommand_window.refresh
if @command_index != @itemcommand_window.index
@itemlist_window.index = 0
@command_index = @itemcommand_window.index
@itemcommand_window.update_help
@itemlist_window.set_item(@itemcommand_window.commands[@command_index])
end
if @itemcommand_window.active
@itemcommand_window.update_help
update_itemcommand
elsif @itemlist_window.active
update_itemlist
elsif @target_window.active
update_target_selection
end
end
def update_itemcommand
if Input.trigger?(Input::B)
Sound.play_cancel
return_scene
return
end
if Input.trigger?(Input::C)
if @itemlist_window.item_number == 0
Sound.play_buzzer
return
end
Sound.play_decision
@itemcommand_window.active = false
@itemlist_window.index = 0
@itemlist_window.active = true
return
end
end
def update_itemlist
if Input.trigger?(Input::B)
Sound.play_cancel
@itemcommand_window.active = true
@itemlist_window.active = false
@itemcommand_window.index = @command_index
elsif Input.trigger?(Input::C)
@item = @itemlist_window.item
if @item != nil
$game_party.last_item_id = @item.id
end
if $game_party.item_can_use?(@item)
Sound.play_decision
determine_item
else
Sound.play_buzzer
end
end
end
def determine_item
if @item.for_friend?
show_target_window(@itemlist_window.index % 2 == 0)
if @item.for_all?
@target_window.index = 99
else
if $game_party.last_target_index < @target_window.item_max
@target_window.index = $game_party.last_target_index
else
@target_window.index = 0
end
end
else
use_item_nontarget
end
end
def update_target_selection
if Input.trigger?(Input::B)
Sound.play_cancel
if $game_party.item_number(@item) == 0
@itemlist_window.refresh
end
@itemlist_window.active = true
@itemlist_window.set_item(@itemcommand_window.commands[@command_index])
hide_target_window
@itemlist_window.active = true
elsif Input.trigger?(Input::C)
if not $game_party.item_can_use?(@item)
Sound.play_buzzer
else
determine_target
end
end
end
def determine_target
used = false
if @item.for_all?
for target in $game_party.members
target.item_effect(target, @item)
used = true unless target.skipped
end
else
$game_party.last_target_index = @target_window.index
target = $game_party.members[@target_window.index]
target.item_effect(target, @item)
used = true unless target.skipped
end
if used
use_item_nontarget
else
Sound.play_buzzer
end
end
def show_target_window(right)
@itemlist_window.active = false
width_remain = 544 - @target_window.width
@target_window.x = right ? width_remain : 0
@target_window.visible = true
@target_window.active = true
if right
@viewport.rect.set(0, 0, width_remain, 416)
@viewport.ox = 0
else
@viewport.rect.set(@target_window.width, 0, width_remain, 416)
@viewport.ox = @target_window.width
end
end
def hide_target_window
@target_window.visible = false
@target_window.active = false
@itemlist_window.set_item(@itemcommand_window.commands[@command_index])
@viewport.rect.set(0, 0, 544, 416)
@viewport.ox = 0
end
def use_item_nontarget
Sound.play_use_item
$game_party.consume_item(@item)
@itemlist_window.draw_item(@itemlist_window.index)
@itemlist_window.set_item(@itemcommand_window.commands[@command_index])
@target_window.refresh
if $game_party.all_dead?
$scene = Scene_Gameover.new
elsif @item.common_event_id > 0
$game_temp.common_event_id = @item.common_event_id
$scene = Scene_Map.new
end
end
end
复制代码
怎样改成640,480屏幕适应? dsu_plus_rewardpost_czw
作者:
orzfly
时间:
2012-4-8 10:08
本帖最后由 orzfly 于 2012-4-8 13:22 编辑
@iisnow
看第一个脚本尾部 “如何后台运行”
一题多问 脚本来源估计是6r世界的那个水区活动
@八宝粥先生
喜羊羊大灰狼 what is that?
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1