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.

Temporarily stop event from moving

Hi. ^^

My question is:

Is it possible to temporarily stop an event from moving? I have an event on follow, and have it so that when event.fadeout == true, in class Game_Map update, the opacity slowly fades to 0 and the event is then teleported to the original spot. While this fadeout I want him to stop moving (I can't change move_type/frequency/route/speed as that will mess up how it is all reset after the teleport). Maybe there's some method like event.moving = false?

I'm not sure.

Thank you! :)
 

Zeriab

Sponsor

You want to look at the update_move method in Game_Character class (Section Game_Character 2) at around line 80.

Here is a code snippet where you can tag events for not moving while a certain switch is OFF. (Move when it is ON)
[rgss]#==============================================================================
# ** Game_Event (Paste anywhere below Game_Event and above Main)
#------------------------------------------------------------------------------
#  This add-on will allow you to determine enable and disable update for events
#  by turning switches on and off.
#
#  Put \w[23] in the name of an event and it will be updated if switch number
#  23 is ON. It won't be updated if switch number 23 is OFF.
#  The general syntax is \w[id] where id is the id of the switch you want to use
#  Don't include leading zero's (0023) since the number will be considered as
#  base 8 instead of base 10. (Basically 8 and 9 doesn't exist, so 6, 7, 10, 11)
#  If you put more than one \w[id] in the name only the last \w[id] will be used
#
#  Remember that by default all switches start as OFF
#  Also note that if \w[0] or no \w[id] is used the event will work as normally
#==============================================================================
 
class Game_Event < Game_Character
  alias zeriab_waitswitch_game_event_initialize :initialize
  alias zeriab_waitswitch_game_event_update_move :update_move
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     map_id : map ID (not used in this snippet)
  #     event  : event (RPG::Event)
  #     *args  : any other arguments to send one to the originally method,
  #              just in case more are needed
  #--------------------------------------------------------------------------
  def initialize(map_id, event, *args)
    @wait_switch = 0
    event.name.gsub(/\\[Ww]\[([0-9]+)\]/) {@wait_switch = $1.to_i } # Only 1 wait switch is supported, faster
    zeriab_waitswitch_game_event_initialize(map_id, event, *args)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update_move
    unless @wait_switch > 0 && !$game_switches[@wait_switch]
      zeriab_waitswitch_game_event_update_move
    end
  end
end
[/rgss]

Just put \w[23] some where in the name of the relevant name where 23 designates the switch to use.

*hugs*
- Zeriab
 
Take a look at force_move_route method of the Character class.
In the loop that handles the fade, you should be able to include a force_move_route command on that event.
Inside the "when event.fadeout == true" (if, while, whatever), use

move_route = RPG::Move_Route.new #the move type defaults to '0', which is no move command.
move_route.repeat = false
event.force_move_route(move_route)

Then, once the fade ends, the custom_move_route method should set it back to the original move_route.


another option would be to set the event up with another event page with a condition (self switch).
then in the fade section, or right before it, set the self switch on. after the fade, set it back to off.

Code:
 

      # Make a self switch key

      key = [map_id, event_id, parameters[0]]    # I assume parameters[0] is 0,1,2,3 for switch A,B,C,D

      # Change self switches

      $game_self_switches[key] = 1                 # 0 = OFF,  1 = ON

 
 
@zeriab: Hm, I can't change the event name unfortunately. ^^; But thank you for the post.~

@Brewmeister: uninitialized method RPG::Move_Route error. :3 I have this in the update of $Game_Map:

Code:
  #check fadeout woar

  if event.fadeout == true

    event.opacity -= 5

    move_route = RPG::Move_Route.new #the move type defaults to '0', which is no move command.

move_route.repeat = false

event.force_move_route(move_route)

    if event.opacity <= 0

      event.opacity = 0

      x = event.event.x

      y = event.event.y

      event.moveto(x,y)

      event.fadeout = false

      event.opacity = event.original_opacity

    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