Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: Sin86 on August 09, 2012, 12:39:08 pm

Title: Blizz ABS custom triggers help
Post by: Sin86 on August 09, 2012, 12:39:08 pm
Got a question. Is there a way where you can have an event with 2 Blizz ABS triggers on one event?

In other words, having the first trigger will activate the next page on the same event but another trigger will activate a new event.

I know you can have one event with 2 triggers on it but whenever I do this, both triggers will activate the next upcoming event. I'm trying to have it where one event can have 2 triggers but each trigger will activate 2 seperate events.
Title: Re: Blizz ABS custom triggers help
Post by: KK20 on August 12, 2012, 02:11:08 am
What you want is not possible.

UNTIL NOW LOLOL-*cough*: ShowHide
=begin
===============================================================================
Enemy Event Trigger Condition Checking                                Ver. 1.00
- By KK20                                                             [8/11/12]
===============================================================================

[Information]
  Blizzard ABS allows the creator to make event triggers for map battlers. It
  was possible for players to allow multiple triggers for one event page,
  meaning that the events would run if any ONE of those triggers was satisfied.
  With this script, the creator can now make conditional branches for each
  trigger.
 
 
[Example]
  The event can be triggered via ActionButton and Weapon. If player presses
  ActionButton, the event will say "Hi." If the player attacks with his weapon,
  the event says "Ouch!"
 
-------------------------------------------------------------------------------

[How to Use]
  Create triggers as you would normally (at the top of the event list as a
  comment line--read the BlizzABS manual for details). In a conditional branch,
  use the 'Script' option. Then, type this line:
 
      $game_map.events[@SELF].triggered?(trigger_id, object_id)
     
  >> trigger_id : The ID of the trigger type (i.e. CETPlayerTouch, CETWeapon)
   [[** NOTE **]]
   If you want to learn more of the types of triggers, refer to the manual.
   Also, it is MANDATORY to add this code before the trigger variable:
                                 
                                 BlizzABS::
   
  >> object_id  : The ID of the object (i.e weapon ID, skill ID, item ID)
  [[** NOTE **]]
  This parameter is 'nil' by default. Thus, this parameter can be entirely
  skipped. Only specify a value if necessary.
 
 
[Examples of Usage]
  $game_map.events[@SELF].triggered?(BlizzABS::CETActionButton)
    => If the player pressed the ActionButton to trigger the event
   
  $game_map.events[@SELF].triggered?(BlizzABS::CETWeapon, 5)
    => If the player attacked with the weapon of ID 5
   
  $game_map.events[@SELF].triggered?(BlizzABS::CETSkill)
    => If the player attacked with any skill
   
===============================================================================
Credits
  KK20      : Creating this script edit
  Blizzard  : So that you can use this script in BlizzABS (duh :P)
  Sin86     : For the idea
===============================================================================
=end

class Map_Enemy < Map_Battler
  #----------------------------------------------------------------------------
  # triggered?
  #  trigger_id : The ID of the trigger type (i.e. CETPlayerTouch, CETWeapon)
  #  object_id  : The ID of the object (i.e weapon ID, skill ID, item ID)
  #  Returns if the event was triggered by a certain trigger.
  #----------------------------------------------------------------------------
  def triggered?(trigger_id, object_id = nil)
    return (@event_trigger[0] == trigger_id) if object_id.nil?
    return @event_trigger == [trigger_id, object_id]
  end
  #----------------------------------------------------------------------------
  # Initialization
  # ** Initialize variable 'event_trigger'
  #----------------------------------------------------------------------------
  alias init_map_enemy_after initialize
  def initialize(map_id, event, id = 0, group = 0, attributes = 0x00,
                 move = false, immortal = false, full_passable = false,
                 custom = false, delay = 40, view = 5, hear = 40, nojump = false)
    @event_trigger = [-1, -1]
    init_map_enemy_after(map_id, event, id, group, attributes,
                 move, immortal, full_passable,
                 custom, delay, view, hear, nojump)
  end
               
  #----------------------------------------------------------------------------
  # start
  #  Setups the starting event code.
  #  ** Removed the line -> @trigger = 1 **
  #----------------------------------------------------------------------------
  def start
    # if event code exists
    return if @list.size <= 1
    # set starting and execution flag
    @starting = @execute = true
  end
  #----------------------------------------------------------------------------
  # event_execution?
  #  Tests if the enemy died and is executing an event now.
  #  ** Added @event_trigger = -1 **
  #----------------------------------------------------------------------------
  def event_execution?
    # stop if not executing
    return false if !@execute
    # if about to start or running already
    if @starting || $game_system.map_interpreter.running?
      # reset blending type
      @blend_type = 0 if @starting
      # reset moving route
      @force_move = []
      # executing event
      return true
    end
    # if enemy revived with event command
    if valid? && !battler.dead?
      # reset opacity
      @opacity = 255
      # reset blending type
      @blend_type = 0
      # reset execute flag
      @execute = false
      # recreate data pack for new enemy
      @ai = BlizzABS::AI::Data_Enemy.new(self, @ai.group, @ai.attributes,
          @ai.custom, @ai.delay_time, @ai.view_range, @ai.hearing_range_ratio)
      # reset moving route
      @force_move = []
    # if opacity is 0
    elsif (!valid? || battler.dead?) && @opacity == 0
      # set execute flag and erased flag
      @execute, @erased = false, true
      # refresh
      refresh
    end
    @event_trigger = [-1, -1]
    # not executing event
    return false
  end
  #----------------------------------------------------------------------------
  # attack_effect
  #  character - the character that holds attack data (can be projectile)
  #  _battler  - the attacking battler
  #  Executes attack upon a map character.
  #----------------------------------------------------------------------------
  def attack_effect(character, _battler)
    # call superclass method
    result = super
    # if actor
    if _battler.is_a?(Game_Actor)
      # get weapon ID and custom event trigger type
      id, cet = _battler.weapon_id, BlizzABS::CETWeapon
    # if enemy
    elsif _battler.is_a?(Game_Enemy)
      # get weapon ID and custom event trigger type
      id, cet = _battler.id, BlizzABS::CETEnemy
    end
    # if can be activated by this weapon / enemy
    if result && @custom_triggers.has_key?(cet) &&
        (@custom_triggers[cet].size == 0 ||
        @custom_triggers[cet].include?(id))
      # run this enemy as event
      @event_trigger = [cet, id]
      self.start
    end
    # return result
    return result
  end
  #----------------------------------------------------------------------------
  # skill_effect
  #  character - the character that holds skill use (can be projectile)
  #  _battler  - the skill using battler
  #  skill     - the skill
  #  Executes skill use upon a map character.
  #----------------------------------------------------------------------------
  def skill_effect(character, _battler, skill)
    # call superclass method
    result = super
    # if can be activated by this skill
    if result && @custom_triggers.has_key?(BlizzABS::CETSkill) &&
        (@custom_triggers[BlizzABS::CETSkill].size == 0 ||
        @custom_triggers[BlizzABS::CETSkill].include?(skill.id))
      # run this enemy as event
      @event_trigger = [BlizzABS::CETSkill, id]
      self.start
    end
    # return result
    return result
  end
  #----------------------------------------------------------------------------
  # item_effect
  #  character - the character that holds item use (can be projectile)
  #  item      - the item
  #  Executes item use upon a map character.
  #----------------------------------------------------------------------------
  def item_effect(character, _battler, item)
    # call superclass method
    result = super
    # if can be activated by this item
    if result && @custom_triggers.has_key?(BlizzABS::CETItem) &&
        (@custom_triggers[BlizzABS::CETItem].size == 0 ||
        @custom_triggers[BlizzABS::CETItem].include?(item.id))
      # run this enemy as event
      @event_trigger = [BlizzABS::CETItem, id]
      self.start
    end
    # return result
    return result
  end
  #----------------------------------------------------------------------------
  # check_event_trigger_touch
  #  x - x-coordinate
  #  y - y-coordinate
  #  Checks event touching. Called when event moves into player.
  #----------------------------------------------------------------------------
  def check_event_trigger_touch(x, y)
    # get pixel movement rate
    pix = $BlizzABS.pixel
    # stop if an event is being executed already
    return false if $game_system.map_interpreter.running?
    # if any battler in the way
    if @trigger == BlizzABS::CETEventTouch && !jumping? && !over_trigger? &&
        !$game_player.through && $game_player.character_name != '' &&
        $BlizzABS.util.rect_intersection(Rect.new(x, y, pix, pix),
            Rect.new($game_player.x, $game_player.y, pix, pix))
      # start
      @event_trigger = [BlizzABS::CETEventTouch, id]
      start
      # started
      return true
    end
    # not started
    return false
  end
  #----------------------------------------------------------------------------
  # check_event_trigger_at
  #  x - x-coordinate
  #  y - y-coordinate
  #  Check event if it was triggered at a specific position. (pixel movement)
  #  Called when player presses action button or walks into event.
  #----------------------------------------------------------------------------
  def check_event_trigger_at(x, y)
    # get pixel movement rate
    pix = $BlizzABS.pixel
    # if player touched this event and not jumping and not over_trigger
    if !jumping? && !over_trigger? && $BlizzABS.util.rect_intersection(
        Rect.new(@x, @y, pix, pix), Rect.new(x, y, pix, pix))
      # start
      @event_trigger = Input.trigger?(Input::C) ? [BlizzABS::CETActionButton, -1] : [BlizzABS::CETPlayerTouch, -1]
      start
      # started
      return true
    end
    # not started
    return false
  end
end


At least I don't think this is normally in BABS. If there isn't, I believe there should be. :rite:
Title: Re: Blizz ABS custom triggers help
Post by: winkio on August 12, 2012, 02:14:50 am
And it will be.  Good work, *lvls up* :)
Title: Re: Blizz ABS custom triggers help
Post by: ForeverZer0 on August 12, 2012, 02:22:50 am
KK20, you should fill out a template and add that to the database as a BlizzABS addon. I'm sure others could find use of it as well, and it will end up getting lost if it is only here.
Title: Re: Blizz ABS custom triggers help
Post by: KK20 on August 12, 2012, 02:47:32 am
I'll get onto that. It's just winkio's post is making me second guess myself. :P
Title: Re: Blizz ABS custom triggers help
Post by: Blizzard on August 12, 2012, 04:32:30 am
@winkio: Remember to include KK20 in the Special Thanks section of the manual.
Title: Re: Blizz ABS custom triggers help
Post by: winkio on August 15, 2012, 06:55:21 pm
@KK20: publish it as an add-on for now, since it isn't going into version 2.85.  This is one of the features going into v3.0 though.
Title: Re: Blizz ABS custom triggers help
Post by: KK20 on August 15, 2012, 07:19:08 pm
Way ahead of ya (http://forum.chaos-project.com/index.php/topic,12230.0.html)

And thanks  ;)
Title: Re: Blizz ABS custom triggers help
Post by: Blizzard on August 16, 2012, 03:56:03 am
KK20, keeping scripting alive. <3