How to make events detect or interract to another event ?

Discussion in 'RPG Maker MV' started by Ardonie, Nov 18, 2019.

  1. Ardonie

    Ardonie Villager Member

    Messages:
    13
    Likes Received:
    4
    First Language:
    french
    Primarily Uses:
    RMMV
    Hi ! (I don't speak english very well, i'm sorry if I make mistakes and i'm hoping I could be understandable. :) )

    I'm using RMMV and I'm trying to make one event detect another, via collision or zone detection.
    moreover, I would like an event A to be able to detect an event B or event C, but that its reaction is not the same depending on the event encountered, like run away from an event or follow it.

    I know that on RPG Maker, events do not detect each other by default, they can only detect the player... I've been looking for a way for months and I have no clue......

    Do you know any plugins to allow this?
    Or even a trick to make it possible anyway?
     
    Last edited: Nov 18, 2019
    #1
    ct_bolt likes this.
  2. Andar

    Andar Veteran Veteran

    Messages:
    28,672
    Likes Received:
    6,594
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    There are ways, but you need to go into more details on when and what should happen.

    The problem is that all of the workarounds have their own disadvantages and problems, and we need to know what your event will have to do before we can advice you into which workaround will work for you and which will not.

    This goes double if the reaction to another event will be different depending on what that event is. Because the default workaround (comparing event coordinate) will be very problematic ad full of lag if it needs to check different events for different reactions.
     
    #2
    ct_bolt likes this.
  3. Ardonie

    Ardonie Villager Member

    Messages:
    13
    Likes Received:
    4
    First Language:
    french
    Primarily Uses:
    RMMV
    I have some examples in mind like:

    1) the fox and the hen:
    the two events wander quietly on the map, but when they are close enough, say 3 tiles apart, the fox and the hen change their behaviour, the fox will chase the hen, and the hen will flee the fox, they will also move more quickly.
    if the fox catches the hen, he eats it and the hen's event disappears.
    if there are several hens on the field, the fox will hunt the nearest one.
    if the hen manages to escape, then the fox returns to his usual behaviour, which is to walk quietly on the map.
    I use the YanFly plugin "Event Proximity Activate" for zone detections, but I don't know how to use it to make one event detect another.

    2) the flame behavior
    I made a system that generates flames on the field, if the player does not extinguish the flame quickly, a new spawn flame on the adgacent tiles.
    the flame can burn other events, such as a living being or furniture.
    if the flame is not extinguished after a while, the living being turns into a ghost.
    the furniture will turn into a pile of ashes.

    3) animals on plants
    the player can grow plants on the map and have cows.
    if the cows walk on the crops, it will crush the plant directly.
    crows can come randomly on the map too, they walk on the plants but do not crush them. But they will eat the fruits and berries.

    I hope that these examples allow to visualize what kind of system in event or plugin could be involved,
    I also use the triforce plugins by YanFly as well : Copier, Spawner and Morpher.
    this plugin allows you to create main events on a separate map that serves as a database. you can retrieve a main event as a template and copy it to make it spawn on the map in game, so I wonder if the IDs of the spawned events are the same as their template in the database,
    I have to check this out.
     
    #3
    ct_bolt likes this.
  4. ImaginaryVillain

    ImaginaryVillain Map Event Specialist Veteran

    Messages:
    172
    Likes Received:
    180
    First Language:
    Event Gibberish
    Primarily Uses:
    RMMV
    Well the good news is, your months long search is at an end. I cracked the code on how to differentiate events awhile back.... Pretty much a necessity when you allow the player to place events like I'm doing. Unfortunately the explanation is complicated and you will likely have to adapt it to what you're doing. So you're about to fall down a rabbit hole. :LZSwink:

    Anyway essentially the plan is to give the events a specific characteristic.... So for me I've been using Self Switch A-D. Since I'm using Yanfly's Self Switches and Variables I don't actually use A-D. So I rule a parallel process on the first page of an event and turn on the appropriate switch. But I don't give that switch a page, I instead advance it to different page (Self Switch 1) where it's behavioral events run.

    Then using https://galvs-scripts.com/2016/08/14/mv-puzzle-functions/ (mostly because I didn't want to run requests of events for their switches) I execute a conditional for Galv.PUZ.selfSwitchesOn('Letter',$gameVariables.value(#)); where letter is A-D and the variable is the event ID in question. This checks to see if the switch 'Letter' is on for '#'. Just put whatever code you want it to do in that conditional and you're good.

    If you have no clue how I got the event ID in the example https://forums.rpgmakerweb.com/index.php?threads/rpgmv-having-events-interact.113558/#post-1006170 shows a very simplified example. And in https://forums.rpgmakerweb.com/inde...ent-touching-other-event.114005/#post-1009648 I posted another example where I actually used Galv's Puzzle functions for a projectile.

    There is another option, which I ended up scrapping due to unpredictable behavior with Yanfly's Self Variables/Switches. But if you wish to go that route, when an event is spawned have it push it's event ID to an array. Then have an event check the event ID against that array and if it finds it, run your code. You can even splice the event ID from the array if you wish to recycle numbers. I can probably dig out the code if you want to go this way. I think the upside is it makes differentiating events unnecessary since it replaces that part of the equation, but really didn't save the processing power due it still requiring me to track coordinates anyway. So really it's just a Galv Puzzle Functions replacement in this example.

    Anyway fair warning both of these are CPU intensive, so you will need to spend a lot of time reworking events so you don't bog down the game. Then again I've managed to place over 150 events on the screen with no lag so it's not the worst. But if you're developing for mobile it might be.
     
    #4
    ct_bolt likes this.
  5. Ardonie

    Ardonie Villager Member

    Messages:
    13
    Likes Received:
    4
    First Language:
    french
    Primarily Uses:
    RMMV
    Wow! Thank you very much for all this information, all this links, this potential solutions!

    yes I had come to the same conclusion in my reflection: to have a kind of identification of the event by a defined ID, classifying the events by "defined ID" and so by category. According to this value, the event met adapts its reaction.

    No, fortunately, I only play games for PCs! And I limit the number of spawned events in my game (to avoid computers turning into Panini toaster)

    I'm going to immediately look at all this, I guess it's not going to be very simple, but now I have something concrete to think about.
    I'll keep you informed.

    Thanks again !
     
    #5
    ct_bolt likes this.
  6. ImaginaryVillain

    ImaginaryVillain Map Event Specialist Veteran

    Messages:
    172
    Likes Received:
    180
    First Language:
    Event Gibberish
    Primarily Uses:
    RMMV
    Sure thing, also I was reading through your second post. Though I switched to Galv's Event Spawner, I used to use Yanfly's for awhile... It defaults to starting with event 1000. You can change the setting in the plugin options. Any event you create on a map adds to that number, but even if you despawn it it won't subtract from it.

    Also worth noting I tried for awhile back using Self Variables to differentiate events, unfortunately Galv's Puzzle Functions like most things doesn't like Yanfly's Self Variables. At the time it was beyond my knowledge on how I'd work it without the puzzle functions so I scrapped the idea, now I might just revisit the idea. I'm nothing if not terribly excited to try out complicated and unnecessary eventing solutions in the name of science. :hswt:
     
    #6

Share This Page