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,592
Reaction score
6,522
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,522
Reaction score
14,255
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

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,018
Members
137,563
Latest member
MinyakaAeon
Top