RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu

[Resolved] [RPGMaker 2k3] Detecting distance/range from event to player?

Started by samfortunato, July 15, 2011, 09:55:29 PM

0 Members and 1 Guest are viewing this topic.

samfortunato

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.

modern algebra

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.

samfortunato

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.