[XP] Auto-Targeting for Blizz-ABS

Started by Blizzard, July 26, 2009, 02:57:49 pm

Previous topic - Next topic

Blizzard

July 26, 2009, 02:57:49 pm Last Edit: March 23, 2019, 11:38:42 am by Blizzard
Auto-Targeting for Blizz-ABS
Authors: Blizzard
Version: 1.11b
Type: Blizz-ABS Plugin
Key Term: Blizz-ABS Plugin



Introduction

It will allow you to set a target for the actor before using a skill or item that requires the selection screen.

This script is to be distributed under the same terms and conditions like the script it was created for: Blizz-ABS.


Features


  • when targeting an enemy, every skill and item that would normally call the selection screen now execute on that target immediately
  • toggle it on and off
  • cycle through targets
  • optional auto-facing of target



Screenshots

Spoiler: ShowHide



Demo

N/A


Script

Just make a new script above main and paste this code into it.
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 = 48
  # button for target toggle
  TARGET_TOGGLE_KEY = Input::Key['Q']
  # button for target change
  TARGET_CHANGE_KEY = Input::Key['E']
  # 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
    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)
    @character = character
    update
  end
 
  def update
    @character = $BlizzABS.autotarget
    if @character == nil
      @loop_animation_id = 0
      loop_animation(nil)
      return
    end
    super
    if @loop_animation_id == 0
      @loop_animation_id = BlizzCFG::TARGET_ANIMATION_ID
      loop_animation($data_animations[@loop_animation_id])
    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

In the script in the first comment.


Compatibility

Requires Blizz-ABS to work.


Credits and Thanks


  • Boris "Blizzard" Mikić



Author's Notes

Keep in mind that this plugin comes RIGHT UNDER Blizz-ABS. This script was done on request and is not fully supported by me as my other scripts are.

If you find any bugs, please report them here:
http://forum.chaos-project.com

That's it! N-Joy! =D
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Aqua


Subsonic_Noise

Thanks. Thanks. Thanks. Thanks. Thanks. Thanks. Thanks. Thanks. Thanks. Thanks. Thanks. Thanks. Thanks. Thanks.

I'll try it, too.

Blizzard

There was a slight problem. I improved and updated the script.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

winkio

July 26, 2009, 05:12:11 pm #4 Last Edit: July 26, 2009, 05:30:52 pm by winkio
something tells me that with Blizz's awesome AI, this would really screw you over if you were fighting four or more enemies at once.  Good for small groups of enemies anyways though.

nathmatt

Level++ blizz for this this will go great with my battle dome script when i get all the problems worked out
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


legacyblade

This looks like it can be a freaking awesome script. But I do agree with winkio, as the targeting system would get a bit whacky if there were too many enemies nearby. But then again, that's why it's like Zelda's Z targeting system, you only use it when you need to. It should make a great addition to any game.

Axerax

I was going to suggest making the toggle button select the nearest enemy, as long as the button is held, just like Z targeting in Zelda. Once released it erases the targeting allowing for player movement. This will help for rooms with lots of enemies and crowding. You'd have to make the Z-Targeting acquire the enemy through an arc direction in front of the player instead of in all around, as well limit how many tiles ahead it can see, cause i've been targeting stuff way off my field of view.

Blizzard

Honestly, I was too lazy to implement the target selection of the closest enemy. As for the rest of the target selection, only enemies visible in the screen are targeted with the current version. Of course, that all can be edited. I was just too lazy. :P
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Subsonic_Noise

Uhm, Blizz, there is a problem: It works perfectly except that the targeting screen still comes up o.O

Blizzard

Yes, it comes up when you have no autotarget. That's not a bug.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Subsonic_Noise

No, even when I have one. I'll make a video if you don't believe me XD
Can I somehow also disable it when I have no autotarget, btw?

Blizzard

July 27, 2009, 06:20:42 am #12 Last Edit: July 27, 2009, 06:21:56 am by Blizzard
Look:

if result && $BlizzABS.autotarget != nil && $game_temp.select_data != nil
 ...
 $game_temp.select_data = nil
end


"If the skill can be used and there is a target and selection screen should be displayed, remove the selection screen display request."
The selection screen can't appear if you have an autotarget. It can't. Whatever happens afterwards or before that, it can't appear when there is an autotarget.

If you want the selection screen to never appear, move the "$game_temp.select_data = nil" below that "end". There are two lines where you have to do this.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Subsonic_Noise

July 27, 2009, 06:44:34 am #13 Last Edit: July 27, 2009, 07:16:19 am by Subsonic_Noise
But it does open the targeting scene when I have an enemy selected. I made a video but I can't upload it because of my shitty internet. >.< So you'll have to believe me. Or could I upload it as an attachment? That alwayws worked.

Ok, just to make this even stranger, it just does it for 1 skill o.O
My other skill works without a problem.

Blizzard

What is the skill? Which type is it? What is the target scope?
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Subsonic_Noise

It's a homing skill. Direct skills work without problems. This one worked one out of ~50 times o.O

Blizzard

That's very weird. Homing skills were pretty much the ones I tested this one. :/ I'll look into it.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Kagutsuchi

August 01, 2009, 06:58:47 pm #17 Last Edit: August 01, 2009, 07:01:02 pm by Kagutsuchi
Only issue I have discovered so far is that if you have any enemies which requires a switch or a variable to be active, the game tends to target them rather than enemies that are already moving, so to speak. Somewhat annoying.

Axerax

Quote from: Kagutsuchi on August 01, 2009, 06:58:47 pm
Only issue I have discovered so far is that if you have any enemies which requires a switch or a variable to be active, the game tends to target them rather than enemies that are already moving, so to speak. Somewhat annoying.


I have this problem too. I've been waiting for a fix on this for a bit now.

Blizzard

August 18, 2009, 04:11:09 am #19 Last Edit: August 19, 2009, 03:45:52 am by Blizzard
I'll see if I can find some time today to fix it then.

EDIT: Ok, I did "fix" something, but I don't think it's related to this. I never had problems with targeting enemies that are turned off by a switch or a variable, though. :/
Try it out, maybe I did fix what was causing your problems.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.