xChikyx

Veteran
Veteran
Joined
Aug 7, 2019
Messages
41
Reaction score
12
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,957
Reaction score
4,874
First Language
EN, FR
Primarily Uses
RMMZ

I've moved this thread to RPG Maker XP. Thank you.

 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
402
Reaction score
168
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
41
Reaction score
12
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

ok by this weekend I WILL finally need alpha testers for Backstage: murdered sleep because it's got enough content at this point I want to get it on Steam Early Access ASAP (2/22/2022 would be a cool release date if I can make it).

By all means volunteer here, sure, but where else should I be looking?
1643337839651.png
Randomly trying to make some butcher shop tiles for MZ :3
Current menu of Shadows of the Earth: The Vrila'an Legend. Currently taking a break from combat related mechanics. Hope i get the actor busts done before the day ends :)
Was in need for a black van, so I made one by editing that one truck in the tileset. :kaoswt2:
nFfmJca.png
I honestly haven't ever been really active in this community, even though this year will mark my 4th year of having an account and 5th or 6th of using RPG maker. I didn't do anything with RM for most of 2020 and 2021 for personal reasons, but I'm excited to get back into game making!

Forum statistics

Threads
118,771
Messages
1,118,600
Members
155,932
Latest member
RPGMVNoob
Top