No Counter Attack if TP = 0 & counter attacks using TP

Just looking for a quick snippet, don't know how easy it is but I thought I'd ask!

I've looked around and haven't really found anything, but I'm wondering if someone could write me a script that disables actor counterattacks if their TP is currently at 0.

I'm using an ATB and have counters set at 100% at all times for the actors (it's part of my battle system, so it's deliberate haha), so if there's a counter attack success formula script floating around out there that I've overlooked then maybe something like that would work too? But yes, all I need is a way to completely stop counters from happening (regardless of the counter rate, unless that's too difficult/there's a workaround) if the current actor's TP is at

The second part is that I'd like counter attacks to use a specified percentage of the actor's TP.

Thank you! 
how about using an auto state script


that would allow you to remove the counter attack state if tp is less than one and adds it if its oneor greater


edit: crap, didnt realize this was so old. was doing a search on counter attacks
It's not likely that the person would respond, but I feel I have a good answer.


---


First, this default code handles CounterAttack Rate:


class Game_Battler < Game_BattlerBase

def item_cnt(user, item)
return 0 unless item.physical? # Hit type is not physical
return 0 unless opposite?(user) # No counterattack on allies
return cnt # Return counterattack rate
end

end


As you can see here, cnt (Counterattack Rate) is determined here.  The two current exceptions are if the item/skill is not physical or if the user is not the opposite faction (ie if user is actor, the opposite is enemy).  You simply need to add return 0 if self.tp == 0 before return cnt if you don't want counterattacks at 0 tp.


---


class Scene_Battle < Scene_Base

def invoke_counter_attack(target, item)
@log_window.display_counter(target, item)
attack_skill = $data_skills[target.attack_skill_id]
@subject.item_apply(target, attack_skill)
refresh_status
@log_window.display_action_results(@subject, attack_skill)
end

end


This default code is when your Counterattack is executed.  In short, it'll display the target (you) announcing and then launching a counterattack, updates your battler status, and then show the text for the countered victim (@subject).  If you want to lower your TP by a percentage of your max TP, try placing target.tp -= (0.25 * target.max_tp) before refresh_status (change 0.25 into your own percentage or a formula/method).  Of course, since default max_tp is defined as 100, if you don't have any scripts altering that, you could simply use target.tp -= 25 instead.

Original thread: https://forums.rpgmakerweb.com/threads/no-counter-attack-if-tp-0-counter-attacks-using-tp.42605/