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: - #------------------------------------------------------------------------------#
- =begin
- Multi Hits x Agility
-
- (version 2.4)
- by The_Sarah
-
- -- --
-
-
- ~ REQUIREMENTS ~
- None
-
- -- --
- ~ HOW TO USE ~
- -Basic Use-
-
- Write the "<multihits>" Notetag in the Notes Box section of any skill
- you want to have this script's effects.
- The Notes Box section of skills are found under Skills in the Database.
- The Notetag is written without the speech marks.
- Notetag: "<multihits>"
-
- -- --
- ~ FEATURES ~
- By default, this script makes it so skills cast by the Player Party Members
- (aka the Game Actors) will hit multiple times depending on the difference
- in that Actor's Agility score compared to the Enemy's Agility score.
- The following Speed Checks make the chosen skills hit the following amount
- of times:
- -
- 100% chance to use: 3 times if Player Agility (Plyr Agi) is 2* the Enemy's
- Agility (Eny Agi).
- Or if Plyr Agi is greater than 2* Eny Agi.
- -
- 50% chance to use: 2 times if Plyr Agi is equal to 1.5* Eny Agi.
- Or if Plyr Agi is higher than 1.5* Eny Agi while
- still being lower than 2* Eny Agi.
- 50% chance to use: 3 times if Plyr Agi is equal to 1.5* Eny Agi.
- Or if Plyr Agi is higher than 1.5* Eny Agi while
- still being lower than 2* Eny Agi.
- -
- 33% chance to use: 1 time if Plyr Agi is exactly equal to Eny Agi.
- Or if Plyr Agi is higher than 1* Eny Agi while
- still being lower than 1.5* Eny Agi.
- 33% chance to use: 2 times if Plyr Agi is exactly equal to Eny Agi.
- Or if Plyr Agi is higher than 1* Eny Agi while
- still being lower than 1.5* Eny Agi.
-
- 33% chance to use: 3 times if Plyr Agi is exactly equal to Eny Agi.
- Or if Plyr Agi is higher than 1* Eny Agi while
- still being lower than 1.5* Eny Agi.
- -
- 50% chance to use: 1 time if Plyr Agi is equal to 0.5* Eny Agi.
- Or if Plyr Agi is higher than 0.5* Eny Agi while
- still being lower than 1* Eny Agi.
-
- 50% chance to use: 2 times if Plyr Agi is equal to 0.5* Eny Agi.
- Or if Plyr Agi is higher than 0.5* Eny Agi while
- still being lower than 1* Eny Agi.
-
- -
- 100% chance to use: 1 time if Plyr Agi is less than 0.5* Eny Agi.
- -- --
- ~ HOW TO USE ~
- (continued)
-
- -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 = rand()" part of
- the Editable Method below.
-
- For full information on how to write those lines, look in the Scripting Tips
- section below.
-
- Here are some examples:
- item.repeats = rand(2) means 50% chance to hit 0 times or 1 time
- item.repeats = rand(2) + 1 means 50% chance to hit 1 time or 2 times
- item.repeats = rand(3) + 1 means 33% chance to hit 1 time, 2 times or 3 times
- item.repeats = rand(3) + 2 means 33% chance to hit 2 times, 3 times or 4 times
- item.repeats = rand(2) + 2 means 50% chance to hit 2 times or 3 times
- item.repeats = rand(2) + 3 means 50% chance to hit 3 times or 4 times
- item.repeats = 3 means 100% chance to hit 3 times
-
- -- --
-
-
- ~ AUTHOR'S NOTES ~
-
- This is the first public script I've made to share, so sorry if it's a
- little messy.
- However, it should do everything that RPG Maker Forum user Oddball has
- requested (as well as a little bit extra) :).
- Also, as it is a short script, I have decided to include some tutorial
- information on how to alter scripts within this intro.
- -- --
- ~ HOW TO USE ~
- (Scripting)
-
- -Expert Use-
-
- Additional Agility Times (Speed Checks) can be created, but will require
- some coding/scripting on your part to create.
- In the appropriate location, I have left the comment
- "# *Additional Speed Checks go here* #" for you to add any
- Speed Checks you wish to include.
-
- I have also added a Scripting Tips section (the one after this one) for
- any people with limited to no scripting experience in the hopes that it
- will help. :)
- Simply ignore it if it does not apply to or interest you.
- -- --
- ~ SCRIPTING TIPS ~
-
- > checks if something "is greater than" something else.
- < checks if something "is less than" something else.
- == checks if something "is equal to" something else.
- >= checks if something "is greater than OR equal to" something else.
- <= checks if something "is less than OR equal to" something else.
- = sets something AS something else
- So "dinner = cooked" means that dinner is NOW equal to cooked.
- Whereas "dinner == cooked" ASKS you if dinner is cooked yet.
- rand(2) generates a random number between 0 and 2 but not including 2.
- rand(3) generates a random number between 0 and 3 but not including 3.
- rand(4) generates a random number between 0 and 4 but not including 4.
- So rand(3) can generate the numbers 0, 1 and 2 for example.
- item.repeats = 1 means the skill will hit 1 time.
- item.repeats = 2 means the skill will hit 2 times.
- item.repeats = 5 means the skill will hit 5 times.
- - -
- Combining item.repeats and rand() gives us something like this:
- item.repeats = rand(2) + 1
- This will make item.repeats equal to 0 + 1 or 1 + 1
- Meaning the skill will hit either 1 time or 2 times.
-
- Another example:
- item.repeats = rand(3) + 2
-
- This will make item.repeats equal to 0 + 2, 1 + 2 or 2 + 2
- Meaning the skill will hit either 2 times, 3 times or 4 times.
- - -
- So then!
- If you would like to create an additional Speed Check, you format it
- like this:
-
- Example
-
- # 5th Speed Check: >= 3* speed but < 3.5* speed
- elsif self.agi >= 3 * $game_troop.agi && self.agi < 3.5 * $game_troop.agi
- item.repeats = rand(2) + 3
-
-
- This will make it so if Player Speed is equal to or greater than three
- times the Enemy Speed, but less than 3.5 times the enemy speed...
-
- ... The skill will hit either for 3 or 4 times (0 + 3 or 1 + 3).
-
-
- Simple enough, no?
- -- --
- ~ TERMS OF USE ~
-
- This script is free to use or edit in any game, however, if you then
- end up sharing your game with others (freely OR commercially)...
-
- ... I'd appreciate you including me in the credits somewhere.
- - Ideally like this: "Hits Times Agility script by The_Sarah"
- - Or, if you Edited it: "Original Hits Times Agility script by The_Sarah"
- -- --
-
- ~ Outro ~
- And that's basically it!
- Hope this helps!
- Wish you all... all the best!
- Let's make wonderful games together!
- - The_Sarah
-
- P.S - If you have any scripting questions about this Script, feel free to
- write a reply in the original RPG Maker Forum Thread this script is
- hosted in.
-
- I will reply when I have the time :)
-
- =end
- #------------------------------------------------------------------------------#
- #------------------------------------------------------------------------------#
- # The Script #
- #==============================================================================
- # ** New Module: TheSarahMultiHits
- #==============================================================================
- module TheSarahMultiHits
- class << self
- attr_accessor :original_item_repeats
- attr_accessor :was_game_actor
- end
- end # End of TheSarahMultiHits module
- #------------------------------------------------------------------------------
- # * Existing Class
- # ** Game_Battler
- #------------------------------------------------------------------------------
- class Game_Battler < Game_BattlerBase
- #--------------------------------------------------------------------------
- # * Existing Method
- # ** Calculate Damage (aliased)
- #--------------------------------------------------------------------------
- alias thesarah_multihits_gamebattler_makedamageval make_damage_value
- def make_damage_value(user, item)
- thesarah_multihits_gamebattler_makedamageval(user, item)
- if TheSarahMultiHits::was_game_actor == true
- item.repeats = TheSarahMultiHits::original_item_repeats
- TheSarahMultiHits::was_game_actor = false
- end
- end
- end # End of Game_Battler class
- #==============================================================================
- # * Existing Class
- # ** Game_Actor < Game_Battler
- #------------------------------------------------------------------------------
- # The Editable Method is in this class.
- #==============================================================================
- class Game_Actor < Game_Battler
- #------------------------------------------------------------------------------#
- # * Existing Method (originally from Game_Battler class) #
- #==========~~~~~ ~~~~~==========#
- # ~~ EDITABLE METHOD ~~ #
- # #
- # -Advanced Use- #
- # #
- # This method (below) is where you will find the various "item.repeats = " #
- # you can edit the numbers of. #
- # #
- # -Expert Use- #
- # #
- # This method (below) is where you will find the section provided for you #
- # to add any aditional Speed Checks you wish to create. #
- # #
- # Simply follow the same format as the previous Speed Checks and you #
- # should be fine. #
- # #
- # If you wish to make additional Speed Checks higher than 2* speed: #
- # #
- # It may be wise to delete the "#" in the second half of the line for #
- # the current 2* Speed Check. #
- # This will help limit the range of the 2* speed Speed Check. #
- # #
- #==========~~~~~ ~~~~~==========#
- # ** Use Skill/Item (aliased) #
- #------------------------------------------------------------------------------#
- alias thesarah_multihits_gameactor_use_item use_item
- def use_item(item)
- if self.is_a?(Game_Actor) && item.is_a?(RPG::Skill) && item.note[/<multihits>/i]
- TheSarahMultiHits::original_item_repeats = item.repeats
- TheSarahMultiHits::was_game_actor = true
- # 1st Speed Check: >= 0.5* speed but < 1* speed
- if self.agi >= 0.5 * $game_troop.agi && self.agi < 1 * $game_troop.agi
- item.repeats = rand(2) + 1
-
- # 2nd Speed Check: >= 1* speed but < 1.5* speed
- elsif self.agi >= 1 * $game_troop.agi && self.agi < 1.5 * $game_troop.agi
- item.repeats = rand(3) + 1
-
- # 3rd Speed Check: >= 1.5* speed but < 2* speed
- elsif self.agi >= 1.5 * $game_troop.agi && self.agi < 2 * $game_troop.agi
- item.repeats = rand(2) + 2
-
- # 4th Speed Check: >= 2* speed (with optional < 2.5* speed)
- elsif self.agi >= 2 * $game_troop.agi # && self.agi < 2.5* $game_troop.agi
- item.repeats = 3
-
- # *Additional Speed Checks go here* #
-
- end
- end
- thesarah_multihits_gameactor_use_item(item)
- end # end of method
-
- end # End of Game_Actor class
- #------------------------------------------------------------------------------#
- # End of Script #
- #------------------------------------------------------------------------------#
复制代码
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/