Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- - Battle Use Limits Addon v1.0
- - Made by: Sixth
- - Requires: Tsukihime's Battle Use Limits
- - Description:
- This short script will let you make features that will restrict the amount of
- uses for the specified skills and items in battle.
- - Note-tags:
- To set a battle use limit feature to your actors, classes, equipment and states,
- you can use this note-tag:
- <battle use limit: typeID, max_uses>
- The type part must be replaced by i or s.
- i - For items.
- s - For skills.
- The ID part must be replaced by the database ID of the skill/item.
- And the max_uses part will be the maximum uses allowed for the skill/item
- in battles.
- You can use multiples of this note-tag on the same database object if needed to
- limit more than one skill/item.
- Examples:
- <battle use limit: s45, 3>
- <battle use limit: i70, 1>
- - Important note:
- While this script will limit the usage of skills/items even if the note-tag is
- used on a state, it will NOT reset the usage count of skills/items when a state
- with battle use limit restriction is expired/removed.
- What does this mean? Well, imagine this scenario:
- 1. Actor got inflicted by a state that restricts the usage of Skill 30 to a
- maximum of 3 uses per battle.
- 2. Actor used the skill 3 times in battle, can't use it anymore until the state
- is expired/cured.
- 3. State expired/cured. Still in the same battle. Actor can now use Skill 30
- again.
- 4. Actor got inflicted by the same state in the same battle again.
- 5. Skill 30 is now disabled again, because the skill has been used 3 times
- already in this battle.
- I may add a feature for a usage reset on states later if requested.
- - Installation:
- Place this script below Tsukihime's Battle Use Limits script!
- =end
- class RPG::BaseItem
- attr_accessor :battle_use_l
- def battle_use_l
- init_battle_use_l if @battle_use_l.nil?
- return @battle_use_l
- end
- def init_battle_use_l
- @battle_use_l = []
- cnote = @note.clone
- while cnote =~ /<battle use limit:(?:\s*)(i|s)(\d+)(?:\s*),(?:\s*)(\d+)>/i
- @battle_use_l << [$1, $2.to_i, $3.to_i]
- cnote.sub!(/<battle use limit:(?:\s*)(i|s)(\d+)(?:\s*),(?:\s*)(\d+)>/i,"")
- end
- end
- end
- class Game_BattlerBase
- def battle_use_l(tp,iid)
- b_use_l = []
- feature_objects.each do |ft|
- bul = ft.battle_use_l
- bul.each do |bl|
- next unless bl[0] == tp && bl[1] == iid
- b_use_l << bl
- end
- end
- return -1 if b_use_l.empty?
- return b_use_l.min_by {|bl| bl[2] }[2]
- end
- alias add_bul9921 battle_skill_use_exceeded?
- def battle_skill_use_exceeded?(sk)
- return true if use_exceeded?('s',sk.id,@skill_use_counts[sk.id])
- return add_bul9921(sk)
- end
- alias add_bul2961 battle_item_use_exceeded?
- def battle_item_use_exceeded?(it)
- return true if use_exceeded?('i',it.id,@item_use_counts[it.id])
- return add_bul2961(it)
- end
- def use_exceeded?(tp,sid,use_num)
- return false unless $game_party.in_battle
- bsl = battle_use_l('s',sid)
- return false if bsl < 0
- return use_num >= bsl
- end
- end
- # End of script!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement