You are looking at many info about skill handlings
Overview Every object with material of 'living' faces difficulties in life. To confront these requires skill, and this is how we have implemented such a thing in COW.
Objects have 2 skill handling fields: skills and skillvals.
Note: now we are packaging everything under the skills field.
skills is a string of | delimited skill key names and values.
Each value string includes all of the information needed to handle the skill. This includes the skill's basic values and all temporary modifiers to the skill.
What is a skill modifier? How about an example: One of the skill names is 'aim'. Suppose someone created a ring of aiming. Wearing this ring could result in a plus 10 in the person's aim, even if that brings their aim above their cap (the highest they can develop their skill). Suppose they also wear a cursed ring of aiming. This could result in a -10 in their aim. If they wear both rings, the net modification is 0.
Now back to string handling. I have bad news and good news.
The bad news: Manipulating these strings is very dangerous, because they must maintain the right format in order to keep working. It is also difficult, requiring a complicated series of string manipulations.
The good news: Thorn has taken care of all that intricate work for you, creating some blocks of code to handle all of the precise details.
Therefore, all coders need to know are how to prepare parameters and call blocks of well-tested code to handle the business of skill checking and manipulation.
All of this code is included in this information object. Somewhere in your code, you need to include 58416. Then, set up the required variables and runsub the appropriate block.
Examples (note: only include 58416 once):
Reading the actor's modified aim skill: include 58416; multivar $skiller=$actor,$skillname='aim'; runsub getskillvalue; $aim = $skillvalue; add $skillmod to $aim;
Adding a modifier for a duration: See the material called liquor (code 65676); Note: var $modtick and $modend to the object id where you have blocks modtickeffect and modendeffect. modtickeffect is run for each tick the modifier is in effect and modendeffect is run when the modifier is no longer in effect.
Adding a modifier while an object is hosted: No example yet.
Reading the initial object's aim cap: (typically a trainer or quest handler will need this) include 58416; multivar $skiller=$init_obj,$skillname='aim'; runsub getskillcap; $aimcap = $skillcap;
Setting the initial object's aim cap to 30 (again, something typical of a trainer or quest handler) include 58416; multivar $skiller=$init_obj,$skillname='aim',$skillcap=30,$skilltipobj=58773; runsub setskillcap;
To see the current skill tip objects, read some info about aim (or whatever skill you are working with).
If you are setting the skill cap on a non-player character (for example, a ridiculously high level monster), then the skill tip object doesn't really matter because only players really benefit from tips. So make it $skilltipobj=63949. If somehow this skill tip ends up on a player, they will realize this by the message given each time they advance.
Advancing a skill:
include 58416; multivar $skiller=$actor,$skillname='aim',$skilltipobj=58711; runsub incrskill;
In the above, the skill tip object is the aim10 skilltip, which would be initialized if the $skiller object didn't have an aim skill before incrementing it.
What does incrementing a skill do? It increments $skillpoints until they reach the $skillvalue, at which point the $skillvalue is increased by one and $skillpoints starts over. This happens until the $skillcap is reached.
Note: Sometimes a code block manipulates strings and leaves various side-effect variables behind. Look at the comments in each block of code you are using to make sure it doesn't inadvertedly modify a variable you are using elsewhere.
Configuring skills with arbitrary values If you are building creatures that need various arbitrary values, then ask Thorn or Wolis for an action to allow you to set up their skills. This is not something we want just anyone to be doing for obvious reasons.
Most often code needed
Skills are set to reach a cap. For example, you can practice your aim to 10 points, then you can't go any further without finding a trainer or quest. There can be any number of these for any given cap level.
To add a quest: 1. create your area 2. include a trainer (the object that checks and sets the cap based on some task) 3. find the skilltip object matching the difficulty of your quest 4. Ask whoever owns it to add a tip or rumor that hints about your area.
When players reach that cap, some may get a tip leading them to your little puzzle.
Creating new skills
When creating a new skill, please be sure to create a book about that skill and place all skilltip objects in it.
Creating new modifiers
Simple modifiers, like a 'curse' style prayer, can set a modifier with a duration, then forget it. The living material will handle removal when it expires.
Item-based modifiers are a little trickier, because if they are unhosted, the living material will remove the modifier. So your item will need to add the modifier each time it is hosted the appropriate way. A good way to do this is to put the proper reactions in a material for it.
Overview of blocks
initskill Set a new skill
incrskill Improve a skill
getskillvalue What are the skill's raw and modify values?
getskillcap What are the skill's cap and tip?
setskillcap Replace with new cap and tip.
addmod Put a new modifier on a skill
tickmod This is what we plan to put in living materials to handle changing modifiers when either theur duration runs out or they depend on an object that ceases to be hosted for whatever reason.
Storage details:
$skiller = the object id that you are handling skills for. $skiller's skills = skillkey1=values}1{skillkey2=values}1{...
Rules:
- There can only be 1 of each skill name.
- There may be multiple values that have identical values for different skills. So be careful when swapping.
$skillmods => modname1=vals1}3{modname2=vals2}3{... Each mod value is a string of key values delimited by }4{
mod key names and variable names: mval, modval mdur, moddur moobj, modobj mtick, modtick mend, modend
Example: aim=svalue=4}2{smod=-1}2{spoints=3}2{scap=10}2{stipobj=123}2{mods=purevision=mval=5}4{mdur=2}4{mobj=}4{mtick=}4{mend=Your vision returns to normal}3{teargas=mval=-10}4{mdur=}4{mobj=432}4{mtick=The gas fills your eyes with tears}4{mend=The gas dissipates}1{dodgesvalue=4}2{smod=0}2{spoints=3}2{scap=10}2{stipobj=123}2{mods=
aim is 4, modified to -1, 3 points towards next aim value, tip info stored in object 123, there are 2 modifiers: purevision gives 5 aim for 2 more ticks then the message 'Your vision returns to normal' will appear when the modifier is removed. The other modifier: teargas takes 10 from aim as long as object 432 is hosted to the skiller, with 'The gas fills your eyes with tears' shown at each tick and 'The gas dissipates' when the object is no longer hostd.
dodge is the same as aim, but with no modifiers
WARNING: The following characters cause problems with string handling: '^' has special meaning in perl '_' messes with parsing delimited variables, '~' didn't seem to work ',' causes probs with value/position commands ' also causes probs
Make sure you don't include these in your skill messages! (see skilltipobj's info and extra, modtick, and modend below)
Exception: You can put ',' in your skilltipobj's info because we swap it to ` when parsing the string.
skillvalue = a number used when determining success at a skill. key svalue
skillmod = the sum of all temporary modifiers to the skill. The living material object will handle this. key smod
skillpoints = a counter that increments each time a skill is used. when it exceeds skillcap, notify object about skilltip then reset to 0. if not > skillcap then if exceeds skillvalue then increment skillvalue and reset skillpoints to 0. key spoints
skillcap = a number preventing further advancement of a skill without some special tasks (such as a quests, or visitting a trainer). key scap
skilltipobj = the object ID that has tips for what to do whenever skillpoints reaches the skillcap. Each time skillpoints returns to skillcap, this will remind the player until they do whatever is needed to change the cap and the associated tip object. key stipobj
skilltipobj's info = what should be written in the info of a tip object. This will be displayed as a sayto message to the living object when the skillpoints reach skillcap. You may have variations by separating them with |'s. The message will be randomly chosen from the variations. Variations can be different ways of saying the same thing, or tips for various alternate ways of upgrading the skillcap.
Illegal characters: Do not put ` in the info. ` is used as a substitute for commas.
skilltipobj's extra = What should be written in the extra of the tip object. This will be displayed as a sayto message to the living object when the skillval is incremented. Example: You feel a little more accurate.
Modifiers
Modifiers are strings of 6 values placed under the x key of a skill. There may be multiple modifiers added but they must have unique names. The goal is to have the living material object keep track of modifiers and update everything.
Rule on coding a modifier:
- An object should only add modifiers. Once placed there, don't touch it. The living material will handle the rest.
- There are 2 kinds of modifiers: duration-based and object-based. Duration-based modifiers last for a certain number of ticks then go away. Object-based modifiers last as long as the associated object is worn or wielded.
- For object-based modifiers, consider that the object could be pushed off then rehosted before the living material had a chance to remove it. Therefore it is best to check if's modifier names are there before adding them (such as during a wear or wield reaction).
modname = The name of the modifier (if you don't want to allow a modifier to 'stack', then check for this in the string. This is the key for the modifier string. key mods
modval = A temporary value added to the skillvalue when the skill is used. key mval
moddur = If there is no modNobj, the living material will decrement this at each tick. When it reaches 0, it will remove the modifier values. key mdur
modobj = If there is an object (this field > 0), then the modifier will be in effect as long as the living object is wearing or wielding this object. The living material will check if this object is hosted correctly to the living object. key mobj
modtick = text to display each tick the modifier is in effect. key mtick
modend = text to display when the modifier is removed (either the duration runs out or the modifying object is no longer worn or wielded). key mend
Note: a modifier object can apply to multiple skills. For example, a robotic suit that increases armour, strength, aim, and dodge as long as it is worn. Therefore you may find the same modifier object mentioned in multiple parts of the skillvals string.