Code:
# * KFrozenSkill XP
# Scripter : Kyonides Arkanthes
# v 1.0.0 - 2022-06-09
# Have you ever wanted to freeze a hero's given skill?
# Now you can!
# * Script Calls * #
# actor = $game_actors[ID]
# OR...
# actor = $game_party.actors[Index]
# actor.freeze_skill(SkillID, Options)
# - Options - They got to be separated by commas!
# - Actor with a given ID has got to be dead:
# :actor => 1
# :hp => 1500 (as minimum)
# :sp => 275 (as minimum)
# :gold => 1500
# :item => [ItemID, Quantity]
# Example:
# actor.freeze_skill(1, :actor => 3, :hp => 1200)
# * Optional Script Calls * #
# actor.frozen_skill?(skill_id)
# actor.thawed_skill?(skill_id)
# * Warnings * #
# Skills can only be frozen once!
# The script call will fail if the hero has not learned the chosen skill!
class Game_Actor
alias :kyon_frozen_skill_gm_actor_init :initialize
alias :kyon_frozen_skill_gm_actor_skill_use? :skill_can_use?
def initialize(actor_id)
kyon_frozen_skill_gm_actor_init(actor_id)
@frozen_skills = {}
@thawed_skills = []
end
def freeze_skill(skill_id, options={})
return if !@skills.include?(skill_id) or @thawed_skills.include?(skill_id)
return if options.empty?
@frozen_skills[skill_id] = options
end
def thaw_skill(skill_id)
req = @frozen_skills[skill_id]
return unless req
gold = req[:gold]
if gold and $game_party.gold >= gold
$game_party.lose_gold(gold)
req.delete(:gold)
end
item = req[:item]
if item and $game_party.item_number(item[0]) >= item[1]
$game_party.lose_item(item[0], item[1])
req.delete(:item)
end
var = req[:actor]
req.delete(:actor) if var and $game_actors[var].dead?
var = req[:hp]
req.delete(:hp) if var and var <= maxhp
var = req[:sp]
req.delete(:sp) if var and var <= maxsp
return if req.keys.size > 0
@frozen_skills.delete(skill_id)
@thawed_skills << skill_id
@thawed_skills = @thawed_skills.sort.uniq
true
end
def skill_can_use?(skill_id)
return false if frozen_skill?(skill_id)
kyon_frozen_skill_gm_actor_skill_use?(skill_id)
end
def frozen_skill?(skill_id) @frozen_skills.keys.include?(skill_id) end
def thawed_skill?(skill_id) @thawed_skills.include?(skill_id) end
def frozen_skill_ids() @frozen_skills.keys.sort end
attr_reader :frozen_skills, :thawed_skills
end