Vai al contenuto

Rilevato Ad-Blocker. Per favore disabilita il tuo adblocker quando navighi su makerando.com - Non c'è nessun annuncio invasivo.

  • Chatbox

    You don't have permission to chat.
    Load More
MoonShadow

RGSS3 Bullpup Shooting engine problema

Recommended Posts

Ciao a tutti, sto utilizzando questo abs Bullpup shooting engine, (si lo so è portoghese) funziona molto bene ma ho un problema: nello script è presente la funzione di allerta in prossimità di nemici e io vorrei disattivarla ma di default nn si può fare. La pagina di script è questa:

 

 

#==============================================================================
# Bullpup Shooting Engine Main
#==============================================================================
#------------------------------------------------------------------------------
# Créditos: Leon-S.K --- ou --- AndreMaker --- ou --- 4ndreMTM
#------------------------------------------------------------------------------
#
# Para Criar um inimigo, coloque o comentario em um evento:
#    - enemy_id=  E coloque o ID do inimigo na database
# Para adicionar um comando quando o inimigo morrer, coloque o comentario
#   Die Erase           - Ira apagar o inimigo
#   Die Switch Local X  - Ira ativar a switch local x
#   Die Switch X        - Ira ativar a switch
#
#  Você pode criar um objeto, colocando um comentario no evento
#       - object command
#
#    E SUBSTITUA command por :
#       Self X    - Ativa a switch local x
#       Switch X  - Ativa a swich X
#       Start     - Executa tudo após o comentario
#       Weapon X  - Ativa-se somente com a arma de ID X
#
#    Exemplo:
#       - Object Self A
#
#    Outro Exemplo:
#       - Object Switch 20
#
# Para o Inimigo no database, coloque nos comentarios
#          animation_id= id da animação
#  Para definir uma animação de ataque
#
#     Você ainda pode criar uma arma com dano em area ou que atravessa mais
#   de um inimigo.
#           
#           Para fazer-lo coloque no comentario da arma:
#
#      Adicione "area" para criar uma arma com efeito de area(explosao)
#      Adicione "pierce x" e troque x para quantos inimigos quiser atravessar
#
#  Para colocar as armas no script, visite "Bullpup Weapons"
#------------------------------------------------------------------------------
#==============================================================================
module Module_Of_Config
 
  #------------------------------------------------------------------------------
  # CONFIGURAÇÕES GERAIS
  #------------------------------------------------------------------------------
 
  Opacity_Burn = 10     # A velocidade que a opacidade diminui quando morto
  Enemy_Recover = 60    # Recover padrão de inimigos
  Attack_Key = Key::A       # Tecla de Tiro
  Reload_Key = Key::S       # Tecla de Reload
  Turn_Key   = nil    # Tecla que quando segurada gira o jogador
  Pierce_Enemies = 1    # Quantos inimigos a bala pode atravessar (padrao 1)
  Die_SE = "Monster6"    # SE tocado quando o inimigo Morre
  Player_Die_SE = "die_abyss"    # SE tocado quando o player morre
 
  # Tecla que possui a mesma função de enter
  #  deixe nil para desabilitar
  Enter_Key2 = nil
 
  # Tecla de andar sileciosamente (esgueirar)
  Sneak_Key = Key::Ctrl
 
  # Velocidade do movimento do inimigo
  Enemy_Speed = {:normal => 2, # normal -> velocidade normal do inimigo
                 :search => 3, # search -> quando o inimigo estiver te procurando
                 :chase => 3}  # chase -> quando o inimigo estiver te perseguindo
 
  Mouse_Control = false       # Girar o Player e atirar com o Mouse?
 
  WeaponWeight_Slow = false  # Peso da arma afeta a velocidade do player?
 
  WASD_Movement = false       # Controlar usando WASD
 
  Disable_Control = 0       # Switch que Impede que o Player atire etc...
 
  Show_Damage_Sprites = true   # Mostrar valor do dano no alvo
  Show_Melee_Sprites  = true    # Mostrar sprites de armas melee (facas, etc)
  Show_Weapon_Sprites = true    # Mostrar sprites de armas (pistolas, etc)
  Show_Smoke_On_Fire  = true    # Mostrar sprites de fumaça ao atirar
  Show_Blood_Anim     = true    # Mostrar sangue
  Show_PopUp_Item     = true    # Mostrar janelas de item ganho
 
  Stamina              = false   # Sistema de Stamina
  Max_Stamina          = 150    # Máximo de stamina
  Stamina_Time         = 70    # Tempo até a stamina começar a regenerar
  Stamina_Rate         = 8    # Frequencia de Regeneraçaõ
  Stamina_Regeneration = 5    # Quantidade regenerada cada vez
 
  Jump_On_Damage = false  # Pular quando recebe dano
 
  Health_Time         = 0   # Tempo de espera até o hp começar a regenerar
  Health_Rate         = 0     # Frequencia de Regeneraçaõ
  Health_Regeneration = 0    # Quantidade regenerada cada vez
 
  Decrease_Volume = true   # Diminuir o som periodicamente quando morrendo
  Decrease_Tone   = true   # Diminuir a tonalidade periodicamente quando morrendo
      
  Enemy_Drop = false     # Inimigos dropam suas armas
  Pick_SE = "Equip1"    # Som ao pegar um drop
 
  Quick_Switch_Key = nil   # Tecla de rapida troca de armas
  Swap_SE = "Equip2"          # Som de rapida troca de armas
 
  Drop_Weapon_Key = nil   # Tecla de largar arma
  Drop_SE = "Equip3"         # Som de largar arma
 
  Push_Back_Effect = false  # Aumento do recover quando é atingido
  Push_Back_Melee = 14      # Valor para o push back do ataque melee
 
  Clip_IN_SE = "usp_no_ammo"
 
  #  Se os tiros estiverem passando por um tile que não pode ser passavel, marque
  # o tile com o numero abaixo...
  Terrain_Debug = 1
 
 
  Flash = false  # Flash quando receber dano ou uma explosão acontecer
  Floor = true  # Explosão deixa uma marca do chão
 
  Default_Follow = 0  # Valor padrão para visão dos inimigos
 
  Melee_Wav_Name = "knife_hit"  # Som do ataque melee
    
  Explosion_SE  = "Explosion2"  # Som da explosão
  Blend_Type    = 1  # Sinteticidade (normal, adicionar, subtrair) padrão 1
 
  Fragments     = 10 # Numero de fragmentos que a explosão solta
  Frag_Vel      = 9  # Velocidade dos fragmentos
 
  Smokes        = 2  # Numero de fumaças que a explosão solta
  Smoke_Vel     = 2  # Velocidade da fumaça
  Smoke_Freq    = 3  # Frequencia da fumaça
    
  Shot_Bit = {} # Não Mecha
 
  # GRAFICOS
  # Coloque aqui o caminho para os determinados graficos:
  # Se não souber oque é, não mecha.
  AreaChar      = "$!rocket"
  Floor_Bit     = Bitmap.new("Graphics/Particles/floor")
  Explosion_Bit = Bitmap.new("Graphics/Particles/explosion")
  Fragment_Bit  = Bitmap.new("Graphics/Particles/fragments")
  Smoke_Bit     = Bitmap.new("Graphics/Particles/smoke")
  Blood_Bit     = Bitmap.new("Graphics/Particles/blood")
  Melee_Bit     = Bitmap.new("Graphics/Particles/knifeslash")
  Shot_Bit[:x]  = Bitmap.new("Graphics/Particles/shot_x")
  Shot_Bit[:y]  = Bitmap.new("Graphics/Particles/shot_y")

#----------------------------------------------------------------------------------#

  #------------------------------------------------------------------------------
  # AREA NAO EDITAVEL - APENAS SE SABE OQUE ESTA FAZENDO =D
  #------------------------------------------------------------------------------

 
  def abs_distance_to(me, him)
    dx = me.distance_x_from(him.x).abs
    dy = me.distance_y_from(him.y).abs
    return dx + dy
  end
 
  def same_axis?(me, character)
    return if !me.is_a?(Game_Character) or !character.is_a?(Game_Character)
    ax = me.x - character.x
    ay = me.y - character.y
    case me.direction
    when 2
      return true if ax == 0 and ay < 0
    when 4
      return true if ay == 0 and ax > 0
    when 6
      return true if ay == 0 and ax < 0
    when 8
      return true if ax == 0 and ay > 0
    end
    return false
  end
 
  def in_sight?(me, him, range)
    xx = [];yy = []
    xx.push(me.x); yy.push(me.y)
    SceneManager.scene.spriteset.dep_clear
    case me.direction
    when 2
      for i in 0..range
        if $game_map.passable?(me.x, me.y + i, me.direction) or $game_map.counter?(me.x, me.y + i)
          yy.push(me.y + i)
          #SceneManager.scene.spriteset.depuracao(me.x, me.y + i)
        else
          break
        end
      end
    when 4
      for i in 0..range
        if $game_map.passable?(me.x - i, me.y, me.direction) or $game_map.counter?(me.x - i, me.y)
          xx.push(me.x - i)
          #SceneManager.scene.spriteset.depuracao(me.x - i, me.y)
        else
          break
        end
      end
    when 6
      for i in 0..range
        if $game_map.passable?(me.x + i, me.y, me.direction) or $game_map.counter?(me.x + i, me.y)
          xx.push(me.x + i)
          #SceneManager.scene.spriteset.depuracao(me.x + i, me.y)
        else
          break
        end
      end
    when 8
      for i in 0..range
        if $game_map.passable?(me.x, me.y - i, me.direction) or $game_map.counter?(me.x, me.y - i)
          yy.push(me.y - i)
          #SceneManager.scene.spriteset.depuracao(me.x, me.y - i)
        else
          break
        end
      end
    end
    xx = xx & xx
    yy = yy & yy
    xx.sort!; yy.sort!
    return true if xx.include?(him.x) and yy.include?(him.y)
    return false
  end
end

 
class Game_Map
  attr_accessor :enemies
  attr_accessor :damage_sprites
  attr_accessor :item_windows
  attr_accessor :explosion_chars
  #attr_accessor :last_drops
  attr_accessor :screen
  attr_accessor :hash
  alias abs_setup setup
  def setup(map_id)
    @enemies.nil? ? @enemies = [] : @enemies.clear
    @item_windows.nil? ? @item_windows = [] : @item_windows.clear
    #@last_drops.nil? ? @last_drops = [] : @last_drops.clear
    store_drops [] if @hash.nil?
    abs_setup(map_id)
    if SceneManager.scene.is_a?(Scene_Map)
      SceneManager.scene.dispose_spriteset
      SceneManager.scene.create_spriteset
    end
  end
  def window(type)
    @item_windows.push(type)
  end
  def store_drops array
    @hash = {}; @hash[:x] = []; @hash[:y] = []; @hash[:item] = []; @hash[:angle] = []
    array.each do |sprite|
      @hash[:x].push(sprite.character.x)
      @hash[:y].push(sprite.character.y)
      @hash[:item].push(sprite.item)
      @hash[:angle].push(sprite.angle)
    end
  end
