Tsukihime 1,488 Posted May 28, 2012 (edited) Magic Units Author: Tsukihime Overview This script converts skill types to "units". In the default engine, skill use consumes MP or TP. A "unit of magic" is treated like an item; in order to use the magic, you must have one, and each time you use it, you consume as many units as required. Features Specify skill types that should be treated as units Consume units of skill rather than MP or TP Gain or lose units through script calls Anyone can use the skill as long as they have units Usage You can determine how many units of each skill you can have using <max-units: n> For some integer n You can also determine which skill types should be treated as units by specifying it in the configuration. You can add/remove magic units by using script calls add_units(skill_id, amount, scope_id, scope) lose_units(skill_id, amount, scope_id, scope) scope is either "actor" or "party". If the scope is "party", then the scope_id is the number representing the position of an actor in your party. 1 will be the first person, 2 will be the second person, etc If the scope is actor, then the scope_id is the actor_id. By default, the scope is "party" Download Script: http://db.tt/47ySZhca Demo: http://db.tt/5UCTLMZH (copy rgss30x.dll to the System folder to run it) Edited June 29, 2012 by Tsukihime 2 Allusion and Wren reacted to this Share this post Link to post Share on other sites
MachRiderZ 1 Posted June 29, 2012 (edited) I really like this concept. I think I may try this out. Thanks! EDIT: But it's a little confusing. Do you think you can make a demo? Edited June 29, 2012 by MachRiderZ Share this post Link to post Share on other sites
Tsukihime 1,488 Posted June 29, 2012 (edited) I've added a demo. Copy rgss30x.dll to the system folder since I didn't include it to make it small (most people should have it) I didn't touch the database. In the script, I specified skill type 2 (magic) to be treated as units. There are 4 NPC's. Two on the left demonstrate adding/removing units. The one on the top adds magic to a specific actor in the game. The slime is just for using magic in battle. Edited June 29, 2012 by Tsukihime Share this post Link to post Share on other sites
killerb255 2 Posted July 31, 2012 Nice script, Tsuki! I'm currently using it now. Is there a way to do the following: 1) Have an Actor or Class increase the maximum number of units for their alloted skills as they level up? 2) Have the Skill display "0" uses left when they run out (instead of the Skill disappearing from the menu altogether)? 3) Restore units by resting at an inn? Share this post Link to post Share on other sites
Tsukihime 1,488 Posted July 31, 2012 The design was fairly simple. Someone could probably write an add-on that changes the default behavior, because each magic was modeled after item usage, and not skill-uage (eg: 4/4 uses, 0/5 uses) Share this post Link to post Share on other sites
Tammsyn 8 Posted October 1, 2012 (edited) ok well ive got it so that once drawn the skill remains even when at 0 (shows 0) but i cant get it to show when the actor levels up and is supposed to learn the skill is there a way to add this whit a pre determined amount (wouldnt say full since by default thats 99 which is a bit unfair to start with) EDIT ok so now ive got it so that when you level up you'll learn the skill and gain 10 units of that skill also when reduced to 0 the skill remains however the skills can still be drawn by actors who do not learn the skill so kindda makes it pointless except for the free skill points Edited October 1, 2012 by Tammsyn Share this post Link to post Share on other sites
Tammsyn 8 Posted October 2, 2012 (edited) ok sorry for the double post but can we store the amount of units a specific skill has as a variable so that we can can do a sort of exchange system like what you can do in final fantasy 8 Edited October 2, 2012 by Tammsyn Share this post Link to post Share on other sites
Tsukihime 1,488 Posted October 2, 2012 I don't have any support for that. Share this post Link to post Share on other sites
Tammsyn 8 Posted October 2, 2012 ah shame would have been nice to have Share this post Link to post Share on other sites
Tsukihime 1,488 Posted October 2, 2012 (edited) Maybe, but I can't come up with any reasonable way to do it. You can in theory have arbitrary units of magic on your character so how would you manage that...? I mean, you can always do this: $game_variables[20] = $game_actors[1].get_units(30) Which stores the number of units of magic 30 that your actor has in variable 20. Edited October 2, 2012 by Tsukihime Share this post Link to post Share on other sites
Tammsyn 8 Posted October 2, 2012 ok tried that kept getting get_units is undefined method Share this post Link to post Share on other sites
Tsukihime 1,488 Posted October 2, 2012 Oops it's `get_magic_units` lol Share this post Link to post Share on other sites
Tammsyn 8 Posted October 3, 2012 thank you that worked Share this post Link to post Share on other sites
+ Galdelonian 13 Posted January 1, 2015 Ehm where do I get the .dll? Share this post Link to post Share on other sites
Tsukihime 1,488 Posted January 1, 2015 (edited) It's in the RTP folder. Edited January 1, 2015 by Tsukihime Share this post Link to post Share on other sites
Tesaigo 1 Posted January 9, 2015 Can you have a skill to use both MP and 'Magic Units' or you can only have one at time? Share this post Link to post Share on other sites
Tsukihime 1,488 Posted January 9, 2015 This was intended to replace the way your spells work, so no you can only choose one. Share this post Link to post Share on other sites
Wren 179 Posted January 23, 2015 What? I thought I stalked you good enough to know most of your scripts, but this one has escaped my attention for 2 years. This sounds exactly like something I am doing now using common event checks on every cast of a spell, so using a script to make it more tidy seems like a great idea. I'm going to try this out on my current project and see what happens. Share this post Link to post Share on other sites
ClyncyeRudje 0 Posted April 17, 2018 Do you still have this script? The current download link is broken, and I'd like to use it. Share this post Link to post Share on other sites
roninator2 228 Posted April 18, 2018 (edited) Spoiler =begin #============================================================================== ** Magic Units Author: Hime Date: May 28, 2012 ------------------------------------------------------------------------------ ** Change log May 28 - initial release ------------------------------------------------------------------------------ This script converts skill types to "units". In the default engine, skill use consumes MP or TP. A "unit of magic" is treated like an item; in order to use the magic, you must have one, and each time you use it, you consume as many units as required. You can determine how many units of each skill you can have using <max-units: n> For some integer n You can also determine which skill types should be treated as units by specifying it in the configuration. You can add/remove magic units by using script calls add_units(skill_id, amount, scope_id, scope) lose_units(skill_id, amount, scope_id, scope) scope is either "actor" or "party". If the scope is "party", then the scope_id is the number representing the position of an actor in your party. 1 will be the first person, 2 will be the second person, etc If the scope is actor, then the scope_id is the actor_id. By default, the scope is "party" #============================================================================== =end $imported = {} if $imported.nil? $imported["Tsuki_MagicUnits"] = true #============================================================================== # ** Configuration #============================================================================== module Tsuki module Magic_Units # skill types that this script applies to Applied_Types = [2] # default maximum number of units you can have for a skill Max_Units = 99 # Default_Scope = "party" #============================================================================== # ** Rest of the script #============================================================================== # regex Max_Unit_Regex = /<max-units:?\s*(\d+)\s*>/i end end module RPG class Skill < UsableItem def max_units return @max_units unless @max_units.nil? return @max_units = load_notetag_max_units end def load_notetag_max_units matches = Tsuki::Magic_Units::Max_Unit_Regex.match(self.note) return matches ? matches[1].to_i : Tsuki::Magic_Units::Max_Units end end end # stores a battler's skill units class Game_MagicStore def initialize @units = {} end def all_magic @units.keys.collect {|id| $data_skills[id]} end def skill(skill_id) $data_skills[skill_id] end def add_unit(skill_id, amount) @units[skill_id] = 0 if @units[skill_id].nil? @units[skill_id] = [@units[skill_id] + amount, skill(skill_id).max_units].min end def remove_unit(skill_id, amount) return if @units[skill_id].nil? @units[skill_id] -= amount @units.delete(skill_id) if @units[skill_id] <= 0 end def get_units(skill_id) @units[skill_id] || 0 end end class Game_BattlerBase alias :th_magic_units_init_bbase :initialize def initialize th_magic_units_init_bbase clear_magic_store end def clear_magic_store @magic_store = Game_MagicStore.new end alias :th_magic_units_pay_cost :pay_skill_cost def pay_skill_cost(skill) magic_unit_type?(skill.id) ? pay_unit_cost(skill) : th_magic_units_pay_cost(skill) end alias :th_magic_units_skill_payable? :skill_cost_payable? def skill_cost_payable?(skill) magic_unit_type?(skill.id) ? has_magic_units?(skill.id) : th_magic_units_skill_payable?(skill) end # ignore added skills if they're unit types alias :th_magic_units_added_skills :added_skills def added_skills th_magic_units_added_skills.select {|id| !magic_unit_type?(id)} end def pay_unit_cost(skill) lose_magic_units(skill.id, magic_unit_cost(skill)) end def magic_unit_cost(skill) 1 end def magic_unit_type?(skill_id) Tsuki::Magic_Units::Applied_Types.include?($data_skills[skill_id].stype_id) end def has_magic_units?(skill_id) @magic_store.get_units(skill_id) > 0 end def add_magic_units(skill_id, units) @magic_store.add_unit(skill_id, units) if magic_unit_type?(skill_id) end def lose_magic_units(skill_id, units) @magic_store.remove_unit(skill_id, units) if magic_unit_type?(skill_id) end def get_magic_units(skill_id) @magic_store.get_units(skill_id) if magic_unit_type?(skill_id) end def get_all_magic @magic_store.all_magic end end class Game_Actor < Game_Battler alias :th_magic_units_learn_skill :learn_skill def learn_skill(skill_id) return if magic_unit_type?(skill_id) th_magic_units_learn_skill(skill_id) end alias :th_magic_units_skills :skills def skills th_magic_units_skills.concat(get_all_magic) end end class Game_Interpreter def get_actor(scope, scope_id) scope == "party" ? $game_party.all_members[scope_id-1] : $game_actors[scope_id] end def add_units(id, amount, scope_id=1, scope=Tsuki::Magic_Units::Default_Scope) actor = get_actor(scope.downcase, scope_id) return unless actor actor.add_magic_units(id, amount) end def lose_units(id, amount, scope_id=1, scope=Tsuki::Magic_Units::Default_Scope) actor = get_actor(scope.downcase, scope_id) return unless actor actor.lose_magic_units(id, amount) end end #============================================================================== # ** update skill list window to display units of magic #============================================================================== class Window_SkillList < Window_Selectable def draw_item(index) skill = @data[index] if skill rect = item_rect(index) rect.width -= 4 draw_item_name(skill, rect.x, rect.y, enable?(skill)) if Tsuki::Magic_Units::Applied_Types.include?(skill.stype_id) draw_total_units(rect, skill) else draw_skill_cost(rect, skill) end end end def draw_total_units(rect, skill) draw_text(rect, @actor.get_magic_units(skill.id), 2) end end Edited April 18, 2018 by roninator2 Share this post Link to post Share on other sites