iPhone App Directory
RPG Maker VX
 
Gallery Members Search Calendar Help


Welcome Guest ( Log In | Register )

Collapse

>Announcement

Keep an eye out for the upcoming 3rd Quarter Contest!
2 Pages V   1 2 >  
Reply to this topicStart new topic
> Dart Throwing Script, Long Range Event Activation through Dart Throwing
Pyrofiend
post Jul 14 2013, 10:28 PM
Post #1



Group Icon


Type: Artist




Dart Throw v2.0
By Pyrofiend/Liquid_Pencil


Introduction
This script creates a dart system, where you throw a 'dart' event, and when that dart hits an 'active' event, it either turns on a self-switch, runs the event, changes a switch, or changes a variable. You can use this to knock out guards, create puzzles, assassinate enemies from afar, and other such wonders!

Features

v2.0
. Multiple dart types: Fully customizable dart options with multiple input capability!
. Specialized dart activations: Each active event can be activated differently by each dart type!
. Individual switch activation per dart type!
. More active event options!
- Self-switch activation
- Switch activation
- Variable change
- Event page run
. Multiple event activations: Now you can have a fire dart run the event page and an arrow dart turn on a self switch!
. Various bug fixes and simplifying

v1.2
. Dart maps are now determined simply if they have the dart event!
. Switch activation: Throw darts if a switch is active, but not when you don't!
. Consumable dart item option: Set whether you want the dart item to be consumed or not!

v1.0
. Simple button press to throw a dart straight forward
. Dart keeps flying forward until it hits a wall or an event
. Item assignment option - if you don't have the item, then you can't throw darts!
. 'Active' events - Events that run its event page or change its self switches when hit by dart
. 'Wall' events - Events that function just like walls, but can move!
. 'Pass' areas - Areas that the dart can travel through, but not the player!

Versions

v2.0
. Added multiple dart types.
. Added multiple activation parameters
. Simplified dart customization into a hash
. Moved dart / active / wall tags to Event Comment.

v1.2
. Removed DART_MAPS.
. Added DART_SWITCH
. Added ITEM_CONSUME option.
. Fixed bug where active events near walls and events directly next to the player weren't activated when the dart was thrown.

v1.1
. NO_DART_MAPS array turned into DART_MAPS array; now any map that uses darts needs to be in the DART_MAPS array.

v1.0
. Initial script

Screenshots

Spoiler:


The dart is thrown, and it flies towards the switch...



The dart flips the switch, and the gate is opened!


How to Use
Put the script below the "Materials" section

Spoiler:
CODE
#===============================================================================
# ** Dart Launcher / Long-Range Event Activater
#-------------------------------------------------------------------------------
# By Pyrofied / Liquid_Pencil
# v2.0
#-------------------------------------------------------------------------------
#   This script allows you to create a 'dart' event. When thrown, it will
#   continue to fly away from the player until it either hits a wall or an
#   event. If it hits an 'active' event, it will either run the event or turn
#   on a self-switch. If it hits a 'wall' event, then the dart will act as if
#   it hit a wall.
#
#---------------------------------INSTRUCTIONS---------------------------------
#
#   --------Dart events--------
#
#   A dart event is, simply put, the dart you throw. When it hits an active
#   event, it does what you specify it to do, and when it hits a wall, it
#   disappears.
#
#   To set up a 'dart' event, simply put this in an event comment:
#
#     <type>
#
#   type: Type of dart. Set in the DART_HASH.
#
#   Create a second page with the condition 'Self Switch A is ON.' Make sure
#   that the 'Through' flag is activated. Create a custom move route with only
#   'Move Away from Player,' as a condition, and have the 'Repeat Action' flag
#   on. Set the event graphic for the 'A' page to whatever you please.
#
#   --------Active events--------
#
#   'Active' events are what the dart will activate when it hits. When hit, it
#   will either run said event or activate its self-switch.
#
#   To set up an 'active' event, add this in an event comment:
#
#
#     <active_name, type, method, id, amount, op>
#
#
#   active_name: The name that sets up an 'active' event. It is whatever you
#     whatever you set ACTIVE_EVENT_NAME to be.
#
#   type: The type of dart that activates the event. The name of the dart type
#     can be found in the DART_HASH.
#
#   method: Either 'run', 'SS', 'switch', or 'var' without quotation marks
#     to run the event, turn on a self-switch, turn on a regular switch, or
#     change a variable.
#
#   id / amount / op: Dependent on the method.
#    
#     - If method is run:
#         Leave id, amount, and op blank.
#
#     - If method is SS:
#         id: The self-switch that will be activated. Either A, B, C, or D.
#         Leave amount and op blank.
#
#     - If method is switch:
#         id: The ID of the switch that will be activated.
#         Leave amount and op blank.
#
#     - If method is var:
#         id: The ID of the variable that will be changed.
#         amount: The amount that will be changed in the variable.
#         op: The operation that will be performed. Either 'add' or 'sub'
#           without quotation marks.
#
#   EXAMPLE NAMES:
#
#     Comment: <active, dart, run>
#         - When triggered by the 'dart' dart, the event will run.
#
#     Comment: <active, fire, SS, A>
#         - When triggered by the 'fire' dart, the event's A self-switch will
#             be turned on.
#
#     Comment: <active, dart, switch, 3>
#         - When triggered by the 'dart' dart, the switch with ID 3 will be
#             turned on.
#
#     Comment: <active, arrow, var, 3, 1, add>
#         - When triggered by the 'arrow' dart, the variable with ID 3 will
#             have 1 added to it.
#
#     Comment: <active, arrow, var, 3, 1, sub>
#         - When triggered by the 'arrow' dart, the variable with ID 3 will
#             have 1 subtracted to it.
#
#     Comment: <active, dart, run>
#     Comment: <active, fire, SS, A>
#         - This event can be triggered by either a 'dart' dart or a 'fire'
#             dart. If triggered by the 'dart' event, the event page that is
#             active will run. If triggered by the 'fire' dart, the event's
#             A self-switch will be turned on.
#
#   --------
#
#   Note that the 'run' method is dependent on the current active event page.
#   If you activate a self-switch and have an event page with higher priority
#   that has that self-switch as a condition, it will run that page.
#
#
#   --------Wall events--------
#
#   Wall events behave just like a wall. When the dart runs into it, it will
#   disappear.
#
#   To set up a wall event, simply put this tag in an event comment box:
#
#     <wall>
#
#
#   --------Pass Areas--------
#
#   Pass areas are areas created over tiles that the player can't walk through,
#   but the dart can pass over. You will need to use pass areas over things like
#   pits so the player can't pass over it, but the dart can.
#
#   To set up a pass area, create the area in the event map, and put 'pass' in
#   its area name.
#
#===============================================================================


Demo

v2.0
Demo v2.0

v1.0
Demo v1.0 (outdated)

Script

Spoiler:
CODE
#===============================================================================
# ** Dart Launcher / Long-Range Event Activater
#-------------------------------------------------------------------------------
# By Pyrofied / Liquid_Pencil
# v2.0
#-------------------------------------------------------------------------------
#   This script allows you to create a 'dart' event. When thrown, it will
#   continue to fly away from the player until it either hits a wall or an
#   event. If it hits an 'active' event, it will either run the event or turn
#   on a self-switch. If it hits a 'wall' event, then the dart will act as if
#   it hit a wall.
#
#---------------------------------INSTRUCTIONS---------------------------------
#
#   --------Dart events--------
#
#   A dart event is, simply put, the dart you throw. When it hits an active
#   event, it does what you specify it to do, and when it hits a wall, it
#   disappears.
#
#   To set up a 'dart' event, simply put this in an event comment:
#
#     <type>
#
#   type: Type of dart. Set in the DART_HASH.
#
#   Create a second page with the condition 'Self Switch A is ON.' Make sure
#   that the 'Through' flag is activated. Create a custom move route with only
#   'Move Away from Player,' as a condition, and have the 'Repeat Action' flag
#   on. Set the event graphic for the 'A' page to whatever you please.
#
#   --------Active events--------
#
#   'Active' events are what the dart will activate when it hits. When hit, it
#   will either run said event or activate its self-switch.
#
#   To set up an 'active' event, add this in an event comment:
#
#
#     <active_name, type, method, id, amount, op>
#
#
#   active_name: The name that sets up an 'active' event. It is whatever you
#     whatever you set ACTIVE_EVENT_NAME to be.
#
#   type: The type of dart that activates the event. The name of the dart type
#     can be found in the DART_HASH.
#
#   method: Either 'run', 'SS', 'switch', or 'var' without quotation marks
#     to run the event, turn on a self-switch, turn on a regular switch, or
#     change a variable.
#
#   id / amount / op: Dependent on the method.
#    
#     - If method is run:
#         Leave id, amount, and op blank.
#
#     - If method is SS:
#         id: The self-switch that will be activated. Either A, B, C, or D.
#         Leave amount and op blank.
#
#     - If method is switch:
#         id: The ID of the switch that will be activated.
#         Leave amount and op blank.
#
#     - If method is var:
#         id: The ID of the variable that will be changed.
#         amount: The amount that will be changed in the variable.
#         op: The operation that will be performed. Either 'add' or 'sub'
#           without quotation marks.
#
#   EXAMPLE NAMES:
#
#     Comment: <active, dart, run>
#         - When triggered by the 'dart' dart, the event will run.
#
#     Comment: <active, fire, SS, A>
#         - When triggered by the 'fire' dart, the event's A self-switch will
#             be turned on.
#
#     Comment: <active, dart, switch, 3>
#         - When triggered by the 'dart' dart, the switch with ID 3 will be
#             turned on.
#
#     Comment: <active, arrow, var, 3, 1, add>
#         - When triggered by the 'arrow' dart, the variable with ID 3 will
#             have 1 added to it.
#
#     Comment: <active, arrow, var, 3, 1, sub>
#         - When triggered by the 'arrow' dart, the variable with ID 3 will
#             have 1 subtracted to it.
#
#     Comment: <active, dart, run>
#     Comment: <active, fire, SS, A>
#         - This event can be triggered by either a 'dart' dart or a 'fire'
#             dart. If triggered by the 'dart' event, the event page that is
#             active will run. If triggered by the 'fire' dart, the event's
#             A self-switch will be turned on.
#
#   --------
#
#   Note that the 'run' method is dependent on the current active event page.
#   If you activate a self-switch and have an event page with higher priority
#   that has that self-switch as a condition, it will run that page.
#
#
#   --------Wall events--------
#
#   Wall events behave just like a wall. When the dart runs into it, it will
#   disappear.
#
#   To set up a wall event, simply put this tag in an event comment box:
#
#     <wall>
#
#
#   --------Pass Areas--------
#
#   Pass areas are areas created over tiles that the player can't walk through,
#   but the dart can pass over. You will need to use pass areas over things like
#   pits so the player can't pass over it, but the dart can.
#
#   To set up a pass area, create the area in the event map, and put 'pass' in
#   its area name.
#
#===============================================================================

#-------------------------------------------------------------------------------

#   vv--------------Edit below this point--------------vv

module LP_Dart # DO NOT EDIT THIS NAME
  
  #   DART_HASH: Hash of all dart types.
  #
  #     name  => [[speed, button, switch], [use_item, item_id, consume_item]]
  #
  #   name: Name that needs to be present in the event name box.
  #
  #   speed: Speed of dart type.
  #     1 = 8x Slower
  #     2 = 4x Slower
  #     3 = 2x Slower
  #     4 = Normal
  #     5 = 2x Faster
  #     6 = 4x Faster
  #
  #   button: Sets the button that triggers the dart throw.
  #
  #   use_item: Whether the dart is tied to an item or not. (true / false)
  #
  #   item_id: ID of item to be used. Invalid if use_item is set to false.
  #
  #   consume_item: Whether the item will be consumed after. Invalid if use_item
  #     is set to false.
  #
  #  ----
  #
  #   Note that multiple dart types can be set to the same input, but they need
  #   to be active under different conditions otherwise an error will occur.
  DART_HASH = {
  
    'dart'     => [[7, Input::Y, 3], [true, 21, true]],
    'puppy'    => [[7, Input::Y, 4], [false, 0, false]],
    'fire'     => [[5, Input::Z, 5], [false, 0, false]]
    
  }
  
  #   ACTIVE_EVENT_NAME: Name put in the active event comment.
  ACTIVE_EVENT_NAME = 'active'
  
  #   ^^--------------Edit above this point--------------^^
  
#---------NO EDITS BEYOND THIS POINT UNLESS YOU KNOW WHAT YOU ARE DOING---------
  
  ACTIVE_TAG = /<(?:\w*),[ ]?(\w*),[ ]?(\w*),?[ ]?(\w*),?[ ]?(\d*),?[ ]?(\w*)>/i
  
end

#-------------------------------------------------------------------------------

#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass of the
# Game_Player and Game_Event classes.
#==============================================================================

class Game_Character
  
  #-----------------------------------------------------------------------------
  attr_accessor :move_speed     # Movement speed of dart
  attr_accessor :move_frequency # Movement frequency
  #-----------------------------------------------------------------------------
  
end


#-------------------------------------------------------------------------------

#===============================================================================
# ** Game_Event
#-------------------------------------------------------------------------------
#  This class deals with events. It handles functions including event page
#  switching via condition determinants, and running parallel process events.
#  It's used within the Game_Map class.
#===============================================================================

class Game_Event < Game_Character

  #-----------------------------------------------------------------------------
  attr_reader   :dart            # Dart tag
  attr_reader   :dart_activate   # What will event do when activated?
  attr_reader   :active          # 'Active' event tag
  attr_reader   :map_id          # Map ID of event
  attr_reader   :wall            # Type of dart / active event
  attr_reader   :active_switch   # Self Switch to be activated
  attr_accessor :thrown          # Is event thrown?
  #-----------------------------------------------------------------------------

  #=============================================================================
  # * alias initialize: name/dart now readable
  #=============================================================================
  
  alias dart_check_initialize initialize
  def initialize(map_id, event)
    dart_check_initialize(map_id, event)
    @thrown = false
    @dart_activate = []
    @dart = []
    dart_check(@event)
  end
  
  #=============================================================================
  # * new method: in_area?
  #=============================================================================
  
  def in_pass?(area)
    return false if area == nil
    return false if @map_id != area.map_id
    return false if @x < area.rect.x
    return false if @y < area.rect.y
    return false if @x >= area.rect.x + area.rect.width
    return false if @y >= area.rect.y + area.rect.height
    return true
  end
  
  #=============================================================================
  # * new method: set_dart_direction
  #=============================================================================
  
  def set_dart_direction
    @direction = $game_player.direction
  end
  
  #=============================================================================
  # * new method: set_event_start
  #=============================================================================
  
  def get_event_start
    x = @event.x
    y = @event.y
    return x, y
  end
  
  #=============================================================================
  # * new method: dart_check
  #=============================================================================
  
  def dart_check(event)
    for page in event.pages
      for i in 0...page.list.size
        if page.list[i].code == 108
          name = page.list[i].parameters.to_s
          for type in LP_Dart::DART_HASH.keys
            /<(\w*)>/i =~ name
            if $1.to_s == type
              @dart.push(true, type)
            end
          end
          if name.include?('<wall>')
            @wall = true
          elsif name.include?(LP_Dart::ACTIVE_EVENT_NAME)
            LP_Dart::ACTIVE_TAG =~ name
            type = $1.to_s
            method = $2.to_s
            value = $3.to_s
            amount = $4.to_i
            oper = $5.to_s
            @active = true
            if method == 'run'
              @dart_activate.push(['run', type])
            elsif method == 'SS'
              @dart_activate.push(['SS', value.upcase, type])
            elsif method == 'switch'
              @dart_activate.push(['switch', value.to_i, type])
            elsif method == 'var'
              @dart_activate.push(['var', value.to_i, amount, oper, type])
            end
          end
        end
      end
    end
  end
  
  #=============================================================================
  # * new method: type_check
  #=============================================================================
  
  def type_check(dart_event, active)
    if active[0] == 'run'
      dart = active[1]
    elsif active[0] == 'SS' || active[0] == 'switch'
      dart = active[2]
    elsif active[0] == 'var'
      dart = active[4]
    end
    type = dart_event.dart[1]
    return true if type == dart
    return false
  end
  
