Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Can't figure out why my code isn't looping.

Dko

Member

Hi im trying to spruce up my battle system so based on a particular stat a character will get to make so many attack commands. What I have currently runs with no error but I still only get one attack. With my testing @num_attacks is higher then 1 but the loop I use it with never executes more then once. Could someone see what I must be obviously messing up in my for loop?
EDIT: if you think there is something else I need to post to help please lemme know.
Code:
#--------------------------------------------------------------------------
  # * Frame Update (actor command phase : enemy selection)
  #--------------------------------------------------------------------------
 def update_phase3_enemy_select
    # Update enemy arrow
    @enemy_arrow.update
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # End enemy selection
      end_enemy_select
      return
    end
    
    # If C button was pressed
    if Input.trigger?(Input::C) or Input.trigger?(Input::Y) or Input.trigger?(Input::X) or Input.trigger?(Input::Z)
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      # Set action
      if @active_battler.is_a?(Game_Actor)
        @num_attacks = @active_battler.stam
      else
        @num_attacks = 1
      end
      # Set each attacks strength
      for i in (1..@num_attacks)
        
        if Input.trigger?(Input::C) or Input.trigger?(Input::Y)
          $atk_power[i] = "MED"
        end
        if Input.trigger?(Input::X)
          $atk_power[i] = "STR"
        end
        if Input.trigger?(Input::Z)
          $atk_power[i] = "WEAK"
        end
      end
      
    
      # Set action
      @active_battler.current_action.target_index = @enemy_arrow.index
      # End enemy selection
      end_enemy_select
      # If skill window is showing
      if @skill_window != nil
        # End skill selection
        end_skill_select
      end
      # If item window is showing
      if @item_window != nil
        # End item selection
        end_item_select
      end
      # Go to command input for next actor
      phase3_next_actor
    end
  end
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top