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,341
Reaction score
3,381
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 Profile Posts

So I managed to scare my chief. Between shifts I had an appointment with my psychiatrist, so prior to it I'd told him "If I ain't coming today, they've kept me there.". Then as I was asleep, my phone died. So I overslept and through the entire time I was unreachable.
I spent so much time toiling in VX Ace frankensteining scripts together only for MV to come along and just... have everything.

The overworld tool system in particular I thought was gonna take me a million years to recreate, but nope. Thanks Moghunter.
Going to go live way earlier than usual tonight, pretty much in 20 minutes, purely because I'm bored. :LZSlol:

So... I'm gonna be a parent... XD

Forum statistics

Threads
128,379
Messages
1,194,063
Members
168,877
Latest member
eternaldes
Top