Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> RPGVX Engine - Movement, Based on RMVX
Rukiri
post Oct 28 2010, 02:18 PM
Post #1


emerge -avt awesome! Wait... it brings me.... HERE?!
Group Icon

Group: Revolutionary
Posts: 1,721
Type: Scripter
RM Skill: Advanced




Instructions
Each NPC, Hero, Monster etc must have this creation code or else they will not be able to sync with this script.
if you changing the tile size to say 16, 8, or 5. You need to change the move speed to something lower, you may need to use something like.
move_speed = room_speed * 0.5;
motion_set(direction, tile_size_x/move_speed);

but for 32X32 or 16X16 just using move_speed= 4 or 2 are fine.
8X8 requires move_speed = 1. or you could just use motion_set method for easy movement.

Create Event
CODE
//==================//
//     Author: Rukiri
//     10/29/10
//==================//
// can this object move?
can_move = false;

//Movement speed
move_speed = 4;

// Animation Speed
ani_speed = 0.3;

// Tile Size
tile_size_x = 32;
tile_size_y = 32;

// Tile X/Y
tile_x = x/tile_size_x;
tile_y = y/tile_size_y;

// move
move_down = 1;
move_left = 2;
move_right = 3;
move_up = 4;


Do NOT make these variables global, these must be local variables. If you need to use say move_speed directly with the player object but through another event or script just use the with function.

Example:
CODE
with (obj_player) {
  move_speed = 4; // change 4 to what you want
}


Step Event
CODE
//step-event code
if can_move=true {
  if (tile_x * tile_size_x > x) {
    x += move_speed;
    break;
  } else if (tile_x * tile_size_x < x) {
    x -= move_speed;
    break;
  }

  if (tile_y * tile_size_y > y) {
    y += move_speed;
    break;
  } else if (tile_y * tile_size_y < y) {
    y -= move_speed;
    break;
  }
}

// stop event at the right tile.
if keyboard_check(vk_nokey) {
if (tile_x * tile_size_x = x) { can_move = false; }
if (tile_y * tile_size_y = y)  { can_move = false; }
}
else { can_move = true; }


Keyboard Script
The keyboard script used global variables as you're going to be using it with multiple objects, and it's for the hero and your allies only. Say you wanted to switch to an ally while in combat(got bored with your main hero)

CODE
globalvar kb_enter, kb_select, kb_up, kb_down, kb_left, kb_right, kb_nokey; // place all your keyboard keys in this line.

kb_enter = keyboard_check(vk_enter); // Enter Key
kb_select = keyboard_check(vk_space); // Select Key
kb_up = keyboard_check(vk_up); // Up Key
kb_down = keyboard_check(vk_down); // Down Key
kb_left = keyboard_check(vk_left); // Left Key
kb_right = keyboard_check(vk_right); // Right Key
kb_nokey = keyboard_check(vk_nokey); // No key


scr_move_step
CODE
// Moves the character based on tile position in direction argument0
    // This set of conditionals is strictly for Movement!
   /*
        move_up = 1
        move_down = 2
        move_left = 3
        move_right = 4
   */
    // example, scr_move_step(1,5) will move up 5 tiles.
    if (move_up = argument0) { if (!place_meeting(tile_x *tile_size_x, (tile_y - 1) * tile_size_y, obj_wall)) tile_y -= argument1; }
    else if (move_down = argument0n) { if (!place_meeting(tile_x * 32, (tile_y + 1) * tile_size_y, obj_wall)) tile_y += argument1; }
    else if (move_left = argument0) { if (!place_meeting((tile_x - 1) * tile_size_x, tile_y * tile_size_y, obj_wall)) tile_x -= argument1; }
    else if (move_right = argument0) { if (!place_meeting((tile_x + 1) * tile_size_x, tile_y * 32, obj_wall)) tile_x += argument1; }

// usage
// scr_move_step(argument0,argument1)  
// argument 0 is for direction
// argument 1 is for how many tile should the object move


Demo
Will be released soon!


__________________________
Xeilsoft
- Follow your dreams to the very end..

Kits that I'm working on.
[Unity3D 4.0] LTTP/Minish Cap - I don't have time for custom gfx like what the pze folks are doing but I will try and work on some enhanced LTTP graphics.

