赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 13929 |
最后登录 | 2019-3-12 |
在线时间 | 216 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 80
- 在线时间
- 216 小时
- 注册时间
- 2011-9-17
- 帖子
- 151
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 工藤~新一じ 于 2015-12-1 19:32 编辑
楼主昨天晚上发帖求修改限制型魔法商店的脚本,希望修改成扣除物品学技能的,等不到人回复,所以楼主自己研究了这段脚本,努力了几个小时,终于把这个效果实现了。
楼主是脚本盲,目前只是个懂一两句事件脚本的作者,但楼主有很多想法。
我还想在昨晚我改成功的物品学技能脚本里新增遗忘效果,也想让学习魔法的列表里简洁一些,只显示该主角可学的技能,但这两个效果对楼主来说实在太难实现了。所以楼主仍然保佑希望说论坛的大大能帮助我。
下面脚本第一个是我昨晚改成功的物品学技能脚本。
第二个是带有学习和遗忘效果的脚本。
第三个是把列表简洁,只显示对应角色可学技能的脚本。
楼主真心希望在第一个脚本里融入第二个脚本和第三个脚本的效果! 在此先谢过,这个效果相信楼主现在的能力真的是做不出来了
物品学技能,职业限制型魔法商店:(已测试)
#============================================================================== # ■ 本脚本源自[url]www.66rpg.com[/url],转载与使用请保留此信息 #============================================================================== #——以下是一些自定义的内容 #呼出魔法商店$scene = Scene_MShop.new([1,2,3,4,5,6,7,8]) #在技能说明末尾增加@100,则学习此技能需要扣掉9号变量100 $mShop_use_1 = "魔法水晶" #——这项是购买魔法特技的货币的名称,如“灵魄”、“金钱” $mShop_use_2 = "个" #——这项是购买魔法特技的货币单位,如“点”、“¥” $mShop_use_variable = 9 #——这项是购买魔法特技时消耗的变量编号,如果=0 则是消耗金钱 $mShop_Window_Opacity = 200 #——这项是窗口透明度 # 每个职业可以学的技能列表 $class_canlearn_list = { 1 => [1,80], 2 => [60,61], 3 => []} #============================================================================== # ■ Window_MGold #------------------------------------------------------------------------------ # 显示金钱的窗口。 #============================================================================== class Window_MGold < Window_Base #-------------------------------------------------------------------------- # ● 初始化窗口 #-------------------------------------------------------------------------- def initialize super(0, 0, 272, 64) self.contents = Bitmap.new(width - 32, height - 32) refresh end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh self.contents.clear self.contents.font.color = system_color self.contents.draw_text(0, 0 , 240,32 ,$mShop_use_1) self.contents.font.color = normal_color self.contents.draw_text(0, 0, 240-contents.text_size($mShop_use_2).width-6, 32, $mShop_gold.to_s, 2) self.contents.font.color = system_color self.contents.draw_text(0, 0, 240, 32, $mShop_use_2, 2) end end #============================================================================== # ■ Scene_MShop #------------------------------------------------------------------------------ # 处理特技商店画面的类。 #============================================================================== class Scene_MShop #-------------------------------------------------------------------------- # ● 初始化 #-------------------------------------------------------------------------- def initialize(id) @id = id end #-------------------------------------------------------------------------- # ● 主处理 #-------------------------------------------------------------------------- def main screen = Spriteset_Map.new $game_variables[9] = $game_party.armor_number(951) $game_party.remove_actor(997)#主角离开队伍 if $mShop_use_variable == 0 $mShop_gold = $game_party.gold else $mShop_gold = $game_variables[$mShop_use_variable] end # 生成帮助窗口 @help_window = Window_Help.new @help_window.opacity = $mShop_Window_Opacity # 生成金钱窗口 @gold_window = Window_MGold.new @gold_window.x = 368 @gold_window.y = 416 @gold_window.opacity = $mShop_Window_Opacity # 生成购买窗口 @buy_window = Window_MShopBuy.new(@id) @buy_window.active = true @buy_window.visible = true @buy_window.help_window = @help_window @buy_window.opacity = $mShop_Window_Opacity # 生成状态窗口 @status_window = Window_MShopStatus.new @status_window.visible = true @status_window.active = false @status_window.opacity = $mShop_Window_Opacity # 执行过渡 Graphics.transition # 主循环 loop do # 刷新游戏画面 Graphics.update # 刷新输入信息 Input.update # 刷新画面 update # 如果画面切换的话就中断循环 if $scene != self break end end # 准备过渡 Graphics.freeze # 释放窗口 @help_window.dispose #@mhelp_window.dispose @gold_window.dispose @buy_window.dispose @status_window.dispose screen.dispose end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update # 刷新窗口 @help_window.update #@mhelp_window.update @gold_window.update @buy_window.update @status_window.update # 购买窗口激活的情况下: 调用 update_buy if @buy_window.active update_buy return end if @status_window.active update_status return end end #-------------------------------------------------------------------------- # ● 刷新画面 (购买窗口激活的情况下) #-------------------------------------------------------------------------- def update_buy @status_window.skill = @buy_window.skill if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) $game_variables[25] = $game_party.armor_number(951) $game_variables[24] = $game_variables[25] - $game_variables[9] $game_party.gain_armor(951,-$game_variables[24]) $game_party.add_actor(997)#主角加入队伍 $scene = Scene_Map.new return end if Input.trigger?(Input::C) @skill = @buy_window.skill if @skill == nil or @skill.price > $mShop_gold $game_system.se_play($data_system.buzzer_se) return end $game_system.se_play($data_system.decision_se) @buy_window.active = false @status_window.index = 0 @status_window.active = true end end #-------------------------------------------------------------------------- # ● 刷新画面 (状态窗口激活的情况下) #-------------------------------------------------------------------------- def update_status if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @status_window.active = false @status_window.index = -1 @buy_window.active = true end actor = $game_party.actors[@status_window.index] if Input.trigger?(Input::C) can_learn=false for j in $data_classes[actor.class_id].learnings if j.skill_id == @skill.id can_learn=true end end unless $class_canlearn_list[actor.class_id].nil? can_learn = true if $class_canlearn_list[actor.class_id].include?(@skill.id) end if can_learn==false $game_system.se_play($data_system.cancel_se) return end if $game_party.actors[@status_window.index].skill_learn?(@skill.id) $game_system.se_play($data_system.cancel_se) return else $game_system.se_play($data_system.decision_se) if $mShop_use_variable == 0 $game_party.gain_gold([email]-@skill.price[/email]) $mShop_gold -= @skill.price else $game_variables[$mShop_use_variable] -= @skill.price $mShop_gold -= @skill.price end $game_party.actors[@status_window.index].learn_skill(@skill.id) @gold_window.refresh @buy_window.refresh @status_window.refresh @status_window.active = false @status_window.index = -1 @buy_window.active = true end end end end #============================================================================== # ■ Window_MShopStatus #------------------------------------------------------------------------------ # 特技商店画面、显示物品所持数与角色装备的窗口。 #============================================================================== class Window_MShopStatus < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize super(368, 64, 272, 352) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.size = 18 @skill = nil refresh end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...$game_party.actors.size actor = $game_party.actors[i] # draw_actor_graphic(actor,12,80*i+64) self.contents.font.color = system_color self.contents.draw_text(44, 80*i, 240, 32, actor.name) self.contents.draw_text(0, 80*i , 240-20,32,"等级",2) self.contents.font.color = normal_color self.contents.draw_text(0, 80*i, 240, 32, actor.level.to_s , 2) self.contents.font.color = system_color self.contents.draw_text(44, 80*i+22, 45, 32, $data_system.words.hp) self.contents.font.color = normal_color self.contents.draw_text(44, 80*i+22, 90, 32, actor.maxhp.to_s,2) self.contents.font.color = system_color self.contents.draw_text(150, 80*i+22, 45, 32, $data_system.words.sp) self.contents.font.color = normal_color self.contents.draw_text(150, 80*i+22, 90, 32, actor.maxsp.to_s,2) can_learn=false for j in $data_classes[actor.class_id].learnings if j.skill_id == @skill.id can_learn=true end end unless $class_canlearn_list[actor.class_id].nil? can_learn = true if $class_canlearn_list[actor.class_id].include?(@skill.id) end if can_learn == true if actor.skill_learn?(@skill.id) self.contents.font.color = Color.new(255,255,255,128) self.contents.draw_text(44, 80*i+44, 196, 32, "已经学会改技能 ",2) else self.contents.font.color = Color.new(255,255,0,255) self.contents.draw_text(44, 80*i+44, 196, 32, "可以学会该技能 ",2) end else self.contents.font.color = Color.new(255,255,255,128) self.contents.draw_text(44, 80*i+44, 196, 32, "不适合学该技能 ",2) end end @item_max = $game_party.actors.size end #-------------------------------------------------------------------------- # ● 设置物品 # item : 新的物品 #-------------------------------------------------------------------------- def skill=(skill) if @skill != skill @skill = skill refresh end end #-------------------------------------------------------------------------- # ● 刷新光标矩形 #-------------------------------------------------------------------------- def update_cursor_rect if @index < 0 self.cursor_rect.empty else self.cursor_rect.set(0, @index * 80, self.width - 32, 80) end end end #============================================================================== # ■ Window_MShopBuy #------------------------------------------------------------------------------ # 特技商店画面、浏览显示可以购买的商品的窗口。 #============================================================================== class Window_MShopBuy < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 # shop_goods : 商品 #-------------------------------------------------------------------------- def initialize(id) super(0, 64, 368, 416) @id = id refresh self.index = 0 end #-------------------------------------------------------------------------- # ● 获取物品 #-------------------------------------------------------------------------- def skill return @data[self.index] end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] for skill_id in @id skill = $data_skills[skill_id] if skill != nil @data.push(skill) end end @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max draw_item(i) end end end #-------------------------------------------------------------------------- # ● 描绘羡慕 # index : 项目编号 #-------------------------------------------------------------------------- def draw_item(index) skill = @data[index] # 除此之外的情况设置为无效文字色 if skill.price <= $mShop_gold self.contents.font.color = normal_color else self.contents.font.color = disabled_color end x = 4 y = index * 32 rect = Rect.new(x, y, self.width - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(skill.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0) self.contents.draw_text(x + 240, y, 88, 32, skill.price.to_s, 2) end #-------------------------------------------------------------------------- # ● 刷新帮助文本 #-------------------------------------------------------------------------- def update_help @help_window.set_text(self.skill == nil ? "" : self.skill.description) end end #============================================================================== # ■ RPG原装定义 #============================================================================== module RPG class Skill def description description = @description.split(/@/)[0] return description != nil ? description : '' end def price price = @description.split(/@/)[1] return price != nil ? price.to_i : 0 end end end
#==============================================================================
# ■ 本脚本源自[url]www.66rpg.com[/url],转载与使用请保留此信息
#==============================================================================
#——以下是一些自定义的内容
#呼出魔法商店$scene = Scene_MShop.new([1,2,3,4,5,6,7,8])
#在技能说明末尾增加@100,则学习此技能需要扣掉9号变量100
$mShop_use_1 = "魔法水晶" #——这项是购买魔法特技的货币的名称,如“灵魄”、“金钱”
$mShop_use_2 = "个" #——这项是购买魔法特技的货币单位,如“点”、“¥”
$mShop_use_variable = 9 #——这项是购买魔法特技时消耗的变量编号,如果=0 则是消耗金钱
$mShop_Window_Opacity = 200 #——这项是窗口透明度
# 每个职业可以学的技能列表
$class_canlearn_list = { 1 => [1,80],
2 => [60,61],
3 => []}
#==============================================================================
# ■ Window_MGold
#------------------------------------------------------------------------------
# 显示金钱的窗口。
#==============================================================================
class Window_MGold < Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(0, 0, 272, 64)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, 0 , 240,32 ,$mShop_use_1)
self.contents.font.color = normal_color
self.contents.draw_text(0, 0, 240-contents.text_size($mShop_use_2).width-6, 32, $mShop_gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(0, 0, 240, 32, $mShop_use_2, 2)
end
end
#==============================================================================
# ■ Scene_MShop
#------------------------------------------------------------------------------
# 处理特技商店画面的类。
#==============================================================================
class Scene_MShop
#--------------------------------------------------------------------------
# ● 初始化
#--------------------------------------------------------------------------
def initialize(id)
@id = id
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
screen = Spriteset_Map.new
$game_variables[9] = $game_party.armor_number(951)
$game_party.remove_actor(997)#主角离开队伍
if $mShop_use_variable == 0
$mShop_gold = $game_party.gold
else
$mShop_gold = $game_variables[$mShop_use_variable]
end
# 生成帮助窗口
@help_window = Window_Help.new
@help_window.opacity = $mShop_Window_Opacity
# 生成金钱窗口
@gold_window = Window_MGold.new
@gold_window.x = 368
@gold_window.y = 416
@gold_window.opacity = $mShop_Window_Opacity
# 生成购买窗口
@buy_window = Window_MShopBuy.new(@id)
@buy_window.active = true
@buy_window.visible = true
@buy_window.help_window = @help_window
@buy_window.opacity = $mShop_Window_Opacity
# 生成状态窗口
@status_window = Window_MShopStatus.new
@status_window.visible = true
@status_window.active = false
@status_window.opacity = $mShop_Window_Opacity
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@help_window.dispose
#@mhelp_window.dispose
@gold_window.dispose
@buy_window.dispose
@status_window.dispose
screen.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
#@mhelp_window.update
@gold_window.update
@buy_window.update
@status_window.update
# 购买窗口激活的情况下: 调用 update_buy
if @buy_window.active
update_buy
return
end
if @status_window.active
update_status
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (购买窗口激活的情况下)
#--------------------------------------------------------------------------
def update_buy
@status_window.skill = @buy_window.skill
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$game_variables[25] = $game_party.armor_number(951)
$game_variables[24] = $game_variables[25] - $game_variables[9]
$game_party.gain_armor(951,-$game_variables[24])
$game_party.add_actor(997)#主角加入队伍
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
@skill = @buy_window.skill
if @skill == nil or @skill.price > $mShop_gold
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
@buy_window.active = false
@status_window.index = 0
@status_window.active = true
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (状态窗口激活的情况下)
#--------------------------------------------------------------------------
def update_status
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@status_window.active = false
@status_window.index = -1
@buy_window.active = true
end
actor = $game_party.actors[@status_window.index]
if Input.trigger?(Input::C)
can_learn=false
for j in $data_classes[actor.class_id].learnings
if j.skill_id == @skill.id
can_learn=true
end
end
unless $class_canlearn_list[actor.class_id].nil?
can_learn = true if $class_canlearn_list[actor.class_id].include?(@skill.id)
end
if can_learn==false
$game_system.se_play($data_system.cancel_se)
return
end
if $game_party.actors[@status_window.index].skill_learn?(@skill.id)
$game_system.se_play($data_system.cancel_se)
return
else
$game_system.se_play($data_system.decision_se)
if $mShop_use_variable == 0
$game_party.gain_gold([email]-@skill.price[/email])
$mShop_gold -= @skill.price
else
$game_variables[$mShop_use_variable] -= @skill.price
$mShop_gold -= @skill.price
end
$game_party.actors[@status_window.index].learn_skill(@skill.id)
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
@status_window.active = false
@status_window.index = -1
@buy_window.active = true
end
end
end
end
#==============================================================================
# ■ Window_MShopStatus
#------------------------------------------------------------------------------
# 特技商店画面、显示物品所持数与角色装备的窗口。
#==============================================================================
class Window_MShopStatus < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(368, 64, 272, 352)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 18
@skill = nil
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
# draw_actor_graphic(actor,12,80*i+64)
self.contents.font.color = system_color
self.contents.draw_text(44, 80*i, 240, 32, actor.name)
self.contents.draw_text(0, 80*i , 240-20,32,"等级",2)
self.contents.font.color = normal_color
self.contents.draw_text(0, 80*i, 240, 32, actor.level.to_s , 2)
self.contents.font.color = system_color
self.contents.draw_text(44, 80*i+22, 45, 32, $data_system.words.hp)
self.contents.font.color = normal_color
self.contents.draw_text(44, 80*i+22, 90, 32, actor.maxhp.to_s,2)
self.contents.font.color = system_color
self.contents.draw_text(150, 80*i+22, 45, 32, $data_system.words.sp)
self.contents.font.color = normal_color
self.contents.draw_text(150, 80*i+22, 90, 32, actor.maxsp.to_s,2)
can_learn=false
for j in $data_classes[actor.class_id].learnings
if j.skill_id == @skill.id
can_learn=true
end
end
unless $class_canlearn_list[actor.class_id].nil?
can_learn = true if $class_canlearn_list[actor.class_id].include?(@skill.id)
end
if can_learn == true
if actor.skill_learn?(@skill.id)
self.contents.font.color = Color.new(255,255,255,128)
self.contents.draw_text(44, 80*i+44, 196, 32, "已经学会改技能 ",2)
else
self.contents.font.color = Color.new(255,255,0,255)
self.contents.draw_text(44, 80*i+44, 196, 32, "可以学会该技能 ",2)
end
else
self.contents.font.color = Color.new(255,255,255,128)
self.contents.draw_text(44, 80*i+44, 196, 32, "不适合学该技能 ",2)
end
end
@item_max = $game_party.actors.size
end
#--------------------------------------------------------------------------
# ● 设置物品
# item : 新的物品
#--------------------------------------------------------------------------
def skill=(skill)
if @skill != skill
@skill = skill
refresh
end
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 80, self.width - 32, 80)
end
end
end
#==============================================================================
# ■ Window_MShopBuy
#------------------------------------------------------------------------------
# 特技商店画面、浏览显示可以购买的商品的窗口。
#==============================================================================
class Window_MShopBuy < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# shop_goods : 商品
#--------------------------------------------------------------------------
def initialize(id)
super(0, 64, 368, 416)
@id = id
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def skill
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for skill_id in @id
skill = $data_skills[skill_id]
if skill != nil
@data.push(skill)
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 描绘羡慕
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
skill = @data[index]
# 除此之外的情况设置为无效文字色
if skill.price <= $mShop_gold
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(skill.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0)
self.contents.draw_text(x + 240, y, 88, 32, skill.price.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.skill == nil ? "" : self.skill.description)
end
end
#==============================================================================
# ■ RPG原装定义
#==============================================================================
module RPG
class Skill
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def price
price = @description.split(/@/)[1]
return price != nil ? price.to_i : 0
end
end
end
可学习和遗忘技能魔法商店:(已测试)
#============================================================================== # ■ 本脚本源自[url]www.66rpg.com[/url],转载与使用请保留此信息 #============================================================================== #——以下是一些自定义的内容 $mShop_use_1 = "灵魄" #——这项是购买魔法特技的货币的名称,如“灵魄”、“金钱” $mShop_use_2 = "特斯拉" #——这项是购买魔法特技的货币单位,如“点”、“¥” $mShop_use_variable = 1 #——这项是购买魔法特技时消耗的变量编号,如果=0 则是消耗金钱 $mShop_Window_Opacity = 200 #——这项是窗口透明度 #============================================================================== # ■ Window_MGold #------------------------------------------------------------------------------ # 显示金钱的窗口。 #============================================================================== class Window_MGold < Window_Base #-------------------------------------------------------------------------- # ● 初始化窗口 #-------------------------------------------------------------------------- def initialize super(0, 0, 272, 64) self.contents = Bitmap.new(width - 32, height - 32) refresh end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh self.contents.clear self.contents.font.color = system_color self.contents.draw_text(0, 0 , 240,32 ,$mShop_use_1) self.contents.font.color = normal_color self.contents.draw_text(0, 0, 240-contents.text_size($mShop_use_2).width-6, 32, $mShop_gold.to_s, 2) self.contents.font.color = system_color self.contents.draw_text(0, 0, 240, 32, $mShop_use_2, 2) end end #============================================================================== # ■ Scene_MShop #------------------------------------------------------------------------------ # 处理特技商店画面的类。 #============================================================================== class Scene_MShop #-------------------------------------------------------------------------- # ● 初始化 #-------------------------------------------------------------------------- def initialize(id) @id = id end #-------------------------------------------------------------------------- # ● 主处理 #-------------------------------------------------------------------------- def main screen = Spriteset_Map.new if $mShop_use_variable == 0 $mShop_gold = $game_party.gold else $mShop_gold = $game_variables[$mShop_use_variable] end # 生成帮助窗口 @help_window = Window_Help.new @help_window.opacity = $mShop_Window_Opacity # 生成金钱窗口 @gold_window = Window_MGold.new @gold_window.x = 368 @gold_window.y = 416 @gold_window.opacity = $mShop_Window_Opacity # 生成购买窗口 @buy_window = Window_MShopBuy.new(@id) @buy_window.active = true @buy_window.visible = true @buy_window.help_window = @help_window @buy_window.opacity = $mShop_Window_Opacity # 生成状态窗口 @status_window = Window_MShopStatus.new @status_window.visible = true @status_window.active = false @status_window.opacity = $mShop_Window_Opacity #生成指令窗口 @command_window = Window_Command.new(160,["学会","遗忘"]) @command_window.x = 320 @command_window.y = 240 @command_window.z = 500 @command_window.visible = false @command_window.active = false @command_window.opacity = $mShop_Window_Opacity # 执行过渡 Graphics.transition # 主循环 loop do # 刷新游戏画面 Graphics.update # 刷新输入信息 Input.update # 刷新画面 update # 如果画面切换的话就中断循环 if $scene != self break end end # 准备过渡 Graphics.freeze # 释放窗口 @help_window.dispose #@mhelp_window.dispose @gold_window.dispose @buy_window.dispose @status_window.dispose @command_window.dispose screen.dispose end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update # 刷新窗口 @help_window.update #@mhelp_window.update @gold_window.update @buy_window.update @status_window.update @command_window.update # 购买窗口激活的情况下: 调用 update_buy if @buy_window.active update_buy return end if @status_window.active update_status return end if @command_window.active update_command return end end #-------------------------------------------------------------------------- # ● 刷新画面 (指令窗口激活的情况下) #-------------------------------------------------------------------------- def update_command if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @status_window.index = -1 @command_window.active = false @command_window.visible = false @buy_window.active = true return end if Input.trigger?(Input::C) if @command_window.index == 0 if $game_party.actors[@status_window.index].skill_learn?(@skill.id) or @skill.price > $mShop_gold $game_system.se_play($data_system.cancel_se) return else $game_system.se_play($data_system.decision_se) if $mShop_use_variable == 0 $game_party.gain_gold([email]-@skill.price[/email]) $mShop_gold -= @skill.price else $game_variables[$mShop_use_variable] -= @skill.price $mShop_gold -= @skill.price end $game_party.actors[@status_window.index].learn_skill(@skill.id) @gold_window.refresh @buy_window.refresh @status_window.refresh @status_window.index = -1 @buy_window.active = true @command_window.active = false @command_window.visible = false end elsif @command_window.index == 1 if $game_party.actors[@status_window.index].skill_learn?(@skill.id) == false $game_system.se_play($data_system.cancel_se) return else $game_system.se_play($data_system.decision_se) if $mShop_use_variable == 0 $game_party.gain_gold(@skill.price/2) #<-遗忘价格为学习的一半,/2的地方相同 $mShop_gold += @skill.price/2 else $game_variables[$mShop_use_variable] += @skill.price/2 $mShop_gold += @skill.price/2 end $game_party.actors[@status_window.index].forget_skill(@skill.id) @gold_window.refresh @buy_window.refresh @status_window.refresh @status_window.index = -1 @buy_window.active = true @command_window.active = false @command_window.visible = false end end return end end #-------------------------------------------------------------------------- # ● 刷新画面 (购买窗口激活的情况下) #-------------------------------------------------------------------------- def update_buy @status_window.skill = @buy_window.skill if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) $scene = Scene_Map.new return end if Input.trigger?(Input::C) @skill = @buy_window.skill if @skill == nil #or @skill.price > $mShop_gold $game_system.se_play($data_system.buzzer_se) return end $game_system.se_play($data_system.decision_se) @buy_window.active = false @status_window.index = 0 @status_window.active = true end end #-------------------------------------------------------------------------- # ● 刷新画面 (状态窗口激活的情况下) #-------------------------------------------------------------------------- def update_status if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @status_window.active = false @status_window.index = -1 @buy_window.active = true end if Input.trigger?(Input::C) @status_window.active = false @command_window.visible = true @command_window.active = true end end end #============================================================================== # ■ Window_MShopStatus #------------------------------------------------------------------------------ # 特技商店画面、显示物品所持数与角色装备的窗口。 #============================================================================== class Window_MShopStatus < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize super(368, 64, 272, 352) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.size = 18 @skill = nil refresh end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...$game_party.actors.size actor = $game_party.actors[i] draw_actor_graphic(actor,12,80*i+64) self.contents.font.color = system_color self.contents.draw_text(44, 80*i, 240, 32, actor.name) self.contents.draw_text(0, 80*i , 240-20,32,"等级",2) self.contents.font.color = normal_color self.contents.draw_text(0, 80*i, 240, 32, actor.level.to_s , 2) self.contents.font.color = system_color self.contents.draw_text(44, 80*i+22, 45, 32, $data_system.words.hp) self.contents.font.color = normal_color self.contents.draw_text(44, 80*i+22, 90, 32, actor.maxhp.to_s,2) self.contents.font.color = system_color self.contents.draw_text(150, 80*i+22, 45, 32, $data_system.words.sp) self.contents.font.color = normal_color self.contents.draw_text(150, 80*i+22, 90, 32, actor.maxsp.to_s,2) if actor.skill_learn?(@skill.id) self.contents.font.color = Color.new(255,255,255,128) self.contents.draw_text(44, 80*i+44, 196, 32, "⊙此项特技已经学习⊙",2) else self.contents.font.color = Color.new(255,255,0,255) self.contents.draw_text(44, 80*i+44, 240, 32, "★此项特技尚未学习★") end end @item_max = $game_party.actors.size end #-------------------------------------------------------------------------- # ● 设置物品 # item : 新的物品 #-------------------------------------------------------------------------- def skill=(skill) if @skill != skill @skill = skill refresh end end #-------------------------------------------------------------------------- # ● 刷新光标矩形 #-------------------------------------------------------------------------- def update_cursor_rect if @index < 0 self.cursor_rect.empty else self.cursor_rect.set(0, @index * 80, self.width - 32, 80) end end end #============================================================================== # ■ Window_MShopBuy #------------------------------------------------------------------------------ # 特技商店画面、浏览显示可以购买的商品的窗口。 #============================================================================== class Window_MShopBuy < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 # shop_goods : 商品 #-------------------------------------------------------------------------- def initialize(id) super(0, 64, 368, 416) @id = id refresh self.index = 0 end #-------------------------------------------------------------------------- # ● 获取物品 #-------------------------------------------------------------------------- def skill return @data[self.index] end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] for skill_id in @id skill = $data_skills[skill_id] if skill != nil @data.push(skill) end end @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max draw_item(i) end end end #-------------------------------------------------------------------------- # ● 描绘羡慕 # index : 项目编号 #-------------------------------------------------------------------------- def draw_item(index) skill = @data[index] # 除此之外的情况设置为无效文字色 if skill.price <= $mShop_gold self.contents.font.color = normal_color else self.contents.font.color = disabled_color end x = 4 y = index * 32 rect = Rect.new(x, y, self.width - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(skill.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0) self.contents.draw_text(x + 240, y, 88, 32, skill.price.to_s, 2) end #-------------------------------------------------------------------------- # ● 刷新帮助文本 #-------------------------------------------------------------------------- def update_help @help_window.set_text(self.skill == nil ? "" : self.skill.description) end end #============================================================================== # ■ RPG原装定义 #============================================================================== module RPG class Skill def description description = @description.split(/@/)[0] return description != nil ? description : '' end def price price = @description.split(/@/)[1] return price != nil ? price.to_i : 0 end end end
#==============================================================================
# ■ 本脚本源自[url]www.66rpg.com[/url],转载与使用请保留此信息
#==============================================================================
#——以下是一些自定义的内容
$mShop_use_1 = "灵魄" #——这项是购买魔法特技的货币的名称,如“灵魄”、“金钱”
$mShop_use_2 = "特斯拉" #——这项是购买魔法特技的货币单位,如“点”、“¥”
$mShop_use_variable = 1 #——这项是购买魔法特技时消耗的变量编号,如果=0 则是消耗金钱
$mShop_Window_Opacity = 200 #——这项是窗口透明度
#==============================================================================
# ■ Window_MGold
#------------------------------------------------------------------------------
# 显示金钱的窗口。
#==============================================================================
class Window_MGold < Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(0, 0, 272, 64)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, 0 , 240,32 ,$mShop_use_1)
self.contents.font.color = normal_color
self.contents.draw_text(0, 0, 240-contents.text_size($mShop_use_2).width-6, 32, $mShop_gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(0, 0, 240, 32, $mShop_use_2, 2)
end
end
#==============================================================================
# ■ Scene_MShop
#------------------------------------------------------------------------------
# 处理特技商店画面的类。
#==============================================================================
class Scene_MShop
#--------------------------------------------------------------------------
# ● 初始化
#--------------------------------------------------------------------------
def initialize(id)
@id = id
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
screen = Spriteset_Map.new
if $mShop_use_variable == 0
$mShop_gold = $game_party.gold
else
$mShop_gold = $game_variables[$mShop_use_variable]
end
# 生成帮助窗口
@help_window = Window_Help.new
@help_window.opacity = $mShop_Window_Opacity
# 生成金钱窗口
@gold_window = Window_MGold.new
@gold_window.x = 368
@gold_window.y = 416
@gold_window.opacity = $mShop_Window_Opacity
# 生成购买窗口
@buy_window = Window_MShopBuy.new(@id)
@buy_window.active = true
@buy_window.visible = true
@buy_window.help_window = @help_window
@buy_window.opacity = $mShop_Window_Opacity
# 生成状态窗口
@status_window = Window_MShopStatus.new
@status_window.visible = true
@status_window.active = false
@status_window.opacity = $mShop_Window_Opacity
#生成指令窗口
@command_window = Window_Command.new(160,["学会","遗忘"])
@command_window.x = 320
@command_window.y = 240
@command_window.z = 500
@command_window.visible = false
@command_window.active = false
@command_window.opacity = $mShop_Window_Opacity
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@help_window.dispose
#@mhelp_window.dispose
@gold_window.dispose
@buy_window.dispose
@status_window.dispose
@command_window.dispose
screen.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
#@mhelp_window.update
@gold_window.update
@buy_window.update
@status_window.update
@command_window.update
# 购买窗口激活的情况下: 调用 update_buy
if @buy_window.active
update_buy
return
end
if @status_window.active
update_status
return
end
if @command_window.active
update_command
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (指令窗口激活的情况下)
#--------------------------------------------------------------------------
def update_command
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@status_window.index = -1
@command_window.active = false
@command_window.visible = false
@buy_window.active = true
return
end
if Input.trigger?(Input::C)
if @command_window.index == 0
if $game_party.actors[@status_window.index].skill_learn?(@skill.id) or @skill.price > $mShop_gold
$game_system.se_play($data_system.cancel_se)
return
else
$game_system.se_play($data_system.decision_se)
if $mShop_use_variable == 0
$game_party.gain_gold([email]-@skill.price[/email])
$mShop_gold -= @skill.price
else
$game_variables[$mShop_use_variable] -= @skill.price
$mShop_gold -= @skill.price
end
$game_party.actors[@status_window.index].learn_skill(@skill.id)
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
@status_window.index = -1
@buy_window.active = true
@command_window.active = false
@command_window.visible = false
end
elsif @command_window.index == 1
if $game_party.actors[@status_window.index].skill_learn?(@skill.id) == false
$game_system.se_play($data_system.cancel_se)
return
else
$game_system.se_play($data_system.decision_se)
if $mShop_use_variable == 0
$game_party.gain_gold(@skill.price/2) #<-遗忘价格为学习的一半,/2的地方相同
$mShop_gold += @skill.price/2
else
$game_variables[$mShop_use_variable] += @skill.price/2
$mShop_gold += @skill.price/2
end
$game_party.actors[@status_window.index].forget_skill(@skill.id)
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
@status_window.index = -1
@buy_window.active = true
@command_window.active = false
@command_window.visible = false
end
end
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (购买窗口激活的情况下)
#--------------------------------------------------------------------------
def update_buy
@status_window.skill = @buy_window.skill
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
@skill = @buy_window.skill
if @skill == nil #or @skill.price > $mShop_gold
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
@buy_window.active = false
@status_window.index = 0
@status_window.active = true
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (状态窗口激活的情况下)
#--------------------------------------------------------------------------
def update_status
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@status_window.active = false
@status_window.index = -1
@buy_window.active = true
end
if Input.trigger?(Input::C)
@status_window.active = false
@command_window.visible = true
@command_window.active = true
end
end
end
#==============================================================================
# ■ Window_MShopStatus
#------------------------------------------------------------------------------
# 特技商店画面、显示物品所持数与角色装备的窗口。
#==============================================================================
class Window_MShopStatus < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(368, 64, 272, 352)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 18
@skill = nil
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
draw_actor_graphic(actor,12,80*i+64)
self.contents.font.color = system_color
self.contents.draw_text(44, 80*i, 240, 32, actor.name)
self.contents.draw_text(0, 80*i , 240-20,32,"等级",2)
self.contents.font.color = normal_color
self.contents.draw_text(0, 80*i, 240, 32, actor.level.to_s , 2)
self.contents.font.color = system_color
self.contents.draw_text(44, 80*i+22, 45, 32, $data_system.words.hp)
self.contents.font.color = normal_color
self.contents.draw_text(44, 80*i+22, 90, 32, actor.maxhp.to_s,2)
self.contents.font.color = system_color
self.contents.draw_text(150, 80*i+22, 45, 32, $data_system.words.sp)
self.contents.font.color = normal_color
self.contents.draw_text(150, 80*i+22, 90, 32, actor.maxsp.to_s,2)
if actor.skill_learn?(@skill.id)
self.contents.font.color = Color.new(255,255,255,128)
self.contents.draw_text(44, 80*i+44, 196, 32, "⊙此项特技已经学习⊙",2)
else
self.contents.font.color = Color.new(255,255,0,255)
self.contents.draw_text(44, 80*i+44, 240, 32, "★此项特技尚未学习★")
end
end
@item_max = $game_party.actors.size
end
#--------------------------------------------------------------------------
# ● 设置物品
# item : 新的物品
#--------------------------------------------------------------------------
def skill=(skill)
if @skill != skill
@skill = skill
refresh
end
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 80, self.width - 32, 80)
end
end
end
#==============================================================================
# ■ Window_MShopBuy
#------------------------------------------------------------------------------
# 特技商店画面、浏览显示可以购买的商品的窗口。
#==============================================================================
class Window_MShopBuy < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# shop_goods : 商品
#--------------------------------------------------------------------------
def initialize(id)
super(0, 64, 368, 416)
@id = id
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def skill
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for skill_id in @id
skill = $data_skills[skill_id]
if skill != nil
@data.push(skill)
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 描绘羡慕
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
skill = @data[index]
# 除此之外的情况设置为无效文字色
if skill.price <= $mShop_gold
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(skill.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0)
self.contents.draw_text(x + 240, y, 88, 32, skill.price.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.skill == nil ? "" : self.skill.description)
end
end
#==============================================================================
# ■ RPG原装定义
#==============================================================================
module RPG
class Skill
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def price
price = @description.split(/@/)[1]
return price != nil ? price.to_i : 0
end
end
end
只列出该角色技能,魔法商店:(未测试)
#============================================================================== # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息 #============================================================================== #============================================================================== # ■ 本脚本源自[url]www.66rpg.com[/url],转载与使用请保留此信息 #============================================================================== #——以下是一些自定义的内容 $mShop_use_1 = "学习点数" #——这项是购买魔法特技的货币的名称,如“灵魄”、“金钱” $mShop_use_2 = " " #——这项是购买魔法特技的货币单位,如“点”、“¥” $mShop_use_variable = [1,2,3] #——这项是购买魔法特技时消耗的变量编号,如果=0 则是消耗金钱 $mShop_Window_Opacity = 160 #——这项是窗口透明度 #============================================================================== # ■ RPG原装定义 #============================================================================== module RPG class Skill def description description = @description.split(/@/)[0] return description != nil ? description : '' end def price price = @description.split(/@/)[1] return price != nil ? price.to_i : 0 end end end #============================================================================== # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息 #============================================================================== #============================================================================== # ■ Window_MShopStatus #------------------------------------------------------------------------------ # 特技商店画面、显示物品所持数与角色装备的窗口。 #============================================================================== class Window_MShopStatus < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize super(0, 64, 272, 352) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.size = 18 @skill = nil self.index = 0 refresh end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...$game_party.actors.size actor = $game_party.actors[i] draw_actor_graphic(actor,12,80*i+64) self.contents.font.color = system_color self.contents.draw_text(44, 80*i, 240, 32, actor.name) self.contents.draw_text(0, 80*i , 240-20,32,"等级",2) self.contents.font.color = normal_color self.contents.draw_text(0, 80*i, 240, 32, actor.level.to_s , 2) self.contents.font.color = system_color self.contents.draw_text(44, 80*i+22, 45, 32, $data_system.words.hp) self.contents.font.color = normal_color self.contents.draw_text(44, 80*i+22, 90, 32, actor.maxhp.to_s,2) self.contents.font.color = system_color self.contents.draw_text(150, 80*i+22, 45, 32, $data_system.words.sp) self.contents.font.color = normal_color self.contents.draw_text(150, 80*i+22, 90, 32, actor.maxsp.to_s,2) can_learn=false for j in $data_classes[actor.class_id].learnings if j.skill_id == @skill.id can_learn=true end end if can_learn == true if actor.skill_learn?(@skill.id) self.contents.font.color = Color.new(255,255,255,128) self.contents.draw_text(44, 80*i+44, 196, 32, "⊙此项特技已经学习⊙",2) else self.contents.font.color = Color.new(255,255,0,255) self.contents.draw_text(44, 80*i+44, 240, 32, "★此项特技尚未学习★") end else self.contents.font.color = Color.new(255,255,255,128) self.contents.draw_text(44, 80*i+44, 196, 32, "◇此项特技无法学习◇",2) end end @item_max = $game_party.actors.size end #-------------------------------------------------------------------------- # ● 设置物品 # item : 新的物品 #-------------------------------------------------------------------------- def skill=(skill) if @skill != skill @skill = skill refresh end end #-------------------------------------------------------------------------- # ● 刷新光标矩形 #-------------------------------------------------------------------------- def update_cursor_rect if @index < 0 self.cursor_rect.empty else self.cursor_rect.set(0, @index * 80, self.width - 32, 80) end end end #============================================================================== # ■ Window_MShopBuy #------------------------------------------------------------------------------ # 特技商店画面、浏览显示可以购买的商品的窗口。 #============================================================================== class Window_MShopBuy < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 # shop_goods : 商品 #-------------------------------------------------------------------------- def initialize(id) super(272, 64, 368, 416) @id = id refresh # self.index = 0 end #-------------------------------------------------------------------------- # ● 获取物品 #-------------------------------------------------------------------------- def skill return @data[self.index] end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] for skill_id in @id skill = $data_skills[skill_id] if skill != nil @data.push(skill) end end @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max draw_item(i) end end end #-------------------------------------------------------------------------- # ● 描绘羡慕 # index : 项目编号 #-------------------------------------------------------------------------- def draw_item(index) skill = @data[index] # 除此之外的情况设置为无效文字色 if skill.price <= $mShop_gold self.contents.font.color = normal_color else self.contents.font.color = disabled_color end x = 4 y = index * 32 rect = Rect.new(x, y, self.width - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(skill.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0) self.contents.draw_text(x + 240, y, 88, 32, skill.price.to_s, 2) end #-------------------------------------------------------------------------- # ● 刷新帮助文本 #-------------------------------------------------------------------------- def update_help @help_window.set_text(self.skill == nil ? "" : self.skill.description) end end #============================================================================== # ■ Window_MGold #------------------------------------------------------------------------------ # 显示金钱的窗口。 #============================================================================== class Window_MGold < Window_Base #-------------------------------------------------------------------------- # ● 初始化窗口 #-------------------------------------------------------------------------- def initialize super(0, 0, 272, 64) self.contents = Bitmap.new(width - 32, height - 32) refresh end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh self.contents.clear self.contents.font.color = system_color self.contents.draw_text(0, 0 , 240,32 ,$mShop_use_1) self.contents.font.color = normal_color self.contents.draw_text(0, 0, 240-contents.text_size($mShop_use_2).width-6, 32, $mShop_gold.to_s, 2) self.contents.font.color = system_color self.contents.draw_text(0, 0, 240, 32, $mShop_use_2, 2) end end #============================================================================== # ■ Scene_MShop #------------------------------------------------------------------------------ # 处理特技商店画面的类。 #============================================================================== class Scene_MShop #-------------------------------------------------------------------------- # ● 初始化 #-------------------------------------------------------------------------- def initialize(actor_id = 1) @actor = $game_party.actors[actor_id - 1] @id = [] if $mShop_use_variable[actor_id - 1] == 0 $mShop_gold = $game_party.gold else $mShop_gold = $game_variables[$mShop_use_variable[@actor.id - 1]] end for i in 0... $data_classes[@actor.class_id].learnings.size @id[i] = $data_classes[@actor.class_id].learnings[i].skill_id end end #-------------------------------------------------------------------------- # ● 主处理 #-------------------------------------------------------------------------- def main screen = Spriteset_Map.new # 生成帮助窗口 @help_window = Window_Help.new @help_window.opacity = $mShop_Window_Opacity # 生成金钱窗口 @gold_window = Window_MGold.new @gold_window.x = 0 @gold_window.y = 416 @gold_window.opacity = $mShop_Window_Opacity # 生成购买窗口 @buy_window = Window_MShopBuy.new(@id) @buy_window.active = false @buy_window.visible = true @buy_window.help_window = @help_window @buy_window.opacity = $mShop_Window_Opacity # 生成状态窗口 @status_window = Window_MShopStatus.new @status_window.visible = true @status_window.active = true @status_window.opacity = $mShop_Window_Opacity # 执行过渡 Graphics.transition # 主循环 loop do # 刷新游戏画面 Graphics.update # 刷新输入信息 Input.update # 刷新画面 update # 如果画面切换的话就中断循环 if $scene != self break end end # 准备过渡 Graphics.freeze # 释放窗口 @help_window.dispose @gold_window.dispose @buy_window.dispose @status_window.dispose screen.dispose end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update # 刷新窗口 @help_window.update @gold_window.update @buy_window.update @status_window.update # 购买窗口激活的情况下: 调用 update_buy if @buy_window.active update_buy return end if @status_window.active update_status return end end #-------------------------------------------------------------------------- # ● 刷新画面 (右侧窗口激活的情况下) #-------------------------------------------------------------------------- def update_buy @status_window.skill = @buy_window.skill if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @buy_window.active = false @buy_window.index = -1 @status_window.active = true return end if Input.trigger?(Input::C) @skill = @buy_window.skill if @skill == nil or @skill.price > $mShop_gold $game_system.se_play($data_system.buzzer_se) return end can_learn=false for j in $data_classes[$game_party.actors[@status_window.index].class_id].learnings if j.skill_id == @skill.id can_learn=true end end if can_learn==false $game_system.se_play($data_system.cancel_se) return end if $game_party.actors[@status_window.index].skill_learn?(@skill.id) $game_system.se_play($data_system.cancel_se) return else $game_system.se_play($data_system.decision_se) if $mShop_use_variable[@actor.id - 1] == 0 $game_party.gain_gold([email]-@skill.price[/email]) $mShop_gold -= @skill.price else $game_variables[$mShop_use_variable[@actor.id - 1]] -= @skill.price $mShop_gold -= @skill.price end $game_party.actors[@status_window.index].learn_skill(@skill.id) @gold_window.refresh @buy_window.refresh @status_window.refresh $game_system.se_play($data_system.decision_se) @buy_window.active = false @buy_window.index = -1 @status_window.active = true end end end #-------------------------------------------------------------------------- # ● 刷新画面 (状态窗口激活的情况下) #-------------------------------------------------------------------------- def update_status if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) $scene = Scene_Map.new #---改成menu end if Input.trigger?(Input::C) @actor = $game_party.actors[@status_window.index] @id = [] for i in 0... $data_classes[@actor.class_id].learnings.size @id[i] = $data_classes[@actor.class_id].learnings[i].skill_id end @buy_window.dispose @buy_window = Window_MShopBuy.new(@id) @buy_window.help_window = @help_window if $mShop_use_variable[@actor.id - 1] == 0 $mShop_gold = $game_party.gold else $mShop_gold = $game_variables[$mShop_use_variable[@actor.id - 1]] end @buy_window.opacity = $mShop_Window_Opacity @status_window.refresh @status_window.active = false @buy_window.active = true @buy_window.index = 0 @gold_window.refresh end end end
#==============================================================================
# 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
#==============================================================================
#==============================================================================
# ■ 本脚本源自[url]www.66rpg.com[/url],转载与使用请保留此信息
#==============================================================================
#——以下是一些自定义的内容
$mShop_use_1 = "学习点数" #——这项是购买魔法特技的货币的名称,如“灵魄”、“金钱”
$mShop_use_2 = " " #——这项是购买魔法特技的货币单位,如“点”、“¥”
$mShop_use_variable = [1,2,3] #——这项是购买魔法特技时消耗的变量编号,如果=0 则是消耗金钱
$mShop_Window_Opacity = 160 #——这项是窗口透明度
#==============================================================================
# ■ RPG原装定义
#==============================================================================
module RPG
class Skill
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def price
price = @description.split(/@/)[1]
return price != nil ? price.to_i : 0
end
end
end
#==============================================================================
# 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
#==============================================================================
#==============================================================================
# ■ Window_MShopStatus
#------------------------------------------------------------------------------
# 特技商店画面、显示物品所持数与角色装备的窗口。
#==============================================================================
class Window_MShopStatus < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 64, 272, 352)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 18
@skill = nil
self.index = 0
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
draw_actor_graphic(actor,12,80*i+64)
self.contents.font.color = system_color
self.contents.draw_text(44, 80*i, 240, 32, actor.name)
self.contents.draw_text(0, 80*i , 240-20,32,"等级",2)
self.contents.font.color = normal_color
self.contents.draw_text(0, 80*i, 240, 32, actor.level.to_s , 2)
self.contents.font.color = system_color
self.contents.draw_text(44, 80*i+22, 45, 32, $data_system.words.hp)
self.contents.font.color = normal_color
self.contents.draw_text(44, 80*i+22, 90, 32, actor.maxhp.to_s,2)
self.contents.font.color = system_color
self.contents.draw_text(150, 80*i+22, 45, 32, $data_system.words.sp)
self.contents.font.color = normal_color
self.contents.draw_text(150, 80*i+22, 90, 32, actor.maxsp.to_s,2)
can_learn=false
for j in $data_classes[actor.class_id].learnings
if j.skill_id == @skill.id
can_learn=true
end
end
if can_learn == true
if actor.skill_learn?(@skill.id)
self.contents.font.color = Color.new(255,255,255,128)
self.contents.draw_text(44, 80*i+44, 196, 32, "⊙此项特技已经学习⊙",2)
else
self.contents.font.color = Color.new(255,255,0,255)
self.contents.draw_text(44, 80*i+44, 240, 32, "★此项特技尚未学习★")
end
else
self.contents.font.color = Color.new(255,255,255,128)
self.contents.draw_text(44, 80*i+44, 196, 32, "◇此项特技无法学习◇",2)
end
end
@item_max = $game_party.actors.size
end
#--------------------------------------------------------------------------
# ● 设置物品
# item : 新的物品
#--------------------------------------------------------------------------
def skill=(skill)
if @skill != skill
@skill = skill
refresh
end
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 80, self.width - 32, 80)
end
end
end
#==============================================================================
# ■ Window_MShopBuy
#------------------------------------------------------------------------------
# 特技商店画面、浏览显示可以购买的商品的窗口。
#==============================================================================
class Window_MShopBuy < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# shop_goods : 商品
#--------------------------------------------------------------------------
def initialize(id)
super(272, 64, 368, 416)
@id = id
refresh
# self.index = 0
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def skill
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for skill_id in @id
skill = $data_skills[skill_id]
if skill != nil
@data.push(skill)
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 描绘羡慕
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
skill = @data[index]
# 除此之外的情况设置为无效文字色
if skill.price <= $mShop_gold
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(skill.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0)
self.contents.draw_text(x + 240, y, 88, 32, skill.price.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.skill == nil ? "" : self.skill.description)
end
end
#==============================================================================
# ■ Window_MGold
#------------------------------------------------------------------------------
# 显示金钱的窗口。
#==============================================================================
class Window_MGold < Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(0, 0, 272, 64)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, 0 , 240,32 ,$mShop_use_1)
self.contents.font.color = normal_color
self.contents.draw_text(0, 0, 240-contents.text_size($mShop_use_2).width-6, 32, $mShop_gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(0, 0, 240, 32, $mShop_use_2, 2)
end
end
#==============================================================================
# ■ Scene_MShop
#------------------------------------------------------------------------------
# 处理特技商店画面的类。
#==============================================================================
class Scene_MShop
#--------------------------------------------------------------------------
# ● 初始化
#--------------------------------------------------------------------------
def initialize(actor_id = 1)
@actor = $game_party.actors[actor_id - 1]
@id = []
if $mShop_use_variable[actor_id - 1] == 0
$mShop_gold = $game_party.gold
else
$mShop_gold = $game_variables[$mShop_use_variable[@actor.id - 1]]
end
for i in 0... $data_classes[@actor.class_id].learnings.size
@id[i] = $data_classes[@actor.class_id].learnings[i].skill_id
end
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
screen = Spriteset_Map.new
# 生成帮助窗口
@help_window = Window_Help.new
@help_window.opacity = $mShop_Window_Opacity
# 生成金钱窗口
@gold_window = Window_MGold.new
@gold_window.x = 0
@gold_window.y = 416
@gold_window.opacity = $mShop_Window_Opacity
# 生成购买窗口
@buy_window = Window_MShopBuy.new(@id)
@buy_window.active = false
@buy_window.visible = true
@buy_window.help_window = @help_window
@buy_window.opacity = $mShop_Window_Opacity
# 生成状态窗口
@status_window = Window_MShopStatus.new
@status_window.visible = true
@status_window.active = true
@status_window.opacity = $mShop_Window_Opacity
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@help_window.dispose
@gold_window.dispose
@buy_window.dispose
@status_window.dispose
screen.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
@gold_window.update
@buy_window.update
@status_window.update
# 购买窗口激活的情况下: 调用 update_buy
if @buy_window.active
update_buy
return
end
if @status_window.active
update_status
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (右侧窗口激活的情况下)
#--------------------------------------------------------------------------
def update_buy
@status_window.skill = @buy_window.skill
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@buy_window.active = false
@buy_window.index = -1
@status_window.active = true
return
end
if Input.trigger?(Input::C)
@skill = @buy_window.skill
if @skill == nil or @skill.price > $mShop_gold
$game_system.se_play($data_system.buzzer_se)
return
end
can_learn=false
for j in $data_classes[$game_party.actors[@status_window.index].class_id].learnings
if j.skill_id == @skill.id
can_learn=true
end
end
if can_learn==false
$game_system.se_play($data_system.cancel_se)
return
end
if $game_party.actors[@status_window.index].skill_learn?(@skill.id)
$game_system.se_play($data_system.cancel_se)
return
else
$game_system.se_play($data_system.decision_se)
if $mShop_use_variable[@actor.id - 1] == 0
$game_party.gain_gold([email]-@skill.price[/email])
$mShop_gold -= @skill.price
else
$game_variables[$mShop_use_variable[@actor.id - 1]] -= @skill.price
$mShop_gold -= @skill.price
end
$game_party.actors[@status_window.index].learn_skill(@skill.id)
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
$game_system.se_play($data_system.decision_se)
@buy_window.active = false
@buy_window.index = -1
@status_window.active = true
end
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (状态窗口激活的情况下)
#--------------------------------------------------------------------------
def update_status
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new #---改成menu
end
if Input.trigger?(Input::C)
@actor = $game_party.actors[@status_window.index]
@id = []
for i in 0... $data_classes[@actor.class_id].learnings.size
@id[i] = $data_classes[@actor.class_id].learnings[i].skill_id
end
@buy_window.dispose
@buy_window = Window_MShopBuy.new(@id)
@buy_window.help_window = @help_window
if $mShop_use_variable[@actor.id - 1] == 0
$mShop_gold = $game_party.gold
else
$mShop_gold = $game_variables[$mShop_use_variable[@actor.id - 1]]
end
@buy_window.opacity = $mShop_Window_Opacity
@status_window.refresh
@status_window.active = false
@buy_window.active = true
@buy_window.index = 0
@gold_window.refresh
end
end
end
|
|