Copies someone move route

CodeEmpress

Villager
Member
Joined
Feb 3, 2014
Messages
21
Reaction score
0
First Language
English
Primarily Uses
Could someone help me? (I am new to rgss3)

Well what I need is a script that copies the movement or a certain event.

Example: Given we have two points A and B then Event 1 and 2

Let us say Event 1 found a path starting from A and B. Then I want Event 2 to copy that path.

What I wanna do is that under Event 1 I will create an Event 2 which is like a very fast dot that copies the path of Event 1. More like you are having a line and it shows where you are going.

Thank you very much
 
Last edited by a moderator:

ShadowLurk

Tanoshii~
Veteran
Joined
Feb 14, 2014
Messages
226
Reaction score
53
Primarily Uses
What did you use for pathfinding? Most of the pathfinding scripts I see does not store an array containing their move routes, so by that reason, their path cannot be copied. If you do use pathfinding scripts, just call the same pathfinding method for the second event.
 

CodeEmpress

Villager
Member
Joined
Feb 3, 2014
Messages
21
Reaction score
0
First Language
English
Primarily Uses

ShadowLurk

Tanoshii~
Veteran
Joined
Feb 14, 2014
Messages
226
Reaction score
53
Primarily Uses
Well, let's try this.

class Game_Character attr_accessor :saved_found_path def save_path(x, y, dist = 0) path = $game_map.find_path(x, y, self.x, self.y, dist).reverse @saved_found_path = path.dup end  

  def execute_saved_path(ev = 0)

    if ev == 0

      src_char = self

    elsif ev < 0

      src_char = $game_player

    else

      src_char = $game_map.events[ev]

    end

    return unless src_char.saved_found_path

    path = src_char.saved_found_path

    if !@move_route.repeat

      @move_route.list.delete_at(@move_route_index)

      @move_route.list.insert(@move_route_index, *path)

      @move_route_index -= 1

    elsif path.length > 0

      process_move_command(path[0])

      @move_route_index -= 1

    end

  end

def find_path_saved(x, y, dist = 0) save_path(x, y, dist) execute_saved_path end end class Game_Interpreter def save_path(x, y, ev = 0, dist = 0) char = get_character(ev) #modified line below (added distance parameter) path = $game_map.find_path(x, y, char.x, char.y, dist) path.reverse! path.push(RPG::MoveCommand.new(0)) char.saved_found_path = path.dup end def execute_saved_path(ev = 0, src_ev = ev, wait = false) char = get_character(ev) src_char = get_character(src_ev) return unless src_char.saved_found_path path = src_char.saved_found_path route = RPG::MoveRoute.new route.list = path route.wait = wait route.skippable = true route.repeat = false char.force_move_route(route) end def find_path_saved(x, y, ev = 0, wait = false, dist = 0) save_path(x, y, ev, dist) execute_saved_path(ev, ev, wait) end end 

To find move path while saving them, use 

find_path_saved in either event page or set move route. The arguments mirror find_path.

To execute saved move path, use

execute_saved_path(event, source_event)in event page, or

execute_saved_path(event)in move route page.

Edit: Fixed some errors.
 
Last edited by a moderator:

CodeEmpress

Villager
Member
Joined
Feb 3, 2014
Messages
21
Reaction score
0
First Language
English
Primarily Uses
Thank you gonna try it later when I got home :o
 

ShadowLurk

Tanoshii~
Veteran
Joined
Feb 14, 2014
Messages
226
Reaction score
53
Primarily Uses
Wait. It seems that the script formatting in my last post just... exploded.

Here should be the snippet with the proper formatting:

class Game_Character attr_accessor :saved_found_path def save_path(x, y, dist = 0) path = $game_map.find_path(x, y, self.x, self.y, dist).reverse @saved_found_path = path.dup end def execute_saved_path(ev = 0) if ev == 0 src_char = self elsif ev < 0 src_char = $game_player else src_char = $game_map.events[ev] end return unless src_char.saved_found_path path = src_char.saved_found_path if !@move_route.repeat @move_route.list.delete_at(@move_route_index) @move_route.list.insert(@move_route_index, *path) @move_route_index -= 1 elsif path.length > 0 process_move_command(path[0]) @move_route_index -= 1 end end def find_path_saved(x, y, dist = 0) save_path(x, y, dist) execute_saved_path end endclass Game_Interpreter def save_path(x, y, ev = 0, dist = 0) char = get_character(ev) #modified line below (added distance parameter) path = $game_map.find_path(x, y, char.x, char.y, dist) path.reverse! path.push(RPG::MoveCommand.new(0)) char.saved_found_path = path.dup end def execute_saved_path(ev = 0, src_ev = ev, wait = false) char = get_character(ev) src_char = get_character(src_ev) return unless src_char.saved_found_path path = src_char.saved_found_path route = RPG::MoveRoute.new route.list = path route.wait = wait route.skippable = true route.repeat = false char.force_move_route(route) end def find_path_saved(x, y, ev = 0, wait = false, dist = 0) save_path(x, y, ev, dist) execute_saved_path(ev, ev, wait) end end
Hopefully this one won't explode....
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,018
Members
137,563
Latest member
MinyakaAeon
Top