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
485
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

YES! officially released my games soundtrack on Itunes, Spotify, and Amazon..... kinda cool!

Another old age version of Reid. Trying out different style.
Hey everyone! Not sure how many people know about Cafofo Music on Itch.io, but I highly recommend their Sound Effects! It is amazing quality AND quantity and best of all, they are having a 50% sale! I can't express how much I love sales.
Wow.... My last map GIF got 47 likes, 16 retweet and 2,105 views on Twitter in 24 hours. My game thread here's only got 3k views in 6-7 months. I guess building my Twitter was insanely worth it. :LZSexcite:

Forum statistics

Threads
105,594
Messages
1,014,876
Members
137,264
Latest member
ZeoValinferno
Top