Event triggers Event

Discussion in 'RGSS3 Scripts (RMVX Ace)' started by MeowFace, Dec 18, 2015.

  1. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    178
    Location:
    La La Land
    First Language:
    Meowish
    Made for a request here.

    This allows an event with a name tag <eet> to trigger another event with name tag <eer> it came into collision with.

    Features:

    [1] Event triggering another Event

    [2] Able to check who triggered the event

    [3] Able to set up conditional branches to have different trigger actions depending on who triggered the event.

    [​IMG]

    (possible usage example: npc vs npc battle field)

    [​IMG]

    (possible usage example: random killer)

    [​IMG]

    (possible usage example: randomly flip switches)

    How to Use:
    [1] Paste this below Material and above Main
    [2] Add <eet> in the event's name to enable it to trigger another event.
    [3] Set trigger type to [event trigger] on the event with <eet> name tag
    [4] Add <eer> in the target event's name to enable it to be trigger-able by another event

    Note:

    Event with <eet> name tag will still be able to trigger itself when it comes into collide with the player.

    It will be counted as triggered by player.

    [5] To check if it's a player/event that triggers the event, use the script calls below in your conditional branches script box.

    Script calls for Conditional Branches:

    Check if triggered by Player:

    $game_map.events[@event_id].triggered_by == 0Check if triggered by Any Event:

    $game_map.events[@event_id].triggered_by != 0Check if triggered by Event ID N:

    $game_map.events[@event_id].triggered_by == N(where N is the event id number)



    Compatibility:

    This script overwrites the event trigger method, there might be a chance of conflict if you have another custom script overwriting the event triggers.

    Terms of Use:

    Free for both commercial and non-commercial

    Sample Map:

    Simply make a new project, add this script and extract the Map001.rvdata2 file into your Data Folder

    NPC vs NPC Battle Field with 3rd Party Medic: Map001.rar

    Demo Game:

    http://forums.rpgmakerweb.com/index.php?/topic/53887-medic-medic/

    Script:

    #==============================================================================# ■ Meow Face Event - Event Trigger#------------------------------------------------------------------------------# Allow Event with name tag to trigger other events with name tag on collision#==============================================================================# How to Use:# [1] Paste this below Material and above Main# [2] Add <eet> in the event's name to enable it to trigger another event.# [3] Set trigger type to [event tigger] on the event with <eet> name tag# [4] Add <eer> in the target event's name to enable it to be trigger-able by another event## Script calls for Conditional Branches:#   Check If triggered by player:#     $game_map.events[@event_id].triggered_by == 0#   Check If triggered by event:#     $game_map.events[@event_id].triggered_by != 0#   Check If triggered by event id N:#     $game_map.events[@event_id].triggered_by == N (where N = event id number)#==============================================================================class Game_Player < Game_Character  def start_map_event(x, y, triggers, normal) #overwrite return if $game_map.interpreter.running?    $game_map.events_xy(x, y).each do |event|      if event.trigger_in?(triggers) && event.normal_priority? == normal        event.triggered_by = 0        event.start      end    end  endendclass Game_Event < Game_Character  attr_reader   :meowname  attr_accessor :triggered_by  alias meow_ee_name initialize  def initialize(map_id, event)    meow_ee_name(map_id, event)    @meowname = event.name    @lock_timer = 0    @triggered_by = 0  end  def meow_lock    @locked = true    @lock_timer = 60  end  def meow_start    return if empty?    @starting = true    meow_lock if trigger_in?([2])  end  def check_event_trigger_touch(x, y) #overwrite    return if $game_map.interpreter.running?    if @trigger == 2 && $game_player.pos?(x, y)      @triggered_by = 0      start if !jumping? && normal_priority?    end    $game_map.events_xy(x, y).each do |event|      if @trigger == 2 && @event.name.include?('<eet>')        if !jumping? && normal_priority? && $game_map.events[event.id].meowname.include?('<eer>')          event.triggered_by = @event.id          event.meow_start          $game_map.events[event.id].turn_toward_character($game_map.events[@event.id]) if !@direction_fix          meow_lock        end      end    end  end  alias meow_ee_update update  def update    meow_ee_update    if @lock_timer > 0      @lock_timer -= 1      @locked = false if @lock_timer <= 0    end  endend
    Update:

    [29-Dec-2015]

    Updated to add a demo game.

    [19-Dec-2015]

    Updated the script so it can now checks who triggered the event.

    Also added a sample map for those who wish to see how the battle field is done.

    [18-Dec-2015]

    Fixed the facing problem with the triggered event <eer> so that it will be facing the triggering event <eet> properly.

    Also added a 1 second cool down timer to prevent the triggering event <eet> to spam the trigger continuously.
     

    Attached Files:

    Last edited by a moderator: Jan 1, 2016
    #1
  2. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    178
    Location:
    La La Land
    First Language:
    Meowish
    Found a small bug(typo?) in the default game engine's random move.


    It doesn't allows turning, causing events to "stop moving" in corners for a long time.


    This somehow effect the triggering event.


    When it can't turn around in corners, there will be problems if it's surrounded by other events,


    because it won't be able turn around to trigger them.


    [​IMG]


    Since it's not related to the E-E Trigger script. I am posting it here as a separate add on.


    Here's the hot fix for random move as a standalone script.



    Note that this snippet is overwriting the default random move to enable turning.


    Instead of doing nothing in a fixed direction, now the event will turn and face the wall/edges/another event when it can't move.

    Code:
    #==============================================================================
    # ■ Meow Face Random Move Fix
    #------------------------------------------------------------------------------
    # Fix the random move so events are able to turn when cornered
    #==============================================================================
    # How to Use:
    # [1] Paste this below Material and above Main
    #==============================================================================
    class Game_Character < Game_CharacterBase
      def move_random #overwrite
        move_straight(2 + rand(4) * 2, true)
      end
    end
     
    Last edited by a moderator: Feb 1, 2016
    #2
    UNphiltered_khaos likes this.
  3. UNphiltered_khaos

    UNphiltered_khaos Game Dev. Artist. Veteran

    Messages:
    1,730
    Likes Received:
    640
    Location:
    Montucky
    First Language:
    Americanese
    Primarily Uses:
    N/A
    This is an awesome script, and it just keeps getting deeper and more amazing! I have been using the first iteration to very good effect, but I might move over to this one. I really like the NPC vs. NPC idea and the soldier that triggers random switches... I can think of a few good puzzles to go along with that. (Probably for another game, though.)
     
    #3
  4. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    178
    Location:
    La La Land
    First Language:
    Meowish
    Thanks! Glad you like it!

    I find the switch idea fun here, made it trigger-able only by the soldier and have the soldier shout at the player if the player tries to touch the buttons. lol!

    Player need to wait for the soldier to open the doors/bridges so it makes the maze solving a little more fun. :D
     
    #4
  5. UNphiltered_khaos

    UNphiltered_khaos Game Dev. Artist. Veteran

    Messages:
    1,730
    Likes Received:
    640
    Location:
    Montucky
    First Language:
    Americanese
    Primarily Uses:
    N/A
    I have been dreaming up a lot of things to do with this. It will certainly make for some more fun gameplay elements in other games I will be working on. 
     
    #5
    MeowFace likes this.
  6. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    178
    Location:
    La La Land
    First Language:
    Meowish
    I was trying it out in a demo and ended up making a small stimulation game with it.

    Turns out it just need the script and the rest is using eventing only.

    This script really fires up the inspirations and makes life easy.. lol!

    I am glad you asked for it and lucky enough to take up the challenge. :p
     
    #6
  7. UNphiltered_khaos

    UNphiltered_khaos Game Dev. Artist. Veteran

    Messages:
    1,730
    Likes Received:
    640
    Location:
    Montucky
    First Language:
    Americanese
    Primarily Uses:
    N/A
    The biggest problem I have with this script right now is, I am already working on multiple games (5), and this just makes me want to start on another one. If I keep starting projects, I will never finish one, even if they are short!

    I can't tell you how excited this script makes me, mostly because I don't really make RPGs. :p ! Thank you again for making it!
     
    Last edited by a moderator: Dec 20, 2015
    #7
  8. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    178
    Location:
    La La Land
    First Language:
    Meowish
    lol, glad you like it! and happy game making with all those new ideas! ;)
     
    #8
  9. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    178
    Location:
    La La Land
    First Language:
    Meowish
    #9
  10. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    178
    Location:
    La La Land
    First Language:
    Meowish
    Scripts in top post is being messed up due to the recent V3 to V4 migration.


    Please use this alternative version instead until the web staff is able to fix the format in the top post:

    Code:
    #==============================================================================
    # ■ Meow Face Event - Event Trigger
    #------------------------------------------------------------------------------
    # Allow Event with name tag to trigger other events with name tag on collision
    #==============================================================================
    # How to Use:
    # [1] Paste this below Material and above Main
    # [2] Add <eet> in the event's name to enable it to trigger another event.
    # [3] Set trigger type to [event tigger] on the event with <eet> name tag
    # [4] Add <eer> in the target event's name to enable it to be trigger-able by another event
    #
    # Script calls for Conditional Branches:
    #   Check If triggered by player:
    #     $game_map.events[@event_id].triggered_by == 0
    #   Check If triggered by event:
    #     $game_map.events[@event_id].triggered_by != 0
    #   Check If triggered by event id N:
    #     $game_map.events[@event_id].triggered_by == N (where N = event id number)
    #==============================================================================
    class Game_Player < Game_Character
      def start_map_event(x, y, triggers, normal) #overwrite
        return if $game_map.interpreter.running?
        $game_map.events_xy(x, y).each do |event|
          if event.trigger_in?(triggers) && event.normal_priority? == normal
            event.triggered_by = 0
            event.start
          end
        end
      end
    end
    class Game_Event < Game_Character
      attr_reader   :meowname
      attr_accessor :triggered_by
      alias meow_ee_name initialize
      def initialize(map_id, event)
        meow_ee_name(map_id, event)
        @meowname = event.name
        @lock_timer = 0
        @triggered_by = 0
      end
      def meow_lock
        @locked = true
        @lock_timer = 60
      end
      def meow_start
        return if empty?
        @starting = true
        meow_lock if trigger_in?([2])
      end
      def check_event_trigger_touch(x, y) #overwrite
        return if $game_map.interpreter.running?
        if @trigger == 2 && $game_player.pos?(x, y)
          @triggered_by = 0
          start if !jumping? && normal_priority?
        end
        $game_map.events_xy(x, y).each do |event|
          if @trigger == 2 && @event.name.include?('<eet>')
            if !jumping? && normal_priority? && $game_map.events[event.id].meowname.include?('<eer>')
              event.triggered_by = @event.id
              event.meow_start
              $game_map.events[event.id].turn_toward_character($game_map.events[@event.id]) if !@direction_fix
              meow_lock
            end
          end
        end
      end
      alias meow_ee_update update
      def update
        meow_ee_update
        if @lock_timer > 0
          @lock_timer -= 1
          @locked = false if @lock_timer <= 0
        end
      end
    end
     
    #10
  11. saviliana

    saviliana Warper Member

    Messages:
    3
    Likes Received:
    0
    First Language:
    chinese
    Um, I would like to know that do we have to define the NPC before it reacts with other NPC/objects?
    Since the Sample game have defined the NPC with script name, but the top post didn't said anything about it.
     
    #11

Share This Page