设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 124|回复: 0

[转载发布] The_Sarah - [v2.4] Multi-Hits based on Agility

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9071

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58883
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68848

    灌水之王

    发表于 2026-8-2 14:40:12 | 显示全部楼层 |阅读模式
    Heyoo!
    This is my first ever public script!


    Hits Times Agility v2.4
    by The_Sarah

    Introduction

    This script ties the amount of times a skill is activated in a turn to the difference in Game Actor's agility to the Game Troop Member's agility.

    ---------------------
    Patch Notes
    - Update 6 -
    Version 2.4 is released!
    i) Code stuff:
    This version gets rid of the item_hits_generator instance variable and makes it so skill hits are based directly on the random number generated plus any additional numbers required.
    -  So, for example, "item.repeats = rand(2) + 1" gives us 50% chance to hit once or twice, as rand(2) generates a 0 or a 1 and 0 + 1 is 1 and 1 + 1 is 2... at least according to my old Maths teacher.

    ii) The Advanced Tutorial Tips have been updated accordingly.

    iii) This version also cuts out some of the fat in the code of version 2.3.1

    iv) Please remember, since Update 5, the Notetag for this script is no longer <sarahrepeats> and is instead <multihits>

    Spoiler: Previous Patch Updates
    - Update 5 -
    Version 2.3 is released!
    i) This version changes the Notetag from "<sarahrepeats>" to "<multihits>"
    ii) This version allows the player to put the Notetag "<multihits>" in a skill that BOTH the Enemy Unit and the Player Party Member can use without any problems.
    iii) This version adds a small Module to the Script.
    iv) This version includes some Tutorial Tips on Scripting and reverts the Script to a more direct approach for altering the amount of hits done (rather than using Variables like previous versions did).
    v) This version is awesome.
    vi) Updated to 2.3.1 to fix a slight oversight that would break the game. This is now fixed. Everything is perfect.
    vii) This version is perfect.

    - Update 4 -
    Version 2.2 is released!
    i) This version is just a simple aliasing update, but now you can use this script with as many other scripts as you like and there shouldn't be any coding conflictions.
    ii) I have erased versions 2.1 and 1.0 as they do not have aliased methods and thus can conflict with other scripts.
    iii) I have changed to using this Forum's Code and Spoiler box systems for sharing the code, rather than an external Pastebin link.
    iv) Updated to v2.2.1 to fix an oversight on the speedcheck of being between 1* and 1.5* the speed of enemy.

    - Update 3 -
    i) I have made a version 2.1 and renamed it a little.
    ii) I'll leave the original Pastebin link for version 1.0 below (the simplest version of this script), but will now tweak the rest of this post so it's relevant to version 2.1.
    Spoiler: Previous Patch Updates
    -Update 2-
    i) Version 2.0 was a bit over the top. So see update 3 as I have now streamlined this more detailed version into something more readable and hopefully less intimidating.

    -Update 1 -
    i) Turns out there's a required format to submitting scripts, so I have filled mine out.
    ---------------------


    Features
    Original script made by me (The_Sarah).
    Initially requested by Oddball.
    Further edits done by me (The_Sarah) but after reading tips from Kyonides and Trihan


    The Script by default makes it so:
    If actor agi is 2* enemy agi or higher the skill hits 3 times.
    If actor agi is equal to or greater than 1.5* enemy agi (but less than 2*) the skill has a 50% chance to hit twice and a 50% chance to hit thrice.
    If actor agi is equal to enemy agi it has a 1/3 chance to hit once, twice, or thrice.
    If actor agi is equal to or greater than 0.5* enemy agi (but less than 1*) it has a 50% chance to hit once and a 50% chance to hit twice.
    Any lower than the last example, and it only hits once .


    How to Use
    Place script below materials and above main in the Script Editor.​


    Basic Use -

    i) Write the "<multihits>" Notetag in the Notes Box section of any skill you want to have this script's effects.

    ii) The Notes Box section of skills are found under Skills in the Database.

    iii) The Notetag is written without the speech marks.

    iv) Notetag: "<multihits>"


    Advanced Use -

    You can alter the amount of times a skill hits (within a Speed Check) by editing the number that comes after the "item.repeats = " part of the Editable Method in the Script.

    Information on how rand() works has also been included in the Tutorial Tips of this script.

    Expert Use -

    Additional Agility Times (Speed Checks) can be created, but will require some coding/scripting on your part to create (tutorial tips are included in the Script).


    Script

    Hits Times Agility v2.4 by The_Sarah
    Spoiler: Click this to see Script
                    Ruby:       
    1. #------------------------------------------------------------------------------#
    2. =begin
    3.                            Multi Hits x Agility
    4.                      
    5.                               (version 2.4)
    6.                               by The_Sarah
    7.                            
    8. --                                                                            --
    9.                            
    10.                            
    11.                              ~ REQUIREMENTS ~
    12.                                   None
    13.                               
    14. --                                                                            --
    15.                               ~ HOW TO USE ~
    16.                                -Basic Use-
    17.                            
    18.    Write the "<multihits>" Notetag in the Notes Box section of any skill
    19.    you want to have this script's effects.
    20.    The Notes Box section of skills are found under Skills in the Database.
    21.    The Notetag is written without the speech marks.
    22.    Notetag: "<multihits>"
    23.                               
    24. --                                                                            --
    25.                                ~ FEATURES ~
    26.    By default, this script makes it so skills cast by the Player Party Members
    27.    (aka the Game Actors) will hit multiple times depending on the difference
    28.    in that Actor's Agility score compared to the Enemy's Agility score.
    29.    The following Speed Checks make the chosen skills hit the following amount
    30.    of times:
    31. -
    32. 100% chance to use: 3 times if Player Agility (Plyr Agi) is 2* the Enemy's
    33.                             Agility (Eny Agi).
    34.                             Or if Plyr Agi is greater than 2* Eny Agi.
    35. -
    36. 50%  chance to use: 2 times if Plyr Agi is equal to 1.5* Eny Agi.
    37.                             Or if Plyr Agi is higher than 1.5* Eny Agi while
    38.                             still being lower than 2* Eny Agi.
    39. 50%  chance to use: 3 times if Plyr Agi is equal to 1.5* Eny Agi.
    40.                             Or if Plyr Agi is higher than 1.5* Eny Agi while
    41.                             still being lower than 2* Eny Agi.
    42. -
    43. 33%  chance to use: 1 time  if Plyr Agi is exactly equal to Eny Agi.
    44.                             Or if Plyr Agi is higher than 1* Eny Agi while
    45.                             still being lower than 1.5* Eny Agi.
    46. 33%  chance to use: 2 times if Plyr Agi is exactly equal to Eny Agi.
    47.                             Or if Plyr Agi is higher than 1* Eny Agi while
    48.                             still being lower than 1.5* Eny Agi.
    49.                         
    50. 33%  chance to use: 3 times if Plyr Agi is exactly equal to Eny Agi.
    51.                             Or if Plyr Agi is higher than 1* Eny Agi while
    52.                             still being lower than 1.5* Eny Agi.
    53. -
    54. 50%  chance to use: 1 time  if Plyr Agi is equal to 0.5* Eny Agi.
    55.                             Or if Plyr Agi is higher than 0.5* Eny Agi while
    56.                             still being lower than 1* Eny Agi.
    57.                         
    58. 50%  chance to use: 2 times if Plyr Agi is equal to 0.5* Eny Agi.
    59.                             Or if Plyr Agi is higher than 0.5* Eny Agi while
    60.                             still being lower than 1* Eny Agi.
    61.                  
    62. -
    63. 100% chance to use: 1 time if Plyr Agi is less than 0.5* Eny Agi.
    64. --                                                                            --
    65.                               ~ HOW TO USE ~
    66.                                (continued)
    67.                            
    68.                               -Advanced Use-
    69.    You can alter the amount of times a skill hits (within a Speed Check) by
    70.    editing the number that comes after the "item.repeats = rand()" part of
    71.    the Editable Method below.
    72.   
    73.    For full information on how to write those lines, look in the Scripting Tips
    74.    section below.
    75.   
    76.    Here are some examples:
    77.    item.repeats = rand(2)       means 50% chance to hit 0 times or 1 time
    78.    item.repeats = rand(2) + 1   means 50% chance to hit 1 time or 2 times
    79.    item.repeats = rand(3) + 1   means 33% chance to hit 1 time, 2 times or 3 times
    80.    item.repeats = rand(3) + 2   means 33% chance to hit 2 times, 3 times or 4 times
    81.    item.repeats = rand(2) + 2   means 50% chance to hit 2 times or 3 times
    82.    item.repeats = rand(2) + 3   means 50% chance to hit 3 times or 4 times
    83.    item.repeats = 3             means 100% chance to hit 3 times
    84.                            
    85. --                                                                            --
    86.                            
    87.                            
    88.                             ~ AUTHOR'S NOTES ~                           
    89.                            
    90.    This is the first public script I've made to share, so sorry if it's a
    91.    little messy.
    92.    However, it should do everything that RPG Maker Forum user Oddball has
    93.    requested (as well as a little bit extra) :).
    94.    Also, as it is a short script, I have decided to include some tutorial
    95.    information on how to alter scripts within this intro.
    96. --                                                                            --
    97.                               ~ HOW TO USE ~
    98.                                (Scripting)
    99.                            
    100.                                -Expert Use-
    101.                            
    102.    Additional Agility Times (Speed Checks) can be created, but will require
    103.    some coding/scripting on your part to create.
    104.    In the appropriate location, I have left the comment
    105.    "# *Additional Speed Checks go here* #" for you to add any
    106.    Speed Checks you wish to include.
    107.   
    108.    I have also added a Scripting Tips section (the one after this one) for
    109.    any people with limited to no scripting experience in the hopes that it
    110.    will help. :)
    111.    Simply ignore it if it does not apply to or interest you.
    112. --                                                                            --
    113.                             ~ SCRIPTING TIPS ~
    114.                            
    115.    >   checks if something "is greater than" something else.
    116.    <   checks if something "is less than" something else.
    117.    ==  checks if something "is equal to" something else.
    118.    >=  checks if something "is greater than OR equal to" something else.
    119.    <=  checks if something "is less than OR equal to" something else.
    120.    =   sets something AS something else
    121.    So      "dinner = cooked"    means that dinner is NOW equal to cooked.
    122.    Whereas "dinner == cooked"   ASKS you if dinner is cooked yet.
    123.    rand(2) generates a random number between 0 and 2 but not including 2.
    124.    rand(3) generates a random number between 0 and 3 but not including 3.
    125.    rand(4) generates a random number between 0 and 4 but not including 4.
    126.    So rand(3) can generate the numbers 0, 1 and 2 for example.
    127.    item.repeats = 1 means the skill will hit 1 time.
    128.    item.repeats = 2 means the skill will hit 2 times.
    129.    item.repeats = 5 means the skill will hit 5 times.
    130. -                                                                              -  
    131.    Combining item.repeats and rand() gives us something like this:
    132.    item.repeats = rand(2) + 1
    133.            This will make item.repeats equal to 0 + 1 or 1 + 1
    134.            Meaning the skill will hit either 1 time or 2 times.
    135.   
    136.    Another example:
    137.    item.repeats = rand(3) + 2
    138.   
    139.            This will make item.repeats equal to 0 + 2, 1 + 2 or 2 + 2
    140.            Meaning the skill will hit either 2 times, 3 times or 4 times.
    141. -                                                                              -     
    142.                                 So then!
    143.    If you would like to create an additional Speed Check, you format it
    144.    like this:
    145.   
    146.                                 Example
    147.                              
    148.         # 5th Speed Check: >= 3* speed but < 3.5* speed
    149.      elsif self.agi >= 3 * $game_troop.agi && self.agi < 3.5 * $game_troop.agi
    150.           item.repeats = rand(2) + 3
    151.       
    152.          
    153.    This will make it so if Player Speed is equal to or greater than three
    154.    times the Enemy Speed, but less than 3.5 times the enemy speed...
    155.   
    156.    ... The skill will hit either for 3 or 4 times (0 + 3 or 1 + 3).
    157.          
    158.   
    159.    Simple enough, no?
    160. --                                                                            --
    161.                               ~ TERMS OF USE ~
    162.                            
    163.    This script is free to use or edit in any game, however, if you then
    164.    end up sharing your game with others (freely OR commercially)...
    165.       
    166.    ... I'd appreciate you including me in the credits somewhere.
    167.    - Ideally like this: "Hits Times Agility script by The_Sarah"
    168.    - Or, if you Edited it: "Original Hits Times Agility script by The_Sarah"
    169. --                                                                            --
    170.                            
    171.                                 ~ Outro ~
    172.                           And that's basically it!
    173.                              Hope this helps!
    174.                        Wish you all... all the best!
    175.                     Let's make wonderful games together!
    176.                               - The_Sarah
    177.                            
    178. P.S - If you have any scripting questions about this Script, feel free to
    179.       write a reply in the original RPG Maker Forum Thread this script is
    180.       hosted in.
    181.    
    182.       I will reply when I have the time :)
    183.                        
    184. =end   
    185. #------------------------------------------------------------------------------#
    186. #------------------------------------------------------------------------------#
    187. #                                The Script                                    #
    188. #==============================================================================
    189. # ** New Module: TheSarahMultiHits
    190. #==============================================================================
    191. module TheSarahMultiHits
    192.   class << self
    193.     attr_accessor   :original_item_repeats
    194.     attr_accessor   :was_game_actor
    195.   end
    196. end # End of TheSarahMultiHits module
    197. #------------------------------------------------------------------------------
    198. # * Existing Class
    199. # ** Game_Battler
    200. #------------------------------------------------------------------------------
    201. class Game_Battler < Game_BattlerBase
    202. #--------------------------------------------------------------------------
    203. # * Existing Method
    204. # ** Calculate Damage (aliased)
    205. #--------------------------------------------------------------------------
    206.   alias thesarah_multihits_gamebattler_makedamageval    make_damage_value
    207.   def make_damage_value(user, item)
    208.     thesarah_multihits_gamebattler_makedamageval(user, item)
    209.     if TheSarahMultiHits::was_game_actor == true
    210.     item.repeats = TheSarahMultiHits::original_item_repeats
    211.     TheSarahMultiHits::was_game_actor = false
    212.     end
    213.   end
    214. end # End of Game_Battler class
    215. #==============================================================================
    216. # * Existing Class
    217. # ** Game_Actor < Game_Battler
    218. #------------------------------------------------------------------------------
    219. #                      The Editable Method is in this class.
    220. #==============================================================================
    221. class Game_Actor < Game_Battler
    222. #------------------------------------------------------------------------------#
    223. #      * Existing Method             (originally from Game_Battler class)      #
    224. #==========~~~~~                                                ~~~~~==========#
    225. #                            ~~ EDITABLE METHOD ~~                             #
    226. #                                                                              #
    227. #                               -Advanced Use-                                 #
    228. #                                                                              #
    229. #   This method (below) is where you will find the various "item.repeats = "   #
    230. #   you can edit the numbers of.                                               #
    231. #                                                                              #
    232. #                               -Expert Use-                                   #
    233. #                                                                              #
    234. #   This method (below) is where you will find the section provided for you    #
    235. #   to add any aditional Speed Checks you wish to create.                      #
    236. #                                                                              #
    237. #   Simply follow the same format as the previous Speed Checks and you         #
    238. #   should be fine.                                                            #
    239. #                                                                              #
    240. #   If you wish to make additional Speed Checks higher than 2* speed:          #
    241. #                                                                              #
    242. #   It may be wise to delete the "#" in the second half of the line for        #
    243. #   the current 2* Speed Check.                                                #
    244. #   This will help limit the range of the 2* speed Speed Check.                #
    245. #                                                                              #
    246. #==========~~~~~                                                ~~~~~==========#
    247. #      ** Use Skill/Item             (aliased)                                 #
    248. #------------------------------------------------------------------------------#
    249.   alias thesarah_multihits_gameactor_use_item        use_item
    250.   def use_item(item)
    251.     if self.is_a?(Game_Actor) && item.is_a?(RPG::Skill) && item.note[/<multihits>/i]
    252.         TheSarahMultiHits::original_item_repeats = item.repeats
    253.         TheSarahMultiHits::was_game_actor = true
    254.         # 1st Speed Check: >= 0.5* speed but < 1* speed
    255.         if self.agi >= 0.5 * $game_troop.agi && self.agi < 1 * $game_troop.agi
    256.           item.repeats = rand(2) + 1
    257.       
    258.         # 2nd Speed Check: >= 1* speed but < 1.5* speed
    259.      elsif self.agi >= 1 * $game_troop.agi && self.agi < 1.5 * $game_troop.agi
    260.           item.repeats = rand(3) + 1
    261.       
    262.         # 3rd Speed Check: >= 1.5* speed but < 2* speed
    263.      elsif self.agi >= 1.5 * $game_troop.agi && self.agi < 2 * $game_troop.agi
    264.           item.repeats = rand(2) + 2
    265.       
    266.         # 4th Speed Check: >= 2* speed (with optional < 2.5* speed)
    267.      elsif self.agi >= 2 * $game_troop.agi # && self.agi < 2.5* $game_troop.agi
    268.           item.repeats = 3
    269.      
    270.         # *Additional Speed Checks go here* #
    271.            
    272.         end
    273.     end
    274.     thesarah_multihits_gameactor_use_item(item)
    275.   end # end of method
    276. end # End of Game_Actor class
    277. #------------------------------------------------------------------------------#
    278. #                              End of Script                                   #
    279. #------------------------------------------------------------------------------#
    复制代码



    Credit and Thanks
    Me, aka The_Sarah for making the script.
    Oddball for the idea.
    Kyonides and Trihan for ideas on how to improve it.


    Terms of use

    1) Users must link to this forum post when sharing the script elsewhere.​
    2) Users must provide credit to The_Sarah when using the script in free games & sharing those games with others.​
    3) Users must provide credit to The_Sarah when using the script in a game selling commercially.​
    4) If Users have edited the script, credit must still be provided to The_Sarah for the original script.​
    5) Other than that, there is no cost and it is free to use wherever.​



    本贴来自国际rpgmaker官方论坛作者:The_Sarah处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/the_sarah-v2-4-multi-hits-based-on-agility.124792/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-17 10:26 , Processed in 0.140487 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表