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

Project1

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

[已经过期] 如何稍微修改这个选择角色的脚本

[复制链接]

Lv1.梦旅人

梦石
0
星屑
55
在线时间
7 小时
注册时间
2015-8-14
帖子
5
跳转到指定楼层
1
发表于 2015-8-17 19:47:49 | 只看该作者 |只看大图 回帖奖励 |正序浏览 |阅读模式

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

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

x
原脚本网址: http://www.atelier-rgss.com/RGSS/Menu/VX_Menu07.html

RUBY 代码复制
  1. #==============================================================================
  2. # MOG VX - Character Select V1.0
  3. #==============================================================================
  4. # By Moghunter
  5. # [url]http://www.atelier-rgss.com/[/url]
  6. #==============================================================================
  7. # Scene de seleção de personagens.
  8. #==============================================================================
  9. # 1 - Crie uma pasta com o nome MENUS. (GRAPHICS/MENUS)
  10. # 2 - Deverão conter as seguintes imagens nesta pasta.
  11. #
  12. # Background
  13. # Char_Layout01
  14. # Char_Layout02
  15. # Char_Status_Layout
  16. #
  17. # 3 - Será necessário ter o arquivo Number_Char.png na pasta (GRAPHICS/SYSTEM)
  18. # 4 - Além destes arquivos você deverá ter as imagens dos personagens.
  19. # Você deverá nomear as imagens da seguinte forma.
  20. #
  21. # Nome_do_personagem + _picture
  22. #
  23. # Exemplo:
  24. #
  25. # Ralph_picture.png
  26. #
  27. # Grave a imagem na pasta (GRAPHICS/MENUS)
  28. #
  29. # 5 - Para chamar o script use o seguinte comando.
  30. #
  31. # $scene = Scene_Character_Select.new
  32. #
  33. #==============================================================================
  34. # ** Window_Base
  35. #==============================================================================
  36. class Window_Base < Window
  37.   #--------------------------------------------------------------------------
  38.   # ● draw_picture_number(x,y,value,file_name,align, space, frame_max ,frame_index)     
  39.   #--------------------------------------------------------------------------
  40.   # X - Posição na horizontal
  41.   # Y - Posição na vertical
  42.   # VALUE - Valor Numérico
  43.   # FILE_NAME - Nome do arquivo
  44.   # ALIGN - Centralizar 0 - Esquerda 1- Centro 2 - Direita  
  45.   # SPACE - Espaço entre os números.
  46.   # FRAME_MAX - Quantidade de quadros(Linhas) que a imagem vai ter.
  47.   # FRAME_INDEX - Definição do quadro a ser utilizado.
  48.   #--------------------------------------------------------------------------  
  49.   def draw_picture_number(x,y,value, file_name,align = 0, space = 0, frame_max = 1,frame_index = 0)     
  50.      number_image = Cache.system(file_name)
  51.      frame_max = 1 if frame_max < 1
  52.      frame_index = frame_max -1 if frame_index > frame_max -1
  53.      align = 2 if align > 2
  54.      cw = number_image.width / 10
  55.      ch = number_image.height / frame_max
  56.      h = ch * frame_index
  57.      number = value.abs.to_s.split(//)
  58.      case align
  59.         when 0
  60.            plus_x = (-cw + space) * number.size
  61.         when 1
  62.            plus_x = (-cw + space) * number.size
  63.            plus_x /= 2
  64.         when 2  
  65.            plus_x = 0
  66.      end
  67.      for r in 0..number.size - 1      
  68.          number_abs = number[r].to_i
  69.          number_rect = Rect.new(cw * number_abs, h, cw, ch)
  70.          self.contents.blt(plus_x + x + ((cw - space) * r), y , number_image, number_rect)        
  71.      end      
  72.    end
  73.   #--------------------------------------------------------------------------
  74.   # draw_char_window_status  
  75.   #--------------------------------------------------------------------------  
  76.   def draw_char_window_status(x,y)
  77.     image = Cache.menu("Char_Status_Layout")   
  78.     cw = image.width  
  79.     ch = image.height
  80.     src_rect = Rect.new(0, 0, cw, ch)   
  81.     self.contents.blt(x , y , image, src_rect)     
  82.   end     
  83. end  
  84. #==============================================================================
  85. # ** Window_Character_Status
  86. #==============================================================================
  87. class Window_Character_Status < Window_Base
  88.   attr_accessor :index
  89.   #--------------------------------------------------------------------------
  90.   # * initialize
  91.   #--------------------------------------------------------------------------
  92.   def initialize(actor)
  93.     super(0, 0, 400, 130)
  94.     self.opacity = 0
  95.     actor_id = []
  96.     @index = actor
  97.     for i in 1...$data_actors.size
  98.       actor_id.push($game_actors[i])
  99.     end
  100.     @actor = actor_id[actor -1]
  101.     refresh
  102.   end
  103.   #--------------------------------------------------------------------------
  104.   # * Refresh
  105.   #--------------------------------------------------------------------------
  106.   def refresh
  107.     self.contents.clear
  108.     self.contents.font.bold = true
  109.     self.contents.font.italic = true
  110.     draw_char_window_status(0, 6)   
  111.     draw_actor_face(@actor, 0, 0)
  112.     draw_actor_name(@actor, 140, -5)
  113.     draw_actor_class(@actor, 60, 70)   
  114.     draw_picture_number(155,20,@actor.maxhp, "Number_char",1)   
  115.     draw_picture_number(145,48,@actor.maxmp, "Number_char",1)   
  116.     draw_picture_number(228,28,@actor.atk, "Number_char",1)   
  117.     draw_picture_number(297,28,@actor.def, "Number_char",1)  
  118.     draw_picture_number(207,68,@actor.spi, "Number_char",1)  
  119.     draw_picture_number(277,68,@actor.agi, "Number_char",1)  
  120.   end
  121. end
  122.  
  123. #==============================================================================
  124. # ** Cache
  125. #==============================================================================
  126. module Cache
  127.   #--------------------------------------------------------------------------
  128.   # Menu
  129.   #--------------------------------------------------------------------------  
  130.   def self.menu(filename)
  131.     load_bitmap("Graphics/Menus/", filename)
  132.   end  
  133. end  
  134. #==============================================================================
  135. # ** Scene Character Select
  136. #==============================================================================
  137. class Scene_Character_Select < Scene_Base
  138.   #--------------------------------------------------------------------------
  139.   # * initialize
  140.   #--------------------------------------------------------------------------
  141.   def initialize
  142.       @char_index = 1
  143.       @char_max = $data_actors.size - 1
  144.       @pw_x = 300
  145.       @aw_x = 200     
  146.       @nw_x = 100         
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # * Start
  150.   #--------------------------------------------------------------------------
  151.   def start
  152.     super
  153.     create_layout
  154.     create_window_status
  155.     create_char_image
  156.     reset_position(0)      
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # * create_background
  160.   #--------------------------------------------------------------------------   
  161.   def create_layout
  162.       @background = Plane.new  
  163.       @background.bitmap = Cache.menu("Background")
  164.       @background.z = 0
  165.       @layout_01 = Sprite.new  
  166.       @layout_01.bitmap = Cache.menu("Char_Layout01")
  167.       @layout_01.z = 10      
  168.       @layout_02 = Sprite.new  
  169.       @layout_02.bitmap = Cache.menu("Char_Layout02")
  170.       @layout_02.blend_type = 1
  171.       @layout_02.z = 1  
  172.   end  
  173.   #--------------------------------------------------------------------------
  174.   # * create_window_status
  175.   #--------------------------------------------------------------------------  
  176.   def create_window_status
  177.     @window_status = []
  178.     for i in 1...$data_actors.size
  179.         @window_status[i] = Window_Character_Status.new(i)
  180.         @window_status[i].z = 7
  181.     end
  182.         check_active_window
  183.   end  
  184.   #--------------------------------------------------------------------------
  185.   # * create_window_status
  186.   #--------------------------------------------------------------------------  
  187.   def create_char_image
  188.  
  189.       @actor_picture = []
  190.       actor_id = []
  191.       for i in 1...$data_actors.size
  192.           actor_id.push($game_actors[i])
  193.           actor = actor_id[i - 1]
  194.           @actor_picture[i] = Sprite.new
  195.           @actor_picture[i].bitmap = Cache.menu(actor.name + "_Picture")
  196.       end   
  197.       check_active_picture
  198.   end
  199.   #--------------------------------------------------------------------------
  200.   # * check_active_window
  201.   #--------------------------------------------------------------------------   
  202.   def check_active_window
  203.      for i in 1...$data_actors.size
  204.         @pw = @char_index - 1
  205.         @pw = 1 if @pw > @char_max
  206.         @pw_y = 32
  207.         @pw = @char_max if @pw < 1
  208.         @aw = @char_index
  209.         @aw_y = 160
  210.         @nw = @char_index + 1
  211.         @nw = 1 if @nw > @char_max
  212.         @nw = @char_max if @nw < 1
  213.         @nw_y = 288
  214.         case @window_status[i].index
  215.             when @pw,@aw,@nw
  216.                  @window_status[i].visible = true
  217.             else
  218.                  @window_status[i].visible = false
  219.         end
  220.       end  
  221.   end   
  222.   #--------------------------------------------------------------------------
  223.   # * check_active_picture  
  224.   #--------------------------------------------------------------------------   
  225.   def check_active_picture  
  226.       for i in 1...$data_actors.size     
  227.         case @window_status[i].index
  228.             when @pw,@aw,@nw
  229.                  @actor_picture[i].visible = true
  230.                  @actor_picture[@pw].z = 4
  231.                  @actor_picture[@aw].z = 6   
  232.                  @actor_picture[@nw].z = 4      
  233.                  @actor_picture[@pw].opacity = 120
  234.                  @actor_picture[@aw].opacity = 255
  235.                  @actor_picture[@nw].opacity = 120            
  236.             else
  237.                  @actor_picture[i].visible = false
  238.         end     
  239.       end
  240.   end      
  241.   #--------------------------------------------------------------------------
  242.   # * pre_terminate
  243.   #--------------------------------------------------------------------------
  244.   def pre_terminate
  245.     super
  246.     RPG::BGM.fade(2500)
  247.     Graphics.fadeout(60)
  248.     Graphics.wait(40)
  249.     RPG::BGM.stop
  250.   end  
  251.   #--------------------------------------------------------------------------
  252.   # * terminate
  253.   #--------------------------------------------------------------------------
  254.   def terminate
  255.     super
  256.     for i in 1...$data_actors.size
  257.         @window_status[i].dispose
  258.         @actor_picture[i].bitmap.dispose
  259.         @actor_picture[i].dispose        
  260.     end   
  261.     @background.bitmap.dispose
  262.     @background.dispose
  263.     @layout_01.bitmap.dispose   
  264.     @layout_01.dispose
  265.     @layout_02.bitmap.dispose   
  266.     @layout_02.dispose   
  267.   end
  268.   #--------------------------------------------------------------------------
  269.   # * update
  270.   #--------------------------------------------------------------------------
  271.   def update
  272.     super
  273.     @background.ox += 1
  274.     update_select
  275.     update_slide_window
  276.     update_slide_image
  277.   end
  278.   #--------------------------------------------------------------------------
  279.   # * update_slide_window
  280.   #--------------------------------------------------------------------------  
  281.   def update_slide_window
  282.       @window_status[@aw].x += 1 if @window_status[@aw].x < 0
  283.       @window_status[@nw].x -= 2 if @window_status[@nw].x > -30
  284.       @window_status[@pw].x -= 2 if @window_status[@pw].x > -30
  285.       slide_window_y(@pw,@pw_y)
  286.       slide_window_y(@aw,@aw_y)
  287.       slide_window_y(@nw,@nw_y)
  288.   end
  289.   #--------------------------------------------------------------------------
  290.   # * update_slide_image   
  291.   #--------------------------------------------------------------------------  
  292.   def update_slide_image   
  293.       slide_picture_x(@pw,@pw_x,15)
  294.       slide_picture_x(@aw,@aw_x,5)
  295.       slide_picture_x(@nw,@nw_x,15)
  296.   end
  297.   #--------------------------------------------------------------------------
  298.   # * slide_picture_x
  299.   #--------------------------------------------------------------------------   
  300.   def slide_picture_x(i,x_pos,speed)
  301.       if @actor_picture[i].x < x_pos
  302.          @actor_picture[i].x += speed
  303.          @actor_picture[i].x = x_pos if @actor_picture[i].x > x_pos
  304.       end  
  305.       if @actor_picture[i].x > x_pos
  306.          @actor_picture[i].x -= speed
  307.          @actor_picture[i].x = x_pos if @actor_picture[i].x < x_pos        
  308.        end            
  309.   end     
  310.   #--------------------------------------------------------------------------
  311.   # * slide_window_y
  312.   #--------------------------------------------------------------------------   
  313.   def slide_window_y(i,y_pos)
  314.       if @window_status[i].y < y_pos
  315.          @window_status[i].y += 15
  316.          @window_status[i].y = y_pos if @window_status[i].y > y_pos
  317.       end  
  318.       if @window_status[i].y > y_pos
  319.          @window_status[i].y -= 15
  320.          @window_status[i].y = y_pos if @window_status[i].y < y_pos        
  321.        end            
  322.   end   
  323.   #--------------------------------------------------------------------------
  324.   # * reset_position
  325.   #--------------------------------------------------------------------------     
  326.   def reset_position(diretion)
  327.       check_active_window
  328.       check_active_picture
  329.       case diretion
  330.          when 0
  331.             @window_status[@pw].y = -64
  332.             @actor_picture[@pw].x = 100
  333.          when 1  
  334.             @window_status[@nw].y = 440
  335.             @actor_picture[@nw].x = 400
  336.       end        
  337.   end  
  338.   #--------------------------------------------------------------------------
  339.   # * update_select
  340.   #--------------------------------------------------------------------------
  341.   def update_select
  342.      if Input.trigger?(Input::DOWN) or Input.trigger?(Input::LEFT)
  343.         Sound.play_cursor
  344.         @char_index += 1
  345.         @char_index = 1 if @char_index > @char_max
  346.         if @char_max < 3         
  347.            reset_position(0)
  348.         else  
  349.            reset_position(1)
  350.         end   
  351.      elsif Input.trigger?(Input::UP) or Input.trigger?(Input::RIGHT)
  352.         Sound.play_cursor
  353.         @char_index -= 1
  354.         @char_index = @char_max if @char_index < 1
  355.         reset_position(0)
  356.      elsif Input.trigger?(Input::C)     
  357.         Sound.play_decision
  358.         $game_party.add_actor(@char_index)
  359.         $scene = Scene_Map.new
  360.      end
  361.   end
  362. end  
  363.  
  364. $mog_rgssvx_character_select = true


这是原脚本的选择图画


而这个脚本是从$data.actor.size有多少就能选多少人物
假设有6个人物设置 他就会让你从6个中挑一个当主角


那如果今天我想设置 从3号~5号 三个人物中挑一个当主角
该怎么设定啊 我老是失败
请各位大神救救{:2_270:}

Lv1.梦旅人

梦石
0
星屑
55
在线时间
7 小时
注册时间
2015-8-14
帖子
5
3
 楼主| 发表于 2015-8-18 11:21:09 | 只看该作者
回覆上面的大大:

改完之后出现了这个问题



这是什么意思呢 ( 我的角色头像都有放

麻烦大大了
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
898
在线时间
421 小时
注册时间
2015-7-5
帖子
131
2
发表于 2015-8-17 22:37:46 | 只看该作者
把97行for i in 1...$data_actors.size 改成 for i in 3...6大概就可以了。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-21 17:40

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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