Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: Epherex on August 16, 2014, 11:38:01 am

Title: Blizz-ABS - Change View Ranges of every enemy in the map
Post by: Epherex on August 16, 2014, 11:38:01 am
Hey, I'm creating a Blizz-ABS game and I wanted to know if I can, when certain switch is on, set the vision range of all enemies in the map to 0.
I've searched a lot and still can't find a solution.
This would be for an invisibility system, that when the actor uses a certain item, a switch activates and no enemies can see the player.

English is not my native language, so I could have mistaken some words. Sorry for that.
Thanks.
Title: Re: Blizz-ABS - Change View Ranges of every enemy in the map
Post by: KK20 on August 17, 2014, 02:17:47 am
You're going to have to make a small edit to achieve this. CTRL + SHIFT + F and search for :view_range. Go to the line it takes you to and change it into this:
attr_accessor :view_range

Your script call will look like this:

e = $BlizzABS.get_enemies(TROOP)
e.each{|enemy|
enemy.ai.view_range = 0
}

This will get all the enemies on the map and assign them a vision of zero. This effect goes away as soon as you teleport to a different map. Also note that your enemies will no longer hear or perceive anything since they are based off of the vision's value.
Title: Re: Blizz-ABS - Change View Ranges of every enemy in the map
Post by: Epherex on August 17, 2014, 03:17:21 pm
Quote from: KK20 on August 17, 2014, 02:17:47 am
You're going to have to make a small edit to achieve this. CTRL + SHIFT + F and search for :view_range. Go to the line it takes you to and change it into this:
attr_accessor :view_range

Your script call will look like this:

e = $BlizzABS.get_enemies(TROOP)
e.each{|enemy|
enemy.ai.view_range = 0
}

This will get all the enemies on the map and assign them a vision of zero. This effect goes away as soon as you teleport to a different map. Also note that your enemies will no longer hear or perceive anything since they are based off of the vision's value.


Thank you.
However, I had to change $BlizzABS.get_enemies(TROOP) to $game_map.battlers for it to work (I think this can cause problems). Isn't TROOP supposed to be something else?

EDIT:
I have a problem: When the enemies already saw me and I use the item that turns me invisible, they can still attack me. Isn't there something that can clear their "memory"? This way, the enemies can't go after me even if they saw me before.

EDIT 2:
Got it.
Used this code:
e = $BlizzABS.get_enemies(BlizzABS::TROOP)
e.each{|enemy|
enemy.ai.view_range = 0
enemy.ai.memory = {}
}
Title: Re: Blizz-ABS - Change View Ranges of every enemy in the map
Post by: LiTTleDRAgo on August 18, 2014, 12:04:10 am
try this

#============================================================================
# BlizzABS::AI::Data_Enemy
#----------------------------------------------------------------------------
#  This class processes Map_Enemy AI based upon AI Data, character position
#  and battler status. It includes complete AI control for both actors and
#  enemies.
#============================================================================
class BlizzABS::AI::Data_Enemy
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  $@ || alias_method(:memory_invisible,     :memory)
  $@ || alias_method(:view_range_invisible, :view_range)
  #--------------------------------------------------------------------------
  # * player_invisible?
  #--------------------------------------------------------------------------
  def player_invisible?
    return true if $game_switches[1]
    #return true if $game_player.invisible
    # add as much as you want
    return false
  end
  #--------------------------------------------------------------------------
  # * memory
  #--------------------------------------------------------------------------
  def memory(*args)
    return {} if player_invisible?
    memory_invisible(*args)
  end
  #--------------------------------------------------------------------------
  # * view_range
  #--------------------------------------------------------------------------
  def view_range(*args)
    return 0 if player_invisible?
    view_range_invisible(*args)
  end
end


NB : Untested
Title: Re: Blizz-ABS - Change View Ranges of every enemy in the map
Post by: Epherex on August 18, 2014, 04:17:23 pm
Quote from: LiTTleDRAgo on August 18, 2014, 12:04:10 am
try this

#============================================================================
# BlizzABS::AI::Data_Enemy
#----------------------------------------------------------------------------
#  This class processes Map_Enemy AI based upon AI Data, character position
#  and battler status. It includes complete AI control for both actors and
#  enemies.
#============================================================================
class BlizzABS::AI::Data_Enemy
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  $@ || alias_method(:memory_invisible,     :memory)
  $@ || alias_method(:view_range_invisible, :view_range)
  #--------------------------------------------------------------------------
  # * player_invisible?
  #--------------------------------------------------------------------------
  def player_invisible?
    return true if $game_switches[1]
    #return true if $game_player.invisible
    # add as much as you want
    return false
  end
  #--------------------------------------------------------------------------
  # * memory
  #--------------------------------------------------------------------------
  def memory(*args)
    return {} if player_invisible?
    memory_invisible(*args)
  end
  #--------------------------------------------------------------------------
  # * view_range
  #--------------------------------------------------------------------------
  def view_range(*args)
    return 0 if player_invisible?
    view_range_invisible(*args)
  end
end


NB : Untested


Thanks man, that's much better! Worked nicely.