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: 4
  • normal path 2.png
    normal path 2.png
    193.2 KB · Views: 4
  • scripted path.png
    scripted path.png
    188.5 KB · Views: 4
  • turret projectile script.png
    turret projectile script.png
    108 KB · Views: 2
  • turret script.png
    turret script.png
    228.6 KB · Views: 4

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
5,043
Reaction score
4,395
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

bandicam 2023-10-03 21-54-15-591.png
Redrawing this month
Me: "Who the heck would play a game with no stakes, no enemies, and all you do is raise and breed bees?"
Later after playing it. - "Holy crap, I didn't know it was 1:30. Where'd my time go?"
The site is being slow and funky again. IS SOMEONE CRAFTING POEMS?!
So yeah, @TRIDIUM @TESTOSTERONE, I wuz like, "What do they mean by borderline and boundaries?"

And then, y'all know this girl?

actress1.png

alice_bikini.png

The clothes? They're just a, um, quick edit. :kaoswt:
I've uploaded the opening cutscene from my game to my channel. It basically introduces us to the first three characters, and what their relationships are:
Cosmic Inferno: Opening dialogue

Forum statistics

Threads
135,025
Messages
1,253,048
Members
177,956
Latest member
Monster_Circle
Top