Need help with creating a "dash" type of world map skill

Mahoken

Veteran
Veteran
Joined
Nov 24, 2013
Messages
41
Reaction score
3
First Language
English
Primarily Uses
I'm creating a skill you can use on the map by pressing "Spacebar". The ability is simple: press Space and move forward 2 spaces, going through any walls on the way.

The problem I'm running into is when you use this ability and you land in an object/wall. When that happens, you can simply use the ability again and move through the entire wall, but I want the ability to only let you move through 1-space walls. When you land on something you're not supposed to, I want it to just push you back out to where you came from, but I just can't get the event to spit you back out.

Any suggestions on what to do? I was trying to tinker with region IDs but my scripting knowledge is basically zero, so I haven't been able to get it to work.
 

Attachments

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
386
Reaction score
204
First Language
English
Primarily Uses
RMMV
I would add a condition to your event that says if the tile the player is going to land on is passable then the skill will execute.

To do this you'll need to know how to check the tile, as far as I'm aware with eventing this is probably difficult.

What you could do is use this small code snippet to set a switch to true or false depending on if the target tile is passable.

JavaScript:
var space = 2; // tiles to move, change number to increase/decrease distance.
var d = $gamePlayer.direction();
var x = $gamePlayer.x + (d === 4 ? -space : (d === 6 ? space : 0)); //adjust x if facing left or right.
var y = $gamePlayer.y + (d === 8 ? -space : (d === 2 ? space : 0)); //adjust y if facing up or down.
var passable = $gamePlayer.isMapPassable(x, y, d);
$gameSwitches.setValue(id, passable);  //replace id with switch id to use in conditional branch.
From here just use a normal conditional branch, have the condition be whatever switch id you've used in the code snippet, within the brackets put your existing event commands.

If you want to show the player move to the tile then be booted back out you can use an else branch and have the move route move the player forward then immediately back again.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,510
Reaction score
992
First Language
EN
Primarily Uses
RMMV
Yea, I think the best option with pure eventing would be to use Terrain Tag / Region ID. Maybe something like this:
Code:
◆Comment:Get current player position
◆Control Variables:#0008 X = Map X of Player
◆Control Variables:#0009 Y = Map Y of Player
◆Comment:Determine target coordinates
◆If:Player is facing Down
  ◆Control Variables:#0009 Y += 2
  ◆
:Else
  ◆If:Player is facing Left
    ◆Control Variables:#0008 X -= 2
    ◆
  :Else
    ◆If:Player is facing Right
      ◆Control Variables:#0008 X += 2
      ◆
    :Else
      ◆Control Variables:#0009 Y -= 2
      ◆
    :End
    ◆
  :End
  ◆
:End
◆Comment:Check region ID at target and store in another variable (called "R")
◆Get Location Info:R, Region ID, ({X},{Y})
◆Comment:Check if the region is valid for landing
◆If:R = 5
  ◆Comment:# # # # # DO YOUR STUFF HERE # # # # #
  ◆
:End
Silva's script is much more convenient because it checks the tile passability directly~ :kaothx:
 

Mahoken

Veteran
Veteran
Joined
Nov 24, 2013
Messages
41
Reaction score
3
First Language
English
Primarily Uses
I would add a condition to your event that says if the tile the player is going to land on is passable then the skill will execute.

To do this you'll need to know how to check the tile, as far as I'm aware with eventing this is probably difficult.

What you could do is use this small code snippet to set a switch to true or false depending on if the target tile is passable.

JavaScript:
var space = 2; // tiles to move, change number to increase/decrease distance.
var d = $gamePlayer.direction();
var x = $gamePlayer.x + (d === 4 ? -space : (d === 6 ? space : 0)); //adjust x if facing left or right.
var y = $gamePlayer.y + (d === 8 ? -space : (d === 2 ? space : 0)); //adjust y if facing up or down.
var passable = $gamePlayer.isMapPassable(x, y, d);
$gameSwitches.setValue(id, passable);  //replace id with switch id to use in conditional branch.
From here just use a normal conditional branch, have the condition be whatever switch id you've used in the code snippet, within the brackets put your existing event commands.

