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
33,371
Reaction score
8,395
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
557
Reaction score
353
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
557
Reaction score
353
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
557
Reaction score
353
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

was rendering a video and window decided to bsod on me :D fun
Could not for the life of me figure out how to implement the dual/triple techs in Touch the Stars in a player-friendly way. Was describing all the problems to my wife and just rubber-ducked a solution that should work brilliantly.
I think I'm going to make each equippable item in my fantasy RPG grant a skill while its worn (in addition to the character's learned skills). Equipped gear that might be weaker in stats can still be useful in certain situations if the skill they grant exploits a weakness or resists a strength in the monsters being fought. This could potentially open up lots of build strategies to play with for fun.
:kaojoy:
A lot of those cool RPGs allow players to import their own portraits.
Thus, we shall have that, too. :kaojoy:
Finally, deleted my Reddit account
I cant say I dont regret it, I honestly liked FMA subreddit, but nah, reddit succs

Forum statistics

Threads
113,837
Messages
1,077,847
Members
147,901
Latest member
El_Misterioso
Top