end
#----------------------------------------------------------------------------------#
class Game_Event < Game_Character
  include Module_Of_Config
  attr_accessor :state
  attr_accessor :last_know
  attr_reader :enemy
  attr_reader :object
  attr_reader :not_blood
  attr_reader :st
  attr_reader :dbug
  alias abs_setup_page_settings setup_page_settings
  alias abs_initialize initialize
  alias abs_update update
  alias abs_start start
  alias abs_erase_enemy erase
  def initialize(map_id, event)
    @enemy = nil
    @recover = 0; @timer = 0; @state = :normal
    abs_initialize(map_id, event)
  end
  def setup_page_settings
    abs_setup_page_settings
    check_enemy
  end
  def check_enemy
    if [email protected]?
      @enemy = nil
      $game_map.enemies.delete(self)
    elsif [email protected]?
      @object = nil
      $game_map.enemies.delete(self)
    end
    return if @list.nil?
    weapon = nil
    @list.each do |command|
      next if not command.code == 108 or command.code == 408
      if @enemy.nil?
        if command.parameters[0].downcase.include?("enemy_id=")
          id = command.parameters[0].sub("enemy_id=","")
          @enemy = ABS_Enemy.new(id.to_i)
          @trigger = 2
          $game_map.enemies.push(self)
          print "Enemy #{@enemy.enemy.name} criado \n"
          @move_speed = weight_speed if @enemy.weapon != nil
        elsif command.parameters[0].downcase.include?("object")
          die_com = command.parameters[0].downcase.sub("object ", ""); die_com.downcase!
          if die_com.include?("self ")
            switch = die_com.downcase.sub('self ','')
            switch.downcase!
            switch = check_switch_string(switch)
          elsif die_com.include?("switch ") and !die_com.include?('local')
            switch = die_com.downcase.sub('switch ','')
            switch = switch.to_i
          elsif die_com.include?('start')
            switch = true
          elsif die_com.include?('weapon')
            switch = true
            weapon = (die_com.sub("weapon ",'')).to_i
          else
            switch = true
          end
          @object = ABS_Object.new(switch, weapon)
          $game_map.enemies.push(self)
          print "Objeto criado com switch #{@object.switch} \n"
        end
      else
        if command.parameters[0].downcase.include?("die")
          cmd = command.parameters[0].downcase
          if cmd == "die erase"
            @enemy.die = 0
          elsif cmd.include?("die switch local")
            @enemy.die = 1
            maqoe = cmd.sub("die switch local ",'')
            @enemy.switch = check_switch_string(maqoe)
          elsif cmd.include?("die switch")
            @enemy.die = 2
            maqoe = cmd.sub("die switch ", '')
            @enemy.switch = maqoe.to_i
          else
            @enemy.die = 0
          end
          print "Enemy #{@enemy.enemy.name} die command is #{@enemy.die} \n"
        elsif command.parameters[0].downcase.include?("follow ")
          cmd = command.parameters[0].downcase
          @enemy.follow = (cmd.sub("follow ","")).to_i
        else
          next
        end
      end
    end
  end
 
  def weight_speed
    return 5 if @enemy.weapon.nil?
    return 6 - @enemy.weapon.weight
  end
 
  def check_switch_string(string)
    if string.include?('a')
      return "A"
    elsif string.include?('b')
      return "B"
    elsif string.include?('c')
      return "C"
    elsif string.include?('d')
      return "D"
    end
    return nil
  end
 
  def start_object(used = nil)
    if @object.only.is_a?(Fixnum)
      print "has a only! \n"
      return if @object.only != used.id
    end
    if @object.switch.is_a?(TrueClass)
      start(true);return
    end
    if @object.switch.is_a?(String)
      key = [$game_map.map_id, self.id, @object.switch]
      $game_self_switches[key] ? $game_self_switches[key] = false : $game_self_switches[key] = true
    elsif @object.switch.is_a?(TrueClass)
      @object = nil
      $game_map.enemies.delete(self)
      self.start
    else
      $game_switches[@object.switch] ? $game_switches[@object.switch] = false : $game_switches[@object.switch] = true
    end
  end
 
  def erase
    @character_name = ''
    @priority_type = 1
    moveto(0,0)
    abs_erase_enemy
  end
 
  def damage_enemy(value, pushback, used = nil)
    if [email protected]?
      start_object(used)
      return
    end
    turn_toward_character($game_player)
    @state = :chase if @state == :search and @st == 0
    @recover += (pushback / 2).to_i if Push_Back_Effect
    value -= (rand(10) - 5)
    value -= @enemy.defense
    value = 0 if value < 0
    if Jump_On_Damage
      last_speed = @move_speed
      last_freq = @move_frequency
      @move_speed = 5
      @move_frequency = 5
      jump(0,0)
    end
    $game_map.damage_sprites.push(Damage_Sprite.new(self, value)) if Show_Damage_Sprites == true
    @enemy.hp -= value
    if @enemy.hp <= 0
      $game_map.enemies.delete(self)
      RPG::SE.new(Die_SE, 80).play
      Audio.se_play('Audio/Se/Blow6', 90, 100)
      expp = @enemy.enemy.exp
    end
    if Jump_On_Damage
      @move_speed = last_speed
      @move_frequency = last_freq
    end
  end
 
  def update
    @not_blood = (@object.nil? ? false : true) if @not_blood.nil?
    @bl = false if @bl.nil?
    update_enemy_basic
    abs_update
  end
 
  def update_enemy_basic
    if @enemy != nil
      @recover -= 1 if @recover > 0
      if @enemy.hp <= 0
        update_kill
        return
      end
      update_state
    end
  end
 
  def check_enemies_around
    $game_map.enemies.each do |enemy|
      next if enemy.object != nil
      next if abs_distance_to(self, enemy) >= 6
      next if enemy.st != 0
      if enemy.state != @state
        @state = enemy.state
        if @state == :search
          @last_know = enemy.last_know
        end
      end
    end
  end
 
  def update_state
    return if @enemy.nil?
    return if @enemy.hp == 0
    @move_speed = Enemy_Speed[@state] if @move_speed != Enemy_Speed[@state]
    case @state
    when :normal
      @last_know = nil if @last_know != nil
      check_enemies_around
      clear_path
      if in_sight?(self, $game_player, @enemy.follow)
        if @bl == false
          @bl = true
          @balloon_id = 1
        end
        @state = :chase
      elsif in_sight?(self, $game_player, @enemy.follow + 3)
        change_to_search
        if @bl == false
          @bl = true
          @balloon_id = 2
        end
      elsif check_really_near == true
        change_to_search
      else
        @direction_fix = false if @direction_fix
        @bl = false if @bl
      end
    when :search
      update_search
    when :chase
      print "chasing \n"
      if abs_distance_to(self, $game_player) >= 9; @state = :search; change_to_search; end;
      update_chase!
    end
  end
 
  def change_to_search
    return if @state == :chase
    clear_path
    turn_toward_character($game_player)
    @state = :search
    @last_know = Game_Character.new
    @last_know.moveto($game_player.x,$game_player.y)
    find_path(@last_know.x, @last_know.y)
    @recover = 20
  end
 
  def update_search
    @st = 0 if @st.nil?
    @dbug = 0 if @dbug.nil?
    return if @state != :search
    @state = :normal if @last_know.nil?
    if in_sight?(self, $game_player, @enemy.follow)
      @ballon_id = 0
      @bl = true
      @state = :chase
      @last_know = nil
      @balloon_id = 1
      return
    end
    if (self.x != @last_know.x) == true and (self.y != @last_know.y) == true
      @dbug += 1
      if @map.nil? and @runpath == false
        find_path(@last_know.x, @last_know.y)
      else
        print "searching \n"
        run_path if !moving?
      end
      if @dbug == 200
        @state = :normal
        @last_know = nil; @dbug = 0; clear_path
        return
      end
    else
      clear_path
      @st += 1
      if @st == 40
        print "turn? \n"
        turn_toward_character($game_player) if !moving?
      elsif @st == 80
        print "turn! \n"
        turn_away_from_character($game_player) if !moving?
      elsif @st == 120
        print "turned \n"
        turn_random if !moving?
        @st = 0; @state = :normal
        @last_know = nil
      end
    end
  end
 
  def update_chase!
    return if @state != :chase
    if @enemy.weapon.nil?
      @direction_fix = false if @direction_fix
      if in_sight?(self, $game_player, @enemy.follow)
        clear_path
        move_toward_character($game_player) if !moving?
      else
        if @map.nil? and @runpath == false
          find_path($game_player.x, $game_player.y)
        else
          run_path if !moving?
        end
      end
      dx = distance_x_from($game_player.x).abs
      dy = distance_y_from($game_player.y).abs
      if dx + dy <= 1
        attack; return
      end
    else
      turn_toward_character($game_player) if !moving?
      if in_sight?(self, $game_player, @enemy.follow)
        clear_path
        @direction_fix = true
        update_shooting
      else
        if @map.nil? and @runpath == false
          find_path($game_player.x, $game_player.y)
        else
          run_path if !moving?
        end
        @direction_fix = false
      end
    end
  end
  def update_shooting
    return if @recover > 0
    return if @enemy.weapon.nil?
    if @enemy.weapon.bullets > 0
      RPG::SE.new("#{@enemy.weapon.wav_name}", 100).play
      SceneManager.scene.spriteset.shoot_enemy(self)
      @recover = @enemy.weapon.recover
      @enemy.weapon.bullets -= 1
    else
      RPG::SE.new("#{@enemy.weapon.wav_name}_reload", 100).play
      @enemy.weapon.bullets = @enemy.weapon.max
      @recover = (@enemy.weapon.recover > 40 ? @enemy.weapon.recover : 40 )
    end
  end
  def update_kill
    if @opacity > 0
      @opacity -= Module_Of_Config::Opacity_Burn
    else
      if Enemy_Drop and @enemy.weapon != nil
        SceneManager.scene.spriteset.drop(@x, @y, @enemy.weapon.weapon)
      end
      $game_party.members[0].gain_exp(@enemy.enemy.exp)
      $game_party.gain_gold(@enemy.enemy.gold)
      case @enemy.die
      when 0
        print "Erased enemy #{@enemy.enemy.name}\n"
        self.erase
        @enemy = nil
      when 1
        key = [$game_map.map_id, self.id, @enemy.switch]
        if $game_self_switches[key] == true
          $game_self_switches[key] = false
        else
          $game_self_switches[key] = true
        end
        @opacity = 255
      when 2
        $game_switches[@enemy.switch] ? $game_switches[@enemy.switch] = false : $game_switches[@enemy.switch] = true
        @opacity = 255
      end
      @enemy = nil if [email protected]?
    end
  end
  def start(object_ok = false)
    if object_ok and @object != nil
      abs_start
      return
    end
    abs_start if @enemy.nil?
  end
  def check_really_near
    return false if !$game_player.moving?
    return false if $game_player.sneaking
    sx = distance_x_from($game_player.x).abs
    sy = distance_y_from($game_player.y).abs
    plus = ($game_player.dash? ? 1 : 0)
    return true if sx + sy - plus < 3
  end
  def attack
    return if @enemy.hp == 0 or @recover > 0
    @recover = Module_Of_Config::Enemy_Recover
    SceneManager.scene.spriteset.blood($game_player, @direction)
    value = @enemy.attack
    r = rand(20)
    factor = r - 10
    value += factor
    $game_player.damage_hero(value, Push_Back_Melee)
    SceneManager.scene.spriteset.melee(self)
  end
end
#----------------------------------------------------------------------------------#
class ABS_Object
  attr_accessor :only
  attr_accessor :switch
  def initialize(die_com, only = nil)
    @switch = die_com
    @only = only
  end
end
#----------------------------------------------------------------------------------#
class ABS_Enemy
  include Module_Of_Config
  attr_accessor :enemy
  attr_accessor :hp
  attr_accessor :attack
  attr_accessor :defense
  attr_accessor :die
  attr_accessor :switch
  attr_accessor :weapon
  attr_reader :name
  attr_accessor :follow
  def initialize(id)
    @enemy = Game_Enemy.new(0, id)
    @name = @enemy.name; @weapon = nil
    @die = 0, @switch = nil; @follow = Default_Follow
    note = @enemy.enemy.note
    if note.include?("weapon=")
      id = note.sub("weapon=","").to_i
      arma = Weapons_To_Be_Used::Armas[id]
      p1 = $data_weapons[id]
      p2 = $data_items[arma[0]]
      p3 = arma[1]
      p4 = arma[2]
      p5 = arma[3]
      p6 = arma[4]
      p7 = arma[5]
      @weapon = Abs_Weapon.new(p1,p2,p3,p4,p5,p6,p7)
      @weapon.bullets = @weapon.max
    end
    @hp = enemy.mhp
    @attack = enemy.atk
    @defense = enemy.def
  end
