Restarting a move route when interrupted?

EternalShadow

Veteran
Veteran
Joined
Sep 16, 2012
Messages
5,781
Reaction score
1,041
First Language
English
Primarily Uses
I have a fireball that's flung at players. It's basically a dodging game. 

This fireball is set with a move route. It goes right 10 times.

However, if the player touches the fireball, it is set to 'blow up' and goes back to the magician to continue its pattern of movement.

The issue with this is that it then moves right about 5 times if the player walked into it when it had already moved right 5 times, and goes back to the magician and continues normally if the player does not touch it again.

The fireball is basically trying to use up the remainder of its movements whenever it is touched.

Therefore, I need to find a way to restart an event's movement. Is there a way to do this, or does it need a script?

Thanks.

~The very tired HFL

EDIT:

Screenies;

(Ignore page 2, that was me trying to fiddle with it, it is just 'self switch a' with no text so it doesn't work)

http://imgur.com/AQ2sYM3

And the custom move route:

http://imgur.com/ZITzEyf

EDIT:

Switch 27 puts the fireball back at the start. A parallel does this and then waits for a few frames.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Why do you have 2 pages on the event? If the second page is conditioned by the switch and is what moves the fireball back to its starting spot, delete it.

Then change your custom move route to this:

Set Move Route (This Event) Move Right Script: if x > x1 then moveto(x2,y2)Set the move route to RepeatWhere I have x1, you put the x tile that you want it to reach before returning to the start (if it's 15, put 15, not 015).

Where I have x2 and y2, you put the x and y position of the tile you want it to move back to.

Then in the event commands, also get rid of anything to do with the switch, and instead, use the Set Event Location command to put it back to the starting position.

So you are making both the move route when it reaches the extremity, and the commands when it hits the player, move the event back to where it needs to be, and are not relying on a switch and additional event page to do it.

I THINK the above will work. I don't have Ace with me right now, so can't run a test.
 
Last edited by a moderator:

EternalShadow

Veteran
Veteran
Joined
Sep 16, 2012
Messages
5,781
Reaction score
1,041
First Language
English
Primarily Uses
Why do you have 2 pages on the event? If the second page is conditioned by the switch and is what moves the fireball back to its starting spot, delete it.

Then change your custom move route to this:

Set Move Route (This Event) Move Right Script: if x > x1 then moveto(x2,y2)Set the move route to RepeatWhere I have x1, you put the x tile that you want it to reach before returning to the start (if it's 15, put 15, not 015).

Where I have x2 and y2, you put the x and y position of the tile you want it to move back to.

Then in the event commands, also get rid of anything to do with the switch, and instead, use the Set Event Location command to put it back to the starting position.

So you are making both the move route when it reaches the extremity, and the commands when it hits the player, move the event back to where it needs to be, and are not relying on a switch and additional event page to do it.

I THINK the above will work. I don't have Ace with me right now, so can't run a test.
Hi, sorry for late response, only just got back on Ace.

A scripting error occurs:

http://imgur.com/6HAsP4Q

This is what I have:

if x > 18 then moveto(4,3)
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,676
First Language
German
Primarily Uses
RMMV
This is what I have:


if x > 18 then moveto(4,3)
Please post a screenshot of what you have done, the problem is either placing it in the wrong area or before that line.
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
I took an entirely different approach to setting up projectiles in my games and I don't think I've ever had this move-route problem.  So if the fixes that other people have suggested can work, no need to redesign around my ideas, but if not, give this a try:

Set up the projectile events that have a blank page, then (at least) a second page where the autonomous movement is FIXED.  Set a switch of your choice as a condition for this event page.  Set the trigger to Parallel Process.  Now, in the event body of the page, use a Set Move Route command which contains the full move cycle of Move Right 10 Times.  Make sure you set the Wait option on the Move Route (in most cases you'll also want to set Skip).  After Move Route, add a command to reset the event's location to its origin where it's fired from and then turn the switch off (for better aesthetics, you can set the location offscreen, but then make sure whatever event turns it back on also warps it to the origin where it's fired from).

Whenever you want the projectile to fire, simply have the switch you chose about turn ON.  You can attach that to a timed parallel process event, a button, whatever you want.

You're halfway there.  Since the event body is now controlling the event automatically, rather than on player touch, we need another Parallel event that will check the projectile's location against the player's location.  There are lots of ways to do this with eventing - don't bother.  Here's the basic code you can use to do it much more easily using a Script command:

fire = $game_map.events[3]player = $game_playerif (fire.x == player.x) && (fire.y == player.y)fire.moveto(0, 137)$game_switches[208] = falseendBasically, this checks to see if the fire has hit the player, then turns the fire event off once it has hit the player and moves it back to wherever you want.  Replace 3 with the Event ID of the fire projectile (if you have more than 1 fire projectile, I recommend replacing 3 with i and placing the whole thing in a for loop), the two moveto arguments with the appropriate x and y coordinates the projectile should move back to once it hits the player, and 208 with whatever switch you used above to control the presence of the projectile.  Add in whatever gameplay effects you want to happen when the player is hit by the fire.  Also, I recommend that you add a 1-frame wait at the beginning or end so it's not constantly processing.

Make sure that the actual fire projectile event has the THROUGH property set to ON for all pages.

Basically, the wisdom of this whole approach is that the Move Route will be cancelled as soon as the fire is turned "off", and will restart (causing the entire move route to restart) whenever you turn the fire back "on".
 

EternalShadow

Veteran
Veteran
Joined
Sep 16, 2012
Messages
5,781
Reaction score
1,041
First Language
English
Primarily Uses
Ideally, I would like to avoid scripting as I often run into many issues with it, personally :p

For instance:

Code:
fire = $game_map.events[3]player = $game_playerif (fire.x == player.x) && (fire.y == player.y)fire.moveto(0, 137)$game_switches[208] = falseend
Where is the map number designated? Surely you need a map number to ensure the script doesn't fire on every map? I can't quite explain what I'm saying, but how is this script actually 'activated'?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Only if it's a parallel process COMMON event.
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
Ideally, I would like to avoid scripting as I often run into many issues with it, personally :p

For instance:

fire = $game_map.events[3]player = $game_playerif (fire.x == player.x) && (fire.y == player.y)fire.moveto(0, 137)$game_switches[208] = falseendWhere is the map number designated? Surely you need a map number to ensure the script doesn't fire on every map? I can't quite explain what I'm saying, but how is this script actually 'activated'?
Well, you could event that whole thing if you want; it wouldn't be particularly hard if there's only one fire projectile being used.  Set the X and Y for each into variables, compare them, and use the Set Event Location and Set Switch commands if appropriate.

Either way, it should go inside a Parallel Process event on the map.  Parallel Process events don't need to be "triggered"; they simply run as long as any conditions (in this case, no conditions) are satisfied.  This is why I recommend 1 or more frames of Wait time; this way it will trigger several times per second rather than thousands of times per second (which would create a huge performance hit).

Like Shaz said, only Common Events will trigger on every map.  Map events that are set to Parallel Process will only run while you're on that map.  And lines like $game_map.events[3] automatically look at only the current map's events.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
I have what I think is the perfect solution.  Unfortunately, I can't find the link to the script, and although I have it, I think Archeia's terms are that her scripts cannot be reposted.  But in the hope that someone else knows what the link is, or if you pm her asking where it is, here is the solution.

Script:  NPC Patrol

Scripters Yami, Archeia_Nessiah

Dated 2012.09.14

What it does:

Makes an NPC - or in this case, your fireball - move in a horizontal or vertical path.  Think soldiers patrolling on city walls.  Done by placing a simple Comment on the first event page.

If it hits something, it travels back to its starting position.

In order to ensure that it just does the 10 tiles that you want, place a blank event on the 11th tile so that it hits it when its on its 10th tile.

That's all. 
 

EternalShadow

Veteran
Veteran
Joined
Sep 16, 2012
Messages
5,781
Reaction score
1,041
First Language
English
Primarily Uses
Sorry guys, I gave up and did it the old-fashioned way :p

The very simple solution:

3 event pages.

Page 1: The normal 'event touch' fireball which blows up, vanishes and activates page 2 if it touches the player.

Page 2: Waits a few seconds, then restarts the position of the fireball. Then it waits a few seconds more, and disables its own page (2). 

Page 3: Disables the event entirely if the mage is 'attacked' (activated/touched). 

The logic is that if you go to another event page, then back to the original page (with a wait, of course) - the event resets its own move route! :p

So thanks for trying to help guys, lol - but it looks like the old ways worked XD
 

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

Latest Threads

Latest Profile Posts

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
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

Forum statistics

Threads
105,868
Messages
1,017,072
Members
137,578
Latest member
JamesLightning
Top