Faybs

Warper
Member
Joined
May 19, 2021
Messages
4
Reaction score
0
First Language
English
Primarily Uses
RMMZ
Hello!

I have a problem. For the first time I need to use script commands in my game in order to make it work efficiently. My problem is: I need to set a Move Command from an event which Event ID has (already) been stored in a variable (let's assume Var:20). And I want the move command to be: Go towards X, Y (coordinates, that also have been stored in a variable each) (let's assume Var:21 and 22).
So (again) I know how to store variables, but the issue is to make a line that takes the Event ID (var:20) go towards (var: 21), (var 22)
Please help me out! I would be very grateful! I am open to every suggestion!
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,885
Reaction score
8,240
First Language
German
Primarily Uses
RMMV
if that should happen on any map with any obstacles, then it needs more than just a few mathematics to determine direction - it would need a pathfinding script for the event to find its way around the obstacles to the position.

so you need to find a plugin that enables such a pathfinding script command, and then it completely depends on what functions that plugin offers.
 

Faybs

Warper
Member
Joined
May 19, 2021
Messages
4
Reaction score
0
First Language
English
Primarily Uses
RMMZ
if that should happen on any map with any obstacles, then it needs more than just a few mathematics to determine direction - it would need a pathfinding script for the event to find its way around the obstacles to the position.

so you need to find a plugin that enables such a pathfinding script command, and then it completely depends on what functions that plugin offers.
That is true, but in my case I have no obstacles. To make it easier, I would like to be using the command that is used in the Movement command editor, "Move toward player".
If this is not possible then, I can make the calculations on my own, but therefore I would need a simple command movement such as "Move Down" or "Move Up".
But you have to consider that the event ID that will be moved is defined by a variable (20).
So if you could give me a formula (Script) that solves this problem I would be very grateful. :)
 

EthanFox

Veteran
Veteran
Joined
Oct 15, 2018
Messages
551
Reaction score
352
First Language
English
Primarily Uses
RMMV
Faybs, do you know for a fact that there won't be any obstacles in the way? As that makes it significantly more complex if so.
 

Faybs

Warper
Member
Joined
May 19, 2021
Messages
4
Reaction score
0
First Language
English
Primarily Uses
RMMZ
Faybs, do you know for a fact that there won't be any obstacles in the way? As that makes it significantly more complex if so.
Yes for sure I can design it that way. So what would be your propositions?
 

EthanFox

Veteran
Veteran
Joined
Oct 15, 2018
Messages
551
Reaction score
352
First Language
English
Primarily Uses
RMMV
Yes for sure I can design it that way. So what would be your propositions?

In that case, you're dealing with a basic formula - "the difference between two points".

Do this:

x distance to walk = end x - start x
y distance to walk = end y - start y

Positive values mean you walk right/up, negative values mean you walk left/down.

If you move across, then vertically, then you'll reach your destination, but with a right-angled path.

There are various algorithms you can use to "draw a direct line" from one point to another on a pixel grid.

One thing you could do is randomly choose to move 1 space horizontally/1 space vertically, reducing the amount you need to move each time, so you'll always get a sort-of-diagonal line to your destination.

What sort of effect are you looking for? What's doing the movement, and what are they trying to do?
 

Faybs

Warper
Member
Joined
May 19, 2021
Messages
4
Reaction score
0
First Language
English
Primarily Uses
RMMZ
In that case, you're dealing with a basic formula - "the difference between two points".

Do this:

x distance to walk = end x - start x
y distance to walk = end y - start y

Positive values mean you walk right/up, negative values mean you walk left/down.

If you move across, then vertically, then you'll reach your destination, but with a right-angled path.

There are various algorithms you can use to "draw a direct line" from one point to another on a pixel grid.

One thing you could do is randomly choose to move 1 space horizontally/1 space vertically, reducing the amount you need to move each time, so you'll always get a sort-of-diagonal line to your destination.

What sort of effect are you looking for? What's doing the movement, and what are they trying to do?
So my goal is to be able to move a character automatically from one point to another. Basically that when the player tells him to go there the event (might be an animal or person) follows him.
I just need what kind of script you would use, because I am sure that I can manage basic calculations. I don't know how to script but, to me, it should sound like this:

Event_ID($gameVariables.value(20)).step_toward($gameVariables.value(21),$gameVariables.value(22))

And since I am new to scripting I have no clue where the problem is. Please help me out. ^^'
 

EthanFox

Veteran
Veteran
Joined
Oct 15, 2018
Messages
551
Reaction score
352
First Language
English
Primarily Uses
RMMV
Ah if you want to do it in javascript, someone will need to come along who happens to be better at that than I.
 

Latest Threads

Latest Posts

Latest Profile Posts

Ohh man, Weapon animations plugin feels so mandatory. Seeing that same image regardless of the icon of the weapon....ugh :p
Ok so......Maaaaybe I've taken a ''little'' bit of inspiration from FF9 when it comes to battle hud xD

ff9.PNG

Just maybe....
New version of my wife's art for Tundra's opening map. No new version of Katrina yet, but I think this looks awesome.1624062754755.png
Devil May Cry-Style Action Shooter in RPG Maker 2000! | RPG Maker News #75

Forum statistics

Threads
112,352
Messages
1,067,690
Members
146,002
Latest member
Raytoly
Top