Advertisement
Falmc

Falcao Interactive System 1.7

Aug 24th, 2012
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 29.56 KB | None | 0 0
  1. #==============================================================================#
  2. #  #*****************#                                                         #
  3. #  #*** By Falcao ***#              * Interactive system 1.7                   #
  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: August 24 2012                            #
  8. #==============================================================================#
  9.  
  10. #-------------------------------------------------------------------------------
  11. #      * Features
  12. #
  13. # - Interactive Push system
  14. # - Interactive Pick Up system
  15. # - Interactive Fall System
  16. # - Interactive Jump System
  17. # - Interactive Sensor Vision System
  18. #
  19. # The push system allow you to push events to your desire place, allow you to
  20. # press targets and easily  tell them to do something when collide, events can
  21. # press targets by themself if you give them movement
  22. #
  23. # The pick up system allow you to pick up events and move it wherever you want
  24. # when you throw the event you can easily tell them to do something afther
  25. # throwed
  26. #
  27. # The fall system allow you to fall to espeficific tiles, events fall, fallowers
  28. # fall, events can make the player fall, also you can make something happen
  29. # when an event fall
  30. #
  31. # The Jump System allow you to jump by triggering the action key, followers
  32. # jump together with the player.
  33. #
  34. # The Sensor vision system allow you to activate any event within a vision range
  35. # between the player and the event, the event deactivate when out range
  36. #-------------------------------------------------------------------------------
  37. #
  38. # License:
  39. # For non-comercial games only, for comercial games contact me to the
  40. # following email address falmc99@gmail.com
  41. #-------------------------------------------------------------------------------
  42.  
  43. module FalInt
  44.  
  45. #-------------------------------------------------------------------------------
  46. #                      * Push system *
  47. #
  48. # Write the followings lines on a event command comment tag
  49. #
  50. # PUSHABLE            - Event can be pushed wherever you want
  51. # JUMPBACK            - event jump back if you pushed against an impasable tile
  52. #
  53. # TARGET SELF SWITCH  - Put the self switch letter you want to activate
  54. #                       when collide ex: TARGET SELF SWITCH A
  55. #
  56. # TARGET SWITCH       - Put the switch id you want to activate when collide
  57. #                       ex: TARGET SWITCH 10
  58. #
  59. # TARGET VARIABLE     - Put the variable id you want to increase (+) when
  60. #                       collide ex: TARGET VARIABLE 5
  61. #
  62. # * Important info:
  63. #
  64. # Switches and variables are activated when PUSHED and TARGET collide and
  65. # they are deactivated when not colliding,  when you tranfer to another map
  66. # switches and variables the target activated reset
  67. #
  68. # TARGET events are always through on, always priority below characters and
  69. # dont start with the action key
  70. # PUSHABLE events are always direction fix off and always through off
  71. #
  72. # By default Player can push events too but you can disable or enable that
  73. # anytime with the following command
  74. #
  75. # $game_player.allowto_push = value    change value for true/false
  76. #
  77.  
  78.   # Sound played when the player push an event
  79.   PushSe = "Open1"
  80.  
  81.   # Sound played when pressing a target
  82.   PressTarget = "Switch2"
  83.  
  84.   # Sound played when realeasing the target
  85.   ReleaseTarget = "Switch1"
  86.  
  87. #-------------------------------------------------------------------------------
  88. #                         * Pick Up system *
  89. #
  90. # Write the followings lines on an event command comment tag
  91. #
  92. # PICK UP             The event is picked up when the action keys is triggered
  93. #
  94. # THROW SELF SWITCH   Put self switch letter you want to activate when you throw
  95. #                     the event ex: THROW SELF SWITCH A
  96. #
  97. # If you dont want self switch just leave it.
  98. #
  99. # You can do a lot of stuff when you throw an event, like desappear it, drop
  100. # something, use your imagination.
  101. #
  102.   # Sound played when player pick up an event
  103.   PickUpSe = "Shot1"
  104.  
  105.   # Sound played when player throw the event
  106.   ThrowSe = "Knock"
  107. #-------------------------------------------------------------------------------
  108. #                           * Fall System *
  109. #
  110.  
  111.   # Terrain tag where the player and events fall
  112.   FallTag = 6
  113.  
  114.   # Sound played when falling
  115.   FallSe = "Fall"
  116.  
  117. # Followers can fall too, events can fall too but events are no fools, they
  118. # only fall when player push them, so in order to make an event fall it must be
  119. # tagged PUSHABLE
  120. #
  121. # Write the followings lines on an event command comment tag
  122. #
  123. # FALL SWITCH        Put the switch id you want to activate when event fall
  124. #                    ex: FALL SWITCH 20
  125. #
  126. # FALL VARIABLE      Put the variable id you want to increase (+) when an
  127. #                    event fall ex: FALL VARIABLE 6
  128. #
  129. # If you dont want to activate switch or variable just leave it blank
  130. # Event is erased when they fall
  131. #
  132. # Player and followers decrease hp when they fall, default amount of hp to loose
  133. # is 100, but you can change that value anytime with the following command
  134. #
  135. #
  136. # $game_player.fallhp = value     Change value for desire hp to loose
  137. #                                 ex: $game_player.fallhp = 200
  138. #
  139. # Events can push the player in order to make him fall, write the following line
  140. # on event command comment tag: PUSH THE PLAYER the player will be jumped away
  141. # from the event.
  142. #-------------------------------------------------------------------------------
  143. #                      * Jump System
  144. #
  145. # Call the following line to activate the jump system
  146. #
  147. # $game_player.enable_jump = value      Change value for true / false
  148. #                                       ex: $game_player.enable_jump = true
  149. #
  150. # Player and followers jump together, they can jump only two tiles while
  151. # moving, if the are standing jump only at the same place, press the action key
  152. # to jump
  153.  
  154.   # Sound played when jumping
  155.   JumpSe = "Jump1"
  156. #-------------------------------------------------------------------------------
  157. #                      * Sensor Vision System
  158. #
  159. # Write the followings lines on an event command comment tag
  160. #
  161. # SENSOR VISION RANGE       Put vision range in tiles you want the event to have
  162. #                           ex: SENSOR VISION RANGE 6
  163. #
  164. # The distance is based in tiles between the game player and the event, when the
  165. # player is within the vision range a self switch is activated and it is
  166. # deactivated when the player is out of range
  167. #
  168.   # Self switch that is activated when the player is whithin the range
  169.   SensorSelfsw = "C"
  170. #-------------------------------------------------------------------------------
  171.  
  172.   # Action key, this key toggle pick up events, throw events and jump
  173.   ActionKey = :C
  174.  
  175. end
  176.  
  177. #-------------------------------------------------------------------------------
  178. #                 * Falcao Interactive System version 1.7
  179. #
  180.  
  181. # Game character base: new methods, variables and public instance variables
  182. class Game_CharacterBase
  183.   attr_accessor   :through
  184.   attr_accessor   :priority_type
  185.   attr_accessor   :opacity
  186.   attr_accessor   :move_speed
  187.   attr_accessor   :zoom_x
  188.   attr_accessor   :zoom_y
  189.   attr_accessor   :pushed
  190.   attr_accessor   :direction_fix
  191.   attr_accessor   :x
  192.   attr_accessor   :y
  193.   attr_accessor   :picked
  194.   attr_accessor   :throwed
  195.   attr_accessor   :force_move
  196.   attr_accessor   :obfalling
  197.   attr_accessor   :direction
  198.   attr_accessor   :pushable_busy
  199.   attr_accessor   :inrange
  200.   attr_accessor   :fallbyjump
  201.   alias falcao_intsystem_base_ini initialize
  202.   def initialize
  203.     falcao_intsystem_base_ini
  204.     @zoom_x = 1.0
  205.     @zoom_y = 1.0
  206.     @pushed = false
  207.     @picked = false
  208.     @throwed = false
  209.     @obfalling = 0
  210.   end
  211.  
  212.   # Pasable jump: distance measured in tiles, ignore fall terrian tiles
  213.   def jump_passable?(distance, ignore_events=false)
  214.     dir = @direction
  215.     return false if !ignore_events and collide_with_characters?(
  216.     @x + ajustxy(self)[0] * distance, @y + ajustxy(self)[1] * distance)
  217.    
  218.     return true if self.is_a?(Game_Player) and
  219.     $game_map.terrain_tag(@x + ajustxy(self)[0] * distance,
  220.     @y + ajustxy(self)[1] * distance) == FalInt::FallTag
  221.    
  222.     return true if self.is_a?(Game_Event) and self.check_com("PUSHABLE") and
  223.     $game_map.terrain_tag(@x + ajustxy(self)[0] * distance,
  224.     @y + ajustxy(self)[1] * distance) == FalInt::FallTag
  225.    
  226.     return true if map_passable?(@x, @y + distance,  dir) and dir == 2
  227.     return true if map_passable?(@x - distance, @y,  dir) and dir == 4
  228.     return true if map_passable?(@x + distance, @y,  dir) and dir == 6
  229.     return true if map_passable?(@x, @y - distance,  dir) and dir == 8
  230.     return false
  231.   end
  232.  
  233.   # Start jump: power measured in tiles
  234.   def start_jump(power)
  235.     player = self.is_a?(Game_Player)
  236.     if player
  237.       RPG::SE.new(FalInt::JumpSe,80).play
  238.       self.followers.reverse_each do |f|
  239.         break if Input.dir4 == 0
  240.         f.move_toward_player ; f.move_toward_player ; f.move_toward_player
  241.         f.jump(0,  power)  if @direction == 2
  242.         f.jump(- power, 0) if @direction == 4
  243.         f.jump(power,  0)  if @direction == 6
  244.         f.jump(0, - power) if @direction == 8
  245.       end
  246.     end
  247.     jump(0,  power)  if player ? Input.dir4 == 2 : @direction == 2
  248.     jump(- power, 0) if player ? Input.dir4 == 4 : @direction == 4
  249.     jump(power,  0)  if player ? Input.dir4 == 6 : @direction == 6
  250.     jump(0, - power) if player ? Input.dir4 == 8 : @direction == 8
  251.     jump(0, 0) if Input.dir4 == 0 and player
  252.   end
  253.  
  254.   # Jump back: power measured in tiles
  255.   def jump_back(power=1)
  256.     @direction_fix = true
  257.     jump(0, - power)       if @direction == 2
  258.     jump(power, 0)         if @direction == 4
  259.     jump(- power,  0)      if @direction == 6
  260.     jump(0, power)         if @direction == 8
  261.     @direction_fix = false
  262.   end
  263.  
  264.   # Jump forward: power measured in tiles
  265.   def jump_forward(power=1)
  266.     jump(0, power)       if @direction == 2
  267.     jump(- power, 0)     if @direction == 4
  268.     jump(power,  0)      if @direction == 6
  269.     jump(0, - power)     if @direction == 8
  270.   end
  271.  
  272.    # Ajust x y: object direction if nil take Input only for player
  273.   def ajustxy(d=nil)
  274.     push_x, push_y =   0,   1 if d.nil? ? Input.dir4 == 2 : d.direction == 2
  275.     push_x, push_y = - 1,   0 if d.nil? ? Input.dir4 == 4 : d.direction == 4
  276.     push_x, push_y =   1,   0 if d.nil? ? Input.dir4 == 6 : d.direction == 6
  277.     push_x, push_y =   0, - 1 if d.nil? ? Input.dir4 == 8 : d.direction == 8
  278.     return [push_x, push_y] if d != nil
  279.     push_x, push_y =   0,   0 if Input.dir4 == 0
  280.     return [push_x, push_y]
  281.   end
  282. end
  283.  
  284. # Game Player
  285. class Game_Player < Game_Character
  286.   include FalInt
  287.   attr_accessor   :pushable
  288.   attr_accessor   :fallhp
  289.   attr_accessor   :allowto_push
  290.   attr_accessor   :enable_jump
  291.   attr_accessor   :working_at
  292.   attr_accessor   :icontrol
  293.  
  294.   # aliasing
  295.   alias falcao_intsystem_ini initialize
  296.   alias falcao_intsystem_update update
  297.   alias falcao_intsystem_get_on_vehicle get_on_vehicle
  298.   alias falcao_intsystem_get_off_vehicle get_off_vehicle
  299.   alias falcao_intsystem_move_by_input move_by_input
  300.   alias falcao_intsystem_start_map_event start_map_event
  301.   alias falcao_intsystem_perform_transfer perform_transfer
  302.  
  303.   def initialize
  304.     falcao_intsystem_ini
  305.     @pushable = []
  306.     @eve_fall = []
  307.     @fallhp = 100
  308.     @player_busy = false
  309.     @jump_delay = 0
  310.     @allowto_push = true
  311.     @enable_jump = false
  312.     @pickup_delay = 0
  313.     @standing_pushing = false
  314.     @working_at = {}
  315.     @icontrol = 0
  316.   end
  317.  
  318.   def update
  319.     falcao_intsystem_update
  320.     update_intsystem
  321.   end
  322.  
  323.   def update_intsystem
  324.     update_push_events
  325.     update_falling
  326.     update_pick_up
  327.     update_sensor_system
  328.     perform_jump if Input.trigger?(ActionKey) and
  329.     !$game_map.interpreter.running? and @enable_jump
  330.     @jump_delay -= 1 if @jump_delay > 0
  331.     @icontrol -= 1 if @icontrol > 0
  332.   end
  333.  
  334.   #---------------------------------------------------------------------------
  335.   # * Push System
  336.   #---------------------------------------------------------------------------
  337.   # Player push event object
  338.   def player_push(event)
  339.     event.turn_away_from_player
  340.     event.jump_back if event.check_com("JUMPBACK") and
  341.     event.pushable_busy.nil? and not event.jump_passable?(1, true)
  342.     if event.passable?(event.x, event.y, @direction) and !event.moving?
  343.       unless event.x == @x and event.y == @y
  344.         event.move_away_from_player
  345.         RPG::SE.new(PushSe,80).play
  346.       end
  347.     end
  348.   end
  349.  
  350.   # Push the target
  351.   def press_target(event, sound=true)
  352.     RPG::SE.new(PressTarget,80).play if sound
  353.     self_sw = event.check_selfsw("TARGET SELF SWITCH")
  354.     if self_sw != nil
  355.       $game_self_switches[[$game_map.map_id, event.id, self_sw]] = true
  356.     end
  357.     switch = event.check_var("TARGET SWITCH")
  358.     $game_switches[switch] = true if switch != 0
  359.     variable = event.check_var("TARGET VARIABLE")
  360.     $game_variables[variable] += 1 if variable != 0
  361.     event.pushed = true
  362.     event.refresh
  363.   end
  364.  
  365.   # Release the target
  366.   def release_target(event, sound=true)
  367.     RPG::SE.new(ReleaseTarget, 80).play if sound
  368.     self_sw = event.check_selfsw("TARGET SELF SWITCH")
  369.     if self_sw != nil
  370.       $game_self_switches[[$game_map.map_id, event.id, self_sw]] = false
  371.     end
  372.     switch = event.check_var("TARGET SWITCH")
  373.     $game_switches[switch] = false if switch != 0
  374.     variable = event.check_var("TARGET VARIABLE")
  375.     $game_variables[variable] -= 1 if variable != 0
  376.     event.pushed = false
  377.     event.refresh
  378.   end
  379.  
  380.   # Get float info necesary to release a target
  381.   def afloatxy(object)
  382.     push_x, push_y =   0,  - 0.5  if object.direction == 2 # down
  383.     push_x, push_y =   0.5,   0   if object.direction == 4 # left
  384.     push_x, push_y = - 0.5,   0   if object.direction == 6 # right
  385.     push_x, push_y =   0,     0.5 if object.direction == 8 # up
  386.     return [push_x, push_y]
  387.   end
  388.  
  389.   # Update push events
  390.   def update_push_events
  391.     return if @vehicle_getting_on || in_boat? || in_ship? || in_airship?
  392.    
  393.     for event in $game_map.events.values
  394.       if event.check_com("PUSHABLE") and !self.moving?
  395.         event.direction_fix = false if event.direction_fix
  396.         if event.x == @x + ajustxy[0] and event.y == @y + ajustxy[1]
  397.           player_push(event)
  398.         end
  399.       end
  400.      
  401.       if event.check_selfsw("TARGET SELF SWITCH") != nil
  402.         event.through = true if not event.through
  403.         event.priority_type = 0 if event.priority_type != 0
  404.        
  405.         # Player push targets
  406.         if @allowto_push
  407.           if event.real_x == @real_x and event.real_y == @real_y and
  408.             not event.pushed
  409.             press_target(event, @icontrol == 0)
  410.             @standing_pushing = true
  411.           elsif event.pushed
  412.             if event.real_x == @real_x + afloatxy(self)[0] and
  413.               event.real_y == @real_y + afloatxy(self)[1]
  414.               release_target(event)
  415.               @standing_pushing = false
  416.             end
  417.           end
  418.         end
  419.        
  420.         @pushable.each do |ev|
  421.           ev.through = false if ev.through
  422.           # release a pushed target if the player pick up the object
  423.           if ev.check_com("PICK UP")
  424.             @working_at.delete(ev.id) if !ev.pushable_busy.nil? and
  425.             ev.x == @x + ajustxy(self)[0] and ev.y == @y + ajustxy(self)[1] and
  426.             Input.trigger?(ActionKey)
  427.             if event.pushed and event.x == @x + ajustxy(self)[0] and event.y ==
  428.               @y + ajustxy(self)[1] and Input.trigger?(ActionKey)
  429.               release_target(event)
  430.               break
  431.             end
  432.           end
  433.          
  434.           # events pushing and releasing conditions
  435.           if event.real_x == ev.real_x and event.real_y == ev.real_y and
  436.             not event.pushed and not ev.picked and not ev.throwed
  437.             press_target(event, @icontrol == 0) ; ev.pushable_busy = true
  438.             @working_at[ev.id] = [ev.x, ev.y]
  439.           elsif event.pushed
  440.             break if event.real_x == ev.real_x and event.real_y == ev.real_y
  441.             if event.real_x == ev.real_x + afloatxy(ev)[0] and
  442.               event.real_y == ev.real_y + afloatxy(ev)[1] and not ev.picked
  443.               release_target(event) ; ev.pushable_busy = nil
  444.               @working_at.delete(ev.id)
  445.             end
  446.           end
  447.         end
  448.       end
  449.     end
  450.   end
  451.  
  452.   #---------------------------------------------------------------------------
  453.   # * Pick up System  
  454.   #---------------------------------------------------------------------------
  455.   def update_pick_up
  456.     return if @vehicle_getting_on || in_boat? || in_ship? || in_airship?
  457.     @pickup_delay -= 1 if @pickup_delay > 0
  458.     return if @pickup_delay > 0
  459.     for event in $game_map.events.values
  460.       event.x = @x if event.picked
  461.       event.y = @y if event.picked
  462.    
  463.       if event.throwed  # if throwed do this
  464.         if event.force_move != nil and event.jump_passable?(1, true)
  465.           event.start_jump(1)
  466.           event.force_move = nil
  467.         end
  468.        
  469.         unless event.jumping?
  470.           RPG::SE.new(ThrowSe,80).play
  471.           self_sw = event.check_selfsw("THROW SELF SWITCH")
  472.           if self_sw != nil
  473.             $game_self_switches[[$game_map.map_id, event.id, self_sw]] = true
  474.             event.refresh
  475.             event.direction = event.page.graphic.direction
  476.             changing = true
  477.           end
  478.           @player_busy = event.throwed = false
  479.           event.jump(0,  0) if changing.nil?
  480.           changing = nil
  481.         end
  482.       end
  483.      
  484.       if event.check_com("PICK UP")
  485.         event.priority_type = 1 if event.priority_type == 0
  486.         event.direction_fix = false if event.direction_fix
  487.        
  488.         # Throw object
  489.         if Input.trigger?(ActionKey) and  event.picked and
  490.           !$game_map.interpreter.running?
  491.           event.move_speed = @lastesp
  492.           if    event.jump_passable?(4) ;  event.start_jump(4)
  493.           elsif event.jump_passable?(3) ;  event.start_jump(3)
  494.           elsif event.jump_passable?(2) ;  event.start_jump(2)
  495.           else                          ;  event.force_move = true
  496.           end
  497.           event.picked = false
  498.           event.move_type = @lasmovetype
  499.           event.throwed = true
  500.         end
  501.        
  502.         # Pick up object
  503.         if Input.trigger?(ActionKey) and event.x == @x + ajustxy(self)[0] and
  504.           event.y == @y + ajustxy(self)[1] and !event.picked and
  505.           not self.moving? and not @player_busy
  506.           RPG::SE.new(PickUpSe, 80).play
  507.           @lasmovetype = event.move_type
  508.           event.move_type = 0
  509.           @lastesp = event.move_speed
  510.           event.move_speed = 6
  511.           @player_busy = event.picked = true
  512.           @pickup_delay = 5
  513.         end
  514.       end
  515.     end
  516.   end
  517.  
  518.   #---------------------------------------------------------------------------
  519.   # * Fall System  
  520.   #---------------------------------------------------------------------------
  521.   # events start falling
  522.   def start_falling(event)
  523.     event.obfalling = 1
  524.     event.move_speed = 4.5
  525.     event.through = true
  526.     event.fallbyjump.nil? ? event.move_away_from_player : event.fallbyjump = nil
  527.     RPG::SE.new(FallSe,80).play
  528.     @eve_fall.push(event) unless @eve_fall.include?(event)
  529.     @eve_fall = @eve_fall.uniq
  530.     @player_busy = event.picked = false if event.picked
  531.   end
  532.  
  533.   # Player start falling
  534.   def player_start_falling
  535.     $game_map.events.values.each do |event|
  536.       if event.picked and not event.check_com("PUSHABLE")
  537.         start_falling(event)
  538.       end
  539.     end
  540.     self.through = true
  541.     set_direction(Input.dir4) if Input.dir4 != 0
  542.     self.move_forward if @fallbyjump.nil?
  543.     RPG::SE.new(FallSe,80).play
  544.     @last_speed = self.move_speed
  545.     self.move_speed = 5
  546.     @obfalling = 100
  547.   end
  548.  
  549.   def update_falling
  550.     return if @vehicle_getting_on || in_boat? || in_ship? || in_airship?
  551.    
  552.     # Events fall
  553.     for event in $game_map.events.values
  554.       if event.check_com("PUSHABLE")
  555.         @pushable.push(event) unless @pushable.include?(event)
  556.         if $game_map.terrain_tag(event.real_x + ajustxy[0],
  557.           event.real_y + ajustxy[1]) == FallTag  and
  558.           event.real_x == @real_x + ajustxy[0] and
  559.           event.real_y == @real_y + ajustxy[1] and event.obfalling == 0
  560.           start_falling(event) unless event.moving? and self.moving?
  561.         elsif $game_map.terrain_tag(event.real_x, event.real_y) == FallTag and
  562.           event.obfalling == 0
  563.           unless event.moving?
  564.             event.fallbyjump = true
  565.             start_falling(event)
  566.           end
  567.         end
  568.       end
  569.      
  570.       # Events push the player away
  571.       if event.check_com("PUSH THE PLAYER")
  572.         event.direction_fix = false if event.direction_fix
  573.         if @jump_delay == 0 and @real_x == event.real_x + ajustxy(event)[0] and
  574.           @real_y == event.real_y + ajustxy(event)[1] and @obfalling == 0
  575.          
  576.           @direction = event.direction
  577.           move_forward
  578.           followers.gather
  579.           if jump_passable?(1, ignore_events = true)
  580.             @lastpxy = [@x, @y]
  581.             jump_forward(1) ; @jump_delay = 20
  582.           end
  583.         end
  584.       end
  585.     end
  586.    
  587.     # event falling effect
  588.     @eve_fall.each do |ev|
  589.       if ev.obfalling > 0
  590.         ev.zoom_x -= 0.06
  591.         ev.zoom_y -= 0.06
  592.         if ev.zoom_x <= 0.06  and !ev.erased
  593.           switch = ev.check_var("FALL SWITCH")
  594.           $game_switches[switch] = true if switch != 0
  595.           variable = ev.check_var("FALL VARIABLE")
  596.           $game_variables[variable] += 1 if variable != 0
  597.           event.refresh if switch != 0 || variable != 0
  598.           ev.erase
  599.           @eve_fall.delete_if { |e| e == ev }
  600.           event.obfalling = 0
  601.         end
  602.       end
  603.     end
  604.  
  605.    # followes fall with the player
  606.     self.followers.reverse_each do |f|
  607.       if @obfalling > 0
  608.         f.zoom_x = @zoom_x
  609.         f.zoom_y = @zoom_y
  610.         f.move_toward_player ; f.move_toward_player ; f.move_toward_player
  611.       end
  612.     end
  613.  
  614.     # Player fall
  615.     if $game_map.terrain_tag(@real_x, @real_y) == FallTag and
  616.       @obfalling == 0 and not moving? and not jumping?
  617.       @fallbyjump = true
  618.       player_start_falling
  619.     elsif $game_map.terrain_tag(@real_x + ajustxy[0], @real_y + ajustxy[1]) ==
  620.       FallTag and @obfalling == 0 and !self.moving?
  621.       player_start_falling
  622.     end
  623.    
  624.     if @obfalling > 0
  625.       @obfalling -= 1
  626.       if @obfalling > 30 and @obfalling < 100
  627.         self.zoom_x -= 0.06; self.zoom_y -= 0.06
  628.       end
  629.       if @obfalling == 40
  630.         @fallbyjump.nil? ? self.move_backward : moveto(@lastpxy[0],
  631.         @lastpxy[1]) rescue nil
  632.         @fallbyjump = nil
  633.       end
  634.       if @obfalling == 30
  635.         self.zoom_x = 1.0
  636.         self.zoom_y = 1.0
  637.         self.through = false
  638.         $game_party.members.each do |actor|
  639.           actor.hp -= @fallhp
  640.         end
  641.       end
  642.       self.opacity = (self.opacity + 70) % 160 + 60 if @obfalling < 40
  643.       self.opacity = 255 if @obfalling == 0
  644.       self.move_speed = @last_speed if @obfalling == 0
  645.     end
  646.   end
  647.  
  648.   #---------------------------------------------------------------------------
  649.   # * Jump System
  650.   #---------------------------------------------------------------------------
  651.   def perform_jump
  652.     return if @standing_pushing || self.jumping? || @obfalling > 0 ||
  653.     in_airship? || @vehicle_getting_on || in_boat? || in_ship? ||
  654.     @jump_delay > 0 || @player_busy
  655.     $game_map.events.values.each do |event|
  656.       if event.pushed
  657.         return if event.x == @x and event.y == @y
  658.         if event.x == @x + ajustxy(self)[0] and event.y == @y + ajustxy(self)[1]
  659.           return
  660.         end
  661.       end
  662.     end
  663.     @lastpxy = [@x, @y]
  664.     if    jump_passable?(2)  ;   start_jump(2)
  665.     elsif jump_passable?(1)  ;   start_jump(1)
  666.     else                     ;   start_jump(0)            
  667.     end
  668.     @jump_delay = 16
  669.   end
  670.  
  671.   #---------------------------------------------------------------------------
  672.   # * Sensor Vision System
  673.   #---------------------------------------------------------------------------
  674.   def sensor_area?(parent, target, size)
  675.     distance = (parent.x - target.x).abs + (parent.y - target.y).abs
  676.     enable   = (distance <= size-1)
  677.     return true if enable
  678.     return false
  679.   end
  680.  
  681.   def update_sensor_system
  682.     $game_map.events.values.each do |event|
  683.       range = event.check_var("SENSOR VISION RANGE")
  684.       if range != 0
  685.         if sensor_area?(self, event, range)
  686.           data = [$game_map.map_id, event.id, SensorSelfsw]
  687.           if event.inrange.nil? and !$game_self_switches[[data[0], data[1],
  688.             data[2]]]
  689.             $game_self_switches[[data[0], data[1], data[2]]] = true
  690.             event.inrange = true
  691.           end
  692.         elsif event.inrange != nil
  693.           data = [$game_map.map_id, event.id, SensorSelfsw]
  694.           if $game_self_switches[[data[0], data[1], data[2]]]
  695.             $game_self_switches[[data[0], data[1], data[2]]] = false
  696.             event.inrange = nil
  697.           end
  698.         end
  699.       end
  700.     end
  701.   end
  702.  
  703.   #-----------------------------------------------------------------------------
  704.   #                   * Flow control
  705.   #-----------------------------------------------------------------------------
  706.   def get_on_vehicle
  707.     return if @player_busy
  708.     falcao_intsystem_get_on_vehicle
  709.   end
  710.  
  711.   def get_off_vehicle
  712.     return if $game_map.terrain_tag(@x, @y) == FallTag
  713.     falcao_intsystem_get_off_vehicle
  714.   end
  715.  
  716.   def move_by_input
  717.     return if @obfalling > 0
  718.     falcao_intsystem_move_by_input
  719.   end
  720.  
  721.   def start_map_event(x, y, triggers, normal)
  722.     $game_map.events_xy(x, y).each do |ev|
  723.       return if ev.check_selfsw("TARGET SELF SWITCH") != nil
  724.     end  
  725.     falcao_intsystem_start_map_event(x, y, triggers, normal)
  726.   end
  727.  
  728.   # refresh all the system if the map is not the same
  729.   def perform_transfer
  730.     if $game_map.map_id !=  @new_map_id
  731.       refresh_falcao_int_system
  732.       @working_at = {}
  733.     end
  734.     falcao_intsystem_perform_transfer
  735.   end
  736.  
  737.   # Execute refresh
  738.   def refresh_falcao_int_system
  739.     @pushable = @eve_fall = []
  740.     @player_busy = @standing_pushing = false
  741.     for event in $game_map.events.values
  742.       event.throwed = false if event.throwed
  743.       if event.picked
  744.         event.move_speed = @lastesp
  745.         event.move_type  = @lasmovetype
  746.         event.picked = false
  747.       end
  748.       event.pushable_busy = nil if event.pushable_busy != nil
  749.       release_target(event, sound = false) if event.pushed
  750.     end
  751.   end
  752. end
  753.  
  754. # Game Event: Commands comments definition
  755. class Game_Event < Game_Character
  756.   attr_reader    :erased
  757.   attr_reader    :page
  758.   attr_accessor  :move_type
  759.   def check_com(comment)
  760.     return false if @list.nil? or @list.size <= 0
  761.     for item in @list
  762.       if item.code == 108 or item.code == 408
  763.         if item.parameters[0].include?(comment)
  764.           return true
  765.         end
  766.       end
  767.     end
  768.     return false
  769.   end
  770.  
  771.   def check_var(comment)
  772.     return 0 if @list.nil? or @list.size <= 0
  773.     for item in @list
  774.       if item.code == 108 or item.code == 408
  775.         if item.parameters[0] =~ /#{comment}[ ]?(\d+)?/
  776.           return $1.to_i
  777.         end
  778.       end
  779.     end
  780.     return 0
  781.   end
  782.  
  783.   def check_selfsw(comment)
  784.     return nil if @list.nil? or @list.size <= 0
  785.     for item in @list
  786.       next unless item.code == 108 or item.code == 408
  787.       if item.parameters[0] =~ /#{comment} (.*)/
  788.         return $1.to_s
  789.       end
  790.     end
  791.     return nil
  792.   end
  793. end
  794.  
  795. # Sprite character
  796. class Sprite_Character < Sprite_Base
  797.   alias falcao123_zoom_update update
  798.   def update
  799.     falcao123_zoom_update
  800.     if @zoom_x != @character.zoom_x or
  801.       @zoom_y != @character.zoom_y
  802.       @zoom_x = @character.zoom_x
  803.       @zoom_y = @character.zoom_y      
  804.       self.zoom_x = @character.zoom_x
  805.       self.zoom_y = @character.zoom_y
  806.     end  
  807.   end
  808.  
  809.   # Adjust a picked event to the game player
  810.   alias falcao_intsystem_update_position update_position
  811.   def update_position
  812.     falcao_intsystem_update_position
  813.     if @character.picked
  814.       self.x = $game_player.screen_x
  815.       self.y = $game_player.screen_y - 16
  816.       @character.direction = $game_player.direction
  817.     end
  818.   end
  819. end
  820.  
  821. class << DataManager
  822.  
  823.   # Refresh the system if saving
  824.   alias falcao_intsystem_save_game save_game unless $@
  825.   def DataManager.save_game(index)
  826.     $game_player.refresh_falcao_int_system
  827.     $game_player.icontrol = 10
  828.     falcao_intsystem_save_game(index)
  829.   end
  830.  
  831.   # Tell the system to repositioning the working events, if game is updated
  832.   alias falcao_intsystem_mapreload reload_map_if_updated unless $@
  833.   def DataManager.reload_map_if_updated
  834.     if $game_system.version_id != $data_system.version_id
  835.       $game_player.icontrol = 10
  836.     end
  837.     falcao_intsystem_mapreload
  838.   end
  839. end
  840.  
  841. # Add to array all pushable events
  842. class Game_Map
  843.   alias falcao_intsystem_setup_events setup_events
  844.   def setup_events(*args, &block)
  845.     falcao_intsystem_setup_events(*args, &block)
  846.     @events.values.each do |event|
  847.       $game_player.pushable.push(event) if event.check_com("PUSHABLE")
  848.      
  849.       # Execute event repositioning
  850.       if $game_player.icontrol > 0
  851.         $game_player.working_at.each do |id , value|
  852.           event.moveto(value[0], value[1]) if id == event.id
  853.         end
  854.       end
  855.     end
  856.   end
  857. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement