yami's PCTB battle system error

Yami's predicted charge turn battle system crashes whenever a character counter-attacks.

The relevant script can be found here:

http://yamiworld.wordpress.com/rgss3/battle-scripts/yeas-add-on/pctb/

After googling it for a while, it seems many people have had this error, and that it's due to a faulty line dealing with forced actions I.E forced actions in general crash the game using the script.

Yami has discontinued his support for this script though, so I was wondering if someone could help me provide a fix?

I would be very grateful!
Fix Force Actions

or this one

Spoiler
class Game_Battler < Game_BattlerBase def force_action(skill_id, target_index) action = Game_Action.new(self, true) action.set_skill(skill_id) if target_index == -2 action.target_index = last_target_index elsif target_index == -1 action.decide_random_target else action.target_index = target_index end @actions = [action] + @actions @pctb_forced = true endend
or try this one too.

Spoiler
module BattleManager #-------------------------------------------------------------------------- # * Force Action #-------------------------------------------------------------------------- def self.force_action(battler) @action_forced ||= [] @action_forced.push(battler) end #-------------------------------------------------------------------------- # * Get Next Action Subject #-------------------------------------------------------------------------- def self.next_subject loop do if @action_forced && !@action_forced.empty? battler = @action_forced.shift @action_forced = nil if @action_forced.empty? return battler end battler = @action_battlers.shift return nil unless battler next unless battler.index && battler.alive? unless battler.movable? battler.on_action_end next end return battler end endend
Try any of those 3 <_<;
I am using the most recent Yanfly battle engine script, so the first fix is definitely not it.

As for the next two, where exactly am I supposed to put them?

Should they be put by themselves in a dedicated slot, or should I replace a command line

in another script? If so, where?

EDIT:

I figures out where to put the fix behind your second spoiler line, but haven't gotten around to testing it yet.

Some additional information -

This issue seems to specifically have to do with counter attacks, as the error

does not happen when I use force command event command in battles.

I tried to set up a battle in the database, and used the force command event command,

and made my actor attack at the beginning of the fight, and this had no issues what so ever.

It seems specifically to have to do with line 815.

#--------------------------------------------------------------------------
  # alias method: execute_action
  #--------------------------------------------------------------------------
  alias scene_battle_execute_action_pctb execute_action
  def execute_action
    scene_battle_execute_action_pctb
    unless BattleManager.action_forced?
      @subject.last_obj = @subject.current_action.item unless @subject.last_obj
    end
  end
815 is:

 @subject.last_obj = @subject.current_action.item unless @subject.last_obj
EDIT:

Okay, tested it now.

I put the fix the "Battle Manager" section, and it seems to have done the trick.

I'm just worried because I've heard a lot of people here say that you shouldn't tamper to much with the main modules, but I'm guessing it's okay in this instance?

In any case, it would seem that this battle engine is a bit unstable, and for that reason, I'd like to ask the mods not to close this yet, as it's very possible I'll be getting into more trouble in a moment or two.

In any case, I'm extreeeemely happy for your assistance!

Thanks a lot, man!

If this turns out to have been the solution to stabilize my battle engine, I just might have to put your name in the credits!
I am having the same problem, but don't fully understand what you did to resolve it. Did you just copy the battlemanager module from the spoiler bar into rpg maker's core battle manager? If so, does it matter where in the battlemodule it is placed?
I, too, am having this issue, and was unable to find a resolution anywhere else in the forums or through search engines. Counterattacking and forced actions seem to work just fine, but when an enemy is killed with a counterattack, I get the following error and game crash:

Script 'Yami's PCTB System' line 816: NoMethodError occurred. Undefined method 'item' for nil:NilClass.

I tried pasting the Module BattleManager script that was linked above in various places, since Hian seems to have gotten that to work, but none of them have fixed the issue, and he did not indicate where he put it to successfully solve the problem.
Arg! All of the things! I didn't even know this was an issue until I discovered this forum, and yes, I am having the same problems as everyone else. All forced actions work fine, except enemies that are killed by counterattack. Tried all three fixes in various places and even overwritting the main module. I'm pretty close to abandoning this battle system altogether.
try replacing

@subject.last_obj = @subject.current_action.item unless @subject.last_objwith

Code:
@subject.last_obj = @subject.current_action.item unless @subject.last_obj || @subject.hidden? || @subject.confusion? || [email protected]?
Just tried it out in the battle test and it seems to work just fine, Xypher - thank you very much for your fix.
try replacing

@subject.last_obj = @subject.current_action.item unless @subject.last_objwith

@subject.last_obj = @subject.current_action.item unless @subject.last_obj || @subject.hidden? || @subject.confusion? || [email protected]?
Holy Crap! that's it! that is what i needed thanks!!!
im haveing a same type of error....when i start my battle test it stops and says "Script 'BattleManager' line192 no method error occurred undefind method empty for #<array0x93c8b0c> im not shure what to fix...i need help
Gawreluck, please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.

Please start a new topic, as most probably your error is something different from what was discussed here.

Have you saved the project? have you tested ingame instead of using the editors battletest? Remember to start a new game after new scripts have been added.

Locking this, as it's old and probably solved

Original thread: https://forums.rpgmakerweb.com/threads/yamis-pctb-battle-system-error.18449/