end

#-------------------------------------------------------------------------------

#===============================================================================
# ** Game_Map
#-------------------------------------------------------------------------------
#  This class handles maps. It includes scrolling and passage determination
#  functions. The instance of this class is referenced by $game_map.
#===============================================================================

class Game_Map
  
  #-----------------------------------------------------------------------------
  attr_reader   :map_id         # Map ID
  attr_reader   :map            # Map Object
  attr_reader   :pass_areas     # Array of passable areas
  #-----------------------------------------------------------------------------
  
  #=============================================================================
  # * alias initialize: Adds dart_thrown boolean
  #=============================================================================
  
  alias dart_check_initialize initialize
  def initialize
    dart_check_initialize
    @pass_areas = []
    $dart_events = {} if $dart_events.nil?
    get_pass_areas
  end
  
  #=============================================================================
  # * alias setup: Adds darts to dart events hash
  #=============================================================================
  
  alias dart_check_setup setup
  def setup(map_id)
    dart_check_setup(map_id)
    get_dart_map
  end

  #=============================================================================
  # * new method: get_dart_maps
  #=============================================================================
  
  def get_dart_map
    for event in $game_map.events.values
      if event.dart[0]
        $dart_events[[@map_id, event.dart[1]]] = event
      end
    end
  end
  
  #=============================================================================
  # * new method: get_pass_areas
  #=============================================================================
  
  def get_pass_areas
    for area in $data_areas.values
      if area.name.include?('pass')
        @pass_areas.push(area)
      end
    end
  end
  
  #=============================================================================
  # * alias update: Updates dart if dart is thrown
  #=============================================================================
  
  alias dart_check_update update
  def update
    dart_check_update
    darts = get_dart_hash
    unless darts.empty?
      for dart in darts
        if dart.thrown == true
          x = dart.x
          y = dart.y
          update_dart(dart, x, y)
        end
      end
    end
  end
  
  #=============================================================================
  # * new method: get_dart_hash
  #=============================================================================
  
  def get_dart_hash
    value = []
    for type in LP_Dart::DART_HASH.keys
      event = $dart_events[[@map_id, type]]
      event.nil? ? next : value.push(event)
    end
    return value
  end
  
  #=============================================================================
  # * new method: update_dart
  #=============================================================================
  
  def update_dart(dart, x, y)
    if passable?(x, y)
      if on_map_edge?(x, y)
        event_check(dart, x, y)
        update_dart_edge(dart, x, y)
      else
        event_check(dart, x, y)
      end
    else
      area_check(dart, x, y)
    end
  end
  
  #=============================================================================
  # * new method: update_dart_edge
  #=============================================================================
  
  def update_dart_edge(dart, x, y)
    if dart.direction == 2
      if !passable?(x, y+1)
        stop_dart(dart)
      end
    elsif dart.direction == 4
      if !passable?(x-1, y)
        stop_dart(dart)
      end
    elsif dart.direction == 6
      if !passable?(x+1, y)
        stop_dart(dart)
      end
    else
      if !passable?(x, y-1)
        stop_dart(dart)
      end
    end
  end
  
  #=============================================================================
  # * new method: on_map_edge
  #=============================================================================
  
  def on_map_edge?(x, y)
    max_x = $game_map.map.width - 1
    max_y = $game_map.map.height - 1
    return true if x == 0
    return true if y == 0
    return true if x == max_x
    return true if y == max_y
    return false
  end
  
  #=============================================================================
  # * new method: event_check
  #=============================================================================
  
  def event_check(dart, x, y)
    dart_check = events_xy(x, y)
    if dart_check.size > 1
      dart_check.delete(dart)
      ko_event = dart_check.shift
      if ko_event.active
        for activate in ko_event.dart_activate
          if ko_event.type_check(dart, activate)
            perform_active(ko_event, dart, activate)
            stop_dart(dart)
            refresh
          end
        end
      elsif ko_event.wall
        stop_dart(dart)
      end
    end
  end
  
  #=============================================================================
  # * new method: perform_active
  #=============================================================================
  
  def perform_active(ko_event, dart, activate)
    if activate[0] == 'SS'
      switch = activate[1]
      key = [@map_id, ko_event.id, switch]
      $game_self_switches[key] = true
      ko_event.refresh
    elsif activate[0] == 'run'
      ko_event.start
    elsif activate[0] == 'switch'
      switch = activate[1]
      $game_switches[switch] = true
    elsif activate[0] == 'var'
      var = activate[1]
      amount = activate[2]
      operation = activate[3]
      if operation == 'add'
        $game_variables[var] += amount
      elsif operation == 'sub'
        $game_variables[var] -= amount
      end
    else
      p 'No method set; either you forgot the method or this event has been interpreted as an active event.'
    end
  end
  #=============================================================================
  # * new method: area_check
  #=============================================================================
  
  def area_check(dart, x, y)
    can_pass = false
    for area in @pass_areas
      if dart.in_pass?(area)
        if can_pass == false
          can_pass = true
        end
      end
    end
    if can_pass
      event_check(dart, x, y)
    else
      event_check(dart, x, y)
      stop_dart(dart)
    end
  end
  
  #=============================================================================
  # * new method: stop_dart
  #=============================================================================
  
  def stop_dart(dart)
    dart.thrown = false
    switch = 'A'
    key = [@map_id, dart.id, switch]
    $game_self_switches[key] = false
    dart.refresh
    x, y = dart.get_event_start
    dart.moveto(x, y)
  end
  