Main PC
Core i7 3820 overclocked @ 4.8GHZ
Galaxy: Nvidia Geforce GTX 680 GDDR5 2GB
Asrock X79 Extreme9 w' creative sound
64GB corsair platinum @ 1600MHZ
Muchkin 128GB SSD(boot), OZKIN 2TB SSD, Western Digital GREEN 1TB HDD.
Rosewill Lightning 1000W PSU
OS: Funtoo Linux, Windows 8 (Virtual Machine)

iMac (March 2013)
3.4GHz Quad-core Intel Core i7, Turbo Boost up to 3.9GHz
16GB 1600MHz DDR3 SDRAM - 2X8GB
1TB Serial ATA Drive @ 7200 rpm
NVIDIA GeForce GTX 680MX 2GB GDDR5
Go to the top of the page
 
+Quote Post
   
Rukiri
post Oct 30 2010, 10:05 AM
Post #2


emerge -avt awesome! Wait... it brings me.... HERE?!
Group Icon

Group: Revolutionary
Posts: 1,721
Type: Scripter
RM Skill: Advanced




Okay guys I completely revamped the script, it now can be used by any object!
All bugs have been fixed and everything is smooth!

RPG Maker Move Step
Version: 1.0
Author: Rukiri
Exclusive to: Planet RPG, Rpg Revolution
Style: RPG Maker XP/VX
Tile_move: Yes
Pixel_move: No
because x is divided by tile_size so if you set it to 1 the tile_x or y variable will be the same as x. I recommend using just 2 instead of 1 as the tile_size variables have to be a dividend of 2 basically X or y need to be divided by something that equals a whole number.


How to use
tiles_to_move_x = x Change X to the number of tiles you want to move horizontally.
tiles_to_move_y = x Change X to the number of tiles you want to move vertically.

scr_move_step(direction)

There's an example already in the step event coding.

You can also use this for actual player movement, just remove the code block for, stop_cutscene_move = false

and replace it with
CODE
if (x = tile_x * tile_size_x and y = tile_y * tile_size_y) {
  if keyboard_check(vk_down) {
    scr_move_step(1);
  }
}


Create Event
create
CODE
//=========================//
//   Author: Rukiri
//   10/29/10
//   Completed: 10/30/10
//========================//

// dir 4 or 8

dir_4 = true; // set to false if you want diagonal movements

// can this object move?
can_move=true

//Movement speed
move_speed = 2;

// Animation Speed
ani_speed = 0.3;

// Tile Size
tile_size_x = 32;
tile_size_y = 32;

// Tile X/Y
tile_x = x/tile_size_x;
tile_y = y/tile_size_y;
tile_x_old = xprevious/tile_size_x;
tile_y_old = yprevious/tile_size_y;

// Tiles to move x/y  set to 0 for creation
tiles_to_move_x = 0;
tiles_to_move_y = 0;

// destination tile x/y  use the coding in step event
dest_tile_x = tile_x_old + tiles_to_move_x;
dest_tile_y = tile_y_old + tiles_to_move_y;

// stop cut_scene movement, only use if your using scr_move_step without keyboard checks. Use an alarm for delays in
// switching directions.
stop_cutscene_move = false;

// move
move_down = 1;
move_left = 2;
move_right = 3;
move_up = 4;


Step Event
step
CODE
// Get the tile ID number  y/gridsize
if can_move = true or stop_cutscene_move = false { // checks to see if we're moving if not, x/y will not be added or subtracted from.
    if (tile_x * tile_size_x > x) { // checks if tile_x is greater than x
    x += move_speed; // moves your object to the right
  } else if (tile_x * tile_size_x < x) { // checks if tile_x is less than x
    x -= move_speed; // moves your object to the left
  }

  if (tile_y * tile_size_y > y) { // checks if tile_y is greater than y
    y += move_speed; // moves your object down
  } else if (tile_y * tile_size_y < y) { // checks if tile_y is less than y
    y -= move_speed; // moves your object up
  }

}

// Movement Code Block
if stop_cutscene_move = false { // set stop_cutscene to false when move_step has not been used
if (x = tile_x * tile_size_x and y = tile_y * tile_size_y) { // check to see if you're at the destination tile
    tiles_to_move_y = 1; // set how many tiles the NPC should move at a time (use random for a more NPC like movement)
    dest_tile_x = tile_x_old + tiles_to_move_x; // Make sure you're not walking past your destination tile
    dest_tile_y = tile_y_old + tiles_to_move_y; // Make sure you're not walking past your destination tile
    scr_move_step(1); // move_step script  scr_move_step(direction), 1=down, 2=left, 3=right, 4=up
    
}
}

