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

Project1

 找回密码
 注册会员
搜索
12
返回列表 发新帖
楼主: HзO
打印 上一主题 下一主题

人口贩卖系统的BUG,雇佣兵全部买完就出错!?

 关闭 [复制链接]
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
49
在线时间
15 小时
注册时间
2008-4-8
帖子
357
11
发表于 2008-7-7 20:55:43 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
35 小时
注册时间
2008-6-23
帖子
275
12
 楼主| 发表于 2008-7-7 22:26:01 | 只看该作者
不能用空人物...如果雇佣兵价格为0也可以购买的
HзO
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
35 小时
注册时间
2008-6-23
帖子
275
13
 楼主| 发表于 2008-7-9 23:38:34 | 只看该作者
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
35 小时
注册时间
2008-6-23
帖子
275
14
 楼主| 发表于 2008-7-10 18:52:12 | 只看该作者
一天一顶
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
70
在线时间
215 小时
注册时间
2007-9-5
帖子
370
15
发表于 2008-7-10 23:04:19 | 只看该作者
这脚本其实还有别的BUG...
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-7-13
帖子
26
16
发表于 2008-7-13 17:18:23 | 只看该作者
将雇佣出来的英雄的装备换掉,再解雇回去。就会出错。{/ruo}
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
35 小时
注册时间
2008-6-23
帖子
275
17
 楼主| 发表于 2008-7-17 18:59:51 | 只看该作者
以下引用口水怪于2008-7-13 9:18:23的发言:

将雇佣出来的英雄的装备换掉,再解雇回去。就会出错。




这一点我倒解决了{/hx}
HзO
回复 支持 反对

使用道具 举报

Lv1.梦旅人

逃兵

18
发表于 2008-7-17 19:02:16 | 只看该作者
在适当位置加一句

return if ????.nil?

????请自己替换
「If you judge people, you have no time to love them.」—— Mother Teresa
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
35 小时
注册时间
2008-6-23
帖子
275
19
 楼主| 发表于 2008-7-17 19:07:25 | 只看该作者
