06-20-2022, 09:19 PM
Line 210 : NoMethodError occurred
Undefined method " " for nil:NilClass
Let's break this down....
for target in @target_battlers
#
# Ignore if dead
next if target.dead?
# Ignore if no countertargets
next if target.countertargets == []
#
# Target now becomes active battler
@active_battler = target
# Acquire counterattack target
target = @active_battler.countertargets[0]
# Erase countertarget array
@active_battler.countertargets.clear
# Set array of targeted battlers
@target_battlers = [target]
From what you described, 216 should be the line I highlighted. Betcha didn't know we had the [ bgcolor ] bbcode, eh?
Now... the first part of this is that we have an array of @target_battlers to search through. So it goes through each 'target' in the array... those targets being victimized battlers that were attacked.
The first test ( target.dead?) would cause a crash if we had no target victim battler itself. So a nilClass for the target is a big nope.
Then the next test (target.countertarget == [] ) is to check if the victim target has an empty countertarget array... essentially checking if this victim was attacked BY an aggressive battler and is ready to attack it. If the countertarget array is empty, then we skip to the next victim target in the whole @target_battler array... assuming there may be more than one. Now, if there was no actual countertarget array to test... we would again have a crash. But we don't. That means we have an array that exists. In fact, we wouldn't be able to even get that far and cut out on line 195 when trying to fill the array. This I've confirmed, even whilst writing this just now.
The next thing we do after that is make the victim target the NEW Active battler.... so our former victim may now attack the guy who whapped him. Simple thing there.
Then we get to... your line: target = @active_battler.countertargets[0]
We established that the victim and former 'target', now an active battler, did not have an empty countertarget array. At least one battler must be in there. And the system is choosing the first in the index (countertargets[0]). So that should not be an issue. And then we have the fact that we are taking the battler stuffed in the countertargets array and making it our hapless victim's new TARGET of attack. So that too should not be an issue. The only time anything is pushed into this array IS in-fact line 195 that I previously mentioned would crash if no countertargets array is present.
I have now tried to BREAK the script and create the error.
Please post what you have in the upper config section from what should be line 61: module CounterAttack to line 84: end
Undefined method " " for nil:NilClass
Let's break this down....
for target in @target_battlers
#
# Ignore if dead
next if target.dead?
# Ignore if no countertargets
next if target.countertargets == []
#
# Target now becomes active battler
@active_battler = target
# Acquire counterattack target
target = @active_battler.countertargets[0]
# Erase countertarget array
@active_battler.countertargets.clear
# Set array of targeted battlers
@target_battlers = [target]
From what you described, 216 should be the line I highlighted. Betcha didn't know we had the [ bgcolor ] bbcode, eh?
Now... the first part of this is that we have an array of @target_battlers to search through. So it goes through each 'target' in the array... those targets being victimized battlers that were attacked.
The first test ( target.dead?) would cause a crash if we had no target victim battler itself. So a nilClass for the target is a big nope.
Then the next test (target.countertarget == [] ) is to check if the victim target has an empty countertarget array... essentially checking if this victim was attacked BY an aggressive battler and is ready to attack it. If the countertarget array is empty, then we skip to the next victim target in the whole @target_battler array... assuming there may be more than one. Now, if there was no actual countertarget array to test... we would again have a crash. But we don't. That means we have an array that exists. In fact, we wouldn't be able to even get that far and cut out on line 195 when trying to fill the array. This I've confirmed, even whilst writing this just now.
The next thing we do after that is make the victim target the NEW Active battler.... so our former victim may now attack the guy who whapped him. Simple thing there.
Then we get to... your line: target = @active_battler.countertargets[0]
We established that the victim and former 'target', now an active battler, did not have an empty countertarget array. At least one battler must be in there. And the system is choosing the first in the index (countertargets[0]). So that should not be an issue. And then we have the fact that we are taking the battler stuffed in the countertargets array and making it our hapless victim's new TARGET of attack. So that too should not be an issue. The only time anything is pushed into this array IS in-fact line 195 that I previously mentioned would crash if no countertargets array is present.
I have now tried to BREAK the script and create the error.
Please post what you have in the upper config section from what should be line 61: module CounterAttack to line 84: end