Advertisement
Falmc

Untitled

Aug 24th, 2012
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 29.45 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. #      * Caracteristicas
  12. #
  13. # - Sistema interactivo de Empuje
  14. # - Sistema interactivo de Levante
  15. # - Sistema interactivo de Caidas
  16. # - Sistema interactivo de Saltar
  17. # - Sistema interactivo de Rango de Vision
  18. #
  19. # El sistema de empuje te permite empujar eventos al lugar que quieras, tambien
  20. # permite eventos de blanco y que al colicionar suceda algo, los eventos pueden
  21. # colicionarse por si solos con los blancos si les das movimiento
  22. #
  23. # El sistema de levante te permite levantar eventos y llevartelos al lugar que
  24. # que quieras, una vez levantado los podes tirar y podes decirle al script
  25. # que haga algo cuanbdo lo tiras.
  26. #
  27. # El sistema de caidas te permite caer al vacio en tiles especificos, los segi-
  28. # dores y eventos pueden caer, eventos pueden hacer caer al jugador al vacio.
  29. # tambien podes hacer que al tirar une vento al vacio suceda algo.
  30. #
  31. # El sistema de saltar te permite saltar al apretar la tecla de accion que por
  32. # defecto es la tecla C, los segidores tambien santan.
  33. #
  34. # El sistema de rango de vision te permite activar eventos que esten a cierto
  35. # rango del jugador, se desactivan cuando el jugador sale del rango
  36. #-------------------------------------------------------------------------------
  37. #
  38. # Licensia:
  39. # Este script es para juegos no comerciales, si tu proposito  es para juegos
  40. # comerciales favor de contactarme falmc99@gmail.com
  41. #-------------------------------------------------------------------------------
  42.  
  43. module FalInt
  44.  
  45. #-------------------------------------------------------------------------------
  46. #                      * Sistema de Empuje *
  47. #
  48. # Escribe las siguientes lineas en los comentarios de evento
  49. #
  50. # PUSHABLE            - El evento se convierte en empujable
  51. # JUMPBACK            - El evento salta atras si lo empujas contra una pared
  52. #
  53. # TARGET SELF SWITCH  - Poner el interruptor local a activar cuando colicionan
  54. #                       ejemplo: TARGET SELF SWITCH A
  55. #
  56. # TARGET SWITCH       - Poner el interruptor que quieres activar cuando
  57. #                       colicionan ejem: TARGET SWITCH 10
  58. #
  59. # TARGET VARIABLE     - Poner id de variable que va sumar (+) cuando colicionan
  60. #                       ejemplo: TARGET VARIABLE 5
  61. #
  62. # * Nota:
  63. #
  64. # Interruptores y variables son activados cuando un PUSHABLE y TARGET colicionan
  65. # y son desactivados cuando no colicionan,  cuando te transportas a otro mapa
  66. # esos interruptores y variables se resetean
  67. #
  68. # Es importante saber que esos eventos tomaran propiedades especiales como,
  69. # direcion fija siempre falsa y atravezable siempre off
  70. #
  71. # Por defecto el jugador puede colicionar con los TARGET y activarlo pero
  72. # puedes cambiar eso con el siguiente comando
  73. #
  74. # $game_player.allowto_push = value    cambiar valor a true / false
  75. #
  76.  
  77.   # Sonido al empujar un evento
  78.   PushSe = "Open1"
  79.  
  80.   # Sonido cuando colicionan
  81.   PressTarget = "Switch2"
  82.  
  83.   # Sonido cuando no colicionan
  84.   ReleaseTarget = "Switch1"
  85.  
  86. #-------------------------------------------------------------------------------
  87. #                         * El Sistema de Levante *
  88. #
  89. # Escribe las siguientes lineas en los comentarios de evento
  90. #
  91. # PICK UP             El evento se vuelve levantable cuando apretas la tecla
  92. #
  93. # THROW SELF SWITCH   Poner interruptor local que se quiera activar cuando tiras
  94. #                     el evento ejem: THROW SELF SWITCH A
  95. #
  96. # Si no quieres activar ningun interruptor local dejalo asi
  97. #
  98. # Podes hacer un monton de cosas con este sistema, usa tu imaginacion
  99. #
  100.   # Sonido al levantar un evento
  101.   PickUpSe = "Shot1"
  102.  
  103.   # Sonido al tirar un evento
  104.   ThrowSe = "Knock"
  105. #-------------------------------------------------------------------------------
  106. #                           * El sistema de caidas *
  107. #
  108.  
  109.   # Terreno donde el jugador y eventos caen
  110.   FallTag = 6
  111.  
  112.   # Sonido cuando se esta cayendo
  113.   FallSe = "Fall"
  114.  
  115. # Segidores y eventos pueden caer tambien, pero los eventos no son tontos ellos
  116. # caen solo si el jugador los empuja y caen solo si son PUSHABLES
  117. #
  118. # Escribe las siguientes lineas en los comentarios de evento
  119. #
  120. # FALL SWITCH        Poner id del interruptor a activar cuando un evento cae
  121. #                    ejemplo: FALL SWITCH 20
  122. #
  123. # FALL VARIABLE      Poner id de variable que se va sumar (+) cuando un evento
  124. #                    cae ejemplo: FALL VARIABLE 6
  125. #
  126. # Si no quieres activar interruptor o variable dejalo asi en blanco
  127. # los eventos son borrados cuando caen
  128. #
  129. # El hp del jugador y sus segidores bajan cuando caen al vacio, por defecto
  130. # se pierde 100, pero podes cambiar ese valor con el siguiente comando
  131. #
  132. # $game_player.fallhp = valor     Cambiar valor por el valor deceado
  133. #                                 ejem: $game_player.fallhp = 200
  134. #
  135. # Eventos pueden empujar al jugador para hacerlo caer, escribir la siguiente
  136. # linea en los comentarios de vento: PUSH THE PLAYER el jugador sera empujado
  137. #-------------------------------------------------------------------------------
  138. #                      * El sistema de Saltar
  139. #
  140. # Llamar la siguiente linea de script para activar el salto
  141. #
  142. # $game_player.enable_jump = value      Cambiar value por true / false
  143. #                                       ejem: $game_player.enable_jump = true
  144. #
  145. # Los segidores saltan con el jugador, solo peuden saltar 2 tiles como maximo
  146. # se puede saltar solo al presionar la tecla de accion
  147.  
  148.   # Sonido al saltar
  149.   JumpSe = "Jump1"
  150. #-------------------------------------------------------------------------------
  151. #                      * Sistema de Rango de Vision
  152. #
  153. # Escribe las siguientes lineas en los comentarios de evento
  154. #
  155. # SENSOR VISION RANGE       POner el rango de vision en tiles que el evento va
  156. #                           tener ejem: SENSOR VISION RANGE 6
  157. #
  158. # La distancia es basada entre el jugador y el evento, mientras se esta en rango
  159. # el evento activa un interruptor local, y cuando se sale de rango lo desactiva
  160. #
  161.   # Interruptor local que se activa cuando se esta en rango
  162.   SensorSelfsw = "C"
  163. #-------------------------------------------------------------------------------
  164.  
  165.   # Telcla de accion
  166.   ActionKey = :C
  167.  
  168. end
  169.  
  170. #-------------------------------------------------------------------------------
  171. #                 * Falcao Interactive System version 1.7
  172. #
  173.  
  174. # Game character base: new methods, variables and public instance variables
  175. class Game_CharacterBase
  176.   attr_accessor   :through
  177.   attr_accessor   :priority_type
  178.   attr_accessor   :opacity
  179.   attr_accessor   :move_speed
  180.   attr_accessor   :zoom_x
  181.   attr_accessor   :zoom_y
  182.   attr_accessor   :pushed
  183.   attr_accessor   :direction_fix
  184.   attr_accessor   :x
  185.   attr_accessor   :y
  186.   attr_accessor   :picked
  187.   attr_accessor   :throwed
  188.   attr_accessor   :force_move
  189.   attr_accessor   :obfalling
  190.   attr_accessor   :direction
  191.   attr_accessor   :pushable_busy
  192.   attr_accessor   :inrange
  193.   attr_accessor   :fallbyjump
  194.   alias falcao_intsystem_base_ini initialize
  195.   def initialize
  196.     falcao_intsystem_base_ini
  197.     @zoom_x = 1.0
  198.     @zoom_y = 1.0
  199.     @pushed = false
  200.     @picked = false
  201.     @throwed = false
  202.     @obfalling = 0
  203.   end
  204.  
  205.   # Pasable jump: distance measured in tiles, ignore fall terrian tiles
  206.   def jump_passable?(distance, ignore_events=false)
  207.     dir = @direction
  208.     return false if !ignore_events and collide_with_characters?(
  209.     @x + ajustxy(self)[0] * distance, @y + ajustxy(self)[1] * distance)
  210.    
  211.     return true if self.is_a?(Game_Player) and
  212.     $game_map.terrain_tag(@x + ajustxy(self)[0] * distance,
  213.     @y + ajustxy(self)[1] * distance) == FalInt::FallTag
  214.    
  215.     return true if self.is_a?(Game_Event) and self.check_com("PUSHABLE") and
  216.     $game_map.terrain_tag(@x + ajustxy(self)[0] * distance,
  217.     @y + ajustxy(self)[1] * distance) == FalInt::FallTag
  218.    
  219.     return true if map_passable?(@x, @y + distance,  dir) and dir == 2
  220.     return true if map_passable?(@x - distance, @y,  dir) and dir == 4
  221.     return true if map_passable?(@x + distance, @y,  dir) and dir == 6
  222.     return true if map_passable?(@x, @y - distance,  dir) and dir == 8
  223.     return false
  224.   end
  225.  
  226.   # Start jump: power measured in tiles
  227.   def start_jump(power)
  228.     player = self.is_a?(Game_Player)
  229.     if player
  230.       RPG::SE.new(FalInt::JumpSe,80).play
  231.       self.followers.reverse_each do |f|
  232.         break if Input.dir4 == 0
  233.         f.move_toward_player ; f.move_toward_player ; f.move_toward_player
  234.         f.jump(0,  power)  if @direction == 2
  235.         f.jump(- power, 0) if @direction == 4
  236.         f.jump(power,  0)  if @direction == 6
  237.         f.jump(0, - power) if @direction == 8
  238.       end
  239.     end
  240.     jump(0,  power)  if player ? Input.dir4 == 2 : @direction == 2
  241.     jump(- power, 0) if player ? Input.dir4 == 4 : @direction == 4
  242.     jump(power,  0)  if player ? Input.dir4 == 6 : @direction == 6
  243.     jump(0, - power) if player ? Input.dir4 == 8 : @direction == 8
  244.     jump(0, 0) if Input.dir4 == 0 and player
  245.   end
  246.  
  247.   # Jump back: power measured in tiles
  248.   def jump_back(power=1)
  249.     @direction_fix = true
  250.     jump(0, - power)       if @direction == 2
  251.     jump(power, 0)         if @direction == 4
  252.     jump(- power,  0)      if @direction == 6
  253.     jump(0, power)         if @direction == 8
  254.     @direction_fix = false
  255.   end
  256.  
  257.   # Jump forward: power measured in tiles
  258.   def jump_forward(power=1)
  259.     jump(0, power)       if @direction == 2
  260.     jump(- power, 0)     if @direction == 4
  261.     jump(power,  0)      if @direction == 6
  262.     jump(0, - power)     if @direction == 8
  263.   end
  264.  
  265.    # Ajust x y: object direction if nil take Input only for player
  266.   def ajustxy(d=nil)
  267.     push_x, push_y =   0,   1 if d.nil? ? Input.dir4 == 2 : d.direction == 2
  268.     push_x, push_y = - 1,   0 if d.nil? ? Input.dir4 == 4 : d.direction == 4
  269.     push_x, push_y =   1,   0 if d.nil? ? Input.dir4 == 6 : d.direction == 6
  270.     push_x, push_y =   0, - 1 if d.nil? ? Input.dir4 == 8 : d.direction == 8
  271.     return [push_x, push_y] if d != nil
  272.     push_x, push_y =   0,   0 if Input.dir4 == 0
  273.     return [push_x, push_y]
  274.   end
  275. end
  276.  
  277. # Game Player
  278. class Game_Player < Game_Character
  279.   include FalInt
  280.   attr_accessor   :pushable
  281.   attr_accessor   :fallhp
  282.   attr_accessor   :allowto_push
  283.   attr_accessor   :enable_jump
  284.   attr_accessor   :working_at
  285.   attr_accessor   :icontrol
  286.  
  287.   # aliasing
  288.   alias falcao_intsystem_ini initialize
  289.   alias falcao_intsystem_update update
  290.   alias falcao_intsystem_get_on_vehicle get_on_vehicle
  291.   alias falcao_intsystem_get_off_vehicle get_off_vehicle
  292.   alias falcao_intsystem_move_by_input move_by_input
  293.   alias falcao_intsystem_start_map_event start_map_event
  294.   alias falcao_intsystem_perform_transfer perform_transfer
  295.  
  296.   def initialize
  297.     falcao_intsystem_ini
  298.     @pushable = []
  299.     @eve_fall = []
  300.     @fallhp = 100
  301.     @player_busy = false
  302.     @jump_delay = 0
  303.     @allowto_push = true
  304.     @enable_jump = false
  305.     @pickup_delay = 0
  306.     @standing_pushing = false
  307.     @working_at = {}
  308.     @icontrol = 0
  309.   end
  310.  
  311.   def update
  312.     falcao_intsystem_update
  313.     update_intsystem
  314.   end
  315.  
  316.   def update_intsystem
  317.     update_push_events
  318.     update_falling
  319.     update_pick_up
  320.     update_sensor_system
  321.     perform_jump if Input.trigger?(ActionKey) and
  322.     !$game_map.interpreter.running? and @enable_jump
  323.     @jump_delay -= 1 if @jump_delay > 0
  324.     @icontrol -= 1 if @icontrol > 0
  325.   end
  326.  
  327.   #---------------------------------------------------------------------------
  328.   # * Push System
  329.   #---------------------------------------------------------------------------
  330.   # Player push event object
  331.   def player_push(event)
  332.     event.turn_away_from_player
  333.     event.jump_back if event.check_com("JUMPBACK") and
  334.     event.pushable_busy.nil? and not event.jump_passable?(1, true)
  335.     if event.passable?(event.x, event.y, @direction) and !event.moving?
  336.       unless event.x == @x and event.y == @y
  337.         event.move_away_from_player
  338.         RPG::SE.new(PushSe,80).play
  339.       end
  340.     end
  341.   end
  342.  
  343.   # Push the target
  344.   def press_target(event, sound=true)
  345.     RPG::SE.new(PressTarget,80).play if sound
  346.     self_sw = event.check_selfsw("TARGET SELF SWITCH")
  347.     if self_sw != nil
  348.       $game_self_switches[[$game_map.map_id, event.id, self_sw]] = true
  349.     end
  350.     switch = event.check_var("TARGET SWITCH")
  351.     $game_switches[switch] = true if switch != 0
  352.     variable = event.check_var("TARGET VARIABLE")
  353.     $game_variables[variable] += 1 if variable != 0
  354.     event.pushed = true
  355.     event.refresh
  356.   end
  357.  
  358.   # Release the target
  359.   def release_target(event, sound=true)
  360.     RPG::SE.new(ReleaseTarget, 80).play if sound
  361.     self_sw = event.check_selfsw("TARGET SELF SWITCH")
  362.     if self_sw != nil
  363.       $game_self_switches[[$game_map.map_id, event.id, self_sw]] = false
  364.     end
  365.     switch = event.check_var("TARGET SWITCH")
  366.     $game_switches[switch] = false if switch != 0
  367.     variable = event.check_var("TARGET VARIABLE")
  368.     $game_variables[variable] -= 1 if variable != 0
  369.     event.pushed = false
  370.     event.refresh
  371.   end
  372.  
  373.   # Get float info necesary to release a target
  374.   def afloatxy(object)
  375.     push_x, push_y =   0,  - 0.5  if object.direction == 2 # down
  376.     push_x, push_y =   0.5,   0   if object.direction == 4 # left
  377.     push_x, push_y = - 0.5,   0   if object.direction == 6 # right
  378.     push_x, push_y =   0,     0.5 if object.direction == 8 # up
  379.     return [push_x, push_y]
  380.   end
  381.  
  382.   # Update push events
  383.   def update_push_events
  384.     return if @vehicle_getting_on || in_boat? || in_ship? || in_airship?
  385.    
  386.     for event in $game_map.events.values
  387.       if event.check_com("PUSHABLE") and !self.moving?
  388.         event.direction_fix = false if event.direction_fix
  389.         if event.x == @x + ajustxy[0] and event.y == @y + ajustxy[1]
  390.           player_push(event)
  391.         end
  392.       end
  393.      
  394.       if event.check_selfsw("TARGET SELF SWITCH") != nil
  395.         event.through = true if not event.through
  396.         event.priority_type = 0 if event.priority_type != 0
  397.        
  398.         # Player push targets
  399.         if @allowto_push
  400.           if event.real_x == @real_x and event.real_y == @real_y and
  401.             not event.pushed
  402.             press_target(event, @icontrol == 0)
  403.             @standing_pushing = true
  404.           elsif event.pushed
  405.             if event.real_x == @real_x + afloatxy(self)[0] and
  406.               event.real_y == @real_y + afloatxy(self)[1]
  407.               release_target(event)
  408.               @standing_pushing = false
  409.             end
  410.           end
  411.         end
  412.        
  413.         @pushable.each do |ev|
  414.           ev.through = false if ev.through
  415.           # release a pushed target if the player pick up the object
  416.           if ev.check_com("PICK UP")
  417.             @working_at.delete(ev.id) if !ev.pushable_busy.nil? and
  418.             ev.x == @x + ajustxy(self)[0] and ev.y == @y + ajustxy(self)[1] and
  419.             Input.trigger?(ActionKey)
  420.             if event.pushed and event.x == @x + ajustxy(self)[0] and event.y ==
  421.               @y + ajustxy(self)[1] and Input.trigger?(ActionKey)
  422.               release_target(event)
  423.               break
  424.             end
  425.           end
  426.          
  427.           # events pushing and releasing conditions
  428.           if event.real_x == ev.real_x and event.real_y == ev.real_y and
  429.             not event.pushed and not ev.picked and not ev.throwed
  430.             press_target(event, @icontrol == 0) ; ev.pushable_busy = true
  431.             @working_at[ev.id] = [ev.x, ev.y]
  432.           elsif event.pushed
  433.             break if event.real_x == ev.real_x and event.real_y == ev.real_y
  434.             if event.real_x == ev.real_x + afloatxy(ev)[0] and
  435.               event.real_y == ev.real_y + afloatxy(ev)[1] and not ev.picked
  436.               release_target(event) ; ev.pushable_busy = nil
  437.               @working_at.delete(ev.id)
  438.             end
  439.           end
  440.         end
  441.       end
  442.     end
  443.   end
  444.  
  445.   #---------------------------------------------------------------------------
  446.   # * Pick up System  
  447.   #---------------------------------------------------------------------------
  448.   def update_pick_up
  449.     return if @vehicle_getting_on || in_boat? || in_ship? || in_airship?
  450.     @pickup_delay -= 1 if @pickup_delay > 0
  451.     return if @pickup_delay > 0
  452.     for event in $game_map.events.values
  453.       event.x = @x if event.picked
  454.       event.y = @y if event.picked
  455.    
  456.       if event.throwed  # if throwed do this
  457.         if event.force_move != nil and event.jump_passable?(1, true)
  458.           event.start_jump(1)
  459.           event.force_move = nil
  460.         end
  461.        
  462.         unless event.jumping?
  463.           RPG::SE.new(ThrowSe,80).play
  464.           self_sw = event.check_selfsw("THROW SELF SWITCH")
  465.           if self_sw != nil
  466.             $game_self_switches[[$game_map.map_id, event.id, self_sw]] = true
  467.             event.refresh
  468.             event.direction = event.page.graphic.direction
  469.             changing = true
  470.           end
  471.           @player_busy = event.throwed = false
  472.           event.jump(0,  0) if changing.nil?
  473.           changing = nil
  474.         end
  475.       end
  476.      
  477.       if event.check_com("PICK UP")
  478.         event.priority_type = 1 if event.priority_type == 0
  479.         event.direction_fix = false if event.direction_fix
  480.        
  481.         # Throw object
  482.         if Input.trigger?(ActionKey) and  event.picked and
  483.           !$game_map.interpreter.running?
  484.           event.move_speed = @lastesp
  485.           if    event.jump_passable?(4) ;  event.start_jump(4)
  486.           elsif event.jump_passable?(3) ;  event.start_jump(3)
  487.           elsif event.jump_passable?(2) ;  event.start_jump(2)
  488.           else                          ;  event.force_move = true
  489.           end
  490.           event.picked = false
  491.           event.move_type = @lasmovetype
  492.           event.throwed = true
  493.         end
  494.        
  495.         # Pick up object
  496.         if Input.trigger?(ActionKey) and event.x == @x + ajustxy(self)[0] and
  497.           event.y == @y + ajustxy(self)[1] and !event.picked and
  498.           not self.moving? and not @player_busy
  499.           RPG::SE.new(PickUpSe, 80).play
  500.           @lasmovetype = event.move_type
  501.           event.move_type = 0
  502.           @lastesp = event.move_speed
  503.           event.move_speed = 6
  504.           @player_busy = event.picked = true
  505.           @pickup_delay = 5
  506.         end
  507.       end
  508.     end
  509.   end
  510.  
  511.   #---------------------------------------------------------------------------
  512.   # * Fall System  
  513.   #---------------------------------------------------------------------------
  514.   # events start falling
  515.   def start_falling(event)
  516.     event.obfalling = 1
  517.     event.move_speed = 4.5
  518.     event.through = true
  519.     event.fallbyjump.nil? ? event.move_away_from_player : event.fallbyjump = nil
  520.     RPG::SE.new(FallSe,80).play
  521.     @eve_fall.push(event) unless @eve_fall.include?(event)
  522.     @eve_fall = @eve_fall.uniq
  523.     @player_busy = event.picked = false if event.picked
  524.   end
  525.  
  526.   # Player start falling
  527.   def player_start_falling
  528.     $game_map.events.values.each do |event|
  529.       if event.picked and not event.check_com("PUSHABLE")
  530.         start_falling(event)
  531.       end
  532.     end
  533.     self.through = true
  534.     set_direction(Input.dir4) if Input.dir4 != 0
  535.     self.move_forward if @fallbyjump.nil?
  536.     RPG::SE.new(FallSe,80).play
  537.     @last_speed = self.move_speed
  538.     self.move_speed = 5
  539.     @obfalling = 100
  540.   end
  541.  
  542.   def update_falling
  543.     return if @vehicle_getting_on || in_boat? || in_ship? || in_airship?
  544.    
  545.     # Events fall
  546.     for event in $game_map.events.values
  547.       if event.check_com("PUSHABLE")
  548.         @pushable.push(event) unless @pushable.include?(event)
  549.         if $game_map.terrain_tag(event.real_x + ajustxy[0],
  550.           event.real_y + ajustxy[1]) == FallTag  and
  551.           event.real_x == @real_x + ajustxy[0] and
  552.           event.real_y == @real_y + ajustxy[1] and event.obfalling == 0
  553.           start_falling(event) unless event.moving? and self.moving?
  554.         elsif $game_map.terrain_tag(event.real_x, event.real_y) == FallTag and
  555.           event.obfalling == 0
  556.           unless event.moving?
  557.             event.fallbyjump = true
  558.             start_falling(event)
  559.           end
  560.         end
  561.       end
  562.      
  563.       # Events push the player away
  564.       if event.check_com("PUSH THE PLAYER")
  565.         event.direction_fix = false if event.direction_fix
  566.         if @jump_delay == 0 and @real_x == event.real_x + ajustxy(event)[0] and
  567.           @real_y == event.real_y + ajustxy(event)[1] and @obfalling == 0
  568.          
  569.           @direction = event.direction
  570.           move_forward
  571.           followers.gather
  572.           if jump_passable?(1, ignore_events = true)
  573.             @lastpxy = [@x, @y]
  574.             jump_forward(1) ; @jump_delay = 20
  575.           end
  576.         end
  577.       end
  578.     end
  579.    
  580.     # event falling effect
  581.     @eve_fall.each do |ev|
  582.       if ev.obfalling > 0
  583.         ev.zoom_x -= 0.06
  584.         ev.zoom_y -= 0.06
  585.         if ev.zoom_x <= 0.06  and !ev.erased
  586.           switch = ev.check_var("FALL SWITCH")
  587.           $game_switches[switch] = true if switch != 0
  588.           variable = ev.check_var("FALL VARIABLE")
  589.           $game_variables[variable] += 1 if variable != 0
  590.           event.refresh if switch != 0 || variable != 0
  591.           ev.erase
  592.           @eve_fall.delete_if { |e| e == ev }
  593.           event.obfalling = 0
  594.         end
  595.       end
  596.     end
  597.  
  598.    # followes fall with the player
  599.     self.followers.reverse_each do |f|
  600.       if @obfalling > 0
  601.         f.zoom_x = @zoom_x
  602.         f.zoom_y = @zoom_y
  603.         f.move_toward_player ; f.move_toward_player ; f.move_toward_player
  604.       end
  605.     end
  606.  
  607.     # Player fall
  608.     if $game_map.terrain_tag(@real_x, @real_y) == FallTag and
  609.       @obfalling == 0 and not moving? and not jumping?
  610.       @fallbyjump = true
  611.       player_start_falling
  612.     elsif $game_map.terrain_tag(@real_x + ajustxy[0], @real_y + ajustxy[1]) ==
  613.       FallTag and @obfalling == 0 and !self.moving?
  614.       player_start_falling
  615.     end
  616.    
  617.     if @obfalling > 0
  618.       @obfalling -= 1
  619.       if @obfalling > 30 and @obfalling < 100
  620.         self.zoom_x -= 0.06; self.zoom_y -= 0.06
  621.       end
  622.       if @obfalling == 40
  623.         @fallbyjump.nil? ? self.move_backward : moveto(@lastpxy[0],
  624.         @lastpxy[1]) rescue nil
  625.         @fallbyjump = nil
  626.       end
  627.       if @obfalling == 30
  628.         self.zoom_x = 1.0
  629.         self.zoom_y = 1.0
  630.         self.through = false
  631.         $game_party.members.each do |actor|
  632.           actor.hp -= @fallhp
  633.         end
  634.       end
  635.       self.opacity = (self.opacity + 70) % 160 + 60 if @obfalling < 40
  636.       self.opacity = 255 if @obfalling == 0
  637.       self.move_speed = @last_speed if @obfalling == 0
  638.     end
  639.   end
  640.  
  641.   #---------------------------------------------------------------------------
  642.   # * Jump System
  643.   #---------------------------------------------------------------------------
  644.   def perform_jump
  645.     return if @standing_pushing || self.jumping? || @obfalling > 0 ||
  646.     in_airship? || @vehicle_getting_on || in_boat? || in_ship? ||
  647.     @jump_delay > 0 || @player_busy
  648.     $game_map.events.values.each do |event|
  649.       if event.pushed
  650.         return if event.x == @x and event.y == @y
  651.         if event.x == @x + ajustxy(self)[0] and event.y == @y + ajustxy(self)[1]
  652.           return
  653.         end
  654.       end
  655.     end
  656.     @lastpxy = [@x, @y]
  657.     if    jump_passable?(2)  ;   start_jump(2)
  658.     elsif jump_passable?(1)  ;   start_jump(1)
  659.     else                     ;   start_jump(0)            
  660.     end
  661.     @jump_delay = 16
  662.   end
  663.  
  664.   #---------------------------------------------------------------------------
  665.   # * Sensor Vision System
  666.   #---------------------------------------------------------------------------
  667.   def sensor_area?(parent, target, size)
  668.     distance = (parent.x - target.x).abs + (parent.y - target.y).abs
  669.     enable   = (distance <= size-1)
  670.     return true if enable
  671.     return false
  672.   end
  673.  
  674.   def update_sensor_system
  675.     $game_map.events.values.each do |event|
  676.       range = event.check_var("SENSOR VISION RANGE")
  677.       if range != 0
  678.         if sensor_area?(self, event, range)
  679.           data = [$game_map.map_id, event.id, SensorSelfsw]
  680.           if event.inrange.nil? and !$game_self_switches[[data[0], data[1],
  681.             data[2]]]
  682.             $game_self_switches[[data[0], data[1], data[2]]] = true
  683.             event.inrange = true
  684.           end
  685.         elsif event.inrange != nil
  686.           data = [$game_map.map_id, event.id, SensorSelfsw]
  687.           if $game_self_switches[[data[0], data[1], data[2]]]
  688.             $game_self_switches[[data[0], data[1], data[2]]] = false
  689.             event.inrange = nil
  690.           end
  691.         end
  692.       end
  693.     end
  694.   end
  695.  
  696.   #-----------------------------------------------------------------------------
  697.   #                   * Flow control
  698.   #-----------------------------------------------------------------------------
  699.   def get_on_vehicle
  700.     return if @player_busy
  701.     falcao_intsystem_get_on_vehicle
  702.   end
  703.  
  704.   def get_off_vehicle
  705.     return if $game_map.terrain_tag(@x, @y) == FallTag
  706.     falcao_intsystem_get_off_vehicle
  707.   end
  708.  
  709.   def move_by_input
  710.     return if @obfalling > 0
  711.     falcao_intsystem_move_by_input
  712.   end
  713.  
  714.   def start_map_event(x, y, triggers, normal)
  715.     $game_map.events_xy(x, y).each do |ev|
  716.       return if ev.check_selfsw("TARGET SELF SWITCH") != nil
  717.     end  
  718.     falcao_intsystem_start_map_event(x, y, triggers, normal)
  719.   end
  720.  
  721.   # refresh all the system if the map is not the same
  722.   def perform_transfer
  723.     if $game_map.map_id !=  @new_map_id
  724.       refresh_falcao_int_system
  725.       @working_at = {}
  726.     end
  727.     falcao_intsystem_perform_transfer
  728.   end
  729.  
  730.   # Execute refresh
  731.   def refresh_falcao_int_system
  732.     @pushable = @eve_fall = []
  733.     @player_busy = @standing_pushing = false
  734.     for event in $game_map.events.values
  735.       event.throwed = false if event.throwed
  736.       if event.picked
  737.         event.move_speed = @lastesp
  738.         event.move_type  = @lasmovetype
  739.         event.picked = false
  740.       end
  741.       event.pushable_busy = nil if event.pushable_busy != nil
  742.       release_target(event, sound = false) if event.pushed
  743.     end
  744.   end
  745. end
  746.  
  747. # Game Event: Commands comments definition
  748. class Game_Event < Game_Character
  749.   attr_reader    :erased
  750.   attr_reader    :page
  751.   attr_accessor  :move_type
  752.   def check_com(comment)
  753.     return false if @list.nil? or @list.size <= 0
  754.     for item in @list
  755.       if item.code == 108 or item.code == 408
  756.         if item.parameters[0].include?(comment)
  757.           return true
  758.         end
  759.       end
  760.     end
  761.     return false
  762.   end
  763.  
  764.   def check_var(comment)
  765.     return 0 if @list.nil? or @list.size <= 0
  766.     for item in @list
  767.       if item.code == 108 or item.code == 408
  768.         if item.parameters[0] =~ /#{comment}[ ]?(\d+)?/
  769.           return $1.to_i
  770.         end
  771.       end
  772.     end
  773.     return 0
  774.   end
  775.  
  776.   def check_selfsw(comment)
  777.     return nil if @list.nil? or @list.size <= 0
  778.     for item in @list
  779.       next unless item.code == 108 or item.code == 408
  780.       if item.parameters[0] =~ /#{comment} (.*)/
  781.         return $1.to_s
  782.       end
  783.     end
  784.     return nil
  785.   end
  786. end
  787.  
  788. # Sprite character
  789. class Sprite_Character < Sprite_Base
  790.   alias falcao123_zoom_update update
  791.   def update
  792.     falcao123_zoom_update
  793.     if @zoom_x != @character.zoom_x or
  794.       @zoom_y != @character.zoom_y
  795.       @zoom_x = @character.zoom_x
  796.       @zoom_y = @character.zoom_y      
  797.       self.zoom_x = @character.zoom_x
  798.       self.zoom_y = @character.zoom_y
  799.     end  
  800.   end
  801.  
  802.   # Adjust a picked event to the game player
  803.   alias falcao_intsystem_update_position update_position
  804.   def update_position
  805.     falcao_intsystem_update_position
  806.     if @character.picked
  807.       self.x = $game_player.screen_x
  808.       self.y = $game_player.screen_y - 16
  809.       @character.direction = $game_player.direction
  810.     end
  811.   end
  812. end
  813.  
  814. class << DataManager
  815.  
  816.   # Refresh the system if saving
  817.   alias falcao_intsystem_save_game save_game unless $@
  818.   def DataManager.save_game(index)
  819.     $game_player.refresh_falcao_int_system
  820.     $game_player.icontrol = 10
  821.     falcao_intsystem_save_game(index)
  822.   end
  823.  
  824.   # Tell the system to repositioning the working events, if game is updated
  825.   alias falcao_intsystem_mapreload reload_map_if_updated unless $@
  826.   def DataManager.reload_map_if_updated
  827.     if $game_system.version_id != $data_system.version_id
  828.       $game_player.icontrol = 10
  829.     end
  830.     falcao_intsystem_mapreload
  831.   end
  832. end
  833.  
  834. # Add to array all pushable events
  835. class Game_Map
  836.   alias falcao_intsystem_setup_events setup_events
  837.   def setup_events(*args, &block)
  838.     falcao_intsystem_setup_events(*args, &block)
  839.     @events.values.each do |event|
  840.       $game_player.pushable.push(event) if event.check_com("PUSHABLE")
  841.      
  842.       # Execute event repositioning
  843.       if $game_player.icontrol > 0
  844.         $game_player.working_at.each do |id , value|
  845.           event.moveto(value[0], value[1]) if id == event.id
  846.         end
  847.       end
  848.     end
  849.   end
  850. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement