Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- Como usar: Escreva no nome do evento
- O padrão: <Sensor X>
- Para somente quando o player estiver na visão de frente do evento
- <sfront X>
- Para somente quando o player estiver nas costas do evento
- <sback X>
- Para somente quando o player estiver no lado esquerdo do evento
- <sleft X>
- Para somente quando o player estiver no lado direito do evento
- <sright X>
- =end
- class Game_Event < Game_Character
- #-----------------------------------------------------------------------
- SENSOR_SELF_SWITCH = 'D'
- #-----------------------------------------------------------------------
- alias drago64c_update update
- def update
- sensor_updating unless @unsensor
- drago64c_update
- end
- def sensor_updating
- # padrão
- if @event.name =~ /<Sensor\s?(\d+)>/i
- @event.name =~ /<Sensor\s?(\d+)>/i
- s = [$1.to_i,[$game_map.map_id,@id,SENSOR_SELF_SWITCH],[]]
- s[2] = [(($game_player.x-self.x).abs + ($game_player.y-self.y).abs <=
- s[0]), $game_self_switches[s[1]]] if s[0] > 0
- return unless s[0] > 0 && s[2][0] != s[2][1]
- $game_self_switches[s[1]], $game_map.need_refresh = s[2][0], true
- elsif @event.name =~ /<sfront\s?(\d+)>/i
- return sensorFront
- elsif @event.name =~ /<sback\s?(\d+)>/i
- return sensorBack
- elsif @event.name =~ /<sleft\s?(\d+)>/i
- return sensorLeft
- elsif @event.name =~ /<sright\s?(\d+)>/i
- return sensorRight
- end
- return false
- end
- def sensorFront
- @event.name =~ /<sfront\s?(\d+)>/i
- ##lswit = $2.to_s !== 'D' && ? $2.to_s : SENSOR_SELF_SWITCH
- #if (!($2.to_s).size < 1 && !($2.nil?) && $2.to_s !== 'D')
- # lswit = $2
- #else
- # lswit = SENSOR_SELF_SWITCH
- #end
- lswit = SENSOR_SELF_SWITCH
- switch = [$game_map.map_id,@id,lswit]
- tile = $1.to_i
- $game_self_switches[switch] = false
- case self.direction
- when 2 then vfronts(tile, switch)
- when 4 then vlefts(tile, switch)
- when 6 then vrights(tile, switch)
- when 8 then vbacks(tile, switch)
- end
- end
- def sensorBack
- @event.name =~ /<sback\s?(\d+)>/i
- ##lswit = $2.to_s !== 'D' && ? $2.to_s : SENSOR_SELF_SWITCH
- #if (!($2.to_s).size < 1 && !($2.nil?) && $2.to_s !== 'D')
- # lswit = $2
- #else
- # lswit = SENSOR_SELF_SWITCH
- #end
- lswit = SENSOR_SELF_SWITCH
- switch = [$game_map.map_id,@id,lswit]
- tile = $1.to_i
- $game_self_switches[switch] = false
- case self.direction
- when 8 then vfronts(tile, switch)
- when 6 then vlefts(tile, switch)
- when 4 then vrights(tile, switch)
- when 2 then vbacks(tile, switch)
- end
- end
- def sensorLeft
- @event.name =~ /<sleft\s?(\d+)>/i
- lswit = SENSOR_SELF_SWITCH
- switch = [$game_map.map_id,@id,lswit]
- tile = $1.to_i
- $game_self_switches[switch] = false
- case self.direction
- when 4 then vfronts(tile, switch)
- when 8 then vlefts(tile, switch)
- when 2 then vrights(tile, switch)
- when 6 then vbacks(tile, switch)
- end
- end
- def sensorRight
- @event.name =~ /<sright\s?(\d+)>/i
- lswit = SENSOR_SELF_SWITCH
- switch = [$game_map.map_id,@id,lswit]
- tile = $1.to_i
- $game_self_switches[switch] = false
- case self.direction
- when 4 then vfronts(tile, switch)
- when 2 then vlefts(tile, switch)
- when 8 then vrights(tile, switch)
- when 6 then vbacks(tile, switch)
- end
- end
- def vfronts(range, switch)
- return false unless $game_player.x === self.x
- (self.y..(self.y + range)).each { |y|
- if ($game_player.y == y )
- $game_self_switches[switch] = true
- return true if $game_player.y == y
- else
- #$game_self_switches[switch] = false
- end
- }
- end
- def vbacks(range, switch)
- return false unless $game_player.x === self.x
- (self.y.downto(self.y - range)).each { |y|
- if $game_player.y == y
- $game_self_switches[switch] = true
- return true if $game_player.y == y
- else
- #$game_self_switches[switch] = false
- end
- }
- end
- def vlefts(range, switch)
- return false unless $game_player.y === self.y
- (self.x.downto(self.x - range)).each { |x|
- if $game_player.x == x
- $game_self_switches[switch] = true
- return true
- else
- #$game_self_switches[switch] = false
- end
- }
- end
- def vrights (range, switch)
- return false unless $game_player.y === self.y
- (self.x..(self.x + range)).each { |x|
- if $game_player.x == x
- $game_self_switches[switch] = true
- return true
- else
- #$game_self_switches[switch] = false
- end
- }
- end
- end
- =begin
- class Game_Event < Game_Character
- #-----------------------------------------------------------------------
- SENSOR_SELF_SWITCH = 'D'
- #-----------------------------------------------------------------------
- alias drago64c_update update
- def update
- sensor_updating unless @unsensor
- drago64c_update
- end
- def sensor_updating
- @event.name =~ /<Sensor(\d+)>/i
- s = [$1.to_i,[$game_map.map_id,@id,SENSOR_SELF_SWITCH],[]]
- s[2] = [(($game_player.x-self.x).abs + ($game_player.y-self.y).abs <=
- s[0]), $game_self_switches[s[1]]] if s[0] > 0
- return unless s[0] > 0 && s[2][0] != s[2][1]
- sensorDirection
- $game_self_switches[s[1]], $game_map.need_refresh = s[2][0], true
- end
- def sensorDirection
- if (self.direction === 2)
- end
- end
- =end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement