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

Project1

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

[已经过期] 设计好了10个战斗点 只能出9个战斗不知道原因

[复制链接]

Lv4.逐梦者

梦石
0
星屑
7832
在线时间
1347 小时
注册时间
2015-8-15
帖子
753
跳转到指定楼层
1
发表于 2017-4-3 15:13:30 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
RUBY 代码复制
  1. [pre lang="ruby"]#==============================================================================
  2. # ■ EFS
  3. #------------------------------------------------------------------------------
  4. #  群战系统的游戏主操控类
  5. #   全新版本
  6. #   作者 Raider Soap 肥皂君~
  7. #
  8. #==============================================================================
  9. class EFS
  10.  
  11.   #--------------------------------------------------------------------------
  12.   # ● 初始化数据
  13.   #--------------------------------------------------------------------------
  14.   def initialize(party1,party2)
  15.     $Team_Fighter = []
  16.     $Enermy_Fighter = []
  17.     $Num_Team = 1    # player
  18.     $Team_Fighter.push $game_player
  19.     $Num_Enermy = 0
  20.     #死亡计数
  21.     $Team_Death_counter = 0
  22.     $Enermy_Death_counter = 0
  23.  
  24.     $game_player.self_battler = $game_player # 正太君改
  25.     $game_player.hp = $game_party.actors[0].hp  # 正太君改
  26.     $game_player.maxhp = $game_party.actors[0].maxhp # 正太君改
  27.     $game_player.mp = $game_party.actors[0].sp # 正太君改
  28.     $game_player.maxmp = $game_party.actors[0].maxsp # 正太君改
  29.     $game_player.skilled_level = 3
  30.     $game_player.action_mode = 0
  31.     $game_player.armor = 30
  32.     $game_player.ap = 60
  33.     $game_player.ap_range = 5
  34.     $game_player.atk_se = "swordbasic_"
  35.     $game_player.atk_se_num = 11
  36.     $game_player.heavy = false
  37.     $game_player.name = "theplayer"
  38.     $game_player.atk_fr = 30
  39.     $game_player.is_cav = false
  40.     $game_player.shd = false
  41.  
  42.     #双方队伍
  43.     @team_party = party1
  44.     @enermy_party = party2
  45.  
  46.     #团队
  47.     $team_group = []
  48.     $enermy_group = []
  49.     $team_group[0] = []
  50.     for i in 1..10
  51.       $team_group[i] = []
  52.       $enermy_group[i] = []
  53.     end
  54.     $lisenter = 0
  55.     #坚守的行数量
  56.     @guarding_line_num = 1
  57.  
  58.     #出生点
  59.     @group_spawn = []
  60.     for i in 1..10#  5改为10个
  61.       @group_spawn[i] = []
  62.     end
  63.     @group_spawn_e = []
  64.     for i in 1..10 #  5改为10个
  65.       @group_spawn_e[i] = []
  66.     end
  67.  
  68.     @counter = 0
  69.     @counter_for_wait = 0
  70.     @counter_for_push = 0
  71.  
  72.     @c = false
  73.  
  74.     @spell_used = []
  75.     #一定要把所有技能在这里过一遍
  76.     #一定要把所有技能在这里过一遍
  77.     #一定要把所有技能在这里过一遍
  78.    # for i in 1..X
  79.     @spell_used[1] = Skill_data::TIME[1] # i
  80.    #end
  81.   end
  82.  
  83.   #--------------------------------------------------------------------------
  84.   # ● 显示图标
  85.   #--------------------------------------------------------------------------  
  86.   def show_icon
  87.     if $selected_item == 0
  88.       item_id = 33
  89.     else
  90.       item_id =  Item_data::ID[$selected_item]  
  91.     end  
  92.     if $selected_spell == 0
  93.       spell_id = 0
  94.     else
  95.        spell_id =  $selected_spell
  96.     end  
  97.     item = $data_items[item_id]
  98.     spell_icon = Skill_data::ICON[spell_id]
  99.  
  100.     # 设置变量
  101.     $game_variables[2] = $game_party.item_number(item_id) #物品数量
  102.     $game_variables[3] = @spell_used[$selected_spell]
  103.  
  104.     # 显示图
  105.     $game_screen.pictures[5].show(item.icon_name,1,494,444, 100, 100, 255, 0)
  106.     $game_screen.pictures[2].show(spell_icon,1,532,444, 100, 100, 255, 0)   if not $selected_spell == 0
  107.     $game_screen.pictures[8].show("shd01",1,609,444, 100, 100, 255, 0)
  108.     weapons = $data_weapons[$game_party.actors[0].weapon_id]
  109.     $game_screen.pictures[9].show(weapons.icon_name,1,571,444, 100, 100, 255, 0)
  110.  
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # ● 寻找小队坐标点
  114.   #--------------------------------------------------------------------------
  115.   def group_spawn_points
  116.     #循环全部事件
  117.      for event in $game_map.events.values
  118.        Graphics.update
  119.        if event.name[0,3] == "##T"
  120.           group = event.name[3,1].to_i
  121.           @group_spawn[group].push event.x
  122.           @group_spawn[group].push event.y
  123.           @group_spawn[group].push event.name[4,1].to_i
  124.           #[event.x,event.y,event.name[4,1].to_i]
  125.        elsif event.name[0,3] == "##E"
  126.           group = event.name[3,1].to_i
  127.           @group_spawn_e[group].push event.x
  128.           @group_spawn_e[group].push event.y
  129.           # name[4,1]的值为 1 代表横着 2 代表竖着
  130.           @group_spawn_e[group].push event.name[4,1].to_i      
  131.        end  
  132.      end
  133.   end   
  134.   #--------------------------------------------------------------------------
  135.   # ● 创建士兵
  136.   #--------------------------------------------------------------------------
  137.   def spawn_fighters
  138.     Drop_Item.pre_load
  139.     for group_id in 1..10
  140.        num_people = @team_party.number(group_id)
  141.        next if @team_party.number(group_id) == 0
  142.        num = even?(num_people) ? num_people/2 : (num_people-1)/2
  143.        for i in [email]0..@team_party.number[/email](group_id) - 1
  144.        x = @group_spawn[group_id][0]  
  145.        y = @group_spawn[group_id][1]
  146.        new_x = @group_spawn[group_id][2] == 1 ? x - num + i : x
  147.        new_y = @group_spawn[group_id][2] == 2 ? y - num + i : y
  148.        Drop_Item.make_events_EFS(new_x,new_y)
  149.        Graphics.update
  150.         for event in $game_map.events.values
  151.           if event.x == new_x and event.y == new_y and not event.name[0,2] == "##"
  152.             team_fighter = @team_party.group[group_id][i]
  153.             @team_party.group[group_id][i].set_event(event)
  154.             $Team_Fighter.push(team_fighter)
  155.             $team_group[0].push team_fighter
  156.             $team_group[team_fighter.group_id].push team_fighter         
  157.             event.self_battler = team_fighter
  158.  
  159.           end  
  160.         end
  161.        end
  162.      end
  163.      Drop_Item.refresh_map
  164.   end
  165.   def spawn_fighters_e
  166.       Drop_Item.pre_load
  167.     for group_id in 1..10
  168.        num_people = @enermy_party.number(group_id)
  169.        num = even?(num_people) ? num_people/2 : (num_people-1)/2
  170.        for i in [email]0..@enermy_party.number[/email](group_id)-1
  171.        x = @group_spawn_e[group_id][0]  
  172.        y = @group_spawn_e[group_id][1]
  173.        new_x = @group_spawn_e[group_id][2] == 1 ? x - num + i : x
  174.        new_y = @group_spawn_e[group_id][2] == 2 ? y - num + i : y
  175.        Drop_Item.make_events_EFS(new_x,new_y)
  176.        Graphics.update
  177.        for event in $game_map.events.values
  178.          if event.x == new_x and event.y == new_y and not event.name[0,2] == "##"
  179.             team_fighter = @enermy_party.group[group_id][i]
  180.             @enermy_party.group[group_id][i].set_event(event)
  181.             $Enermy_Fighter.push(team_fighter)
  182.             $enermy_group[team_fighter.group_id].push team_fighter  
  183.             event.self_battler = team_fighter
  184.           end  
  185.        end
  186.        end
  187.      end
  188.      Drop_Item.refresh_map
  189.   end   
  190.   def even?(value)
  191.   value & 1 == 0
  192.   end  
  193.   #--------------------------------------------------------------------------
  194.   # ● 分组设定
  195.   #--------------------------------------------------------------------------
  196.   def groups_setting
  197.     for fighters in $Team_Fighter
  198.       $team_group[fighters.group_id].push fighters if fighters != $game_player
  199.       $team_group[0].push fighters if fighters != $game_player
  200.     end
  201.     for fighters in $Enermy_Fighter
  202.       $enermy_group[fighters.group_id].push fighters
  203.     end
  204.   end  
  205.  
  206.   #--------------------------------------------------------------------------
  207.   # ● 下达初始指令
  208.   #--------------------------------------------------------------------------
  209.   def command(team,group,command_id)
  210.     #TEAM = 1 代表 玩家的队伍 2 代表 敌人的队伍
  211.       if team = 1
  212.         for f in $team_group[group]
  213.          f.command_action = command_id
  214.         end
  215.       else
  216.         for e in $enermy_group[group]
  217.          e.command_action = command_id
  218.         end
  219.       end  
  220.   end   
  221.  
  222.   #--------------------------------------------------------------------------
  223.   # ● 士兵基础设置 # 正太君改
  224.   #--------------------------------------------------------------------------
  225.   def set_fighters
  226.     #循环全部事件
  227.      for event in $game_map.events.values
  228.        if event.name[0,2] == "#T"
  229.          team_fighter = EFS_Team.new(event,event.name[3,3].to_i)
  230.          $Team_Fighter.push(team_fighter)
  231.          event.self_battler = team_fighter
  232.        elsif event.name[0,2] == "#E"
  233.          enermy_fighter = EFS_Enermy.new(event,event.name[3,3].to_i)
  234.          $Enermy_Fighter.push(enermy_fighter)
  235.          event.self_battler = enermy_fighter
  236.        end  
  237.      end  
  238.  
  239.    end
  240.  
  241.  
  242.    def update_player_data
  243.     $game_player.hp = $game_party.actors[0].hp  # 正太君改
  244.     $game_player.mp = $game_party.actors[0].sp # 正太君改
  245.     $game_party.actors[0].hp = $game_party.actors[0].hp.round
  246.     $game_party.actors[0].sp = $game_party.actors[0].sp.round
  247.     $game_player.update_die if $game_player.dead?
  248.     # 冷却
  249.     $item_cd -= 1 if $item_cd > 0
  250.     $spell_cd -= 1 if $spell_cd > 0
  251.     $item_opacity = 255 if $item_cd <= 0 else  $item_opacity = 140
  252.  
  253.     if $selected_item == 0
  254.       item_id = 33
  255.     else
  256.       item_id =  Item_data::ID[$selected_item]  
  257.     end  
  258.     if $selected_spell == 0
  259.       spell_id = 0
  260.     else
  261.        spell_id =  $selected_spell
  262.     end  
  263.     item = $data_items[item_id]
  264.     # 设置变量
  265.     $game_variables[2] = $game_party.item_number(item_id)
  266.     $game_variables[3] = @spell_used[$selected_spell]
  267.     # 显示图
  268.     $game_screen.pictures[2].move(0,0,532,444, 100, 100, 255, 0)   if not $selected_spell == 0
  269.     $game_screen.pictures[8].move(0,0,609,444, 100, 100, 255, 0)
  270.     $game_screen.pictures[5].move(0,0,450,432, 100, 100,$item_opacity, 0)
  271.     weapons = $data_weapons[$game_party.actors[0].weapon_id]
  272.     $game_screen.pictures[9].move(0,0,573,433, 100, 100,255, 0)
  273.  
  274.     show_icon
  275.  
  276.     # 是否是加速状态的更新
  277.     $game_player.accelarting = $game_player.move_speed == 4 ? true : false
  278.  
  279.     end  
  280.  
  281.  
  282.  
  283.   #--------------------------------------------------------------------------
  284.   # ● 主处理  ●  ●  ●  ●  ●  ●  ●  ●  ●  ●  ●  ●  ●  ●  ●  ●  
  285.   #--------------------------------------------------------------------------
  286.   def main
  287.     return if $BattleOn == false
  288.     #判断是否胜利
  289.     if check_winning
  290.       after_battle
  291.       return
  292.     end  
  293.     $game_player.update_die if $game_player.dead?
  294.     #######UPDATE#########
  295.       update_player_data
  296.     ######################
  297.     $game_player.attack if $game_player.attack? and not $game_player.dead?  
  298.  
  299.     #如果敌人是推进策略
  300.     for i in 1..10
  301.       group_check_cor(i)
  302.     end  
  303.     if @enermy_party.strategy == 2
  304.         e_push if push_wait
  305.     end
  306.  
  307.     #判断输入
  308.     if (Kboard.keyboard($R_Key_SPACE)) and not $game_player.dead?
  309.          $game_player.attack if use_sp(90)
  310.      elsif Kboard.keyboard($R_Key_1) and not $game_player.dead?
  311.        Notification.post("第1队!听我的命令!")
  312.       $lisenter = 1 #group 1
  313.     elsif Kboard.keyboard($R_Key_2) and not $game_player.dead?
  314.       $lisenter = 2 #group 2
  315.          Notification.post("第2队!听我的命令!")
  316.     elsif Kboard.keyboard($R_Key_3) and not $game_player.dead?
  317.       $lisenter = 3 #group 3
  318.          Notification.post("第3队!听我的命令!")
  319.     elsif Kboard.keyboard($R_Key_4) and not $game_player.dead?
  320.       $lisenter = 4 #group 4
  321.          Notification.post("第4队!听我的命令!")
  322.     elsif Kboard.keyboard($R_Key_5) and not $game_player.dead?
  323.       $lisenter = 5 #group 5
  324.          Notification.post("第5队!听我的命令!")
  325.        elsif Kboard.keyboard($R_Key_0) and not $game_player.dead?
  326.       $lisenter = 6 #group 5
  327.          Notification.post("第6队!听我的命令!")
  328.     elsif Kboard.keyboard($R_Key_0) and not $game_player.dead?
  329.       $lisenter = 7 #group 5
  330.          Notification.post("第7队!听我的命令!")
  331.     elsif Kboard.keyboard($R_Key_0) and not $game_player.dead?      
  332.       $lisenter = 8 #group 5
  333.          Notification.post("第8队!听我的命令!")
  334.     elsif Kboard.keyboard($R_Key_0) and not $game_player.dead?      
  335.       $lisenter = 9 #group 5
  336.          Notification.post("第9队!听我的命令!")
  337.     elsif Kboard.keyboard($R_Key_0) and not $game_player.dead?      
  338.       $lisenter = 10 #group 5
  339.          Notification.post("第10队!听我的命令!")
  340.     elsif Kboard.keyboard($R_Key_0) and not $game_player.dead?      
  341.  
  342.      $lisenter = 0 #group All
  343.      Notification.post("所有人!听我的命令!")
  344.    elsif Kboard.keyboard($R_Key_Q) and not $game_player.dead?
  345.        Notification.post("坚守这里!")
  346.        blocked = false
  347.        for f in $Team_Fighter
  348.          next if f.is_a?(Game_Player)
  349.          blocked = true if f.check_guard_position($game_player.x,$game_player.y,$game_player.direction)
  350.        end  
  351.        unless blocked
  352.           for e in $team_group[$lisenter]
  353.            e.command_action = 1 #def
  354.            e.set_guard_cor($game_player.x,$game_player.y,$game_player.direction,@guarding_line_num) if not @set
  355.           end  
  356.       @set = true
  357.       else
  358.         $game_system.se_play($data_system.buzzer_se)
  359.       end
  360.     elsif Kboard.keyboard($R_Key_W) and not $game_player.dead?
  361.       Notification.post("跟我来!")
  362.       for e in $team_group[$lisenter]
  363.          e.command_action = 2 #onme
  364.       end  
  365.     elsif Kboard.keyboard($R_Key_E) and not $game_player.dead?
  366.         Notification.post("冲锋")
  367.       for e in $team_group[$lisenter]
  368.          e.command_action = 3 #atk
  369.        end
  370.     elsif Kboard.keyboard($R_Key_A) and not $game_player.dead?
  371.        $game_player.character_name = "theplayer-jump"
  372.        if $game_player.accelarting
  373.          $game_player.animation_id = 117
  374.          $game_player.jump_forward(2) if use_sp(75)
  375.        else
  376.         $game_player.animation_id = 117
  377.         $game_player.jump_forward(1) if use_sp(50)
  378.        end   
  379.     elsif Kboard.keyboard($R_Key_S) and not $game_player.dead?
  380.         use_item
  381.     elsif Kboard.keyboard($R_Key_D) and not $game_player.dead?
  382.         use_spell   
  383.     end   
  384.  
  385.       #是否按键加速
  386.     if Kboard.keyb($R_Key_LSHIFT) and not $game_player.dead? and  not $game_player.attack?
  387.           $game_player.character_name = "theplayer-swd-run" if not $game_player.jumping?
  388.           $game_player.move_speed = use_sp(4) ? 4 : 3
  389.     elsif Kboard.keyb($R_Key_Z) and not $game_player.dead? and  not $game_player.attack?
  390.           $game_player.character_name = "theplayer-shd" if not $game_player.jumping?
  391.           $game_player.heavy = true
  392.           $game_player.move_speed = 2
  393.           $game_player.shd = true     
  394.     else
  395.        if not $game_player.attack?
  396.          $game_player.shd = false
  397.          $game_player.heavy = false
  398.          $game_player.character_name = "theplayer" if not $game_player.jumping?
  399.          $game_party.actors[0].sp += 4
  400.          $game_party.actors[0].sp = $game_party.actors[0].maxsp if $game_party.actors[0].sp >= $game_party.actors[0].maxsp
  401.        end  
  402.          $game_player.move_speed = 3
  403.     end            
  404.  
  405.     if Kboard.keyboard($R_Key_SEP)
  406.       if @guarding_line_num != 1
  407.       @guarding_line_num -= 1
  408.       else
  409.       @guarding_line_num = 3
  410.       end  
  411.     Notification.post("排成"+@guarding_line_num.to_s+"行!")
  412.     elsif Kboard.keyboard($R_Key_DOTT)
  413.       if @guarding_line_num != 3
  414.       @guarding_line_num += 1
  415.       else
  416.       @guarding_line_num = 1
  417.       end  
  418.      Notification.post("排成"+@guarding_line_num.to_s+"行!")
  419.     end  
  420.  
  421.    if Kboard.keyboard($R_Key_ALT)
  422.     @c = @c ? false : true
  423.     $game_switches[5] = @c
  424.     $game_switches[6] = @c
  425.    end  
  426.  
  427.     #所有士兵的main
  428.     for i in 1..$Team_Fighter.size-1
  429.      $Team_Fighter[i].main
  430.     end
  431.     for e in $Enermy_Fighter
  432.       e.main
  433.     end
  434.     @set = false
  435.  
  436.   end
  437.   #--------------------------------------------------------------------------
  438.   # ● 判断玩家的体力是否足够维持&&可以的话就扣掉相应的
  439.   #--------------------------------------------------------------------------  
  440.   def use_sp(sp)
  441.     if $game_party.actors[0].sp < sp
  442.         $game_system.se_play($data_system.buzzer_se)
  443.         return false
  444.     else
  445.         $game_party.actors[0].sp -= sp if ! $game_player.attack?
  446.         return true
  447.     end
  448.   end
  449.   #--------------------------------------------------------------------------
  450.   # ● 敌人策略分析器
  451.   #--------------------------------------------------------------------------  
  452.   def enermy_strategy
  453.     case @enermy_party.strategy
  454.     when 1
  455.       for e in $Enermy_Fighter
  456.         e.get_group_spawn(@group_spawn_e,@group_spawn)
  457.         e.command_action = 1
  458.       end
  459.     when 2
  460.       for e in $Enermy_Fighter
  461.         e.get_group_spawn(@group_spawn_e,@group_spawn)
  462.         e.command_action = 1
  463.       end
  464.     when 3  
  465.       for e in $Enermy_Fighter
  466.         e.command_action = 3
  467.       end
  468.     end
  469.   end
  470.   #--------------------------------------------------------------------------
  471.   # ● 设置初始坚守坐标
  472.   #--------------------------------------------------------------------------
  473.   def set_defualt_guard_cor
  474.       for e in $Team_Fighter
  475.         next if e.is_a?(Game_Player)
  476.         e.get_group_spawn(@group_spawn_e,@group_spawn)
  477.         e.command_action = 1
  478.       end
  479.   end
  480.   #--------------------------------------------------------------------------
  481.   # ● 是否进入警戒距离
  482.   #--------------------------------------------------------------------------   
  483.     def group_check_cor(group_id)
  484.       d_list = []
  485.       e_x,e_y = enermy_avg_cor(group_id)
  486.       for i in 1..10
  487.         t_x,t_y = team_avg_cor(i)
  488.         d = (t_x - e_x).abs + (t_y - e_y).abs
  489.         d_list.push d
  490.       end  
  491.       if d_list.min < 10
  492.         for e in $enermy_group[group_id]
  493.             e.command_action = 3
  494.         end  
  495.       end  
  496.   end
  497.   #--------------------------------------------------------------------------
  498.   # ● 小队的平均坐标
  499.   #--------------------------------------------------------------------------   
  500.   def team_avg_cor(group_id)
  501.     return 0,0 if $team_group[group_id] == nil or $team_group[group_id].size == 0
  502.     sum_x,sum_y = 0,0
  503.     for f in $team_group[group_id]
  504.       sum_x += f.event.x
  505.       sum_y += f.event.y
  506.     end  
  507.     sum_x /= $team_group[group_id].size
  508.     sum_y /= $team_group[group_id].size
  509.     return sum_x,sum_y
  510.   end
  511.   def enermy_avg_cor(group_id)
  512.     return 0,0 if $enermy_group[group_id] == nil or $enermy_group[group_id].size == 0
  513.     sum_x,sum_y = 0,0
  514.     for f in $enermy_group[group_id]
  515.       sum_x += f.event.x
  516.       sum_y += f.event.y
  517.     end  
  518.     sum_x /= $enermy_group[group_id].size
  519.     sum_y /= $enermy_group[group_id].size
  520.     return sum_x,sum_y
  521.   end
  522.  
  523.   def team_avg_cor_all
  524.     sum_x,sum_y = 0,0
  525.     for f in $Team_Fighter
  526.       sum_x += f.event.x
  527.       sum_y += f.event.y
  528.     end  
  529.     sum_x /= $Team_Fighter.size
  530.     sum_y /= $Team_Fighter.size
  531.     return sum_x,sum_y
  532.   end  
  533.   def enermy_avg_cor_all
  534.     sum_x,sum_y = 0,0
  535.     for f in $Enermy_Fighter
  536.       sum_x += f.event.x
  537.       sum_y += f.event.y
  538.     end  
  539.     sum_x /= $Enermy_Fighter.size
  540.     sum_y /= $Enermy_Fighter.size
  541.     return sum_x,sum_y
  542.   end   
  543.   #--------------------------------------------------------------------------
  544.   # ● 使用物品
  545.   #--------------------------------------------------------------------------
  546.   def use_item
  547.     if $selected_item == 0
  548.       item_id = 33
  549.     else
  550.       item_id =  Item_data::ID[$selected_item]  
  551.     end  
  552.     item = $data_items[item_id]
  553.     # 如果物品用完的情况下
  554.       if $game_party.item_number(item_id) == 0
  555.         # 演奏冻结 SE
  556.         $game_system.se_play($data_system.buzzer_se)
  557.         return
  558.       end
  559.     # 如果交战中
  560.       if $game_player.attack?
  561.         # 演奏冻结 SE
  562.         $game_system.se_play($data_system.buzzer_se)
  563.         return
  564.       end      
  565.     #冷却时间
  566.     if $item_cd > 0
  567.         # 演奏冻结 SE
  568.         $game_system.se_play($data_system.buzzer_se)
  569.         return
  570.     end   
  571.  
  572.      target = $game_party.actors[0]
  573.      used = target.item_effect(item)
  574.  
  575.     # 使用物品的情况下
  576.       if used
  577.         # 演奏物品使用时的 SE
  578.         $game_system.se_play(item.menu_se)
  579.         # 设定冷却时间
  580.         $item_cd = Item_data::COLD_DOWN[$selected_item]
  581.         ###设置变灰###
  582.         $item_opacity = 140
  583.         # 动画
  584.         $game_player.animation_id = item.animation2_id
  585.         # 消耗品的情况下
  586.         if item.consumable
  587.           # 使用的物品数减 1
  588.           $game_party.lose_item(item.id, 1)
  589.         end
  590.         # 全灭的情况下
  591.         if $game_party.all_dead?
  592.           $scene = Scene_Gameover.new
  593.           return
  594.         end
  595.         # 公共事件 ID 有效的情况下
  596.         if item.common_event_id > 0
  597.           # 预约调用公共事件
  598.           $game_temp.common_event_id = item.common_event_id
  599.           return
  600.         end
  601.       end
  602.       # 无法使用物品的情况下
  603.       unless used
  604.         # 演奏冻结 SE
  605.         $game_system.se_play($data_system.buzzer_se)
  606.       end
  607.       return
  608.     end  
  609.   #--------------------------------------------------------------------------
  610.   # ● 使用技能
  611.   #--------------------------------------------------------------------------   
  612.   def use_spell
  613.     return if $selected_spell == 0
  614.     # 如果技能使用次数用完
  615.     if @spell_used[$selected_spell] <= 0
  616.         # 演奏冻结 SE
  617.         $game_system.se_play($data_system.buzzer_se)
  618.         return
  619.     end
  620.     # 如果交战中
  621.     if $game_player.attack?
  622.         # 演奏冻结 SE
  623.         $game_system.se_play($data_system.buzzer_se)
  624.         return
  625.     end      
  626.     #冷却时间
  627.     if $spell_cd > 0
  628.         # 演奏冻结 SE
  629.         $game_system.se_play($data_system.buzzer_se)
  630.         return
  631.     end   
  632.  
  633.     @spell_used[$selected_spell] -= 1
  634.     $spell_cd = Skill_data::CD[$selected_spell]
  635.     name = Skill_data::NAME[$selected_spell]
  636.     code = Skill_data::CODE[$selected_spell]
  637.     Notification.post("发动了技能"+name+"!")
  638.     EFS_Spell.use_spell(code)
  639.  
  640.   end
  641.   #--------------------------------------------------------------------------
  642.   # ● 判断胜利
  643.   #--------------------------------------------------------------------------
  644.   def check_winning
  645.         counter = 0
  646.       for enermy in $Enermy_Fighter
  647.         if enermy.dead?
  648.          counter+=1
  649.         end  
  650.       end  
  651.       return counter >= $Enermy_Fighter.size
  652.   end
  653.   #--------------------------------------------------------------------------
  654.   # ● 战后处理
  655.   #--------------------------------------------------------------------------
  656.   def after_battle
  657.     if Kboard.keyboard($R_Key_TAB)
  658.       reset
  659.       $scene.spriteset.clear_point_arrow
  660.       $scene.spriteset.clear_arrow
  661.       $game_temp.common_event_id = 2
  662.       $game_player.move_speed = 4
  663.       $BattleOn = false
  664.       $game_switches[20] = false
  665.       $game_temp.common_event_id = 21
  666.       Notification.clear
  667.       $game = nil
  668.       back_to_map  
  669.       $game_party.actors[0].sp = $game_party.actors[0].maxsp
  670.       $player_party.full_ammo
  671.       return
  672.     end      
  673.     $game_party.actors[0].sp += 5
  674.     $game_party.actors[0].sp = $game_party.actors[0].maxsp if $game_party.actors[0].sp >= $game_party.actors[0].maxsp
  675.     for e in $Enermy_Fighter        
  676.       e.event.update_die
  677.     end
  678.     for i in 1..$Team_Fighter.size-1
  679.      $Team_Fighter[i].event.update_die if $Team_Fighter[i].dead?
  680.      next if $Team_Fighter[i].dead?
  681.      $Team_Fighter[i].event.attack_action = false
  682.      $Team_Fighter[i].action_mode = 1
  683.      $Team_Fighter[i].event.character_name = $Team_Fighter[i].name
  684.     end
  685.       $game_player.attack_action = false
  686.       $game_player.action_mode = 1
  687.       $game_player.attack_over
  688.       $game_player.move_speed =3
  689.     $game_party.actors[0].hp = $game_party.actors[0].hp.round
  690.     $game_party.actors[0].sp = $game_party.actors[0].sp.round
  691.       for e in $Team_Fighter
  692.         next if e.is_a?(Game_Player)
  693.         e.remove_all_state
  694.       end  
  695.     end
  696.   #--------------------------------------------------------------------------
  697.   # ● 战斗结束的士兵处理
  698.   #--------------------------------------------------------------------------  
  699.   def reset
  700.     for f in $Team_Fighter
  701.       next if f.is_a?(Game_Player)
  702.       $player_party.delete(f) if f.dead? and not f.wounded
  703.     end
  704.   end  
  705.   #--------------------------------------------------------------------------
  706.   # ● 战斗结束返回地图
  707.   #--------------------------------------------------------------------------      
  708.   def back_to_map
  709.     # 场所移动中、信息显示中、过渡处理中的情况下
  710.     if $game_temp.player_transferring or
  711.        $game_temp.message_window_showing or
  712.        $game_temp.transition_processing
  713.       # 结束
  714.       return false
  715.     end
  716.     $game_temp.player_transferring = true
  717.       # 设置主角的移动目标
  718.       $game_temp.player_new_map_id = @or_map_id
  719.       $game_temp.player_new_x = @or_x
  720.       $game_temp.player_new_y = @or_y
  721.       $game_temp.player_new_direction = @or_d
  722.       # 准备过渡
  723.       Graphics.freeze
  724.       # 设置过渡处理中标志
  725.       $game_temp.transition_processing = true
  726.       $game_temp.transition_name = ""
  727.     return false
  728.  
  729.   end  
  730.   def load_or_map_data
  731.     @or_map_id = $game_map.map_id
  732.     @or_x =  $game_player.x
  733.     @or_y =  $game_player.y
  734.     @or_d =  $game_player.direction
  735.   end  
  736.   #--------------------------------------------------------------------------
  737.   #--------------------------------------------------------------------------
  738.   #--------------------------------------------------------------------------
  739.   #--------------------------------------------------------------------------
  740.   #--------------------------------------------------------------------------
  741.   # ● 接近目标的方向 (面向目标)
  742.   #--------------------------------------------------------------------------
  743.   def get_guard_direction
  744.     sx = @group_spawn_e[1][0] - @group_spawn[1][0]
  745.     sy = @group_spawn_e[1][1] - @group_spawn[1][1]
  746.     abs_sx= (sx).abs  
  747.     abs_sy = (sy).abs
  748.     if abs_sx == 0 and abs_sy == 0
  749.       return
  750.     end
  751.     if sx.abs > sy.abs
  752.       return sx > 0 ? 4 : 6
  753.     else
  754.       return sy > 0 ? 8 : 2
  755.     end
  756.   end  
  757.  
  758.   def e_push
  759.     case get_guard_direction
  760.     when 2
  761.       for i in 1..5
  762.       @group_spawn_e[i][1] += 4
  763.       end
  764.     when 4
  765.       for i in 1..5
  766.       @group_spawn_e[i][0] -= 4
  767.       end
  768.     when 6
  769.       for i in 1..5
  770.       @group_spawn_e[i][0] += 4
  771.       end
  772.     when 8
  773.       for i in 1..5
  774.       @group_spawn_e[i][1] -= 4
  775.       end
  776.     end  
  777.     for e in $Enermy_Fighter
  778.       e.get_group_spawn(@group_spawn_e,@group_spawn)
  779.     end  
  780.   end
  781.   #--------------------------------------------------------------------------
  782.   # ● Code等待
  783.   #--------------------------------------------------------------------------
  784.   def push_wait
  785.       if @counter_for_push < 135
  786.         @counter_for_push += 1
  787.         return false
  788.       else
  789.         @counter_for_push = 0
  790.         return true
  791.       end
  792.   end     
  793.   #--------------------------------------------------------------------------
  794.   # ● Code等待
  795.   #--------------------------------------------------------------------------
  796.   def code_wait(s)
  797.     #不需要解释,自己写的太渣了
  798.     if @counter_for_wait < s
  799.       @counter_for_wait += 1
  800.       return false
  801.     else
  802.       @counter_for_wait = 0
  803.       return true
  804.     end
  805.   end     
  806.  
  807.  
  808.  
  809.  
  810. end
[/pre]

群战.jpg (240.79 KB, 下载次数: 22)

群战.jpg

群战2.jpg (39.32 KB, 下载次数: 20)

群战2.jpg
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-11-27 06:19

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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