Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: chaucer on July 08, 2013, 01:56:59 pm

Title: [XP] Blizz ABS Auto-Targeting + Mouse
Post by: chaucer on July 08, 2013, 01:56:59 pm
Auto-Targeting for Blizz-ABS + Mouse
Authors: Blizzard, chaucer
Version: 1.11
Type: Blizz ABS Plugin
Key Term: Blizz-ABS Plugin



Introduction
Allows you to select an enemy before using skills & items



Features




Screenshots
Spoiler: ShowHide
(http://i36.servimg.com/u/f36/18/11/80/75/mouse_10.png)




Demo

N/A if you need one just ask :)


Script


Spoiler: ShowHide

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Auto-Targeting for Blizz-ABS by Blizzard
# Version: 1.11b
# Type: Blizz-ABS Add-on
# Date: 26.7.2009
# Date v1.0b: 26.7.2009
# Date v1.1b: 19.8.2009
# Date v1.11b: 26.11.2009
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
#  This script is to be distributed under the same terms and conditions like
#  the script it was created for: Blizz-ABS.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Information:
#
#   This script must be placed RIGHT BELOW Blizz-ABS and requires Blizz-ABS
#   v2.6 or higher to work properly. It will allow you to set a target for the
#   actor before using a skill or item that requires the selection screen.
#
#
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

if !$BlizzABS || BlizzABS::VERSION < 2.6
 raise 'ERROR: The "Auto-Targeting" plugin requires Blizz-ABS 2.6 or higher.'
end

#==============================================================================
# module BlizzCFG
#==============================================================================

module BlizzCFG
 
 #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 # START Configuration
 #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
 # animation ID of animation to play over the target
 TARGET_ANIMATION_ID = 1      #ID of Animation or nil for Arrow Base
 #button for mouse toggle
 TARGET_MOUSE_KEY = Input::Key['Mouse Left']
 # button for target toggle
 TARGET_TOGGLE_KEY = Input::Key['Q']
 # button for target change
 TARGET_CHANGE_KEY = Input::Key['E']
 # choose if the arrow is ahove or below target(if TARGET_ANIMATION_ID = nil)
 TARGET_ABOVE = false
 # auto facing the target all the time
 AUTO_TURNING = false
 
 #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 # END Configuration
 #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

end

$blizzabs_auto_target = 1.11

#==============================================================================
# BlizzABS::Processor
#==============================================================================

class BlizzABS::Processor
 
 attr_accessor :autotarget
 
end
 
#==============================================================================
# BlizzABS::Controls
#==============================================================================

class BlizzABS::Controls
 
 alias update_attack_autotarget_later update_attack
 def update_attack
   if $BlizzABS.autotarget == nil
     if Input.trigger?(BlizzCFG::TARGET_TOGGLE_KEY) ||
         Input.trigger?(BlizzCFG::TARGET_CHANGE_KEY)
       targets = $game_map.battlers.find_all {|b| b.valid? && b.in_screen?}
       $BlizzABS.autotarget = targets[0] if targets.size > 0
     end
#===============================================================================
#Mouse Controls
     if Input.trigger?(BlizzCFG::TARGET_MOUSE_KEY)
       targets = $game_map.battlers.find_all {|b| b.valid? && b.in_screen? && b.mouse_in_area?}
       $BlizzABS.autotarget = targets[0]
     end

   elsif Input.trigger?(BlizzCFG::TARGET_MOUSE_KEY)
       targets = $game_map.battlers.find_all {|b| b.valid? && b.in_screen? && b.mouse_in_area?}
       index = $game_map.battlers.any?{|b| b.valid? && b.mouse_in_area?}
       $BlizzABS.autotarget = targets[0] if targets[0] !=nil
       # end
#===============================================================================
   elsif Input.trigger?(BlizzCFG::TARGET_TOGGLE_KEY)
     $BlizzABS.autotarget = nil
   elsif Input.repeat?(BlizzCFG::TARGET_CHANGE_KEY)
     targets = $game_map.battlers.find_all {|b| b.valid? && b.in_screen?}
     index = targets.index($BlizzABS.autotarget)
     $BlizzABS.autotarget = targets[(index + 1) % targets.size] if index != nil
   end
   if $BlizzABS.autotarget != nil && (!$BlizzABS.autotarget.in_screen? ||
       !$BlizzABS.autotarget.valid?)
     $BlizzABS.autotarget = nil
   end
   return update_attack_autotarget_later
 end
 
 alias update_skill_autotarget_later update_skill
 def update_skill
   result = update_skill_autotarget_later
   if result && $BlizzABS.autotarget != nil && $game_temp.select_data != nil
     characters = []
     $game_temp.select_data[3].each {|s| characters.push(s.character)}
     if characters.include?($BlizzABS.autotarget)
       $game_player.ai.target = $BlizzABS.autotarget
       $game_player.use_skill($game_temp.select_data[0])
     else
       $game_system.se_play($data_system.buzzer_se)
     end
     $game_temp.select_data = nil
   end
   return result
 end
 
 alias update_item_autotarget_later update_item
 def update_item
   result = update_item_autotarget_later
   if result && $BlizzABS.autotarget != nil && $game_temp.select_data != nil
     characters = []
     $game_temp.select_data[3].each {|s| characters.push(s.character)}
     if characters.include?($BlizzABS.autotarget)
       $game_player.ai.target = $BlizzABS.autotarget
       $game_player.use_item($game_temp.select_data[0])
     else
       $game_system.se_play($data_system.buzzer_se)
     end
     $game_temp.select_data = nil
   end
   return result
 end
 
end

$BlizzABS = BlizzABS::Processor.new

#==============================================================================
# Game_Character
#==============================================================================

class Game_Character
 
 attr_accessor :direction_fix

end

#==============================================================================
# Spriteset_Map
#==============================================================================

class Sprite_Targeter < RPG::Sprite
 
 attr_accessor :character
 def initialize(viewport, character = nil)
   super(viewport)
   self.bitmap = Bitmap.new(1, 1) if BlizzCFG::TARGET_ANIMATION_ID !=nil
   @character = character
   @blink_count = 0
   update
 end

 def update
   @character = $BlizzABS.autotarget
   if @character == nil
     self.bitmap = nil
     @loop_animation_id = 0
     loop_animation(nil)
     return
   end
   super
   @blink_count += 1 if BlizzCFG::TARGET_ANIMATION_ID ==nil
    @blink_count = 0 if @blink_count == 8
    self.bitmap = RPG::Cache.windowskin($game_system.windowskin_name) if BlizzCFG::TARGET_ANIMATION_ID ==nil
    self.ox = self.bitmap.width / 12 if BlizzCFG::TARGET_ANIMATION_ID ==nil
    self.oy = 0 if BlizzCFG::TARGET_ABOVE == false && BlizzCFG::TARGET_ANIMATION_ID ==nil
    self.oy = -(self.bitmap.height) + 64  if BlizzCFG::TARGET_ABOVE == true &&  BlizzCFG::TARGET_ANIMATION_ID ==nil
    self.mirror = true if BlizzCFG::TARGET_ABOVE == true
    self.angle = 180 if BlizzCFG::TARGET_ABOVE == true
    self.z = 0
    if @blink_count < 4
     self.src_rect.set(128, 96, 32, 32) if BlizzCFG::TARGET_ANIMATION_ID ==nil
   else
     self.src_rect.set(160, 96, 32, 32) if BlizzCFG::TARGET_ANIMATION_ID ==nil
   end
   if @loop_animation_id == 0
     @loop_animation_id = BlizzCFG::TARGET_ANIMATION_ID
     loop_animation($data_animations[@loop_animation_id]) if BlizzCFG::TARGET_ANIMATION_ID !=nil
   end
   self.x = @character.screen_x
   self.y = @character.screen_y
   self.z = @character.screen_z(0)
 end
 

end

#==============================================================================
# Spriteset_Map
#==============================================================================

class Spriteset_Map
 
 alias init_autotarget_later initialize
 def initialize
   @autotarget = Sprite_Targeter.new(@viewport1)
   init_autotarget_later
 end
 
 alias update_autotarget_later update
 def update
   @autotarget.update
   if BlizzCFG::AUTO_TURNING && $BlizzABS.autotarget != nil
     $game_player.turn_toward($BlizzABS.autotarget)
   end
   update_autotarget_later
 end
 
 alias dispose_autotarget_later dispose
 def dispose
   @autotarget.dispose
   @autotarget = nil
   dispose_autotarget_later
 end
 
end



Instructions

Place Below Blizz ABS (Instructions in script)


Compatibility

Requires Blizz-ABS & Mouse Controler to work


Credits and Thanks




Author's Notes

None
Title: Re: [XP] Blizz ABS Auto-Targeting + Mouse
Post by: Blizzard on July 08, 2013, 06:56:25 pm
You forgot to include yourself in the credits. xD *fixes*
Title: Re: [XP] Blizz ABS Auto-Targeting + Mouse
Post by: chaucer on March 18, 2014, 03:39:10 am
updated
- Fixed arrow flashing animation when set to nil
- Added option to choose if the arrow is above or below enemy
Title: Re: [XP] Blizz ABS Auto-Targeting + Mouse
Post by: glad300 on May 25, 2014, 03:57:09 am
Hello, when I click on an ennemy a error window tells me that there is no mouse_in_area? method for Map_Enemy class... I tried to fix this myself but I can't so Im asking for your help  :roll:
Title: Re: [XP] Blizz ABS Auto-Targeting + Mouse
Post by: chaucer on May 25, 2014, 04:48:08 am
sorry, forgot to mention requires MCES(Mouse Controller Enhancement Script) found here http://forum.chaos-project.com/index.php/topic,5909.0.html (http://forum.chaos-project.com/index.php/topic,5909.0.html) i'll update the main post tomorrow, too tired now and internets going too slow. hope that helps :)
Title: Re: [XP] Blizz ABS Auto-Targeting + Mouse
Post by: glad300 on May 25, 2014, 05:44:14 am
Thats okay, thanks for your help