VXAce Diagonal movement for a specific event but not the player

So basically, I decided to give the killer in my horror game a flamethrower. The mechanic is the fire just goes forward. It's not too hard to dodge and eventually the killer gets frustrated and just ditches the flamethrower and runs after you himself. Then if you manage to get away from him, he gets his flamethrower back.
For this I use the "turn towards player" option in move route, follower by a bunch of "1 step forward"'s.
The problem is I don't think the flamethrower is all that effective with just the 4 directions and I figured adding diagonal movement for the fire would make it a lot scarier.
I know there is an option to have an event move diagonally in the "set move route" option, but the problem is how does the event detect if the player is diagonal to it?
Here's a video example of how the flamethrower works so far.

If you're wondering how the fire is spawned, I'm using Kal's EventSpawn 1.2 script.
The fire spawns in, turns to the player and moves forward a bunch of times.
How would I go about making it detect if the player is diagonal to it?
Thank you.
Your game looks very nice!

is how does the event detect if the player is diagonal to it?
When you say diagonal, do you mean just that the player is not in a straight line regarding the event?

I made a small script to allow an event to go towards a character diagonally, I'm unsure if the event triggering on collision works properly though so you might need a more advanced diagonal script in such case.

In your move commands, you can replace a step movement by a script call:
move_toward_player8
The event will go 1 step in diagonal direction if the player is not on the same x or y line with the event. If they share the same line, then the event will move 1 step in a straight direction.

1762681030933.png


Here is the script I wrote:
Ruby:
#============================================================================
# Game_Character
#============================================================================
class Game_Character < Game_CharacterBase
  #--------------------------------------------------------------------------
  # new method: move_toward_character8 -> goes towards the character,
  # allows diagonal directions
  #--------------------------------------------------------------------------
  def move_toward_character8(character)
    sx = distance_x_from(character.x)
    sy = distance_y_from(character.y)
    #case for diagonal movements
    if sx.abs > 0 && sy.abs > 0
      dx = sx > 0 ? 4 : 6
      dy = sy > 0 ? 8 : 2
      move_diagonal(dx,dy)
      return if @move_succeed
    end
    #if straight line or if diagonal fails, tries straight movement
    move_toward_character(character)
  end
 
  #--------------------------------------------------------------------------
  # new method: move_toward_player8
  #--------------------------------------------------------------------------
  def move_toward_player8
    move_toward_character8($game_player)
  end
end #Game_Character

#============================================================================
# Game_Interpreter
#============================================================================
class Game_Interpreter
  #--------------------------------------------------------------------------
  # new method: move_toward_character8 -> current event goes to selected
  # character
  #--------------------------------------------------------------------------
  def move_toward_character8(character)
    $game_map.events[@event_id].move_toward_character_8(character) if same_map? && @event_id > 0
  end
 
  #--------------------------------------------------------------------------
  # new method: move_toward_player8
  #--------------------------------------------------------------------------
  def move_toward_player8
    $game_map.events[@event_id].move_toward_player8 if same_map? && @event_id > 0
  end
end #Game_Interpreter
Your game looks very nice!


When you say diagonal, do you mean just that the player is not in a straight line regarding the event?

I made a small script to allow an event to go towards a character diagonally, I'm unsure if the event triggering on collision works properly though so you might need a more advanced diagonal script in such case.

In your move commands, you can replace a step movement by a script call:
move_toward_player8
The event will go 1 step in diagonal direction if the player is not on the same x or y line with the event. If they share the same line, then the event will move 1 step in a straight direction.
Thank you so much!
And thank you for the script.
At first I didn't really like how it just follows the player but after a few tweaks, like making the fire slower and not letting it go as far as id did before, I actually don't mind it.
Here's how its looking.

It kinda seems to move unpredictably, like actual fire, so that's pretty neat.
Just a question though, is there any way to make the fire go just straight diagonal once it moves diagonally first. Like, if the fire starts off going diagonally, it just keeps going diagonally without trying to follow the player?
That was my original idea and while I do like how it currently is, I'd still like to tray it my original way just to compare.
Thank you
Yeah this is a design mistake from my part, here is a second version of the script:
Ruby:
#==============================================================================
# Diagonal Event's commands
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 09/11/2025
#==============================================================================

$imported = {} if $imported.nil?
$imported["TIM-DiagonalEventsCommands"] = true

#==============================================================================
# Version History
#------------------------------------------------------------------------------
# 09/11/2025: Original release
#==============================================================================
# Description: Adds move event commands that you can use in script calls
# when moving your events:
#
# turn_toward_character8(character) #(use this before using move_straight8)
# turn_toward_player8
# move_toward_character8(character)
# move_toward_player8
# set_direction8(d) #(with d in [1...9] a direction that allows diagonals too)
# move_straight8    #(walk forward, if a diagonal walk was used with my other
#                    script calls, then the forward will be diagonal)
#==============================================================================
# Term of use: Free to use in free or commercial games,  credit is not mandatory
#==============================================================================

#============================================================================
# TIM
#============================================================================
module TIM
  #============================================================================
  # Dir8 -> calculation regarding directions (values in numpad)
  #============================================================================
  module Dir8
    #--------------------------------------------------------------------------
    # new method: reverse_dir -> return the opposite direction
    #--------------------------------------------------------------------------
    def self.reverse_dir(d)
      return 10-d
    end
    #--------------------------------------------------------------------------
    # new method: dir_right (turn 90 degrees to the right)
    # 2 -> 4 -> 8 -> 6 -> 2 && 1 -> 7 -> 9 -> 3 -> 1
    #--------------------------------------------------------------------------
    def self.dir_right(d)
      (d*7) % 10
    end
    #--------------------------------------------------------------------------
    # new method: dir_left (turn 90 degrees to the left)
    # 2 -> 6 -> 8 -> 4 -> 2 && 1 -> 3 -> 9 -> 7 -> 1
    #--------------------------------------------------------------------------
    def self.dir_left(d)
      (d*3) % 10
    end
    #--------------------------------------------------------------------------
    # new method: diagonal? -. asks if direction is diagonal
    #--------------------------------------------------------------------------
    def self.diagonal?(d)
      d%2 != 0
    end
    #--------------------------------------------------------------------------
    # new method: pos_to_dir4 -> return a direction to look at x,y
    # (relative coordinates)
    #--------------------------------------------------------------------------
    def self.pos_to_dir4(x,y)
      return (x > 0 ? 6 : 4) if x.abs > y.abs
      return (y > 0 ? 2 : 8) if y != 0
      return 0 #no change to the dir
    end
    #--------------------------------------------------------------------------
    # new method: pos_to_dir8 -> return a direction to look at x,y
    # (relative coordinates)
    #--------------------------------------------------------------------------
    def self.pos_to_dir8(x,y)
      x = (x.abs / x).to_i if x != 0
      y = (y.abs / y).to_i if y != 0
      delta_to_dir(x,y)
    end
    #--------------------------------------------------------------------------
    # new method: delta_to_dir -> turns a [x,y] delta (x,y in [-1,0,1] each
    # into a dir8 in [1..9]
    #--------------------------------------------------------------------------
    def self.delta_to_dir(dx,dy)
      1 + (1 + dx) + (1 - dy) * 3
    end
    #--------------------------------------------------------------------------
    # new method: dir_to_pos -> return a [x,y] representing the direction
    #--------------------------------------------------------------------------
    def self.dir_to_pos(d)
      d -= 1
      dx = (d % 3) - 1
      dy = 1 - (d / 3)
      return [dx,dy]
    end
  end #Dir8
end #TIM

#============================================================================
# Game_Character
#============================================================================
class Game_Character < Game_CharacterBase
  #--------------------------------------------------------------------------
  # new method: set_direction8 -> sets the direction to one in [1..9]
  #--------------------------------------------------------------------------
  def set_direction8(d)
    return @dir8 = d if TIM::Dir8.diagonal?(d)
    @dir8 = nil
    set_direction(d)
  end
 
  #--------------------------------------------------------------------------
  # new method: turn_toward_character8
  #--------------------------------------------------------------------------
  def turn_toward_character8(character)
    sx = -distance_x_from(character.x)
    sy = -distance_y_from(character.y)
    set_direction8(TIM::Dir8.pos_to_dir8(sx,sy))
  end
 
  #--------------------------------------------------------------------------
  # new method: move_toward_character8 -> goes towards the character,
  # allows diagonal directions
  #--------------------------------------------------------------------------
  def move_toward_character8(character)
    turn_toward_character8(character)
    move_straight8
  end
 
  #--------------------------------------------------------------------------
  # new method: move_straight8 -> follows direction8 if available, else, use
  # the classic direction (dir4)
  #--------------------------------------------------------------------------
  def move_straight8
    if @dir8
      dx,dy = TIM::Dir8.dir_to_pos(@dir8)
      move_diagonal(dx > 0 ? 6 : 4, dy > 0 ? 2 : 8)
      return if @move_succeed
    end
    move_straight(@direction)
  end
 
  #--------------------------------------------------------------------------
  # new method: move_toward_player8
  #--------------------------------------------------------------------------
  def move_toward_player8
    move_toward_character8($game_player)
  end
 
  #--------------------------------------------------------------------------
  # new method: turn_toward_player8
  #--------------------------------------------------------------------------
  def turn_toward_player8
    turn_toward_character8($game_player)
  end
