RMMV I need a plugin that detects if two specified events are touching eachother

jakeybreaky

Veteran
Veteran
Joined
Nov 9, 2019
Messages
40
Reaction score
18
First Language
English
Primarily Uses
RMMV
I have an enemy which is set to parallel, which will chase the player when it’s on screen. I basically need a plugin that can trigger a separate event once the player and the specified enemy touch.

Currently I’m using variables that track the player and the enemies X and Y coordinates, unfortunately the way I’m doing things now lags the heck out of the game as it is, and I’d eventually like to have as many as four of these enemies on screen at once.

Being able to set a conditional branch so “If Event 1 is touching Event 2 then:” would be ideal.

Anybody wanna take a crack at it?
 

Tiamat-86

old jrpg gamer
Veteran
Joined
Dec 5, 2017
Messages
604
Reaction score
256
First Language
english
Primarily Uses
RMMV
theres a few ways this can be done with yanfly plugins.
event chase was made for this.
but the same setup could be made with move route core

the main point being changing the movement to an autonomous movement instead of parallel process so the trigger type can be changed to either player touch or event touch
 

Dopan

Veteran
Veteran
Joined
Mar 27, 2020
Messages
674
Reaction score
347
First Language
German
Primarily Uses
RMMV
JavaScript:
$gameMap.distance($gameMap.event(Id1).x, $gameMap.event(Id1).y, $gameMap.event(Id2).x, $gameMap.event(Id2).y)
This calculates the distance betwen 2 Events.

Following scriptCall will Set a switch to True or False depending if the Distance betwen Event 1&2 is "1" or not.
JavaScript:
// ScriptCall : "this.distanceOne(id1, id2, switchID);"
        Game_Interpreter.prototype.distanceOne = function(id1, id2, switchID) {
            var dst = $gameMap.distance($gameMap.event(Id1).x, $gameMap.event(Id1).y, $gameMap.event(Id2).x, $gameMap.event(Id2).y);
                If ( dst == 1 ) {$gameSwitches.setValue(switchID, true)} else {$gameSwitches.setValue(switchID, false)} ;
        };
Edit
But i think using an event chase player plugin and let that event get triggered with Player touch, should do the job aswell..
(i did something similar in one of my projects)
 
Last edited:

jakeybreaky

Veteran
Veteran
Joined
Nov 9, 2019
Messages
40
Reaction score
18
First Language
English
Primarily Uses
RMMV
theres a few ways this can be done with yanfly plugins.
event chase was made for this.
but the same setup could be made with move route core

the main point being changing the movement to an autonomous movement instead of parallel process so the trigger type can be changed to either player touch or event touch
Hmm... This could work... I'll fiddle around with it a bit! Thanks!
 

jakeybreaky

Veteran
Veteran
Joined
Nov 9, 2019
Messages
40
Reaction score
18
First Language
English
Primarily Uses
RMMV
JavaScript:
$gameMap.distance($gameMap.event(Id1).x, $gameMap.event(Id1).y, $gameMap.event(Id2).x, $gameMap.event(Id2).y)
This calcukates the disatnce betwen 2 Events.

Following scriptCall will Set a switch to True or False depending if the Distance betwen Event 1&2 is "1" or not.
JavaScript:
        Game_Interpreter.prototype.DistanceOne = function(id1, id2. switchID) {
            var dst = $gameMap.distance($gameMap.event(Id1).x, $gameMap.event(Id1).y, $gameMap.event(Id2).x, $gameMap.event(Id2).y);
                If ( dst == 1 ) {$gameSwitches.setValue(switchID, true)} else {$gameSwitches.setValue(switchID, false)} ;
        };
Nice! Thanks!
 

jakeybreaky

Veteran
Veteran
Joined
Nov 9, 2019
Messages
40
Reaction score
18
First Language
English
Primarily Uses
RMMV
Update: I ended up going with the Yanfly plugin. It took a little fiddling to get the event to do exactly what I wanted, but the game is running a lot smoother now.
 

jakeybreaky

Veteran
Veteran
Joined
Nov 9, 2019
Messages
40
Reaction score
18
First Language
English
Primarily Uses
RMMV
Thanks! I'll take a look at that one as well!
 

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

Latest Threads

Latest Profile Posts



Guess what's next...
How you feel about font and dialogue box changing for every main character while the minor cast and regular npc get their own styles? Too much?
Just found an obviously custom effect (i.e. edited by me) in my resources>sounds folder called "rip jaw off". Dear Lord what is wrong with me as a person that at some point I needed a sound *specifically* for THAT??
(...rhetorical question.)
so like with the whole 'familiarity breeds contempt thingy', how are you supposed to tell if your title screen/battle music gets really tedious after a few dozen plays or if you're just personally hella sick of it?
YAY!!! My third help Guide STEAM integration in MV (High performance) has been posted!

Forum statistics

Threads
107,520
Messages
1,030,227
Members
139,644
Latest member
five88uytin1
Top