// make sure an NPC doesn't walk past it's destination tile
if tiles_to_move_x >= 1
{
   if dest_tile_x = tile_x { stop_cutscene_move = true; }
}
if tiles_to_move_y >= 1
{
   if dest_tile_y == tile_y { stop_cutscene_move = true; }
}

// stop event at the right tile.
if (tile_x * tile_size_x = x and tile_y * tile_size_y = y) { // make sure we're not moving when we release our direction keyboard keys
  can_move = false; // set can_move to false when we're not moving
}
else { can_move = true } // set can_move to true when we are moving


scr_move_step
script
CODE
// Moves the character based on tile position in direction argument0
    // This set of conditionals is strictly for Movement!
   /*
        move_up = 1
        move_down = 2
        move_left = 3
        move_right = 4
   */
    // example, scr_move_step(1,5) will move up 5 tiles.
    if (move_up = argument0) { if (!place_meeting(tile_x *32, (tile_y - 1) * 32, obj_wall)) tile_y -= 1;  }  
    else if (move_down = argument0) { if (!place_meeting(tile_x * 32, (tile_y + 1) * 32, obj_wall)) tile_y += 1;  }
    else if (move_left = argument0) { if (!place_meeting((tile_x - 1) * 32, tile_y * 32, obj_wall)) tile_x -= 1;   }
    else if (move_right = argument0) { if (!place_meeting((tile_x + 1) * 32, tile_y * 32, obj_wall)) tile_x += 1; }

// usage
// scr_move_step(argument0)  
// argument 0 is for direction


__________________________
Xeilsoft
- Follow your dreams to the very end..

Kits that I'm working on.
[Unity3D 4.0] LTTP/Minish Cap - I don't have time for custom gfx like what the pze folks are doing but I will try and work on some enhanced LTTP graphics.

Main PC
Core i7 3820 overclocked @ 4.8GHZ
Galaxy: Nvidia Geforce GTX 680 GDDR5 2GB
Asrock X79 Extreme9 w' creative sound
64GB corsair platinum @ 1600MHZ
Muchkin 128GB SSD(boot), OZKIN 2TB SSD, Western Digital GREEN 1TB HDD.
Rosewill Lightning 1000W PSU
OS: Funtoo Linux, Windows 8 (Virtual Machine)

iMac (March 2013)
3.4GHz Quad-core Intel Core i7, Turbo Boost up to 3.9GHz
16GB 1600MHz DDR3 SDRAM - 2X8GB
1TB Serial ATA Drive @ 7200 rpm
NVIDIA GeForce GTX 680MX 2GB GDDR5
Go to the top of the page
 
+Quote Post
   
maaddogg
post Nov 2 2010, 09:52 AM
Post #3


Level 2
Group Icon

Group: Member
Posts: 24
Type: Event Designer
RM Skill: Skilled




lookin good Rukiri happy.gif


__________________________

Join the home of the Nyan Cat ^^
Go to the top of the page
 
+Quote Post
   
Rukiri
post Nov 2 2010, 02:53 PM
Post #4


emerge -avt awesome! Wait... it brings me.... HERE?!
Group Icon

Group: Revolutionary
Posts: 1,721
Type: Scripter
RM Skill: Advanced




Thanks Ozuma. Lol, you might wanna just create a sig bar instead of using our forums logo.


__________________________
Xeilsoft
- Follow your dreams to the very end..

Kits that I'm working on.
[Unity3D 4.0] LTTP/Minish Cap - I don't have time for custom gfx like what the pze folks are doing but I will try and work on some enhanced LTTP graphics.

Main PC
Core i7 3820 overclocked @ 4.8GHZ
Galaxy: Nvidia Geforce GTX 680 GDDR5 2GB
Asrock X79 Extreme9 w' creative sound
64GB corsair platinum @ 1600MHZ
Muchkin 128GB SSD(boot), OZKIN 2TB SSD, Western Digital GREEN 1TB HDD.
Rosewill Lightning 1000W PSU
OS: Funtoo Linux, Windows 8 (Virtual Machine)

iMac (March 2013)
3.4GHz Quad-core Intel Core i7, Turbo Boost up to 3.9GHz
16GB 1600MHz DDR3 SDRAM - 2X8GB
1TB Serial ATA Drive @ 7200 rpm
NVIDIA GeForce GTX 680MX 2GB GDDR5
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 20th May 2013 - 01:50 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker