Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Falcao Throw and hits events V 1.0 RMVX

Hi

This script allow you throw any event on map just by equip any weapon like a bow also you can create event target to hit it

Features

- Allow you to throw events on map
- When you throw an event you can hit other event target then START
- Allow you create wepons like bow, boomerang or any tool you want
- Eeasy to use


Instructions

Place the script above main. Then put the following words in the
events command comments.

* Tool commands

WEAPON X instead X put the weapon ID that represents the object
If weapon X is equiped you able to throw the event

ITEM X Opcional. Instead X put the Item ID that the weapons will
spend. (Perfect to crate Bows) only work with WEAPON X

MULTIHIT Opcional. The event object HIT a target more than one time
Perfect to create tools like boomerangs etc.

* Target comands

START This comment make any event start when it is touched by
The event Object


You can create a lot of tools using this great utility


Credits

By Falcao


Demo

http://www.4shared.com/file/142433428/2 ... vents.html



I recomend you to dowload demo but if you want the code only. here you go

Code:
 

#==================================================================#

#  #*****************#             Throw and Hit events 1.0        #

#  #*** By Falcao ***#             Allow you throw events objects  #

#  #*****************#             like arrows rocks etc.          #

#         RMVX                                                     #

# makerpalace.onlinegoo.com                                        #

#==================================================================#

 

module Falcao

  

# Game Variable that represent the Weapon ID in an event page

# Use it like a page condition variable

WeaponVariable = 50

 

end

 

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

# * Instructios

# 

# Place the script above main. Then put the following words in the

# events command comments.

#

# * Tool commands

#

# WEAPON X     instead X put the weapon ID that represents the object

#              If weapon X is equiped you able to throw the event

#

# ITEM X       Opcional. Instead X put the Item ID that the weapons will 

#              spend. (Perfect to crate Bows) only work with WEAPON X 

#

# MULTIHIT     Opcional. The event object HIT a target more than one time

#              Perfect to create tools like boomerangs etc.

#

# * Target comands

#

# START        This comment make any event start when it is touched by

#              The event Object

#

# Note: You can create as many event object you nees so use the script

#       wisely

#

# Credits to Falcao (Sorry bad english im Salvadorian)

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

 

 

class Game_Map

  attr_accessor :event_ref

  alias falcaosetupevent_set setup

  def setup(map_id)

    falcaosetupevent_set(map_id)

    @event_ref = false

    actor = $game_party.members[0]

    var = Falcao::WeaponVariable

    $game_variables[var] = actor.weapon_id

    falref_events

  end

  

  alias falcaosetupevent_update update

  def update

    if @event_ref

      falref_events

    end

    falcaosetupevent_update

  end

  

  def falref_events

    for event in @events.values

      event.refresh

      if event.weaponid != nil

        event.transparent = true

        event.through = true

      end

    end

    @event_ref = false

  end

end

 

class Game_Event < Game_Character

  attr_reader     :weaponid

  attr_reader     :blanco

  attr_reader     :itemid 

  attr_reader     :multihit

  attr_accessor   :through 

  attr_accessor   :page

  

  alias falcaoHIT_ref refresh

  

  def refresh

    crear_ini

    falcaoHIT_ref

    crear_comments

  end

  

  def crear_ini

    @weaponid = nil

    @itemid = nil

    @blanco = false

    @multihit = false

  end

  

  def crear_comments

    if @page != nil

      for i in @page.list

        if i.code == 108 or i.code == 408

          if i.parameters[0].upcase[/WEAPON/] != nil

            @weaponid = i.parameters[0].split[1].to_i

          end

          if i.parameters[0].upcase[/START/] != nil

            @blanco = true

          end

          if i.parameters[0].upcase[/ITEM/] != nil

            @itemid = i.parameters[0].split[1].to_i

          end

          if i.parameters[0].upcase[/MULTIHIT/] != nil

            @multihit = true

          end

        end

      end

    end

  end

  

  def activar

    return if @list.size <= 1                   

    @starting = true

    lock if @trigger < 3

    $game_map.interpreter.setup_starting_event

  end

end

 

class Game_Player < Game_Character

  def forzar_movimiento

    for event in $game_map.events.values

      if event.semueve == true

        lista = event.move_route.list.size - 1

        event.move_route.skippable = true

        if lista == event.move_route_index and lista != 0

          event.semueve = false 

          event.transparent = true

          event.moveto(0, 0)

          $game_system.menu_disabled = false

        end

        return unless movable?

        case Input.dir4

        when 2;  move_down

        when 4;  move_left

        when 6;  move_right

        when 8;  move_up

        end

      end

    end

  end

end

 

