In need of a script to set move route, and being able to change the code within, from outside

Monkey BizNiz

Veteran
Veteran
Joined
Apr 22, 2017
Messages
229
Reaction score
30
First Language
Not English
Primarily Uses
RMMV
Hey guys,
Im in need of a script to ''set movement route'' in all possible ways. And i wish to make the movement orders I will send through that script - variable. So that basically i would have something like this:
Code:
mr = RPG::MoveRoute.new
mr.repeat = false
mr.wait = true
mr.list = []

mr.list.push( RPG::MoveCommand.new(36, []) )
mr.list.push( RPG::MoveCommand.new )

$game_map.events[@event_id].force_move_route(mr)

And the idea would be that the "mr.list.push( RPG::MoveCommand.new(36, [])" should be variable, which i could change from the outside, which would basically change the whole move order. Which is what i have need for.

Also keep in mind that i grabbed that code from this thread https://forums.rpgmakerweb.com/index.php?threads/creating-a-move-route-with-a-script-command.59367/, and it was made for rpg maker vx ace, and i need this to work in rpg maker MV

Thanks in advance :D:thumbsup-left:
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,634
Reaction score
1,452
First Language
French
Primarily Uses
RMMV
PHP:
Game_Character.prototype.processMoveCommand = function(command) {
    var gc = Game_Character;
    var params = command.parameters;
    switch (command.code) {
    case gc.ROUTE_END:
        this.processRouteEnd();
        break;
    case gc.ROUTE_MOVE_DOWN:
        this.moveStraight(2);
        break;
    case gc.ROUTE_MOVE_LEFT:
        this.moveStraight(4);
        break;
    case gc.ROUTE_MOVE_RIGHT:
        this.moveStraight(6);
        break;
    case gc.ROUTE_MOVE_UP:
        this.moveStraight(8);
        break;
    case gc.ROUTE_MOVE_LOWER_L:
        this.moveDiagonally(4, 2);
        break;
    case gc.ROUTE_MOVE_LOWER_R:
        this.moveDiagonally(6, 2);
        break;
    case gc.ROUTE_MOVE_UPPER_L:
        this.moveDiagonally(4, 8);
        break;
    case gc.ROUTE_MOVE_UPPER_R:
        this.moveDiagonally(6, 8);
        break;
    case gc.ROUTE_MOVE_RANDOM:
        this.moveRandom();
        break;
    case gc.ROUTE_MOVE_TOWARD:
        this.moveTowardPlayer();
        break;
    case gc.ROUTE_MOVE_AWAY:
        this.moveAwayFromPlayer();
        break;
    case gc.ROUTE_MOVE_FORWARD:
        this.moveForward();
        break;
    case gc.ROUTE_MOVE_BACKWARD:
        this.moveBackward();
        break;
    case gc.ROUTE_JUMP:
        this.jump(params[0], params[1]);
        break;
    case gc.ROUTE_WAIT:
        this._waitCount = params[0] - 1;
        break;
    case gc.ROUTE_TURN_DOWN:
        this.setDirection(2);
        break;
    case gc.ROUTE_TURN_LEFT:
        this.setDirection(4);
        break;
    case gc.ROUTE_TURN_RIGHT:
        this.setDirection(6);
        break;
    case gc.ROUTE_TURN_UP:
        this.setDirection(8);
        break;
    case gc.ROUTE_TURN_90D_R:
        this.turnRight90();
        break;
    case gc.ROUTE_TURN_90D_L:
        this.turnLeft90();
        break;
    case gc.ROUTE_TURN_180D:
        this.turn180();
        break;
    case gc.ROUTE_TURN_90D_R_L:
        this.turnRightOrLeft90();
        break;
    case gc.ROUTE_TURN_RANDOM:
        this.turnRandom();
        break;
    case gc.ROUTE_TURN_TOWARD:
        this.turnTowardPlayer();
        break;
    case gc.ROUTE_TURN_AWAY:
        this.turnAwayFromPlayer();
        break;
    case gc.ROUTE_SWITCH_ON:
        $gameSwitches.setValue(params[0], true);
        break;
    case gc.ROUTE_SWITCH_OFF:
        $gameSwitches.setValue(params[0], false);
        break;
    case gc.ROUTE_CHANGE_SPEED:
        this.setMoveSpeed(params[0]);
        break;
    case gc.ROUTE_CHANGE_FREQ:
        this.setMoveFrequency(params[0]);
        break;
    case gc.ROUTE_WALK_ANIME_ON:
        this.setWalkAnime(true);
        break;
    case gc.ROUTE_WALK_ANIME_OFF:
        this.setWalkAnime(false);
        break;
    case gc.ROUTE_STEP_ANIME_ON:
        this.setStepAnime(true);
        break;
    case gc.ROUTE_STEP_ANIME_OFF:
        this.setStepAnime(false);
        break;
    case gc.ROUTE_DIR_FIX_ON:
        this.setDirectionFix(true);
        break;
    case gc.ROUTE_DIR_FIX_OFF:
        this.setDirectionFix(false);
        break;
    case gc.ROUTE_THROUGH_ON:
        this.setThrough(true);
        break;
    case gc.ROUTE_THROUGH_OFF:
        this.setThrough(false);
        break;
    case gc.ROUTE_TRANSPARENT_ON:
        this.setTransparent(true);
        break;
    case gc.ROUTE_TRANSPARENT_OFF:
        this.setTransparent(false);
        break;
    case gc.ROUTE_CHANGE_IMAGE:
        this.setImage(params[0], params[1]);
        break;
    case gc.ROUTE_CHANGE_OPACITY:
        this.setOpacity(params[0]);
        break;
    case gc.ROUTE_CHANGE_BLEND_MODE:
        this.setBlendMode(params[0]);
        break;
    case gc.ROUTE_PLAY_SE:
        AudioManager.playSe(params[0]);
        break;
    case gc.ROUTE_SCRIPT:
        eval(params[0]);
        break;
    }
};
 

Monkey BizNiz

Veteran
Veteran
Joined
Apr 22, 2017
Messages
229
Reaction score
30
First Language
Not English
Primarily Uses
RMMV
hey thanks!
those seem to be the commands I was looking for, but im afraid I dont know how to actually use these in practice. hehe
Could you perhaps give me an example on how i would go about - to make an event move away from the player?
Ive tried this, for testing:
Code:
Game_Character.prototype.processMoveCommand = function(command) {
    var gc = Game_Character;
    var params = command.parameters;
    switch (command.code) {
    case gc.ROUTE_MOVE_TOWARD:
        this.moveTowardPlayer();
        break;
    }
};
It doesnt give an error, but it just freezes the player.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,074
Reaction score
7,985
First Language
German
Primarily Uses
RMMV
I think it will help a lot if you tell us what you want to do (ingame terms) instead of how you want to do it (script a move route).

One reasons why there is only limited support and examples for scripting a move Route is because in most cases it is easier to set the move route in the editor and not by scripting.
Of all the people who asked advice about this in the past, more than half of them only did so because they had a far too complex assumption in how to do something, and we would tell them a better way once we had more details.
 

Monkey BizNiz

Veteran
Veteran
Joined
Apr 22, 2017
Messages
229
Reaction score
30
First Language
Not English
Primarily Uses
RMMV
I think it will help a lot if you tell us what you want to do (ingame terms) instead of how you want to do it (script a move route).

One reasons why there is only limited support and examples for scripting a move Route is because in most cases it is easier to set the move route in the editor and not by scripting.
Of all the people who asked advice about this in the past, more than half of them only did so because they had a far too complex assumption in how to do something, and we would tell them a better way once we had more details.

I'm trying to find a method to set movement routes for regular events - through common events. And since you cant actually set movement routes through common events, except for the player; Im trying to figure out a work-around.
To basically being able to manipulate a single ''set movement route'' script within a regular npc event, by having a variable instead of the actual set movement command - like jump, move away from player, etc, and being able to alter that variable from within the common event, thus changing the order in the set movement command.

I hope its clear enough what im saying, because Im having a hard time explaining this, and i can imagine people having an even harder time understanding it. Im not even sure how to say it more clearer.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,074
Reaction score
7,985
First Language
German
Primarily Uses
RMMV
And why would you need to set the move route by common event?

By the way - there is a way to set a move route to an event if that common event is called from the map event, that is what the option "this event" is about. It has a few requirements, but those are usually automatically true for most cases where setting a move route by common event is considered. And the few cases where that is not possible are usually better served with a true plugin that doesn't use common events.

By the way - "ingame terms" means what the player sees in the game as a result, telling us you want to set the move route in a common event is still telling us how you want to do "something", but not what that something in the game really is.
 

Monkey BizNiz

Veteran
Veteran
Joined
Apr 22, 2017
Messages
229
Reaction score
30
First Language
Not English
Primarily Uses
RMMV
And why would you need to set the move route by common event?

By the way - there is a way to set a move route to an event if that common event is called from the map event, that is what the option "this event" is about. It has a few requirements, but those are usually automatically true for most cases where setting a move route by common event is considered. And the few cases where that is not possible are usually better served with a true plugin that doesn't use common events.

By the way - "ingame terms" means what the player sees in the game as a result, telling us you want to set the move route in a common event is still telling us how you want to do "something", but not what that something in the game really is.

@Andar
1) well the reason I want to use a common event is; is because im creating a sort of simulation game, where basically every NPC event walking around has "generic" - if thats the rigth word, text and movement, dependant on variables and traits, that ive given that specific npc. And it would get rid of an incredible amount of micromanagement, if i could deal with all that stuff in a common event.

2) Holy hell, my mind is literally blown. Like a few months ago when I did this, literally nothing happened when I used a common event to move a map event. And now it suddenly works. Im really wondering if its something in a new update, or if made a mistake back then - but honestly, i really remember doing exactly the same as i did now, and as far as i see, the only way to not make the common event move the specific map event is by just calling the switch that turns said common event on. I was just so sure that it didnt work, that i didnt even bother retrying it again.

Well i suppose theres no need for me to pull off a script for set movement route now. Although any wisdom is still useful.
Anyway thanks for making me retry it again.

Oh and would you mind telling me what those requirements are, to be able to set a move route through a common event, because im really curious what i couldve done wrong back then.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,166
Reaction score
14,211
First Language
English
Primarily Uses
RMMV
This is the third thread you have started about this issue.

You should note, if you need this still, that the code you provided in your first post is from VX Ace, but that you actually want this for MV. To avoid confusion for anyone who wants to help.
 

Monkey BizNiz

Veteran
Veteran
Joined
Apr 22, 2017
Messages
229
Reaction score
30
First Language
Not English
Primarily Uses
RMMV
This is the third thread you have started about this issue.

You should note, if you need this still, that the code you provided in your first post is from VX Ace, but that you actually want this for MV. To avoid confusion for anyone who wants to help.
Well, one thread was about how to freeze an event until a specific condition was met, and I just happened to use the movement route as an example for what i needed it for, even though i was looking for using it in general. And i remade a new thread here, about the previously made thread about basically the same issue, because afterwards I realised that it was more script related, and i mightve had more luck here.

And if im correct - javascript is for rpg maker MV only, and RGSS is for the the older rpg makers, right? Oh and here; i did mention it:D
Also keep in mind that i grabbed that code from this thread https://forums.rpgmakerweb.com/index.php?threads/creating-a-move-route-with-a-script-command.59367/, and it was made for rpg maker vx ace, and i need this to work in rpg maker MV
But i understand your confusement. I try to be clear in my explanations, but these long essays i have to write to explain my problems arent my strong suit haha.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,074
Reaction score
7,985
First Language
German
Primarily Uses
RMMV
As for your question above:

There are different ways to use a common event depending in trigger and structure.

If the trigger remains "none" you can call the common event from a map-event. In that case the common event becomes part of the map event for every purpose, allowing you to access that map events self-switches and it's move route and more with the regular event commands.
You can even direct scripts at it as long as the script functions can use the "this event" code.

Only if a common event is set to parallel or autorun and started independently, that assignment of the structure becomes difficult. There are some differences between Ace and MV here, so I'm not sure what can be done in MV in such a case.
 

Monkey BizNiz

Veteran
Veteran
Joined
Apr 22, 2017
Messages
229
Reaction score
30
First Language
Not English
Primarily Uses
RMMV
As for your question above:

There are different ways to use a common event depending in trigger and structure.

If the trigger remains "none" you can call the common event from a map-event. In that case the common event becomes part of the map event for every purpose, allowing you to access that map events self-switches and it's move route and more with the regular event commands.
You can even direct scripts at it as long as the script functions can use the "this event" code.

Only if a common event is set to parallel or autorun and started independently, that assignment of the structure becomes difficult. There are some differences between Ace and MV here, so I'm not sure what can be done in MV in such a case.
I see, i will just have to experiment with it a bit i suppose. Thanks
 

Monkey BizNiz

Veteran
Veteran
Joined
Apr 22, 2017
Messages
229
Reaction score
30
First Language
Not English
Primarily Uses
RMMV
Hey past me!
To answer the actual question on your first post, you can put a script in a setmovement route, and add ''eval($gameVariables.value(any number));''
then outside the setmovement route, you can change the value of the variable inside the setmovement route, to the command you wish to execute! Heres the list of commands:
Code:
this.processRouteEnd();
this.moveStraight(2);
this.moveStraight(4);
this.moveStraight(6);
this.moveStraight(8);
this.moveDiagonally(4, 2);
this.moveDiagonally(6, 2);
this.moveDiagonally(4, 8);
this.moveDiagonally(6, 8);
this.moveRandom();
this.moveTowardPlayer();
this.moveAwayFromPlayer();
this.moveForward();
this.moveBackward();
this.jump(params[0], params[1]);
this._waitCount = params[0] - 1;
this.setDirection(2);
this.setDirection(4);
this.setDirection(6);
this.setDirection(8);
this.turnRight90();
this.turnLeft90();
this.turn180();
this.turnRightOrLeft90();
this.turnRandom();
this.turnTowardPlayer();
this.turnAwayFromPlayer();
$gameSwitches.setValue(params[0], true);
$gameSwitches.setValue(params[0], false);
this.setMoveSpeed(params[0]);
this.setMoveFrequency(params[0]);
this.setWalkAnime(true);
this.setWalkAnime(false);
this.setStepAnime(true);
this.setStepAnime(false);
this.setDirectionFix(true);
this.setDirectionFix(false);
this.setThrough(true);
this.setThrough(false);
this.setTransparent(true);
this.setTransparent(false);
this.setImage(params[0], params[1]);
this.setOpacity(params[0]);
this.setBlendMode(params[0]);
AudioManager.playSe(params[0]);
eval(params[0]);

heres an example:
◆Control Variables:#0006 = "this.moveStraight(8);"
◆Set Movement Route:This Event (Wait)
:Set Movement Route:◇Script:eval($gameVariables.value(6))
 

Latest Threads

Latest Posts

Latest Profile Posts

One feature that I'm missing is the ability to see Who is viewing a topic...

It was kinda nice to 'see' some faces, even if they don't say anything.
unnamed_image.jpg
SOMEONE'S SINGLE! HE DOES LIKE ALL GENDERS! SADLY, HE HAS NO NUMBER TO NOTE OF BECAUSE HE HAS NO USE FOR A PHONE, BECUASE SUMMONING WORKS MUCH BETTER AND DOES NOT COME WITH AN ITEMISED BILL.
I just found out that MZ regional price on Steam in my place is much cheaper than MV.
Our water started to work again, now i don't have to fill up our toilet with water again.

Forum statistics

Threads
108,887
Messages
1,040,320
Members
141,326
Latest member
Lotus8901
Top