适当位置是哪里?麻烦看看...
  1. module Mercenaries
  2. class Window_Help < ::Window_Base
  3.    def initialize
  4.      super(0, 0, 196, 256)
  5.      self.contents = Bitmap.new(width - 32, height - 32)
  6.      self.contents.font.size = 18
  7.      @actor = nil
  8.      self.z += 10
  9.    end
  10.    def draw_actor(actor)
  11.      if @actor != actor
  12.        self.contents.clear
  13.        bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
  14.        bx = (self.width / 2) - bitmap.width / 2
  15.        by = (self.height / 2) - bitmap.height / 2
  16.        self.contents.blt(bx, by, bitmap, bitmap.rect, 196)
  17.        self.contents.draw_text(4, 4 + 0, 196, 18, "价格:" + actor.price.to_s)
  18.        self.contents.draw_text(4, 4 + 20, 196, 18, "姓名:" + actor.name)
  19.        self.contents.draw_text(4, 4 + 40, 196, 18, "职业:" + actor.class_name)
  20.        self.contents.draw_text(4, 4 + 60, 196, 18, "武器:#{$data_weapons[actor.weapon_id].name}")
  21.        self.contents.draw_text(4, 4 + 80, 196, 18, "铠甲:#{$data_armors[actor.armor3_id].name}")
  22.        self.contents.draw_text(4, 4 + 100, 196, 18, "攻击力:#{actor.atk}")
  23.        self.contents.draw_text(4, 4 + 120, 196, 18, "防御力:#{actor.pdef}")
  24.        self.contents.draw_text(4, 4 + 140, 196, 18, "魔御力:#{actor.mdef}")
  25.        self.contents.draw_text(4, 4 + 160, 196, 18, "力量:#{actor.str}")
  26.        self.contents.draw_text(4, 4 + 180, 196, 18, "灵巧:#{actor.dex}")
  27.        self.contents.draw_text(4, 4 + 200, 196, 18, "速度:#{actor.agi}")
  28.        self.contents.draw_text(4, 4 + 220, 196, 18, "魔力:#{actor.int}")
  29.        @actor = actor
  30.      end
  31.    end
  32. end
  33. class Window_ShopCommand < Window_Selectable
  34.    #--------------------------------------------------------------------------
  35.    # ● 初始化对像
  36.    #--------------------------------------------------------------------------
  37.    def initialize
  38.      super(80, 90 - 64, 480, 64)
  39.      self.contents = Bitmap.new(width - 32, height - 32)
  40.      @item_max = 3
  41.      @column_max = 3
  42.      @commands = ["雇佣", "解除", "取消"]
  43.      refresh
  44.      self.index = 0
  45.    end
  46.    #--------------------------------------------------------------------------
  47.    # ● 刷新
  48.    #--------------------------------------------------------------------------
  49.    def refresh
  50.      self.contents.clear
  51.      for i in 0...@item_max
  52.        draw_item(i)
  53.      end
  54.    end
  55.    #--------------------------------------------------------------------------
  56.    # ● 描绘项目
  57.    #     index : 项目编号
  58.    #--------------------------------------------------------------------------
  59.    def draw_item(index)
  60.      x = 4 + index * 160
  61.      self.contents.draw_text(x, 0, 128, 32, @commands[index])
  62.    end
  63. end
  64. class Window_Mercenaries < ::Window_Selectable
  65.    attr_reader   :column_max
  66.    attr_reader   :item_max
  67.    attr_reader   :mercenaries
  68.    def initialize(mercenaries)
  69.      super(80, 90, 480, 320)
  70.      @mercenaries = mercenaries
  71.      @column_max = 7
  72.      refresh
  73.      self.index = 0
  74.    end
  75.    def set_mercenaries(mercenaries)
  76.      @mercenaries = mercenaries
  77.      refresh
  78.    end
  79.    def id
  80.      return if @mercenaries.to_s == ""
  81.      return @mercenaries[self.index]
  82.    end
  83.    def refresh
  84.      if self.contents != nil
  85.        self.contents.dispose
  86.        self.contents = nil
  87.      end
  88.      @item_max = @mercenaries.size
  89.      if @item_max > 0
  90.        self.contents = Bitmap.new(width - 32, row_max * 80)
  91.        for i in 0...@item_max
  92.          draw_actor(i)
  93.        end
  94.      end
  95.    end
  96.    def draw_actor(index)
  97.      return if @mercenaries.to_s == ""
  98.      x = 4 + (index % @column_max * 64)
  99.      y = 4 + (index / @column_max * 80)
  100.      actor = $game_actors[@mercenaries[index]]
  101.      bitmap = RPG::Cache.character(actor.character_name,actor.character_hue)
  102.      rect = bitmap.rect
  103.      rect.width /= 4
  104.      rect.height /= 4
  105.      self.contents.blt(x, y, bitmap, rect)
  106.      self.contents.font.size = 12
  107.      self.contents.draw_text(x, y + 64 - 8, 64, 16, actor.name)
  108.      self.contents.font.size = 9
  109.      self.contents.draw_text(x + 4, y + 64 - 16, 64, 9, "Lv."+sprintf("%02d", actor.level))
  110.    end
  111.    #--------------------------------------------------------------------------
  112.    # ● 更新光标举行
  113.    #--------------------------------------------------------------------------
  114.    def update_cursor_rect
  115.      # 光标位置不满 0 的情况下
  116.      if @index < 0
  117.        self.cursor_rect.empty
  118.        return
  119.      end
  120.      # 获取当前的行
  121.      row = @index / @column_max
  122.      # 当前行被显示开头行前面的情况下
  123.      if row < self.top_row
  124.        # 从当前行向开头行滚动
  125.        self.top_row = row
  126.      end
  127.      # 当前行被显示末尾行之后的情况下
  128.      if row > self.top_row + (self.page_row_max - 1)
  129.        # 从当前行向末尾滚动
  130.        self.top_row = row - (self.page_row_max - 1)
  131.      end
  132.      # 计算光标的宽
  133.      cursor_width = self.width / @column_max - 32
  134.      # 计算光标坐标
  135.      x = @index % @column_max * 64
  136.      y = @index / @column_max * 80 - self.oy
  137.      # 更新国标矩形
  138.      self.cursor_rect.set(x, y, 64, 80)
  139.    end
  140. end
  141. class Scene_Mercenaries
  142.    def initialize(mercenaries)
  143.      @mercenaries = mercenaries
  144.      for actor in $game_party.actors
  145.        if @mercenaries.include?(actor.id)
  146.          @mercenaries.delete(actor.id)
  147.        end
  148.      end
  149.      @windows = []
  150.      @temp = @mercenaries.dup
  151.      @type = -1
  152.    end
  153.    def main_start

  154.        make_window
  155.      
  156.      @spriteset = Spriteset_Map.new
  157.    end
  158.    def main_loop
  159.      while $scene == self
  160.        rm_update
  161.        input_update
  162.        update_window
  163.      end
  164.    end
  165.    def main_end
  166.      dispose_window
  167.      @spriteset.dispose
  168.    end
  169.    def main
  170.      main_start
  171.      Graphics.transition
  172.      main_loop
  173.      Graphics.freeze
  174.      main_end
  175.    end
  176.    def make_window
  177.      @window_shopcommand = Window_ShopCommand.new
  178.      @window_help = Window_Help.new
  179.      @window_mercenaries = Window_Mercenaries.new(@mercenaries)
  180.      @window_mercenaries.active = false
  181.      @window_mercenaries.index = -1
  182.      wx = (@window_mercenaries.index % @window_mercenaries.column_max * 64)
  183.      wy = (@window_mercenaries.index / @window_mercenaries.column_max * 80)
  184.      @window_help.x = wx + @window_mercenaries.x + 64
  185.      @window_help.y = wy + @window_mercenaries.y + 80
  186.      @window_gold = Window_Gold.new
  187.      @window_gold.x = 640 - @window_gold.width - 32
  188.      @window_gold.y = 480 - @window_gold.height - 32
  189.      @windows << @window_gold << @window_shopcommand << @window_mercenaries << @window_help
  190.      @window_help.visible = false
  191.    end
  192.    def update_window
  193.      @windows.each{ |window|window.update }
  194.      help_update
  195.    end
  196.    def dispose_window
  197.      @windows.each{ |window|window.dispose }
  198.    end
  199.    def help_update
  200.      if @window_mercenaries.active
  201.        @window_help.visible = true
  202.        wx = (@window_mercenaries.index % @window_mercenaries.column_max * 64)
  203.        wy = (@window_mercenaries.index / @window_mercenaries.column_max * 80)
  204.        @window_help.x = wx + @window_mercenaries.x + 64
  205.        @window_help.y = wy + @window_mercenaries.y + 80
  206.        if @window_help.x + @window_help.width > 640
  207.          @window_help.x = 640 - @window_help.width
  208.        end
  209.        if @window_help.y + @window_help.height > 480
  210.          @window_help.y = 480 - @window_help.height
  211.        end
  212.        @window_help.draw_actor($game_actors[@window_mercenaries.id])
  213.      else
  214.        @window_help.visible = false
  215.      end
  216.    end
  217.    def input_update
  218.      if Input.trigger?(Input::B)
  219.        @type = -1
  220.        @window_shopcommand.active = true
  221.        @window_mercenaries.active = false
  222.        @window_mercenaries.index = -1
  223.        return
  224.      end
  225.      if Input.trigger?(Input::C)
  226.        if @window_shopcommand.active
  227.          case @window_shopcommand.index
  228.          when 0
  229.            return if @temp == []
  230.            @window_mercenaries.set_mercenaries(@temp)
  231.            @type = 0
  232.            @window_shopcommand.active = false
  233.            @window_mercenaries.active = true
  234.            @window_mercenaries.index = 0
  235.            return
  236.          when 1
  237.            return if $game_party.actors == []
  238.            actors = []
  239.            for actor in $game_party.actors
  240.              actors << actor.id
  241.            end
  242.            
  243.            @window_mercenaries.set_mercenaries(actors)
  244.            @type = 1
  245.            @window_shopcommand.active = false
  246.            @window_mercenaries.active = true
  247.            @window_mercenaries.index = 0
  248.            return
  249.          when 2
  250.            $scene = Scene_Map.new
  251.            return
  252.          end
  253.        end
  254.        case @type
  255.        when 0
  256.          if $game_party.gold >= $game_actors[@window_mercenaries.id].price
  257.            if $game_party.actors.size < 4
  258.              $game_party.lose_gold($game_actors[@window_mercenaries.id].price)
  259.              $game_party.add_actor(@window_mercenaries.id)
  260.              @window_mercenaries.mercenaries.delete(@window_mercenaries.id)
  261.              @window_mercenaries.refresh
  262.              if @window_mercenaries.index > @window_mercenaries.mercenaries.size-1
  263.                @window_mercenaries.index = @window_mercenaries.mercenaries.size-1
  264.              end
  265.            end
  266.          end
  267.        when 1
  268.          if @window_mercenaries.id != 1
  269.            $game_party.gain_gold($game_actors[@window_mercenaries.id].price / 2)
  270.            $game_party.remove_actor(@window_mercenaries.id)
  271.            @temp << @window_mercenaries.id
  272.            @window_mercenaries.mercenaries.delete(@window_mercenaries.id)
  273.            @window_mercenaries.refresh
  274.            if @window_mercenaries.index > @window_mercenaries.mercenaries.size-1
  275.              @window_mercenaries.index = @window_mercenaries.mercenaries.size-1
  276.            end
  277.          end
  278.        end
  279.        @window_gold.refresh
  280.      end
  281.    end
  282.    def rm_update
  283.      Graphics.update
  284.      Input.update
  285.    end
  286. end
  287. end
  288. class Game_Actor
  289. def price
  290.    price = @name.split(/,/)[1].nil? ? 0 : @name.split(/,/)[1].to_i
  291.    return price * self.level
  292. end
  293. def name
  294.    return @name.split(/,/)[0]
  295. end
  296. end
  297. class Game_System
  298. attr_reader   :mercenaries
  299. alias old_initialize initialize
  300. def initialize
  301.    old_initialize
  302.    @mercenaries = {}
  303. end
  304. end
复制代码
HзO
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-8-9 02:02

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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