Blizz ABS custom triggers help

Started by Sin86, August 09, 2012, 12:39:08 pm

Previous topic - Next topic

Sin86

August 09, 2012, 12:39:08 pm Last Edit: August 09, 2012, 12:41:52 pm by Sin86
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.

KK20

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:

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

winkio

And it will be.  Good work, *lvls up* :)

ForeverZer0

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.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

KK20

I'll get onto that. It's just winkio's post is making me second guess myself. :P

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Blizzard

@winkio: Remember to include KK20 in the Special Thanks section of the manual.
Check out our game brands:

Daygames
Game Night Games
Chugnar Games

Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

winkio

@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.

KK20


Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Blizzard

Check out our game brands:

Daygames
Game Night Games
Chugnar Games

Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.