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

Project1

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

[已经解决] 这个脚本能看出支援是队伍的几号ID吗

[复制链接]

Lv4.逐梦者

梦石
0
星屑
12157
在线时间
4435 小时
注册时间
2014-4-11
帖子
5955

开拓者

跳转到指定楼层
1
发表于 2016-2-4 18:55:16 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 yang1zhi 于 2016-2-4 19:47 编辑

  if $game_party.actors[1].skill_learn?(BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)])
要找出被设置为支援模式的是几号ID,写到这条里面


RUBY 代码复制
  1. #=============================================================================#
  2. #                           ■ BFS - PartyTactics
  3. #-----------------------------------------------------------------------------#
  4. #                          战术方面(预设5种战技)
  5. #=============================================================================#
  6. module BFS_Tactics
  7.   DATA = [["攻击模式", "BFS-attacker", "负责攻击,会使用攻击技能"],
  8.           ["支援模式", "BFS-heal", "负责支援,会使用恢复技能"]]
  9.      #     ["第二控制者", "BFS-controller", "使用ESDF控制上下左右移动,Y键进行攻击来控制装配有这个战技的队友"],
  10.      #     ["坚守者", "BFS-defender", "呆在原地,用于启动机关,只攻击附近的怪物"],
  11.      #     ["探路者", "BFS-seeker", "熟悉地形的战友会给你行进的帮助"]]
  12. end
  13. # 定义几个窗口和一个场景
  14. # (主界面部分)
  15. class Window_Tactics < Window_Selectable
  16.   def initialize
  17.     super(68, 240, 240, 160)
  18.     @item_max = BFS_Tactics::DATA.size
  19.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  20.     self.opacity = 220
  21.     @column_max = 1
  22.     refresh
  23.     self.index = 0
  24.     self.z = 9999
  25.     @old_index = self.index
  26.   end
  27.   def update
  28.     super
  29.     if @old_index != self.index
  30.       @old_index = self.index
  31.       $scene.info_update(self.index)
  32.     end
  33.   end
  34.   def refresh
  35.     self.contents.clear
  36.     for i in 0...@item_max
  37.       draw_item(i)
  38.     end
  39.   end
  40.   def draw_item(index)
  41.     self.contents.font.color = normal_color
  42.     tactics_info = BFS_Tactics::DATA[index]
  43.     x = 4
  44.     y = index * 32
  45.     rect = Rect.new(x, y, self.width, 32)
  46.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  47.     bitmap = RPG::Cache.icon(tactics_info[1])
  48.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), 255)
  49.     self.contents.draw_text(x + 28, y, 204, 32, tactics_info[0], 0)
  50.   end
  51. end
  52. class Window_Character_Change < Window_Base
  53.   attr_reader   :index
  54.   def initialize
  55.     super(170, 100, 276, 128)
  56.     self.contents = Bitmap.new($game_party.actors.size * 32 + 100, height - 32)
  57.     self.opacity = 220
  58.     refresh
  59.     self.active = true
  60.     self.z = 9999
  61.     @index = 0
  62.   end
  63.   def refresh
  64.     self.contents.clear
  65.     @item_max = $game_party.actors.size
  66.     for i in 0...$game_party.actors.size
  67.       x = 64 * i + 22
  68.       y = 0
  69.       actor = $game_party.actors[i]
  70.       draw_actor_graphic(actor, x, y + 55)
  71.       draw_actor_tactics(actor, x, y + 90)
  72.     end
  73.   end
  74.   def update
  75.     super
  76.     if self.active and @index >= 0
  77.       if Input.repeat?(Input::RIGHT)
  78.         if Input.trigger?(Input::RIGHT) #or @index < @item_max
  79.           $game_system.se_play($data_system.cursor_se)
  80.           @index = (@index + 1) % @item_max
  81.         end
  82.       end
  83.       if Input.repeat?(Input::LEFT)
  84.         if Input.trigger?(Input::LEFT) #or @index >= 0
  85.           $game_system.se_play($data_system.cursor_se)
  86.           @index = (@index - 1 + @item_max) % @item_max
  87.         end
  88.       end
  89.     end
  90.     update_cursor_rect
  91.   end
  92.   def update_cursor_rect
  93.     self.cursor_rect.set(@index * 64 - 5, 0, (self.width - 32) / 4, self.height - 32)
  94.   end
  95.   def draw_actor_tactics(actor, x, y)
  96.     icon_name = (BFS_Tactics::DATA[actor.tactics_type])[1]
  97.     bitmap = RPG::Cache.icon(icon_name)
  98.     src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
  99.     self.contents.blt(x - bitmap.width / 2, y - bitmap.height, bitmap, src_rect)
  100.   end
  101. end
  102. class Window_Tactics_Info < Window_Base
  103.   def initialize
  104.     super(308, 240, 276, 160)
  105.     self.contents = Bitmap.new(width - 32, height - 32)
  106.     self.opacity = 220
  107.     self.z = 9999
  108.     refresh(0)
  109.   end
  110.   def refresh(index)
  111.     self.contents.clear
  112.     self.contents.font.color = normal_color
  113.     text = (BFS_Tactics::DATA[index])[2].clone
  114.     x = y = 0
  115.     loop do
  116.       cha_max = 11
  117.       now_text = text[0, cha_max * 3]
  118.       text.slice!(0, cha_max * 3)
  119.       break if now_text == ""
  120.       self.contents.draw_text(0, 32 * y, 300, 32, now_text)
  121.       x += cha_max * 3
  122.       y += 1
  123.     end
  124.   end
  125. end
  126. class Scene_Tactics
  127.   def main
  128.     @tactics_window = Window_Tactics.new
  129.     @character_window = Window_Character_Change.new
  130.     @tac_info_window = Window_Tactics_Info.new
  131.     @background = Spriteset_Map.new
  132.     Graphics.transition
  133.     # 主循环
  134.     loop do
  135.       # 刷新游戏画面
  136.       Graphics.update
  137.       # 刷新输入信息
  138.       Input.update
  139.       # 刷新画面
  140.       update
  141.       # 如果切换画面就中断循环
  142.       if $scene != self
  143.         break
  144.       end
  145.     end
  146.     # 准备过渡
  147.     Graphics.freeze
  148.     # 释放窗口
  149.     @tactics_window.dispose
  150.     @character_window.dispose
  151.     @tac_info_window.dispose
  152.     @background.dispose
  153.   end
  154.   def info_update(index)
  155.     @tac_info_window.refresh(index)
  156.   end  
  157.   def update
  158.     @tactics_window.update
  159.     @character_window.update
  160.     if Input.trigger?(Input::C)
  161.       $game_system.se_play($data_system.equip_se)
  162.       $game_party.actors[@character_window.index].tactics_type = @tactics_window.index
  163.       @character_window.refresh
  164.     end
  165.     if Input.trigger?(Input::B) or Kboard.trigger?(BFS_Setting::BUTTON_CALL_TACTICS)
  166.       $game_system.se_play($data_system.cancel_se)
  167.       $scene = Scene_Map.new
  168.     end
  169.   end
  170. end
  171. class Game_Friend < Game_Event
  172.   def bfs_move
  173.     return if @battler.tactics_type == 3
  174.     return move_follow if @battler.dead?
  175.     return if @stop_count < 0
  176.     return if @aimovement_stand_by
  177.     return move_follow if $game_temp.bfs_follow
  178.     case @battler.tactics_type
  179.     when 0 #攻击主力
  180.       attack_force
  181.     when 1 #支援主力
  182.       support_force
  183. #    when 2 #第二控制者
  184.       controlled_update
  185.   #  when 3 #坚守者
  186.   #    defend_force
  187. #   when 4 #探路者
  188.   #    lead_way
  189.     end
  190.   end
  191.   # --------------------------------
  192.   # 攻击主力
  193.   # --------------------------------
  194.   def attack_force
  195.       update_sensor
  196.       if @enemy_in_range == nil
  197.         case rand(10)
  198.         when 1
  199.           move_random
  200.         when 2..4
  201.           @stop_count = 0
  202.         when 5..10
  203.           move_follow
  204.         end
  205.       else
  206.         case rand(10)
  207.         when 1..4
  208.           move_toward_event($game_map.events[@enemy_in_range])
  209.           return if moving?
  210.           @stop_count = -20
  211.         when 5..7
  212.           case rand(25)
  213.           when 0..17
  214.             attack_command
  215.           when 18..24
  216.             magic_command
  217.           end
  218.           @stop_count = -20
  219.         when 9..10
  220.           move_follow
  221.         end
  222.       end
  223.     end
  224.   def controlled_update
  225.     if Kboard.press?($R_Key_E)
  226.       return unless passable?(@x, @y, 8)
  227.       turn_up
  228.       @y -= 1
  229.     end
  230.     if Kboard.press?($R_Key_D)
  231.       return unless passable?(@x, @y, 2)
  232.       turn_down
  233.       @y += 1
  234.     end
  235.     if Kboard.press?($R_Key_S)
  236.       return unless passable?(@x, @y, 4)
  237.       turn_left
  238.       @x -= 1
  239.     end
  240.     if Kboard.press?($R_Key_F)
  241.       return unless passable?(@x, @y, 6)
  242.       turn_right
  243.       @x += 1
  244.     end
  245.     if Kboard.trigger?($R_Key_Y)
  246.       attack_command
  247.     end
  248.   end
  249.   # --------------------------------
  250.   # 支援主力
  251.   # --------------------------------
  252.   def support_force
  253.     case rand(6)
  254.     when 0..4
  255.       update_sensor
  256.       return move_follow if @enemy_in_range == nil
  257.       case rand(7)
  258.       when 0..4
  259.         move_toward_event($game_map.events[@enemy_in_range])
  260.         return if moving?
  261.         @stop_count = -20
  262.       when 5..7
  263.         attack_command
  264.       end
  265.     when 5
  266.       update_hp_sensor
  267.       return move_follow if @low_hp_characters == 0
  268.  
  269.  
  270.       #队友回血
  271.  
  272.   if $game_party.actors[1].skill_learn?(BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)])
  273.       self.pop_damage_text(BFS_Setting::WORDS_CURE[rand(BFS_Setting::WORDS_CURE.size)])
  274.        self.shoot(BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)])      
  275.        #但队伍人数等于2的时候
  276.     if $game_party.actors.size == 2
  277.                       #1、2号人物受技能影响
  278.          $game_party.actors[0].skill_effect(self.battler, $data_skills[BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)]])
  279.         $game_party.actors[1].skill_effect(self.battler, $data_skills[BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)]])
  280.       end
  281.        if $game_party.actors.size == 3
  282.         $game_party.actors[0].skill_effect(self.battler, $data_skills[BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)]])
  283.         $game_party.actors[1].skill_effect(self.battler, $data_skills[BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)]])
  284.          $game_party.actors[2].skill_effect(self.battler, $data_skills[BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)]])
  285.        end
  286.          if $game_party.actors.size == 4
  287.         $game_party.actors[0].skill_effect(self.battler, $data_skills[BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)]])
  288.         $game_party.actors[1].skill_effect(self.battler, $data_skills[BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)]])
  289.          $game_party.actors[2].skill_effect(self.battler, $data_skills[BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)]])
  290.        $game_party.actors[3].skill_effect(self.battler, $data_skills[BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)]])
  291.      end
  292.      end
  293.      #回血加血技能冷却
  294.       @stop_count = -100
  295.     end
  296.   end
  297.   def defend_force
  298.     update_sensor
  299.     return turn_toward_player if @enemy_in_range == nil
  300.     case rand(5)
  301.     when 0..2
  302.       turn_toward_event(@enemy_in_range)
  303.     when 3..5
  304.       attack_command
  305.       @stop_count = -20
  306.     end
  307.   end
  308.   def lead_way
  309.     return move_follow if self.battler.id != 4
  310.     return move_follow if $game_map.map_id != 5
  311.     lead_destination = $game_system.lead[$game_system.lead_step]
  312.     distance = (self.x - $game_player.x).abs + (self.y - $game_player.y).abs
  313.     if distance > 8
  314.       turn_toward_player
  315.     else
  316.       move_toward_cell(lead_destination[0],lead_destination[1])
  317.       if lead_destination[0] == self.x and lead_destination[1] == self.y
  318.         if $game_system.lead_step + 1 == $game_system.lead.size
  319.           turn_toward_player
  320.         else
  321.           $game_system.lead_step += 1
  322.         end
  323.       end
  324.     end
  325.   end
  326.   def d
  327.     #when 2 #自由
  328.       update_sensor
  329.       if @enemy_in_range == nil
  330.         move_follow
  331.       else
  332.         case rand(10)
  333.         when 1..4
  334.           move_toward_event($game_map.events[@enemy_in_range])
  335.           return if moving?
  336.           @stop_count = -20         
  337.         when 5..7
  338.           attack_command
  339.           @stop_count = -20
  340.         when 9..10
  341.           move_follow
  342.         end
  343.       end
  344.       #when 3 # BOSS(特殊模式)
  345.         unless $game_switches[BFS_Setting::BOSS_MODE_SWITCH]
  346.           $game_temp.bfs_party_mode = 0
  347.           $boss_event_id = nil
  348.           return
  349.         end
  350.         case rand(46)
  351.         when 0..15
  352.           move_follow
  353.         when 16..25
  354.           move_toward_event($game_map.events[$boss_event_id])
  355.           return if moving?
  356.           @stop_count = -30
  357.         when 26..40
  358.           attack_command
  359.           @stop_count = -20
  360.         when 41..45
  361.           magic_command
  362.           @stop_count = -30
  363.         end
  364.       end
  365.     end

评分

参与人数 1星屑 +35 收起 理由
RyanBern + 35 手动认可奖励

查看全部评分

Lv5.捕梦者 (暗夜天使)

只有笨蛋才会看到

梦石
1
星屑
21484
在线时间
9389 小时
注册时间
2012-6-19
帖子
7114

开拓者短篇九导演组冠军

2
发表于 2016-2-4 19:27:56 | 只看该作者


你在 A 脚本里用了一个全局变量
你在 B 脚本里又用了同一个名字的全局变量

至少其中一个脚本全局变量的值会因此产生问题


所以,你必须保证,你起的名字,和你已有的任何一个全局变量名字都不同

点评

就是一个名字而已,你起的短也没关系,如果你用的脚本质量足够高的话一般是没问题的  发表于 2016-2-4 20:23
那加_和不加_是一样的吗。不重复的话就没关系吗,$A也行吗  发表于 2016-2-4 19:35

评分

参与人数 1星屑 +150 收起 理由
RyanBern + 150 我很赞同

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

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

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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