Project1

标题: 人口贩卖(雇佣兵系统)名字出错? [打印本页]

作者: XM.YF.D    时间: 2012-10-21 00:34
标题: 人口贩卖(雇佣兵系统)名字出错?
不知道为什么在别的Project 就行,可是我正在制作住的就不行啊?


‘‘──XM.YF.D于2012-10-21 00:35补充以下内容:

看不看到图?
’’
作者: XM.YF.D    时间: 2012-10-21 00:37
C:\Users\黄\Desktop\X\QQ拼音截图未命名.jpg
作者: XM.YF.D    时间: 2012-10-21 00:40
https://rpg.blue/forum.php?mod=attachment&aid=MTM5NjU3fGQ4MjZlMWI5MWY2NDk2ZmE1OTU2ODg1YTVhNzIwNmUwfDE3Mjc2NjM0NDI%3D&request=yes&_f=.jpg

QQ拼音截图未命名.jpg (14.97 KB, 下载次数: 6)

QQ拼音截图未命名.jpg

作者: zxcgood2009    时间: 2012-10-21 15:20
把脚本贴出来
作者: XM.YF.D    时间: 2012-10-22 05:54
本帖最后由 hys111111 于 2012-10-23 12:48 编辑
  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, "precio:" + actor.price.to_s)
  18.         self.contents.draw_text(4, 4 + 20, 196, 18, "nombre:" + actor.name)
  19.         self.contents.draw_text(4, 4 + 40, 196, 18, "tipo:" + actor.class_name)
  20.         self.contents.draw_text(4, 4 + 60, 196, 18, "arma:#{$data_weapons[actor.weapon_id].name}")
  21.         self.contents.draw_text(4, 4 + 80, 196, 18, "armadura:#{$data_armors[actor.armor3_id].name}")
  22.         self.contents.draw_text(4, 4 + 100, 196, 18, "atk:#{actor.atk}")
  23.         self.contents.draw_text(4, 4 + 120, 196, 18, "defa:#{actor.pdef}")
  24.         self.contents.draw_text(4, 4 + 140, 196, 18, "defm:#{actor.mdef}")
  25.         self.contents.draw_text(4, 4 + 160, 196, 18, "poder:#{actor.str}")
  26.         self.contents.draw_text(4, 4 + 180, 196, 18, "movimientos:#{actor.dex}")
  27.         self.contents.draw_text(4, 4 + 200, 196, 18, "velocidad:#{actor.agi}")
  28.         self.contents.draw_text(4, 4 + 220, 196, 18, "magia:#{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 = ["+persona", "qitar", "cancelar"]
  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 @mercenaries[self.index]
  81.     end
  82.     def refresh
  83.       if self.contents != nil
  84.         self.contents.dispose
  85.         self.contents = nil
  86.       end
  87.       @item_max = @mercenaries.size
  88.       if @item_max > 0
  89.         self.contents = Bitmap.new(width - 32, row_max * 80)
  90.         for i in 0...@item_max
  91.           draw_actor(i)
  92.         end
  93.       end
  94.     end
  95.     def draw_actor(index)
  96.       x = 4 + (index % @column_max * 64)
  97.       y = 4 + (index / @column_max * 80)
  98.       actor = $game_actors[@mercenaries[index]]
  99.       bitmap = RPG::Cache.character(actor.character_name,actor.character_hue)
  100.       rect = bitmap.rect
  101.       rect.width /= 4
  102.       rect.height /= 4
  103.       self.contents.blt(x, y, bitmap, rect)
  104.       self.contents.font.size = 12
  105.       self.contents.draw_text(x, y + 64 - 8, 64, 16, actor.name)
  106.       self.contents.font.size = 9
  107.       self.contents.draw_text(x + 4, y + 64 - 16, 64, 9, "Lv."+sprintf("%02d", actor.level))
  108.     end
  109.     #--------------------------------------------------------------------------
  110.     # ● 更新光标举行
  111.     #--------------------------------------------------------------------------
  112.     def update_cursor_rect
  113.       # 光标位置不满 0 的情况下
  114.       if @index < 0
  115.         self.cursor_rect.empty
  116.         return
  117.       end
  118.       # 获取当前的行
  119.       row = @index / @column_max
  120.       # 当前行被显示开头行前面的情况下
  121.       if row < self.top_row
  122.         # 从当前行向开头行滚动
  123.         self.top_row = row
  124.       end
  125.       # 当前行被显示末尾行之后的情况下
  126.       if row > self.top_row + (self.page_row_max - 1)
  127.         # 从当前行向末尾滚动
  128.         self.top_row = row - (self.page_row_max - 1)
  129.       end
  130.       # 计算光标的宽
  131.       cursor_width = self.width / @column_max - 32
  132.       # 计算光标坐标
  133.       x = @index % @column_max * 64
  134.       y = @index / @column_max * 80 - self.oy
  135.       # 更新国标矩形
  136.       self.cursor_rect.set(x, y, 64, 80)
  137.     end
  138.   end
  139.   class Scene_Mercenaries
  140.     def initialize(mercenaries)
  141.       @mercenaries = mercenaries
  142.       for actor in $game_party.actors
  143.         if @mercenaries.include?(actor.id)
  144.           @mercenaries.delete(actor.id)
  145.         end
  146.       end
  147.       @windows = []
  148.       @temp = @mercenaries.dup
  149.       @type = -1
  150.     end
  151.     def main_start
  152.       make_window
  153.       @spriteset = Spriteset_Map.new
  154.     end
  155.     def main_loop
  156.       while $scene == self
  157.         rm_update
  158.         input_update
  159.         update_window
  160.       end
  161.     end
  162.     def main_end
  163.       dispose_window
  164.       @spriteset.dispose
  165.     end
  166.     def main
  167.       main_start
  168.       Graphics.transition
  169.       main_loop
  170.       Graphics.freeze
  171.       main_end
  172.     end
  173.     def make_window
  174.       @window_shopcommand = Window_ShopCommand.new
  175.       @window_help = Window_Help.new
  176.       @window_mercenaries = Window_Mercenaries.new(@mercenaries)
  177.       @window_mercenaries.active = false
  178.       @window_mercenaries.index = -1
  179.       wx = (@window_mercenaries.index % @window_mercenaries.column_max * 64)
  180.       wy = (@window_mercenaries.index / @window_mercenaries.column_max * 80)
  181.       @window_help.x = wx + @window_mercenaries.x + 64
  182.       @window_help.y = wy + @window_mercenaries.y + 80
  183.       @window_gold = Window_Gold.new
  184.       @window_gold.x = 640 - @window_gold.width - 32
  185.       @window_gold.y = 480 - @window_gold.height - 32
  186.       @windows << @window_gold << @window_shopcommand << @window_mercenaries << @window_help
  187.       @window_help.visible = false
  188.     end
  189.     def update_window
  190.       @windows.each{ |window|window.update }
  191.       help_update
  192.     end
  193.     def dispose_window
  194.       @windows.each{ |window|window.dispose }
  195.     end
  196.     def help_update
  197.       if @window_mercenaries.active
  198.         @window_help.visible = true
  199.         wx = (@window_mercenaries.index % @window_mercenaries.column_max * 64)
  200.         wy = (@window_mercenaries.index / @window_mercenaries.column_max * 80)
  201.         @window_help.x = wx + @window_mercenaries.x + 64
  202.         @window_help.y = wy + @window_mercenaries.y + 80
  203.         if @window_help.x + @window_help.width > 640
  204.           @window_help.x = 640 - @window_help.width
  205.         end
  206.         if @window_help.y + @window_help.height > 480
  207.           @window_help.y = 480 - @window_help.height
  208.         end
  209.         @window_help.draw_actor($game_actors[@window_mercenaries.id])
  210.       else
  211.         @window_help.visible = false
  212.       end
  213.     end
  214.     def input_update
  215.       if Input.trigger?(Input::B)
  216.         @type = -1
  217.         @window_shopcommand.active = true
  218.         @window_mercenaries.active = false
  219.         @window_mercenaries.index = -1
  220.         return
  221.       end
  222.       if Input.trigger?(Input::C)
  223.         if @window_shopcommand.active
  224.           case @window_shopcommand.index
  225.           when 0
  226.             @window_mercenaries.set_mercenaries(@temp)
  227.             @type = 0
  228.             @window_shopcommand.active = false
  229.             @window_mercenaries.active = true
  230.             @window_mercenaries.index = 0
  231.             return
  232.           when 1
  233.             actors = []
  234.             for actor in $game_party.actors
  235.               actors << actor.id
  236.             end
  237.             @window_mercenaries.set_mercenaries(actors)
  238.             @type = 1
  239.             @window_shopcommand.active = false
  240.             @window_mercenaries.active = true
  241.             @window_mercenaries.index = 0
  242.             return
  243.           when 2
  244.             $scene = Scene_Map.new
  245.             return
  246.           end
  247.         end
  248.         case @type
  249.         when 0
  250.           if $game_party.gold >= $game_actors[@window_mercenaries.id].price
  251.             if $game_party.actors.size < 4
  252.               $game_party.lose_gold($game_actors[@window_mercenaries.id].price)
  253.               $game_party.add_actor(@window_mercenaries.id)
  254.               @window_mercenaries.mercenaries.delete(@window_mercenaries.id)
  255.               @window_mercenaries.refresh
  256.               if @window_mercenaries.index > @window_mercenaries.mercenaries.size-1
  257.                 @window_mercenaries.index = @window_mercenaries.mercenaries.size-1
  258.               end
  259.             end
  260.           end
  261.         when 1
  262.           if @window_mercenaries.id != 1
  263.             $game_party.gain_gold($game_actors[@window_mercenaries.id].price / 2)
  264.             $game_party.remove_actor(@window_mercenaries.id)
  265.             @temp << @window_mercenaries.id
  266.             @window_mercenaries.mercenaries.delete(@window_mercenaries.id)
  267.             @window_mercenaries.refresh
  268.             if @window_mercenaries.index > @window_mercenaries.mercenaries.size-1
  269.               @window_mercenaries.index = @window_mercenaries.mercenaries.size-1
  270.             end
  271.           end
  272.         end
  273.         @window_gold.refresh
  274.       end
  275.     end
  276.     def rm_update
  277.       Graphics.update
  278.       Input.update
  279.     end
  280.   end
  281. end
  282. class Game_Actor
  283.   def price
  284.     price = @name.split(/,/)[1].nil? ? 0 : @name.split(/,/)[1].to_i
  285.     return price * self.level
  286.   end
  287.   def name
  288.     return @name.split(/,/)[0]
  289.   end
  290. end
  291. class Game_System
  292.   attr_reader   :mercenaries
  293.   alias old_initialize initialize
  294.   def initialize
  295.     old_initialize
  296.     @mercenaries = {}
  297.   end
  298. end
复制代码
------
我只是改了 self.contents.draw_text的行 比如:武器=armas
作者: XM.YF.D    时间: 2012-10-22 05:57
@zxcgood2009  然后我就用源的试了,可是都是一样不行~~~~
作者: zxcgood2009    时间: 2012-10-22 11:29
我测试了一下,没有问题。
(你能不能把使用方法也给写出来,害我找了半天才搞定。)
你的这个应该是脚本冲突,而且我的技术也不太行,搞了半天都没弄懂这脚本为什么这样写。
你的图片上的错误提示里有一个Mercenaries,你在脚本编辑器里搜Mercenaries,看看别的脚本里有没有,如果有那脚本冲突就在那个脚本里了。
如果没有,那我就不知道了。
作者: XM.YF.D    时间: 2012-10-23 04:36
zxcgood2009 发表于 2012-10-22 11:29
我测试了一下,没有问题。
(你能不能把使用方法也给写出来,害我找了半天才搞定。)
你的这个应该是脚本冲 ...

使用方法
a = [9, 10, 11]
$scene =\
Mercenaries::\
Scene_Mercenaries.new(a)
作者: XM.YF.D    时间: 2012-10-26 01:20
有没有办法啊?




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1