end
#----------------------------------------------------------------------------------#
class Game_Player < Game_Character
  include Module_Of_Config
  attr_accessor :kill_player
  attr_accessor :equipped_weapon
  attr_accessor :need_check
  attr_accessor :hrate
  attr_accessor :weight
  attr_accessor :stamina
  attr_reader   :aiming
  attr_reader   :stamina_wasted
  alias abs_initialize initialize
  alias abs_update update
 
  def initialize
    @st_time, @st_rate = 0, 0
    @recover = 0; $master_sound = 0; @stamina = Max_Stamina; @stamina_wasted = false
    @kill_player = false; @need_check = true; @hrate = 0; @hwait = 0; @weight = false
    @real_vis_character_name = @character_name
    @real_vis_character_index = @character_index
    abs_initialize
  end
 
  def update_stamina
    return unless Stamina
    return unless SceneManager.scene.is_a?(Scene_Map)
    spriteset = SceneManager.scene.spriteset
    if Stamina_Gauge::Enabled
      if spriteset.stamina_gauge != nil
        spriteset.stamina_gauge.update if spriteset.stamina_gauge.stamina != @stamina or spriteset.stamina_gauge.visible != !SceneManager.scene.hud.nil?
      else
        spriteset.create_stamina_gauge
      end
    end
    if dash? and moving?
      minus = 1 + distance_per_frame
      if @stamina - minus < 0
        @stamina = 0
      else
        @stamina -= minus
      end
      @st_time = Stamina_Time
      @stamina_wasted = true if @stamina == 0
      return
    else
      if @st_time > 0
        @st_time -= 1
      else
        if @st_rate == Stamina_Rate
          if @stamina + Stamina_Regeneration > Max_Stamina
            @stamina = Max_Stamina
          else
            @stamina += Stamina_Regeneration
          end
          @stamina_wasted = false if @stamina == Max_Stamina
          @st_rate = 0
        else
          @st_rate += 1
        end
      end
    end
  end
 
  alias :normal_dash :dash?
  def dash?
    if Stamina
      return false if @stamina == 0 or @stamina_wasted
    end
    return normal_dash
  end
 
  def sneaking
    Input.press?(Sneak_Key)
  end
 
  def update_inputs
    return if stop_bullpup!
    if @recover == 0 and Input.trigger?(Drop_Weapon_Key) and @equipped_weapon != nil
      drop_weapon
    end
    if Mouse_Control
      update_mouse_control
    else
      if @recover == 0 and Input.trigger?(Quick_Switch_Key)
        quick_weapon_swap
      end
      if not @equipped_weapon == nil
        if Input.press?(Attack_Key) and @recover == 0
          if not @equipped_weapon.bullets == 0
            @equipped_weapon.area == true ? update_attack(true) : update_attack
            return
          else
            Audio.se_play("Audio/SE/#{@equipped_weapon.wav_name}_no_ammo", 100, 130)
            @recover = @equipped_weapon.recover
          end
        end
        if Input.trigger?(Reload_Key)
          if @equipped_weapon.bullets == 0
            reload(@equipped_weapon)
          else
            Audio.se_play("Audio/SE/Buzzer1", 80, 100)
          end
        end
      else
        if Input.press?(Attack_Key)
          update_melee if @recover == 0
        end
      end
    end
  end
 
  def update_mouse_control
    return if Mouse_Control == false
    if @recover == 0 and Mouse.click?(Mouse::SCROLL)
      quick_weapon_swap
    end
    if not @equipped_weapon == nil
      if Mouse.press?(Mouse::LEFT) and @recover == 0
        if not @equipped_weapon.bullets == 0
          @equipped_weapon.area == true ? update_attack(true) : update_attack
          return
        else
          Audio.se_play("Audio/SE/#{@equipped_weapon.wav_name}_no_ammo", 100, 130)
          @recover = @equipped_weapon.recover
        end
      end
      if Input.trigger?(Reload_Key)
        if @equipped_weapon.bullets == 0
          reload(@equipped_weapon)
        else
          Audio.se_play("Audio/SE/Buzzer1", 80, 100)
        end
      end
    else
      if Mouse.click?(Mouse::LEFT)
        update_melee if @recover == 0
      end
    end
  end
 
  def update
    update_health_reg
    @original_ms = @move_speed if @original_ms.nil?
    if sneaking
      @move_speed = @original_ms - 1
    else
      if !dash?
        @move_speed = @original_ms if @move_speed != @original_ms
      end
    end
    if WeaponWeight_Slow == true
      if @equipped_weapon != nil
        @move_speed = weight_speed if @move_speed != weight_speed
      else
        @move_speed = 5 if @move_speed != 5
      end
    end
    update_kill if @kill_player
    update_stamina if Stamina
    if $reload_sprite.nil?
      @recover -= 1 if @recover > 0
    end
    re_check_equipped_weapon if @need_check == true
    abs_update
    update_inputs
    update_strafe if Mouse_Control
  end
 
  def update_strafe
    return if stop_bullpup!
    bx = Mouse.x - self.screen_x
    by = Mouse.y - (self.screen_y-16)
    rad_angle = Math.atan2(bx,by) rescue 1
    r_angle = (rad_angle*360)/(2*Math::PI)
    if r_angle >= 135 and r_angle <= 225 #between?(-2,-1)
      set_direction(8) if @direction != 8
    elsif r_angle >= -135 and r_angle <= -45 #.between?(-2,2)
      set_direction(4) if @direction != 4
    elsif r_angle >= 45 and r_angle <= 135 #.between?(1,2)
      set_direction(6) if @direction != 6
    elsif r_angle >= -45 and r_angle <= 45#.between?(-1,1)
      set_direction(2) if @direction != 2
    end
  end
 
  def stop_bullpup!
    return true if $game_switches[Disable_Control] == true
    return true if $game_map.interpreter.running?
    return true if $game_message.busy?
    return false
  end
 
  if Mouse_Control
    def move_straight(d, turn_ok = true)
      @followers.move if passable?(@x, @y, d)
      @move_succeed = passable?(@x, @y, d)
      if @move_succeed
        set_direction(d) if stop_bullpup!
        @x = $game_map.round_x_with_direction(@x, d)
        @y = $game_map.round_y_with_direction(@y, d)
        @real_x = $game_map.x_with_direction(@x, reverse_dir(d))
        @real_y = $game_map.y_with_direction(@y, reverse_dir(d))
        increase_steps
      elsif turn_ok
        set_direction(d) if stop_bullpup!
        check_event_trigger_touch_front
      end
    end
  end
 
  def weight_speed
    return if not WeaponWeight_Slow
    return 6 - @equipped_weapon.weight
  end
 
  def update_health_reg
    actor = $game_party.members[0]
    return if actor.nil?
    return if actor.hp == actor.mhp
    if Decrease_Volume
      volume = (50 * actor.hp / actor.mhp).to_i
      $master_sound = 50 - volume
    end
    if Decrease_Tone
      if @last_alpha.nil?
        @last_alpha = $game_map.screen.tone
      elsif actor.hp == actor.mhp
        if @last_alpha != $game_map.screen.tone
          @last_alpha = $game_map.screen.tone
        end
      end
      color = (255 * actor.hp / actor.mhp).to_i
      tone = (@last_alpha.gray + 255) - color
      if tone < 0; tone = 0; elsif tone > 255; tone = 255; end
      $game_map.screen.start_tone_change(Tone.new(@last_alpha.red,@last_alpha.green,@last_alpha.blue,tone), 0)
    end
    if @hwait > 0
      @hwait -= 1; return
    else
      if @hrate == Health_Rate
        if actor.hp + Health_Regeneration > actor.mhp
          actor.hp = actor.mhp
        else
          actor.hp += Health_Regeneration
        end
        @hrate = 0
      else
        @hrate += 1
      end
    end
  end
 
  alias :move :movable?
  def movable?
    return false if @kill_player
    move
  end
 
  def drop_weapon
    return if @equipped_weapon == nil
    RPG::SE.new(Drop_SE, 90).play
    item = @equipped_weapon.weapon
    SceneManager.scene.spriteset.drop(@x, @y, item)
    actor = $game_party.members[0]
    actor.change_equip(0,nil)
    @equipped_weapon = nil
    $game_party.lose_item(item, 1)
    SceneManager.scene.spriteset.refresh!
    $game_system.hud_need_refresh = true
  end
 
  def quick_weapon_swap
    real = []
    $weapons.each {|weapon|
      if $game_party.has_item?(weapon.weapon, true)
        real.push(weapon)
      end
    }
    return if real.empty?
    if @equipped_weapon.nil?
      @equipped_weapon = real[0]
      $game_party.members[0].change_equip(0, real[0].weapon)
      $game_party.lose_item(real[0].weapon, 1)
      $game_map.window(Pop.new(real[0].weapon))
      proc; return
    end
    if real.size == 1
      $game_party.gain_item(@equipped_weapon.weapon, 1,false, true)
      @equipped_weapon = real[0]
      $game_party.members[0].change_equip(0, real[0].weapon)
      $game_party.lose_item(real[0].weapon, 1)
      $game_map.window(Pop.new(real[0].weapon))
      proc; return
    end
    if real.include?(@equipped_weapon)
      index = real.index(@equipped_weapon)
      if index == real.size - 1
        $game_party.gain_item(@equipped_weapon.weapon, 1,false,true)
        @equipped_weapon = real[0]
        $game_party.members[0].force_change_equip(0, real[0].weapon)
        $game_party.lose_item(real[0].weapon, 1)
        $game_map.window(Pop.new(real[0].weapon))
        proc; return
      else
        #$game_party.gain_item(@equipped_weapon.weapon, 1)
        @equipped_weapon = real[index + 1]
        $game_party.members[0].change_equip(0, real[index + 1].weapon)
        $game_map.item_windows.clear;
        $game_party.lose_item(real[index + 1].weapon, 1)
        $game_map.window(Pop.new(real[index + 1].weapon))
        proc; return
      end
    else
      $game_party.gain_item(@equipped_weapon.weapon, 1,false,true)
      @equipped_weapon = real[0]
      $game_party.members[0].change_equip(0, real[0].weapon)
      $game_party.lose_item(real[0].weapon, 1)
      $game_map.window(Pop.new(real[0].weapon))
      proc; return
    end
    proc
  end
 
  def proc
    @recover = 30
    @need_check = true
    SceneManager.scene.spriteset.refresh! if Show_Weapon_Sprites
    RPG::SE.new(Swap_SE,80).play
  end
 
  def move_by_input
    return if !movable? || $game_map.interpreter.running?
    if Input.press?(Turn_Key)
      set_direction(Input.dir4) if Input.dir4 > 0
    else
      move_straight(Input.dir4) if Input.dir4 > 0
    end
  end
 
  def update_melee
    actor = $game_party.members[0]
    @recover = 60
    if actor.weapons[0] != nil and Show_Melee_Sprites
      SceneManager.scene.spriteset.weapon(self, actor.weapons[0].icon_index)
    end
    SceneManager.scene.spriteset.melee(self)
    return if $game_map.enemies.empty?
    $game_map.enemies.each {|enemy|
      damage = actor.atk
      if @direction == enemy.direction
        damage *= 2
      end
      ax = @x - enemy.x
      ay = @y - enemy.y
      case @direction
      when 2
        if ax == 0 and ay == -1
          enemy.damage_enemy(damage, Push_Back_Melee)
          SceneManager.scene.spriteset.blood(enemy, @direction) if enemy.object.nil?
        end
      when 4
        if ay == 0 and ax == 1
          enemy.damage_enemy(damage, Push_Back_Melee)
          SceneManager.scene.spriteset.blood(enemy, @direction) if enemy.object.nil?
        end
      when 6
        if ay == 0 and ax == -1
          enemy.damage_enemy(damage, Push_Back_Melee)
          SceneManager.scene.spriteset.blood(enemy, @direction) if enemy.object.nil?
        end
      when 8
        if ax == 0 and ay == 1
          enemy.damage_enemy(damage, Push_Back_Melee)
          SceneManager.scene.spriteset.blood(enemy, @direction) if enemy.object.nil?
        end
      end
    }
  end
 
  def re_check_equipped_weapon
    if self.actor.weapons[0].nil?
      print "#{self.actor.name} has no weapon\n"
      @equipped_weapon = nil; return
    end
    $weapons.each { |weapon|
      if self.actor.equips.include?(weapon.weapon)
        @equipped_weapon = weapon
        return
      elsif self.actor.weapons[0].id == weapon.weapon.id
        @equipped_weapon = weapon
        return
      else
        @equipped_weapon = nil
      end }
    @need_check = false
  end
 
  def reload(weapon)
    $game_party.items.each { |item|
      if item.id == weapon.magazine.id
        rec = 0
        if @equipped_weapon.recover < 40
          rec = 40
        else
          rec = @equipped_weapon.recover
        end
        SceneManager.scene.spriteset.reload(rec)
        @recover = (@equipped_weapon.recover > 40 ? @equipped_weapon.recover : 45)
        $game_party.lose_item(weapon.magazine,1)
        @equipped_weapon.bullets += @equipped_weapon.max
        Audio.se_play("Audio/Se/#{weapon.wav_name}_reload", 100, 100)
        @recover = @equipped_weapon.recover
        return
      end
    }
    Audio.se_play("Audio/Se/Buzzer1", 85, 100)
  end
 
  def update_attack(bazooca = false)
    return if $game_map.interpreter.running? or $game_message.busy?
    $game_map.enemies.compact!
    return if @kill_player
    return if $game_party.members[0].weapons[0] == nil
    re_check_equipped_weapon if @equipped_weapon == nil
    return if @equipped_weapon.nil? or @equipped_weapon.class != Abs_Weapon
    Audio.se_stop
    Audio.se_play("Audio/Se/#{@equipped_weapon.wav_name}", 100, 100)
    @equipped_weapon.bullets -= 1
    @recover = @equipped_weapon.recover
    range_x = {'pos' => [], 'neg' => []}
    range_y = {'pos' => [], 'neg' => []}
    SceneManager.scene.spriteset.shoot(self)
    $game_map.enemies.each {|enemy|
      next if enemy.object != nil
      next if enemy.state == :chase
      dx = enemy.distance_x_from(self.x).abs
      dy = enemy.distance_y_from(self.y).abs
      rg = (@equipped_weapon.wav_name.include?("silenced") ? 2 : 4)
      if dx+dy <= rg
        enemy.change_to_search
        enemy.balloon_id = 2
      end
    }
    for i in 1..8
      if (map_passable?(@x - i, @y, 4) or $game_map.counter?(@x - i, @y)) and $game_map.terrain_tag(@x - i, @y) != Terrain_Debug
        range_x['pos'].push(i)
      else
        break; next
      end
    end
    for i in 1..8
      if (map_passable?(@x + i, @y, 6) or $game_map.counter?(@x + i, @y)) and $game_map.terrain_tag(@x + i, @y) != Terrain_Debug
        range_x['neg'].push(i * (-1))
      else
        break; next
      end
    end
    for i in 1..8
      if (map_passable?(@x, @y - i, 8) or $game_map.counter?(@x, @y - i)) and $game_map.terrain_tag(@x, @y - i) != Terrain_Debug
        range_y['pos'].push(i)
      else
        break; next
      end
    end
    for i in 1..8
      if (map_passable?(@x, @y + i, 2) or $game_map.counter?(@x, @y + i)) and $game_map.terrain_tag(@x, @y + i) != Terrain_Debug
        range_y['neg'].push(i * (-1))
      else
        break; next
      end
    end
    @new_enemies = []
    $game_map.enemies.each do |enemy|
      ax = @x - enemy.x
      ay = @y - enemy.y
      case @direction
      when 2
        if not ax != 0
          if ay == -1
            @new_enemies[0] = enemy
          elsif ay == - 2
            @new_enemies[1] = enemy
          elsif ay == - 3
            @new_enemies[2] = enemy
          elsif ay == - 4
            @new_enemies[3] = enemy
          elsif ay == - 5
            @new_enemies[4] = enemy
          elsif ay == - 6
            @new_enemies[5] = enemy
          elsif ay == - 7
            @new_enemies[6] = enemy
          elsif ax == - 8
            @new_enemies[7] = enemy
          end
        end
      when 4
        if not ay != 0
          if ax == 1
            @new_enemies[0] = enemy
          elsif ax == 2
            @new_enemies[1] = enemy
          elsif ax == 3
            @new_enemies[2] = enemy
          elsif ax == 4
            @new_enemies[3] = enemy
          elsif ax == 5
            @new_enemies[4] = enemy
          elsif ax == 6
            @new_enemies[5] = enemy
          elsif ax == 7
            @new_enemies[6] = enemy
          elsif ax == 8
            @new_enemies[7] = enemy
          end
        end
      when 6
        if not ay != 0
          if ax == -1
            @new_enemies[0] = enemy
          elsif ax == - 2
            @new_enemies[1] = enemy
          elsif ax == - 3
            @new_enemies[2] = enemy
          elsif ax == - 4
            @new_enemies[3] = enemy
          elsif ax == - 5
            @new_enemies[4] = enemy
          elsif ax == - 6
            @new_enemies[5] = enemy
          elsif ax == - 7
            @new_enemies[6] = enemy
          elsif ax == - 8
            @new_enemies[7] = enemy
          end
        end
      when 8
        if not ax != 0
          if ay == 1
            @new_enemies[0] = enemy
          elsif ay == 2
            @new_enemies[1] = enemy
          elsif ay == 3
            @new_enemies[2] = enemy
          elsif ay == 4
            @new_enemies[3] = enemy
          elsif ay == 5
            @new_enemies[4] = enemy
          elsif ay == 6
            @new_enemies[5] = enemy
          elsif ay == 7
            @new_enemies[6] = enemy
          elsif ay == 8
            @new_enemies[7] = enemy
          end
        end
      end
    end
    @new_enemies.compact!; a = 0
    @new_enemies.each do |enemy|
      if @equipped_weapon.pierce == true
        break if a >= Pierce_Enemies + @equipped_weapon.pierce_num
      else
        break if a >= Pierce_Enemies
      end
      next if not enemy.is_a?(Game_Event)
      ax = @x - enemy.x
      ay = @y - enemy.y
      case @direction
      when 2
        if ax == 0
          if range_y['neg'].include?(ay)
            bazooca ? damage_area(enemy) : attack_enemy(enemy)
            a += 1
            next
          else
            @equipped_weapon.area ? miss_area(range_x, range_y) : miss; break
          end
        else
          @equipped_weapon.area ? miss_area(range_x, range_y) : miss; break
        end
      when 4
        if ay == 0
          if range_x['pos'].include?(ax)
            bazooca ? damage_area(enemy) : attack_enemy(enemy)
            a += 1
            next
          else
            @equipped_weapon.area ? miss_area(range_x, range_y) : miss; break
          end
        else
          @equipped_weapon.area ? miss_area(range_x, range_y) : miss; break
        end
      when 6
        if ay == 0
          if range_x['neg'].include?(ax)
            bazooca ? damage_area(enemy) : attack_enemy(enemy)
            a += 1
            next
          else
            @equipped_weapon.area ? miss_area(range_x, range_y) : miss; break
          end
        else
          @equipped_weapon.area ? miss_area(range_x, range_y) : miss; break
        end
      when 8
        if ax == 0
          if range_y['pos'].include?(ay)
            bazooca ? damage_area(enemy) : attack_enemy(enemy)
            a += 1
            next
          else
            @equipped_weapon.area ? miss_area(range_x, range_y) : miss; break
          end
        else
          @equipped_weapon.area ? miss_area(range_x, range_y) : miss; break
        end
      end
    end
    @new_enemies.clear
    if a == 0
      @equipped_weapon.area ? miss_area(range_x, range_y) : miss
    end
  end
 
  def miss_area(area_x, area_y)
    @recover = @equipped_weapon.recover
    area_x['pos'].sort!; area_x['neg'].sort!
    area_y['pos'].sort!; area_y['neg'].sort!
    area_x['pos'].compact!; area_x['neg'].compact!
    area_y['pos'].compact!; area_y['neg'].compact!
    xis, yis = @x, @y
    gm = $game_party.members[0]
    pre_feito = gm.atk - gm.def
    pre_feito = 0 if pre_feito <= 0
    if not area_x['pos'].empty? or area_x['neg'].empty? or area_y['pos'].empty? or area_y['neg'].empty?
      case @direction
      when 2
        if area_y['neg'][0].nil?; damage_hero(pre_feito, 20); SceneManager.scene.spriteset.explode($game_player.x, $game_player.y); return; end
        xis = @x; yis -= area_y['neg'][0]
      when 4
        a = area_x['pos'].size
        if area_x['pos'][a - 1].nil?; damage_hero(pre_feito, 20); SceneManager.scene.spriteset.explode($game_player.x, $game_player.y); return; end
        yis = @y; xis -= area_x['pos'][a - 1]
      when 6
        if area_x['neg'][0].nil?; damage_hero(pre_feito, 20); SceneManager.scene.spriteset.explode($game_player.x, $game_player.y); return; end
        yis = @y; xis -= area_x['neg'][0]
      when 8
        a = area_y['pos'].size
        if area_y['pos'][a - 1].nil?; damage_hero(pre_feito, 20); SceneManager.scene.spriteset.explode($game_player.x, $game_player.y); return; end
        xis = @x; yis -= area_y['pos'][a - 1]
      end
    else
      return
    end
    xis = 0 if xis.nil?
    yis = 0 if yis.nil?
    SceneManager.scene.spriteset.area(self, xis, yis)
    SceneManager.scene.spriteset.explode(xis,yis)
    range = {}
    range[:x] = [xis]; range[:y] = [yis]
    for i in 0..1
      range[:x].push(xis + i)
      range[:y].push(yis + i)
      range[:x].push(xis - i)
      range[:y].push(yis - i)
    end
    range[:x] = range[:x] & range[:x]
    range[:y] = range[:y] & range[:y]
    range[:x].sort!; range[:y].sort!
    $game_map.enemies.each {|enemy|
      if range[:x].include?(enemy.x) and range[:y].include?(enemy.y)
        enemy.damage_enemy(pre_feito, 20, @equipped_weapon.weapon)
      end
    }
    if range[:x].include?($game_player.x) and range[:y].include?($game_player.y)
      $game_player.damage_hero(pre_feito, 20, @equipped_weapon.weapon)
    end
  end
 
  def remove_bullets(qnt)
    if @equipped_weapon.bullets - qnt < 0
      @equipped_weapons.bullets = 0
    else
      @equipped_weapon.bullets -= qnt
    end
  end
 
  def damage_area(enemy)
    Audio.se_play("Audio/Se/#{@equipped_weapon.wav_name}", 100, 100)
    SceneManager.scene.spriteset.area(self, enemy.x, enemy.y)
    SceneManager.scene.spriteset.explode(enemy.x, enemy.y)
    xis, yis = enemy.x, enemy.y
    area = {'X' => [], 'Y' => []}
    area['X'].push(xis + 1)
    area['X'].push(xis - 1)
    area['Y'].push(yis + 1)
    area['Y'].push(yis - 1)
    area['X'].push(xis)
    area['Y'].push(yis)
    area['X'].sort!; area['Y'].sort!
    $game_map.enemies.compact!
    a = $game_map.enemies.compact; a.delete(enemy)
    attack_enemy(enemy, true)
    for enemi in a
      if area['X'].include?(enemi.x) and area['Y'].include?(enemi.y)
        attack_enemy(enemi, true)
      end
    end
    Audio.se_play("Audio/Se/explosion1", 100, 100)
  end
 
  def miss
    hero = $game_party.members[0]
    @recover = @equipped_weapon.recover
  end
 
  def attack_enemy(event, bazooca = false)
    hero = $game_party.members[0]
    r = rand(10)
    rand = r - 5
    event.damage_enemy(hero.atk + rand, @equipped_weapon.pushback, @equipped_weapon.weapon)
    if event.object.nil?
      SceneManager.scene.spriteset.blood(event, @direction) if bazooca != true
    end
    @recover = @equipped_weapon.recover
  end
 
  def get_bullets(weapon)
    if not weapon.bullets == weapon.max
      $game_party.lose_item(weapon.magazine, 1)
      weapon.bullets += weapon.max
    else
      return
    end
  end
 
  def damage_hero(value, pushback)
    return if @kill_player
    @hwait = Health_Time
    @recover += (pushback / 2).to_i if Push_Back_Effect
    jump(0,0) if Jump_On_Damage
    hero = $game_party.members[0]
    value -= hero.def
    value -= (rand(10) - 5)
    value = 0 if value < 0
    $game_map.damage_sprites.push(Damage_Sprite.new(self, value)) if Show_Damage_Sprites == true
    if not value > hero.hp
      hero.hp -= value
    else
      hero.hp = 1
      @kill_player = true
      RPG::SE.new(Player_Die_SE, 80).play
    end
  end
 
  def update_kill
    if @opacity > 0
      @opacity -= Module_Of_Config::Opacity_Burn
    else
      SceneManager.goto(Scene_Gameover)
    end
  end
end

if Module_Of_Config::WASD_Movement
  class << Input
    
    alias :dir :dir4
    def dir4
      return dir_wasd
    end
    
    def dir_wasd
      return 8 if self.press?(Key::W) or self.press?(:UP)
      return 4 if self.press?(Key::A) or self.press?(:LEFT)
      return 2 if self.press?(Key::S) or self.press?(:DOWN)
      return 6 if self.press?(Key: :D) or self.press?(:RIGHT)
      return 0
    end
  end
end
#----------------------------------------------------------------------------------#
class Scene_Map < Scene_Base
 
  alias :upd :update
  def update
    upd
    Mouse.update
  end
end
#----------------------------------------------------------------------------------#
class Spriteset_Map
  alias abs_initialize initialize
  alias abs_update update
  alias abs_dispose dispose
  attr_reader :viewport1
  def initialize
    $game_map.damage_sprites = []
    $game_map.item_windows = []
    $game_map.explosion_chars = []
    @spritees = {}; $reload_sprite = nil
    abs_initialize
  end
  def update
    abs_update
    trash = []
    trash2 = []
    $game_map.damage_sprites.each do |sprite|
      sprite.update
      trash.push(sprite )if sprite.disposed?
    end
    if !$game_map.item_windows.empty?
      if $game_map.item_windows[0].is_a?(Pop)
        $game_map.item_windows[0].update
        trash2.push($game_map.item_windows[0]) if $game_map.item_windows[0].disposed?
      end
    end
    trash2.each { |item| $game_map.item_windows.delete(item) }
    $game_map.item_windows.compact!
    trash.each { |item| $game_map.damage_sprites.delete(item) }
    trash2.clear; trash.clear
    for char in $game_map.explosion_chars
      char.update
      char.my_sprite = Sprite_Character.new(@viewport1, char) if char.my_sprite.nil?
      trash.push(char) if char.disposed?
    end
    trash.each { |item| $game_map.explosion_chars.delete(item) }
  end
  def dispose
    abs_dispose
    $game_map.damage_sprites.each do |sprite|
      sprite.bitmap.dispose
      sprite.dispose
    end
    $game_map.damage_sprites.clear
    $game_map.item_windows.each do |window|
      window.dispose
    end
    $game_map.item_windows.clear
    $game_map.explosion_chars.each { |char| char.dispose }
    $game_map.explosion_chars.clear
  end
end
#----------------------------------------------------------------------------------#
class Game_Party < Game_Unit
  alias metodo_aliasado_com_sucesso gain_item
  def gain_item(item, amount, include_equip = false, swaping = false)
    if amount > 0 and Module_Of_Config::Show_PopUp_Item
      $game_map.window(Pop.new(item)) if swaping == false
    end
    $game_system.hud_need_refresh = true
    metodo_aliasado_com_sucesso(item, amount, include_equip)
  end
end
#----------------------------------------------------------------------------------#
class Damage_Sprite < Sprite
  def initialize(target, value)
    super(nil)
    @target = target
    self.bitmap = Bitmap.new(100,20)
    self.bitmap.draw_text(0,0,100,20,value,1)
    self.ox = 50
    self.z = 999
    self.x = target.screen_x
    self.y = target.screen_y - 40
    @timer = 50
  end
  def update
    if @timer > 0
      @timer -= 1
      self.y -= 1 if not self.y < @target.screen_y - 60
    else
      if self.opacity > 0
        self.opacity -= 15
        self.y -= 2
      else
        dispose
      end
    end
  end
  def dispose
    self.bitmap.dispose
    super
  end
end
#----------------------------------------------------------------------------------#
class Reward_Sprite < Sprite
  def initialize(target, value)
    super(nil)
    @target = target
    self.bitmap = Bitmap.new(100,20)
    self.bitmap.font.color = Color.new(72,0,255)
    self.bitmap.draw_text(0,0,100,20,value,1)
    self.ox = 50
    self.z = 999
    self.x = target.screen_x - 5
    self.y = target.screen_y - 40
    @timer = 50
  end
  def update
    if @timer > 0
      @timer -= 1
      self.zoom_x += 0.008
      self.zoom_y += 0.008
      self.y -= 1 if not self.y < @target.screen_y - 60
    else
      if self.opacity > 0
        self.opacity -= 15
        self.y -= 2
      else
        dispose
      end
    end
  end
  def dispose
    self.bitmap.dispose
    super
  end
end
#----------------------------------------------------------------------------------#
class Window_Ammo < Window_Base
  def initialize
    super(0,0,120,52)
    self.contents = Bitmap.new(width - 32, height - 32)
    if not $game_player.equipped_weapon == nil
      self.contents.draw_text(2,0,120,20,"Ammo:" + $game_player.equipped_weapon.bullets.to_s)
    end
  end
  def dispose
    super
  end
end
#----------------------------------------------------------------------------------#
class Pop < Window_Base
  def initialize(item)
    if not item.nil?
      super(0,355,175,60)
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.draw_text(30,5,120,20, item.name)
      draw_icon(item.icon_index, 5, 5)
      @timer = 70
      self.opacity = 0; self.visible = false
    else
      dispose if not self.disposed?
    end
  end
  def update
    return if self.disposed?
    self.opacity = 255 if self.opacity != 255
    self.visible = true if self.visible == false
    @timer > 0 ? @timer -= 1 : dispose
  end
  def dispose
    super
  end
end
#----------------------------------------------------------------------------------#
module DataManager
  def self.make_save_contents
    contents = {}
    contents[:system]        = $game_system
    contents[:timer]         = $game_timer
    contents[:message]       = $game_message
    contents[:switches]      = $game_switches
    contents[:variables]     = $game_variables
    contents[:self_switches] = $game_self_switches
    contents[:actors]        = $game_actors
    contents[:party]         = $game_party
    contents[:troop]         = $game_troop
    contents[:map]           = $game_map
    contents[:player]        = $game_player
    if $weapons != nil
      $weapons.compact!
      contents[:weapons]     = $weapons
    end
    contents
  end
  def self.extract_save_contents(contents)
    $game_system        = contents[:system]
    $game_timer         = contents[:timer]
    $game_message       = contents[:message]
    $game_switches      = contents[:switches]
    $game_variables     = contents[:variables]
    $game_self_switches = contents[:self_switches]
    $game_actors        = contents[:actors]
    $game_party         = contents[:party]
    $game_troop         = contents[:troop]
    $game_map           = contents[:map]
    $game_player        = contents[:player]
    $weapons            = contents[:weapons] if contents.has_key?(:weapons)
    $weapons.compact!
  end
end

class Scene_Gameover < Scene_Base
  alias :weapons_reset :start
  def start
    weapons_reset
    $weapons.each {|weapon| weapon.bullets = 0}
  end
end
if Module_Of_Config::Decrease_Volume
  class << Audio
    alias :play! :se_play
    def se_play(dir, volume, rate)
      new = (volume - $master_sound rescue volume)
      new = 0 if new < 0
      play!(dir,new,rate)
    end
  end
  $master_sound = 0
end
#----------------------------------------------------------------------------------#
module Definitions
 
  Sprite_angles = {2=>[80,110,140,170],4=>[340,10,40,70],6=>[290,260,230,200],8=>[290,320,350,20]}
  Move_correction = {2=>[-8,-10],4=>[0,-10],6=>[0,-4],8=>[4,-10]}
  Sprite_z_values = { 2=>120, 4=>50, 6=>120, 8=>50}

  Static_Angles = {2=>140,4=>40,6=>320,8=>350} # 6=>340
  Static_Move = {2=>[-8,-14],4=>[0,-10],6=>[10,0],8=>[4,-10]}
  Static_Z = { 2=>120, 4=>50, 6=>120, 8=>50}
  Static_Mirror = {2 => false, 4=>false,6=>true,8=>false}
  Kick_Angles = {2=>[-14,-10,-6],4=>[-14,-10,-6],6=>[14,10,6],8=>[14,10,6] }
 
end

class Scene_Map < Scene_Base; attr_reader :spriteset; end

