12-13-2014, 05:41 PM
(07-10-2014, 04:59 AM)Djigit Wrote: Okay I managed to solve this problem. This topic can be closed by now.Hello guys. Thanks for your help.
EDIT: Theres still little problem: The actor does also counterattack when somebody uses a heal skill or a cure skill. Is there a chance to fix that problem? Please do not cloe.
Here is what I've done to make it work. First how to make it work WITHOUT an ctb or atb addon
1. put the counterattack addon above main.
2. go to line 475/ 476 put an # infront of these lines.
They should look like this now:
Code:#target.counter_info = [target.current_action.kind, target.current_action.basic,#target.current_action.skill_id, target.current_action.item_id, target.action_scope]
3. go to line 387
and replace this line here:
Code:if battler.cast_action != nil and battler.counter_action_set
with this
Code:if battler.counter_action != nil and battler.counter_action_set
4. Put this script below your counterattack script:
Code:class Game_Battler
define_method(:cast_action) { |*a| } unless method_defined?(:cast_action)
define_method(:counter_info=) { |*a| } unless method_defined?(:counter_info=)
def remember_current_action
@remembered_action = [@current_action.clone, self.action_scope]
end
def restore_current_action
@current_action, self.action_scope = *@remembered_action
clear_remembered_action
end
def clear_remembered_action
@remembered_action = nil
end
end
class Scene_Battle
#--------------------------------------------------------------------------
# * Check allow next action
# EDIT: Always allow Counter-Actions
#--------------------------------------------------------------------------
def allow_next_action
return false if cant_if_same
return false if cant_if_damaged_or_invisible
return false if cant_target_invisible
return true if @active_battlers.empty?
# --- EDIT: ---
@action_battlers.each_with_index do |battler, index|
next unless battler.counter_waiting != nil
next unless battler.counter_waiting.wait_counter
next if @active_battlers.include?(battler)
@action_battlers.delete_at(index)
@action_battlers.unshift(battler)
return true
end
# -------------
return false if cant_if_enemy_target and not Allow_Enemy_Target
return false if cant_target_active and not Allow_Active_Target
return false if cant_target_moving? and not Allow_Moving_Target
return true if next_before_return? and Next_Before_Return
return true if allow_same_targets? and Allow_Same_Target
return true if allow_diff_targets? and Allow_Diff_Targets
return false
end
#--------------------------------------------------------------------------
# * Update battler phase 5 (part 1)
# battler : active battler
# EDIT: Do not remove Countering Targets from the queue!
#--------------------------------------------------------------------------
def step5_part1(battler)
step5_part1_counter(battler)
if battler.counter_waiting != nil
battler.counter_waiting.wait_counter = false
battler.counter_waiting = nil
end
for target in $game_party.actors + $game_troop.enemies
if target.counter_action != nil and target.inputable? and not
target.hp0? and not battler.counter_action_set
set_counter_action(battler, target)
target.counter_action_set = true
@action_battlers.unshift(target)
#@action_battlers.uniq!
if target.returning? and target.moving?
target.current_phase = 'Phase 2-1'
target.target_x = target.actual_x
target.target_y = target.actual_y
end
end
target.counter_action = nil
end
end
#--------------------------------------------------------------------------
# * Set counter action
# battler : battler
# target : target
# EDIT: Remember original action to restore it after Execution;
# Force Counter Action to suppress Restriction-Effects.
#--------------------------------------------------------------------------
alias_method(:set_counter_action_ILC_remember_action, :set_counter_action)
def set_counter_action(battler, target)
target.remember_current_action
set_counter_action_ILC_remember_action(battler, target)
target.current_action.forcing = true
end
#--------------------------------------------------------------------------
# * Update battler phase 5 (part 4)
# battler : active battler
# EDIT: Restore remembered Action when terminating a Counter
#--------------------------------------------------------------------------
def step5_part4(battler)
# ---
battler.restore_current_action if battler.counter_action_set
# ---
step5_part4_counter(battler)
battler.counter_action_set = false
battler.valid_counters.clear
end
end
Now it should work fine unless you use ctb or atb addon
5.1 If yo want to use the ctb or atb addon you have to do the same but add little things.
(REMEMBER: YOU HAVE TO DO THE SAME STEPS BEFORE TOO)
5.2 go to line 63 of the little script and replace:
Code:target.inputable?
with
Code:target.inputable_by_status?
5.3 Add this little code between the line 4 and 6.
Code:alias_method(:inputable_by_status?, :inputable?)
Now it should work also if you use one of the ctb or atb addon.
Thank you very much wulfman and admin or moderator please close this topic..
Normally the counterattack works fine so far. I did everything you said and he counters the attack fine.
But theres one huge problem: I've configurated a state (number 100) where the battler with the state uses a potion (number 37) whenenver he is attacked by a monster.
Thats how I made it in the script:
Code:
Counter_Setting['State'][101] = {
{'type' => 4, 'condition' => 'user.is_a?(Game_Enemy)'} => {'type' => 2, 'id' => 37, 'cost' => true},
}
So according to this configuration the battler with state 101 uses a potion (which is id 37 in my database) to heal whenever he is attacked by an enemy (game enemy) with physical or magical attack.
Well it works, the battler indeed uses a potion after he has been attacked but sadly he doesnt use the potion on himself. He always uses the potion on the first actor. The actor which has the state 101 is the last in the row. (I mean he's the fourth actor).
Instead of healing himself with the potion, he heals the first actor.
Is there any bug in the code or did I just configurated it wrong?