EventChasePlayer extension so events can't see through impassable tiles - RMMV

JDevain

Veteran
Veteran
Joined
Oct 21, 2018
Messages
121
Reaction score
46
First Language
English
Primarily Uses
RMMV
Yanfly's EventChasePlayer plugin makes it so events will chase you if you are in their line-of-sight.

The problem is that events can see through walls (or any impassabe tiles). Well, DreamX wrote a short script that fixes that by checking to see if the tiles are impassable.

Here's the page where I found that plugin.
And here's the plugin itself.

It works perfectly. The only problem is that the event's "cone of vision" is only 1 tile wide. In the EventChasePlayer plugin, the cone of vision goes out at a 45 degree angle. This picture illustrates what I mean:



These are examples based on a "this._chaseRange" of 10 (event will start chasing when you are within 10 tiles from it). The Event on the left shows the original cone of vision (i.e. if you step on a snowy tile, the event will be alerted). The event on the right shows DreamX's cone of vision, which means you have to get directly in front of the event in order for it to react to you (or to the event's immediate side).

I would like something like DreamX's fix, but that retained the original 45 degree cone of vision. I tried contacting DreamX, but his profile page says he was last seen January 2017, so it doesn't look like he's active anymore.

I have no idea how difficult something like this would be, but, for me personally, if making the cone of vision like the one above/left is too difficult or time consuming, then a cone of vision that had a latteral limit of, say, 4 or 5 spaces, would also be very helpful. I don't know if that would make it easier or not, just thought I'd mention it.

Coupled with Yanfly's EventChaseStealth (and, in my case, Yanfly's MoveRouteCore), this would allow people to make much better and more intuitive stealth games.

Thanks!
 

Attachments

JDevain

Veteran
Veteran
Joined
Oct 21, 2018
Messages
121
Reaction score
46
First Language
English
Primarily Uses
RMMV
Hey, thanks for the reply, caethyril!

This actually fixes a different problem, which is that NPCs stop and stare at you when they're not supposed to be able to see you. It doesn't make NPCs unable to see through walls (i.e. impassable tiles).

DreamX's plugin fixes the seeing-through-walls problem, which, in effect, also fixes the stop-and-stare problem. The problem with DreamX's plugin is that NPCs have a cone of vision that is just one tile wide, so they won't start chasing you unless you get directly in front of them (it's not a bug or anything, that's just how he wrote it).
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,959
Reaction score
1,406
First Language
EN
Primarily Uses
RMMZ
OK, so I think my line-of-sight plugin is working properly now...it's much more complex than most other stuff I've tried for RMMV so fingers crossed! Here's a link:
By default it's set up to only consider tileset passability for blocking sight, but there are options available (hopefully not too confusing) if you want to consider events and/or regions. You may want to alter the default range and FOV ("cone of vision") in the parameters. Toggle the "Use line-of-sight" parameter under YEP_EventChasePlayer and it should use the new algorithm for those vision checks. Make sure it loads after Yanfly's Chase plugins, too.

It's fairly lightweight (checks once per tile) so hopefully there won't be any notable performance issues. :kaoswt:

I'll get around to posting this in Plugin Releases at some point, just thought I'd post it here first~ :kaoslp:

(Incidentally, I found that EventChasePlayer's vision "angle" is actually just based on relative coordinates, e.g. if you're "higher" on the map than the event and you're in range, they will see you if they face up, no matter what your relative x-positions are. The range helps reduce this effect, though.)
 

JDevain

Veteran
Veteran
Joined
Oct 21, 2018
Messages
121
Reaction score
46
First Language
English
Primarily Uses
RMMV
Wow, caethyril, thanks!

I'll test this out and get back to you. It may take a few days, as I'm busy with Christmas and all for the next couple of days. I've been trying all kinds of complicated workarounds, and if this works, it would definitely make things a WHOLE lot easier.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,959
Reaction score
1,406
First Language
EN
Primarily Uses
RMMZ
You're welcome! And take your time, I think I need a bit of a break from that plugin now, haha. :kaoslp:
 

JDevain

Veteran
Veteran
Joined
Oct 21, 2018
Messages
121
Reaction score
46
First Language
English
Primarily Uses
RMMV
Hey, caethyril. I know I said it would probably be a few days, but apparently I can't seem to keep my hands off of this project...

So anyway, I've been experimenting with your plugin, and I must be doing something wrong. I can't seem to create a scenario where there's a difference between having your plugin on or off. I've uploaded a demo here so you can see exactly what I'm doing. As you'll see, I have a solid wall between the player and the NPC, and I've also placed a region over that wall and declared it in the "Region Occlusion" settings. Either way, with your plugin on or off, it seems to have the exact same behavior, which is that the event sees through the wall as if it's not there and starts following the player as soon as it gets in the event's FOV.

I was wondering if you could take a look at the demo, whenever you get a chance, and let me know what I'm missing. But no rush or anything, I know you mentioned that you're a little burnt out on this plugin.

Thanks!
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,959
Reaction score
1,406
First Language
EN
Primarily Uses
RMMZ
Luckily this looks like an easy problem to solve, albeit one I haven't seen before.

It seems you've somehow got a version of the plugin with an extra line, Displaying Cae_LineOfSight.js., at the end? That's causing an error and making the plugin completely fail to load (hence no difference on or off). I tried deleting the line and your demo started working as expected. :kaophew: Not sure where the line came from in the first place, though (I double-checked the Drive version and it looks fine). :kaoswt2:

Two things to try:
  • Re-download the plugin! (Not sure if this'll work because not sure how that extra line got there...)
  • Open up the plugin in a text editor (even something basic like Notepad should work OK) and check that the very last line is this:
    Code:
    })(CAE.LineOfSight);
    Delete anything you see after that line, save, and test the project again~ :kaopride:

I notice that the plugin doesn't cope well with "wall-top" tiles, though, that'll probably need fixing. "Wall" tiles are OK, the tops/ceilings aren't. Probably because you can walk around on the latter once you're up there. :kaosigh: Regions work OK, though!

For reference: during playtest you can press F8 to display the console. Any red text there indicates an error, which may or may not have a serious cause, like a plugin failing to load.

Merry Christmas! :kaojoy:
 
Last edited:

JDevain

Veteran
Veteran
Joined
Oct 21, 2018
Messages
121
Reaction score
46
First Language
English
Primarily Uses
RMMV
OK, I've been testing this out, and I've tried to break it in about every way I can think of, and I haven't experienced a glitch yet. You did it! The added feature of being able to choose a field of view was such an improvement. I thought I wanted the default 90 degree angle (45 degrees on each side), but after experimenting with it, I realized a 160 degree angle works a lot better, has a more natural feel. That might not have even occured to me if I was locked into a hard-coded 90 degree reality.

This was a wonderful Christmas present. Thank you!

As for the weird insertion at the end of the script, here's what happened: instead of downloading the script directly, I copy-pasted your code into a plain txt file, and then renamed it as a js file. For whatever reason, it copied "Displaying Cae_LineOfSight.js." and pasted it at the end, even though it wasn't it the text. I guess it grabbed it from the HTML source code. So that's good to know.

Really, I think anyone using Yanfly's Event Chase Player plugin should be using this too. Thanks so much!
 

JDevain

Veteran
Veteran
Joined
Oct 21, 2018
Messages
121
Reaction score
46
First Language
English
Primarily Uses
RMMV
caethyril, it looks like maybe I spoke too soon. I'm now having problems with occlusion depending on which way the event is facing and what the range is set to. There's no consistent pattern to it, it's different on different maps.

Here are some pictures to show you what I mean. The light stone tiles represent the event's FOV, and the red/orange tiles represent places where the event can see the player even with an occluding region blocking their view. The first four are with a range of 9, the next four with a range of 10.





Here's another one, also with a range of 9, but on a different map, and it has a completely different pattern than the other one with a range of 9 facing the same direction.



I haven't been able to figure out any common denominator, it seems random. I uploaded another demo here, if that helps at all. I'm hoping it's something that I'm doing. By the way, your script's size on my end is 28,175 bytes. Is that right? I was thinking that maybe it got corrupted again, and that's what's causing the problem...
 

Attachments

Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,959
Reaction score
1,406
First Language
EN
Primarily Uses
RMMZ
Oh yes, bug confirmed, sorry! :kaoback: It's an error related to drawing the line of sight: it's going in the wrong direction for some reason and never reaching the target. Then it's checking the wrong set of tiles for occlusion and producing "random" looking results. I think it may be due to rounding errors but this was one of the biggest issues I had before release...will let you know if I come up with a fix!
 

alphawiz

Veteran
Veteran
Joined
Feb 8, 2017
Messages
57
Reaction score
9
First Language
English
Primarily Uses
RMMV
OK, so I think my line-of-sight plugin is working properly now...it's much more complex than most other stuff I've tried for RMMV so fingers crossed! Here's a link:

By default it's set up to only consider tileset passability for blocking sight, but there are options available (hopefully not too confusing) if you want to consider events and/or regions. You may want to alter the default range and FOV ("cone of vision") in the parameters. Toggle the "Use line-of-sight" parameter under YEP_EventChasePlayer and it should use the new algorithm for those vision checks. Make sure it loads after Yanfly's Chase plugins, too.
:kaoswt:
You are a game saver! I kept running into problems with my guard events seeing the player while they're at important locations, coming over and wrecking things. This plugin made it possible to actually dodge the guards and do other stuff on the map without having to completetly redo the maps.

THANK YOU for writing it!
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,959
Reaction score
1,406
First Language
EN
Primarily Uses
RMMZ
You are a game saver! I kept running into problems with my guard events seeing the player while they're at important locations, coming over and wrecking things. This plugin made it possible to actually dodge the guards and do other stuff on the map without having to completetly redo the maps.
Wait, what? I thought it was broken...something like the lines going off in the wrong directions? :kaoswt2:

Galv has a neat line-of-sight type plugin here in case you're interested:
 

alphawiz

Veteran
Veteran
Joined
Feb 8, 2017
Messages
57
Reaction score
9
First Language
English
Primarily Uses
RMMV
It may be broken somehow, but it works well enough for my purposes.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Less than a week and I can move into my new apartment and out of this bad situation. I'm so excited! Then game making power will increase. :kaoluv:
Enter the password in letters. (English subtitles)
I really tried to pull off something for halloween, but I don't feel like going on. I feel like the plot I was building was too generic, and I couldn't connect to it as I do with other projects. On the bright side, I've been working on my cosmic-puzzle project, so far I think the core mechanics are working properly, so I'll be creating some large test maps to see how it works out.
People2_5 & SF_Monster1 added!

Ami
--- X Costume ---

M.Healer: I'm wearing M.Mage's Costume.
M.Mage: I'm wearing M.Healer's Costume.
M.Knight: Why not using the Scary Costume like me,The Scary Frankenstein?
M.Healer: Err…Because we have low of Budget.
M.Mage: Yeah,right.

Forum statistics

Threads
104,602
Messages
1,007,483
Members
136,084
Latest member
TikeTenGamesOffical
Top