Making rules for multiple events

● ARCHIVED · READ-ONLY
Started by Geoff Moore 8 posts View original ↗
  1. I'm making a minigame where a mother racoon has to save her babies from a witch, and the baby racoon will follow either the witch or the racoon. I want to add more racoon babies and enemies to it, but the way I'm doing it the eventing is going to get kind of out of hand, and is going to make it really hard to go back and change stuff if I need to. I'm wondering if there's a way to apply rules to multiple events. For example:
     

    raccoon1.jpg

    raccoon2.jpg

    This common event (triggered by a parallel process) checks if a baby racoon (events 2 through 6) is 1 tile away from the witch (event 7). If true, the baby racoon follows the witch UNLESS the player is 2 or less tiles away from the baby racoon. The conditional branch code goes off the edge of the screenshot, the first nested pair read like this:

    ($game_map.events[2].x - $game_map.events[7].x).abs + ($game_map.events[2].y - $game_map.events[7].y).abs == 1

        ($game_player.x - $game_map.events[2].x).abs + ($game_player.y -     $game_map.events[2].y).abs <= 2

    And then that's repeated all the way down the event with the [2] increasing to repeat the logic for each racoon baby.

    So, my question is, can I just have one bit of code that checks this for any baby racoon and any enemy, rather than having to make a separate condition for every single combination of baby racoon and enemy?

    I hope I explained that okay. Thanks for reading!
  2. I haven't looked at your sreenshot (honestly, I've just fallen out of bed and still haven't finished my first cuppa).


    Instead of having one event that does a loop to check multiple events, can you just make a common event that checks "this event" (the baby raccoons) and determines who they should follow?


    In script, that would be $game_map.events[@event_id]


    Make your baby raccoons a parallel process, add a Call Common Event to that event that checks, and then make it move towards the appropriate target. There'll be a bit of tweaking to see if they need to change targets, or to stop doing the check once they've chosen a target or whatever.


    May not work any better than what you already have, but it's another option to consider.
  3. I see... I'm going to try and figure this out, thanks! The player can also be a target for the baby raccoons, so how would I set the player as the target? At the moment I'm using autonomous 'approach' movement, but it would be tidier if I could refer to the player's ID. For the witch (event 7), I'm using this in a custom move route:

    move_toward_event(7)

    What do I use for the player? Thanks for bearing with me.

    Edit: forgot to mention that code is from FP: Move Routes by Tsukihime: http://www.rpgmakervxace.net/topic/3891-fp-move-routes/

    Edit 2: Also, how do I actually set the follower for the specific raccoon? My individual branches in the screenshots set a separate variable for each raccoon, how can I do that without the individual branches?
  4. There is a move route command for Move Toward Player.
  5. Ah, okay, I was using an autonomous Custom Move Route which doesn't allow for conditions, if I understand correctly. So yeah, I need to do it in the main event window, I think. But I still need to know how to refer to the player in my events.

    The problem is, I don't understand how to pass the information to the triggering event. Could you take a look at the screenshots in my first post if you have time? At the moment I'm setting a variable for each baby that touches an enemy, and a switch when they touch the player. I want to throw the relevant information to whichever baby activates the event without all the individual clauses, is that possible? Sorry if I'm being dense, I'm just struggling with the concept.

    The way I see the logic for enemies touching raccoons working is this:

    If the event triggering this common event is within 1 tile of any enemy:
       If the event triggering this common event is within 2 tiles of the player, do nothing.
       Otherwise, set the event tiggering this common event's target to the ID of the enemy.

    And then the baby raccoon events will move at random unless they are following an enemy or the player.

    Sorry, I'm still really new to this. Thanks again!
  6. That script looks very helpful, Tommy Gun, but I don't see how it solves my problem. At the moment I'm storing variables for every individual raccoons target, surely if I had clone objects and one variable they would all do the same thing? I'm basically wondering if I can get around having all those separate variables.

    It's entirely possible you've answered my question and I just don't get it. If so, could you break it down for me? If not, please let me know if my explanations above don't make sense, and I can try and rephrase the issue. Thanks.

    EDIT: Hmm... even though I don't really understand, I have an idea for how to solve this. I'm going to use multiple event pages with autonomous movement in the raccoons and a script that allows me more to use more self switches, which will clutter my raccoons a little but means I can use [@event_id] throughout the common events, which is more important. I might try a local variables script as well, for the enemy event ID to follow. Any advice on how to simplify this further would be appreciated. Thanks!
  7. What you're trying to do is very complicated (and very admirable) and it looks like Shaz has given you some great direction so far.

    I'm not 100% sure but I think that if you got creative with the scripting you could make this process much easier by aliasing one of the default Move methods.  For example, in my most recent game I wanted one specific type of "enemy" NPC character to usually stay still, and occasionally move left or right.  I arbitrarily chose to alias the move_random method, and wrote the code as follows so that only events with this specific event model will use the new move_random behavior (other events can still use the old move_random behavior).  That way, I could simply use a really simple Custom Move Route for each of these enemies that simply had one line: Move Random.

    If you implement your logic for checking the distance between the event and the Mother Raccoon/Witch and then moving toward one event or the other (or doing nothing) into a method like this, you can probably make it work well.

    Code:
      #--------------------------------------------------------------------------  # * Move at Random - PARTIALLY OVERWRITTEN  #       This method will only use the original behavior if an Event ID  #       match (for any custom movement) is not found.  #--------------------------------------------------------------------------  alias :move_in_pattern :move_random  def move_random    m_type = 0 # The Custom Movement Pattern for a given event    case character_name    when "Evil"      m_type = 1 if character_index = 7    end    case m_type    when 1      rng = rand(4).to_i      if rng == 3        move_straight(4)      elsif rng == 2        move_straight(6)      else        @wait_count = 15      end    when 0      move_in_pattern    else      move_in_pattern    end  end