RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Replace Skill

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Replace Skill
Version: 1.0
Author: modern algebra
Date: October 29, 2010

Version History


  • <Version 1.0> 10.29.2010 - Original Release

Description


This script is very simple. It allows you to specify skills to forget when a certain skill is learned. As a corollary, you also will not learn a new skill if you already have a skill that would have replaced it.

Sounds useless? Kind of. But it can be helpful if, say, you want to give the impression of a skill levelling up. Say you have a series of skills: Heal I is learned at level 2, Heal II is learned at level 14, and Heal III is learned at level 32. With this script, you can set it so that Heal I is forgotten when you learn Heal II, and Heal II is forgotten when you learn Heal III.

Also, since it was designed with consideration to the idea that it would be used to give the illusion that skills were levelling, a conditional branch check to see if a skill is learned will return true as long as you have either the skill asked for or any skill that would cause you to forget the skill asked for. So, if your conditional branch is checking for the Heal I skill, it will return true if you have Heal I, Heal II, or Heal III.

Features

  • Allows you to forget specific skills when you learn a new one, thus giving the appearance of levelling the skill
  • Conditional branches on skill learned will return true as long as you have either the skill being checked or a skill that would cause you to forget the skill being learned
  • Will not allow an actor to learn a skill if one of the skills he/she already has would cause that skill to be forgotten

Instructions

Place the script above Main and below Materials in the Script Editor. If using my Note Editor script with the General Compatibility Patch, then this script must be placed below that. If you encounter any problems, try placing this script below every other custom script you are using. If it is still troublesome, then find the topic at RMRK.net and report it.

The script is easy to setup: all you need to do is put the following code into the notebox of a skill:

        \forget[x, y, ..., z]

where: x-z are the IDs of the skills you want to forget when this skill is learned. It allows for multiples so that, with serial skills, you can ensure that all lower levels will not be learnable when you have a higher level of that skil. So, for the Heal I, II, III example (and let's say the ID of Heal I is 34, the ID of Heal II is 35, and the ID of Heal II is 36 - they don't have to be sequential, but they are those by default):
    Heal I would be empty;
    Heal II would have the code:  \forget[34]
    Heal III would have the code: \forget[34, 35]

Script


Code: [Select]
#==============================================================================
#    Replace Skill
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: October 29, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script is very simple. It allows you to specify skills to forget when
#   a certain skill is learned. As a corollary, you also will not learn a new
#   skill if you already have a skill that would have replaced it.
#
#    Sounds useless? Kind of. But it can be helpful if, say, you want to give
#   the impression of a skill levelling up. Say you have a series of skills:
#   Heal I is learned at level 2, Heal II is learned at level 14, and Heal III
#   is learned at level 32. With this script, you can set it so that Heal I is
#   forgotten when you learn Heal II, and Heal II is forgotten when you learn
#   Heal III.
#
#    Also, since it was designed with consideration to the idea that it would
#   be used to give the illusion that skills were levelling, a conditional
#   branch check to see if a skill is learned will return true as long as you
#   have either the skill asked for or any skill that would cause you to forget
#   the skill asked for. So, if your conditional branch is checking for the
#   Heal I skill, it will return true if you have Heal I, Heal II, or Heal III.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place the script above Main and below Materials in the Script Editor. If
#   using my Note Editor script with the General Compatibility Patch, then this
#   script must be placed below that. If you encounter any problems, try
#   placing this script below every other custom script you are using. If it
#   is still troublesome, then find the topic at RMRK.net and report it.
#
#    The script is easy to setup: all you need to do is put the following code
#   into the notebox of a skill:
#
#        \forget[x, y, ..., z]
#
#   where: x-z are the IDs of the skills you want to forget when this skill is
#  learned. It allows for multiples so that, with serial skills, you can ensure
#  that all lower levels will not be learnable when you have a higher level of
#  that skil. So, for the Heal I, II, III example (and let's say the ID of Heal
#  I is 34, the ID of Heal II is 35, and the ID of Heal II is 36 - they don't
#  have to be sequential, but they are those by default):
#    Heal I would be empty;
#    Heal II would have the code:  \forget[34]
#    Heal III would have the code: \forget[34, 35]
#==============================================================================

#==============================================================================
# ** RPG::Skill
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - mars_forget_skills
#==============================================================================

class RPG::Skill
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Forget Skills
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def mars_forget_skills
    if !@mars_forget_skills
      @mars_forget_skills = []
      if self.note[/\\FORGET\[(.+?)\]/i] != nil
        $1.scan (/\d+/).each { |id| @mars_forget_skills.push (id.to_i) }
      end
    end
    return @mars_forget_skills
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Compatibility with Note Editor + General Compatibility Patch
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  if self.method_defined? (:ma_reset_note_values)
    alias morlg_relcskl_reset_6hw1 ma_reset_note_values
    def ma_reset_note_values (*args)
      morlg_relcskl_reset_6hw1 (*args) # Run Original Method
      @mars_forget_skills = nil
    end
  end
end

#==============================================================================
# ** Game_Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - learn_skill; skill_learn?
#==============================================================================

class Game_Actor
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Skill Learn?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malab_replce_skllrn_8uj3 skill_learn?
  def skill_learn? (skill, *args)
    (@skills - skill.mars_forget_skills).each { |s_id|
      return true if $data_skills[s_id].mars_forget_skills.include? (skill.id)
    }
    return malab_replce_skllrn_8uj3 (skill, *args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Learn Skill
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mlg_rplskl_lernskl_7yh3 learn_skill
  def learn_skill (skill_id, *args)
    mlg_rplskl_lernskl_7yh3 (skill_id, *args) # Run Original method
    $data_skills[skill_id].mars_forget_skills.each { |s_id| forget_skill (s_id) } if @skills.include? (skill_id)
  end
end

Credit


  • modern algebra

Thanks

  • Dimosthenos, for the request

Support


If you encounter any bugs with this script, please report it in this topic. Remember to look at the Script Troubleshooting for the Non-Scripter tutorial first and see if anything in there helps. Even if it does and you are able to fix the problem, please alert me to the issue.

Known Compatibility Issues

If using the Note Editor and General Compatibility Patch, then this script must be placed below it.

**
Rep: +0/-0Level 75
RMRK Junior
Nice!
But i think you Scripted this to fast :P
An error poped up when i chosed New game. Might be one of the scripts i got that bugged this problem :/
Code: [Select]
Script 'Replace Skill' line 96: NoMethodError occurred.
undefined method 'mars_forget_skills' for 857:Fixnum
« Last Edit: October 30, 2010, 02:25:30 AM by Dimosthennis »
MrD

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
It works fine when using all default scripts; it must be an incompatibility with another script. The skill_learn? method is supposed to accept only a skill object as its argument. Whatever other script you are using must change it so that it can accept skill IDs as well. At least, that's what I assume it does. Do you have >857 skills? If not, then it is doing something else entirely and I would need to see the offending script.

If the other script aliases and doesn't overwrite, then you'll be able to fix it simply by putting this script above the other one in the script editor. Otherwise, you can try replacing the skill_learn? method in my script with:

Code: [Select]

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Skill Learn?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malab_replce_skllrn_8uj3 skill_learn?
  def skill_learn? (skill, *args)
    orig_skill = skill
    skill = $data_skills[orig_skill] if skill.is_a? (Fixnum)
    (@skills - skill.mars_forget_skills).each { |s_id|
      return true if $data_skills[s_id].mars_forget_skills.include? (skill.id)
    }
    return malab_replce_skllrn_8uj3 (orig_skill, *args)
  end

**
Rep: +0/-0Level 75
RMRK Junior
Ah!
It works fine now.
Hade to 'replace Skill_Learn?' what you script.
Thanks alot :)
and how do i give you a Rep point? :P

MrD
MrD

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
youu have to have 75 posts or more. Rep is meaningless anyway.

***
Rep:
Level 74
I'm baaack!
You can do this with common events set to parallel process... You can also set an event to every map so you don't need a switch but that would take longer and be harder...

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Yeah, but it's not exactly efficient to have a ton of conditional branches operating every frame just to check whether every actor has however many skills and replace them if they have the next level of it. And by "not exactly efficient," I mean "totally inefficient".

***
Rep:
Level 71
RMRK Junior
What Modern says is true, I tried what the other guy said, about running parallel processes, it worked fine, but it lagged the fuck out of the game. I was lucky to be running at 5 FPS at any given time, and it was annoying. Thanks for the awesome script modern.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Well, you could use wait frames to reduce that since there is no reason to run an event like that every frame, but it is still inefficient