Having trouble setting a temporary stop or slowing enemy movement in my Tower Defence.

Drekex

Villager
Member
Joined
Dec 5, 2021
Messages
28
Reaction score
8
First Language
French
Primarily Uses
RMMZ
How it works with Galv’s projectile script, is that when an event with the projEffect comment is hit, the event set in the projectile movement route script is triggered.

I tried to use a normal movement route, but when a different speed is triggered by an outside event, it breaks the intended path.

The other way I’ve tried it is with a Script. When the enemy reaches a turning point in the track specified in the coordinates, it changes its movement route to turn in the intended direction. The problem is, by using an outside event to stop its movement, it aborts the direction and completely stops since it changed route. Even slowing its speed doesn’t work since it aborts the current path anyway (but it is how it’s supposed to work).

I’d like to know if there is a simple way to slow or stop enemy movement without breaking the intended path. It can be a script or a plugin as well.
 

Attachments

  • normal path.png
    normal path.png
    179.5 KB · Views: 3
  • normal path 2.png
    normal path 2.png
    193.2 KB · Views: 3
  • scripted path.png
    scripted path.png
    188.5 KB · Views: 3
  • turret projectile script.png
    turret projectile script.png
    108 KB · Views: 2
  • turret script.png
    turret script.png
    228.6 KB · Views: 3

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
4,338
Reaction score
3,374
First Language
EN
Primarily Uses
RMMZ
As you've noticed, a character can only have 1 move route at a time. (Events may have an autonomous route, but that's just a default used when they don't have a "normal" route assigned via the Set Movement Route command.)

You can use a Script command to set a character's move speed without using a move route, e.g.

$gameMap.event(123).setMoveSpeed(3.5)
I.e. "set map event 123's move speed equal to 3.5".

To make a character stop completely, you can set their move speed to -1067 or less, e.g.

$gameMap.event(123).setMoveSpeed(-2000);
This value is because the default move speed is a logarithmic scale: +1 speed makes you move twice as fast. 0 speed just means you move at 2^(0-8) = 1/256 tiles per frame. By exploiting the limited precision of JavaScript's Number, it is possible to get an effective distancePerFrame of 0.
[Edit: corrected the value I wrote for 0-speed "tiles per frame" in my technical explanation. :kaoslp:]
 
Last edited:

Drekex

Villager
Member
Joined
Dec 5, 2021
Messages
28
Reaction score
8
First Language
French
Primarily Uses
RMMZ
Ok, so it works perfectly!
I set the speed to stop the event's movement:
$gameMap.event(1).setMoveSpeed(-1068)
Then, I used a wait script call to stun 20 frames since it doesn't affect the route:
$gameMap.event(1)._waitCount = 19;
After, the speed is set back to the original event speed:
$gameMap.event(1).setMoveSpeed(3)
 

Latest Threads

Latest Posts

Latest Profile Posts

Debugging multiplayer issues... I'm having fun, right?
yay_streaming.jpg

For just starting streaming on the 10th... Definitely not the worst. :LZScheeze:

Granted I need 333.34 hours a month on average to achieve money. So I don't really expect that, but it sure has helped my game dev go much faster.
Proud on how this map turned out.

FnmhDLIXgAAOvIC
I just finally fixed a huge problem that wouldn’t let my game load and would crash it.. I thought that I was gonna have to trash the project and start over lol
The feeling when you finally found and killed that one gamebreaker that you could not really grasp before.:kaojoy:

Forum statistics

Threads
128,327
Messages
1,193,626
Members
168,808
Latest member
snotery
Top