Guardinthena

Artist
Veteran
Joined
Nov 30, 2013
Messages
459
Reaction score
1,151
First Language
English
Primarily Uses
RMVXA
Hello everyone! I am scratching my head over this one and would appreciate some assistance!

I am attempting to create an event that displays a static sprite of a tree. My goal is that I want this event to have a 'detection radius' or 'directional line of sight' that checks for the player's x and y position. If the player is behind the event I want the tree to become semi-transparent. When the player is not behind the event, either to the left, right (if the player is out of the graphic tree sprite) or below to return to normal transparency. Following the events in the demo on this forum: https://forums.rpgmakerweb.com/index.php?threads/direction-based-line-of-sight-events.3452/ I was able to get the event to detect the player when standing behind the tree but I can't figure out how to event it to make the tree solid again when the player leaves the area.

To see a visual representation of what I want, there is this lovely Youtube video but the coding is for MV and I need one for VX Ace.

I have tried the line of sight, but I think I might need a radius instead. I am over my head in the scripting department. If someone knows how to do this, I would love the help! This have been bothering me for ages.
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
690
Reaction score
448
First Language
English
Primarily Uses
RMVXA
You can do something like:
Code:
if $game_player.x.between?(3, 8) && $game_player.y.between?(1, 4)
     $game_self_switches[[@map_id, @event_id, "A"]] = true
end
on page 1 and
Code:
if !$game_player.x.between?(3, 8) || !$game_player.y.between?(1, 4)
     $game_self_switches[[@map_id, @event_id, "A"]] = false
end
on page 2.

Just change the numbers accordingly. The above would check if the player is in the x coordinate 3 to 8 and the y coordinate 1 to 4. Set page 2's condition to be Self Switch A ON.

Or, to specifically use the event's coordinates:
Code:
ex = $game_map.events[@event_id].x
ey = $game_map.events[@event_id].y
if $game_player.x.between?(ex, ex+2) && $game_player.y.between?(ey, ey+3)
     $game_self_switches[[@map_id, @event_id, "A"]] = true
end
on page 1 and
Code:
ex = $game_map.events[@event_id].x
ey = $game_map.events[@event_id].y
if !$game_player.x.between?(ex, ex+2) || !$game_player.y.between?(ey, ey+3)
     $game_self_switches[[@map_id, @event_id, "A"]] = false
end
on page 2.

That would check for the player being between the event's x coordinate and 2 steps to the right and the event's y coordinate and 3 steps above.

Of course, if you want to use a different self switch, change "A" to another letter.

EDIT:
I should add that both pages need to be set to 'parallel process'. :)
 

Guardinthena

Artist
Veteran
Joined
Nov 30, 2013
Messages
459
Reaction score
1,151
First Language
English
Primarily Uses
RMVXA
You are a godsend @A-Moonless-Night! Thank you so much for your speedy reply! I just have a few questions about the set up. Do you want me to put the code in the script call tab on page three, or am I suppose to put it in the conditional branch's script call?
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
690
Reaction score
448
First Language
English
Primarily Uses
RMVXA
No worries! Just put the code in a script call (tab three).
 

Guardinthena

Artist
Veteran
Joined
Nov 30, 2013
Messages
459
Reaction score
1,151
First Language
English
Primarily Uses
RMVXA
I've made some progress here. The tree is constantly flickering between the two pages, with it mostly transparent. I'm not sure what I'm doing wrong. I placed the opacity in a custom move command. I've uploaded images to show what I'm doing. This particular tree graphic I am use is three wide and six tall. Does the script code provided check for when the player is just behind the tree? I am having a problem where I can be anywhere and it is just flickering constantly.

treeproblem.PNG treeproblem2.PNG
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
690
Reaction score
448
First Language
English
Primarily Uses
RMVXA
Delete the 'Control Self Switch' at the bottom and just leave the script call; it already includes a line to change the self switch.

EDIT:
A picture to show you what I mean:
option 1.png

Alternatively, if you're uncomfortable with having the whole thing as a script call, you can do this:
option 2.png
The script call for the conditional branch is the same as the top line of those script calls I posted before, but you just remove the 'if' at the start.
 
Last edited:

Guardinthena

Artist
Veteran
Joined
Nov 30, 2013
Messages
459
Reaction score
1,151
First Language
English
Primarily Uses
RMVXA
Well, I'm starting to feel embarrassed here. I am not sure what I'm doing wrong, but the tree refuses to change transparency no matter where I step around it. I have the second page set up so that the tree is supposed to change opacity to 125. I went so far last night that I ditched the command and just modified the graphic so that there is one set solid and the other transparent. Still nothing. I must be missing something there. For the x and y coordinates, is it accurate if I set x as (1, 3) to check for player in the three tiles above the event going across and for the y (1, 6) to check for all the squares in a rectangle that encompasses the tree graphic height?
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
690
Reaction score
448
First Language
English
Primarily Uses
RMVXA
You need to go off the event's coordinates on the map. If you use 1 to 3 as the x coordinates, then it will literally check those. So, you can either check each event's coordinates on the map and put those in, or use the other script call I gave earlier that uses the event's coordinates.
 

Guardinthena

Artist
Veteran
Joined
Nov 30, 2013
Messages
459
Reaction score
1,151
First Language
English
Primarily Uses
RMVXA
Ha! I knew I was missing something. This is what I get for trying to read through and comprehend scripting late at night or between my kiddies nap time! Everything works now. Thank you for being so patient with me, @A-Moonless-Night! You have been such a great help. The tree works. Now, onto my next phase for my game, implementing all those trees.
 

Latest Threads

Latest Posts

Latest Profile Posts

Alisa: Prophecy of the Falling Stars. Join Alisa, a quiet girl with a heart filled with love and hope, on her journey to prevent a calamity. My next RPG Maker music pack is my largest and most focused pack yet. It's a musical story that focuses on a young heroine named Alisa who has been assigned the ultimate task to prevent a calamity.

SnJj_O.png
Alien Worlds, Minecraft Blocks, Extend Options, Fine Speed Control, Art by Muggu | RPG Maker News #33

Rest in Peace vlog gun...
vloggunsmallface.png
Another unnamed character, and probably last one for now.
She's a dragon girl inspired by fafnir dragon. as always, name suggestion is welcomed.
Dragon_Girl.jpg

Dragon_Girl_1.png

Forum statistics

Threads
111,164
Messages
1,058,883
Members
144,408
Latest member
Bretzel68440
Top