Jump to content
Fomar0153

Learn Skills based on Usage

Recommended Posts

This script does exactly what it says in the title, it lets you learn skills by using skills and can replace the original skill if you wish it to.

As per usual instructions are in the script.

 

Stand Alone Version

 

 

=begin
Skills Level Up Based on Usage Script
by Fomar0153
Version 1.0
----------------------
Notes
----------------------
No requirements
Allows you to learn new skills by using your existing skills.
----------------------
Instructions
----------------------
You will need to edit module Skill_Uses, further instructions
are located there.
----------------------
Known bugs
----------------------
None
=end
module Skill_Uses

 SKILLS = []
 # Add/Edit lines like the one below
 # SKILLS[ORIGINAL] = [NEW, USES, REPLACE] REPLACE should be true or false
 SKILLS[3] = [4, 50, true]
 # Reads as: When using skill 3 for it's 50th time replace it with skill 4

end

class Game_Actor < Game_Battler
 #--------------------------------------------------------------------------
 # â— Aliases setup
 #--------------------------------------------------------------------------
 alias fomar0003_setup setup
 def setup(actor_id)
   fomar0003_setup(actor_id)
   @skill_uses = []
 end
 #--------------------------------------------------------------------------
 # â— New Method add_skill_use
 #--------------------------------------------------------------------------
 def add_skill_use(id)
   if @skill_uses[id] == nil
     @skill_uses[id] = 0
   end
   @skill_uses[id] += 1
   unless Skill_Uses::SKILLS[id] == nil
     if @skill_uses[id] == Skill_Uses::SKILLS[id][1]
       learn_skill(Skill_Uses::SKILLS[id][0])
       forget_skill(id) if Skill_Uses::SKILLS[id][2]
       SceneManager.scene.add_text(@name + " learns " + $data_skills[skill_Uses::SKILLS[id][0]].name + ".")
     end
   end
 end
end

class Game_Battler < Game_BattlerBase
 #--------------------------------------------------------------------------
 # â— Aliases item_apply
 #--------------------------------------------------------------------------
 alias fomar0004_item_apply item_apply
 def item_apply(user, item)
   if user.is_a?(Game_Actor) and item.is_a?(RPG::Skill)
     user.add_skill_use(item.id)
   end
   fomar0004_item_apply(user, item)
 end
end

class Scene_Battle < Scene_Base
 #--------------------------------------------------------------------------
 # â— New method add_text
 #--------------------------------------------------------------------------
 def add_text(text)
   @log_window.add_text(text)
 end
end

 

 

 

Unique Classes Version

 

=begin
Skill Master Script
by Fomar0153
Version 1.0
----------------------
Notes
----------------------
Requires my unique classes script
Allows you to learn new skills by using your existing skills.
----------------------
Instructions
----------------------
You will need to edit module Skill_Uses, further instructions
are located there.
----------------------
Known bugs
----------------------
None
=end

module Skill_Uses

 SKILLS = []
 # Add/Edit lines like the one below
 # SKILLS[ORIGINAL] = [NEW, USES, REPLACE] REPLACE should be true or false
 SKILLS[3] = [4, 50, true]
 # Reads as: When using skill 3 for it's 50th time replace it with skill 4

end

class Game_SkillMaster < Game_Actor
 #--------------------------------------------------------------------------
 # â— New Method setup
 #--------------------------------------------------------------------------
 def setup(actor_id)
   super(actor_id)
   @skill_uses = []
 end
 #--------------------------------------------------------------------------
 # â— New Method add_skill_use
 #--------------------------------------------------------------------------
 def add_skill_use(id)
   if @skill_uses[id] == nil
     @skill_uses[id] = 0
   end
   @skill_uses[id] += 1
   unless Skill_Uses::SKILLS[id] == nil
     if @skill_uses[id] == Skill_Uses::SKILLS[id][1]
       learn_skill(Skill_Uses::SKILLS[id][0])
       forget_skill(id) if Skill_Uses::SKILLS[id][2]
       SceneManager.scene.add_text(@name + " learns " + $data_skills[skill_Uses::SKILLS[id][0]].name + ".")
     end
   end
 end
end

class Game_Battler < Game_BattlerBase
 #--------------------------------------------------------------------------
 # â— Aliases item_apply
 #--------------------------------------------------------------------------
 alias fomar0004_item_apply item_apply
 def item_apply(user, item)
   if user.is_a?(Game_SkillMaster) and item.is_a?(RPG::Skill)
     user.add_skill_use(item.id)
   end
   fomar0004_item_apply(user, item)
 end
end

class Scene_Battle < Scene_Base
 #--------------------------------------------------------------------------
 # â— New method add_text
 #--------------------------------------------------------------------------
 def add_text(text)
       @log_window.add_text(text)
 end
end

 

Share this post


Link to post
Share on other sites

Hi Fomar, just letting you know that this happened (in the stand alone version):

 

SMALL BUG??:

I did this:

SKILLS[3] = [4, 2]

SKILLS[4] = [3, 2]

This is what happened (all in the same battle btw):

  • Fire[3] was used 2 times and it changed to Wind[4]. Good.
  • Wind[4] was then used 2 times and it changed back to Fire[3]. Good.
  • Fire[3] was then used 2 (and more) times but it did not change to Wind[4]. Bad? Unless it was intentional.

