查看: 4016|回复: 3

[RMVA发布] XP->VA魔法商店移植

[复制链接]
梦石
0
星屑
50
在线时间
31 小时
注册时间
2010-8-27
回帖
4
发表于 2013-7-2 21:42:52 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 fk1995 于 2013-7-2 21:44 编辑

之前在网上找到的魔法商店,可惜只有XP版本的,原网址:
http://www.66rpg.com/articles/3087
我对它进行了到VA的移植,并且重新设计了排版,使得看起来更加舒服一点。
目前我的设置是如果该角色在升级过程中不会学习到该魔法、技能的话则他无法再魔法商店里学习到该技能。
因此可以在职业的技能那里把能学的都设置到1级就学会然后遗忘掉就行。
使用方法:
复制全部脚本内容,在Main脚本之前按insert,插入此脚本全部内容。  
首先,参考在脚本的顶部注释修改购买魔法消耗的货币称呼和变量编号(=0就是金钱)。  
然后,给你所有可以购买的魔法的介绍说明部分,在后面添加 @价格。比如给某个冰魔法设置如下:
给予敌单体冰属性伤害。@500  
最后,需要呼叫魔法商店的时候,在事件中使用脚本:SceneManager.call(Scene_MShop,para=[80,81,82,83])
这样,其中的数字表示这个商店中出售的魔法编号。注意两点:1、中括号不可省略,2、如果一行输入不下,可以在数字的逗号后面换行。

关于版权问题,因为原作者目测不太可能联系得上,所以暂时不考虑。
如果原作者对于我的修改有任何意见,欢迎提出。
如果有任何建议或者BUG的,也欢迎提出。
另外,本人第一次写脚本,所以兼容性难以保证,希望多多包涵。

效果图:
QQ图片20130702214344.jpg

工程:
http://pan.baidu.com/share/link? ... 8&uk=1527234810

代码:
[pre lang="ruby" line="1"]#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
#==============================================================================
#——以下是一些自定义的内容
$mShop_use_1 = "LP"    #——这项是购买魔法特技的货币的名称,如“灵魄”、“金钱”
$mShop_use_2 = "LP"  #——这项是购买魔法特技的货币单位,如“点”、“¥”
$mShop_use_variable = 1  #——这项是购买魔法特技时消耗的变量编号,如果=0 则是消耗金钱
$mShop_Window_Opacity = 200  #——这项是窗口透明度
#==============================================================================
# ■ Window_MGold
#------------------------------------------------------------------------------
#  显示LP的窗口。
#==============================================================================
class Window_MGold < Window_Base
  #--------------------------------------------------------------------------
  # ● 初始化窗口
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 544-32-standard_padding*2, 64)
    self.contents = Bitmap.new(width - standard_padding*2, height - standard_padding*2)
    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 < Scene_Base
  #--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  def initialize(id)
    @id = id
    create_main_viewport
  end   
  #--------------------------------------------------------------------------
  # ● 主处理
  #--------------------------------------------------------------------------
  def main
    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 = 0
    @gold_window.y = 416 - 64
    @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
    @status_window.skill = @buy_window.skill
    # 执行过渡
    Graphics.transition
    # 主循环
    loop do
      # 刷新游戏画面
      Graphics.update
      # 刷新输入信息
      Input.update
      # 刷新画面
      update
      if !SceneManager.scene_is? (Scene_MShop)
        break
      # 如果画面切换的话就中断循环
      end
    end
    # 释放窗口
    pre_terminate
    terminate
  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)
      Sound::play_cancel
      # 返回
      SceneManager.return
      # 释放窗口
      return
    end
    if Input.trigger?(Input::C)
      @skill = @buy_window.skill
      if @skill == nil or @skill.price > $mShop_gold
        Sound::play_buzzer
        return
      end
      Sound::play_ok
      @buy_window.active = false
      @status_window.index = 0
      @status_window.active = true
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面 (状态窗口激活的情况下)
  #--------------------------------------------------------------------------
  def update_status
    if Input.trigger?(Input::B)
      Sound::play_cancel
      @status_window.active = false
      @status_window.index = -1
      @buy_window.active = true
    end
    if Input.trigger?(Input::C)
      if $game_party.members[@status_window.index].skill_learn?(@skill)
      Sound::play_buzzer
        return
      else
        Sound::play_ok
        if $mShop_use_variable == 0
          $game_party.gain_gold(-@skill.price)
          $mShop_gold -= @skill.price
        else
          $game_variables[$mShop_use_variable] -= @skill.price
          $mShop_gold -= @skill.price
        end
        $game_party.members[@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_MShopBuy
#------------------------------------------------------------------------------
#  特技商店画面、浏览显示可以购买的商品的窗口。
#==============================================================================
class Window_MShopBuy < Window_Selectable

  #--------------------------------------------------------------------------
  # ● 修改行高为合适的值
  #--------------------------------------------------------------------------
  def line_height
    return 32
  end
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #     shop_goods : 商品
  #--------------------------------------------------------------------------
  
  def initialize(id)
    @id = id
    super(0, 64, 544-32-standard_padding*2, 416-64-64)
    refresh
    self.index = 0
  end

  #--------------------------------------------------------------------------
  # ● 获取物品
  #--------------------------------------------------------------------------
  def skill
    return @data[self.index]
  end
  def item_max
    if @id != nil
      return @id.size
    end
  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
    if item_max > 0
      self.contents = Bitmap.new(width - 32, item_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 = system_color
    end
    x = 4
    y = index * 32
    rect = Rect.new(x, y, self.width - 24, 24)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    draw_icon(skill.icon_index,x,y+4,self.contents.font.color == normal_color)
    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_MShopStatus
#------------------------------------------------------------------------------
#  特技商店画面、显示物品所持数与角色装备的窗口。
#==============================================================================
class Window_MShopStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 修改行高为合适的值
  #--------------------------------------------------------------------------
  def line_height
    return 32
  end
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize
    super(Graphics.width-standard_padding*2-32,64,standard_padding*2+32 , Graphics.height-64)
    self.contents = Bitmap.new(width - 24,  32*$game_party.members.size+2*standard_padding>height - 32-64? 32*$game_party.members.size+2*standard_padding : height - 32-64)
    self.contents.font.size = 32
    @skill = nil
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...$game_party.members.size
      actor = $game_party.members
      if actor.class.skills.include?(@skill.id)
        if !actor.skill_learn?(@skill)
          draw_actor_graphic(actor,standard_padding+4,32*i+16+12+4)
        else
          draw_actor_graphic(actor,standard_padding+4,32*i+16+12+4,150)
        end
      else
        next
      end
    end
  end
  def item_max
      return $game_party.members.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 * 32, 44, 44)
    end
  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
  class Class < BaseItem
    def skills
      @allskills = []
      self.learnings.each do |skill|
      @allskills.push(skill.skill_id)
        end
      return @allskills
    end
end

end
#==============================================================================
# ■ 场景管理器定义
#==============================================================================

module SceneManager
  #--------------------------------------------------------------------------
  # ● 呼び出し
  #--------------------------------------------------------------------------
  def self.call(scene_class,para = nil)
    @stack.push(@scene)
    @scene = scene_class.new(para)
  end
end

class Window_Base < Window
  #--------------------------------------------------------------------------
  # ● 描绘角色行走图(只给定角色对象)
  #--------------------------------------------------------------------------
  def draw_actor_graphic(actor, x, y, alpha = 255)
    draw_character(actor.character_name, actor.character_index, x, y,alpha)
  end
  #--------------------------------------------------------------------------
  # ● 描绘行走图
  #--------------------------------------------------------------------------
  def draw_character(character_name, character_index, x, y,alpha = 255)
    return unless character_name # 不给文件名神马的最讨厌了
    bitmap = Cache.character(character_name) # 读取Cache里的行走图像
    sign = character_name[/^[\!\$]./] # 如果文件名里带!和$的话有特殊含义哦
    if sign && sign.include?('$') # 如果有$的话是大图
      cw = bitmap.width / 3
      ch = bitmap.height / 4
    else                          # 不然是小图。有!表示非人物的行走图。宝箱之类的。
      cw = bitmap.width / 12
      ch = bitmap.height / 8
    end
    n = character_index           # 这都要偷懒啊……
    src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
    contents.blt(x - cw / 2, y - ch, bitmap, src_rect,alpha) # Bitmap.blt方法
  end
end


#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================[/pre]
梦石
0
星屑
50
在线时间
17 小时
注册时间
2013-6-15
回帖
4
发表于 2013-7-4 00:46:29 | 显示全部楼层
额...求解,这是什么情况...
QQ图片20130704004523.jpg
回复

使用道具 举报

梦石
0
星屑
50
在线时间
31 小时
注册时间
2010-8-27
回帖
4
 楼主| 发表于 2013-7-4 16:03:06 | 显示全部楼层
星月夜的睡狮 发表于 2013-7-4 00:46
额...求解,这是什么情况...

在其他脚本里,Window_Base类继承了非默认的类(默认的话是Window类),所以有此BUG
请全局搜索class Window_Base来确认到底继承了什么类……
回复

使用道具 举报

梦石
0
星屑
858
在线时间
929 小时
注册时间
2006-6-26
回帖
1377
发表于 2019-5-18 10:45:05 | 显示全部楼层
能不能指定某角色只能学习某些魔法?
我是不是可以签名了?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部