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
618
Reaction score
266
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
680
Reaction score
349
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!
 

Latest Threads

Latest Posts

Latest Profile Posts

Not sure if it's true (and I won't judge or blame anyone if it is, really), but I heard from confident sources that you guys (and girls) really really like to
How is this new year for everyone? Hope you are well. Still deep in Covid in the US. Its like a vampire and refuses to die with even more strains. I need some holy water to kill it with.
in my game, what's known as HeadSpace is combining with the real world...
oh looks like the forums updated while I wasn't looking and we can put a banner now. Neat!
Treating this as a devlog

Forum statistics

Threads
107,665
Messages
1,031,264
Members
139,790
Latest member
TransDiv
Top