class Spriteset_Map
 
  include Module_Of_Config
  include Definitions
  attr_accessor :smoke
  attr_accessor :stamina_gauge
 
  alias :mtm_initialize :initialize
  def initialize
    @explosions = []; @smoke = []; @floors = []; @particles = []; @parts = []
    @array_weapons = {}; @weapons = {}; @drops = []
    mtm_initialize
    if $last_frame != nil
      $reload_sprite = Reload.new($last_frame, @viewport2, $last_max)
    end
    if !$game_map.hash[:x].empty?
      xis = $game_map.hash[:x]
      yis = $game_map.hash[:y]
      items = $game_map.hash[:item]
      angles = $game_map.hash[:angle]
      xis.each_with_index do |xx, i|
        @drops.push(Particle_Sprites::Drop.new(xx, yis, items, @viewport1, angles))
      end
    end
    create_enemy_weapons if Show_Weapon_Sprites
  end
 
  def create_enemy_weapons
    $game_map.enemies.each {|enemy|
      next if enemy.enemy.nil?
      if enemy.enemy.weapon != nil
        icon = (enemy.enemy.weapon.weapon.icon_index rescue nil)
        return if icon.nil?
        bitmap = Bitmap.new(24,24)
        bitmap.blt(0,0,Cache.system("Iconset"),Rect.new(icon%16*24,icon/16*24,24,24))
        sprite = Sprite.new(@viewport1)
        sprite.ox, sprite.oy = 22,22
        sprite.zoom_x, sprite.zoom_y = 0.85, 0.85
        sprite.bitmap = bitmap
        @weapons[enemy] = [sprite, false, 0]
      end
    }
  end
 
  alias :mtm_update :update
  def update
    update_explosions if [email protected]?
    update_smokes if [email protected]?
    update_particles if [email protected]?
    update_parts if [email protected]?
    update_array if !@array_weapons.empty?
    update_drops if [email protected]?
    trash = []
    @floors.each { |sprite|
      sprite.update
      if sprite.disposed?
        trash.push(sprite)
      end
    }
    trash.each {|item| @floors.delete(item)}; trash.clear
    if Show_Weapon_Sprites
      update_vis_equip
    end
    if $reload_sprite != nil
      $reload_sprite.update
      $reload_sprite = nil if $reload_sprite.disposed?
    end
    mtm_update
  end
 
  def depuracao(x, y)
    @dep = [] if @dep.nil?
    @dep.push(Particle_Sprites::Dep.new(x,y, @viewport1))
  end
 
  def dep_clear
    if @dep.is_a?(Array)
      @dep.each {|sprite| sprite.dispose if not sprite.disposed?}
      @dep.clear
    end
  end
 
  def create_stamina_gauge
    @stamina_gauge = Stamina_Bar.new(@viewport2)
  end
 
  def reload(frames)
    return if $reload_sprite != nil
    $reload_sprite = Reload.new(frames, @viewport2)
  end
 
  def update_vis_equip
    update_enemy_weapons
    return if $game_player.equipped_weapon == nil
    if @weapons.keys.include?(:player)
      sprite = @weapons[:player][0]; player = $game_player
      kick = @weapons[:player][1]; time = @weapons[:player][2]
      sprite.update
      if $game_player.kill_player
        @wtf.nil? ? @wtf = 1 : @wtf += 1
        return if @wtf == 3
        sprite.x += rand(2) - 1
        sprite.y += rand(2) - 1
        sprite.angle += rand(4) - 2
        return
      end
      sprite.x = player.screen_x + Static_Move[player.direction][0]
      sprite.y = player.screen_y + Static_Move[player.direction][1]
      sprite.z = Static_Z[player.direction]# - 15
      sprite.mirror = Static_Mirror[player.direction]
      if kick
        case time
        when 9
          sprite.angle = Static_Angles[player.direction] + Kick_Angles[player.direction][0]
        when 6
          sprite.angle = Static_Angles[player.direction] + Kick_Angles[player.direction][1]
        when 3
          sprite.angle = Static_Angles[player.direction] + Kick_Angles[player.direction][2]
        when 0
          @weapons[:player][1] = false
          @weapons[:player][2] = 0
        end
        @weapons[:player][2] -= 1
      else
        sprite.angle = Static_Angles[player.direction]
      end
    else
      icon = ($game_player.equipped_weapon.weapon.icon_index rescue nil)
      return if icon.nil?
      bitmap = Bitmap.new(24,24)
      bitmap.blt(0,0,Cache.system("Iconset"),Rect.new(icon%16*24,icon/16*24,24,24))
      sprite = Sprite.new(@viewport1)
      sprite.ox, sprite.oy = 22,22
      sprite.zoom_x, sprite.zoom_y = 0.85, 0.85
      sprite.bitmap = bitmap
      @weapons[:player] = [sprite, false, 0]
    end
  end
 
  def update_enemy_weapons
    new_weapons = @weapons.clone
    new_weapons[:player] = nil
    new_weapons.delete(:player)
    new_weapons.each {|key, value|
      enemy = key; sprite = value[0]; kick = value[1]; time = value[2]
      if enemy.nil?
        sprite.dispose if not sprite.disposed?
        next
      end
      if enemy.enemy.nil?
        sprite.dispose if not sprite.disposed?
        next
      end
      sprite.update
      sprite.x = enemy.screen_x + Static_Move[enemy.direction][0]
      sprite.y = enemy.screen_y + Static_Move[enemy.direction][1]
      sprite.z = Static_Z[enemy.direction]# - 15
      sprite.mirror = Static_Mirror[enemy.direction]
      if kick
        case time
        when 9
          sprite.angle = Static_Angles[enemy.direction] + Kick_Angles[enemy.direction][0]
        when 6
          sprite.angle = Static_Angles[enemy.direction] + Kick_Angles[enemy.direction][1]
        when 3
          sprite.angle = Static_Angles[enemy.direction] + Kick_Angles[enemy.direction][2]
        when 0
          @weapons[enemy][1] = false
          @weapons[enemy][2] = 0
        end
        @weapons[enemy][2] -= 1
      else
        sprite.angle = Static_Angles[enemy.direction]
      end
    }
  end
 
  def refresh!
    if @weapons[:player] != nil
      @weapons[:player][0].dispose if not @weapons[:player][0].disposed?
      @weapons.delete(:player)
    end
    icon = ($game_player.equipped_weapon.weapon.icon_index rescue nil)
    return if icon.nil?
    bitmap = Bitmap.new(24,24)
    bitmap.blt(0,0,Cache.system("Iconset"),Rect.new(icon%16*24,icon/16*24,24,24))
    sprite = Sprite.new(@viewport1)
    sprite.ox, sprite.oy = 22,22
    sprite.zoom_x, sprite.zoom_y = 0.85, 0.85
    sprite.bitmap = bitmap
    @weapons[:player] = [sprite, false, 0]
  end
 
  def update_array
    trash = []
    @array_weapons.each_with_index {|array, i|
      update_array_weapon(array)
      trash.push(@array_weapons) if array[1][1] == false
    }
    trash.each {|item| @array_weapons.delete(item) }; trash.clear
  end
 
  def update_array_weapon(array)
    array[1][0].x = array[0].screen_x + Move_correction[array[0].direction][0]
    array[1][0].y = array[0].screen_y + Move_correction[array[0].direction][1]
    if !array[1][3]
      case array[1][2]
      when 12
        array[1][0].angle = Sprite_angles[array[0].direction][0]
        array[1][0].z = Sprite_z_values[array[0].direction] - 15
      when 9
        array[1][0].angle = Sprite_angles[array[0].direction][1]
        array[1][0].z = Sprite_z_values[array[0].direction] - 15
      when 6
        array[1][0].angle = Sprite_angles[array[0].direction][2]
        array[1][0].z = Sprite_z_values[array[0].direction] - 15
      when 3
        array[1][0].angle = Sprite_angles[array[0].direction][3]
        array[1][0].z = Sprite_z_values[array[0].direction] - 15
      when 0
        array[1][1] = false
        array[1][0].bitmap = nil
      end
    else
      if array[1][2] > 0
        array[1][0].angle = Sprite_angles[array[0].direction][2]
        array[1][0].z = Sprite_z_values[array[0].direction] - 15
      else
        array[1][1] = false
        array[1][0].bitmap = nil
      end
    end
    array[1][0].update
    array[1][2] -= 1
  end
 
  alias :mtm_dispose :dispose
  def dispose
    @explosions.each {|sprite| sprite.dispose if not sprite.disposed? }
    @explosions = nil
    @smoke.each {|sprite| sprite.dispose if not sprite.disposed? }
    @smoke = nil
    @particles.each {|sprite| sprite.dispose if not sprite.disposed?}
    @particles = nil
    @parts.each {|sprite| sprite.dispose if not sprite.disposed?}
    @parts = nil
    if @weapons[:player].is_a?(Sprite)
      @weapons[:player].dispose if not @weapons[:player].disposed?
      @weapons[:player] = nil
      @weapons.delete(:player)
    end
    @weapons.each {|key, value| value[0].dispose if not value[0].disposed? }
    @weapons = nil
    $game_map.store_drops @drops
    @drops = nil
    if $reload_sprite != nil
      $reload_sprite.store
      $reload_sprite = nil
    end
    mtm_dispose
  end
 
  def blood(target, direction)
    return unless Show_Blood_Anim
    if target.is_a?(Game_Event)
      return if target.not_blood
    end
    3.times { @particles.push(Particle_Sprites::Blood.new(target,direction, @viewport1)) }
    return unless Flash
    @character_sprites.each {|sprite_character|
      next if sprite_character.character != target
      sprite_character.flash(Color.new(255,0,0), 30)
      break
    }
  end
 
  def drop(x, y, weapon)
    @drops.push(Particle_Sprites::Drop.new(x,y,weapon,@viewport1))
  end
 
  def explode(x, y)
    @explosions.push(Particle_Sprites::Explosion.new(x, y, @viewport1))
    i = 0
    loop { i += 1; break if i == 5}
    for i in 0..Smokes - 1
      @smoke.push(Particle_Sprites::Smoke.new(x, y, @viewport1))
    end
    if Floor
      if @floors.empty?
        @floors.push(Particle_Sprites::Floor.new(x, y, @viewport1))
      else
        if not @floors.any? {|floor| floor.event_x == x and floor.event_y == y}
          @floors.push(Particle_Sprites::Floor.new(x, y, @viewport1))
        end
      end
    end
  end
    
  def weapon(character, icon_index)
    return if character.nil?
    return if icon_index == 0
    icon = icon_index
    bitmap = Bitmap.new(24,24)
    bitmap.blt(0,0,Cache.system("Iconset"),Rect.new(icon%16*24,icon/16*24,24,24))
    sprite = Sprite.new(@viewport1)
    sprite.ox, sprite.oy = 22,22
    sprite.bitmap = bitmap
    @array_weapons[character] = [sprite,true,12,false]
  end
 
  def melee(character)
    Audio.se_stop
    RPG::SE.new("#{Melee_Wav_Name}", 80).play
    @particles.push(Particle_Sprites::Melee.new(character, @viewport1))
  end
 
  def area(attacker, final_x, final_y)
    @particles.push(Particle_Sprites::Area.new(attacker ,final_x, final_y, @viewport1))
  end
 
  def shoot(character)
    if character.is_a?(Game_Player)
      if @weapons[:player] != nil
        @weapons[:player][1] = true
        @weapons[:player][2] = 9
      end
    end
    @particles.push(Particle_Sprites::Shot.new(character, @parts, @viewport1))
    if Show_Smoke_On_Fire
      @smoke.push(Particle_Sprites::Smoke2.new(character, @viewport1))
    end
  end
 
  def shoot_enemy(event)
    if @weapons[event] != nil
      @weapons[event][1] = true
      @weapons[event][2] = 9
    end
    if event.enemy.weapon.area == true
      @particles.push(Particle_Sprites::Enemy_Area.new(event, @viewport1))
    else
      @particles.push(Particle_Sprites::Enemy_Shot.new(event, @parts, @viewport1))
    end
    if Show_Smoke_On_Fire
      @smoke.push(Particle_Sprites::Smoke2.new(event, @viewport1))
    end
  end
 
  def update_explosions
    trash = []
    @explosions.each {|sprite|
      sprite.update
      trash.push(sprite) if sprite.disposed?
    }
    trash.each {|item| @explosions.delete(item)}
    trash.clear
  end
 
  def update_parts
    trash = []
    @parts.each {|sprite|
      sprite.update
      trash.push(sprite) if sprite.disposed?
    }
    trash.each {|item| @parts.delete(item)}
    trash.clear
  end
 
  def update_smokes
    trash = []
    @smoke.each {|sprite|
      sprite.update
      trash.push(sprite) if sprite.disposed?
    }
    trash.each {|item| @smoke.delete(item)}
    trash.clear
  end
 
  def update_particles
    trash = []
    @particles.each {|sprite|
      sprite.update
      trash.push(sprite) if sprite.disposed?
    }
    trash.each {|item| @particles.delete(item)}
    trash.clear
  end
 
  def update_drops
    trash = []
    @drops.each {|sprite|
      sprite.update
      trash.push(sprite) if sprite.disposed?
    }
    trash.each {|item| @drops.delete(item)}
    trash.clear
  end
end