If you want to show the player move to the tile then be booted back out you can use an else branch and have the move route move the player forward then immediately back again.
It's working great so far, way easier than what I managed to do. However, my only issue I'm running into now is that if you use the ability and land in front of an impassable terrain (you have to be facing it too), it runs the error and spits you back out.
 

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
386
Reaction score
204
First Language
English
Primarily Uses
RMMV
It's working great so far, way easier than what I managed to do. However, my only issue I'm running into now is that if you use the ability and land in front of an impassable terrain (you have to be facing it too), it runs the error and spits you back out.
Yeah, that's my bad, if I'd dug deeper into the function I'd have realised that the code is checking that you can exit the tile in the direction that you are facing and that you can enter the tile in front. There are alternatives that might be safer.

JavaScript:
var space = 2; // tiles to move, change number to increase/decrease distance.
var d = $gamePlayer.direction();
var x = $gamePlayer.x + (d === 4 ? -space : (d === 6 ? space : 0)); //adjust x if facing left or right.
var y = $gamePlayer.y + (d === 8 ? -space : (d === 2 ? space : 0)); //adjust y if facing up or down.
var passable = $gameMap.isPassable(x, y, d);
$gameSwitches.setValue(id, passable);  //replace id with switch id to use in conditional branch.
So long as the tile being landed on has passability in the direction the player is facing, this won't trigger the else branch. No checks are done on the tile in front of the player's landing position.

If you're going to be having the player land on tiles that themselves have limited passability it might be worth checking to see if there is Any passibility by doing some extra checks.

JavaScript:
var space = 2; // tiles to move, change number to increase/decrease distance.
var d = $gamePlayer.direction();
var x = $gamePlayer.x + (d === 4 ? -space : (d === 6 ? space : 0)); //adjust x if facing left or right.
var y = $gamePlayer.y + (d === 8 ? -space : (d === 2 ? space : 0)); //adjust y if facing up or down.
var passable = $gameMap.isPassable(x, y, 2) || $gameMap.isPassable(x, y, 4) || $gameMap.isPassable(x, y, 6) || $gameMap.isPassable(x, y, 8);
$gameSwitches.setValue(id, passable);  //replace id with switch id to use in conditional branch.
While this is not so nice to look at it checks for passability in all directions and if there's at least one then it's fine to land on the tile. Again, this doesn't check any of the neighbouring tiles.

If you wanted the player to at least have some wiggle room when they jumped you could replace "$gameMap.isPassable" with "$gamePlayer.isMapPassable" and it will only execute if the player can enter a space and make a move in at least one direction. I'd argue that this is unnecessary though as the player can always turn around on one tile and reactivate the ability - if they want to jump into tiny holes who are you to stop them? :p
 

Mahoken

Veteran
Veteran
Joined
Nov 24, 2013
Messages
41
Reaction score
3
First Language
English
Primarily Uses
If you're going to be having the player land on tiles that themselves have limited passability it might be worth checking to see if there is Any passibility by doing some extra checks.
Might be a dumb question, but what do you mean by "limited passability"? Is there more than just "cannot pass through" and "can pass through" for tiles?
 

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
386
Reaction score
204
First Language
English
Primarily Uses
RMMV
Yes, there's a little more to it than that. The engine has the option to set directional passage for tiles on the B and C sheets, so it's possible to have tiles that you can only move up or down from (eg. a set of ladders). There's also the ladder setting which I presume overrides the "can/cannot pass" settings of the A tile with the B/C tile's own passability (I don't really do a lot with maps or passability so I could be wrong).

You can access this information from the tilesets section of the database.

1581898465645.png
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Profile Posts

so, ive been gone for too long when i log in and see that everything is where is shouldn't be. XD
Steam killing my eyes.. I forgot why I use it only when I have no other choice
Making a map, my brain went "Look, Mjölnir!" as I plotted out a sacrificial entrance.

Actually, it went, "Look, hammer. Wait, Thor's hammer!"
CG tile rendering, take 3: windows.
which section you guys think looks more accurate to the perspective? left or right?

for reference, this is what it looks like "at street level"
Okay, Animal Crossing is remarkably addictive and exceptionally calming. I've been playing it pretty exclusively... like... 6 hours a day. Been a while since I've been this engrossed.

Forum statistics

Threads
95,402
Messages
928,920
Members
125,620
Latest member
Marlin
Top