The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: Terra-chan on July 29, 2010, 06:53:19 PM

Title: [Request] Level Skills by Use
Post by: Terra-chan on July 29, 2010, 06:53:19 PM
Title: Re: [Request] Level Skills by Use
Post by: modern algebra on July 29, 2010, 07:15:30 PM
I would love to help you with this; unfortunately I am going away tomorrow. But I will see what I can do when I get back.
Title: Re: [Request] Level Skills by Use
Post by: Terra-chan on July 29, 2010, 08:30:13 PM
Thank you for the consideration at least then. I'll be sure to keep updates going on this since it's posted in multiple locations.
Title: Re: [Request] Level Skills by Use
Post by: Terra-chan on August 03, 2010, 12:12:42 AM
Divided by Zero has announced that he is working on an update to his script and will keep my request in mind. I have mentioned to him that I had an issue with his script combined with Melody's Status Menu (not a critical failure, only that his point distribution would not show within the Melody Status menu). I'm not sure how that will pan out ultimately, or if he'll keep the point system or switch to a use system or somehow make it able to use one or the other.

As of yet, no one has posted any results in the direction of this request, so I still await that. All parties that have posted interest had ulterior motives (SowS to learn how to work with the Skill menu, DBZ for consideration in an update for his script). We'll see how things pan out on that front, but I'd still be curious to see MA's results if he picks this up too.
Title: Re: [Request] Level Skills by Use
Post by: Terra-chan on August 07, 2010, 07:32:05 PM
*pokes this request*
I'm not getting any information on this at all... I don't know what's happening anymore and it's kinda disheartening... *puppy-eyes*
Title: Re: [Request] Level Skills by Use
Post by: modern algebra on August 09, 2010, 12:31:56 AM
Well, I don't want to step on anyone's toes if they've already started working on it. If you have confirmation from SowS and DBZ that they will no longer work on it, then I'll take a shot.
Title: Re: [Request] Level Skills by Use
Post by: Terra-chan on August 12, 2010, 11:12:01 PM
I have word back from both SowS and DBZ.
Quote from: SowSsorry, i can't finish it. i won't be able to script for awhile.
Quote from: dividedbyzeroI'm very sorry, but I think my script update might be a while yet; I'm fairly busy and haven't found much time to make progress. I hope somebody else can help you out with this. In case this isn't a very time-sensitive request, I'll be sure to notify you when my script is ready in case you haven't found anything by the time it's done.
Title: Re: [Request] Level Skills by Use
Post by: modern algebra on August 16, 2010, 12:33:33 PM
Alright. If I find time today I may work on it and see how it goes.
Title: Re: [Request] Level Skills by Use
Post by: Nhoj_yeR on August 17, 2010, 05:22:25 PM
i'll check the script when MA is done. :P
-SowS
Title: Re: [Request] Level Skills by Use
Post by: Terra-chan on August 22, 2010, 06:49:22 AM
Oopsidaisy.
Project members are anticipating this script so it could be included as part of a tutorial, so I'm giving a bump to learn of progress if any...
Title: Re: [Request] Level Skills by Use
Post by: modern algebra on August 22, 2010, 04:04:11 PM
Sorry, I haven't had time to work on it yet because I've been babysitting all week. I will get around to it though - I will likely use my Learn Skills By Use script as a base, so all I will need to do is work out the levelling aspects. It should be pretty simple once I get to work on it.

The tagging you want will be somewhat tricky to achieve though for several reasons. (A) The YEM scripts wouldn't be able to tell that something is between tags and so would automatically load those attributes regardless. That could be solved by interjecting before it is interpreted and converting the tags to something unreadable, and converting back once the proper level is reached. However, (B) another problem is that YEM scripts always load attributes only once when the skill is first accessed, meaning that if it would need to be reactivated.

Anyway, what I will probably end up doing is intervening at the start, before any notes are interpreted, and separate each skill level into separate skills, but the tagging might not be exactly in the format you want. Anyway, I'll figure it out but it might be a little tricky. At the very least, you can expect that it won't be done this week.
Title: Re: [Request] Level Skills by Use
Post by: Terra-chan on August 23, 2010, 01:54:03 AM
I suggested 3 different methods of tagging as 3 different possibilities. In the end, what works, works, right?

If strength of skill can be increased by perhaps a percentage overall that's cool too. Like Percentage Damage, Percentage Cost. And maybe a percentage cooldown or duration, but we'll see about that.

If this is an addon to your Learn Skills by Use and they are usable together then it's possible we could use a combination of the two. One of the big things would be making melodies (as in customizing attack actions.) I still need to play with it, but if we wanted to say, increase the amount of attacks a move does we'd have to play with the melody function because I know that that allows adding in additional strikes.

So if both can be used in conjunction, it would still be great for cutting down on exactly how many skills we need to make ^_^
Title: Re: [Request] Level Skills by Use
Post by: Terra-chan on August 26, 2010, 09:45:15 PM
Don't want to be pushy, because I know this is a handful and you have a life, but I already don't go by bump once every 24 hours. Even a post of what you plan it to work out to be would be cool ^_^
Title: Re: [Request] Level Skills by Use
Post by: modern algebra on August 26, 2010, 10:43:36 PM
Well, I sort of did that already, but I can try to be a little more clear. It will likely require my Learn Skills By Use script, but it will be setup along the lines of your third option. Essentially what I plan to do for each skill that has levels is, upon startup, separate each level of it into a new skill (this script will need to be below your melody scripts, by the way). There is some trickiness, in that I may need to redefine the $data_skills global variable a little bit, but there's no reason for you to worry about that since if I do, I will do it in a way that shouldn't impact any other scripts.

Anyway, the notes will be set up in a similar manner to your third option so as to use bbcode-esque tags like this:

\level[X]    /level[X]\level[Y]   /level[Y]

Notes within those tags will apply only to that level of skill, while notes not within any level tags will be included in all levels of the skill. I will also include codes for changing the values of regular options like damage and variance, but I haven't settled on exact format yet. Naturally, I will include tags for you to set level growth as well as options to explicitly set how many uses are needed for each level.

Anyway, you don't need to worry about these things. If I find I am unable to do it, I will inform you. Until then, you can assume that I will work on it when I find the time. I still need to do a few other scripting tasks before I can start on this, but they are fairly minor. As I said last Sunday, you can at least expect that the script won't be done before this Sunday.
Title: Re: [Request] Level Skills by Use
Post by: Terra-chan on August 26, 2010, 11:07:56 PM
Thank you for the layout. That makes sense and it's something to look forward to. ^_^ It'd be pretty sweet if it works out as planned.
Title: Re: [Request] Level Skills by Use
Post by: Terra-chan on August 30, 2010, 06:05:16 AM
You mentioned you'd have looked into it more after Sunday and just want to say, looking at the Learn Skills by Use thread recent posts that Level skills by use should see results as you reach the use needed for each skill, and should not wait for a level up.
Title: Re: [Request] Level Skills by Use
Post by: Terra-chan on September 05, 2010, 04:04:33 AM
Oopsidaisy?  :'(
Title: Re: [Request] Level Skills by Use
Post by: modern algebra on September 05, 2010, 01:14:22 PM
Patience is a virtue. I had a hurricane to deal with. I'm working on the update to LSBU that will allow you to learn skills instantly. This script is next on the list.
Title: Re: [Request] Level Skills by Use
Post by: Terra-chan on September 05, 2010, 08:12:20 PM
No problem. I just like to know what's going on. Sorry to hear about the hurricane. Hope things work out for you.
Title: Re: [Request] Level Skills by Use
Post by: modern algebra on September 09, 2010, 08:17:32 PM
Alright, just a quick update for you. I've almost finished the update to LSBU that will learn the skill instantly. Once finished that, I will begin working exclusively on this script. I'm back at school now, so I will try to get it out of this way on the weekend. I have a few ideas on how to access them and how to save the level each actor has at that skill, so we'll see.

Now, I do have a few questions for you. It's leveling, so I assume you want to remove the old levels of the skill when you level it. Y/N? It doesn't make a big difference either way. Also, when a skill is levelled, how do you want that reflected when looking at the skill? I notice that you would like to have a "Info" or "Use" window come up when selecting a skill. I would prefer not to have that as it's kind of bulky and it shows very little information. The way I show Use count in LSU is by allowing the player to press SHIFT (or any button of the creator's choosing) and it will change the description to show the Use count). However, there is still the issue of showing level. Now, I can do that by either including that in the information shown when you press SHIFT, or I can do it by adding a suffix to the skill, such as Fire 1, Fire 2, ... or Fire I, Fire II, ... Which would you prefer?
Title: Re: [Request] Level Skills by Use
Post by: Terra-chan on September 09, 2010, 08:43:07 PM
The Info or Use is more in consideration so that the visuals would not mess up with any menu scripts and still be compatible with the Default system or a custom menu like YEM. I don't know how that would work out ultimately, since we are using YEM JP in the Skill Overhaul. We are using Passive skills as well (I realize leveling Passive skills would be a pain, but it occurs to me that if it's made to be possible, people could actually mimic the FFII stat leveling system using Melody and this script.... Which would be nice as I've seen a few people request it)

And we were planning on removing the old skill when it's leveled. Like I said, if it's usable in conjuction with Learn skills by use, if there were any skills we also wanted to keep after leveling and learn a new skill that would be cool, and also probably make us completely abandon the YEM JP SYstem except for Passives... although we may look at Shanghai's passives instead as they are Skill oriented and not State oriented.

The Press shift would be good, we can add that to our Skill Tutorial using my Keyboard Key icons and all :3

I think that showing it in the information would be more canon with our source material. But thinking of other users, the option of displaying it next to the skill in the menu is also a good idea. I don't like to be self, so if it's possible to make it an either or option, that would be great for other people wanting to use the script too ^_^

From our source material (http://halfprince.wordpress.com/halfprince-main/), a description of the character's skills at level 8.
QuoteAbilities: Thick Skin – Ability Level 1, Charisma +5% / Buddha's Mountain's Phantom Kick – Ability Level 1, 10% chance of tripling attack power when using leg attacks (multiplier does not include weapon(s)' attack power) / Chop – Ability Level 3, attack power +10% when using Chop / Continuous Attack – Ability Level 3, can attack continuously for up to 4 times / Terrifying Roar – Ability Level 1, reduces enemy defense by 3%
We aren't following them all exactly though, but we are trying to be as close as possible.
Title: Re: [Request] Level Skills by Use
Post by: The Mormegil on September 09, 2010, 11:13:45 PM
Since I am looking forward to this script, may I add a suggestion? One of the things I think should be noticed is enemies. They can use skills, but at which level? If you use a skill players use, would it be terrible to have the possibility to add a notetag or even a hash in the script (say, {Enemy ID --> ["Fire_2", "Ice_2", "Death_12"]} or something, I'm no expert) that configures the skill level for enemies?
Title: Re: [Request] Level Skills by Use
Post by: modern algebra on September 10, 2010, 12:18:36 AM
That is an important consideration and one I hadn't thought of. I will be sure to add that feature, though I may use IDs instead of names. Something more like:

\skill_level[[skill_id, level], [skill_id, level], ...]
Title: Re: [Request] Level Skills by Use
Post by: modern algebra on September 14, 2010, 09:24:29 PM
I am sorry that I haven't gotten around to this yet. Distractions abound :) I have to get some applications done before the end of the week, but after that, I will get around to this script.

I haven't forgotten you.
Title: Re: [Request] Level Skills by Use
Post by: Terra-chan on September 15, 2010, 05:16:41 AM
Thank you for the consideration. I wasn't worried. I see you updating other scripts, and some of them I can see how they can relate to this, so that's a progress report too :3

You are probably one of the best scripters around, so of course you're busy. :3
Title: Re: [Request] Level Skills by Use
Post by: modern algebra on September 23, 2010, 12:16:54 AM
Alright, Learn Skills By Use 2.0 is now out, so that does most of the work in regard to instantly learning skills (which will be levelling in this). Everything else will rest on how nicely I will be able handle storing the various levels of skills.
Title: Re: [Request] Level Skills by Use
Post by: Terra-chan on September 23, 2010, 02:44:07 AM
I saw that... and it requires Zeriab's Dialog script? He has 3 posted, does it need all 3? Just makes me wonder...
Title: Re: [Request] Level Skills by Use
Post by: modern algebra on September 23, 2010, 03:55:40 AM
No, it only requires the base script. One of the other two is a sample, and the other is an implementation of the sample. You only need the main one.
Title: Re: [Request] Level Skills by Use
Post by: modern algebra on September 26, 2010, 02:00:14 AM
OK, this is finished. I'll do a little testing tomorrow and if all goes well I will release it then.
Title: Re: [Request] Level Skills by Use
Post by: Terra-chan on October 03, 2010, 07:26:30 AM
Sweet, look forward to seeing it.

[Edit]
How is the testing coming along?
Title: Re: [Request] Level Skills by Use
Post by: modern algebra on October 03, 2010, 01:07:56 PM
It's fine so far. I haven't been able to do much. I will try to get it done today if I can find the time.
Title: Re: [Request] Level Skills by Use
Post by: modern algebra on October 11, 2010, 04:27:46 PM
Hey, sorry for being such a bum about this. I am finished, but I really haven't had time to test it and I didn't do anything to incorporate it into other scripts yet either. Sorry. Anyway, I figure that since I have no idea when I will be able to test it, I will just share it and you can test it and report back to me if something isn't working properly. Also, you can tell me what needs improvement.

Here it is - I made a small update to LSU to version 2.0a (http://rmrk.net/index.php/topic,34581.0.html). You will need to grab that first.

Put the LSU script above all other custom scripts that use skill noteboxes, and put this addon directly below it:


#==============================================================================
#    Skill Levels
#      Addon to Learn Skills By Use 2.0a
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: October 11, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This is an addon to Learn Skills By Use that permits you to create levels
#   of the skill that are learnable by using the lower level version of a skill
#   a set number of times.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    If using this script, then you must put the Learn Skills By Use 2.0a above
#   every other custom script in the Script Editor (F11), and put this script
#   directly under it. Otherwise, it will not inherit note stats from other
#   scripts.
#
#    Firstly, you can have an actor directly learn a level of a skill by using
#   the following code in a Script call in an event:
#       learn_skill_level (actor_id, skill_id, level)
#         actor_id : the ID of the actor you want to learn the skill level
#         skill_id : the ID of the skill
#         level    : the level of the skill you want the actor to learn.
#
#    Now for the hard stuff: setting up levels of the skill. The most important
#   part of this are the level tags (note that you can change what you use for
#   tags in the MASL_REGEXP hash in the Editable Region):
#
#      \L[x].../L
#
#   Everything between those tags will be placed only in the note of the skill
#  level x. Anything that is not between tags like that will be in the note of
#  all levels of the skills (except for root_skill paths). This is useful for
#  two reasons: 1. It allows you to set the generic stats for that level; and
#  2. If using a script that allows you to set stats through the notebox, then
#  they will only apply to the levels you want them to.
#
#   For each of the generic skill stats, you can specify a new value for that
#  level between the level codes. Each generic stat has a shortcut to take less
#  room than writing out its name, though you can do that as well. You can set
#  what the shortcuts are in the MASL_REGEXP hash if you need to. Any of these
#  may be placed within the \L[x].../L and will change the stat for that level.
#  If not specified, then the stat will default to whatever it is set up in the
#  database as.
#    \N[x]    - This will set the name of the skill to x.
#    \D[x]    - This will set the description of the skill to x.
#    \M1[x]   - This will set the first line of the use message to x.
#    \M2[x]   - This will set the second line of the use message to x
#    \I[x]    - This will set the icon used to x.
#    \S[x]    - This will set the scope to x. (0 => None; 1 => One Enemy;
#              2 => All Enemies; 3 => One Enemy Dual; 4 => One Random Enemy;
#              5 => 2 Random Enemies; 6 => 3 Random Enemies; 7 => One Ally;
#              8 => All Allies; 9 => One Ally (Dead); 10 => All Allies (Dead)
#              11 => The User)
#    \O[x]    - This will set the occasion to x. (0 => Always;
#              1 => Only in Battle; 2 => Only from the Menu; 3 => Never)
#    \SPD[x]  - This will set the speed to x.
#    \AID[x]  - This sets the ID of the animation used to x.
#    \CEID[x] - This sets the ID of the common event called to x.
#    \DMG[x]  - This sets the base damage value to x.
#    \V[x]    - This sets the variance to x.
#    \ATK[x]  - This sets the ATK_F stat to x.
#    \SPI[x]  - This sets the SPI_F stat to x.
#    \H[x]    - This sets the hit stat to x.
#    \MP[x]   - This sets the MP cost to x.
#    \PA      - This sets the physical attack property to on.
#    \!PA     - This sets the physical attack property to off.
#    \DMP     - This sets the damage to MP property to on.
#    \!DMP    - This sets the damage to MP property to off.
#    \AD      - This sets the absorb damage property to on.
#    \!AD     - This sets the absorb damage property to off.
#    \ID      - This sets the ignore defence property to on.
#    \!ID     - This sets the ignore defence property to off.
#    \ES[x,y,z] - This sets the element set array. Add each ID of every
#              element you want the skill to have and separate by commas.
#    \PSS[x,y,z] - This sets the plus state set array. Add each ID of every
#              state you want the skill to add and separate by commas.
#    \MSS[x,y,z] - This sets the minus state set array. Add each ID of every
#              state you want the skill to remove and separate by commas.
#
#  Another very important code is the \use command. Outside of level tags, the
# code is used as following:
#
#    \use[x, y]
#      where x is the base number of uses and y is the level growth. Put
#     simply, the formula is x + (level-1)*y, and that is how many times you
#     will need to use the previous skill in order to level it up.
#
#  The best way to demonstrate is an example. If you have \use[10, 15], then
# you will have to use the initial skill 10 (10 + 0*15) times to get it to
# level 2. You will then have to use the level 2 skill 25 (10 + 1*15) times to
# learn level 3. You will then have to use the level 3 skill 40 (10 + 2*15)
# times to get to level 4, etc...
#
#  However, you can also use the \use code within level tags and that will
# directly set how many times you need to use the previous skill to get to the
# level. In this case, the code is simply:
#    \use[x]
# where x is the number of times to use the skill.
#
#  The Use commands are crucial! Without them, you cannot advance to new
# levels unless you use the \root_skill (shortcutted as \RS) within the level
# tags. You will need to do this if you want to require another skill in order
# to advance to a particular level (in which case you cannot use the \use codes
# as they only deal with the previous level of the skill. If you want to use
# the \RS codes, you may. Keep in mind that the ID of a skill greater than
# level 1 is (level - 1)*1000 + id. So, if you have a skill with ID 17 in the
# database, then level 2 of the skill can be referenced by 1017, level 3 by
# 2017, level 4 by 3017, etc...
#
#  Anyway, all of that probably sounds confusing, so here are some examples:
#
#   Skill 1 (Fire I) Notebox:
#     I am generic note\use[15, 10]
#     \L[1]note that only applies to level 1/L
#     \l[2]\n[Fire II]\pss[13]level 2
#     note\dmg[50]/l
#     \L[3]\dmg[50]\h[85]\pss[13,16]
#     \n[Fire III]\ADLEVEL 3/L
#
#  OK, so the first level of the skill would be exactly what you see in the
# database. Let's say it's called Fire I, does 30 damage, and has a hit rate of
# 80. The note of the level 1 skill, for the purposes of other scripts, would
# read: "I am generic note\use[15, 10] note that only applies to level 1
# Because of the \use[15,10] code, you would learn level 2 of this skill
# after 15 uses.
#  As you can see within the \l[2].../l codes, there is a \n code which will
# change the name of the skill to Fire II. As well, it now adds the state with
# ID 13 (Attack Down), and does 50 damage. It's note, for the purposes of other
# scripts, will read: "I am generic note\use[15, 10] level 2 note". You would
# get to level 3 after using this skill 25 times.
#  Again with level 3, the damage will be 50 (note that it needs to be repeated
# as otherwise it would inherit from level 1. The hit rate of this script is
# set to 85 by the \h code. In addition to state 13, the \pss code also adds
# state 16 (AGI Down). The \n code changes the name of the skill to Fire III
# and the \AD code now makes it so the user will absorb the damage. The note
# of level 3 will read: "I am generic note\use[15, 10] LEVEL 3"
#
#  It probably seems a little complicated but I am sure you will get the hang
# of it. I will do one more little example just to show the use of \RS codes.
# I will leave out any substantive changes since the only thing I want to show
# is how you can vary the requirements for learning a new level.
#
#    Skill 2 Note (ID is 2)
#      \L[2]\rs[2, 15, <4>, F]
#      \rs[4, 0, <2>]/L
#      \L[3]\use[25]/L
#      \L[4]\rs[2002, 25, <1004>, F]
#      \rs[1004, 10, <2002>]/L
#
#  OK, so what the above code will do is fairly simple. As I said, I didn't put
# anything that would actually change the stats of the skill - I just want to
# focus on the use of RS codes. In order to advance to level 2 of the skill,
# the \rs[2, 15, <4>, F] code means that you must use level 1 of the skill 15
# times. However, the <4> means that you also have to meet the conditions of
# \rs[4, 0, <2>] before it will advance. In that case, you don't have to use
# skill 4, you just need to have learned it before it will allow you to
# advance. The F in the first will mean that you will forget the 1st level of
# the skill when you learn level 2.
#
#  Next, the level 3 codes only have a \use[25] code in it. This means you will
# just have to use the level 2 version of the skill 25 times before you learn
# level 3.
#
#  Finally, in order to learn level 4, the \rs[2002, 25, <1004>, F] code means
# that you need to use the level 3 version of the skill 25 times but also need
# to meet the conditions for 1004 (level 2 of skill 4). That code is
# \rs[1004, 10, <2002>], which means that you need to use the level 2 version
# of skill 4 10 times. You then forget level 3 of skill 2.
#
#  All in all, I recommend just using \use codes, but \rs will be necessary if
# you want to require other skills in order to advance levels. I note that
# while you are able to use \use[x] code within a level branch, you cannot use
# the \use[x, y] code outside or else that will establish a path where you only
# have to use the previous level of the skill.
#==============================================================================

#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#  EDITABLE REGION
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# MASL_FORGET_LOWER_LEVELS - a boolean. When true, then the lower levels of the
#  skills are forgotten when an actor learns a new level skill. In other words,
#  it will replace. If false, then the lower levels will not be erased.
MASL_FORGET_LOWER_LEVELS = true
# MASL_VOCAB_LEVELSKILL - When a skill levels, what message do you want to
#  show up. %s will be replaced by the skill name, %n will be replaced by the
#  actor name, and %l will be replaced by the level. %s1 will be replaced with
#  the name of the first level of the skill.
MASL_VOCAB_LEVELSKILL = "%s1 has levelled up! It is now Level %l"
# MASL_REGEXP - shortcuts for setting the default attributes differently per
#  level. If you edit this, remember that there must be a comma after each line
MASL_REGEXP = { # <- Do not touch this!
  "level"           => "L",
  "name"            => "N",
  "description"     => "D",
  "message1"        => "M1",
  "message2"        => "M2",
  "icon_index"      => "I",
  "scope"           => "S",
  "occasion"        => "O",
  "speed"           => "SPD",
  "animation_id"    => "AID",
  "common_event_id" => "CEID",
  "base_damage"     => "DMG",
  "variance"        => "V",
  "atk_f"           => "ATK",
  "spi_f"           => "SPI",
  "hit"             => "H",
  "mp_cost"         => "MP",
  "physical_attack" => "PA",
  "damage_to_mp"    => "DMP",
  "absorb_damage"   => "AD",
  "ignore_defense"  => "ID",
  "element_set"     => "ES",
  "plus_state_set"  => "PSS",
  "minus_state_set" => "MSS",
  "root_skill"      => "RS"
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#  END EDITABLE REGION
#//////////////////////////////////////////////////////////////////////////////
} # <- Do not touch this

#==============================================================================
# ** RPG::Skill
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new class constant - MASL_ATTR_NAMES
#    new instance method - masl_setup_skill_level
#==============================================================================

class RPG::Skill
  MASL_ATTR_NAMES = [["name", "description", "message1", "message2"],
    ["physical_attack", "damage_to_mp", "absorb_damage", "ignore_defense"],
    ["icon_index", "scope", "occasion", "speed", "animation_id",
      "common_event_id", "base_damage", "variance", "atk_f", "spi_f", "hit",
      "mp_cost"],
    ["element_set", "plus_state_set", "minus_state_set"]]
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Setup Skill Level
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def masl_setup_skill_level (new_id, unique_note = "")
    self.id = new_id
    # Get all attribute names
    string_attr, boolean_attr, int_attr, ary_attr = *MASL_ATTR_NAMES
    # Set any string attributes specified
    string_attr.each { |attr|
      unique_note.sub! (/\\(#{MASL_REGEXP[attr]}|#{attr})\[(.+?)\]/i) {
        self.send (attr + "=", $2.to_s)
        "" }
    }
    # Set any boolean attributes specified
    boolean_attr.each { |attr|
      unique_note.sub! (/\\(!?)(#{MASL_REGEXP[attr]}|#{attr})/i) {
        self.send (attr + "=", $2.empty?)
        "" }
    }
    # Set any integer attributes specified
    int_attr.each { |attr|
      unique_note.sub! (/\\(#{MASL_REGEXP[attr]}|#{attr})\[(\d+)\]/i) {
        self.send (attr + "=", $2.to_i)
        "" }
    }
    # Set any array attributes specified
    ary_attr.each { |attr|
      if (unique_note.sub! (/\\(#{MASL_REGEXP[attr]}|#{attr})\[(.+?)\]/i) { "" }) != nil
        array = []
        $2.gsub (/(\d+)/i) { |int| array.push (int.to_i) }
        self.send (attr + "=", array)
      end
    }
    unique_note.gsub! (/\\#{MASL_REGEXP["root_skill"]}\[/i) { "\\ROOT_SKILL[" }
    self.note.gsub! (/\\(LEVEL|#{MASL_REGEXP["level"]})\[(\d+)\].*?\/(LEVEL|#{MASL_REGEXP["level"]})/i) { "" }
    # Delete any global references to root skills since, if located
    #  outside level branches, it would be sufficient to teach all the
    #  higher levels of the skill immediately. This way, they can only
    #  apply to the first level of the skill.
    self.note.gsub! (/\\ROOT_SKILL\[.+?\]/i) { "" }
    self.note += unique_note
    # Put in use requirements
    f = MASL_FORGET_LOWER_LEVELS ? ", F" : ""
    if unique_note[/\\USE\[(\d+)\]/i] != nil
      self.note += "\\ROOT_SKILL[#{self.id - 1000}, #{$1}#{f}]"
    elsif self.note[/\\USE\[(\d+)[,:;]\s*(\d+)\]/i] != nil
      use = $1.to_i + (self.id / 1000)*$2.to_i
      self.note += "\\ROOT_SKILL[#{self.id - 1000}, #{use}#{f}]"
    end
  end
end

#==============================================================================
# ** Data_Skills
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This class is a subclass of array meant to be able to handle calls for
# different skill levels
#==============================================================================

class Data_Skills < Array
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize (default_array)
    super (default_array.size) # Run super method
    # Duplicate array
    for i in 0...default_array.size
      self[i] = default_array[i]
    end
    create_level_hash
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create Level Hash
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def create_level_hash
    @level_hash = {}
    for i in 0...self.size
      skill = self[i]
      next if skill.nil?
      # Split RPG::Skill into multiple skills for each level
      skill.note.gsub! (/\\(LEVEL|#{MASL_REGEXP["level"]})\[(\d+)\](.*?)\/(LEVEL|#{MASL_REGEXP["level"]})/i) {
        level = $2.to_i
        l_note = $3.to_s
        if level < 1
          ""
        elsif level == 1
          l_note
        else
          new_skill = Marshal.load (Marshal.dump (skill))
          new_skill.masl_setup_skill_level (skill.id + (level - 1)*1000, l_note)
          @level_hash[new_skill.id] = new_skill
          ""
        end
      }
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Reset LSU Cache
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def reset_lsu_cache
    # Reset Root Skills analysis for every level
    self.each { |skill|
      next if skill.nil?
      skill.ma_root_skills.each { |path|
        path.each { |a| self[a[0]].ma_descendant_skills.delete (self.id) }
      }
      skill.ma_cache_lsu_skill_stats       # Recache skill stats for LSU
    }
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Get Element
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def [] (key)
    if key > 1000
      return @level_hash[key] unless @level_hash[key].nil?
      return self[key - 1000]
    end
    return super (key)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Iterate
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def each (*args, &block)
    return (self + @level_hash.values).each (*args, &block)
  end
end

if LSU_LEARN_IMMEDIATELY
#==============================================================================
# ** Dialog_LearnSkill
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This class processes when a new skill is learned
#==============================================================================

class Dialog_LearnSkill < Dialog
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Help Text
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malg_lsusl_hlptxt_6yn2 help_text
  def help_text (*args)
    if @skill.id > 1000
      text = MASL_VOCAB_LEVELSKILL.gsub (/%s1/) { $data_skills[@skill.id % 1000].name }
      text.gsub! (/%s/) { @skill.name }
      text.gsub! (/%n/) { @actor.name }
      return text.gsub (/%l/) { ((@skill.id / 1000) + 1).to_s }
    else
      return malg_lsusl_hlptxt_6yn2 (*args)
    end
  end
end
end

#==============================================================================
# ** Game_Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - learn_skill_level
#==============================================================================

class Game_Interpreter
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Learn Skill Level
  #    actor_id : ID of the actor who is learning the skill
  #    skill_id : ID of the base skill
  #    level    : level of the skill to teach.
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def learn_skill_level (actor_id, skill_id, level = 1)
    actor = $game_actors[actor_id]
    # Forget all lower level instances of this skill
    if MASL_FORGET_LOWER_LEVELS && level > 1
      actor.skills.each { |skill|
        if skill.id % 1000 == skill_id && skill.id < (level - 1)*1000
          actor.forget_skill (skill_id)
        end
      }
    end
    actor.learn_skill (skill_id + (level - 1)*1000)
  end
end

#==============================================================================
# ** Scene_Title
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - load_database, load_bt_database
#==============================================================================

class Scene_Title
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Load Database
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias moral_sklvl_loaddb_7ol9 load_database
  def load_database (*args)
    moral_sklvl_loaddb_7ol9 (*args) # Run Original Method
    $data_skills = Data_Skills.new ($data_skills)
    $data_skills.reset_lsu_cache
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Load Database for Battle Testing
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mnab_lvskl_btdata_6wp1 load_bt_database
  def load_bt_database (*args)
    mnab_lvskl_btdata_6wp1 (*args) # Run Original Method
    $data_skills = Data_Skills.new ($data_skills)
    $data_skills.reset_lsu_cache
  end
end


Have fun and hopefully it works. Make sure you tell me if there are any bugs or if some things need improvement.
Title: Re: [Request] Level Skills by Use
Post by: Terra-chan on December 09, 2010, 04:06:51 PM
The project leader got around to testing it and this is what she said.
QuoteI have run into a problem--the skills set up won't level up, regardless of what the use tag is set to. To make sure that it wasn't just me making an error I also tried using the example MA had in the instructions, to the same end. If it set it up as a root skill it works fine, so it's just the level add-on. Also, when used with YEM (I tested the script both in v.034 and in a new project without YEM), the "Used: _ times" field disappears if you switch through windows in the skill menu.

--S.R.
Title: Re: [Request] Level Skills by Use
Post by: modern algebra on December 09, 2010, 04:22:12 PM
hmm, well tell her to recreate the problems in a new project and send it to me (assuming she doesn't want to share the main project). I've tested it and it has worked fine, so it's hard for me to identify the problem just from that description, particularly as it doesn't disclose any error message.

Whatever the problem, I imagine it's just some conflict I didn't anticipate with YEM, where for instance the skill use isn't updating. It should be easy to fix once I can identify the problem through a demo like that.
Title: Re: [Request] Level Skills by Use
Post by: Terra-chan on December 10, 2010, 07:08:56 PM
QuoteAfter playing around with the script set up again, I have managed to get a skill to level up. The reason why "couldn't" before is because when using the \use[x, y] tag, it took the second level of usage to level to skill to lvl 2 (for example, using \use[2, 2] it took 4 usages instead of 2). To cover my bases, I tested this both with having the lvl 1 skill learned automatically for the class and with the skill call script--and of course, making sure that the skill really was started at lvl 1. Fortunately, this isn't really a problem to work around, but I've included the demo project I tested this in regardless: http://www.4shared.com/file/oRqGb475/Project1.html

Thank you for your time!
Title: Re: [Request] Level Skills by Use
Post by: modern algebra on December 10, 2010, 09:31:23 PM
Ah, I'm glad to hear that.

Thinking of it now, that was a really poor design choice. I guess I was thinking of it starting at level 0, but the starting level was always intended to be 1, so bad logic on my part. Sorry if I caused any distress.