class Game_Character

  attr_accessor :direction

  attr_accessor :semueve

  attr_accessor :move_route_index

  attr_accessor :move_route

  attr_accessor :move_failed

  alias falcaopegatinas_ini initialize

  def initialize

    falcaopegatinas_ini

    @objeto_x = 0

    @objeto_y = 0

    @semueve = false

  end

  

  alias falcaopegatinas_update update

  def update

    falcaopegatinas_update

    update_objects

    update_fevents

    $game_player.forzar_movimiento

  end

   

  def update_objects

    for event in $game_map.events.values

      if event.weaponid != nil and event.semueve == true

        @objeto_x = event.x

        @objeto_y = event.y

      end

      

      if event.blanco == true

        if event.x == @objeto_x and event.y == @objeto_y

          event.activar

          clear_hit

        end

      end

    end

  end

  

  def clear_hit

    for event in $game_map.events.values

      if event.semueve == true

        return if event.multihit

        event.move_failed = true

        event.transparent = true

        event.moveto(0, 0)

      end

    end

  end

  #----

  def update_fevents

    for event in $game_map.events.values

      return if event.semueve == true

      if Input.trigger?(Input::X)

        actor = $game_party.members[0]

        if event.weaponid != nil

          if actor.weapons.include?($data_weapons[event.weaponid]) 

            if event.itemid != nil

              item = $data_items[event.itemid]

              if $game_party.item_quantity(item.id) > 0

                set_event(event.id)

                $game_party.lose_item($data_items[item.id], 1)

              else

                return

              end

            else

              set_event(event.id)

            end

          end

        end

      end

    end

  end

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

  def set_event(id)

    event = $game_map.events[id]

    event.transparent = false

    cx = $game_player.x

    cy = $game_player.y

    event.moveto(cx, cy)

    event.direction = $game_player.direction

    $game_system.menu_disabled = true

    for i in event.page.list

      if i.code == 205

        event.start

        event.semueve = true

      end

    end

  end

end

 

class Scene_Equip

  alias falcao_set_update update

  def update

    actor = $game_party.members[0]

    var = Falcao::WeaponVariable

    $game_variables[var] = actor.weapon_id

    if Input.trigger?(Input::B)

      $game_map.event_ref = true

    end

    falcao_set_update

  end

end

 

class Game_Party < Game_Unit

  def item_quantity(item_id)

    return @items.include?(item_id) ? @items[item_id] : 0

  end

end

 

class Weaponsadd < Window_Base

  def initialize(x,y)

    super(x, y, 70, 66)

    self.opacity = 150

    self.visible = false

    refresh

  end

 

  def refresh

    self.contents.clear

    self.contents.font.name = "Times New Roman"

    self.contents.font.size = 16

    self.contents.font.bold = true

    draw_weapons

  end

  def draw_weapons

    for event in $game_map.events.values

      actor = $game_party.members[0]

      if actor.weapon_id == event.weaponid

        weapon = $data_weapons[event.weaponid]

        draw_icon(weapon.icon_index,5, 0)

        if event.itemid != nil

          item = $data_items[event.itemid]

          number = $game_party.item_quantity(item.id)

          self.contents.draw_text(10, 4, 50, 50, number.to_s)

        end

      end

    end

  end

end

 

class Scene_Map

  alias falcaoadd_weapons_main main

  def main

    crear_ventana

    falcaoadd_weapons_main

    borrar_ventana

  end

  def crear_ventana

    @fweapons = Weaponsadd.new(475,0)

  end

  def borrar_ventana

    @fweapons.dispose

  end

  alias falcaoadd_weapons_update update

  def update

    for event in $game_map.events.values

      if event.itemid != nil

        actor = $game_party.members[0]

        if actor.weapon_id == event.weaponid

          @fweapons.visible = true

          @fweapons.refresh

        else

          @fweapons.visible = false

        end

      end

    end

    falcaoadd_weapons_update

  end

end

 
 
samanoskue":1ya80ej7 said:
I get a script 'Throw and Hit' line 55: NoMethodError occurred
undefined meathod 'weapon_id' for nil:NilClass

Did you get the error from demo or your project?

If you get the error from your project make sure to load new game intead load a previous

Look at the examples on demo and you should not have any trouble
 
samanoskue":1kvkwiwp said:
I get a script 'Throw and Hit' line 55: NoMethodError occurred
undefined meathod 'weapon_id' for nil:NilClass

Did you get the error from demo or your project?

If you get the error from your project make sure to load new game intead load a previous

Look at the examples on demo and you should not have any trouble
 

Illitum

Sponsor

Falco, could something like this be transported to XP? I really would like to use this in XP instead of having to use a full on battle script to get the same effect.
 
Illitum":13vlcl2a said:
Falco, could something like this be transported to XP? I really would like to use this in XP instead of having to use a full on battle script to get the same effect.

Yep even i create both version together but XP version was not released cuz Falcao's laziness

But two peoples ask me same thing, that mean later i gonna post Maker Xp version of this script
 
Problem solved. I had my game start with out any characters in the party. Kind of weird but it works now I just have to use some fancy events to it my game to work the way it was. Thanks this is going to help a lot.

p.s. is there a way I could have npc(event) be able to use this script to shot at the player.
I'm using this as a simple action battle system. everything work from the players end.
 
samanoskue":32ltl5jx said:
Problem solved. I had my game start with out any characters in the party. Kind of weird but it works now I just have to use some fancy events to it my game to work the way it was. Thanks this is going to help a lot.

p.s. is there a way I could have npc(event) be able to use this script to shot at the player.
I'm using this as a simple action battle system. everything work from the players end.

Next version is righ on, Include event hit the player an a lot of new features just be patient

My english is a peace of crap but im doing my best jeje
 
I didn't mean to be pushy. Your script saved my project. I was looking into building a huge Action Battle System that was way above my coding skill so I probably would have given up. So by all means take as mush time as you need. Thanks again for give a much simpler way of getting the results I was looking for.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top