Vlue 271 Posted April 28, 2012 (edited) Proximity Events - v1.3 by V.M. Introduction This script will allow you to use the script portion of conditional branches to activate events based on player proximity. Uses could be monster groups that chase down the player or lights that activate when the player walks near them, or anything else you can manage to do with it. Features - Activate events based on how close the player is to them How to Use All details in the script. Script Convenient Pastebin: Here FAQ To be announced if necessary? Credit and Thanks - By V.M.of D.T. - Free to use in any project with credit given History Version 1.3 - Simple Line of Sight! Ooooh ahhhh. Version 1.2 - Added rectangle function (inprox_r?) Version 1.1 - Added directional function (inprox_d?) Edited December 11, 2012 by Vlue 6 Share this post Link to post Share on other sites
Jon Wei 5 Posted April 28, 2012 (edited) Whoa. This is useful. Reminds me of the good ol' Eventer's Toolbox. After copy and pasting your conditional checks, I am still getting errors (undefined for inprox/ Game_Interpreter) Edited April 28, 2012 by Jon Wei Share this post Link to post Share on other sites
Wendell 81 Posted May 4, 2012 I am with the same error. Share this post Link to post Share on other sites
Vlue 271 Posted May 4, 2012 Oh, bad examples! Bad!! They lost their question marks somewhere, I gave them new ones. Clarification.. it's Proxy.inprox? and not Proxy.inprox that's why it's not working. Share this post Link to post Share on other sites
Wendell 81 Posted May 4, 2012 Working perfectly now. Very good work. Share this post Link to post Share on other sites
Tsukihime 1,489 Posted May 4, 2012 (edited) Can you add shapes as well? Currently it's a single line (in one direction, or all 4 directions). How about triangle scope (one direction, 4 directions)? Perhaps specifying the angle of the line as well? (eg: so I could make sweeping scopes just by looping over the angle) Or perhaps a rectangle? origin is the center of the sprite, takes up the entire width and height of the sprite rounded down to the nearest tile (eg: if it takes up only partial tiles, just forget the ones on the outside). You can round it down to the nearest 32 pixels (tilesize) and then divide by 32 to get the value relative to the tilemap. Edited May 4, 2012 by Tsukihime Share this post Link to post Share on other sites
Vlue 271 Posted May 4, 2012 Can you add shapes as well? Currently it's a single line (in one direction, or all 4 directions). How about triangle scope (one direction, 4 directions)? Or perhaps a rectangle? origin is the center of the sprite, takes up the entire width of the sprite rounded down to the nearest tile. Actually as it works, inprox_d? isn't a line, it's triangular-y shaped like the first portion of your pic! If orthogonocologicly directions means not just 4way however, no it doesn't work like that, this uses tiles and not pixels. And inprox? isn't a line in either direction either, its a circle! (As circly as a bunch of tiles can be anyhow!)((ok more of a diamond, but shsh) Rectangangly would be possible yes, I'll probably throw that in (sometime... eventually) Share this post Link to post Share on other sites
Tsukihime 1,489 Posted May 4, 2012 ya it's fine if it's not possible. I was thinking maybe there was a way to quickly calculate diagonal proximity quickly. Share this post Link to post Share on other sites
Vlue 271 Posted May 4, 2012 ya it's fine if it's not possible. I was thinking maybe there was a way to quickly calculate diagonal proximity quickly. One day maybe it will be! (It's certainly possible to write in, if I find the time) On the plus side? New version, new function. Proxy.inprox_r?(@event_id, width, height) will check to see if the player is in the rectangle around the event as defined by width/height Works best with odd numbers! Share this post Link to post Share on other sites
Tsukihime 1,489 Posted May 4, 2012 (edited) Hmm, when I say (@event_id, 2, 2) if you approach from the left, it works. If you approach from the top, it works. If you're standing diagonally to the event in the top-left, it works. But if you approach from bottom or right or basically anywhere on the other side, it doesn't work. In my head that means "a rectangle of width 2 and height of width 2" But that doesn't really tell you where the origin is. The origin should be centered at the middle of the tile (eg: x*32 + 16, y*32 + 16). It is not an easy problem with tiles because you are working with 32 pixels each, where you have to first convert to pixels to determine the size of the box, and the convert it back to tiles to determine what the actual range is. Edited May 4, 2012 by Tsukihime Share this post Link to post Share on other sites
Vlue 271 Posted May 4, 2012 There's a reason I said works best with odd numbers! Share this post Link to post Share on other sites
Tsukihime 1,489 Posted May 4, 2012 (edited) Oh lol alright as long as it's odd it works as expected Edited May 4, 2012 by Tsukihime Share this post Link to post Share on other sites
Geoff4321 0 Posted June 13, 2012 What I need to input in the "#" of Proxy.inprox_d?(@event_id, [#]) ? Share this post Link to post Share on other sites
Vlue 271 Posted June 13, 2012 A number. Specifically the number of tiles away it will check up to. Share this post Link to post Share on other sites
Tobyej 4 Posted June 13, 2012 Hey, I am just having an issue with "Proxy.inprox_d?(@event_id, [#])", it always comes up with an error: game interpreter line 450: type error occurred. Array can't be coerced into a Fixnnum. I tried it out a on a completely fresh project, no other scripts and get the same issue. All the other calls work perfectly though (this is one incredibly useful script by the way! Thanks a bunch for it!). 1 Share this post Link to post Share on other sites
Vlue 271 Posted June 14, 2012 Hrm I actually posted it as [#] with the brackets and all... oops. Yah, just use a number, don't use brackets. Post edited to reflect that. My bad~ Share this post Link to post Share on other sites
Tobyej 4 Posted June 14, 2012 Ah okay, thanks! It works fine now. Share this post Link to post Share on other sites
Tobyej 4 Posted June 14, 2012 (edited) Just have a suggestion: is it possible to make it so these can be based off the player as opposed to an event? I just want to use it with directional checking, so certain events will act differently when the player is facing them. EDIT: And maybe add a feature that allows events to detect each other? So if one event is in within range of another, it will give chase for example. Edited June 15, 2012 by Tobyej Share this post Link to post Share on other sites
Paddy 77 Posted July 25, 2012 Haha, this script is so much fun. I was wondering, is it possible so that events can't see you when you're behind specific tiles, like walls and crates, etc? 1 Share this post Link to post Share on other sites
Vlue 271 Posted July 25, 2012 No not atm, but I've been thinking about it. Share this post Link to post Share on other sites
Paddy 77 Posted July 25, 2012 (edited) That's a tad unfortunate. But it's not like this is still short of its uses. Right now I've thought of so many ways I could make my project more fun using this script, so cheers for that. EDIT: Been fiddling around with the events I've been using for this script, and I've figured out a way to "hide" behind certain tiles. It's quite simple, and makes use of regions. All you need to do is assign a conditional branch for the script call, so it only gets triggered when you're on a specific tile. Kinda like this: Control Variables: [0001: Region] = $game_player.region_id Conditional Branch: Variable [0001: Region] = 1 Conditional Branch: Script: Proxy.inprox_d?(@event_id, 5) And then follow on from that. As for scripting that in for the sake of simplicity, I think it's possible to add another section, where you could input the ID for any region that you don't want to trigger off the event. I'm pretty clueless with scripting myself, but I know you had something very similar with your climate and day/night scripts. Edited July 25, 2012 by Paddy Share this post Link to post Share on other sites
+ Tuomo L 116 Posted October 6, 2012 There is one major flaw with this script... If you have a mouse, it detects the proximity of the mouse cursor as the player proximity. Share this post Link to post Share on other sites
Vlue 271 Posted October 6, 2012 There is one major flaw with this script... If you have a mouse, it detects the proximity of the mouse cursor as the player proximity. I don't quite understand, this script has nothing to do with the mouse, unless you mean when using a particular mouse script that fancily plays around with how player location works, in which case it wouldn't be a flaw with this script but with their compatibility with each other. Share this post Link to post Share on other sites
Vlue 271 Posted December 11, 2012 Updated to 1.3 to include a basic sort of line of sight component to the detection (which you can say doesn't apply to specific checks) Can also use regions to declare certain obstacles as transparent so they don't interfere with los, like pits and small boulders. Share this post Link to post Share on other sites
Wendell 81 Posted December 11, 2012 I just didn't get the transparent function. If I set a region as transparent what happens? Sorry for my "noobiness". Share this post Link to post Share on other sites