xChikyx

Veteran
Veteran
Joined
Aug 7, 2019
Messages
32
Reaction score
10
First Language
English
Primarily Uses
RMXP
Hi!
I'm currently working on a project using RPG Maker XP in a pretty complicated way. Anyway, I'm trying to create a global event that reads when the player is facing a wall. Is thre anything out there that already does so?
So far the only idea I have is to make a HUGE series of conditional branches in which, for each map, it checks the direction of the player is facing and its coordinates to see if next to a wall, But that is, first of all, insane, and, second, not efficient at all.

Is there any way to interact with the Tile Counters or Tile Terrains using a script maybe to know when I'm adjacent to (not over) them? For example, if I put a wall with a Tile Terrain indicator in 1, then if the player is adjacent to the wall, it would trigger the event.

This is what I have in mid (hope it makes any sense and it's possible):
If Character facing Terrain 1
if Distance between Character and Terrain 1 == 1
Facing Wall Switch = ON
end
else
Facing Wall Switch = OFF
end

If you know how to address terrain tags or counter tags on scripts please elt me know.
If you know a script that does this already please let me know too.
Any help is welcome.



EDIT: Never mind, I think I managed to make a script that does so... I'll put it in the comments in case anyone needs it :D


EDIT FOR THE SCRIPT:
class FaceWall
#Script by Sumerian Games
#Call with FaceWall.new

def initialize
if $game_player.direction == 2
viendox = $game_player.x
viendoy = $game_player.y + 1
end
if $game_player.direction == 4
viendox = $game_player.x - 1
viendoy = $game_player.y
end
if $game_player.direction == 6
viendox = $game_player.x + 1
viendoy = $game_player.y
end
if $game_player.direction == 8
viendox = $game_player.x
viendoy = $game_player.y - 1
end

terraintype = $game_map.terrain_tag(viendox, viendoy)
if terraintype == 0 #here the terrain type is the one in the tileset
$game_variables[25] = 0 #change the variable number here
end
if terraintype == 1
$game_variables[25] = 1
end
end
end

Usage:
Put in the terrain tab on the tilesets the Tiles you need to be as walls with a terrain number (in this case 1)
When you need it, call the script and check for variables. In this case, the variable 25. When the character is facing a wall, the variable will be set as 1. When not, it will be a 0.
Then, in the event you're calling the scrip, check for the conditions: If Variable 25 = 1, then do something when facing the wall.
It wasnt that hard to make actually. Hope you find it useful.
If you use it in your game, i'd appreciate a mention in the credits :D
 
Last edited:

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,822
Reaction score
4,754
First Language
English
Primarily Uses
RMMZ

I've moved this thread to RPG Maker XP. Please be sure to post your threads in the correct forum next time. Thank you.

 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
347
Reaction score
131
First Language
English
Primarily Uses
RMXP
Let me fix it up for you:
Code:
class Game_Player < Game_Character

  def get_tt_in_front
    dir = @direction
    nx = @x + (dir == 4 ? -1 : dir == 6 ? 1 : 0)
    ny = @y + (dir == 8 ? -1 : dir == 2 ? 1 : 0)
    $game_map.terrain_tag(nx, ny)
  end

  def facing_wall?
    !passable?(@x, @y, @direction)
  end
end
Script calls:
Code:
$game_player.facing_wall?
$game_player.get_tt_in_front
You can just use a Conditional Branch--4th tab for Script option--and put something like this:
Code:
$game_player.facing_wall? && $game_player.get_tt_in_front == 1
 
Last edited:

xChikyx

Veteran
Veteran
Joined
Aug 7, 2019
Messages
32
Reaction score
10
First Language
English
Primarily Uses
RMXP
oh, that's much shorter hahah
I'm pretty new working with scripts, normally I have just really complex engines, but bot scripts. I'll see how yours work :)
 

Latest Threads

Latest Posts

Latest Profile Posts

I wrote RPGMakerMZ JavaScript reference in Japanese.
But I think you'll be able to read it through the translator.

back in April of 2019, I watched my friend's art stream on twitch. that was when I got inspired to draw most of the assets for my game. it's been a LONG journey since, but totally worth it.
RPG MZ multiplayer in development
Square-Enix, why you didn't released the classic Dragon Quests on Steam yet? :kaocry:
This is by far my most favorite boss monster I've made, its name is Gosck

Forum statistics

Threads
109,139
Messages
1,042,480
Members
141,646
Latest member
Twigsmcsquids
Top