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
541
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
493
Reaction score
223
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 Posts

Latest Profile Posts

being able to transition music seamlessly is amazing. my main character's theme has lyrics and it goes from vocal version to istrumental when he leaves his room. and vice versa. and thanks to a plugin, the transition is seamless. I love it.
All of the auditions for our game are so good, I'm so glad I'm not in charge of choosing completely. lol I just can't with some of them. I listen to them on repeat. XD
Working on a Patch to integrate AlphaABS into random generated Dungeons. Was a bit tricky, but the outcome is a real Life Changer!!

Will release it the next days!
Been pretty busy... but I got a better headset for recording and listening today. Dad says that he'll consider taking me to Great Wolf Lodge for the first time once I finish summer classes (my final semester!) I'll be taking my plushie friends with me: Bendy, Lolbit, and Helen Henny. (I WUV PLUSHIES!)
SF_Monster3,4 added!

Forum statistics

Threads
105,651
Messages
1,015,304
Members
137,327
Latest member
Mezzy
Top