07-07-2014, 03:40 AM
I have the demo. I inserted the ATB addon (not the CTB addon) above the counter attack script, and then set up 'ALL' my actors to perform a simple general attack if they were themselves attacked. Each one had:
in their case. I deleted everything else as I didn't want any counter attack except that one. And I got nothing.
I then swapped the ATB addon with the CTB. Hey, you can't use both at the same time. And with the same luck.... none.
I did some testing, and found the set_counter_condition method that detects who the attacker and defender are, and confirmed that it is passing the data, but the freakin counter attack isn't HAPPENING!!!!
You want a reaction if actor #17 is attacked by an enemy, right? Fine. I wrote an end run around. Paste THIS below the counterattack script. Just remember that the counter attack script needs either the ATB or CTB addon too.
I set the actor to be tested as actor #17, he requires to be inflicted by state #91, and I 'nil'ed out the enemy data, so any enemy attacking him will turn on an RPGMaker switch. That switch, I defined as switch #15.
These are editable at the top of the script.
You wanted a conditional branch to occur if an actor was attacked? There you go.
Just be sure to reset the switch when needed.
Code:
{'type' => 4 } => {'type' => 0}
I then swapped the ATB addon with the CTB. Hey, you can't use both at the same time. And with the same luck.... none.
I did some testing, and found the set_counter_condition method that detects who the attacker and defender are, and confirmed that it is passing the data, but the freakin counter attack isn't HAPPENING!!!!
You want a reaction if actor #17 is attacked by an enemy, right? Fine. I wrote an end run around. Paste THIS below the counterattack script. Just remember that the counter attack script needs either the ATB or CTB addon too.
Code:
# COUNTER ATTACK ADDENDUM
# This system merely uses Atoa's counter attack system for the purposes of
# turning on a switch which can be used to trigger an event, be it a battle
# event or map event.
#
DEFENDING_ACTOR = 17 # This is your chosen actor (You'll prolly use 17)
DEFENDING_STATE = 91 # If the actor has to be status inflicted (else nil)
ENEMY_INDEX = nil #2 # Know the index of the enemy? If not, set to nil
AGGRESSIVE_ENEMY_ID = nil #1 # Want to go by an ID Enemy Database ID?
COUNTER_SWITCH_ID = 15 # This sets what RMXP switch is turned on for your
# responce
#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
# This class handles temporary data that is not included with save data.
# Refer to "$game_temp" for the instance of this class.
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias counter_attack_addon_initialize initialize
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :battle_enemy_index # Index of current enemy in battle
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# The original call
counter_attack_addon_initialize
@battle_enemy_index = 0
end
end
#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
# This class deals with battlers. It's used as a superclass for the Game_Actor
# and Game_Enemy classes.
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias counter_attack_addon_set_counter_condition set_counter_condition
#--------------------------------------------------------------------------
# * Set counter condition
# user : user
# damage : damage
# skill : skill
#--------------------------------------------------------------------------
def set_counter_condition(user, damage, skill = nil)
if self.actor?
if self.id == DEFENDING_ACTOR
if user.is_a?(Game_Enemy)
flag_0 = false
flag_0 = self if user.states.include?(DEFENDING_STATE)
flag_0 = true if DEFENDING_STATE.nil?
flag_1 = false
flag_1 = true if user.id == AGGRESSIVE_ENEMY_ID
flag_1 = true if AGGRESSIVE_ENEMY_ID.nil?
flag_2 = false
flag_2 = true if $game_temp.battle_enemy_index == ENEMY_INDEX
flag_2 = true if ENEMY_INDEX.nil?
# If all conditions are met
if (flag_0 && flag_1 && flag_2)
$game_switches[COUNTER_SWITCH_ID] = true
return
end
end
end
end
# The original call
counter_attack_addon_set_counter_condition(user, damage, skill)
end
end
I set the actor to be tested as actor #17, he requires to be inflicted by state #91, and I 'nil'ed out the enemy data, so any enemy attacking him will turn on an RPGMaker switch. That switch, I defined as switch #15.
These are editable at the top of the script.
You wanted a conditional branch to occur if an actor was attacked? There you go.
Just be sure to reset the switch when needed.