end

#-------------------------------------------------------------------------------

#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
#  An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================

class Game_Interpreter
  
  #=============================================================================
  # * new method: start_dart_throw
  #=============================================================================
  
  def start_dart_throw(dart, x, y)
    direc = $game_player.direction
    if direc == 2
      y += 1
    elsif direc == 4
      x -= 1
    elsif direc == 6
      x += 1
    else
      y -= 1
    end
    dart.moveto(x,y)
    dart.thrown = true
    map = $game_map.map_id
    switch = 'A'
    key = [map, dart.id, switch]
    $game_self_switches[key] = true
    $game_map.update_dart(dart, x, y)
  end
end

#-------------------------------------------------------------------------------

#===============================================================================
# ** Scene_Map
#-------------------------------------------------------------------------------
#  This class performs the map screen processing.
#===============================================================================

class Scene_Map < Scene_Base
  
  #=============================================================================
  # * alias update: checks Input
  #=============================================================================
  
  alias dart_throw_update :update
  def update
    dart_throw_update
    update_dart_trigger
  end
  
  #=============================================================================
  # * new method: update_dart_trigger
  #=============================================================================
  
  def update_dart_trigger
    for type in LP_Dart::DART_HASH.keys
      button = LP_Dart::DART_HASH[type][0][1]
      if not $game_message.visible and Input.trigger?(button)
        map = $game_map.map_id
        x = $game_player.x
        y = $game_player.y
        if !$dart_events[[map, type]].nil?
          dart = $dart_events[[map, type]]
          if dart.dart
            switch = LP_Dart::DART_HASH[type][0][2]
            if $game_switches[switch] || switch == 0
              if dart.thrown
                Sound.play_buzzer
              else
                if LP_Dart::DART_HASH[type][1][0]
                  item_id = LP_Dart::DART_HASH[type][1][1]
                  item = $data_items[item_id]
                  if $game_party.has_item?(item)
                    if LP_Dart::DART_HASH[type][1][2]
                      $game_party.lose_item(item, 1)
                    end
                    dart_prepare(type, dart, x, y)
                  else
                    Sound.play_buzzer
                  end
                else
                  dart_prepare(type, dart, x, y)
                end
              end
            else
              @sound = true
            end
          end
        else
          @sound = true
        end
      end
    end
    if @sound
      Sound.play_buzzer unless @dart_work
      @sound = false
      @dart_work = false
    end
  end

  #=============================================================================
  # * new method: update_dart_trigger
  #=============================================================================
  
  def dart_prepare(type, dart, x, y)
    dart.set_dart_direction
    $game_map.interpreter.start_dart_throw(dart, x, y)
    dart.refresh
    dart.move_speed = LP_Dart::DART_HASH[type][0][0]
    dart.move_frequency = 5
    @sound = false
    @dart_work = true
  end
  
end

#-------------------------------------------------------------------------------

#==============================================================================
# ** Scene_File
#------------------------------------------------------------------------------
#  This class performs the save and load screen processing.
#==============================================================================

class Scene_File < Scene_Base
  
  #--------------------------------------------------------------------------
  # alias write_save_file: Adds $dart_events hash
  #--------------------------------------------------------------------------
  
  alias dart_write_save_data write_save_data
  def write_save_data(file)
    dart_write_save_data(file)
    Marshal.dump($dart_events, file)
  end
  
  #--------------------------------------------------------------------------
  # alias read_save_data: Reads $dart_events hash
  #--------------------------------------------------------------------------
  
  alias dart_read_save_data read_save_data
  def read_save_data(file)
    dart_read_save_data(file)
    $dart_events = Marshal.load(file)
  end
  
end


FAQ
None yet; will update as questions come along

Known Isuses

Credits and Thanks
- Pyrofiend/Liquid_Pencil
- ???nOBodY??? - for helping me twice with a few things in the code

Author's Notes

- This will only be used for free projects - if you plan on making your project commercial, talk to me first.
- This was originally meant to be just for my game. I will only update this script if I personally feel there needs to be more features added, or if there are some good suggestions given to me.
- Don't be afraid to suggest new features! If they're simple enough, I may be able to add it in just for you!

This post has been edited by Pyrofiend: Aug 3 2013, 05:14 PM


--------------------
I support:

Spoiler:
Go to the top of the page
 
+Quote Post
   
esperhunter
post Jul 15 2013, 01:16 AM
Post #2