module Particle_Sprites
 
  class Area < Game_Character
    
    include Module_Of_Config
    attr_accessor :sprite
    
    def initialize(character, final_x, final_y, view)
      super(); @character, @fx, @fy = character.clone, final_x, final_y; @view = view
      @move_speed = 7
      @move_frequency = 3
      @through = true
      @sprite = Sprite_Character.new(view,self)
      set_graphic(AreaChar, 0); @disposed = false
      moveto(@character.x, @character.y); set_direction @character.direction
      update
    end
    
    def update
      return if disposed?
      @sprite.update if not @sprite.disposed?
      if !destination_reached?
        move_straight(@direction)
        SceneManager.scene.spriteset.smoke.push(Smoke.new(@x, @y, @view))
      else
        dispose
      end
    end
    
    def destination_reached?
      return true if @x == @fx and @y == @fy
      return false
    end
    
    def dispose
      @disposed = true
      @sprite.dispose if not @sprite.disposed?
      @sprite = nil
    end
    
    def disposed?
      @disposed
    end
  end
 
  class Shot < Sprite
    
    include Module_Of_Config
    
    def initialize(character, parts_array, view)
      super(view); @character = character; @direction = character.direction
      case @direction
      when 2; self.bitmap = Shot_Bit[:y]
      when 4; self.bitmap = Shot_Bit[:x]
      when 6; self.bitmap = Shot_Bit[:x]
      when 8; self.bitmap = Shot_Bit[:y]
      end
      self.ox, self.oy = 16,16
      self.x, self.y = character.screen_x, character.screen_y - 8
      @parts = parts_array
      @disposer = Game_Character.new
      @disposer.moveto(@character.x, @character.y)
      @disposer.set_direction(@direction)
      get_speed; update
    end
    
    def update
      return if self.disposed?
      if out_screen?
        dispose; return
      end
      case @disposer.direction
      when 2
        @disposer.moveto(@disposer.x, @disposer.y + 1)
        if [email protected]_passable?(@disposer.x, @disposer.y, @disposer.direction) or @disposer.collide_with_characters?(@disposer.x, @disposer.y) or $game_map.terrain_tag(@disposer.x, @disposer.y) == 1 and $game_map.counter?(@disposer.x, @disposer.y) != true
          dispose; return
        end
      when 4
        @disposer.moveto(@disposer.x - 1, @disposer.y)
        if [email protected]_passable?(@disposer.x, @disposer.y, @disposer.direction) or @disposer.collide_with_characters?(@disposer.x, @disposer.y) or $game_map.terrain_tag(@disposer.x, @disposer.y) == 1 and $game_map.counter?(@disposer.x, @disposer.y) != true
          dispose; return
        end
      when 6
        @disposer.moveto(@disposer.x + 1, @disposer.y)
        if [email protected]_passable?(@disposer.x, @disposer.y, @disposer.direction) or @disposer.collide_with_characters?(@disposer.x, @disposer.y) or $game_map.terrain_tag(@disposer.x, @disposer.y) == 1 and $game_map.counter?(@disposer.x, @disposer.y) != true
          dispose; return
        end
      when 8
        @disposer.moveto(@disposer.x, @disposer.y - 1)
        if [email protected]_passable?(@disposer.x, @disposer.y, @disposer.direction) or @disposer.collide_with_characters?(@disposer.x, @disposer.y) or $game_map.terrain_tag(@disposer.x, @disposer.y) == 1 and $game_map.counter?(@disposer.x, @disposer.y) != true
          dispose; return
        end
      end
      self.x, self.y = @disposer.screen_x, @disposer.screen_y - 8
      self.opacity > 0 ? self.opacity -= 25 : dispose
      create_new_parts
    end
      
    def out_screen?
      return false if @disposer.x  == $game_map.width - 1 and @character.x == $game_map.width - 1
      return false if @disposer.y  == $game_map.height and @character.y == $game_map.height
      return true if @disposer.x + 1 == $game_map.width or @disposer.y + 1 == $game_map.height
      return false if @disposer.x == 0 and @character.x == 0
      return false if @disposer.y == 0 and @character.y == 0
      return true if @disposer.x == 0 or @disposer.y == 0
      return false
    end
    
    def get_speed
      case @direction
      when 2
        @vx = 0
        @vy = 25
      when 4
        @vx = -25
        @vy = 0
      when 6
        @vx = 25
        @vy = 0
      when 8
        @vx = 0
        @vy = -25
      end
    end
    
    def create_new_parts
      return if self.disposed?
      3.times do
        case @direction
        when 2
          vx = 0
          vy = 1
        when 4
          vx = -1
          vy = 0
        when 6
          vx = 1
          vy = 0
        when 8
          vx = 0
          vy = -1
        end
        @parts.push(Part.new(self, self.viewport, vx, vy))
      end
    end
    
    def dispose
      super
      @disposer = nil
    end
  end
 
  class Part < Sprite
    
    def initialize(sprite, view, vx, vy)
      super(view); @sprite = sprite
      self.bitmap = Bitmap.new(2,2)
      self.bitmap.fill_rect(0,0,2,2,Color.new(255,216,0))
      rx, ry = rand(12) - 6, rand(12) - 6
      self.x, self.y = sprite.x + rx, sprite.y + ry
      @vx, @vy = vx, vy
      update
    end
    
    def update
      return if self.disposed?
      self.x += @vx
      self.y += @vy
      self.opacity > 0 ? self.opacity -= 8 : dispose
    end
  end
 
  class Melee < Sprite
    
    include Module_Of_Config
    
    def initialize(character, view)
      @character = character.clone
      super(view)
      self.bitmap = Melee_Bit
      self.z = 60; self.blend_type = 1
      self.ox, self.oy = 16,16
      self.x, self.y = @character.screen_x, @character.screen_y - 8
      character!
      update
    end
    
    def update
      return if disposed?
      self.opacity > 0 ? self.opacity -= 6 : dispose
    end
    
    def character!
      case @character.direction
      when 2
        self.y += 8
        self.angle = 180
      when 4
        self.x -= 8
        self.angle = 90
      when 6
        self.x += 8
        self.angle = 270
      when 8
        self.y -= 8
        self.angle = 0
      end
    end
  end
 
  class Explosion < Sprite
 
    include Module_Of_Config
    attr_reader :event
    
    def initialize(x, y, viewport)
      super(viewport)
      @phase = 0; @timer = 30
      @event = Game_Character.new
      @event.moveto(x,y)
      self.z = 999
      self.bitmap = Bitmap.new(128,128)
      self.ox = 64; self.oy = 64
      self.x, self.y = @event.screen_x, @event.screen_y - 32
      RPG::SE.new(Explosion_SE, 100).play
      self.blend_type = Blend_Type
      self.bitmap.blt(0,0,Explosion_Bit,Rect.new(128 * @phase,0,128,128))
      self.viewport.flash(Color.new(255,105,0,190),30) if Flash
      @event = nil
      create_fragments
      update
      self.viewport.flash(Color.new(234,96,0),25)
    end
    
    def create_fragments
      @fragments = []
      for i in 0..Fragments - 1
        @fragments.push(Fragment.new(self.x, self.y, self.viewport))
      end
      @fragments.compact
    end
    
    def update_fragments
      trash = []
      @fragments.each {|sprite|
        sprite.update
        trash.push(sprite) if sprite.disposed?
      }
      trash.each {|item| @fragments.delete(item) if @fragments.include?(item)}
    end
    
    def update
      return if self.disposed?
      update_fragments
      self.bitmap.clear
      case @timer
      when 30
        @phase = 0
      when 27
        @phase = 1
      when 24
        @phase = 2
      when 21
        @phase = 3
      when 18
        @phase = 4
      when 15
        @phase = 5
      when 12
        @phase = 6
      when 9
        @phase = 7
      when 6
        @phase = 8
      when 3
        @phase = 9
      when 0
        self.dispose
      end
      if @timer == 0
        self.dispose if not self.disposed?
        return
      end
      @timer -= 1
      self.bitmap.blt(0,0,Explosion_Bit,Rect.new(128 * @phase,0,128,128))
    end
    
    def dispose
      super
      return if @fragments.nil?
      if [email protected]?
        @fragments.each {|frag|
          frag.dispose if not frag.disposed?
        }
        @fragments.clear
      end
    end
  end

  class Fragment < Sprite
    
    include Module_Of_Config
    
    def initialize(x, y, viewport)
      super()
      self.viewport = viewport
      r = rand(15)
      self.bitmap = Bitmap.new(32,32)
      self.z = 0
      self.bitmap.blt(0,0,Fragment_Bit,Rect.new(32 * r,0,32,32))
      self.blend_type = 2
      @vx, @vy = rand(Frag_Vel) - (Frag_Vel/2).to_i, rand(Frag_Vel) - (Frag_Vel/2).to_i
      self.x, self.y = x - 16, y - 16
    end
    
    def update
      return if self.disposed?
      self.x += @vx
      self.y += @vy
      self.opacity -= 9
    end
  end

  class Smoke < Sprite
    
    include Module_Of_Config
    
    def initialize(x, y, viewport)
      @event = Game_Character.new
      @event.moveto(x,y)
      super(viewport)
      self.bitmap = Smoke_Bit
      self.blend_type = 2
      self.opacity = 150
      self.z = 999 - 5
      self.x, self.y = @event.screen_x - 16, @event.screen_y - 32 - 16
      @event = nil
      @vx, @vy = rand(4) - 2, rand(4) - 2
      @vx = 1 if @vx == 0; @vy = 1 if @vy == 0
      @move_freq = Smoke_Freq
      update
    end
    
    def update
      return if self.disposed?
      if @move_freq > 0
        @move_freq -= 1
      else
        @move_freq = Smoke_Freq
        self.x += @vx
        self.y += @vy
      end
      self.opacity > 0 ? self.opacity -= 2 : dispose
    end
  end
 
  class Smoke2 < Sprite
    
    include Module_Of_Config
    
    def initialize(character, viewport)
      @character = character.clone
      direction = character.direction
      super(viewport)
      self.bitmap = Smoke_Bit
      self.blend_type = 2
      self.opacity = 150
      self.z = 0
      self.zoom_x, self.zoom_y = 0.3, 0.3
      case direction
      when 2
        self.x, self.y = @character.screen_x - 9, @character.screen_y + 6
      when 4
        self.x, self.y = @character.screen_x - 26, @character.screen_y - 19
      when 6
        self.x, self.y = @character.screen_x + 9, @character.screen_y - 21
      when 8
        self.x, self.y = @character.screen_x - 9, @character.screen_y - 36
      end
      @vx, @vy = rand(4) - 2, rand(4) - 2
      @vx = 1 if @vx == 0; @vy = 1 if @vy == 0
      @move_freq = Smoke_Freq + 2
      update
    end
    
    def update
      return if self.disposed?
      if @move_freq > 0
        @move_freq -= 1
      else
        @move_freq = Smoke_Freq + 2
        self.x += @vx
        self.y += @vy
      end
      self.opacity > 0 ? self.opacity -= 4 : dispose
    end
  end

  class Floor < Sprite
    
    attr_reader :event_x
    attr_reader :event_y
    
    def initialize(x,y,viewport)
      @event_x, @event_y = x,y
      super(viewport)
      self.z = 0
      self.ox, self.oy = 16,16
      self.bitmap = Module_Of_Config::Floor_Bit
      @event = Game_Character.new
      @event.moveto(x,y)
      self.x, self.y = @event.screen_x, @event.screen_y - 8
      self.z = @event.screen_z
    end
    
    def update
      self.x = @event.screen_x if self.x != @event.screen_x
      self.y =  @event.screen_y - 8 if self.y != @event.screen_y - 8
      self.z = @event.screen_z if self.z != @event.screen_z
    end
  end

  class PlayerWeapon < Sprite
    
    Sprite_z_values = { 2=>120, 4=>50, 6=>120, 8=>50}
    Sprite_Mirror = {2=>false,4=>false,6=>true,8=>false}
    
    Sprite_Angles = {2=>100, 4=>20, 6=>340, 8=>100}
    Move_correction = {2=>[2,-4],4=>[-7,-10],6=>[8,-14],8=>[-2,-18]}

    def initialize(view)
      super(view)
      self.bitmap = Bitmap.new(24,24)
      self.ox, self.oy = 12,12
      icon = $game_player.equipped_weapon.weapon.icon_index
      self.bitmap.blt(0,0,Cache.system("Iconset"), Rect.new(icon%16*24,icon/16*24,24,24))
      update
    end
    
    def update
      self.x = $game_player.screen_x + Move_correction[$game_player.direction][0]
      self.y = $game_player.screen_y + Move_correction[$game_player.direction][1]
      self.z = Sprite_z_values[$game_player.direction]
      self.angle = Sprite_Angles[$game_player.direction]
      self.mirror = Sprite_Mirror[$game_player.direction]
    end
  end
 
  class Blood < Sprite
    
    include Module_Of_Config
    
    def initialize(target, direction, view)
      @target, @direction = target, direction
      super(view)
      self.bitmap = Bitmap.new(32,32)
      rand = rand(7) + 3
      self.bitmap.blt(0,0,Blood_Bit, Rect.new(32 * rand,0,32,32))
      self.ox, self.oy = 16,16
      self.x, self.y = @target.screen_x, @target.screen_y - 8
      self.z = 30
      get_speed
      update
    end
    
    def update
      return if self.disposed?
      return if @vx.nil? or @vy.nil?
      if @target.nil?
        dispose; return
      end
      self.x += @vx
      self.y += @vy
      self.opacity > 0 ? self.opacity -= 6 : dispose
    end
    
    def get_speed
      case @direction
      when 2
        @vx = rand(4) - 2
        @vy = rand(4)
      when 4
        @vx = -rand(4)
        @vy = rand(4) - 2
      when 6
        @vx = rand(4)
        @vy = rand(4) - 2
      when 8
        @vx = rand(4) - 2
        @vy = -rand(4)
      end
    end
  end
 
  class Enemy_Shot < Sprite
    
    include Module_Of_Config
    
    def initialize(character, parts_array, view)
      super(view); @character = character; @direction = character.direction
      case @direction
      when 2; self.bitmap = Shot_Bit[:y]
      when 4; self.bitmap = Shot_Bit[:x]
      when 6; self.bitmap = Shot_Bit[:x]
      when 8; self.bitmap = Shot_Bit[:y]
      end
      self.ox, self.oy = 16,16
      self.x, self.y = character.screen_x, character.screen_y - 8
      @parts = parts_array
      @disposer = Game_Character.new
      @disposer.moveto(@character.x, @character.y)
      @disposer.set_direction(@direction)
      get_speed; update
    end
    
    def update
      return if self.disposed?
      case @disposer.direction
      when 2
        @disposer.moveto(@disposer.x, @disposer.y + 1)
        if [email protected]_passable?(@disposer.x, @disposer.y, @disposer.direction) or @disposer.collide_with_characters?(@disposer.x, @disposer.y) or $game_map.terrain_tag(@disposer.x, @disposer.y) == 1 and $game_map.counter?(@disposer.x, @disposer.y) != true
          dispose; return
        end
      when 4
        @disposer.moveto(@disposer.x - 1, @disposer.y)
        if [email protected]_passable?(@disposer.x, @disposer.y, @disposer.direction) or @disposer.collide_with_characters?(@disposer.x, @disposer.y) or $game_map.terrain_tag(@disposer.x, @disposer.y) == 1 and $game_map.counter?(@disposer.x, @disposer.y) != true
          dispose; return
        end
      when 6
        @disposer.moveto(@disposer.x + 1, @disposer.y)
        if [email protected]_passable?(@disposer.x, @disposer.y, @disposer.direction) or @disposer.collide_with_characters?(@disposer.x, @disposer.y) or $game_map.terrain_tag(@disposer.x, @disposer.y) == 1 and $game_map.counter?(@disposer.x, @disposer.y) != true
          dispose; return
        end
      when 8
        @disposer.moveto(@disposer.x, @disposer.y - 1)
        if [email protected]_passable?(@disposer.x, @disposer.y, @disposer.direction) or @disposer.collide_with_characters?(@disposer.x, @disposer.y) or $game_map.terrain_tag(@disposer.x, @disposer.y) == 1 and $game_map.counter?(@disposer.x, @disposer.y) != true
          dispose; return
        end
      end
      #self.x += @vx
      #self.y += @vy
      self.x, self.y = @disposer.screen_x, @disposer.screen_y - 8
      self.opacity > 0 ? self.opacity -= 25 : dispose
      return if self.disposed?
      if hit_area?(self.x, self.y)
        if @character.enemy.nil?
          dispose if not self.disposed?
          return
        else
          $game_player.damage_hero(@character.enemy.attack + @character.enemy.weapon.weapon.params[2], @character.enemy.weapon.pushback)
          SceneManager.scene.spriteset.blood($game_player, @character.direction) if SceneManager.scene.is_a?(Scene_Map)
          dispose if not self.disposed?
          return
        end
      end
      create_new_parts
    end
    
    def get_speed
      case @direction
      when 2
        @vx = 0
        @vy = 25
      when 4
        @vx = -25
        @vy = 0
      when 6
        @vx = 25
        @vy = 0
      when 8
        @vx = 0
        @vy = -25
      end
    end
    
    def create_new_parts
      return if self.disposed?
      3.times do
        case @direction
        when 2
          vx = 0
          vy = 1
        when 4
          vx = -1
          vy = 0
        when 6
          vx = 1
          vy = 0
        when 8
          vx = 0
          vy = -1
        end
        @parts.push(Part.new(self, self.viewport, vx, vy))
      end
    end
    
    def dispose
      super
      @disposer = nil
    end
    
    def area_x
      result = []
      init = ($game_player.screen_x - 16).to_i
      final = (init + 32).to_i
      for i in init..final
        result.push(i)
      end
      result.sort
    end
    
    def area_y
      result = []
      init = ($game_player.screen_y - 28).to_i
      final = (init + 32).to_i
      for i in init..final
        result.push(i)
      end
      result.sort
    end
    
    def hit_area?(x,y)
      return false if self.disposed?
      return true if area_x.include?(x) and area_y.include? (y)
      return false
    end
  end
 
  class Drop < Sprite
    
    attr_reader :character
    attr_reader :item
    
    def initialize(x, y, item, view, angle = nil)
      super(view)
      @character = Game_Character.new
      @character.moveto(x,y)
      @item = item
      self.ox, self.oy = 12,12
      self.bitmap = Bitmap.new(32,32)
      icon = item.icon_index
      if icon.nil?
        dispose; return
      end
      self.bitmap.blt(4,4,Cache.system("Iconset"), Rect.new(icon%16*24,icon/16*24,24,24))
      if angle.nil?
        self.angle += rand(60) - 30
      else
        self.angle = angle
      end
    end

    def update
      return if self.disposed?
      self.x, self.y = @character.screen_x, @character.screen_y - 16
      if self.viewport.nil?
        self.viewport = SceneManager.scene.spriteset.viewport1 if SceneManager.scene.is_a?(Scene_Map)
      end
      if player_in_range?
        if Input.trigger?(:C) or Input.repeat?(:C)
          pick_up
        end
      end   
    end
    
    def player_in_range?
      return true if $game_player.x == @character.x and $game_player.y == @character.y
      return true if $game_player.x - 1 == @character.x and $game_player.y == @character.y
      return true if $game_player.x + 1 == @character.x and $game_player.y == @character.y
      return true if $game_player.y - 1 == @character.y and $game_player.x == @character.x
      return true if $game_player.y + 1 == @character.y and $game_player.x == @character.x
      return false
    end
    
    def pick_up
      if $game_party.has_item?(@item, true)
        to_gain = nil
        $weapons.each {|w| next if w.weapon != @item; to_gain = w.magazine; break}
        $game_party.gain_item(to_gain,1)
      else
        $game_party.gain_item(@item,1)
        if $game_player.equipped_weapon.nil?
          to_equip = nil
          $weapons.each {|w| next if w.weapon != @item; to_equip = w; break}
          $game_player.equipped_weapon = to_equip
          $game_party.members[0].change_equip(0,@item)
          SceneManager.scene.spriteset.refresh!
          $game_player.need_check = true
          $game_party.lose_item(@item,1)
        end
      end
      RPG::SE.new("#{Module_Of_Config::Pick_SE}", 90).play
      dispose if not disposed?
    end
    
    def dispose
      super
      @character = nil; @item = nil
    end
  end
 
  class Enemy_Area < Game_Character
    
    include Module_Of_Config
    attr_accessor :sprite
    
    def initialize(character, view)
      super(); @character = character.clone; @view = view
      @move_speed = 7
      @move_frequency = 3
      @travel = 0
      @through = true
      set_graphic(AreaChar, 0); @disposed = false
      @sprite = Sprite_Character.new(view,self)
      moveto(@character.x, @character.y); set_direction @character.direction
      update
    end
    
    def update
      return if self.disposed?
      @sprite.update if not @sprite.disposed?
      if !destination_reached?
        if @character.enemy.nil?
          dispose; return
        end
        move_straight(@direction)
        @travel += 1
        SceneManager.scene.spriteset.smoke.push(Smoke.new(@x, @y, @view))
        if @x == $game_player.x and @y == $game_player.y
          SceneManager.scene.spriteset.explode(@x, @y)
          $game_player.damage_hero(@character.enemy.attack + @character.enemy.weapon.weapon.params[2])
          dispose if not self.disposed?
        end
        if @travel >= 8
          SceneManager.scene.spriteset.explode(@x, @y)
          if $game_player.x - 1 == @x and $game_player.y == @y
            $game_player.damage_hero((@character.enemy.attack + @character.enemy.weapon.weapon.params[2] / 2).to_i)
          elsif $game_player.x + 1 == @x and $game_player.y == @y
            $game_player.damage_hero((@character.enemy.attack + @character.enemy.weapon.weapon.params[2] / 2).to_i)
          elsif $game_player.y + 1 == @y and $game_player.x == @x
            $game_player.damage_hero((@character.enemy.attack + @character.enemy.weapon.weapon.params[2] / 2).to_i)
          elsif $game_player.y - 1 == @y and $game_player.x == @x
            $game_player.damage_hero((@character.enemy.attack + @character.enemy.weapon.weapon.params[2] / 2).to_i)
          end
          dispose if not self.disposed?
        end
      else
        dispose if not self.disposed?
      end
    end
    
    def destination_reached?
      return true if @x == @fx and @y == @fy
      return false
    end
    
    def dispose
      @disposed = true
      @sprite.dispose if not @sprite.disposed?
      @sprite = nil
    end
    
    def disposed?
      @disposed
    end
    
    def area_x
      result = []
      init = ($game_player.screen_x - 16).to_i
      final = (init + 32).to_i
      for i in init..final
        result.push(i)
      end
      result.sort
    end
    
    def area_y
      result = []
      init = ($game_player.screen_y - 28).to_i
      final = (init + 32).to_i
      for i in init..final
        result.push(i)
      end
      result.sort
    end
    
    def hit_area?(x,y)
      return true if area_x.include?(x) and area_y.include? (y)
      return false
    end
  end
 
  class Dep < Sprite
    def initialize(x, y, view)
      super(view)
      @char = Game_Character.new
      @char.moveto(x,y)
      self.bitmap = Bitmap.new(32,32)
      self.ox, self.oy = 16,16
      self.x, self.y = @char.screen_x, @char.screen_y - 8
      self.bitmap.fill_rect(0,0,32,32,Color.new(255,255,255,200))
    end
  end
