The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Tutorials and Eventing => Topic started by: samfortunato on July 15, 2011, 09:55:29 PM

Title: [Resolved] [RPGMaker 2k3] Detecting distance/range from event to player?
Post by: samfortunato on July 15, 2011, 09:55:29 PM
I'm trying to create an ABS, and I want it so RPG Maker 2k3 would detect the range between a player and an event (NPC/enemy). I want to make it so if the player is right next to the event and hits shift, the Player will 'damage' the enemy (by means of lowering a variable or something). Does anyone know how to do this? Thank you so much.
Title: Re: [RPGMaker 2k3] Detecting distance/range from event to player?
Post by: modern algebra on July 15, 2011, 10:25:44 PM
You can set a variable to the x or y position of any character (event or player). All you'd need to do is check the direction and see if the difference between the player's and event's location is 1 or -1, as the case might be.
Title: Re: [RPGMaker 2k3] Detecting distance/range from event to player?
Post by: samfortunato on July 16, 2011, 12:05:45 AM
How do you check the difference between two variables? I know you can do greater than or less than, equal to etc., is that all I have to do? Or is there a way to check if there is a specific number difference, i.e. a difference of 1 like you said? Unless I'm confused...

EDIT: Resolved; found a way to figure out the calculations. The tutorial I found it from is here: http://rpgmaker.net/tutorials/16/ to detect 'square' proximity (I think, not sure if it's circle; i only tested it out with a distance of 1) if anyone wants to do this.