Guest User

Falcao interactive system 2.0

a guest
Sep 5th, 2012
3,188
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================#
  2. #  #*****************#                                                         #
  3. #  #*** By Falcao ***#              * Interactive system 2.0                   #
  4. #  #*****************#         This script allow you to interact with events   #
  5. #                              game player, game characters and tarrain tiles  #
  6. #       RMVXACE                The feeling of realism is inminent              #
  7. #  www.makerpalace.com         Date: September 5 2012                          #
  8. #==============================================================================#
  9.  
  10. # * Installation
  11. #
  12. # You will need the graphics characters provided in the download post,
  13. # all pictures must be placed in character folder.
  14. #
  15. # Copy and paste the script above main and below materials. Done!
  16. #
  17. # Any pixel movement script may alter the X and Y axis this script is based
  18. # so i recomend you get rid any pixel movement script you have installed.
  19. #-------------------------------------------------------------------------------
  20. # License:
  21. # For non-comercial games only, for comercial games contact me to the
  22. # following email address falmc99@gmail.com
  23.  
  24. #-------------------------------------------------------------------------------
  25. #      * Features
  26. #
  27. # - Interactive Push system
  28. # - Interactive Pick Up system
  29. # - Interactive Fall System
  30. # - Interactive Jump System
  31. # - Interactive Sensor Vision System
  32. # - Interactive Tool HookShot
  33. # - Interactive Tool Flame Thrower
  34. # - Interactive Tool Bombs
  35. # - Interactive Tool Barrel
  36. # - Interactive Tool Blade
  37. # - Interactive Tool Arrows
  38. # - Interactive Dynamic Light Effects
  39. # - Interactive Dynamic Drop
  40. #
  41. # The push system allow you to push events to your desire place, allow you to
  42. # press targets and easily  tell them to do something when collide, events can
  43. # press targets by themself if you give them movement
  44. #
  45. # The pick up system allow you to pick up events and move it wherever you want
  46. # when you throw the event you can easily tell them to do something afther
  47. # throwed
  48. #
  49. # The fall system allow you to fall to espeficific tiles, events fall, fallowers
  50. # fall, events can make the player fall, also you can make something happen
  51. # when an event fall
  52. #
  53. # The Jump System allow you to jump by triggering the action key, followers
  54. # jump together with the player.
  55. #
  56. # The Sensor vision system allow you to activate any event within a vision range
  57. # between the player and the event, the event deactivate when out range
  58. #
  59. # The tool hookshot allow you to pull yourself to a different positions in
  60. # the map, you can grab objects from x distance and also start events tagged
  61. #
  62. # The tool flame thrower alllow tou star events tagged, burn torchs, burn the
  63. # barrel etc, create a ligh effect to see in the darkness
  64. #
  65. # The tool bomb allow you to explode some areas activating events tagged,
  66. # bombs can be picked and throwed, game party is affected if the bomb hurt them
  67. #
  68. # The tool barrel is a native tool created for this system never seen before in
  69. # a game, you can make a lot of things as: use it as a lantern, pick up throw,
  70. # burn the barrel with the flame trower, can be grabbed with the hook shot,
  71. # allow tou to solve puzzles, push events from the push system and much more.
  72. #
  73. # The tool blade allow you clean your path by cutting grass or wherever you want
  74. # to do with it, also you can apply drop to it
  75. #
  76. # The tool Arrows aloow you to activate events from long distance, you can
  77. # interact with bombs like creating a bomb arrow at real time
  78. #
  79. # The dynamic light effects allow you to create real lights on event tagged
  80. # you can set intencity, direction and do a lot of things.
  81. #
  82. # The dynamic drop allow you to create events to drop items jus by tagging
  83. # a simple command.
  84. #-------------------------------------------------------------------------------
  85.  
  86. module FalInt
  87.  
  88. #-------------------------------------------------------------------------------
  89. #                      * Push system *
  90. #
  91. # Write the followings lines on a event command comment tag
  92. #
  93. # PUSHABLE            - Event can be pushed wherever you want
  94. # JUMPBACK            - event jump back if you pushed against an impasable tile
  95. #
  96. # TARGET SELF SWITCH  - Put the self switch letter you want to activate
  97. #                       when collide ex: TARGET SELF SWITCH A
  98. #
  99. # TARGET SWITCH       - Put the switch id you want to activate when collide
  100. #                       ex: TARGET SWITCH 10
  101. #
  102. # TARGET VARIABLE     - Put the variable id you want to increase (+) when
  103. #                       collide ex: TARGET VARIABLE 5
  104. #
  105. # * Important info:
  106. #
  107. # Switches and variables are activated when PUSHED and TARGET collide and
  108. # they are deactivated when not colliding,  when you tranfer to another map
  109. # switches and variables the target activated reset
  110. #
  111. # TARGET events are always through on, always priority below characters and
  112. # dont start with the action key
  113. # PUSHABLE events are always direction fix off and always through off
  114. #
  115. # By default Player can push events too but you can disable or enable that
  116. # anytime with the following command
  117. #
  118. # $game_player.allowto_push = value    change value for true/false
  119. #
  120.  
  121.   # Sound played when the player push an event
  122.   PushSe = "Open1"
  123.  
  124.   # Sound played when pressing a target
  125.   PressTarget = "Switch2"
  126.  
  127.   # Sound played when realeasing the target
  128.   ReleaseTarget = "Switch1"
  129.  
  130. #-------------------------------------------------------------------------------
  131. #                         * Pick Up system *
  132. #
  133. # Write the followings lines on an event command comment tag
  134. #
  135. # PICK UP             The event is picked up when the action keys is triggered
  136. #
  137. # THROW SELF SWITCH   Put self switch letter you want to activate when you throw
  138. #                     the event ex: THROW SELF SWITCH A
  139. #
  140. # If you dont want self switch just leave it.
  141. #
  142. # You can do a lot of stuff when you throw an event, like desappear it, drop
  143. # something, use your imagination.
  144. #
  145.   # Sound played when player pick up an event
  146.   PickUpSe = "Shot1"
  147.  
  148.   # Sound played when player throw the event
  149.   ThrowSe = "Knock"
  150.  
  151. # * Pick Up Graphic
  152. #
  153. # You can change the actor graphic while picking an object, to show the graphic
  154. # the following requiriment must match.
  155. #
  156. # 1 -Obviously you graphic
  157. # 2- Name your graphic as your ariginal graphic plus $ and index
  158. #
  159. # Example: my character name is Actor4 index 0, so your pick up graphic must
  160. # be named $Actor4_index0
  161. #
  162. # If your main character is individual leave index0 as default
  163. #-------------------------------------------------------------------------------
  164. #                           * Fall System *
  165. #
  166.  
  167.   # Terrain tag where the player and events fall
  168.   FallTag = 6
  169.  
  170.   # Sound played when falling
  171.   FallSe = "Fall"
  172.  
  173. # Followers can fall too, events can fall too but events are no fools, they
  174. # only fall when player push them, so in order to make an event fall it must be
  175. # tagged PUSHABLE
  176. #
  177. # Write the followings lines on an event command comment tag
  178. #
  179. # FALL SWITCH        Put the switch id you want to activate when event fall
  180. #                    ex: FALL SWITCH 20
  181. #
  182. # FALL VARIABLE      Put the variable id you want to increase (+) when an
  183. #                    event fall ex: FALL VARIABLE 6
  184. #
  185. # If you dont want to activate switch or variable just leave it blank
  186. # Event is erased when they fall
  187. #
  188. # Player and followers decrease hp when they fall, default amount of hp to loose
  189. # is 100, but you can change that value anytime with the following command
  190. #
  191. #
  192. # $game_player.fallhp = value     Change value for desire hp to loose
  193. #                                 ex: $game_player.fallhp = 200
  194. #
  195. # Events can push the player in order to make him fall, write the following line
  196. # on event command comment tag: PUSH THE PLAYER the player will be jumped away
  197. # from the event.
  198. #-------------------------------------------------------------------------------
  199. #                      * Jump System
  200. #
  201. # Call the following line to activate the jump system
  202. #
  203. # $game_player.enable_jump = value      Change value for true / false
  204. #                                       ex: $game_player.enable_jump = true
  205. #
  206. # Player and followers jump together, they can jump only two tiles while
  207. # moving, if the are standing jump only at the same place, press the action key
  208. # to jump
  209.  
  210.   # Sound played when jumping
  211.   JumpSe = "Jump1"
  212. #-------------------------------------------------------------------------------
  213. #                      * Sensor Vision System
  214. #
  215. # Write the followings lines on an event command comment tag
  216. #
  217. # SENSOR VISION RANGE       Put vision range in tiles you want the event to have
  218. #                           ex: SENSOR VISION RANGE 6
  219. #
  220. # The distance is based in tiles between the game player and the event, when the
  221. # player is within the vision range a self switch is activated and it is
  222. # deactivated when the player is out of range
  223. #
  224.   # Self switch that is activated when the player is whithin the range
  225.   SensorSelfsw = "C"
  226. #-------------------------------------------------------------------------------
  227.  
  228.   # Action key, this key toggle pick up events, throw events and jump
  229.   ActionKey = :C
  230.  
  231. #-------------------------------------------------------------------------------
  232. # * Interactive tool Hookshot
  233.  
  234.   # Hookshot graphic, must be on characters graphic folder
  235.   HookGraphic = "$Hooktest4"
  236.  
  237.   # Weapon id that need to be equiped in order to use the Hook Shot
  238.   HweaponId = 61
  239.  
  240.   # How long you want the hook to have? it is measure in tiles
  241.   HookLong = 11
  242.  
  243.   # Hookshot speed, you can choose a value between 1 to 10, it support decimals
  244.   HookSpeed = 6
  245.  
  246.   # Sound played when using the hook
  247.   HookActionSe = "Bow1"
  248.  
  249.   # Sound played when hooking object
  250.   HookHookingSe = "Hammer"
  251.  
  252. #  HookShot Actions, write the followings lines on event comment tag
  253. #  
  254. #  HOOK PULL           Game player move from current position to event position
  255. #
  256. #  HOOK GRAB           The event can be grabbed by the hookshot
  257. #
  258. #  HOOK START          The event start when hit it by the hookshot
  259. #
  260.  
  261. #-------------------------------------------------------------------------------
  262. # * Interactive tool Flame Thrower
  263.  
  264.   # Flame graphic, must be on characters graphic folder
  265.   FlameGraphic = "$Flame"
  266.  
  267.   # Weapon id that need to be equiped in order to use the flame thrower
  268.   FweaponId = 62
  269.  
  270.   # Magic points (MP) that is consumed when using the flame thrower
  271.   FlameMpCost = 1
  272.  
  273.   # Flame duration, it is measured in frames, 60 frames = 1 second
  274.   FlameDuration = 60
  275.  
  276.   # Sound played when using the flame
  277.   FlameSoundSe = "Fire1"
  278.  
  279. # Flame Actions, write the followings lines on event comment tag
  280. #
  281. # FLAME START           The event start when hit it by the Flame Thrower
  282. #
  283. # Note: A flame ligh is displayed when the current game tone change, it can be
  284. # used as a small lantern for short time.
  285.  
  286. #-------------------------------------------------------------------------------
  287. # * Interactive tool Bomb
  288.  
  289.   # Bomb graphic, must be on characters graphic folder
  290.   BombGraphic = "$Bomb"
  291.  
  292.   # Weapon id that need to be equiped in order to use the bombs
  293.   BweaponId = 63
  294.  
  295.   # Item id that is consumed when using a bomb
  296.   BcostItemId = 17
  297.  
  298.   # How long you want the bomb to be showed? it is measured in seconds
  299.   BombDuration = 4
  300.  
  301.   # Bomb impact area, it is measured in tiles between the bomb and the object
  302.   BombImpactArea = 2
  303.  
  304.   # Total damage done to the game party if hurted by the bomb
  305.   BombDamage = 100
  306.  
  307.   # Sound played when using a bomb
  308.   BombActionSe = "Knock"
  309.  
  310.   # Animation id that is showed when the bomb explode
  311.   BombAnimationId = 14
  312.  
  313. # Bomb Actions, write the followings lines on event comment tag
  314. #
  315. # BOMB SELF SWITCH        Put self switch letter you want to activate when the
  316. #                         bomb explode an event. ex: BOMB SELF SWITCH A
  317. #
  318. # Note: The bomb is an area tool, affect to all events tagged above, it hurt to
  319. # the game party, keep your ass in a safe place, Bomb can be picked an throwed
  320.  
  321. #-------------------------------------------------------------------------------
  322. # * Interactive tool Barrel
  323.  
  324.   # Barrel graphic showed when is normal
  325.   BarrelGraphicOff = "$Barrel1"
  326.  
  327.   # Barrel graphic showed when is burning
  328.   BarrelGraphicOn = "$Barrel2"
  329.  
  330.   # Weapon id that need to be equiped in order to use the barrel
  331.   BAweaponId = 64
  332.  
  333.   # Item id that is consumed when using the barrel (the barrel wood)
  334.   BarrelItemCost = 19
  335.  
  336.   # Sound played when using a barrel
  337.   BarrelActionSe = "Knock"
  338.  
  339. # Note: The barrel system is a powerfull tool, that can do a lot of things
  340. # - Use the barrel as a lantern
  341. # - Burn the barrel with the flamne thrower
  342. # - Pick up and throw the barrel
  343. # - Grab the barrel with the hookshot
  344. # - Press events from the push system
  345. #
  346. # Note2: When the barrel is burned a ligh effect is created so you can pick up
  347. # the barrel and have a lantern
  348. #
  349. # Default barrel burn time is 20 seconds but can be changed wherever you want
  350. # with this script call:    $game_player.barrelburntime = 30   time in seconds
  351. #
  352. #           * Screen tone asociated with the barrel burnnig time
  353. #
  354. # By default no screen tone is changed when burning the barrel, just a pure ligh
  355. # is displayed around the barrel, but you can apply screen tone changes where
  356. # the barrel ligh gonna be used.
  357. #
  358. # Use this scripts call to tint next maps and activate the barrel burn tone chan
  359. #
  360. # $game_player.dark_nextmap           Activate the barrel ligh tone changes and
  361. #                                     the next map will be tinted dark
  362. #                                    
  363. # $game_player.normal_nextmap         Next map normalize, yes when you leave
  364. #                                     from the cave or something like that
  365.  
  366. # Barrel light tone change (Red, Green, Blue, Gray), when barrel burn
  367.   BarrelScreenTone = Tone.new(-60, -60, -60, 10)
  368.  
  369.   # Tone that is defined as normal in your game ( it s the default game tone)
  370.   GameNormalTone = Tone.new(0, 0, 0, 0)
  371.  
  372. #-------------------------------------------------------------------------------
  373. # * Interactive tool Blade
  374.  
  375.   # Blade graphic
  376.   BladeGraphic = "$Navaja"
  377.  
  378.   # Weapon id that need to be equiped in order to use the Blade
  379.   BladeWeaponId = 65
  380.  
  381.   # Sound played when using the blade
  382.   BladeSoundSe = "Bow2"
  383.  
  384. # Blade Actions, write the followings lines on event comment tag
  385. #
  386. # BLADE SELF SWITCH     Put self switch letter you want to activate when the
  387. #                       blade hit the event ex: BLADE SELF SWITCH A
  388. #
  389. # BLADE HIT ANIMATION   Put animation id that you want to be showed when the
  390. #                       blade hit the event ex: BLADE HIT ANIMATION 112
  391. #
  392. #-------------------------------------------------------------------------------
  393. # * Interactive tool Arrow
  394.  
  395.   # Arrow Graphic
  396.   ArrowGraphic = "$Arrow"
  397.  
  398.   # Weapon id that need to be equiped in order to use Arrows
  399.   ArrowWeaponId = 66
  400.  
  401.   # Item id that is consumed when using the arrows
  402.   ArrowItemCost = 18
  403.  
  404.   # Range of the arrows, it is measured in tiles
  405.   ArrowRange = 15
  406.  
  407.   # Sound played when using arrows
  408.   ArrowActionSe = "Bow3"
  409.  
  410. # Arrow Actions, write the followings lines on event comment tag
  411. #
  412. # ARROW START           Event start when hit it by the arrows
  413. #
  414. #-------------------------------------------------------------------------------
  415. # Key to triggers the tools, key A from the keyboard
  416.   ToolActionKey = :X
  417. #
  418. #-------------------------------------------------------------------------------
  419. #                      * Tools important notes
  420. #
  421. # An event tagged as HOOK START, FLAME START, ARROW START, dont start with the
  422. # player action key, they only start with the action tool.
  423. #
  424. #-------------------------------------------------------------------------------
  425. # * Interactive Dynamic Lights
  426.  
  427.   # Ligh effects graphic
  428.   LightsGraphic = "$Light_effects"
  429.  
  430. # Light Effects Actions, write the followings lines on event comment tag
  431. #
  432. # LIGHT EFFECT DIRECTION     Activate Ligh effect on that event, write the
  433. #                            direcction you want the graphic to be displayed
  434. #                            2 = Down, 4 = LEFT, 6 = RIGHT, 8 = UP
  435. #                            ex: LIGHT EFFECT DIRECTION = 2
  436. #
  437. # LIGHT EFFECT INTENCITY     Put the intencity number you want the light to have
  438. #                            there are five levels only: choose a value from
  439. #                            1 to 5 ex: LIGHT EFFECT INTENCITY 1
  440. #
  441. # LIGHT EFFECT REQUIRE FLAME The light effec is displayed only when the flame
  442. #                            thrower hit it
  443. #
  444. # Note: in case you want to turn on / off the ligh effect manually on event
  445. # use the followings script calls
  446. #
  447. # $game_map.lighactive(event_id, value)
  448. #
  449. # Intead of event id put event id, intead of value put true / false
  450. # ex: $game_map.lighactive(1, true)
  451. #
  452. # Note2: in order to use those script calls you have to tag the event as
  453. # LIGHT EFFECT REQUIRE FLAME
  454. #
  455. #-------------------------------------------------------------------------------
  456. # * Interactive Dynamic Drop
  457. #
  458. # Write the followings lines on event comment tag
  459. #
  460. # DROP ITEM ID          Put item id that you want to be droped by the event.
  461. #                       ex: DROP ITEM ID 1
  462. #-------------------------------------------------------------------------------
  463. end
  464.  
  465. #-------------------------------------------------------------------------------
  466. #                 * Falcao Interactive System version 2.0
  467.  
  468. #
  469. #  * Game tools creation
  470.  
  471. # Game hook
  472. class Game_Hook < Game_Character
  473.   attr_accessor   :index
  474.   def initialize(index)
  475.     super()
  476.     @through = true
  477.     @index = index
  478.     @character_name = FalInt::HookGraphic
  479.     @move_speed = FalInt::HookSpeed
  480.     @priority_type = 2
  481.   end
  482. end
  483.  
  484. # Game fire
  485. class Game_Fire < Game_Character
  486.   attr_accessor   :action_time
  487.   def initialize
  488.     super
  489.     @through = true
  490.     @character_name = FalInt::FlameGraphic
  491.     @move_speed = 6
  492.     @action_time = 0
  493.     @priority_type = 2
  494.     @step_anime = true
  495.   end
  496. end
  497.  
  498. # Game bomb
  499. class Game_Bomb < Game_Character
  500.   attr_accessor   :action_time
  501.   def initialize
  502.     super
  503.     @character_name = FalInt::BombGraphic
  504.     @action_time = 0
  505.     @step_anime = true
  506.     @move_speed = 6
  507.   end
  508. end
  509.  
  510. # Game Barrel
  511. class Game_Barrel < Game_Character
  512.   attr_accessor   :fire_duration
  513.   attr_accessor   :character_name
  514.   attr_accessor   :pevent
  515.   def initialize
  516.     super
  517.     @character_name = FalInt::BarrelGraphicOff
  518.     @fire_duration = 0
  519.     @step_anime = true
  520.     @move_speed = 6
  521.   end
  522. end
  523.  
  524. # Game Blade
  525. class Game_Blade < Game_Character
  526.   attr_accessor   :action_time
  527.   def initialize
  528.     super
  529.     @character_name = FalInt::BladeGraphic
  530.     @move_speed = 6
  531.     @action_time = 0
  532.     @through = true
  533.     @priority_type = 2
  534.     @step_anime = true
  535.   end
  536. end
  537.  
  538. # Game arrows
  539. class Game_Arrow < Game_Character
  540.   def initialize
  541.     super
  542.     @through = true
  543.     @character_name = FalInt::ArrowGraphic
  544.     @move_speed = 6
  545.     @priority_type = 2
  546.   end
  547. end
  548.  
  549. # Sprite sets
  550. class Spriteset_Map
  551.   alias falcao_intsystem_create_characters create_characters
  552.   def create_characters
  553.     create_interactive_characters
  554.     falcao_intsystem_create_characters
  555.   end
  556.  
  557.   def create_interactive_characters
  558.     if $game_player.clear_lights
  559.       dispose_light_effects
  560.       dispose_drop_sprites
  561.       $game_player.clear_lights = false
  562.     end
  563.     @hook_sprites = []
  564.     @lighesprites = []
  565.     @drop_sprites = []
  566.     @drop_events = []
  567.     play = $game_player
  568.     play.showing_hook   ? create_hook_sprites   : play.clear_hook
  569.     play.showing_fire   ? create_fire_sprite    : play.gamefire.moveto(-1, -1)
  570.     play.showing_bomb   ? create_bomb_sprite    : play.gamebomb.moveto(-1, -1)
  571.     play.showing_barrel ? create_barrel_sprite  : play.gamebarrel.moveto(-1, -1)
  572.     play.showing_blade  ? create_blade_sprite   : play.gameblade.moveto(-1, -1)
  573.     play.showing_arrow  ? create_arrow_sprite   : play.gamearrow.moveto(-1, -1)
  574.     create_light_effects
  575.     create_fblight  # fire barrel ligh
  576.     create_fireligh # flame thrower light
  577.     case    play.intreserved_tone[0]
  578.     when 1; $game_map.screen.start_tone_change(Tone.new(-130, -130, -130, 10),0)
  579.     when 2; $game_map.screen.start_tone_change(FalInt::GameNormalTone, 0)
  580.     end
  581.     play.intreserved_tone[1] = $game_map.map_id if play.intreserved_tone[0] != 0
  582.     play.intreserved_tone[1] = nil if play.intreserved_tone[0] == 2
  583.     if play.intreserved_tone[0] != 0 and play.gamebarrel.fire_duration > 0 and
  584.       play.intreserved_tone[1] != nil
  585.       play.current_tonesv = $game_map.screen.tone
  586.       $game_map.screen.start_tone_change(FalInt::BarrelScreenTone, 0)
  587.     end
  588.     play.intreserved_tone[0] = 0
  589.   end
  590.  
  591.   alias falcao_intsystem_dispose_h dispose
  592.   def dispose
  593.     dispose_hook_sprites
  594.     dispose_fire_sprite
  595.     dispose_bomb_sprite
  596.     dispose_barrel_sprite
  597.     dispose_light_effects
  598.     dispose_fblight   #fire barrel light
  599.     dispose_fireligh  #flame thrower light
  600.     dispose_blade_sprite
  601.     dispose_drop_sprites
  602.     dispose_arrow_sprite
  603.     falcao_intsystem_dispose_h
  604.   end
  605.  
  606.   def create_hook_sprites
  607.     return if not @hook_sprites.empty?
  608.     for hook in $game_player.hookshot
  609.       hook.transparent = false
  610.       sprite = Sprite_Character.new(@viewport1, hook)
  611.       @hook_sprites.push(sprite)
  612.     end
  613.   end
  614.  
  615.   def dispose_hook_sprites
  616.     return if @hook_sprites.empty?
  617.     @hook_sprites.each {|sprite| sprite.dispose }
  618.     @hook_sprites = []
  619.   end
  620.  
  621.   def create_fire_sprite
  622.     return if not @fire_sprite.nil?
  623.     @fire_sprite = Sprite_Character.new(@viewport1, $game_player.gamefire)
  624.   end
  625.  
  626.   def dispose_fire_sprite
  627.     return if @fire_sprite.nil?
  628.     @fire_sprite.dispose
  629.     @fire_sprite = nil
  630.   end
  631.  
  632.   def create_bomb_sprite
  633.     return if not @bomb_sprite.nil?
  634.     @bomb_sprite = Sprite_Character.new(@viewport1, $game_player.gamebomb)
  635.   end
  636.  
  637.   def dispose_bomb_sprite
  638.     return if @bomb_sprite.nil?
  639.     @bomb_sprite.dispose
  640.     @bomb_sprite = nil
  641.   end
  642.  
  643.   def create_barrel_sprite
  644.     return if not @barrel_sprite.nil?
  645.     @barrel_sprite = Sprite_Character.new(@viewport1, $game_player.gamebarrel)
  646.   end
  647.  
  648.   def dispose_barrel_sprite
  649.     return if @barrel_sprite.nil?
  650.     @barrel_sprite.dispose
  651.     @barrel_sprite = nil
  652.   end
  653.  
  654.   def create_fblight
  655.     return if not @fblight_sprite.nil?
  656.     @fblight_sprite = Sprite_LightEffec.new(@viewport1,
  657.     $game_player.gamebarrel, 2,  5)
  658.   end
  659.  
  660.   def dispose_fblight
  661.     return if @fblight_sprite.nil?
  662.     @fblight_sprite.dispose
  663.     @fblight_sprite = nil
  664.   end
  665.  
  666.   def create_fireligh
  667.     return if not @firelight_sprite.nil?
  668.     @firelight_sprite = Sprite_LightEffec.new(@viewport1,
  669.     $game_player.gamefire, 2,  2)
  670.   end
  671.  
  672.   def dispose_fireligh
  673.     return if @firelight_sprite.nil?
  674.     @firelight_sprite.dispose
  675.     @firelight_sprite = nil
  676.   end
  677.  
  678.   def create_blade_sprite
  679.     return if not @blade_sprite.nil?
  680.     @blade_sprite = Sprite_Character.new(@viewport1, $game_player.gameblade)
  681.   end
  682.  
  683.   def dispose_blade_sprite
  684.     return if @blade_sprite.nil?
  685.     @blade_sprite.dispose
  686.     @blade_sprite = nil
  687.   end
  688.  
  689.   def create_arrow_sprite
  690.     return if not @arrow_sprite.nil?
  691.     @arrow_sprite = Sprite_Character.new(@viewport1, $game_player.gamearrow)
  692.   end
  693.  
  694.   def dispose_arrow_sprite
  695.     return if @arrow_sprite.nil?
  696.     @arrow_sprite.dispose
  697.     @arrow_sprite = nil
  698.   end
  699.  
  700.   alias falcao_intsystem_update_characters update_characters
  701.   def update_characters
  702.     update_int_game_sprites
  703.     falcao_intsystem_update_characters
  704.   end
  705.  
  706.   def update_int_game_sprites
  707.     $game_player.showing_hook   ? create_hook_sprites  : dispose_hook_sprites
  708.     $game_player.showing_bomb   ? create_bomb_sprite   : dispose_bomb_sprite
  709.     $game_player.showing_barrel ? create_barrel_sprite : dispose_barrel_sprite
  710.     $game_player.showing_blade  ? create_blade_sprite  : dispose_blade_sprite
  711.     $game_player.showing_arrow  ? create_arrow_sprite  : dispose_arrow_sprite
  712.     if $game_player.showing_fire
  713.       create_fire_sprite
  714.       create_fireligh if $game_map.screen.tone != $game_player.snormal_tone
  715.     else
  716.       dispose_fire_sprite
  717.       dispose_fireligh
  718.     end
  719.     $game_player.gamebarrel.fire_duration > 0 ? create_fblight : dispose_fblight
  720.     @hook_sprites.each {|sprite| sprite.update }
  721.     @fire_sprite.update      if not @fire_sprite.nil?
  722.     @bomb_sprite.update      if not @bomb_sprite.nil?
  723.     @barrel_sprite.update    if not @barrel_sprite.nil?
  724.     @fblight_sprite.update   if not @fblight_sprite.nil? # fire barrel ligh
  725.     @firelight_sprite.update if not @firelight_sprite.nil?
  726.     @blade_sprite.update     if not @blade_sprite.nil?
  727.     @arrow_sprite.update if not @arrow_sprite.nil?
  728.     update_drop_sprites
  729.     @lighesprites.each {|sprite| sprite.update }
  730.   end
  731.  
  732.   # ligh effecs creation
  733.   def create_light_effects
  734.     for event in $game_map.events.values
  735.       direction = event.check_var("LIGHT EFFECT DIRECTION")
  736.       if direction != 0
  737.         intencity = event.check_var("LIGHT EFFECT INTENCITY")
  738.         @lighesprites.push(Sprite_LightEffec.new(@viewport1,
  739.         event, direction, intencity == 0 ? 1 : intencity))
  740.       end
  741.     end
  742.   end
  743.  
  744.   def dispose_light_effects
  745.     @lighesprites.each {|sprite| sprite.dispose }
  746.     @lighesprites.clear
  747.   end
  748.  
  749.   # easy drop system
  750.   def update_drop_sprites
  751.     for event in $game_map.events.values
  752.       item = event.check_var("DROP ITEM ID")
  753.       if item != 0
  754.         unless @drop_events.include?(event)
  755.           sprite = Sprite_DropItem.new(@viewport1, event, item)
  756.           @drop_sprites.push(sprite)
  757.           @drop_events.push(event)
  758.         end
  759.       end
  760.     end
  761.     for drop in @drop_sprites
  762.       drop.update
  763.       if drop.disposed?
  764.         @drop_sprites.delete(drop)
  765.       end
  766.     end
  767.   end
  768.  
  769.   # drop sprites dispose
  770.   def dispose_drop_sprites
  771.     @drop_sprites.each {|sprite| sprite.dispose }
  772.     @drop_sprites.clear
  773.   end
  774. end
  775.  
  776. # Ligh effects sprites
  777. class Sprite_LightEffec < Sprite
  778.   def initialize(viewport, character, direction=2, intencity=1)
  779.     super(viewport)
  780.     @character = character
  781.     @character_name = FalInt::LightsGraphic
  782.     @direction = direction
  783.     self.blend_type = 1
  784.     self.z = 2 * 100
  785.     set_character_bitmap
  786.     self.wave_amp = 3
  787.     self.wave_length = 240
  788.     self.wave_speed = 320
  789.     setup_intencity(intencity)
  790.     update
  791.   end
  792.  
  793.   def setup_intencity(intencity)
  794.     case intencity
  795.     when 1 ; @intencity = [zx = 1,   zy = 1,   sx = 0, sy = 0,   opa = 42]
  796.     when 2 ; @intencity = [zx = 1.5, zy = 1.5, sx = 0, sy = 30,  opa = 42]
  797.     when 3 ; @intencity = [zx = 2,   zy = 2,   sx = 0, sy = 60,  opa = 42]
  798.     when 4 ; @intencity = [zx = 2.5, zy = 2.5, sx = 0, sy = 90,  opa = 42]
  799.     when 5 ; @intencity = [zx = 3,   zy = 3,   sx = 0, sy = 120, opa = 42]
  800.     end
  801.     self.zoom_x  = @intencity[0]
  802.     self.zoom_y  = @intencity[1]
  803.     self.opacity = @intencity[4]
  804.   end
  805.  
  806.   def set_character_bitmap
  807.     self.bitmap = Cache.character(@character_name)
  808.     @cw = bitmap.width / 3
  809.     @ch = bitmap.height / 4
  810.     self.ox = @cw / 2 ;  self.oy = @ch
  811.   end
  812.  
  813.   def update
  814.     super
  815.     self.bush_depth = @character.bush_depth
  816.     update_src_rect
  817.     update_position
  818.   end
  819.  
  820.   def update_position
  821.     if @character.picked
  822.       self.x = $game_player.screen_x + @intencity[2]
  823.       self.y = $game_player.screen_y + @intencity[3]
  824.     else
  825.       self.x = @character.screen_x      + @intencity[2]
  826.       self.y = @character.screen_y + 22 + @intencity[3]
  827.     end
  828.     if @character.is_a?(Game_Event)
  829.       active = @character.check_com("LIGHT EFFECT REQUIRE FLAME")
  830.       self.visible = @character.activate_light if active
  831.     end
  832.     if @character.is_a?(Game_Fire)
  833.       play = $game_player
  834.       case play.direction
  835.       when 2 ; self.x = play.screen_x ;      self.y = play.screen_y + 120
  836.       when 4 ; self.x = play.screen_x - 60 ; self.y = play.screen_y + 65
  837.       when 6 ; self.x = play.screen_x + 60 ; self.y = play.screen_y + 65
  838.       when 8 ; self.x = play.screen_x ;      self.y = play.screen_y + 10
  839.       end
  840.     end
  841.   end
  842.  
  843.   def update_src_rect
  844.     pattern = @character.pattern < 3 ? @character.pattern : 1
  845.     sx = (0 % 4 * 3 + pattern) * @cw
  846.     sy = (0 / 4 * 4 + (@direction - 2) / 2) * @ch
  847.     self.src_rect.set(sx, sy, @cw, @ch)
  848.   end
  849. end
  850.  
  851. # Basic drop sprites
  852. class Sprite_DropItem < Sprite
  853.   def initialize(viewport, event, item)
  854.     super(viewport)
  855.     @event = event
  856.     @item = $data_items[item]
  857.     self.z = @event.screen_z
  858.     @object_zooming = 0
  859.     set_bitmap
  860.     update
  861.     @event.jump(0,0)
  862.   end
  863.  
  864.   def update
  865.     super
  866.     @event.through = true if not @event.through
  867.     @object_zooming += 1
  868.     case @object_zooming
  869.     when 1..10  ; self.zoom_x -= 0.02 ;  self.zoom_y -= 0.02
  870.     when 11..20 ; self.zoom_x += 0.02 ;  self.zoom_y += 0.02
  871.     when 21..30 ; self.zoom_x = 1.0   ;  self.zoom_y = 1.0; @object_zooming = 0
  872.     end
  873.     self.x = @event.screen_x - 12
  874.     self.y = @event.screen_y - 24
  875.     if @event.x == $game_player.x and @event.y == $game_player.y
  876.       RPG::SE.new("Item1", 80).play
  877.       $game_party.gain_item(@item, 1)
  878.       @event.start
  879.       dispose
  880.     end
  881.   end
  882.  
  883.   def dispose
  884.     self.bitmap.dispose
  885.     self.bitmap = nil
  886.     super
  887.   end
  888.  
  889.   def set_bitmap
  890.     self.bitmap = Bitmap.new(24, 24)
  891.     bitmap = Cache.system("Iconset")
  892.     icon = @item.icon_index
  893.     rect = Rect.new(icon % 16 * 24, icon / 16 * 24, 24, 24)
  894.     self.bitmap.blt(0, 0, bitmap, rect)
  895.   end
  896. end
  897.  
  898. # Game character base: new methods, variables and public instance variables
  899. class Game_CharacterBase
  900.   attr_accessor   :through
  901.   attr_accessor   :priority_type
  902.   attr_accessor   :opacity
  903.   attr_accessor   :move_speed
  904.   attr_accessor   :zoom_x
  905.   attr_accessor   :zoom_y
  906.   attr_accessor   :pushed
  907.   attr_accessor   :direction_fix
  908.   attr_accessor   :x
  909.   attr_accessor   :y
  910.   attr_accessor   :picked
  911.   attr_accessor   :throwed
  912.   attr_accessor   :force_move
  913.   attr_accessor   :obfalling
  914.   attr_accessor   :direction
  915.   attr_accessor   :pushable_busy
  916.   attr_accessor   :inrange
  917.   attr_accessor   :fallbyjump
  918.   attr_accessor   :char_steps
  919.   attr_accessor   :hook_start
  920.   attr_accessor   :fire_start
  921.   attr_accessor   :activate_light
  922.   attr_accessor   :bush_depth
  923.   attr_accessor   :pattern
  924.   attr_accessor   :blade_start
  925.   alias falcao_intsystem_base_ini initialize
  926.   def initialize
  927.     @zoom_x = 1.0
  928.     @zoom_y = 1.0
  929.     @pushed = false
  930.     @picked = false
  931.     @throwed = false
  932.     @obfalling = 0
  933.     @char_steps = 0
  934.     @activate_light = false
  935.     falcao_intsystem_base_ini
  936.   end
  937.  
  938.   alias falcao_intsystem_update_stop update_stop
  939.   def update_stop
  940.     char_steps_update if self.is_a?(Game_Player) and $game_player.hooking
  941.     char_steps_update if self.is_a?(Game_Hook) and !$game_player.hooking
  942.     char_steps_update unless self.is_a?(Game_Player) || self.is_a?(Game_Hook)
  943.     falcao_intsystem_update_stop
  944.   end
  945.  
  946.   def char_steps_update
  947.     if @char_steps > 0 and not moving?
  948.       move_forward ; @char_steps -= 1
  949.     end
  950.   end
  951.  
  952.   alias falcao_intsystem_passable passable?
  953.   def passable?(x, y, d)
  954.     bx = $game_map.round_x_with_direction(x, d)
  955.     by = $game_map.round_y_with_direction(y, d)
  956.     if self.is_a?(Game_Event) || self.is_a?(Game_Player)
  957.       return false if collide_with_bomb(bx, by)
  958.       return false if collide_with_barrel(bx, by)
  959.     end
  960.     falcao_intsystem_passable(x, y, d)
  961.   end
  962.  
  963.   def collide_with_bomb(x, y)
  964.     $game_player.gamebomb.pos_nt?(x, y)
  965.   end
  966.  
  967.   def collide_with_barrel(x, y)
  968.     $game_player.gamebarrel.pos_nt?(x, y)
  969.   end
  970.  
  971.   # Pasable jump: distance measured in tiles, ignore fall terrian tiles
  972.   def jump_passable?(distance, ignore_events=false)
  973.     dir = @direction
  974.     return false if !ignore_events and collide_with_characters?(
  975.     @x + ajustxy(self)[0] * distance, @y + ajustxy(self)[1] * distance)
  976.    
  977.     return true if self.is_a?(Game_Player) and
  978.     $game_map.terrain_tag(@x + ajustxy(self)[0] * distance,
  979.     @y + ajustxy(self)[1] * distance) == FalInt::FallTag
  980.    
  981.     return true if self.is_a?(Game_Event) and self.check_com("PUSHABLE") and
  982.     $game_map.terrain_tag(@x + ajustxy(self)[0] * distance,
  983.     @y + ajustxy(self)[1] * distance) == FalInt::FallTag
  984.    
  985.     return true if map_passable?(@x, @y + distance,  dir) and dir == 2
  986.     return true if map_passable?(@x - distance, @y,  dir) and dir == 4
  987.     return true if map_passable?(@x + distance, @y,  dir) and dir == 6
  988.     return true if map_passable?(@x, @y - distance,  dir) and dir == 8
  989.     return false
  990.   end
  991.  
  992.   # sensor
  993.   def sensor_area?(target, size)
  994.     distance = (@x - target.x).abs + (@y - target.y).abs
  995.     enable   = (distance <= size-1)
  996.     return true if enable
  997.     return false
  998.   end
  999.  
  1000.   # Start jump: power measured in tiles
  1001.   def start_jump(power)
  1002.     player = self.is_a?(Game_Player)
  1003.     if player
  1004.       RPG::SE.new(FalInt::JumpSe,80).play
  1005.       self.followers.reverse_each do |f|
  1006.         break if Input.dir4 == 0
  1007.         f.move_toward_player ; f.move_toward_player ; f.move_toward_player
  1008.         f.jump(0,  power)  if @direction == 2
  1009.         f.jump(- power, 0) if @direction == 4
  1010.         f.jump(power,  0)  if @direction == 6
  1011.         f.jump(0, - power) if @direction == 8
  1012.       end
  1013.     end
  1014.     jump(0,  power)  if player ? Input.dir4 == 2 : @direction == 2
  1015.     jump(- power, 0) if player ? Input.dir4 == 4 : @direction == 4
  1016.     jump(power,  0)  if player ? Input.dir4 == 6 : @direction == 6
  1017.     jump(0, - power) if player ? Input.dir4 == 8 : @direction == 8
  1018.     jump(0, 0) if Input.dir4 == 0 and player
  1019.   end
  1020.  
  1021.   # Jump back: power measured in tiles
  1022.   def jump_back(power=1)
  1023.     @direction_fix = true
  1024.     jump(0, - power)       if @direction == 2
  1025.     jump(power, 0)         if @direction == 4
  1026.     jump(- power,  0)      if @direction == 6
  1027.     jump(0, power)         if @direction == 8
  1028.     @direction_fix = false
  1029.   end
  1030.  
  1031.   # Jump forward: power measured in tiles
  1032.   def jump_forward(power=1)
  1033.     jump(0, power)       if @direction == 2
  1034.     jump(- power, 0)     if @direction == 4
  1035.     jump(power,  0)      if @direction == 6
  1036.     jump(0, - power)     if @direction == 8
  1037.   end
  1038.  
  1039.    # Ajust x y: object direction if nil take Input only for player
  1040.   def ajustxy(d=nil)
  1041.     push_x, push_y =   0,   1 if d.nil? ? Input.dir4 == 2 : d.direction == 2
  1042.     push_x, push_y = - 1,   0 if d.nil? ? Input.dir4 == 4 : d.direction == 4
  1043.     push_x, push_y =   1,   0 if d.nil? ? Input.dir4 == 6 : d.direction == 6
  1044.     push_x, push_y =   0, - 1 if d.nil? ? Input.dir4 == 8 : d.direction == 8
  1045.     return [push_x, push_y] if d != nil
  1046.     push_x, push_y =   0,   0 if Input.dir4 == 0
  1047.     return [push_x, push_y]
  1048.   end
  1049.  
  1050.   # Avoid update game player pattern when required
  1051.   alias falcao_intsystem_update_anime_pattern update_anime_pattern
  1052.   def update_anime_pattern
  1053.     return if self.is_a?(Game_Player) and self.tool_anime > 0
  1054.     return if self.is_a?(Game_Blade) and self.action_time > 0
  1055.     falcao_intsystem_update_anime_pattern
  1056.   end
  1057. end
  1058.  
  1059. # Game Player
  1060. class Game_Player < Game_Character
  1061.   include FalInt
  1062.   attr_accessor   :pushable
  1063.   attr_accessor   :fallhp
  1064.   attr_accessor   :allowto_push
  1065.   attr_accessor   :enable_jump
  1066.   attr_accessor   :working_at
  1067.   attr_accessor   :icontrol
  1068.   attr_reader     :hookshot    
  1069.   attr_reader     :hooking
  1070.   attr_reader     :showing_hook
  1071.   attr_reader     :gamefire
  1072.   attr_reader     :showing_fire
  1073.   attr_reader     :gamebomb
  1074.   attr_reader     :showing_bomb
  1075.   attr_reader     :grabing
  1076.   attr_accessor   :clear_lights
  1077.   attr_reader     :gamebarrel
  1078.   attr_reader     :showing_barrel
  1079.   attr_reader     :gameblade
  1080.   attr_reader     :showing_blade
  1081.   attr_reader     :snormal_tone
  1082.   attr_accessor   :intreserved_tone
  1083.   attr_accessor   :current_tonesv
  1084.   attr_reader     :tool_anime
  1085.   attr_reader     :gamearrow
  1086.   attr_reader     :showing_arrow
  1087.   attr_accessor   :barrelburntime
  1088.   # aliasing
  1089.   alias falcao_intsystem_ini initialize
  1090.   alias falcao_intsystem_update update
  1091.   alias falcao_intsystem_get_on_vehicle get_on_vehicle
  1092.   alias falcao_intsystem_get_off_vehicle get_off_vehicle
  1093.   alias falcao_intsystem_move_by_input move_by_input
  1094.   alias falcao_intsystem_start_map_event start_map_event
  1095.   alias falcao_intsystem_perform_transfer perform_transfer
  1096.  
  1097.   def initialize
  1098.     int_system_initialize
  1099.     falcao_intsystem_ini
  1100.   end
  1101.  
  1102.   def update
  1103.     update_intsystem
  1104.     falcao_intsystem_update
  1105.   end
  1106.  
  1107.   def int_system_initialize
  1108.     @pushable = []
  1109.     @eve_fall = []
  1110.     @fallhp = 100
  1111.     @player_busy = false
  1112.     @jump_delay = 0
  1113.     @allowto_push = true
  1114.     @enable_jump = false
  1115.     @pickup_delay = 0
  1116.     @standing_pushing = false
  1117.     @working_at = {}
  1118.     @icontrol = 0
  1119.     @grabevents = []
  1120.     @clear_lights = false
  1121.     @intreserved_tone = [0, nil]
  1122.     @tool_anime = 0
  1123.     @snormal_tone = GameNormalTone
  1124.     initialize_int_tools
  1125.   end
  1126.  
  1127.   def initialize_int_tools
  1128.     @hooking = false
  1129.     @hookshot = []
  1130.     for i in 1..HookLong
  1131.       @hookshot.push(Game_Hook.new(i))
  1132.     end
  1133.     @showing_hook = false
  1134.     @gamefire = Game_Fire.new
  1135.     @showing_fire = false
  1136.     @gamebomb = Game_Bomb.new
  1137.     @showing_bomb = false
  1138.     @collectargets = []
  1139.     @damage_blink = 0
  1140.     @gamebarrel = Game_Barrel.new
  1141.     @showing_barrel = false
  1142.     @barrelburntime = 20
  1143.     @gameblade = Game_Blade.new
  1144.     @showing_blade = false
  1145.     @gamearrow = Game_Arrow.new
  1146.     @showing_arrow = false
  1147.   end
  1148.  
  1149.   def update_intsystem
  1150.     update_push_events
  1151.     update_falling
  1152.     update_pick_up
  1153.     update_sensor_system
  1154.     update_hookshot
  1155.     update_game_fire
  1156.     update_game_bomb
  1157.     update_game_barrel
  1158.     update_game_blade
  1159.     update_game_arrow
  1160.     perform_jump if Input.trigger?(ActionKey) and
  1161.     !$game_map.interpreter.running? and @enable_jump
  1162.     update_int_timing
  1163.   end
  1164.  
  1165.   def update_int_timing
  1166.     @jump_delay -= 1   if @jump_delay > 0
  1167.     @icontrol   -= 1   if @icontrol > 0
  1168.     @tool_anime -= 1   if @tool_anime > 0
  1169.     @pattern     = 0   if @tool_anime > 0
  1170.   end
  1171.  
  1172.   #---------------------------------------------------------------------------
  1173.   # * Hook Shot action definition
  1174.  
  1175.   # Trigger this tool
  1176.   def hook_action
  1177.     if tool_canuse?(HweaponId) and not @showing_hook
  1178.       unless character_at_playerpos?
  1179.         @hookshot.each do |hook|
  1180.           hook.direction = @direction
  1181.           hook.moveto(@x, @y)
  1182.           hook.char_steps = hook.index
  1183.         end
  1184.         @showing_hook = true
  1185.         RPG::SE.new(HookActionSe, 80).play
  1186.         @tool_anime = 30
  1187.       else
  1188.         Sound.play_buzzer
  1189.       end
  1190.     end
  1191.   end
  1192.  
  1193.   def update_hookshot
  1194.     hook_action
  1195.     return unless @showing_hook
  1196.     @hookshot.each do |hook|
  1197.       hook.update
  1198.       hook.x = @x unless hook_moving?
  1199.       hook.y = @y unless hook_moving?
  1200.       hook.transparent = true if hook.real_x == @real_x and
  1201.       hook.real_y == @real_y
  1202.       if !hook_moving? and @showing_hook and hook.index == HookLong and
  1203.         hook.real_x == @real_x and hook.real_y == @real_y and @grabing.nil?
  1204.         @showing_hook = false
  1205.       end
  1206.       #barrel grabing
  1207.       if @gamebarrel.x == hook.x and @gamebarrel.y == hook.y and @grabing.nil?
  1208.         unless @gamebarrel.x == @x and @gamebarrel.y == @y
  1209.           @gamebarrel.through = true
  1210.           @gamebarrel.move_speed = hook.move_speed + 0.5
  1211.           @gamebarrel.turn_toward_player
  1212.           @gamebarrel.char_steps = hook.index
  1213.           @grabing = true
  1214.         end
  1215.       elsif @grabing != nil
  1216.         hook.char_steps = 0
  1217.         if @gamebarrel.x == @x and @gamebarrel.y == @y
  1218.           @gamebarrel.move_speed = 6
  1219.           @gamebarrel.through = false
  1220.           @grabing = nil
  1221.         end
  1222.       end
  1223.  
  1224.       $game_map.events.values.each do |event|
  1225.         # Hook grab
  1226.         if event.check_com("HOOK GRAB")
  1227.           @grabevents.push(event) unless @grabevents.include?(event)
  1228.           event.direction_fix = false if event.direction_fix
  1229.           if event.x == hook.x and event.y == hook.y and @grabing.nil?
  1230.             unless event.x == @x and event.y == @y
  1231.               @datae_s_t = [event.move_speed, event.through, event.move_type]
  1232.               event.through = true
  1233.               event.move_speed = hook.move_speed + 0.5
  1234.               event.move_type  = 0
  1235.               event.turn_toward_player
  1236.               event.char_steps = hook.index
  1237.               @grabing = true
  1238.             end
  1239.           elsif @grabing != nil
  1240.             hook.char_steps = 0
  1241.             if event.x == @x and event.y == @y
  1242.               event.move_speed = @datae_s_t[0]
  1243.               event.through = @datae_s_t[1]
  1244.               event.move_type = @datae_s_t[2]
  1245.               @grabing = nil
  1246.             end
  1247.           end
  1248.          
  1249.           # hook pull
  1250.         elsif event.check_com("HOOK PULL")
  1251.           if event.x == @x and event.y == @y
  1252.             @move_speed = @data_s_t[0]
  1253.             @through = @data_s_t[1]
  1254.             @hooking = @showing_hook = false
  1255.             hook.priority_type = 2
  1256.             break
  1257.           end
  1258.           if hook.x == event.x and hook.y == event.y and not @hooking
  1259.             @data_s_t = [@move_speed, @through]
  1260.             @move_speed = hook.move_speed
  1261.             @through = @hooking = true
  1262.             @char_steps = hook.index
  1263.             hook.priority_type = 1
  1264.             followers.gather
  1265.             RPG::SE.new(HookHookingSe,80).play
  1266.           end
  1267.         end
  1268.          
  1269.         # Hook start
  1270.         if event.check_com("HOOK START")
  1271.           if event.x == hook.x and event.y == hook.y and event.hook_start.nil?
  1272.             event.start
  1273.             event.hook_start = true
  1274.           elsif event.hook_start != nil
  1275.             hook.char_steps = 0
  1276.             event.hook_start = nil unless hook_moving?
  1277.           end
  1278.         end
  1279.       end
  1280.     end
  1281.   end
  1282.  
  1283.   def character_at_playerpos?
  1284.     return true if @gamebarrel.x == @x and @gamebarrel.y == @y
  1285.     @grabevents.any?{|event| event.x == @x && event.y == @y }
  1286.   end
  1287.  
  1288.   def hook_moving?
  1289.     @hookshot.any? {|hook| hook.char_steps > 0 }
  1290.   end
  1291.  
  1292.   def clear_hook
  1293.     @hookshot.each {|hook| hook.moveto(-1, -1) }
  1294.   end
  1295.  
  1296.   #---------------------------------------------------------------------------
  1297.   # * Flame Thrower action definition
  1298.  
  1299.   # Trigger this tool
  1300.   def game_fire_action
  1301.     if tool_canuse?(FweaponId) and not @showing_fire
  1302.       if actor.mp >= FlameMpCost
  1303.         @gamefire.direction = @direction
  1304.         @gamefire.moveto(@x, @y)
  1305.         @gamefire.char_steps = 2
  1306.         @gamefire.action_time = FlameDuration
  1307.         @showing_fire = true
  1308.         RPG::SE.new(FlameSoundSe,80).play
  1309.         actor.mp -= FlameMpCost
  1310.         @tool_anime = FlameDuration
  1311.       else
  1312.         Sound.play_buzzer
  1313.       end
  1314.     end
  1315.   end
  1316.  
  1317.   def update_game_fire
  1318.     game_fire_action
  1319.     return unless @showing_fire
  1320.     @gamefire.update
  1321.     @gamefire.action_time -= 1 if @gamefire.action_time > 0
  1322.     @showing_fire = false if @gamefire.action_time == 0
  1323.     @gamefire.moveto(-1, -1) if @gamefire.action_time == 0
  1324.     $game_map.events.values.each do |event|
  1325.       if event.fire_start != nil and @gamefire.action_time == 0
  1326.         clear_event
  1327.         break
  1328.       end
  1329.       if event.check_com("FLAME START")
  1330.         if event.x == @gamefire.x and event.y == @gamefire.y and
  1331.           event.fire_start.nil?
  1332.           active = event.check_com("LIGHT EFFECT REQUIRE FLAME")
  1333.           event.activate_light = true if active
  1334.           event.start
  1335.           event.fire_start = true
  1336.         end
  1337.       end
  1338.     end
  1339.   end
  1340.  
  1341.   def clear_event
  1342.     $game_map.events.values.each {|event| event.fire_start = nil }
  1343.   end
  1344.  
  1345.   #---------------------------------------------------------------------------
  1346.   # * Bombs action definition
  1347.  
  1348.   # Trigger this tool
  1349.   def game_bomb_action
  1350.     if tool_canuse?(BweaponId) and not @showing_bomb
  1351.       if $game_party.has_item?($data_items[BcostItemId])
  1352.         $game_party.consume_item($data_items[BcostItemId])
  1353.         @gamebomb.direction = @direction
  1354.         @gamebomb.moveto(@x, @y)
  1355.         @gamebomb.jump_passable?(1)?@gamebomb.start_jump(1) :@gamebomb.jump(0,0)
  1356.         @gamebomb.action_time = BombDuration * 60
  1357.         @showing_bomb = true
  1358.         @gamebomb.through = false
  1359.         RPG::SE.new(BombActionSe,90).play
  1360.         @tool_anime = 20
  1361.       else
  1362.         Sound.play_buzzer
  1363.       end
  1364.     end
  1365.   end
  1366.  
  1367.   def update_game_bomb
  1368.     game_bomb_action
  1369.     if @damage_blink > 0
  1370.       @damage_blink -= 1
  1371.       self.opacity = (self.opacity + 70) % 160 + 60 if @damage_blink < 30
  1372.       self.opacity = 255 if @damage_blink == 0
  1373.     end
  1374.     return unless @showing_bomb
  1375.     @gamebomb.update
  1376.     pickup_int_character(@gamebomb)
  1377.     @gamebomb.action_time -= 1 if @gamebomb.action_time > 0
  1378.     if @gamebomb.action_time == 35
  1379.       @gamebomb.picked ? self.animation_id = BombAnimationId :
  1380.       @gamebomb.animation_id = BombAnimationId
  1381.     end
  1382.    
  1383.     # if time is over collect targets to activate them
  1384.     if @gamebomb.action_time == 0
  1385.       $game_map.events.values.each do |event|
  1386.         if @gamebomb.sensor_area?(event, BombImpactArea)
  1387.           @collectargets.push(event)
  1388.         end
  1389.       end
  1390.       @collectargets.push(self) if sensor_area?(@gamebomb, BombImpactArea)
  1391.       start_bomb_impact
  1392.       @showing_bomb = false
  1393.     end
  1394.   end
  1395.  
  1396.   # Bomb impact
  1397.   def start_bomb_impact
  1398.     @collectargets.each do |targets|
  1399.       if targets.is_a?(Game_Event)
  1400.         self_sw = targets.check_selfsw("BOMB SELF SWITCH")
  1401.         if self_sw != nil
  1402.           $game_self_switches[[$game_map.map_id, targets.id, self_sw]] = true
  1403.         end
  1404.       elsif targets.is_a?(Game_Player)
  1405.         @damage_blink = 40
  1406.       end
  1407.     end
  1408.     if @damage_blink > 0
  1409.       $game_party.members.each {|actor| actor.hp -= BombDamage }
  1410.       move_backward
  1411.     end
  1412.     @collectargets.clear
  1413.     @player_busy = @gamebomb.picked = @gamebomb.throwed = false if
  1414.     @gamebomb.picked
  1415.     removepick_graphic
  1416.     @gamebomb.moveto(-1, -1)
  1417.   end
  1418.  
  1419.   #-----------------------------------------------------------------------------
  1420.   # * Barrel action definition
  1421.  
  1422.   # Trigger this tool
  1423.   def game_barrel_action
  1424.     if tool_canuse?(BAweaponId) and not @showing_barrel
  1425.       if $game_party.has_item?($data_items[BarrelItemCost])
  1426.         $game_party.consume_item($data_items[BarrelItemCost])
  1427.         @gamebarrel.direction = @direction
  1428.         @gamebarrel.moveto(@x, @y)
  1429.         @gamebarrel.jump_passable?(1) ? @gamebarrel.start_jump(1) :
  1430.         @gamebarrel.jump(0, 0)
  1431.         @showing_barrel = true
  1432.         @tool_anime = 20
  1433.         RPG::SE.new(BarrelActionSe,80).play
  1434.       else
  1435.         Sound.play_buzzer
  1436.       end
  1437.     end
  1438.   end
  1439.  
  1440.   def update_game_barrel
  1441.     game_barrel_action
  1442.     return unless @showing_barrel
  1443.     @gamebarrel.update
  1444.     pickup_int_character(@gamebarrel)
  1445.     if @gamebarrel.fire_duration > 0
  1446.       @gamebarrel.fire_duration -= 1
  1447.       if @gamebarrel.fire_duration == 0
  1448.         @gamebarrel.character_name = BarrelGraphicOff
  1449.         $game_map.screen.start_tone_change(@current_tonesv, 0) if
  1450.         @intreserved_tone[1] != nil
  1451.       end
  1452.     end
  1453.     if @gamebarrel.x == @gamefire.x and  @gamebarrel.y == @gamefire.y and
  1454.       @gamebarrel.fire_duration == 0
  1455.       @gamebarrel.character_name = BarrelGraphicOn
  1456.       @gamebarrel.fire_duration = @barrelburntime * 60
  1457.       if @intreserved_tone[1] != nil
  1458.         @current_tonesv = $game_map.screen.tone
  1459.         $game_map.screen.start_tone_change(BarrelScreenTone, 0)
  1460.       end
  1461.     end
  1462.   end
  1463.  
  1464.   #-----------------------------------------------------------------------------
  1465.   # * Blade action definition
  1466.  
  1467.   # Trigger this tool
  1468.   def game_blade_action
  1469.     if tool_canuse?(BladeWeaponId) and not @showing_blade
  1470.       @gameblade.direction = @direction
  1471.       @gameblade.moveto(@x, @y)
  1472.       @showing_blade = true
  1473.       @gameblade.action_time = 30
  1474.       @tool_anime = @gameblade.action_time
  1475.       RPG::SE.new(BladeSoundSe,75, 130).play
  1476.     end
  1477.   end
  1478.  
  1479.   def update_game_blade
  1480.     game_blade_action
  1481.     return unless @showing_blade
  1482.     @gameblade.update
  1483.     @gameblade.action_time -= 1 if @gameblade.action_time > 0
  1484.     @gameblade.move_forward if @gameblade.action_time == 18
  1485.     case @gameblade.action_time
  1486.     when 24..30 ; @gameblade.pattern = 0
  1487.     when 18..24 ; @gameblade.pattern = 1
  1488.     when 1..18 ; @gameblade.pattern = 2
  1489.     when 0 ; @showing_blade = false
  1490.     end
  1491.     for event in $game_map.events.values
  1492.       if event.blade_start != nil and @gameblade.action_time == 0
  1493.         event.blade_start = nil
  1494.         break
  1495.       end
  1496.       self_sw = event.check_selfsw("BLADE SELF SWITCH")
  1497.       if self_sw != nil
  1498.         if event.x == @gameblade.x and event.y == @gameblade.y and
  1499.           event.blade_start.nil?
  1500.           animation = event.check_var("BLADE HIT ANIMATION")
  1501.           event.animation_id = animation if animation != 0
  1502.           $game_self_switches[[$game_map.map_id, event.id, self_sw]] = true
  1503.           event.blade_start = true
  1504.         end
  1505.       end
  1506.     end
  1507.   end
  1508.  
  1509.   #----------------------------------------------------------------------------
  1510.   # Arrow
  1511.  
  1512.   def game_arrow_action
  1513.     if tool_canuse?(ArrowWeaponId) and not @showing_arrow
  1514.       if $game_party.has_item?($data_items[ArrowItemCost])
  1515.         $game_party.consume_item($data_items[ArrowItemCost])
  1516.         @gamearrow.direction = @direction
  1517.         @gamearrow.moveto(@x, @y)
  1518.         @showing_arrow = true
  1519.         @tool_anime = 20
  1520.         @gamearrow.char_steps = ArrowRange
  1521.         RPG::SE.new(ArrowActionSe,80).play
  1522.       else
  1523.         Sound.play_buzzer
  1524.       end
  1525.     end
  1526.   end
  1527.  
  1528.   def update_game_arrow
  1529.     game_arrow_action
  1530.     return unless @showing_arrow
  1531.     @gamearrow.update
  1532.     @showing_arrow = false if @gamearrow.char_steps == 0
  1533.     # bomb arrow grab
  1534.     if @gamebomb.x == @gamearrow.x  and @gamebomb.y == @gamearrow.y and
  1535.       @gamebomb.char_steps == 0 and @showing_arrow
  1536.       @gamebomb.through = true
  1537.       @gamebomb.direction = @gamearrow.direction
  1538.       @gamebomb.char_steps = @gamearrow.char_steps
  1539.     end
  1540.     for event in $game_map.events.values
  1541.       if event.check_com("ARROW START")
  1542.         if event.x == @gamearrow.x and event.y == @gamearrow.y and
  1543.           @gamearrow.char_steps > 0
  1544.           event.start
  1545.           @gamearrow.char_steps = 0
  1546.         end
  1547.       end
  1548.     end
  1549.   end
  1550.  
  1551.   #---------------------------------------------------------------------------
  1552.   # * Tools common actions
  1553.  
  1554.   # check if equiped tool can be used
  1555.   def tool_canuse?(id)
  1556.     return false if @obfalling > 0
  1557.     return true if !@player_busy and Input.trigger?(ToolActionKey) &&
  1558.     !$game_map.interpreter.running? && actor.weapons.include?($data_weapons[id])
  1559.     return false
  1560.   end
  1561.  
  1562.   # pick interactive character, apply to bombs and barrel
  1563.   def pickup_int_character(char)
  1564.     if char.throwed
  1565.       if char.force_move != nil and char.jump_passable?(1, true)
  1566.         char.start_jump(1) ; char.force_move = nil
  1567.       end
  1568.       unless char.jumping?
  1569.         RPG::SE.new(ThrowSe, 90).play
  1570.         @player_busy = char.throwed = false
  1571.       end
  1572.     end
  1573.     return if char.is_a?(Game_Bomb) and char.action_time < 35
  1574.     if Input.trigger?(ActionKey) and  char.picked and
  1575.       !$game_map.interpreter.running?
  1576.       if    char.jump_passable?(4) ;  char.start_jump(4)
  1577.       elsif char.jump_passable?(3) ;  char.start_jump(3)
  1578.       elsif char.jump_passable?(2) ;  char.start_jump(2)
  1579.       else                          ;      char.force_move = true
  1580.       end
  1581.       char.picked = false
  1582.       char.throwed = true
  1583.       removepick_graphic ; @tool_anime = 16
  1584.     end
  1585.     if Input.trigger?(ActionKey) and char.x == @x + ajustxy(self)[0] and
  1586.       char.y == @y + ajustxy(self)[1] and !self.moving? and !@player_busy
  1587.       RPG::SE.new(PickUpSe, 80).play
  1588.       @player_busy = char.picked = true
  1589.       applypick_grafhic ; @tool_anime = 16
  1590.     end
  1591.   end
  1592.  
  1593.   #---------------------------------------------------------------------------
  1594.   # * Push System
  1595.   #---------------------------------------------------------------------------
  1596.   # Player push event object
  1597.   def player_push(event)
  1598.     event.turn_away_from_player
  1599.     event.jump_back if event.check_com("JUMPBACK") and
  1600.     event.pushable_busy.nil? and not event.jump_passable?(1, true)
  1601.     if event.passable?(event.x, event.y, @direction) and !event.moving?
  1602.       unless event.x == @x and event.y == @y
  1603.         event.move_away_from_player
  1604.         RPG::SE.new(PushSe,80).play
  1605.       end
  1606.     end
  1607.   end
  1608.  
  1609.   # Push the target
  1610.   def press_target(event, sound=true)
  1611.     RPG::SE.new(PressTarget,80).play if sound
  1612.     self_sw = event.check_selfsw("TARGET SELF SWITCH")
  1613.     if self_sw != nil
  1614.       $game_self_switches[[$game_map.map_id, event.id, self_sw]] = true
  1615.     end
  1616.     switch = event.check_var("TARGET SWITCH")
  1617.     $game_switches[switch] = true if switch != 0
  1618.     variable = event.check_var("TARGET VARIABLE")
  1619.     $game_variables[variable] += 1 if variable != 0
  1620.     event.pushed = true
  1621.     event.refresh
  1622.   end
  1623.  
  1624.   # Release the target
  1625.   def release_target(event, sound=true)
  1626.     RPG::SE.new(ReleaseTarget, 80).play if sound
  1627.     self_sw = event.check_selfsw("TARGET SELF SWITCH")
  1628.     if self_sw != nil
  1629.       $game_self_switches[[$game_map.map_id, event.id, self_sw]] = false
  1630.     end
  1631.     switch = event.check_var("TARGET SWITCH")
  1632.     $game_switches[switch] = false if switch != 0
  1633.     variable = event.check_var("TARGET VARIABLE")
  1634.     $game_variables[variable] -= 1 if variable != 0
  1635.     event.pushed = false
  1636.     event.refresh
  1637.   end
  1638.  
  1639.   # Get float info necesary to release a target
  1640.   def afloatxy(object)
  1641.     push_x, push_y =   0,  - 0.5  if object.direction == 2 # down
  1642.     push_x, push_y =   0.5,   0   if object.direction == 4 # left
  1643.     push_x, push_y = - 0.5,   0   if object.direction == 6 # right
  1644.     push_x, push_y =   0,     0.5 if object.direction == 8 # up
  1645.     return [push_x, push_y]
  1646.   end
  1647.  
  1648.   # Update push events
  1649.   def update_push_events
  1650.     return if @vehicle_getting_on || in_boat? || in_ship? || in_airship?
  1651.     for event in $game_map.events.values
  1652.       if event.check_com("PUSHABLE") and !self.moving?
  1653.         event.direction_fix = false if event.direction_fix
  1654.         if event.x == @x + ajustxy[0] and event.y == @y + ajustxy[1]
  1655.           player_push(event)
  1656.         end
  1657.       end
  1658.      
  1659.       if event.check_selfsw("TARGET SELF SWITCH") != nil
  1660.         event.through = true if not event.through
  1661.         event.priority_type = 0 if event.priority_type != 0
  1662.        
  1663.         # Player push targets
  1664.         if @allowto_push
  1665.           if event.real_x == @real_x and event.real_y == @real_y and
  1666.             not event.pushed
  1667.             press_target(event, @icontrol == 0)
  1668.             @standing_pushing = true
  1669.           elsif event.pushed
  1670.             if event.real_x == @real_x + afloatxy(self)[0] and
  1671.               event.real_y == @real_y + afloatxy(self)[1]
  1672.               release_target(event)
  1673.               @standing_pushing = false
  1674.             end
  1675.           end
  1676.         end
  1677.        
  1678.         # Barrel presing
  1679.         if event.real_x == @gamebarrel.real_x and event.real_y ==
  1680.           @gamebarrel.real_y and not event.pushed and !@gamebarrel.picked and
  1681.           not @gamebarrel.throwed
  1682.           press_target(event, @icontrol == 0) ; @gamebarrel.pushable_busy = true
  1683.           @gamebarrel.pevent = event
  1684.         elsif event.pushed and event.x == @x + ajustxy(self)[0] and event.y ==
  1685.           @y + ajustxy(self)[1] and Input.trigger?(ActionKey) and
  1686.           not @gamebarrel.pushable_busy.nil?
  1687.           release_target(event) ; @gamebarrel.pushable_busy = nil
  1688.           break
  1689.         end
  1690.         if @gamebarrel.char_steps > 0 and !@grabing.nil? and
  1691.           !@gamebarrel.pushable_busy.nil?
  1692.           release_target(@gamebarrel.pevent) ; @gamebarrel.pushable_busy = nil
  1693.         end
  1694.        
  1695.         @pushable.each do |ev|
  1696.           if @grabing.nil?
  1697.             ev.through = false if ev.through
  1698.           end
  1699.           # release a pushed target if the player pick up the object
  1700.           if ev.check_com("PICK UP")
  1701.             @working_at.delete(ev.id) if !ev.pushable_busy.nil? and
  1702.             ev.x == @x + ajustxy(self)[0] and ev.y == @y + ajustxy(self)[1] and
  1703.             Input.trigger?(ActionKey)
  1704.             if event.pushed and event.x == @x + ajustxy(self)[0] and event.y ==
  1705.               @y + ajustxy(self)[1] and Input.trigger?(ActionKey)
  1706.               release_target(event)
  1707.               break
  1708.             end
  1709.           end
  1710.          
  1711.           # events pushing and releasing conditions
  1712.           if event.real_x == ev.real_x and event.real_y == ev.real_y and
  1713.             not event.pushed and not ev.picked and not ev.throwed
  1714.             press_target(event, @icontrol == 0) ; ev.pushable_busy = true
  1715.             @working_at[ev.id] = [ev.x, ev.y]
  1716.           elsif event.pushed
  1717.             break if event.real_x == ev.real_x and event.real_y == ev.real_y
  1718.             if event.real_x == ev.real_x + afloatxy(ev)[0] and
  1719.               event.real_y == ev.real_y + afloatxy(ev)[1] and not ev.picked
  1720.               release_target(event) ; ev.pushable_busy = nil
  1721.               @working_at.delete(ev.id)
  1722.             end
  1723.           end
  1724.         end
  1725.       end
  1726.     end
  1727.   end
  1728.  
  1729.   #---------------------------------------------------------------------------
  1730.   # * Pick up System  
  1731.   #---------------------------------------------------------------------------
  1732.   def update_pick_up
  1733.     return if @vehicle_getting_on || in_boat? || in_ship? || in_airship?
  1734.     @pickup_delay -= 1 if @pickup_delay > 0
  1735.     return if @pickup_delay > 0
  1736.     for event in $game_map.events.values
  1737.       if event.throwed  # if throwed do this
  1738.         if event.force_move != nil and event.jump_passable?(1, true)
  1739.           event.start_jump(1)
  1740.           event.force_move = nil
  1741.         end
  1742.        
  1743.         unless event.jumping?
  1744.           RPG::SE.new(ThrowSe,80).play
  1745.           self_sw = event.check_selfsw("THROW SELF SWITCH")
  1746.           if self_sw != nil
  1747.             $game_self_switches[[$game_map.map_id, event.id, self_sw]] = true
  1748.             event.refresh
  1749.             event.direction = event.page.graphic.direction
  1750.             changing = true
  1751.           end
  1752.           @player_busy = event.throwed = false
  1753.           event.jump(0,  0) if changing.nil?
  1754.           changing = nil
  1755.         end
  1756.       end
  1757.      
  1758.       if event.check_com("PICK UP")
  1759.         event.priority_type = 1 if event.priority_type == 0
  1760.         event.direction_fix = false if event.direction_fix
  1761.         # Throw object
  1762.         if Input.trigger?(ActionKey) and  event.picked and
  1763.           !$game_map.interpreter.running?
  1764.           event.move_speed = @pickevdata[0]
  1765.           if    event.jump_passable?(4) ;  event.start_jump(4)
  1766.           elsif event.jump_passable?(3) ;  event.start_jump(3)
  1767.           elsif event.jump_passable?(2) ;  event.start_jump(2)
  1768.           else                          ;  event.force_move = true
  1769.           end
  1770.           event.picked = false
  1771.           event.move_type = @pickevdata[1]
  1772.           event.throwed = true
  1773.           removepick_graphic ; @tool_anime = 16
  1774.         end
  1775.        
  1776.         # Pick up object
  1777.         if Input.trigger?(ActionKey) and event.x == @x + ajustxy(self)[0] and
  1778.           event.y == @y + ajustxy(self)[1] and !event.picked and
  1779.           not self.moving? and not @player_busy
  1780.           RPG::SE.new(PickUpSe, 80).play
  1781.           @pickevdata = [event.move_speed, event.move_type]
  1782.           event.move_speed = 6
  1783.           event.move_type = 0
  1784.           event.priority_type = 1
  1785.           @player_busy = event.picked = true
  1786.           @pickup_delay = 5
  1787.           applypick_grafhic ; @tool_anime = 16
  1788.         end
  1789.       end
  1790.     end
  1791.   end
  1792.  
  1793.   def applypick_grafhic
  1794.     if actor_graphic_pickup != nil
  1795.       @lastgrain = [@character_name, @character_index]
  1796.       @character_name = actor_graphic_pickup
  1797.     end
  1798.   end
  1799.  
  1800.   def removepick_graphic
  1801.     if @lastgrain != nil
  1802.       @character_name = @lastgrain[0]
  1803.       @character_index = @lastgrain[1]
  1804.       @lastgrain = nil
  1805.     end
  1806.   end
  1807.  
  1808.   def actor_graphic_pickup
  1809.     name = @character_name.sub("$", "") ; index = @character_index
  1810.     graphic_name = "$" + name + "_index" + index.to_s
  1811.     graphic = Cache.character(graphic_name) rescue nil
  1812.     return graphic_name if graphic != nil
  1813.     return nil
  1814.   end
  1815.  
  1816.   #---------------------------------------------------------------------------
  1817.   # * Fall System  
  1818.   #---------------------------------------------------------------------------
  1819.   # events start falling
  1820.   def start_falling(event)
  1821.     event.obfalling = 1
  1822.     event.move_speed = 4.5
  1823.     event.through = true
  1824.     event.fallbyjump.nil? ? event.move_away_from_player : event.fallbyjump = nil
  1825.     RPG::SE.new(FallSe,80).play
  1826.     @eve_fall.push(event) unless @eve_fall.include?(event)
  1827.     @eve_fall = @eve_fall.uniq
  1828.     @player_busy = event.picked = false if event.picked
  1829.   end
  1830.  
  1831.   # Player start falling
  1832.   def player_start_falling
  1833.     $game_map.events.values.each do |event|
  1834.       if event.picked and not event.check_com("PUSHABLE")
  1835.         start_falling(event)
  1836.       end
  1837.     end
  1838.     self.through = true
  1839.     set_direction(Input.dir4) if Input.dir4 != 0
  1840.     self.move_forward if @fallbyjump.nil?
  1841.     RPG::SE.new(FallSe,80).play
  1842.     @last_speed = self.move_speed
  1843.     self.move_speed = 5
  1844.     @obfalling = 100
  1845.     if @gamebarrel.picked
  1846.       @player_busy = @gamebarrel.picked = false
  1847.       @gamebarrel.jump_back
  1848.     end
  1849.     if @gamebomb.picked
  1850.       @player_busy = @gamebomb.picked = false
  1851.       @gamebomb.jump_back
  1852.     end
  1853.     removepick_graphic
  1854.   end
  1855.  
  1856.   def update_falling
  1857.     return if @vehicle_getting_on || in_boat? || in_ship? || in_airship?
  1858.    
  1859.     # Events fall
  1860.     for event in $game_map.events.values
  1861.       if event.check_com("PUSHABLE") and @grabing.nil?
  1862.        
  1863.         @pushable.push(event) unless @pushable.include?(event)
  1864.         if $game_map.terrain_tag(event.real_x + ajustxy[0],
  1865.           event.real_y + ajustxy[1]) == FallTag  and
  1866.           event.real_x == @real_x + ajustxy[0] and
  1867.           event.real_y == @real_y + ajustxy[1] and event.obfalling == 0
  1868.           start_falling(event) unless event.moving? and self.moving?
  1869.          
  1870.         elsif $game_map.terrain_tag(event.real_x, event.real_y) == FallTag and
  1871.           event.obfalling == 0
  1872.           unless event.moving?
  1873.             event.fallbyjump = true
  1874.             start_falling(event)
  1875.           end
  1876.         end
  1877.       end
  1878.      
  1879.       # Events push the player away
  1880.       if event.check_com("PUSH THE PLAYER")
  1881.         event.direction_fix = false if event.direction_fix
  1882.         if @jump_delay == 0 and @real_x == event.real_x + ajustxy(event)[0] and
  1883.           @real_y == event.real_y + ajustxy(event)[1] and @obfalling == 0 and
  1884.           not @showing_hook
  1885.           @direction = event.direction
  1886.           move_forward
  1887.           followers.gather
  1888.           if jump_passable?(1, ignore_events = true)
  1889.             @lastpxy = [@x, @y]
  1890.             jump_forward(1) ; @jump_delay = 20
  1891.           end
  1892.         end
  1893.       end
  1894.     end
  1895.    
  1896.     # event falling effect
  1897.     @eve_fall.each do |ev|
  1898.       if ev.obfalling > 0
  1899.         ev.zoom_x -= 0.06
  1900.         ev.zoom_y -= 0.06
  1901.         if ev.zoom_x <= 0.06  and !ev.erased
  1902.           switch = ev.check_var("FALL SWITCH")
  1903.           $game_switches[switch] = true if switch != 0
  1904.           variable = ev.check_var("FALL VARIABLE")
  1905.           $game_variables[variable] += 1 if variable != 0
  1906.           event.refresh if switch != 0 || variable != 0
  1907.           ev.erase
  1908.           @eve_fall.delete_if { |e| e == ev }
  1909.           event.obfalling = 0
  1910.         end
  1911.       end
  1912.     end
  1913.  
  1914.    # followes fall with the player
  1915.     self.followers.reverse_each do |f|
  1916.       if @obfalling > 0
  1917.         f.zoom_x = @zoom_x
  1918.         f.zoom_y = @zoom_y
  1919.         f.move_toward_player ; f.move_toward_player ; f.move_toward_player
  1920.       end
  1921.     end
  1922.  
  1923.     unless @showing_hook
  1924.       if $game_map.terrain_tag(@real_x, @real_y) == FallTag and
  1925.         @obfalling == 0 and not moving? and not jumping?
  1926.         @fallbyjump = true
  1927.         player_start_falling
  1928.       elsif $game_map.terrain_tag(@real_x + ajustxy[0], @real_y + ajustxy[1]) ==
  1929.         FallTag and @obfalling == 0 and !self.moving?
  1930.         player_start_falling
  1931.       end
  1932.     end
  1933.    
  1934.     if @obfalling > 0
  1935.       @obfalling -= 1
  1936.       if @obfalling > 30 and @obfalling < 100
  1937.         self.zoom_x -= 0.06; self.zoom_y -= 0.06
  1938.       end
  1939.       if @obfalling == 40
  1940.         @fallbyjump.nil? ? self.move_backward : moveto(@lastpxy[0],
  1941.         @lastpxy[1]) rescue nil
  1942.         @fallbyjump = nil
  1943.       end
  1944.       if @obfalling == 30
  1945.         self.zoom_x = 1.0
  1946.         self.zoom_y = 1.0
  1947.         $game_party.members.each do |actor|
  1948.           actor.hp -= @fallhp
  1949.         end
  1950.       end
  1951.       self.through = false if @obfalling == 15
  1952.       self.opacity = (self.opacity + 70) % 160 + 60 if @obfalling < 40
  1953.       self.opacity = 255 if @obfalling == 0
  1954.       self.move_speed = @last_speed if @obfalling == 0
  1955.     end
  1956.   end
  1957.  
  1958.   #---------------------------------------------------------------------------
  1959.   # * Jump System
  1960.   #---------------------------------------------------------------------------
  1961.   def perform_jump
  1962.     return if @standing_pushing || self.jumping? || @obfalling > 0 ||
  1963.     in_airship? || @vehicle_getting_on || in_boat? || in_ship? ||
  1964.     @jump_delay > 0 || @player_busy || @showing_hook || @showing_fire
  1965.     $game_map.events.values.each do |event|
  1966.       if event.pushed
  1967.         return if event.x == @x and event.y == @y
  1968.         if event.x == @x + ajustxy(self)[0] and event.y == @y + ajustxy(self)[1]
  1969.           return
  1970.         end
  1971.       end
  1972.     end
  1973.     @lastpxy = [@x, @y]
  1974.     if    jump_passable?(2)  ;   start_jump(2)
  1975.     elsif jump_passable?(1)  ;   start_jump(1)
  1976.     else                     ;   start_jump(0)            
  1977.     end
  1978.     @jump_delay = 16
  1979.   end
  1980.  
  1981.   #---------------------------------------------------------------------------
  1982.   # * Sensor Vision System
  1983.   #---------------------------------------------------------------------------
  1984.   def update_sensor_system
  1985.     $game_map.events.values.each do |event|
  1986.       range = event.check_var("SENSOR VISION RANGE")
  1987.       if range != 0
  1988.         if sensor_area?(event, range)
  1989.           data = [$game_map.map_id, event.id, SensorSelfsw]
  1990.           if event.inrange.nil? and !$game_self_switches[[data[0], data[1],
  1991.             data[2]]]
  1992.             $game_self_switches[[data[0], data[1], data[2]]] = true
  1993.             event.inrange = true
  1994.           end
  1995.         elsif event.inrange != nil
  1996.           data = [$game_map.map_id, event.id, SensorSelfsw]
  1997.           if $game_self_switches[[data[0], data[1], data[2]]]
  1998.             $game_self_switches[[data[0], data[1], data[2]]] = false
  1999.             event.inrange = nil
  2000.           end
  2001.         end
  2002.       end
  2003.     end
  2004.   end
  2005.  
  2006.   #-----------------------------------------------------------------------------
  2007.   #                   * Flow control
  2008.   #-----------------------------------------------------------------------------
  2009.   def get_on_vehicle
  2010.     return if @player_busy
  2011.     falcao_intsystem_get_on_vehicle
  2012.   end
  2013.  
  2014.   def get_off_vehicle
  2015.     return if $game_map.terrain_tag(@x, @y) == FallTag
  2016.     falcao_intsystem_get_off_vehicle
  2017.   end
  2018.  
  2019.   def move_by_input
  2020.     return if @obfalling > 0 || @showing_hook || @showing_fire|| @tool_anime > 0
  2021.     falcao_intsystem_move_by_input
  2022.   end
  2023.  
  2024.   def start_map_event(x, y, triggers, normal)
  2025.     $game_map.events_xy(x, y).each do |ev|
  2026.       return if ev.check_selfsw("TARGET SELF SWITCH") != nil || ev.check_com(
  2027.       "FLAME START") ||ev.check_com("ARROW START") ||ev.check_com("HOOK START")
  2028.     end  
  2029.     falcao_intsystem_start_map_event(x, y, triggers, normal)
  2030.   end
  2031.  
  2032.   # refresh all the system if the map is not the same
  2033.   def perform_transfer
  2034.     if $game_map.map_id !=  @new_map_id
  2035.       refresh_falcao_int_system
  2036.       @clear_lights = true
  2037.       @working_at = {} ; @grabevents = []
  2038.       if @showing_barrel and not @gamebarrel.picked
  2039.         @showing_barrel = false
  2040.         @gamebarrel.moveto(-1, -1)
  2041.         @gamebarrel.fire_duration  = 0; @gamebarrel.pushable_busy = nil
  2042.         @gamebarrel.character_name = BarrelGraphicOff
  2043.       end
  2044.       if @showing_bomb and not @gamebomb.picked
  2045.         @gamebomb.action_time = 0
  2046.         @showing_bomb = false
  2047.         @gamebomb.moveto(-1, -1)
  2048.       end
  2049.       @gamearrow.char_steps = 0 if @showing_arrow
  2050.       @showing_arrow = false if @showing_arrow
  2051.     end
  2052.     falcao_intsystem_perform_transfer
  2053.   end
  2054.  
  2055.   # Execute refresh
  2056.   def refresh_falcao_int_system
  2057.     @pushable = [];  @eve_fall = []
  2058.     @standing_pushing = false
  2059.     @player_busy = false unless @gamebomb.picked || @gamebarrel.picked
  2060.     for event in $game_map.events.values
  2061.       event.throwed = false if event.throwed
  2062.       if event.picked
  2063.         event.move_speed = @pickevdata[0]
  2064.         event.move_type  = @pickevdata[1]
  2065.         event.picked = false
  2066.         removepick_graphic
  2067.       end
  2068.       event.pushable_busy = nil if event.pushable_busy != nil
  2069.       release_target(event, sound = false) if event.pushed
  2070.     end
  2071.   end
  2072.  
  2073.   def dark_nextmap
  2074.     @intreserved_tone[0] = 1
  2075.   end
  2076.  
  2077.   def normal_nextmap
  2078.     @intreserved_tone[0] = 2
  2079.   end
  2080. end
  2081.  
  2082. # Game Event: Commands comments definition
  2083. class Game_Event < Game_Character
  2084.   attr_reader    :erased
  2085.   attr_reader    :page
  2086.   attr_accessor  :move_type
  2087.   def check_com(comment)
  2088.     return false if @list.nil? or @list.size <= 0
  2089.     for item in @list
  2090.       if item.code == 108 or item.code == 408
  2091.         if item.parameters[0].include?(comment)
  2092.           return true
  2093.         end
  2094.       end
  2095.     end
  2096.     return false
  2097.   end
  2098.  
  2099.   def check_var(comment)
  2100.     return 0 if @list.nil? or @list.size <= 0
  2101.     for item in @list
  2102.       if item.code == 108 or item.code == 408
  2103.         if item.parameters[0] =~ /#{comment}[ ]?(\d+)?/
  2104.           return $1.to_i
  2105.         end
  2106.       end
  2107.     end
  2108.     return 0
  2109.   end
  2110.  
  2111.   def check_selfsw(comment)
  2112.     return nil if @list.nil? or @list.size <= 0
  2113.     for item in @list
  2114.       next unless item.code == 108 or item.code == 408
  2115.       if item.parameters[0] =~ /#{comment} (.*)/
  2116.         return $1.to_s
  2117.       end
  2118.     end
  2119.     return nil
  2120.   end
  2121. end
  2122.  
  2123. # Sprite character
  2124. class Sprite_Character < Sprite_Base
  2125.   alias falcao123_zoom_update update
  2126.   def update
  2127.     falcao123_zoom_update
  2128.     if @zoom_x != @character.zoom_x or
  2129.       @zoom_y != @character.zoom_y
  2130.       @zoom_x = @character.zoom_x
  2131.       @zoom_y = @character.zoom_y      
  2132.       self.zoom_x = @character.zoom_x
  2133.       self.zoom_y = @character.zoom_y
  2134.     end  
  2135.   end
  2136.  
  2137.   alias falcao_intsystem_update_position update_position
  2138.   def update_position
  2139.     falcao_intsystem_update_position
  2140.     update_int_characters_positions
  2141.   end
  2142.  
  2143.   def update_int_characters_positions
  2144.     play = $game_player
  2145.      
  2146.     # Objects fixed to player position
  2147.     if @character.picked
  2148.       self.x = play.screen_x
  2149.       self.y = play.screen_y - 20
  2150.       @character.direction = play.direction
  2151.       @character.x = play.x
  2152.       @character.y = play.y
  2153.       self.z = 101
  2154.       @character.bush_depth = 0
  2155.     end
  2156.    
  2157.     if @character.is_a?(Game_Hook)
  2158.       case play.direction
  2159.       when 2 ; self.x = self.x        ; self.y = self.y + 2
  2160.       when 4 ; self.x = self.x - 4    ; self.y = self.y
  2161.       when 6 ; self.x = self.x + 4    ; self.y = self.y
  2162.       when 8 ; self.x = self.x        ; self.y = self.y - 6
  2163.       end
  2164.     end
  2165.    
  2166.     if @character.is_a?(Game_Fire)
  2167.       case play.direction
  2168.       when 2; self.x = play.screen_x      ; self.y = play.screen_y + 90 # Down
  2169.       when 4; self.x = play.screen_x - 49 ; self.y = play.screen_y + 41 # Left
  2170.       when 6; self.x = play.screen_x + 49 ; self.y = play.screen_y + 41 # Right
  2171.       when 8; self.x = play.screen_x      ; self.y = play.screen_y - 20 # Up
  2172.       end
  2173.     end
  2174.  
  2175.     if @character.is_a?(Game_Blade)
  2176.       self.x = play.screen_x
  2177.       self.y = play.screen_y
  2178.     end
  2179.   end
  2180. end
  2181.  
  2182. class << DataManager
  2183.  
  2184.   # Refresh the system if saving
  2185.   alias falcao_intsystem_save_game save_game unless $@
  2186.   def DataManager.save_game(index)
  2187.     $game_player.refresh_falcao_int_system
  2188.     $game_player.icontrol = 10
  2189.     falcao_intsystem_save_game(index)
  2190.   end
  2191.  
  2192.   # Tell the system to repositioning the working events, if game is updated
  2193.   alias falcao_intsystem_mapreload reload_map_if_updated unless $@
  2194.   def DataManager.reload_map_if_updated
  2195.     if $game_system.version_id != $data_system.version_id
  2196.       $game_player.icontrol = 10
  2197.     end
  2198.     falcao_intsystem_mapreload
  2199.   end
  2200. end
  2201.  
  2202. # Add to array all pushable events
  2203. class Game_Map
  2204.   alias falcao_intsystem_setup_events setup_events
  2205.   def setup_events(*args, &block)
  2206.     falcao_intsystem_setup_events(*args, &block)
  2207.     @events.values.each do |event|
  2208.       $game_player.pushable.push(event) if event.check_com("PUSHABLE")
  2209.      
  2210.       # Execute event repositioning
  2211.       if $game_player.icontrol > 0
  2212.         $game_player.working_at.each do |id , value|
  2213.           event.moveto(value[0], value[1]) if id == event.id
  2214.         end
  2215.       end
  2216.     end
  2217.   end
  2218.  
  2219.   # avoid damage floor when hooking
  2220.   alias falcao_intsystem_damage_floor damage_floor?
  2221.   def damage_floor?(x, y)
  2222.     return if $game_player.showing_hook
  2223.     falcao_intsystem_damage_floor(x, y)
  2224.   end
  2225.  
  2226.   def lighactive(event_id, value)
  2227.     @events[event_id].activate_light = value
  2228.   end
  2229. end
  2230.  
  2231. # Avoid tranfer in some situatios
  2232. class Game_Interpreter
  2233.   alias falcao_intsystem_command_201 command_201
  2234.   def command_201
  2235.     return if $game_player.showing_hook || $game_player.showing_fire
  2236.     falcao_intsystem_command_201
  2237.   end
  2238. end
  2239.  
  2240. # While grabing object you cannot enter menu
  2241. class Scene_Map < Scene_Base
  2242.   alias falcao_intsystem_update_call_menu update_call_menu
  2243.   def update_call_menu
  2244.     return if $game_player.grabing != nil
  2245.     falcao_intsystem_update_call_menu
  2246.   end
  2247. end
RAW Paste Data