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

  • shadowstep.png
    shadowstep.png
    54.5 KB · Views: 9

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
402
Reaction score
225
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

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,957
Reaction score
2,292
First Language
EN
Primarily Uses
RMMZ
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
402
Reaction score
225
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
402
Reaction score
225
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
 

Latest Threads

Latest Posts

Latest Profile Posts

Folks, if anyone sends you a message inviting you to add their API to your game, please report them. We don't want people spamming our members asking them to add stuff to their games for their own (or others') benefit.
I'm listening to iiluminaughtii talking about the secrets behind shady businesses and scams. Meanwhile I'm writing a fanfic about Sephiroth from FF7, one specifically for my stepmom. I'll get to give it to her, too, because my boss said I could take the holidays off! Dec. 22-27 I will be in Orlando, and maybe Fort Myers too, visiting my dad and stepmom!
Of course, I bought a handful of games on the Steam Black Friday sale. Will I try them? Will I complete any? Who knows...
I don't really have any neat updates today about how I screwed up programming... But if you want to observe the intensenes of me programming, then you can check out my stream :)
New Weapons.gif
No more spam from me today, I promise! Just wanted to upload this, people have been giving me feedback that my weapon sprites (which were RTP) clashed badly with my battlers for ages, so today I finally took the plunge and updated them! Really happy with how they came out :D :D

Forum statistics

Threads
117,009
Messages
1,103,786
Members
152,904
Latest member
gumi16
Top