设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1456|回复: 2
打印 上一主题 下一主题

[已经解决] 关于佣兵脚本的问题~

[复制链接]

Lv1.梦旅人

梦石
0
星屑
90
在线时间
6 小时
注册时间
2010-7-9
帖子
40
跳转到指定楼层
1
发表于 2010-7-9 09:20:27 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
呃,好早拈来的佣兵脚本……希望大侠帮忙教教如何把雇佣金去掉——能做成像DQ里一样就更好了……
如果能把这个脚本添加注释……那你就是神了!!!
拜谢~

module Mercenaries
  class Window_Help < ::Window_Base
    def initialize
      super(0, 0, 196, 256)
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.font.size = 18
      @actor = nil
      self.z += 10
    end
    def draw_actor(actor)
      if @actor != actor
        self.contents.clear
        bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
        bx = (self.width / 2) - bitmap.width / 2
        by = (self.height / 2) - bitmap.height / 2
        self.contents.blt(bx, by, bitmap, bitmap.rect, 196)
        self.contents.draw_text(4, 4 + 0, 196, 18, "价格:" + actor.price.to_s)
        self.contents.draw_text(4, 4 + 20, 196, 18, "姓名:" + actor.name)
        self.contents.draw_text(4, 4 + 40, 196, 18, "职业:" + actor.class_name)
        self.contents.draw_text(4, 4 + 60, 196, 18, "武器:#{$data_weapons[actor.weapon_id].name}")
        self.contents.draw_text(4, 4 + 80, 196, 18, "铠甲:#{$data_armors[actor.armor3_id].name}")
        self.contents.draw_text(4, 4 + 100, 196, 18, "攻击力:#{actor.atk}")
        self.contents.draw_text(4, 4 + 120, 196, 18, "防御力:#{actor.pdef}")
        self.contents.draw_text(4, 4 + 140, 196, 18, "魔御力:#{actor.mdef}")
        self.contents.draw_text(4, 4 + 160, 196, 18, "力量:#{actor.str}")
        self.contents.draw_text(4, 4 + 180, 196, 18, "灵巧:#{actor.dex}")
        self.contents.draw_text(4, 4 + 200, 196, 18, "速度:#{actor.agi}")
        self.contents.draw_text(4, 4 + 220, 196, 18, "魔力:#{actor.int}")
        @actor = actor
      end
    end
  end
  class Window_ShopCommand < Window_Selectable
    #--------------------------------------------------------------------------
    # ● 初始化对像
    #--------------------------------------------------------------------------
    def initialize
      super(80, 90 - 64, 480, 64)
      self.contents = Bitmap.new(width - 32, height - 32)
      @item_max = 3
      @column_max = 3
      @commands = ["雇佣", "解除", "取消"]
      refresh
      self.index = 0
    end
    #--------------------------------------------------------------------------
    # ● 刷新
    #--------------------------------------------------------------------------
    def refresh
      self.contents.clear
      for i in 0...@item_max
        draw_item(i)
      end
    end
    #--------------------------------------------------------------------------
    # ● 描绘项目
    #     index : 项目编号
    #--------------------------------------------------------------------------
    def draw_item(index)
      x = 4 + index * 160
      self.contents.draw_text(x, 0, 128, 32, @commands[index])
    end
  end
  class Window_Mercenaries < ::Window_Selectable
    attr_reader   :column_max
    attr_reader   :item_max
    attr_reader   :mercenaries
    def initialize(mercenaries)
      super(80, 90, 480, 320)
      @mercenaries = mercenaries
      @column_max = 7
      refresh
      self.index = 0
    end
    def set_mercenaries(mercenaries)
      @mercenaries = mercenaries
      refresh
    end
    def id
      return @mercenaries[self.index]
    end
    def refresh
      if self.contents != nil
        self.contents.dispose
        self.contents = nil
      end
      @item_max = @mercenaries.size
      if @item_max > 0
        self.contents = Bitmap.new(width - 32, row_max * 80)
        for i in 0...@item_max
          draw_actor(i)
        end
      end
    end
    def draw_actor(index)
      x = 4 + (index % @column_max * 64)
      y = 4 + (index / @column_max * 80)
      actor = $game_actors[@mercenaries[index]]
      bitmap = RPG::Cache.character(actor.character_name,actor.character_hue)
      rect = bitmap.rect
      rect.width /= 4
      rect.height /= 4
      self.contents.blt(x, y, bitmap, rect)
      self.contents.font.size = 12
      self.contents.draw_text(x, y + 64 - 8, 64, 16, actor.name)
      self.contents.font.size = 9
      self.contents.draw_text(x + 4, y + 64 - 16, 64, 9, "Lv."+sprintf("%02d", actor.level))
    end
    #--------------------------------------------------------------------------
    # ● 更新光标举行
    #--------------------------------------------------------------------------
    def update_cursor_rect
      # 光标位置不满 0 的情况下
      if @index < 0
        self.cursor_rect.empty
        return
      end
      # 获取当前的行
      row = @index / @column_max
      # 当前行被显示开头行前面的情况下
      if row < self.top_row
        # 从当前行向开头行滚动
        self.top_row = row
      end
      # 当前行被显示末尾行之后的情况下
      if row > self.top_row + (self.page_row_max - 1)
        # 从当前行向末尾滚动
        self.top_row = row - (self.page_row_max - 1)
      end
      # 计算光标的宽
      cursor_width = self.width / @column_max - 32
      # 计算光标坐标
      x = @index % @column_max * 64
      y = @index / @column_max * 80 - self.oy
      # 更新国标矩形
      self.cursor_rect.set(x, y, 64, 80)
    end
  end
  class Scene_Mercenaries
    def initialize(mercenaries)
      @mercenaries = mercenaries
      for actor in $game_party.actors
        if @mercenaries.include?(actor.id)
          @mercenaries.delete(actor.id)
        end
      end
      @windows = []
      @temp = @mercenaries.dup
      @type = -1
    end
    def main_start
      make_window
      @spriteset = Spriteset_Map.new
    end
    def main_loop
      while $scene == self
        rm_update
        input_update
        update_window
      end
    end
    def main_end
      dispose_window
      @spriteset.dispose
    end
    def main
      main_start
      Graphics.transition
      main_loop
      Graphics.freeze
      main_end
    end
    def make_window
      @window_shopcommand = Window_ShopCommand.new
      @window_help = Window_Help.new
      @window_mercenaries = Window_Mercenaries.new(@mercenaries)
      @window_mercenaries.active = false
      @window_mercenaries.index = -1
      wx = (@window_mercenaries.index % @window_mercenaries.column_max * 64)
      wy = (@window_mercenaries.index / @window_mercenaries.column_max * 80)
      @window_help.x = wx + @window_mercenaries.x + 64
      @window_help.y = wy + @window_mercenaries.y + 80
      @window_gold = Window_Gold.new
      @window_gold.x = 640 - @window_gold.width - 32
      @window_gold.y = 480 - @window_gold.height - 32
      @windows << @window_gold << @window_shopcommand << @window_mercenaries << @window_help
      @window_help.visible = false
    end
    def update_window
      @windows.each{ |window|window.update }
      help_update
    end
    def dispose_window
      @windows.each{ |window|window.dispose }
    end
    def help_update
      if @window_mercenaries.active
        @window_help.visible = true
        wx = (@window_mercenaries.index % @window_mercenaries.column_max * 64)
        wy = (@window_mercenaries.index / @window_mercenaries.column_max * 80)
        @window_help.x = wx + @window_mercenaries.x + 64
        @window_help.y = wy + @window_mercenaries.y + 80
        if @window_help.x + @window_help.width > 640
          @window_help.x = 640 - @window_help.width
        end
        if @window_help.y + @window_help.height > 480
          @window_help.y = 480 - @window_help.height
        end
        @window_help.draw_actor($game_actors[@window_mercenaries.id])
      else
        @window_help.visible = false
      end
    end
    def input_update
      if Input.trigger?(Input::B)
        @type = -1
        @window_shopcommand.active = true
        @window_mercenaries.active = false
        @window_mercenaries.index = -1
        return
      end
      if Input.trigger?(Input::C)
        if @window_shopcommand.active
          case @window_shopcommand.index
          when 0
            @window_mercenaries.set_mercenaries(@temp)
            @type = 0
            @window_shopcommand.active = false
            @window_mercenaries.active = true
            @window_mercenaries.index = 0
            return
          when 1
            actors = []
            for actor in $game_party.actors
              actors << actor.id
            end
            @window_mercenaries.set_mercenaries(actors)
            @type = 1
            @window_shopcommand.active = false
            @window_mercenaries.active = true
            @window_mercenaries.index = 0
            return
          when 2
            $scene = Scene_Map.new
            return
          end
        end
        case @type
        when 0
          if $game_party.gold >= $game_actors[@window_mercenaries.id].price
            if $game_party.actors.size < 4
              $game_party.lose_gold($game_actors[@window_mercenaries.id].price)
              $game_party.add_actor(@window_mercenaries.id)
              @window_mercenaries.mercenaries.delete(@window_mercenaries.id)
              @window_mercenaries.refresh
              if @window_mercenaries.index > @window_mercenaries.mercenaries.size-1
                @window_mercenaries.index = @window_mercenaries.mercenaries.size-1
              end
            end
          end
        when 1
          if @window_mercenaries.id != 1
            $game_party.gain_gold($game_actors[@window_mercenaries.id].price / 2)
            $game_party.remove_actor(@window_mercenaries.id)
            @temp << @window_mercenaries.id
            @window_mercenaries.mercenaries.delete(@window_mercenaries.id)
            @window_mercenaries.refresh
            if @window_mercenaries.index > @window_mercenaries.mercenaries.size-1
              @window_mercenaries.index = @window_mercenaries.mercenaries.size-1
            end
          end
        end
        @window_gold.refresh
      end
    end
    def rm_update
      Graphics.update
      Input.update
    end
  end
end
class Game_Actor
  def price
    price = @name.split(/,/)[1].nil? ? 0 : @name.split(/,/)[1].to_i
    return price * self.level
  end
  def name
    return @name.split(/,/)[0]
  end
end
class Game_System
  attr_reader   :mercenaries
  alias old_initialize initialize
  def initialize
    old_initialize
    @mercenaries = {}
  end
end

Lv1.梦旅人

不画画就死星人

梦石
0
星屑
164
在线时间
1818 小时
注册时间
2007-6-14
帖子
3219
2
发表于 2010-7-9 09:37:20 | 只看该作者
if $game_party.gold >= $game_actors[@window_mercenaries.id].price 金钱判断
   end         其对应的结束句
$game_party.lose_gold($game_actors[@window_mercenaries.id].price)  金钱操作
$game_party.gain_gold($game_actors[@window_mercenaries.id].price / 2)同上
这几行注释掉
如果不想显示金钱窗口,就把
@window_gold = Window_Gold.new
      @window_gold.x = 640 - @window_gold.width - 32
      @window_gold.y = 480 - @window_gold.height - 32
也注释掉
。。手头没有RM,不能保证完全正确

评分

参与人数 1星屑 +500 收起 理由
「旅」 + 500 认可答案

查看全部评分

渣绘关注慎重
[url=http://www.pixiv.net/member.php?id=1160389][color=DimGray]http://www.pixiv.net/member.php?id=1160389[/color][/url]
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
90
在线时间
6 小时
注册时间
2010-7-9
帖子
40
3
 楼主| 发表于 2010-7-9 09:38:48 | 只看该作者
拜谢!
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-9 17:22

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表