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.

Force Action using scripting instead of Event Commands

I'm using a large party script that allows for more than four "heroes" in a party. The way I'm planning my battles and skills will require a lot of Forced Actions. Unfortunately, since a five person party is not a feature that came originally with RMXP, I am unable to do a forced action on the fifth battler.

Here is the code for Force Action:
Code:
  #--------------------------------------------------------------------------

  # * Force Action

  #--------------------------------------------------------------------------

  def command_339

    # Ignore if not in battle

    unless $game_temp.in_battle

      return true

    end

    # Ignore if number of turns = 0

    if $game_temp.battle_turn == 0

      return true

    end

    # Process with iterator (For convenience, this process won't be repeated)

    iterate_battler(@parameters[0], @parameters[1]) do |battler|

      # If battler exists

      if battler.exist?

        # Set action

        battler.current_action.kind = @parameters[2]

        if battler.current_action.kind == 0

          battler.current_action.basic = @parameters[3]

        else

          battler.current_action.skill_id = @parameters[3]

        end

        # Set action target

        if @parameters[4] == -2

          if battler.is_a?(Game_Enemy)

            battler.current_action.decide_last_target_for_enemy

          else

            battler.current_action.decide_last_target_for_actor

          end

        elsif @parameters[4] == -1

          if battler.is_a?(Game_Enemy)

            battler.current_action.decide_random_target_for_enemy

          else

            battler.current_action.decide_random_target_for_actor

          end

        elsif @parameters[4] >= 0

          battler.current_action.target_index = @parameters[4]

        end

        # Set force flag

        battler.current_action.forcing = true

        # If action is valid and [run now]

        if battler.current_action.valid? and @parameters[5] == 1

          # Set battler being forced into action

          $game_temp.forcing_battler = battler

          # Advance index

          @index += 1

          # End

          return false

        end

      end

    end

    # Continue

    return true

  end

 

I'm not very sure I understand fully how this works.. But what I'm thinking is this:

Firstly, I think this is the line that chooses which battler? I'm guessing that (@parameters[0], @parameters[1]) is referring to the Actor or Enemy chosen using the event command. How do I make it so that in the place of those parameters I can just call upon a certain actor in the party?
Code:
    iterate_battler(@parameters[0], @parameters[1]) do |battler|

Also, I realize that because I'm using a script I can't use the other parts of the event commands to set what action and target I want. So I'm guessing it means I have to tamper with the other parameters as well.

I think I can see what each individual thing does, but have no knowledge of how to adapt it.
I would really appreciate if someone took the time to
1) Explain how to choose a certain actor, action, and target outside of the command system
2) Explain how to create a call-able script that will allow variety in creating forced actions for the fifth party member
Or simply just create a script that would allow the fifth party member to do forced actions

Apologies for my weak attempt at understanding the code, and thanks in advance for any help that is given!
 
okey, you have 5 parameters
@parameter0: the battler forced is an ? 0: enemy | 1: actor
@parameter1: the id of the forced battler
@parameter2: the ActionKind of the forced Battler (0 = basics, 1 = skills)
@parameter3: the Id of Basics or Skill (for basics, 0 = attack, 1 = defend, 2 = escape, 3 = do nothing)
@parameter4: the target (-2 = last target, -1 = random target, 0-7 = targets (actor or enemy depends on skillscope))

I don't know if it works, but i would try it that way:
Code:
@parameter0 = 1 # forced one is an actor.

@parameter1 = 4 # he's the fifth in party.

@parameter2 = 0 # he must use a basic skill.

@parameter3 = 0 # he attacks...

@parameter4 = -1 # ...a random enemy

command_339 # executes the settings above (i hope^^)
 
Thank you so much! It's worked, with a little modifications. (@parameters[0] instead of @parameter0 and same for other parameters)

I didn't realize it could be done this simply! Thanks a million!
 

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