Guardinthena

Artist
Veteran
Joined
Nov 30, 2013
Messages
567
Reaction score
1,506
First Language
English
Primarily Uses
RMMV
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
695
Reaction score
452
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
567
Reaction score
1,506
First Language
English
Primarily Uses
RMMV
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
695
Reaction score
452
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
567
Reaction score
1,506
First Language
English
Primarily Uses
RMMV
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
695
Reaction score
452
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
567
Reaction score
1,506
First Language
English
Primarily Uses
RMMV
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
695
Reaction score
452
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
567
Reaction score
1,506
First Language
English
Primarily Uses
RMMV
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

Made this sign for a you-know-what type of business, completely from scratch.
Gotta admit, i'm extremely proud of it.

image.png
After 7 months of really hard work and then 6 months of lazing around and procrastinating with adding the final touches my game is finally complete! Not bad considering that a year ago I didn't really even know about variables. Thanks to everyone who helped with questions and assets! Feels good to have a game under my belt! Ep2 (also self contained) may possibly come in the future!
I just made a breakthrough in my Battlecore problem where the Abort Battle command wouldn't work after using a Custom Action Sequence skill. It seems that Abort Battle can't be the last command in the event.
Before, the event was ordered (Dialogue -> Abort Battle). But having the message appear LAST fixed it.
(Abort Battle -> Dialogue)
"Does anyone remember the new year 2022? yeah, that was like yesterday. Wait, what do you mean by '2022 is almost over'?"
kuestsdynamisxp001.jpg


Just a glimpse of how Kuests Dynamis XP would look like.

Forum statistics

Threads
126,886
Messages
1,182,069
Members
166,675
Latest member
OPOPOP
Top