I sort of expected the fire to change to wind again. Although I may not have the cause to do such a thing in my game, I was just testing around as it may help others if they wish to have such a toggling gameplay.

Edited by Seiryuki

Share this post


Link to post
Share on other sites

If you wish to change that behaviour then I suggest modifying this line:

if @skill_uses[id] == Skill_Uses::SKILLS[id][1]

or alternatively have it reset the skill use counter e.g.

      if @skill_uses[id] == Skill_Uses::SKILLS[id][1]
       @skill_uses[id] = 0
       learn_skill(Skill_Uses::SKILLS[id][0])
       forget_skill(id) if Skill_Uses::SKILLS[id][2]
       SceneManager.scene.add_text(@name + " learns " + $data_skills[skill_Uses::SKILLS[id][0]].name + ".")
     end

Share this post


Link to post
Share on other sites

or alternatively have it reset the skill use counter e.g.

@skill_uses[id] = 0

Ah yes, the reset counter makes more sense so I'll do that. Thanks again for scripting this! :D

 

 

EDIT : Fix for message displaying in battle even when skill already learned:

 

  #--------------------------------------------------------------------------
 # ? New Method add_skill_use
 #--------------------------------------------------------------------------
 def add_skill_use(id)
if @skill_uses[id] == nil
  @skill_uses[id] = 0
end
@skill_uses[id] += 1
unless Skill_Uses::SKILLS[id] == nil
  if @skill_uses[id] == Skill_Uses::SKILLS[id][1]
	@skill_uses[id] = 0
	if Skill_Uses::SKILLS[id][2] && !skill_learn?($data_skills[skill_Uses::SKILLS[id][0]])
	  SceneManager.scene.add_text(@name + "  levels " + $data_skills[id].name + " up to " + $data_skills[skill_Uses::SKILLS[id][0]].name + ".")
	elsif !Skill_Uses::SKILLS[id][2] && !skill_learn?($data_skills[skill_Uses::SKILLS[id][0]])
	  SceneManager.scene.add_text(@name + " learns " + $data_skills[skill_Uses::SKILLS[id][0]].name + ".")
	end
	learn_skill(Skill_Uses::SKILLS[id][0])
	forget_skill(id) if Skill_Uses::SKILLS[id][2]
  end
end
 end

 

Edited by Seiryuki

Share this post


Link to post
Share on other sites

I really like this system and it's really simple.

One problem, does it only work in battle? If I want my healers to get better at healing by using their healing spells it breaks when they heal outside of battle.

Share this post


Link to post
Share on other sites

Hey, thanks for the script! I just have one concern...

I'm fairly new to scripting here, and this script works fine for all skills except for the attack and guard commands. For example, I want the user to learn a skill based on attacking a certain amount of times, but it's not working. Skill 1 is used for normal attacking, so I edited for example, SKILLS[1] = [164, 20, false] but it doesn't work. Any help would be greatly appeciated!

Share this post


Link to post
Share on other sites

can i do this:

SKILLS[26] = [28, 10]

SKILLS[27] = [28, 5]

 

Reads as: skill Heal III (28) learn when using skill Heal (26) for 10 time or when usingskill Heal II (27) for 5 time

*sorry for my bad english

Edited by g_melodyta

Share this post


Link to post
Share on other sites

Love the script so far, but I think I found a bug.  When using a skill in battle and getting the required number of uses to learn the next one, everything works fine.  When doing it from the menu, it breaks.

 

The example I ran into is Heal.  I set it to learn Heal 2 after 3 uses, just to test it out.  Again, in battle it worked fine.  When I tried it from the menu, everything crashed.

 

Script 'Skill Suage' line 51: NoMethodError ocured

undefined method 'add_text' for #<Scene_Skill:0x3537ae8>

 

The line in question is the last one here;

 

[ def add_skill_use(id)
    if @skill_uses[id] == nil
      @skill_uses[id] = 0
    end
    @skill_uses[id] += 1
    unless Skill_Uses::SKILLS[id] == nil
      if @skill_uses[id] == Skill_Uses::SKILLS[id][1]
        learn_skill(Skill_Uses::SKILLS[id][0])
        forget_skill(id) if Skill_Uses::SKILLS[id][2]
        SceneManager.scene.add_text(@name + " learns " + $data_skills[skill_Uses::SKILLS[id][0]].name + ".")
      end]

 

I hope I posted that right.  I'm just starting to learn Ruby, and I'm not even sure yet how to fix this.  Any help?

Edited by timidjester

Share this post


Link to post
Share on other sites

Just a small note if you find that setting a skill to replace  in the script doesn't work. If you set your skills as add skill in the actor feature box in the database the replace won't work, However, if you set the same skills in the classes section of the database it's double rainbows folks. Chearz!

Share this post


Link to post
Share on other sites

I did this;



module Skill_Uses

  SKILLS[141] = [145, 2, true]

end

And i get error like that

 

depxc0.png

 

EDIT : Ops. Okay, i got this. :) Thanks for script.

Edited by smeros

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted