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.
[embedded media]
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.
How to Create Dynamic Trees
● ARCHIVED · READ-ONLY
-
-
You can do something like:
Code:on page 1 andif $game_player.x.between?(3, 8) && $game_player.y.between?(1, 4) $game_self_switches[[@map_id, @event_id, "A"]] = true end
Code:on page 2.if !$game_player.x.between?(3, 8) || !$game_player.y.between?(1, 4) $game_self_switches[[@map_id, @event_id, "A"]] = false end
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:on page 1 andex = $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
Code:on page 2.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
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'. :) -
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?
-
No worries! Just put the code in a script call (tab three).
-
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.
Spoiler -
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:
Alternatively, if you're uncomfortable with having the whole thing as a script call, you can do this:
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. -
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?
-
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.
-
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.