*Officially dead* :(
Group Icon


Type: Artist
Alignment: Chaotic Neutral




This is really neat! I can't wait to try it out, thanks for sharing.


--------------------


One of my current projects with an award-winning demo. Click to play!


Things I support
Spoiler:








Other stuff...
Spoiler:

If you are a believer of Jesus Christ and are 100% proud of it, put this in your sig.
If you are a pokemon fan...
Spoiler:




Go to the top of the page
 
+Quote Post
   
rgangsta
post Jul 20 2013, 04:43 PM
Post #3


The Handyman
Group Icon


Type: Designer
Alignment: Neutral Evil




It's like you knew I needed this. biggrin.gif


--------------------
Go to the top of the page
 
+Quote Post
   
Nong97
post Jul 21 2013, 01:15 AM
Post #4



Group Icon


Type: Spriter




This is so cool! (HAHA, Poor Ralph)
Very neat system!


--------------------
My Project:

--VXNet Forum--
--Wordpress--
------------------------------------------------------------------------------------------------------------------------------------------------------
I Support:
------------------------------------------------------------------------------------------------------------------------------------------------------


------------------------------------------------------------------------------------------------------------------------------------------------------
Go to the top of the page
 
+Quote Post
   
IXFURU
post Jul 21 2013, 03:36 AM
Post #5


just a nut trying to keep away the squirrels
Group Icon


Type: Undisclosed
Alignment: Lawful Evil




That was pretty awesome, Pyrofiend!

I like the ability to 'run' the event as normal. I saw a script sort of like this a while back which only dealt with self-switches and didn't have this feature. This makes it so that anything you can do with an event you can do with a dart. How bout a dart that opens up a shop? Or a dart which adds a party member? That really leaves a great deal of room for the creator and user of the script. Nice Job!

I have a suggestion. Why not make it so that there can be multiple DART_ITEMS? Maybe use an array instead of a single variable. That way there could be multiple variations of the dart, with varying speeds and such.

Just an idea. I did like the script and the demo. It took me like six darts to get past the floating red orbs.


--------------------




To Support:


Spoiler:
CODE
[url="http://www.rpgmakervx.net/index.php?showtopic=57406"][img]http://i16.photobucket.com/albums/b38/Dwiguitar/TheFinishLineUserBar_zps63f6f475.png[/img][/url]


I support:


Spoiler:







I actually won something...Can you believe that?!

Spoiler:



Go to the top of the page
 
+Quote Post
   
Neosky
post Jul 21 2013, 04:57 AM
Post #6


Master of the DarkSyde of Cheese!
Group Icon


Type: Undisclosed
Alignment: Lawful Evil




Now I can have rock throwing and dart shooting! Awesome work, thanks!

+rep!


--------------------


Remember, Remember the 5th of November...
Spoiler:



If you are new, please go through this spoiler for VERY useful links.
Spoiler:





Tarris Thread || User Forum || Tarris Hold Website || Twitch.tv
Go to the top of the page
 
+Quote Post
   
Pyrofiend
post Jul 21 2013, 04:09 PM
Post #7



Group Icon


Type: Artist




Quick script change
NO_DART_MAPS turned into DART_MAPS: Now any map where you can throw darts into it need to be in the DART_MAPS array. You can get the new script at the original post.

Thank you everyone for trying out the script! It means a lot to me that I managed to make something people are actually using.

@esperhunter

I was considering putting in multiple item IDs before I posted this, but unfortunately as of now I don't know how I'd go about implementing it. I might put it in if more people would like that.

This post has been edited by Pyrofiend: Jul 21 2013, 04:09 PM


--------------------
I support:

Spoiler:
Go to the top of the page
 
+Quote Post
   
flipsomel
post Jul 21 2013, 09:01 PM
Post #8


L. Khaos
Group Icon


Type: Undisclosed





Great job Pyro!

The demo was fun, nice twist in the plot at the end xD


--------------------
Go to the top of the page
 
+Quote Post
   
Neosky
post Jul 24 2013, 06:32 PM
Post #9


Master of the DarkSyde of Cheese!
Group Icon


Type: Undisclosed
Alignment: Lawful Evil




Ok I simply adore this script. BUT

I was wondering if I could clear some things up, or maybe make some suggestions??

Ok first, so I noticed if an event is right next to you it won't trigger.

I know it's for long range use, but I was thinking of using it for trigger events, like freezing things or something.

Second, I noticed it stops one block from the "wall" like tiles.

So say you have a [b] is black
[f] is floor.
[u] is you

[b][f][f][f][u] So if I shoot it left, it will go through 2 [f] but on the [f] just before the [b] it stops. So if I have an event that was on that last [f] I wouldn't be able to trigger it.


Not sure if this anything you can fix, but thought I would bring it up. This script is a lot of help, but there are some minor things that erk me at the moment. wink.gif thanks again though! Still using it, but was kinda hoping for an updated maybe ? XD


--------------------


Remember, Remember the 5th of November...
Spoiler:



If you are new, please go through this spoiler for VERY useful links.
Spoiler:





Tarris Thread || User Forum || Tarris Hold Website || Twitch.tv
Go to the top of the page
 
+Quote Post
   
Pyrofiend
post Jul 26 2013, 12:07 AM
Post #10



Group Icon


Type: Artist




@neosky

For your first problem, the way the script works is that it technically checks the block in front of the dart after it's transported in front of your player, meaning it skips active events if they're right next to the player. That can be fixed, though.

EDIT: Okay, here's how to fix it.

After line 423:

CODE
    $game_self_switches[key] = true


put:
CODE
    $game_map.update_dart(x, y)


That'll fix your problem right up.

I'm a bit confused on your second problem. The way the dart works is that right after you throw it, this is what it should look like:

[b][f][f][d][u]

with [d] being the dart. Based on that, it SHOULD only go two spaces before hitting the wall.

Maybe what you're seeing is just a visual problem. I've noticed that the dart disappears directly in front of the event instead of going THROUGH the event. It's just how the update method works. Try placing an active event in the last [f] block and see what happens.

This post has been edited by Pyrofiend: Jul 26 2013, 12:39 AM


--------------------
I support:

Spoiler:
Go to the top of the page
 
+Quote Post
   
Neosky
post Jul 26 2013, 02:40 AM
Post #11


Master of the DarkSyde of Cheese!
Group Icon


Type: Undisclosed
Alignment: Lawful Evil




Ok see the red boxes?

it stops before hitting those areas.

instead of at the end of it, going into the black. Cause it's blocked at the black.... not the floor??

Does that help?


and thanks, for the fix, I'll try it out!
Attached File(s)
Attached File  red.png ( 17.35K ) Number of downloads: 5
 


--------------------


Remember, Remember the 5th of November...
Spoiler:



If you are new, please go through this spoiler for VERY useful links.
Spoiler:





Tarris Thread || User Forum || Tarris Hold Website || Twitch.tv
Go to the top of the page
 
+Quote Post
   
Pyrofiend
post Jul 26 2013, 02:49 AM
Post #12



Group Icon


Type: Artist




@neosky

I'll take a look at it when I can. Something just came up that's gonna be taking a lot of my time.


--------------------
I support:

Spoiler:
Go to the top of the page
 
+Quote Post
   
Neosky
post Jul 26 2013, 03:47 AM
Post #13


Master of the DarkSyde of Cheese!
Group Icon


Type: Undisclosed
Alignment: Lawful Evil




Take your time, it's not a big deal, it's just one of those things. I have an OCD, and details like that get to me, XD. so don't worry about it.


--------------------


Remember, Remember the 5th of November...
Spoiler:



If you are new, please go through this spoiler for VERY useful links.
Spoiler:





Tarris Thread || User Forum || Tarris Hold Website || Twitch.tv
Go to the top of the page
 
+Quote Post
   
Neosky
post Jul 30 2013, 08:54 PM
Post #14


Master of the DarkSyde of Cheese!
Group Icon


Type: Undisclosed
Alignment: Lawful Evil




Just curious is there a way I can make it where you can't shoot it without having something equipped?

I've tried if character has equipped then
turn on self switch
else
turn off

but it still works. I guess it turns on the A switch by itself in the script.

Then I thought about that, so I made it false so it didn't turn it on by itself and that worked....... but had odd effects, XD.

like the event would stay on screen until I shot it again, and would just keep going and so on, just weird things... so I'm looking further into this.

Just wondering if you knew something.



*edit*

I might have a secondary idea.
If you can't do that, is there a way that i could turn it on with a switch?
Say I turn the use item to false... with that I could just use it, anywhere there is an allowance and the event is present.
Well I was thinking that maybe you can make it where if item is false use a switch to turn it on.

So later in the game, someone gives you a key item, and now you can use the ability. So in doing that the event would give you an item, but turn on a switch as well, allow dart.

and now you can use it, without using up the item, and not being able to use it before hand.


As talking / writing this, I think I can just edit out the using part of the script, where it still needs an item, but doesn't consume it. I'm going to go try that....

XD

*update*

CODE
$game_party.lose_item(item, 1)


I got rid of this, and now I need the item, but it doesn't consume. So that works perfect.


--------------------


Remember, Remember the 5th of November...
Spoiler:



If you are new, please go through this spoiler for VERY useful links.
Spoiler:





Tarris Thread || User Forum || Tarris Hold Website || Twitch.tv
Go to the top of the page
 
+Quote Post
   
Pyrofiend
post Jul 31 2013, 04:36 AM
Post #15



Group Icon


Type: Artist




@neosky

It certainly seems like you got it to work on your own time! XD

I might just semi-steal the idea of a non consumable dart option and switch to activate the dart throwing...it's honestly really easy to put in XD


--------------------
I support:

Spoiler:
Go to the top of the page
 
+Quote Post
   
Neosky
post Jul 31 2013, 05:29 AM
Post #16


Master of the DarkSyde of Cheese!
Group Icon


Type: Undisclosed
Alignment: Lawful Evil




Yeah.

Well I'm thinking of using it to freeze on screen enemies... like in Valkyrie profile.

Also using it to turn on switches and puzzles.

But I didn't want to allow the player to do all of this at the beginning until they unlocked the ability.

So then they have to go back to places the already visited and can unlock secrets now.

So a switch or something would be nice to allow a turn on / off event.

I still kinda of need that part. I know a bit about how to do it, but not being a person that can code from scratch, I don't want to take the chance in screwing it up, XD.

Also, if you're still thinking about the multi-dart option that would be great. Having different "spells" would be awesome, like frost darts, fire darts, and so on. XD.


--------------------


Remember, Remember the 5th of November...
Spoiler:



If you are new, please go through this spoiler for VERY useful links.
Spoiler:





Tarris Thread || User Forum || Tarris Hold Website || Twitch.tv
Go to the top of the page
 
+Quote Post
   
Pyrofiend
post Aug 1 2013, 04:40 PM
Post #17



Group Icon


Type: Artist




Update
Script has been updated to v1.2! Take a look in the description to get the new script.

Thank you everyone for trying out the script!

@neosky

I implemented the switch and fixed the bugs with the edges. I'll get to adding multiple dart types soon.

This post has been edited by Pyrofiend: Aug 1 2013, 05:45 PM


--------------------
I support:

Spoiler:
Go to the top of the page
 
+Quote Post
   
Neosky
post Aug 1 2013, 07:51 PM
Post #18


Master of the DarkSyde of Cheese!
Group Icon


Type: Undisclosed
Alignment: Lawful Evil




awesome!

You are a god!

Ok just a thought.

I had to do this before for something.

If I copy your script and then change all the name tags or w/e I should then have another chance for a dart.

So I could turn on one with a swtich when you equip something.
Then turn it off, and turn on the copied script switch when you equip something else.
Thus having a different dart then the first.

That's lazy way of doing it, but i think it should be able to accomplish the task.


*edit*
Ok while I was writing that, I think I came up with it.
I can make a variable array.

Where with variable set to this or that can.... hmmm
actually....

Sorry I'm thinking while I'm writing... it helps.....
Ok I was thinking, if I changed the variable, how would that change the dart... and how to setup an event to understand this change....
Then I thought, ok you can make that dart event with different pages. SS- A / B /C / D. Thus different images that way.
Then in that event would idk, turn on a swtich or set another variable - Yeah set a puzzle variable to something.

That way the events you would use it on if set to a specific variable would under stand that w/e was used was what was needed, that way if it's set to the wrong variable it would tell you...

Sorry... lol thinking.


Ok I'm going to try this out, and let you know how it goes.

Thanks for listening! XD




*UPDATE*

With the help of ???nOBody???

I was able to get up to 4 total darts, ran by a variable change.
I had it all setup, but the way my array was set.. was slightly wrong, I chose the wrong format of it.
but ???nOBody??? let me know that, and I changed that part and it works great now.

so I can use an event in game, to change a variable and then that changes the dart page.

So now I have A - D self swtiches being used.


*UPDATE* Question
Your patches work great.

but for some reason, the image doesn't show if I'm standing one block away from it. it works, just doesn't show.
not sure if this is cause of something... idk. but I'm looking into it.

here's a pic. I'm thinking that it's cause it's moving so fast or cause it's starting at that block correct? but it just looks weird shooting it from right there and nothing is showing but it's working, so I think i can deal with it.

scratch that, it's not the speed, it's because it starts in that block, and then ends in that block...Not sure how we'd fix that... of if we can...
Attached File(s)
Attached File  adfad.png ( 89.81K ) Number of downloads: 6
 


--------------------


Remember, Remember the 5th of November...
Spoiler:



If you are new, please go through this spoiler for VERY useful links.
Spoiler:





Tarris Thread || User Forum || Tarris Hold Website || Twitch.tv
Go to the top of the page
 
+Quote Post
   
Pyrofiend
post Aug 3 2013, 04:14 AM
Post #19



Group Icon


Type: Artist




DART THROW UPDATE

Dart script now updated to version 2! Now there are multiple types of darts that can be used simultaneously with their own switch and item parameters as well as multiple event activations! A demo will be coming soon with the new script and better explanations for the new layout.

@neosky

For your most recent issue, like you said the script works fine, it's just the visuals that are glitching up. If I were to take a guess, the slime was just about to move right in front of you, then you threw the dart. Within the code, the X and Y coordinates of the slime and the dart at the point of throwing were equal, even when the visuals didn't exactly match up. This is just the way the X and Y coordinates for any game_character object (player and events) works. Visually there'll be some clunkiness, but in all technicality it works perfectly fine.

Not too sure if this new script update will sync up exactly with what you have. If what you have works fine, then go ahead and use it, but take a look at the newest script and see if it still works or is what you need.

If you have any more problems with the script you can just PM me and I'll try to work it out there, ok?

This post has been edited by Pyrofiend: Aug 3 2013, 04:15 AM


--------------------
I support:

Spoiler:
Go to the top of the page
 
+Quote Post
   
Neosky
post Aug 3 2013, 07:58 AM
Post #20


Master of the DarkSyde of Cheese!
Group Icon


Type: Undisclosed
Alignment: Lawful Evil




Awesome I can't wait to see the new Demo.

As for the new problem, yeah I'm not going to look at that for right now...

And as for my edit, it works perfect for what I wanted, but I would love to see what you came up with in your demo.




Just a thought, in your 1.0 I think or which ever didn't have the fix for right next to you event activate. I think the image shown correctly with the event being a block away. idk I'll check it out and let you know. maybe there was something changed... you never know.


Thanks again! i'm having a lot of fun making puzzles.

just played the 1.0 demo and no it didn't. So n/m, idk. XD


--------------------


Remember, Remember the 5th of November...
Spoiler:



If you are new, please go through this spoiler for VERY useful links.
Spoiler:





Tarris Thread || User Forum || Tarris Hold Website || Twitch.tv
Go to the top of the page
 
+Quote Post
   

2 Pages V   1 2 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 29th July 2014 - 10:01 PM

RPGMakerVX.net is an Privacy Policy, Legal.