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
16
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
540
Reaction score
219
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
484
Reaction score
205
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
16
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
16
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
16
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
16
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

LittlePIGGY wrote on atreyoray's profile.
Where are you TT^TT
We need ARP_InGameManual for MZ
Oh my gosh. Thank you, Macy's! Thank you so much! You have made me very happy!
Happy Thanksgiving everyone! What are you thankful for? I'm thankful that I no longer have PTSD, and that I get to enjoy a good meal with my mom and stepdad! It might not be the same as before COVID, but at least I still get to enjoy the holiday!


Made another map, this one even has a cool moving waterfall. I'll have an animated GIF later whenever I'm done adding stuff. :LZSwink:

Forum statistics

Threads
105,548
Messages
1,014,544
Members
137,226
Latest member
Eryndor
Top