06-21-2022, 02:11 AM
Um... allow me to point out that ... no counter will work? Now, I will also say that I ran into no error messages with this. But no counter will work at all. Allow me to set the example text below in Courier New so you can see...
# Actor Counters
# ==============
# Define the actors perfoming counter attacks: the chance of a counter,
# the skill ID used (or 0 for melee), and optionally the SP cost.
#
# Chance Skill SPCost
#========== ====== ====== ======
ACTOR[2] = [ 0, 0] # Basil delivers melee 0%
# Enemy Counters
# ==============
# Define the enemies perfoming counter attacks: the chance of a counter,
# the skill ID used (or 0 for melee), and optionally the SP cost.
#
# Chance Skill SPCost
#========== ====== ====== ======
ENEMY[1] = [ 0, 7, true] # Ghosts use Fire 0% (never)
This is your config, spaced out and lined up... and the first value in the array is 'chance of performing'. In both your cases, you have NONE.
Now... here's the kick.
def counterattack_phase4_step5
#
# Cycle through targets
for target in @target_battlers
#
# Next if no damage
next if target.damage.nil?
#
# Next if paralyzed - 'Can't Move'
next if target.restriction == 4
#
# Skip if no HP loss (healing ignored)
next unless (target.damage).to_i > 0
# Skip if attack was a counter
next if @counterattack == true
#
# Define chance
chance = 0
# Determine counterattack chance for enemy/actor
if target.is_a?(Game_Enemy)
if CounterAttack::ENEMY.has_key?(target.id)
chance = CounterAttack::ENEMY[target.id][0]
end
else
if CounterAttack::ACTOR.has_key?(target.id)
chance = CounterAttack::ACTOR[target.id][0]
end
end
#
# Skip if there is no chance of counter
next if chance == 0
# Skip if counterattack failed
next if chance < rand(100)
# Push active battler into array
target.countertargets.push(@active_battler)
#
end
#
end
Um... this was the section I fixed prior when you had actors or enemies attempting to attack when not defined. Now let me explain something.
The first yellow block assumes that the counter has 0 chance of being performed.
The second and third yellow blocks are the 'chance of counter' per your actor or enemy*
And the fourth yellow block says 'If still no chance... just go to the next guy'
So if there is 0 chance of success... you go and check the next guy and never reach the ORANGE block which sets up your actor to even do the counter attack. And (*) Your actors are, from your own config, never going to have a counter attack as their chance value is set to 0.
Insofar as the method with the error you are receiving....
This I only just posted to you, but I don't have to go any further with the script than here.
The last line, I replied that if you have no defined counterattacks, you skip the battler.
So if you have 0 chance of a counter, you never have the counter pushed into the countertargets array shown in the orange block. And this section says if you have no countertargets, skip.
In essence, in no way should you be having this error as you have no way for a counterattack to even be registered.
There has got to be something else in play. There is nothing in the script itself that would cause your issue.
# Actor Counters
# ==============
# Define the actors perfoming counter attacks: the chance of a counter,
# the skill ID used (or 0 for melee), and optionally the SP cost.
#
# Chance Skill SPCost
#========== ====== ====== ======
ACTOR[2] = [ 0, 0] # Basil delivers melee 0%
# Enemy Counters
# ==============
# Define the enemies perfoming counter attacks: the chance of a counter,
# the skill ID used (or 0 for melee), and optionally the SP cost.
#
# Chance Skill SPCost
#========== ====== ====== ======
ENEMY[1] = [ 0, 7, true] # Ghosts use Fire 0% (never)
This is your config, spaced out and lined up... and the first value in the array is 'chance of performing'. In both your cases, you have NONE.
Now... here's the kick.
def counterattack_phase4_step5
#
# Cycle through targets
for target in @target_battlers
#
# Next if no damage
next if target.damage.nil?
#
# Next if paralyzed - 'Can't Move'
next if target.restriction == 4
#
# Skip if no HP loss (healing ignored)
next unless (target.damage).to_i > 0
# Skip if attack was a counter
next if @counterattack == true
#
# Define chance
chance = 0
# Determine counterattack chance for enemy/actor
if target.is_a?(Game_Enemy)
if CounterAttack::ENEMY.has_key?(target.id)
chance = CounterAttack::ENEMY[target.id][0]
end
else
if CounterAttack::ACTOR.has_key?(target.id)
chance = CounterAttack::ACTOR[target.id][0]
end
end
#
# Skip if there is no chance of counter
next if chance == 0
# Skip if counterattack failed
next if chance < rand(100)
# Push active battler into array
target.countertargets.push(@active_battler)
#
end
#
end
Um... this was the section I fixed prior when you had actors or enemies attempting to attack when not defined. Now let me explain something.
The first yellow block assumes that the counter has 0 chance of being performed.
The second and third yellow blocks are the 'chance of counter' per your actor or enemy*
And the fourth yellow block says 'If still no chance... just go to the next guy'
So if there is 0 chance of success... you go and check the next guy and never reach the ORANGE block which sets up your actor to even do the counter attack. And (*) Your actors are, from your own config, never going to have a counter attack as their chance value is set to 0.
Insofar as the method with the error you are receiving....
(06-20-2022, 09:19 PM)DerVVulfman Wrote: for target in @target_battlers
#
# Ignore if dead
next if target.dead?
# Ignore if no countertargets
next if target.countertargets == []
This I only just posted to you, but I don't have to go any further with the script than here.
The last line, I replied that if you have no defined counterattacks, you skip the battler.
So if you have 0 chance of a counter, you never have the counter pushed into the countertargets array shown in the orange block. And this section says if you have no countertargets, skip.
In essence, in no way should you be having this error as you have no way for a counterattack to even be registered.
There has got to be something else in play. There is nothing in the script itself that would cause your issue.