[Solved]Event that Follow another Event

Started by MetalZelda, March 15, 2014, 01:37:56 pm

Previous topic - Next topic

MetalZelda

March 15, 2014, 01:37:56 pm Last Edit: March 17, 2014, 10:02:53 am by MetalZelda
Hello everyone
Okay so I don't know if this was asked before, or else ...

Well, All I want is a event that follow another event in a scripting or eventing way, all result I found was RPG VX Ace scripts, and some was using the Move Straight Method but didn't succeed well.

I don't really know what to do, this special thing would allow extended boss making or NPC interraction for example
If someone have the solution, or have time to convert this script, it would be cool


=begin
==============================================================================
** FP: Move Routes
Author: Tsukihime
Date: Aug 17, 2012
------------------------------------------------------------------------------
** Change log
Sep 3
  -added support for "compass-based" movement.
Aug 17
  -fixed bug where custom move route causes freezing
Jul 8
  -fixed bug where retrieving character on map was flawed
May 17
  -Initial release
------------------------------------------------------------------------------
Extends the move route system by providing more options.
Acessible through move route scripts

You can specify a sequence of move commands by typing a
move-string

  moves("UDUDLRLR3R3R3L3L")
   
U means up
D means down
L means left
R means right.

For diagonal movement, use the following
Q is upper-left
W is upper-right
A is lower-left
S is lower-right

You can also specify some movement behavior.
They all take an event ID corresponding to the
event ID on the game map

  move_toward_event (event_id)
  move_from_event (event_id)
  turn_toward_event (event_id)
  turn_from_event (event_id)
 
You can also play a balloon animation

  show_balloon(anim_id, event_id)
 
0 is the event itself (can be omitted)
-1 is the player
other event ID's are events on the map

Compass-based movement uses the compass directions to determine which
direction to move. For example

 North direction = up
    move_north = up
    move_south = down
   
 North direction = left
    move_north = left
    move_south = right
   
The following methods are available

  set_north(direction)
    -takes a numerical direction (2, 4, 6, 8) to specify the north dir
     
  move_north(count)
  move_south(count)
  move_west(count)
  move_east(count)
  turn_north
  turn_west
  turn_east
  turn_south
 
Where `count` is the number of times you want to move in that direction
==============================================================================
=end
$imported = {} if $imported.nil?
$imported["FP_MoveRoutes"] = true
#==============================================================================
# ** Configuration.
#==============================================================================
module Feature_Plus
 module Move_Routes
   
   Move_String = /(\d*)([UDLRQWAS])/
 end
end
#==============================================================================
# ** Rest of the script.
#==============================================================================

class Game_Character < Game_CharacterBase
 include Feature_Plus::Move_Routes
 
 alias :fp_move_route_init_private_members :init_private_members
 def init_private_members
   fp_move_route_init_private_members
   @northDir = 8
   @jump_distance = 1
   @follow_distance = 0
 end
 
 def add_move(move_route, dir, num=1)
   num.times do |i|
     move_route.list.insert(move_route.list.size - 1, RPG::MoveCommand.new(dir))
   end
 end
 
 def get_character(id)
   if id < 0
     $game_player
   else
     $game_map.events[id > 0 ? id : @id]
   end
 end
 
 def show_animation(anim_id, event_id=0)
   character = get_character(event_id)
   return unless character    
   character.animation_id = anim_id
 end
 
 def show_balloon(anim_id, event_id=0)
   character = get_character(event_id)
   return unless character
   character.balloon_id = anim_id
 end
 #--------------------------------------------------------------------------
 # * Define move route using move string
 #--------------------------------------------------------------------------
 def moves(string)
   move_route = RPG::MoveRoute.new
   cmds = string.scan(Move_String)
   cmds.each do |cmd|
     num = cmd[0].empty? ? 1 : cmd[0].to_i rescue 1
     case cmd[1]
     when "U"; code = ROUTE_MOVE_UP
     when "D"; code = ROUTE_MOVE_DOWN
     when "L"; code = ROUTE_MOVE_LEFT
     when "R"; code = ROUTE_MOVE_RIGHT
     when "Q"; code = ROUTE_MOVE_UPPER_L
     when "W"; code = ROUTE_MOVE_UPPER_R
     when "A"; code = ROUTE_MOVE_LOWER_L
     when "S"; code = ROUTE_MOVE_LOWER_R
     end
     add_move(move_route, code, num)
   end
   # replace the script call
   @move_route.list.delete_at(@move_route_index)
   @move_route.list.insert(@move_route_index, *move_route.list[0...-1])
   @move_route_index -= 1
 end

 def move_pos(x, y)
   sx = distance_x_from(x)
   sy = distance_y_from(y)
   if sx.abs > 0
     move_straight(sx > 0 ? 4 : 6)
     move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sy.abs != 0
   elsif sy.abs > 0
     move_straight(sy > 0 ? 8 : 2)
     move_straight(sx > 0 ? 4 : 6) if !@move_succeed && sx.abs != 0
   end
 end
 
 #--------------------------------------------------------------------------
 # * Convenience methods
 #--------------------------------------------------------------------------
 def move_down(count)
   count.times { move_straight(2)}
 end
 
 def move_left(count)
   count.times { move_straight(4)}
 end
 
 def move_right(count)
   count.times { move_straight(6)}
 end
 
 def move_up(count)
   count.times { move_straight(8)}
 end
 
 #--------------------------------------------------------------------------
 # * 4-dir compass-based movement, based on the which direction is "north".
 #--------------------------------------------------------------------------
 
 def set_north(direction)
   @northDir = direction
 end
 
 def move_north(count=1)
   case @northDir
   when 2
     move_down(count)
   when 4
     move_left(count)
   when 6
     move_right(count)
   when 8
     move_up(count)
   end
 end
 
 def move_west(count=1)
   case @northDir
   when 2
     move_right(count)
   when 4
     move_down(count)
   when 6
     move_up(count)
   when 8
     move_left(count)
   end
 end
 
 def move_east(count=1)
   case @northDir
   when 2
     move_left(count)
   when 4
     move_up(count)
   when 6
     move_down(count)
   when 8
     move_right(count)
   end
 end
 
 def move_south(count=1)
   case @northDir
   when 2
     move_up(count)
   when 4
     move_right(count)
   when 6
     move_left(count)
   when 8
     move_down(count)
   end
 end
 
 def turn_north
   case @northDir
   when 2
     set_direction(2)
   when 4
     set_direction(4)
   when 6
     set_direction(6)
   when 8
     set_direction(8)
   end
 end
 
 def turn_east
   case @northDir
   when 2
     set_direction(4)
   when 4
     set_direction(8)
   when 6
     set_direction(2)
   when 8
     set_direction(6)
   end
 end
 
 def turn_west
   case @northDir
   when 2
     set_direction(6)
   when 4
     set_direction(2)
   when 6
     set_direction(8)
   when 8
     set_direction(4)
   end
 end
 
 def turn_south
   case @northDir
   when 2
     set_direction(8)
   when 4
     set_direction(6)
   when 6
     set_direction(4)
   when 8
     set_direction(2)
   end
 end
 
 #--------------------------------------------------------------------------
 # * Move toward event, by event id
 #--------------------------------------------------------------------------
 def move_toward_event(event_id)
   event = get_character(event_id)
   move_toward_character(event)
 end
 #--------------------------------------------------------------------------
 # * Move away from event, by event id
 #--------------------------------------------------------------------------
 def move_from_event(event_id)
   event = get_character(event_id)
   move_away_from_character(event)
 end
 #--------------------------------------------------------------------------
 # * Turn toward event, by event id
 #--------------------------------------------------------------------------
 def turn_toward_event(event_id)
   event = get_character(event_id)
   turn_toward_character(event)
 end
 #--------------------------------------------------------------------------
 # * Turn away from event, by event id
 #--------------------------------------------------------------------------
 def turn_from_event(event_id)
   event = get_character(event_id)
   turn_away_from_character(event)
 end
 
 def mt_event(evt_id)
   move_toward_event(evt_id)
 end
 
 def mf_event(evt_id)
   move_from_event(evt_id)
 end
 
 def tt_event(evt_id)
   turn_toward_event(evt_id)
 end
 
 def tf_event(evt_id)
   turn_from_event(evt_id)
 end
end

Zexion

Couldn't you just give the two events the same move route?

G_G

No, because that's obviously too much work and we all know game development is supposed to be easy. :V

Seriously, what Zexion said, since you said you'd be okay with eventing it, it wouldn't be that hard to make one event follow another.

MetalZelda

March 17, 2014, 08:52:53 am #3 Last Edit: March 17, 2014, 10:02:25 am by MetalZelda
I found a script by Heretic that allow this option, And I accidentally posted this before seeing Heretic's script ^^
@Zenion : It's more faster to have 1 script call instead of editing all parts,etc. I was thinking of a boss for a Zelda game here ^^

http://forum.chaos-project.com/index.php/topic,12295.0.html