end

class Reload < Sprite
 
  def initialize(frames, view, max = nil)
    if max.nil?
      @frames = frames; @max = frames
     else
      @frames = frames; @max = max
    end
    $last_max, $last_frame = nil,nil
    super(view)
    self.bitmap = Bitmap.new(128,26)
    self.ox, self.oy = self.bitmap.width / 2, self.bitmap.height / 2
    self.x, self.y = 544/2,416/2 + 100
    self.bitmap.font.color = Color.new(255,216,0)
    self.bitmap.font.bold = true
    self.bitmap.font.size = 14
    create_base
    update
  end
 
  def update
    return if self.disposed?
    self.bitmap.clear
    create_base
    if @frames > 0
      @frames -= 1
    else
      RPG::SE.new(Module_Of_Config::Clip_IN_SE, 100).play
      dispose if not self.disposed?
      return
    end
    wd = 124 * @frames / @max; wd = 124 - wd
    self.bitmap.fill_rect(2,2,wd,22,Color.new(255,216,0))
    self.bitmap.draw_text(12,4,90,20,"RELOADING...")
  end
 
  def create_base
    return if self.disposed?
    self.bitmap.fill_rect(0,0,128,26,Color.new(255,216,0))
    self.bitmap.fill_rect(1,1,126,24,Color.new())
  end
 
  def store
    $last_frame = @frames
    $last_max   = @max
    dispose if not self.disposed?
  end
end

if Module_Of_Config::WASD_Movement
  class Window_Selectable < Window_Base
    def process_cursor_move
      return unless cursor_movable?
      last_index = @index
      cursor_down (Input.trigger?(:DOWN))  if Input.repeat?(:DOWN)
      cursor_up   (Input.trigger?(:UP))    if Input.repeat?(:UP)
      cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
      cursor_left (Input.trigger?(:LEFT))  if Input.repeat?(:LEFT)
      cursor_down (Input.trigger?(Key::S))  if Input.repeat?(Key::S)
      cursor_up   (Input.trigger?(Key::W))    if Input.repeat?(Key::W)
      cursor_right(Input.trigger?(Key: :D)) if Input.repeat?(Key: :D)
      cursor_left (Input.trigger?(Key::A))  if Input.repeat?(Key::A)
      cursor_pagedown   if !handle?(:pagedown) && Input.trigger?(:R)
      cursor_pageup     if !handle?(:pageup)   && Input.trigger?(:L)
      Sound.play_cursor if @index != last_index
    end
  end
end

if Module_Of_Config::Enter_Key2 != nil
  class << Input
    alias normal_trigger? trigger?
    alias normal_repeat? repeat?
    alias normal_press? press?
    
    def trigger?(key)
      if key == :C
        if normal_trigger?(:C) == false
          return normal_trigger?(Module_Of_Config::Enter_Key2)
        else
          true
        end
      else
        normal_trigger?(key)
      end
    end
    def repeat?(key)
      if key == :C
        if normal_repeat?(:C) == false
          return normal_repeat?(Module_Of_Config::Enter_Key2)
        else
          true
        end
      else
        normal_repeat?(key)
      end
    end
    def press?(key)
      if key == :C
        if normal_press?(:C) == false
          return normal_press?(Module_Of_Config::Enter_Key2)
        else
          true
        end
      else
        normal_press?(key)
      end
    end
  end
end

#-----##-----##-----##-----##-----##-----##-----##-----##-----##-----##-----#
# FIM ## FIM ## FIM ## FIM ## FIM ## FIM ## FIM ## FIM ## FIM ## FIM ## FIM #
#-----##-----##-----##-----##-----##-----##-----##-----##-----##-----##-----#

 

 

in particolare questo è il comando che imposta la distanza di "allerta" dei nemici

Default_Follow = 0 # Valor padrão para visão dos inimigos

lo impostato a 0 ma rimane comunque attivo. Qualcuno può aiutarmi? Grazie in anticipo. smile.png

 

Condividi questo messaggio


Link di questo messaggio
Condividi su altri siti

Crea un account o accedi per lasciare un commento

You need to be a member in order to leave a comment

Crea un account

Iscriviti per un nuovo account nella nostra comunità. È facile!

Registra un nuovo account

Accedi

Sei già registrato? Accedi qui.

Accedi Ora

  • Contenuti simili

    • Da Deyan87
      Non capisco perchè mi da questo errore, mi sapete aiutare?

    • Da Deyan87
      Sto provando il BS Tankentai sapete se c'è un modo per far animare anche i mostri?
    • Da Brainmax
      Salve di nuovo
      ho riscontrato un problema con i light scripts di victor.
      quando provo ad andare sul sito per gli script, dropbox mi fa errore 404
      (il file e' stato temporaneamente rimosso)
      volevo domandare se qualcuno li aveva per gentimente offirmeli
      ringrazio in anticipo
    • Da gianchy
      Salve ragazzi avrei un problema con uno script.
      In pratica l'errore è questo:  Script 'Window_BattleStatus' line 52: TypeError occurred. no implicit conversion from nil to integer
      E si verifica quando uso l'evocazione durante il combattimento qualcuno sa come risolverlo?
       
      Gli script che attualmente ho installato sono:
      -Yami Engine Symphony
      -Victor Engine - Basic Module
      -8 Direzioni
      -Enemy HUD (By Pacman)
      -Battle Command List v1.09b
      -Skill Restrictions v1.03
      -Ace Menu Engine v1.07
      -Crystal Engine - Basic Module
      -Guardian Forces
      -GF Junction
      -GF Menu
      -GF Items
      -GF Summon
      -Hide Skill Types
       
      Mi affido alla vostra maggior conoscenza degli script
    • Da Dreamghost
      Sto riscontrando dei problemi con questo script che non mi capacito di capire. 
       
      Copio grezzamente lo script e va tutto bene, do un occhiata alle istruzioni e inizio a scrivere i talenti per il primo personaggio. Ne faccio 3-4, tutto funziona nei limiti del programmato. Finisco di scrivere questi talenti, e la situazione quando avvio il gioco è questa:

       
      Qualcuno ha già usato questo script prima di me e ha riscontrato lo stesso problema? 

      Rassegnato ormai provo il predecessore di questo script, una versione meno potetente e più basica. 

      La copio grezzamente, avvio, tutto ok. Leggo le istruzioni, scrivo il primo talento e..


       
      Sono punto e a capo. Mi viene il dubbio di non aver capito come si fa a personalizzare lo script ò_ò

      Qualcuno che lo ha già fatto?
×