赞 | 0 |
VIP | 6 |
好人卡 | 5 |
积分 | 1 |
经验 | 20519 |
最后登录 | 2018-6-4 |
在线时间 | 197 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 59
- 在线时间
- 197 小时
- 注册时间
- 2010-6-18
- 帖子
- 342
|
本帖最后由 xiaominging 于 2010-7-27 10:55 编辑
回复 jyx520520 的帖子
实际上不用连续提醒我三遍,我也可以努力工作的
先把我修改后的脚本放上来,具体用法在说明里有
#---------------------------------------------------------------------------
# 仿网游多任务系统v0.1 by秀秀
#---------------------------------------------------------------------------
=begin
作者:秀秀
版本:v1.0
注意:注明“←xiaoming”的部分都是我动过的
都由xiaominging负责,你也可以通过搜索
“←xiaoming”(好吧,这个是“小明”的拼音)的字样来查看我在哪里动了手脚。
对于未经秀秀许可而作的修改我表示抱歉,因为我没有找到原帖。
以下是近乎脚本渣的我画蛇添足的功能
#当变量$xiaoming为0时显示本来的四个选项
【查看任务】
【完成列表】
【接受任务】
【提交任务】
当变量$xiaoming为1时显示前面的两个选项
【查看任务】
【完成列表】
#也就是说如果想要两个选项的效果
#就在调用任务主窗体之前调用脚本$xiaoming = 1
#如果想要四个选项的效果
#就在调用任务窗体之前调用脚本$xiaoming = 0
[使用方法]
在脚本开始的地方的设置常量Missions
设置好之后 调用 $scene = SceneMission.new 即可
[Mission数据结构]
Mission 是一个用来存放任务的数组
格式: Mission[任务1,任务2,任务3,任务n], 可无限设置
而Mission数组里的每个元素 又是一个数组 大小为固定size = 5
分别为: 1.任务名称 (字符串)
2.任务等级 (整数)
3.任务类型和条件(数组)
第一个元素为类型
类型: 0 为触发式
1 为持有物品
2 为杀敌数一定
第二个元素为条件
当第一个元素为0时候
设置为字符串(即开关名)
当第二个元素为1时候
设置为 hash(即某物品或者武器和数量
键为类型,0:物品,1:武器,2:防具)
如{0=>[[1,3],[2,4]],1=>[[5,10]],2=>[10,12]}
表示 物品id为1 数量3
物品id为2 数量为4
武器id为5,数量为10
防具id为10,数量为12
当第二个元素为1时候(即杀敌数量)
设置为 hash(敌人id和数量)
如{14=>5,6=>12,7=>8}
表示需要干掉
id为14敌人5次
id为6的敌人12次
id为7的敌人8次
4.任务描述(字符串)
5.报酬(数组)
第一个元素为金钱(整数)
第二个元素为物品,武器,防具
设置为 hash(即某物品或者武器和数量
键为类型,0:物品,1:武器,2:防具)
如:{0=>[[1,10],[2,6]],1=>[[6,8]]}
表示 物品id为1 数量10
物品id为2 数量为6
武器id为6,数量为8
6.其他描述(字符串)
如:如此任务达成 我会帮你打开XX门
配合事件里插入脚本
$game_system.finishNameSort.include?(name)
name是任务名称
可以检测是否已经完成改任务 来判断是否打开XX门
[其他功能]
接受一个任务
MissionList.Start(name)
判断一个任务是否执行中
Mission.mission_run?(name)
提交一个任务
Mission.checkMission(name)
判断某个任务是否完成
$game_system.finishNameSort.include?(name)
还有一些功能就不单独描述了 具体看脚本核心部分
=end
#-----------------------------------------------------------------------------
# 设置任务部分
#------------------------------------------------------------------------------
module MissionList
Missions = [
["对话",1,
[0,"对话01"],"去找阿尔西斯对话",[100,
{0=>[[1,5]],}],"可能就在附近,仔细找找吧"+"这信息是刷屏幕,主要测试自动换行功能"*10],
["寻找密斯里尔剑",2,
[1,{1=>[[4,1]]}],
"也许在地图的某个角落",[0,{1=>[[1,1]],2=>[[1,1]]}],"也许在地图的某个角落"],
["灰狼",9,[2,{2=>5}],
"干掉5个灰狼"+"测试自动换行功能"*10,[1000,{}],""],
["灰狼+灰狼首领",4,[2,{1=>5,2=>5}],
"干掉5个灰狼和5个灰狼首领",[2000,
{0=>[[1,3],[2,1],[3,1]],1=>[[2,1],[3,1],[7,1]],2=>[[1,1],[2,1]]}],"丰厚的奖品哦"],
["重复灰狼任务1",1,[2,{1=>5}],
"干掉5个灰狼",[0,{1=>[[3,5]]}],""],
["重复灰狼任务2",2,[2,{1=>5}],
"干掉5个灰狼",[0,{1=>[[3,5]]}],""],
["重复灰狼任务3",3,[2,{1=>5}],
"干掉5个幽灵",[0,{1=>[[3,5]]}],""],
["重复灰狼任务4",4,[2,{1=>5}],
"干掉5个幽灵",[0,{1=>[[3,5]]}],""],
["重复灰狼任务5",5,[2,{1=>5}],
"干掉5个幽灵",[0,{1=>[[3,5]]}],""],
["重复灰狼任务6",6,[2,{1=>5}],
"干掉5个幽灵",[0,{1=>[[3,5]]}],""],
["重复灰狼任务7",7,[2,{1=>5}],
"干掉5个幽灵",[0,{1=>[[3,5]]}],""],
["重复灰狼任务8",8,[2,{1=>5}],
"干掉5个幽灵",[0,{1=>[[3,5]]}],""],
["重复灰狼任务9",9,[2,{1=>5}],
"干掉5个幽灵",[0,{1=>[[3,5]]}],""],
["叶子的任务10",10,[2,{1=>5}],
"干掉5个幽灵",[0,{1=>[[3,5]]}],""],
["寻找圣剑材料",10,
[1,{0=>[[32,5],[33,8],[34,11]]}],
"寻找圣剑所需的三个材料,圣剑材料1,圣剑材料2,圣剑材料3",
[0,{1=>[[33,1]]}],"找到这些可以做圣剑"],
]
module_function
def self.Start(name)
Missions.each do |mission|
Mission.startMission(*mission) if mission[0] == name
end
end
def canMissionList
if Missions.empty? or Missions.nil?
raise "任务没有设置好,请检查"
end
temp = []
Missions.each do |mission|
# if $game_system.missions[mission[0]].nil?
#添加到任务列表 并设置不需要在列表里的任务
temp << mission[0] if mission[0] != "寻找圣剑材料"
# end
end
return temp
end
end
#------------------------------------------------------------------------------
# 内部类定义部分
#------------------------------------------------------------------------------
class Hash < Object
def soft
@temp = []
self.each_pair{|key, value| @temp << [key,value] }
return @temp
end
end
class Integer
def rStar
return "★"*self
end
end
class Bitmap
def auto_line_draw_text(x,y,text,limit,height,align)
lines = text.getLines(limit)
@limit = limit
@n = 0
for i in 0...lines
@t1 = []
if lines == 1
@t1 << text
end
if lines > 1
@t= text.split(//)
while @t1.join.size < @limit
break if @t[@n].nil?
@t1.push(@t[@n])
@n += 1
end
end
draw_text(x,y+i*height,500,height,@t1.join,align)
end
end
end
class String
def getLines(limit)
lines = (self.length/limit).to_i
lines += 1 if self.length%limit != 0
return lines
end
end
#------------------------------------------------------------------------------
# 系统重定义部分
#------------------------------------------------------------------------------
class Game_Battler
def dead?
if (@hp == 0 and not @immortal)
@temp_a = 0 if @temp_a == nil
if self.is_a?(Game_Enemy) and @temp_a == 0
id = self.instance_variable_get enemy_id
now_mission = $game_system.missionEnemyIds #[name][id]
goal_mission = $game_system.missions # [name].kind[1][id]
# 检索是否存在于列表中
$game_system.missionEnemyIds.keys.each do |name|
# return true if $game_system.missionEnemyIds[name] == nil
if now_mission[name][id] != nil and goal_mission[name] != nil and
now_mission[name][id] < goal_mission[name].kind[1][id]
# $game_system.missions[name].stutas == 0
$game_system.missionEnemyIds[name][id] += 1
break
end
end
@temp_a = 1
end
return true
end
end
end
class Game_System
attr_accessor :missions
#attr_accessor :finishMissionTimes
attr_accessor :finishMissionList
attr_accessor :missionSwitch
attr_accessor :missionEnemyIds
attr_accessor :missionNameSort
attr_accessor :finishNameSort
alias ori_initialize initialize
def initialize
ori_initialize
@missions = {}
#@finishMissionTimes = {}
@finishMissionList = {}
@missionSwitch = {}
@missionEnemyIds = {}
@missionNameSort = []
@finishNameSort = []
@missionHouseList = []
end
end
class GetMission
attr_reader :level
attr_reader :kind
attr_reader :description
attr_reader :money
attr_reader :items
attr_reader :reswards_des
# attr_accessor :stutas
def initialize(level,kind,description,rewards,rewards_des)
@level = level
@kind = kind
@description = description
@money = rewards[0]
@items = rewards[1]
@reswards_des = rewards_des
end
end
class FinishMission < GetMission
attr_accessor :times
def initialize(times,*args)
new_args = [args[0],args[1],args[2],[args[3],args[4]],args[5]]
super(*new_args)
@times = times
end
end
#----------------------------------------------------------------------------
# 任务核心部分
#----------------------------------------------------------------------------
module Mission
module_function
def startMission(name,level,kind,description,rewards,rewards_des)
unless $game_system.missions.has_key?(name)
# 检查参数合法性
self.getError(name,level,kind,description,rewards,rewards_des)
$game_system.missions[name] = GetMission.new(
level,kind,description,rewards,rewards_des)
$game_system.missionNameSort << name unless $game_system.missionNameSort.include?(name)
case kind[0]
when 0
# 设置开关初始状态
$game_system.missionSwitch[kind[1]] = false
when 1
# 开启了一个获得物品的任务
when 2
# 开启了一个杀敌数的任务并设置列表
# {name1=>{id1=number,id2=number},name2={id1=number,id2=number}}
$game_system.missionEnemyIds[name] = {}
enemies = kind[1].sort
enemies.each{|id| $game_system.missionEnemyIds[name][id[0]] = 0}
end
end
return
end
# 开启一个组合任务
#(- -,好像没必要了 可以直接接受2个或者多个无报酬任务
# 全部完成后再给报酬)
def startComboMission;end
def getError(name,level,kind,description,rewards,rewards_des)
raise sprintf("任务:%s的参数 level 不是一个 Integer",name) unless level.kind_of?(Integer)
raise sprintf("任务:%s的参数 kind[0] 不是一个 Integer",name) unless kind[0].kind_of?(Integer)
case kind[0]
when 0
raise sprintf("任务:%s的参数 kind[1] 不是一个 String",name) unless kind[1].kind_of?(String)
when 1..2
unless (kind[1].kind_of?(Hash))
raise sprintf("任务:%s的参数 kind[1] 不是一个 Hash",name)
end
end
raise sprintf("任务:%s的参数 description 不是一个 String",name) unless description.kind_of?(String)
raise sprintf("任务:%s的参数 rewards[0] 不是一个 Integer",name) unless rewards[0].kind_of?(Integer)
raise sprintf("任务:%s的参数 rewards[1] 不是一个 Hash",name) unless rewards[1].kind_of?(Hash)
raise sprintf("任务:%s的参数 rewards_des 不是一个 String",name) unless rewards_des.kind_of?(String)
end
# 接受一个或多个任务添加到任务所
def addMissionHouse(*missions)
missions.each{|a|$game_system.missionHouseList << a}
end
# 任务所删除一个或多个任务
def deleteMissionHouse(*missions)
missions.each{|a|$game_system.missionHouseList.delete(a)}
end
# 放弃任务 可多个
def stopMission(*name)
name.each do |aname|
$game_system.missions.delete(aname) if $game_system.missions.include?(aname)
end
end
# 检索任务
def checkMission(name)
# 检索是否已接了任务
if $game_system.missions[name] != nil
kind = $game_system.missions[name].kind
else
return self.missionReslut(2,name,self.message(4)){|msg|self.putsMessage(msg);return}
end
# 类型
case kind[0]
# 条件触发式
when 0
switch_name = $game_system.missions[name].kind[1]
if $game_system.missionSwitch[switch_name] == true
$game_system.missionSwitch.delete(name)
# 返回成功结果
return self.missionReslut(0,name,self.message(0)){|msg|self.putsMessage(msg);return}
else
# 返回未完成结果
self.missionReslut(1,name,self.message(1)){|msg|self.putsMessage(msg);return}
end
# 持有物品
when 1
# 转化为 item格式的数组
# 如 [[1,10],[5,15]] 道具1数量10 道具5数量15
items = kind[1].select{|akind,array| akind == 0}[0][1] if kind[1][0] != nil
weapons = kind[1].select{|bkind,array| bkind == 1}[0][1] if kind[1][1] != nil
armors = kind[1].select{|ckind,array| ckind == 2}[0][1] if kind[1][2] != nil
unless items.nil?
unless self.check(name,0,items)
# 道具数量不合格
return self.missionReslut(1,name,self.message(2)){|msg|self.putsMessage(msg);return}
end
end
unless weapons.nil?
unless self.check(name,1,weapons)
# 武器数量不合格
return self.missionReslut(1,name,self.message(2)){|msg|self.putsMessage(msg);return}
end
end
unless armors.nil?
unless self.check(name,2,armors)
# 防具数量不合格
return self.missionReslut(1,name,self.message(2)){|msg|self.putsMessage(msg);return}
end
end
# 返回成功结果
return self.missionReslut(0,name,self.message(0)){|msg|self.putsMessage(msg);return}
# 杀敌数一定
when 2
enemies = kind[1].soft
enemies.each do |id,number|
if $game_system.missionEnemyIds[name][id] < number
return self.missionReslut(1,name,self.message(3)){|msg|self.putsMessage(msg);return}
end
end
# 清空敌人id列表
$game_system.missionEnemyIds.delete(name)
# 返回成功结果
return self.missionReslut(0,name,self.message(0)){|msg|self.putsMessage(msg);return}
end
end
def message(kind)
if kind == 0
return "恭喜你任务完成,请查收奖品"
elsif kind == 1
return "似乎还未达到要求"
elsif kind == 2
return "请检查是否获得了任务所需物品和数量"
elsif kind == 3
return "任务所需杀敌数还不够"
elsif kind == 4
return "未开启的任务类型"
else
return
end
end
def putsMessage(msg)
if $scene.is_a?(SceneMission)
$scene.message = msg
end
return
end
def check(name,kind,*args)
if kind == 0
# 任务所需物品array
items = args
# 获取现在物品
now_items = $game_party.instance_variable_get items
# 检查是否包含物品
ids01 = []
items[0].each{|item| ids01 << item[0]}
now_ids = now_items.keys
unless now_ids|ids01 == now_ids
return false
end
# 检查数量是否合格
items[0].each do |item|
return false if now_items[item[0]] < item[1]
end
elsif kind == 1
# 任务所需武器array
weapons = args
# 获取现在物品
now_weapons = $game_party.instance_variable_get weapons
# 检查是否包含物品
ids02 = []
weapons[0].each{|weapon| ids02 << weapon[0]}
now_ids = now_weapons.keys
unless now_ids|ids02 == now_ids
return false
end
# 检查数量是否合格
weapons[0].each do |weapon|
return false if now_weapons[weapon[0]] < weapon[1]
end
elsif kind == 2
# 任务所需物品array
armors = args
# 获取现在物品
now_armors = $game_party.instance_variable_get :@armors
# 检查是否包含物品
ids03 = []
armors[0].each{|armor| ids03 << armor[0][0]}
now_ids = now_armors.keys
unless now_ids|ids03 == now_ids
return false
end
# 检查数量是否合格
armors[0].each do |armor|
return false if now_armors[armor[0]] < armor[1]
end
else
end
# 检查通过
return true
end
#返回一种任务结果
def missionReslut(result,name,message)
case result
when 0
# 将任务转移到完成列表
self.missionMove(name)
# 获得报酬
self.getRewards(name)
# 清空任务
$game_system.missionNameSort.delete(name)
$game_system.missions.delete(name)
# 抛出任务成功信息
yield message
when 1
# 抛出未完成信息
yield message
#任务还未完成
return false
when 2
# 抛出未完成信息
yield message
#无此任务
return false
end
return
end
# 转移到任务完成列表
def missionMove(name)
@mission = $game_system.missions[name]
# 保存全部实例变量
@include = ["@level","@kind","@description","@money","@items","@reswards_des"]
@include_value = []
temp = []
@include.each do |a|
if a == "@monney"
temp << a
next
end
if a == "@tiems"
temp << a
a = temp
end
@include_value.push @mission.instance_variable_get eval(":"+a)
end
if $game_system.finishMissionList.include? name
# 任务名称=>完成次数
# 如果包含 完成次数+1
$game_system.finishMissionList[name].times += 1
else
# 如果不包含 建立一个完成任务的列表
$game_system.finishNameSort.push(name) unless $game_system.finishNameSort.include?(name)
$game_system.finishMissionList[name] = FinishMission.new(1,*@include_value)
end
return
end
# 获取报酬
def getRewards(name)
return if $game_system.missions[name] == nil
# [金钱,{种类1=>[[ID1,数量],[ID2,数量]],种类2=>[[ID1,数量],[ID2,数量]]}]
money = $game_system.missions[name].money
items = $game_system.missions[name].items
# 获取赏金
self.get_money(money) if money != 0
# 获得物品
if items[0] != nil
items[0].each{|id,number|
$game_party.send :gain_item,id,number
}
end
# 获得武器
if items[1] != nil
items[1].each{|id,number|
$game_party.send :gain_weapon,id,number
}
end
# 获得防具
if items[2] != nil
items[2].each{|id,number|
$game_party.send :gain_armor,id,number
}
end
return
end
def get_money(n)
$game_party.send :gain_gold,n
end
# *mission 可接收多个任务名称作为参数
def mission_finished?(*missions)
# return $game_system.finishMissionList.keys | missions
missions.each do |mission|
return false unless $game_system.finishMissionList.has_key?(mission)
end
return true
end
# 检查mission是否正在执行
def mission_run?(*missions)
#p missions
#p $game_system.missions
missions.each do |mission|
return false unless $game_system.missions.has_key?(mission)
end
return true
# p $game_system.missions.keys | missions
# return $game_system.missions.keys | missions
end
# 获取当前任务数量
def mission_counts
return $game_system.missions.length
end
end
#-----------------------------------------------------------------------------
# 菜单部分
#-----------------------------------------------------------------------------
# 任务所主菜单
class WindowMissionMain < Window_Selectable
def initialize
if $xiaoming == 1#←xiaoming
y = 100
m = 2
else
y = 160
m = 4
end
#原脚本没有这个判断
#注意当变量$xiaoming为1时只显示【查看任务】和【完成列表】
#当变量$xiaoming为0时显示本来的四个选项
#也就是说如果想要两个选项的效果
#就在调用任务主窗体之前调用脚本$xiaoming = 1
#如果想要四个选项的效果
#就在调用任务窗体之前调用脚本$xiaoming = 0
super(240,100,160,y) #←xiaoming
# super(240,100,160,160)
self.contents = Bitmap.new(width - 32, height - 32)
@item_max = m
# @item_max = 4
@column_max = 1
self.opacity = 255
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
if $xiaoming == 1#←xiaoming
c = ""
d = ""
else
c = "接受任务"
d = "提交任务"
end
#原脚本没有这个判断
self.contents.draw_text(0,0,200,32,"查看任务",0)#←xiaoming
self.contents.draw_text(0,32,200,32,"完成列表",0)
self.contents.draw_text(0,32*2,200,32,c,0)
self.contents.draw_text(0,32*3,200,32,d,0)
# self.contents.draw_text(0,0,200,32,"接受任务",0)
# self.contents.draw_text(0,32,200,32,"提交任务",0)
# self.contents.draw_text(0,32*2,200,32,"查看任务",0)
# self.contents.draw_text(0,32*3,200,32,"完成列表",0)
end
end
# 可接受任务的列表
class WindowCanAcceptList < Window_Selectable
def initialize
super(70,60,500,360)
@width = width
@column_max = 1
self.opacity = 255
self.visible = false
self.index = 0
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh(*list)
self.contents.clear if self.contents != nil
self.contents = Bitmap.new(@width - 32, list.size * 32+32)
@item_max = list.size
for i in list
MissionList::Missions.each do |mission|
if mission[0] == i
@level = mission[1]
@name = i
break
end
end
pos = list.index(i)
if $game_system.missions[@name] != nil
self.contents.font.color = disabled_color
else
self.contents.font.color = normal_color
end
self.contents.draw_text(0,pos*32,200,32,i,0)
self.contents.draw_text(220,pos*32,200,32,@level.rStar,0)
end
end
end
# 任务中的列表
class WindowAccetpedList < Window_Selectable
def initialize
super(70,60,500,360)
@width = width
@column_max = 1
self.opacity = 255
self.visible = false
self.index = 0
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh(*list)
return if list.empty?
self.contents.clear if self.contents != nil
self.contents = Bitmap.new(@width - 32, list.size * 32)
@item_max = list.size
for i in list
levels = $game_system.missions.level.rStar
pos = list.index(i)
self.contents.draw_text(0,pos*32,200,32,i,0)
self.contents.draw_text(220,pos*32,200,32,levels,0)
end
end
end
# 任务完成的列表
class WindowFinishList < Window_Selectable
def initialize
super(70,60,500,360)
@width = width
@column_max = 1
self.visible = false
self.opacity = 255
self.index = 0
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh(*list)
return if list.empty?
self.contents.clear if self.contents != nil
self.contents = Bitmap.new(@width - 32,list.size * 32)
@item_max = list.size
for i in list
level = $game_system.finishMissionList.level.rStar
pos = list.index(i)
self.contents.draw_text(0,pos*32,200,32,i,0)
self.contents.draw_text(220,pos*32,200,32,level,0)
end
end
end
# 任务描述窗口
class WindowMissionDes < Window_Base#
TEXT = ["[任务等级]","[任务条件]","[任务描述]","[任务报酬]","[其他]"]
TEXT2 = "接受任务请按确定键,返回上级菜单按取消键"
def initialize
super(70,40,500,400)
@viewport = Viewport.new(70,40+64,500,400-64)
@viewport.z = self.z + 1
self.visible = false
self.contents = Bitmap.new(width-32,64)
end
def update
super
if self.active
if @text != nil
@text.x > - 300 ? @text.x -= 2 : @text.x = 650
end
case Input.dir4
when 2
move_block(0)
move_bar(1)
when 8
move_block(1)
move_bar(0)
end
end
end
def nVisible
if self.visible == true
@sprite.visible = true if @sprite != nil
@bar.visible = true if @bar != nil
#@text.visible = true if @text != nil
end
if self.visible == false
@sprite.visible = false if @sprite != nil
@bar.visible = false if @bar != nil
@text.visible = false if @text != nil
end
end
def dispose
super
@sprite.dispose if @sprite != nil
@bar.dispose if @bar != nil
@text.dispose if @text != nil
end
def move_block(kind)
if kind == 0
@sprite.y -= 4
end
if kind == 1
@sprite.y += 4
end
end
def move_bar(kind)
if kind == 0
@bar.y -= (4/@rate).to_f if @bar.y > 112
end
if kind == 1
@bar.y += (4/@rate).to_f if @bar.y < 400 - @bar.bitmap.height
end
end
def getColor(n)
if n == 0
return Color.new(255,255,255,255)
elsif n == 1
return Color.new(255,255,0,255)
elsif n == 2
return Color.new(255,0,0,255)
elsif n == 3
return Color.new(128,128,128,255)
else
end
end
def refresh(name,listKind)
raise "listKind参数设置不正确" unless [0,1,2].include? listKind
self.contents.clear
# bitmap.clear if bitmap != nil
@sprite.dispose if @sprite != nil
@bar.dispose if @bar != nil
@name = name
# 可接受列表
if listKind == 0
MissionList::Missions.each do |mission|
if mission[0] == @name
@mission = mission
break
end
end
#mission_name = @mission[0]
level = @mission[1]
kind = @mission[2][0]
condition = @mission[2][1]
description = @mission[3]
money = @mission[4][0]
@mission[4][1][0] != nil ? item = @mission[4][1][0] : item = "无"
@mission[4][1][1] != nil ? weapon = @mission[4][1][1] : weapon = "无"
@mission[4][1][2] != nil ? armor = @mission[4][1][2] : armor = "无"
reward_des = @mission[5]
end
# 任务中列表
if listKind == 1
$game_system.missionNameSort.each do |mission|
if mission == @name
@mission = $game_system.missions[@name]
break
end
end
#mission_name = @mission.name
level = @mission.level
kind = @mission.kind[0]
condition = @mission.kind[1]
description = @mission.description
money = @mission.money
@mission.items[0] != nil ? item = @mission.items[0] : item = "无"
@mission.items[1] != nil ? weapon = @mission.items[1] : weapon = "无"
@mission.items[2] != nil ? armor = @mission.items[2] : armor = "无"
reward_des = @mission.reswards_des
end
# 完成列表
if listKind == 2
$game_system.finishNameSort.each do |mission|
if mission == @name
@mission = $game_system.finishMissionList[@name]
break
end
end
#mission_name = @mission.name
finish_times = @mission.times
level = @mission.level
kind = @mission.kind[0]
condition = @mission.kind[1]
description = @mission.description
money = @mission.money
@mission.items[0] != nil ? item = @mission.items[0] : item = "无"
@mission.items[1] != nil ? weapon = @mission.items[1] : weapon = "无"
@mission.items[2] != nil ? armor = @mission.items[2] : armor = "无"
reward_des = @mission.reswards_des
end
self.contents.font.color = getColor(2)
self.contents.draw_text(0,0,450-32,32,"【"+name+"】",1)
if listKind == 2
self.contents.font.color = getColor(1)
self.contents.draw_text(0,20,450-32,32,"完成次数:#{finish_times}",1)
end
self.contents.fill_rect(16,48,450,2,getColor(0))
# 开始计算Bitmap的height
@height = 11
case kind
when 0
# 40个字节一行计算
condition == "" ? @height += 1 : @height += condition.getLines(40)
when 1
@height += condition[0].size if condition[0] != nil
@height += condition[1].size if condition[1] != nil
@height += condition[2].size if condition[2] != nil
when 2
@height += condition.size
end
description == "" ? @height += 1 : @height += description.getLines(40) + 1
if listKind == 0
# 计算若无报酬的情况
@mission[4][1][0] == nil ? @height += 1 : @height += @mission[4][1][0].size
@mission[4][1][1] == nil ? @height += 1 : @height += @mission[4][1][1].size
@mission[4][1][2] == nil ? @height += 1 : @height += @mission[4][1][2].size
end
if listKind == 1
item == "无" ? @height += 1 : @height += item.size
weapon == "无" ? @height += 1 : @height += weapon.size
armor == "无" ? @height += 1 : @height += armor.size
end
if listKind == 2
end
reward_des == "" ? @height += 1 : @height += reward_des.getLines(40)
# 设置滚动字幕
if listKind == 0
@text = Sprite.new
@text.bitmap = Bitmap.new(640,32)
@text.bitmap.draw_text(0,0,640,32,TEXT2,0)
@text.x,@text.y,@text.ox,@text.oy = 650,0,0,0
end
# 计算滚动条
barHeight = 100
@rate = 2
#@rate = ((@height * 32) / barHeight).to_f
#if @rate >= 1
# barHeight = (barHeight/@rate).to_f
#end
bitmapBar = Bitmap.new(12,barHeight)
bitmapBar.fill_rect(0,0,bitmapBar.width,bitmapBar.height,getColor(0))
@bar = Sprite.new
@bar.bitmap = bitmapBar
@bar.x,@bar.y,@bar.z,@bar.ox,@bar.oy = 490,112,self.z+2,0,0
# 设置显示内容矩形
bitmap = Bitmap.new(500-32,@height*32)
@sprite = Sprite.new(@viewport)
@sprite.x,@sprite.y,@sprite.ox,@sprite.oy = 40,0,0,0
@sprite.bitmap = bitmap
@sprite.bitmap.font.color = getColor(1)
@sprite.bitmap.draw_text(0,0,468,32,TEXT[0],0)
@sprite.bitmap.font.color = getColor(0)
@sprite.bitmap.draw_text(0,32,468,32,level.rStar,0)
@sprite.bitmap.font.color = getColor(1)
@sprite.bitmap.draw_text(0,32*2,468,32,TEXT[1],0)
@sprite.bitmap.font.color = getColor(0)
# 完成事件的情况
if kind == 0
@sprite.bitmap.auto_line_draw_text(0,32*3,"无",40,32,0)
if condition.getLines(40) == 0
next_line = 32*4
else
next_line = 32*(3+condition.getLines(40))
end
end
# 取得物品的情况
if kind == 1
tem01 = 0
pos = 0
if condition[0] != nil
condition[0].each do |id,number|
pos = condition[0].index([id,number])
name = $data_items[id].name
icon_name = $data_items[id].icon_name
# blt(x, y, src_bitmap, src_rect[, opacity])
bt = RPG::Cache.icon(icon_name)
rect1 = Rect.new(0,32*3+pos*32,24,24)
rect2 = Rect.new(0,0,bt.width,bt.height)
@sprite.bitmap.stretch_blt(rect1,bt,rect2)
@sprite.bitmap.draw_text(64,32*3+pos*32,400,32,name,0)
case listKind
when 0,2
@sprite.bitmap.draw_text(300,32*3+pos*32,100,32,"x"+number.to_s,0)
when 1
now_items = $game_party.instance_variable_get :@items
now_number = (now_items[id].nil? ? 0 : now_items[id])
@sprite.bitmap.draw_text(250,32*3+pos*32,100,32,now_number.to_s+"/"+number.to_s,0)
when 2
end
end
tem01 += condition[0].size
end
if condition[1] != nil
condition[1].each do |id,number|
pos = condition[1].index([id,number]) + tem01
name = $data_weapons[id].name
icon_name = $data_weapons[id].icon_name
bt = RPG::Cache.icon(icon_name)
rect1 = Rect.new(0,32*3+pos*32,24,24)
rect2 = Rect.new(0,0,bt.width,bt.height)
@sprite.bitmap.stretch_blt(rect1,bt,rect2)
case listKind
when 0,2
@sprite.bitmap.draw_text(64,32*3+pos*32,400,32,name,0)
@sprite.bitmap.draw_text(300,32*3+pos*32,100,32,"x"+number.to_s,0)
when 1
now_weapons = $game_party.instance_variable_get :@weapons
now_number = (now_weapons[id].nil? ? 0 : now_weapons[id])
@sprite.bitmap.draw_text(300,32*3+pos*32,100,32,now_number.to_s+"/"+number.to_s,0)
when 2
end
end
tem01 += condition[1].size
end
if condition[2] != nil
p condition[2]
condition[2].each do |id,number|
pos = condition[2].index([id,number]) + tem01
name = $data_armors[id].name
icon_name = $data_armors[id].icon_name
bt = RPG::Cache.icon(icon_name)
rect1 = Rect.new(0,32*3+pos*32,24,24)
rect2 = Rect.new(0,0,bt.width,bt.height)
@sprite.bitmap.stretch_blt(rect1,bt,rect2)
case listKind
when 0,2
@sprite.bitmap.draw_text(64,32*3+pos*32,400,32,name,0)
@sprite.bitmap.draw_text(300,32*3+pos*32,100,32,"x"+number.to_s,0)
when 1
now_armors = $game_party.instance_variable_get :@armors
now_number = (now_armors[id].nil? ? 0 : now_armors[id])
@sprite.bitmap.draw_text(300,32*3+pos*32,100,32,now_number.to_s+"/"+number.to_s,0)
when 2
end
end
tem01 += condition[2].size
end
next_line = 32*(3+tem01)
end
# 杀敌的情况
if kind == 2
pos01 = 0
condition.sort.each do |id,number|
pos01 = condition.sort.index([id,number])
name = $data_enemies[id].name
@sprite.bitmap.draw_text(0,32*3+pos01*32,400,32,name,0)
case listKind
when 0,2
@sprite.bitmap.draw_text(300,32*3+pos01*32,100,32,"x"+number.to_s,0)
when 1
if $game_system.missionEnemyIds[@name][id] == nil
now_number = 0
else
now_number = $game_system.missionEnemyIds[@name][id]
end
@sprite.bitmap.draw_text(300,32*3+pos01*32,100,32,now_number.to_s+"/"+number.to_s,0)
end
end
next_line = 32*(3+condition.sort.size)
end
@sprite.bitmap.font.color = getColor(1)
@sprite.bitmap.draw_text(0,next_line,400,32,TEXT[2],0)
@sprite.bitmap.font.color = getColor(0)
@sprite.bitmap.auto_line_draw_text(0,next_line+32,description,40,32,0)
if description.getLines(40) == 0
next_line = next_line+32*2
else
next_line = (next_line+32)+32*description.getLines(40)
end
@sprite.bitmap.font.color = getColor(1)
@sprite.bitmap.draw_text(0,next_line,400,32,TEXT[3],0)
# 分割线
@sprite.bitmap.fill_rect(0,next_line+48,250,1,getColor(0))
@sprite.bitmap.font.color = getColor(0)
@sprite.bitmap.draw_text(0,next_line+32*2,400,32,"[金钱]",0)
@sprite.bitmap.draw_text(0,next_line+32*3,150,32,money.to_s+"G",0)
@sprite.bitmap.draw_text(0,next_line+32*4,400,32,"[道具]",0)
next_line = next_line+32*5
tem02 = 0
if item == "无"
@sprite.bitmap.draw_text(0,next_line,400,32,item,0)
tem02 += 1
else
item.each do |id,number|
name = $data_items[id].name
pos02 = item.index([id,number])
icon_name = $data_items[id].icon_name
bt = RPG::Cache.icon(icon_name)
rect1 = Rect.new(0,next_line+pos02*32,24,24)
rect2 = Rect.new(0,0,bt.width,bt.height)
@sprite.bitmap.stretch_blt(rect1,bt,rect2)
@sprite.bitmap.draw_text(64,next_line+pos02*32,400,32,name,0)
@sprite.bitmap.draw_text(300,next_line+pos02*32,100,32,"x"+number.to_s,0)
end
tem02 += item.size
end
next_line += tem02*32
@sprite.bitmap.draw_text(0,next_line,400,32,"[武器]",0)
next_line += 32
tem03 = 0
if weapon == "无"
@sprite.bitmap.draw_text(0,next_line,400,32,weapon,0)
tem03 += 1
else
weapon.each do |id,number|
name = $data_weapons[id].name
pos03 = weapon.index([id,number])
icon_name = $data_weapons[id].icon_name
bt = RPG::Cache.icon(icon_name)
rect1 = Rect.new(0,next_line+pos03*32,24,24)
rect2 = Rect.new(0,0,bt.width,bt.height)
@sprite.bitmap.stretch_blt(rect1,bt,rect2)
@sprite.bitmap.draw_text(64,next_line+pos03*32,400,32,name,0)
@sprite.bitmap.draw_text(300,next_line+pos03*32,100,32,"x"+number.to_s,0)
end
tem03 += weapon.size
end
next_line += tem03*32
@sprite.bitmap.draw_text(0,next_line,400,32,"[防具]",0)
next_line += 32
tem04 = 0
if armor == "无"
@sprite.bitmap.draw_text(0,next_line,400,32,armor,0)
tem04 += 1
else
armor.each do |id,number|
name = $data_armors[id].name
pos04 = armor.index([id,number])
icon_name = $data_armors[id].icon_name
bt = RPG::Cache.icon(icon_name)
rect1 = Rect.new(0,next_line+pos04*32,24,24)
rect2 = Rect.new(0,0,bt.width,bt.height)
@sprite.bitmap.stretch_blt(rect1,bt,rect2)
@sprite.bitmap.draw_text(64,next_line+pos04*32,400,32,name,0)
@sprite.bitmap.draw_text(300,next_line+pos04*32,100,32,"x"+number.to_s,0)
end
tem04 += armor.size
end
next_line += tem04*32
@sprite.bitmap.font.color = getColor(1)
@sprite.bitmap.draw_text(0,next_line,400,32,TEXT[4],0)
@sprite.bitmap.font.color = getColor(0)
next_line += 32
@sprite.bitmap.auto_line_draw_text(0,next_line,reward_des,40,32,0)
end
end
#-----------------------------------------------------------------------------
# 场景部分
#-----------------------------------------------------------------------------
class SceneMission
attr_accessor :message
attr_accessor :reward_list
def main
# 外部接口
@message = ""
@reward_list = {}
@spriteset = Spriteset_Map.new
@main_window = WindowMissionMain.new
@main_window.active = true
@can_accept = WindowCanAcceptList.new
@can_accept.active = false
@accepted = WindowAccetpedList.new
@accepted.active = false
@finished = WindowFinishList.new
@finished.active = false
@window_des = WindowMissionDes.new
@window_des.active = false
@result = Window_Help.new
@result.active = false
@result.visible = false
@result.x,@result.y,@result.z = 0,200,@window_des.z+100
# @yes_or_no = WindowYesOrNo.new
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@main_window.dispose
@can_accept.dispose
@accepted.dispose
@finished.dispose
@window_des.dispose
@result.dispose
@spriteset.dispose
end
def update
return update_main if @main_window.active
return update_can_accept if @can_accept.active
return update_accepted if @accepted.active
return update_finished if @finished.active
return update_window_des if @window_des.active
return update_result if @result.active
end
def update_main
@main_window.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
@main_window.visible = false
@main_window.active = false
case @main_window.index
when 2 # 接受←xiaoming
# when 0
@can_accept.active = true
@can_accept.visible = true
@can_accept.refresh(*MissionList.canMissionList)
@can_accept.index = 0
return
when 3 # 提交
# when 1
@accepted.active = true
@accepted.visible = true
@accepted.refresh(*$game_system.missionNameSort)
@accepted.index = 0
return
when 0 # 查看
# when 2
@accepted.active = true
@accepted.visible = true
@accepted.refresh(*$game_system.missionNameSort)
@accepted.index = 0
return
when 1 # 完成
# when 3
@finished.active = true
@finished.visible = true
@finished.refresh(*$game_system.finishNameSort)
@finished.index = 0
return
end
end
end
def update_can_accept
@can_accept.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@can_accept.active = false
@can_accept.visible = false
@main_window.visible = true
@main_window.active = true
# @main_window.index = 0
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
name = MissionList.canMissionList[@can_accept.index]
return if $game_system.missions[name] != nil
@can_accept.active = false
@can_accept.visible = false
@window_des.visible = true
@window_des.refresh(MissionList.canMissionList[@can_accept.index],0)
@window_des.active = true
return
end
end
# 接受了的列表
def update_accepted
@accepted.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@accepted.active = false
@accepted.visible = false
@main_window.visible = true
@main_window.active = true
# @main_window.index = 0
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
case @main_window.index
when 1 #提交 检索任务
return if $game_system.missionNameSort[@accepted.index].nil?
Mission.checkMission($game_system.missionNameSort[@accepted.index])
@accepted.active = false
@result.set_text(@message,1)
@result.active = true
@result.visible = true
when 2
if $game_system.missionNameSort[@accepted.index].nil?
return
end
@accepted.active = false
@accepted.visible = false
@window_des.active = true
@window_des.visible = true
@window_des.refresh($game_system.missionNameSort[@accepted.index],1)
when 3
end
end
end
# 完成了的列表
def update_finished
@finished.update
if Input.trigger?(Input::C)
return if $game_system.finishNameSort[@finished.index].nil?
$game_system.se_play($data_system.decision_se)
@finished.active = false
@finished.visible = false
@window_des.active = true
@window_des.visible = true
@window_des.refresh($game_system.finishNameSort[@finished.index],2)
return
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@finished.active = false
@finished.visible = false
@main_window.visible = true
@main_window.active = true
# @main_window.index = 0
return
end
end
def update_window_des
@window_des.update
if Input.trigger?(Input::C)
case @main_window.index
when 2 #←xiaoming
# when 0
$game_system.se_play($data_system.decision_se)
@window_des.active = false
@result.active = true
name = MissionList.canMissionList[@can_accept.index]
MissionList.Start(name)
@result.set_text("接受了任务" + name,1)
when 3 # 提交任务
# when 1
when 0 # 查看任务
# when 2
when 1 # 完成列表
# when 3
end
return
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@window_des.visible = false
@window_des.active = false
@window_des.nVisible
case @main_window.index
# 接受
when 0
@can_accept.active = true
@can_accept.visible = true
return
# 提交
when 2
@accepted.active = true
@accepted.visible = true
return
when 3
@finished.active = true
@finished.visible = true
end
end
end
def update_result
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
@result.active = false
@result.visible = false
@window_des.visible = false
@window_des.nVisible
@can_accept.visible = false
@accepted.visible = false
@finished.visible = false
@main_window.visible = true
@main_window.active = true
@main_window.index = 0
return
end
@result.update
end
end
#-----------------------------------------------------------------------------
# 结束
#-----------------------------------------------------------------------------
然后是你想要的通过物品调用任务窗体的方法
|
|