Calculate Counter Chance based on attacker CNT vs target CNT?

Status
Not open for further replies.
Joined
Mar 30, 2017
Messages
4
Reaction score
0
First Language
English
Primarily Uses
RMMV
Specifically, the section I want to change is this, line 591 to 600 in Scene_Battle:
Code:
#--------------------------------------------------------------------------
# * Invoke Skill/Item
#--------------------------------------------------------------------------
  def invoke_item(target, item)
    if rand < target.item_cnt(@subject, item) # <--- THIS LINE
      invoke_counter_attack(target, item)
    elsif rand < target.item_mrf(@subject, item)
      invoke_magic_reflection(target, item)
    else
      apply_item_effects(apply_substitute(target, item), item)
    end
    @subject.last_target_index = target.index
  end
I want to change that "target.item_cnt" to be the target's cnt vs the atacker's cnt. (target cnt - attacker cnt.)

I'm pretty sure no rounding when the number is negative is necessary, as rand is positive, so even -100% results in no counter.

Any idea as to how I would go about doing this? How would I add the attacker's CNT into this?


If this involves an external script, it must be compatible with: Most Yanfly scripts, Fomar0153's ATB system, and Victor Core.

Not sure if this would help, but here's an example of an incompatible script of similar purpose (no battle animations play, which is vital for Galv's Timed Button Attacks): Hamedo: Improve Counter Attack
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,479
Reaction score
6,311
First Language
Indonesian
Primarily Uses
RMVXA
The one that needs to change is not that line, but the one in Game_Battler. This located in Game_Battler at line 458
Code:
class Game_Battler
 def item_cnt(user, item)
    return 0 unless item.physical?     
    return 0 unless opposite?(user)   
    return cnt - user.cnt # <-- changed this
  end
end
It should be compatible with most of scripts you mentioned above, unless.... when it's not
 
Joined
Mar 30, 2017
Messages
4
Reaction score
0
First Language
English
Primarily Uses
RMMV
The one that needs to change is not that line, but the one in Game_Battler. This located in Game_Battler at line 458
Code:
class Game_Battler
 def item_cnt(user, item)
    return 0 unless item.physical?   
    return 0 unless opposite?(user) 
    return cnt - user.cnt # <-- changed this
  end
end
It should be compatible with most of scripts you mentioned above, unless.... when it's not
Thanks a lot! It works perfectly! :smile:

Issue has been resolved.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,231
Reaction score
13,794
First Language
English
Primarily Uses
RMVXA

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts


Although limited to only this shop for room decorations, I like this aspect for previewing items.
So yesterday I got a follower (follow my NSFW art account) who dmed me and said to me :
if you continue to be friends with [name of the artists] which make me uncomfortable I will have to unfollow and I am like :
... do it?
Did I add too many?? Is there such a thing?

Rabbit's Shop I've been reworking. Still some dated graphics but 99% satisfied I think.:kaophew:
Traps, detecting traps, and disarming traps including treasure traps have now been implemented into my Might and Magic-inspired project. If you don't want to get hurt, you better have a character who focuses on the perception skill, and you better have a character who focuses on the disarm skill!

Forum statistics

Threads
100,834
Messages
980,071
Members
132,481
Latest member
loehz
Top