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

  1.  
  2. #==================================================================#
  3. #  #*****************#             Throw and Hit events 1.0        #
  4. #  #*** By Falcao ***#             Allow you throw events objects  #
  5. #  #*****************#             like arrows rocks etc.          #
  6. #         RMVX                                                     #
  7. # makerpalace.onlinegoo.com                                        #
  8. #==================================================================#
  9.  
  10. module Falcao
  11.  
  12. # Game Variable that represent the Weapon ID in an event page
  13. # Use it like a page condition variable
  14. WeaponVariable = 50
  15.  
  16. end
  17.  
  18. #------------------------------------------------------------------------
  19. # * Instructios
  20. #
  21. # Place the script above main. Then put the following words in the
  22. # events command comments.
  23. #
  24. # * Tool commands
  25. #
  26. # WEAPON X     instead X put the weapon ID that represents the object
  27. #              If weapon X is equiped you able to throw the event
  28. #
  29. # ITEM X       Opcional. Instead X put the Item ID that the weapons will
  30. #              spend. (Perfect to crate Bows) only work with WEAPON X
  31. #
  32. # MULTIHIT     Opcional. The event object HIT a target more than one time
  33. #              Perfect to create tools like boomerangs etc.
  34. #
  35. # * Target comands
  36. #
  37. # START        This comment make any event start when it is touched by
  38. #              The event Object
  39. #
  40. # Note: You can create as many event object you nees so use the script
  41. #       wisely
  42. #
  43. # Credits to Falcao (Sorry bad english im Salvadorian)
  44. #-------------------------------------------------------------------------
  45.  
  46.  
  47. class Game_Map
  48.   attr_accessor :event_ref
  49.   alias falcaosetupevent_set setup
  50.   def setup(map_id)
  51.     falcaosetupevent_set(map_id)
  52.     @event_ref = false
  53.     actor = $game_party.members[0]
  54.     var = Falcao::WeaponVariable
  55.     $game_variables[var] = actor.weapon_id
  56.     falref_events
  57.   end
  58.  
  59.   alias falcaosetupevent_update update
  60.   def update
  61.     if @event_ref
  62.       falref_events
  63.     end
  64.     falcaosetupevent_update
  65.   end
  66.  
  67.   def falref_events
  68.     for event in @events.values
  69.       event.refresh
  70.       if event.weaponid != nil
  71.         event.transparent = true
  72.         event.through = true
  73.       end
  74.     end
  75.     @event_ref = false
  76.   end
  77. end
  78.  
  79. class Game_Event < Game_Character
  80.   attr_reader     :weaponid
  81.   attr_reader     :blanco
  82.   attr_reader     :itemid
  83.   attr_reader     :multihit
  84.   attr_accessor   :through
  85.   attr_accessor   :page
  86.  
  87.   alias falcaoHIT_ref refresh
  88.  
  89.   def refresh
  90.     crear_ini
  91.     falcaoHIT_ref
  92.     crear_comments
  93.   end
  94.  
  95.   def crear_ini
  96.     @weaponid = nil
  97.     @itemid = nil
  98.     @blanco = false
  99.     @multihit = false
  100.   end
  101.  
  102.   def crear_comments
  103.     if @page != nil
  104.       for i in @page.list
  105.         if i.code == 108 or i.code == 408
  106.           if i.parameters[0].upcase[/WEAPON/] != nil
  107.             @weaponid = i.parameters[0].split[1].to_i
  108.           end
  109.           if i.parameters[0].upcase[/START/] != nil
  110.             @blanco = true
  111.           end
  112.           if i.parameters[0].upcase[/ITEM/] != nil
  113.             @itemid = i.parameters[0].split[1].to_i
  114.           end
  115.           if i.parameters[0].upcase[/MULTIHIT/] != nil
  116.             @multihit = true
  117.           end
  118.         end
  119.       end
  120.     end
  121.   end
  122.  
  123.   def activar
  124.     return if @list.size <= 1                  
  125.     @starting = true
  126.     lock if @trigger < 3
  127.     $game_map.interpreter.setup_starting_event
  128.   end
  129. end
  130.  
  131. class Game_Player < Game_Character
  132.   def forzar_movimiento
  133.     for event in $game_map.events.values
  134.       if event.semueve == true
  135.         lista = event.move_route.list.size - 1
  136.         event.move_route.skippable = true
  137.         if lista == event.move_route_index and lista != 0
  138.           event.semueve = false
  139.           event.transparent = true
  140.           event.moveto(0, 0)
  141.           $game_system.menu_disabled = false
  142.         end
  143.         return unless movable?
  144.         case Input.dir4
  145.         when 2;  move_down
  146.         when 4;  move_left
  147.         when 6;  move_right
  148.         when 8;  move_up
  149.         end
  150.       end
  151.     end
  152.   end
  153. end
  154.  
  155. class Game_Character
  156.   attr_accessor :direction
  157.   attr_accessor :semueve
  158.   attr_accessor :move_route_index
  159.   attr_accessor :move_route
  160.   attr_accessor :move_failed
  161.   alias falcaopegatinas_ini initialize
  162.   def initialize
  163.     falcaopegatinas_ini
  164.     @objeto_x = 0
  165.     @objeto_y = 0
  166.     @semueve = false
  167.   end
  168.  
  169.   alias falcaopegatinas_update update
  170.   def update
  171.     falcaopegatinas_update
  172.     update_objects
  173.     update_fevents
  174.     $game_player.forzar_movimiento
  175.   end
  176.    
  177.   def update_objects
  178.     for event in $game_map.events.values
  179.       if event.weaponid != nil and event.semueve == true
  180.         @objeto_x = event.x
  181.         @objeto_y = event.y
  182.       end
  183.      
  184.       if event.blanco == true
  185.         if event.x == @objeto_x and event.y == @objeto_y
  186.           event.activar
  187.           clear_hit
  188.         end
  189.       end
  190.     end
  191.   end
  192.  
  193.   def clear_hit
  194.     for event in $game_map.events.values
  195.       if event.semueve == true
  196.         return if event.multihit
  197.         event.move_failed = true
  198.         event.transparent = true
  199.         event.moveto(0, 0)
  200.       end
  201.     end
  202.   end
  203.   #----
  204.   def update_fevents
  205.     for event in $game_map.events.values
  206.       return if event.semueve == true
  207.       if Input.trigger?(Input::X)
  208.         actor = $game_party.members[0]
  209.         if event.weaponid != nil
  210.           if actor.weapons.include?($data_weapons[event.weaponid])
  211.             if event.itemid != nil
  212.               item = $data_items[event.itemid]
  213.               if $game_party.item_quantity(item.id) > 0
  214.                 set_event(event.id)
  215.                 $game_party.lose_item($data_items[item.id], 1)
  216.               else
  217.                 return
  218.               end
  219.             else
  220.               set_event(event.id)
  221.             end
  222.           end
  223.         end
  224.       end
  225.     end
  226.   end
  227.   #----------------
  228.   def set_event(id)
  229.     event = $game_map.events[id]
  230.     event.transparent = false
  231.     cx = $game_player.x
  232.     cy = $game_player.y
  233.     event.moveto(cx, cy)
  234.     event.direction = $game_player.direction
  235.     $game_system.menu_disabled = true
  236.     for i in event.page.list
  237.       if i.code == 205
  238.         event.start
  239.         event.semueve = true
  240.       end
  241.     end
  242.   end
  243. end
  244.  
  245. class Scene_Equip
  246.   alias falcao_set_update update
  247.   def update
  248.     actor = $game_party.members[0]
  249.     var = Falcao::WeaponVariable
  250.     $game_variables[var] = actor.weapon_id
  251.     if Input.trigger?(Input::B)
  252.       $game_map.event_ref = true
  253.     end
  254.     falcao_set_update
  255.   end
  256. end
  257.  
  258. class Game_Party < Game_Unit
  259.   def item_quantity(item_id)
  260.     return @items.include?(item_id) ? @items[item_id] : 0
  261.   end
  262. end
  263.  
  264. class Weaponsadd < Window_Base
  265.   def initialize(x,y)
  266.     super(x, y, 70, 66)
  267.     self.opacity = 150
  268.     self.visible = false
  269.     refresh
  270.   end
  271.  
  272.   def refresh
  273.     self.contents.clear
  274.     self.contents.font.name = "Times New Roman"
  275.     self.contents.font.size = 16
  276.     self.contents.font.bold = true
  277.     draw_weapons
  278.   end
  279.   def draw_weapons
  280.     for event in $game_map.events.values
  281.       actor = $game_party.members[0]
  282.       if actor.weapon_id == event.weaponid
  283.         weapon = $data_weapons[event.weaponid]
  284.         draw_icon(weapon.icon_index,5, 0)
  285.         if event.itemid != nil
  286.           item = $data_items[event.itemid]
  287.           number = $game_party.item_quantity(item.id)
  288.           self.contents.draw_text(10, 4, 50, 50, number.to_s)
  289.         end
  290.       end
  291.     end
  292.   end
  293. end
  294.  
  295. class Scene_Map
  296.   alias falcaoadd_weapons_main main
  297.   def main
  298.     crear_ventana
  299.     falcaoadd_weapons_main
  300.     borrar_ventana
  301.   end
  302.   def crear_ventana
  303.     @fweapons = Weaponsadd.new(475,0)
  304.   end
  305.   def borrar_ventana
  306.     @fweapons.dispose
  307.   end
  308.   alias falcaoadd_weapons_update update
  309.   def update
  310.     for event in $game_map.events.values
  311.       if event.itemid != nil
  312.         actor = $game_party.members[0]
  313.         if actor.weapon_id == event.weaponid
  314.           @fweapons.visible = true
  315.           @fweapons.refresh
  316.         else
  317.           @fweapons.visible = false
  318.         end
  319.       end
  320.     end
  321.     falcaoadd_weapons_update
  322.   end
  323. end
  324.  
Expand to see the code.
Could something like this be made for XP?
I get a script 'Throw and Hit' line 55: NoMethodError occurred
undefined meathod 'weapon_id' for nil:NilClass
samanoskue wrote:
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 wrote:
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
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 wrote:
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 wrote:
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
Your English seems fine to me. Your tutorial demo made perfect sense as well.
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.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=68098