end #Game_Character
You can use in your event's move route the following script calls:
turn_toward_character8(character) (use this before using move_straight8)
turn_toward_player8
move_toward_character8(character)
move_toward_player8
set_direction8(d) (with d in [1...9] a direction that allows diagonals too)
move_straight8 (walk forward, if a diagonal walk was used with my other script calls, then the forward will be diagonal)
Yeah this is a design mistake from my part, here is a second version of the script:
Ruby:
#============================================================================
# TIM
#============================================================================
module TIM
  #============================================================================
  # Dir8 -> calculation regarding directions (values in numpad)
  #============================================================================
  module Dir8
    #--------------------------------------------------------------------------
    # new method: reverse_dir -> return the opposite direction
    #--------------------------------------------------------------------------
    def self.reverse_dir(d)
      return 10-d
    end
    #--------------------------------------------------------------------------
    # new method: dir_right (turn 90 degrees to the right)
    # 2 -> 4 -> 8 -> 6 -> 2 && 1 -> 7 -> 9 -> 3 -> 1
    #--------------------------------------------------------------------------
    def self.dir_right(d)
      (d*7) % 10
    end
    #--------------------------------------------------------------------------
    # new method: dir_left (turn 90 degrees to the left)
    # 2 -> 6 -> 8 -> 4 -> 2 && 1 -> 3 -> 9 -> 7 -> 1
    #--------------------------------------------------------------------------
    def self.dir_left(d)
      (d*3) % 10
    end
    #--------------------------------------------------------------------------
    # new method: diagonal? -. asks if direction is diagonal
    #--------------------------------------------------------------------------
    def self.diagonal?(d)
      d%2 != 0
    end
    #--------------------------------------------------------------------------
    # new method: pos_to_dir4 -> return a direction to look at x,y
    # (relative coordinates)
    #--------------------------------------------------------------------------
    def self.pos_to_dir4(x,y)
      return (x > 0 ? 6 : 4) if x.abs > y.abs
      return (y > 0 ? 2 : 8) if y != 0
      return 0 #no change to the dir
    end
    #--------------------------------------------------------------------------
    # new method: pos_to_dir8 -> return a direction to look at x,y
    # (relative coordinates)
    #--------------------------------------------------------------------------
    def self.pos_to_dir8(x,y)
      x = (x.abs / x).to_i if x != 0
      y = (y.abs / y).to_i if y != 0
      delta_to_dir(x,y)
    end
    #--------------------------------------------------------------------------
    # new method: delta_to_dir -> turns a [x,y] delta (x,y in [-1,0,1] each
    # into a dir8 in [1..9]
    #--------------------------------------------------------------------------
    def self.delta_to_dir(dx,dy)
      1 + (1 + dx) + (1 - dy) * 3
    end
    #--------------------------------------------------------------------------
    # new method: dir_to_pos -> return a [x,y] representing the direction
    #--------------------------------------------------------------------------
    def self.dir_to_pos(d)
      d -= 1
      dx = (d % 3) - 1
      dy = 1 - (d / 3)
      return [dx,dy]
    end
  end #Dir8
end #TIM

#============================================================================
# Game_Character
#============================================================================
class Game_Character < Game_CharacterBase
  #--------------------------------------------------------------------------
  # new method: set_direction8 -> sets the direction to one in [1..9]
  #--------------------------------------------------------------------------
  def set_direction8(d)
    return @dir8 = d if TIM::Dir8.diagonal?(d)
    @dir8 = nil
    set_direction(d)
  end
 
  #--------------------------------------------------------------------------
  # new method: turn_toward_character8
  #--------------------------------------------------------------------------
  def turn_toward_character8(character)
    sx = -distance_x_from(character.x)
    sy = -distance_y_from(character.y)
    set_direction8(TIM::Dir8.pos_to_dir8(sx,sy))
  end
 
  #--------------------------------------------------------------------------
  # new method: move_toward_character8 -> goes towards the character,
  # allows diagonal directions
  #--------------------------------------------------------------------------
  def move_toward_character8(character)
    turn_toward_character8(character)
    move_straight8
  end
 
  #--------------------------------------------------------------------------
  # new method: move_straight8 -> follows direction8 if available, else, use
  # the classic direction (dir4)
  #--------------------------------------------------------------------------
  def move_straight8
    if @dir8
      dx,dy = TIM::Dir8.dir_to_pos(@dir8)
      move_diagonal(dx > 0 ? 6 : 4, dy > 0 ? 2 : 8)
      return if @move_succeed
    end
    move_straight(@direction)
  end
 
  #--------------------------------------------------------------------------
  # new method: move_toward_player8
  #--------------------------------------------------------------------------
  def move_toward_player8
    move_toward_character8($game_player)
  end
 
  #--------------------------------------------------------------------------
  # new method: turn_toward_player8
  #--------------------------------------------------------------------------
  def turn_toward_player8
    turn_toward_character8($game_player)
  end
end #Game_Character
You can use in your event's move route the following script calls:
turn_toward_character8(character) (use this before using move_straight8)
turn_toward_player8
move_toward_character8(character)
move_toward_player8
set_direction8(d) (with d in [1...9] a direction that allows diagonals too)
move_straight8 (walk forward, if a diagonal walk was used with my other script calls, then the forward will be diagonal)
thank you so much!
Yeah this is exactly what I wanted.
Though after a bit of testing I think it always going straight forward makes the flamthrower kinda worthless so I think using a mix of walk forward and move towards player adding that bit of unpredictability while also making it more fair to the player.
Thank you so much for this script!
Do you have a name for it so I can credit it in the game?
I updated the script above to add an header, you may credit me for it, though it's not mandatory for this script ~

Original thread: https://forums.rpgmakerweb.com/threads/diagonal-movement-for-a-specific-event-but-not-the-player.180926/