Generic Skill Object #19051

Parent Owner Flags Source rpg_march_2006/skillobj.txt

Aliases: Generic, Skill, Object

18 verbs · 22 properties · 1 children

Verbs

VerbSpecFlagsDefinerLines
resolvethis none this#1905127
movetothis none this#190516
penaltythis none this#190516
property_namethis none this#190512
initializethis none thisrx#190518
recyclethis none thisrx#190518
descriptionthis none this#1905111
tell_statsthis none this#1905110
stinkcloud_pen*altythis none this#1905129
fake_resolve pseudoresolvethis none this#1905127
capthis none this#1905113
improve_learn_okthis none this#190511
slowness_modthis none this#1905110
check_improvethis none this#1905118
do_improvethis none this#1905111
track_usagethis none this#190511
penalty_trustedthis none this#190513
stinkcloud_pen(old)this none this#1905128

Properties

PropertyDefinerFlagsOwnerValue
dependant#19051r{{}, {}}
learn#19051r10
encumbrance#19051r0
insanity#19051r0
injury#19051r0
fatigue#19051r0
dep_names#19051r{}
neg_deps#19051r{}
neg_dep_names#19051r{}
max_level#19051r25
caps#19051r{}
cap_names#19051r{}
cap_boost_mult#19051r1
enc_ins_inj_fat#19051rc{0, 0, 0, 0}
improve_learn_ok#19051rc1
improve_task#19051r264748148
queue#19051not readable (E_PERM)
move_dependent#19051r0
key#19051not readable (E_PERM)
aliases#19051{"Generic", "Skill", "Object"}
description#19051"An indicator of skill in some nameless area."
object_size#19051{15902, 1141286561}

Ancestry

Ancestors (nearest first): none

Children: #22517 Generic Spell Skill Object

Call graph

calls n19051_0 #19051:resolve n19051_2 #19051:penalty n19051_0->n19051_2 n19051_12 #19051:slowness_mod n19051_0->n19051_12 n19051_13 #19051:check_improve n19051_0->n19051_13 n19051_15 #19051:track_usage n19051_0->n19051_15 n19051_4 #19051:initialize n19051_1 #19051:moveto n19051_4->n19051_1 n19051_5 #19051:recycle n19051_3 #19051:property_name n19051_5->n19051_3 n19051_9 #19051:fake_resolve n19051_9->n19051_3 n19051_16 #19051:penalty_trusted n19051_16->n19051_2

Source

resolve

Spec this none thisDefiner #19051

Referenced by

none

Source

1":resolve(<OBJ character>, <NUM modifier to resolve>, [FLAG no_improve], [OBJ permissions]) => NUM result of skill roll for character, with modfier added on.";
2"The no_improve flag, if given and true, prevents the doll's skill improvement routine from being called at all.";
3"The permissions argument overrides the regular perm check for gm probationary status in deciding whether or not to call the doll's improve routine.";
4if (caller_perms() in (rpg = $local.rpg).gms)
5  {char, mod, ?no_imp = 0, ?perms = caller_perms()} = args;
6  if (valid(doll = rpg:get_doll(char)))
7    no_imp = no_imp || (valid(doll.duelee) && (`rpg:get_doll(doll.duelee).duelee ! E_INVIND' == doll.character));
8    res = rpg:roll(doll:total(this) + mod) - (pen = this:penalty(doll));
9    res = this:slowness_mod(res - this:stinkcloud_pen(doll), doll);
10    ic = this:slowness_mod(max(20, random(180) - 60), doll) - pen;
11    if (no_imp)
12      "... don't call improve ...";
13    else
14      if ((res > -20) && (res < ic))
15        (perms in rpg.probation) || this:check_improve(doll);
16      endif
17      this:track_usage();
18    endif
19    doll.last_action = time();
20    return res;
21  else
22    return -200;
23  endif
24else
25  return 100 - random(200);
26  "Return some random nonsensical number, just so prospective GMs can practice with resolves and not get E_TYPEs from an E_PERM.";
27endif

moveto

Spec this none thisDefiner #19051

Referenced by

Source

1{where} = args;
2if ($local.rpg:is_grandmaster(caller_perms()) || caller_perms().wizard)
3  return pass(where);
4else
5  return E_PERM;
6endif

penalty

Spec this none thisDefiner #19051

Referenced by

Source

1{doll} = args;
2if (caller == this)
3  return ((((4 + (this.injury * doll.inj)) + (this.insanity * doll.ins)) + (this.fatigue * doll.fat)) + ((this.encumbrance * doll:encumbrance()) / 3)) / min(25, doll.end || 15);
4endif
5return 0;
6"THX (#105941) - Mon Mar 29, 1999 - subst /10/(doll.end || 15)/2";

property_name

Spec this none thisDefiner #19051

Referenced by

Source

1"Return the corresponding property name on $local.rpg.doll.";
2return this.aliases[1];

initialize

Spec this none thisFlags rxDefiner #19051

Referenced by

none

Source

1if ((caller == this) || $perm_utils:controls(caller_perms(), this))
2  this:moveto($local.rpg.skills);
3  $quota_utils:object_bytes(this);
4  return pass(@args);
5else
6  return E_PERM;
7endif
8"Profane 13-DEC-95 1126 EST -- $quota:utils:object_size.";

recycle

Spec this none thisFlags rxDefiner #19051

Referenced by

none

Source

1if ((caller == this) || $perm_utils:controls(caller_perms(), this))
2  propname = this:property_name();
3  delete_property($local.rpg.doll, propname);
4  delete_property($local.rpg.skills, propname);
5  return pass(@args);
6else
7  return E_PERM;
8endif

description

Spec this none thisDefiner #19051

Referenced by

none

Source

1"Return the description, plus a line detailing which skills affect this one.";
2deps = this.dependant;
3atts = deps[1];
4skills = deps[2];
5if (atts || skills)
6  depstr = (((this:title() + " is a skill directly influenced by ") + (atts ? "the attributes " + $string_utils:title_list(atts) | "")) + (skills ? ((atts ? ", and " | "") + "the skill(s) ") + $string_utils:title_list(skills) | "")) + ".";
7else
8  depstr = this:title() + " is a basic attribute.";
9endif
10return {@(typeof(base = pass(@args)) == LIST) ? base | {base}, depstr};
11"DR 10-APR-94 -- Tweaked the spacing in 'the skills'.";

tell_stats

Spec this none thisDefiner #19051

Referenced by

none

Source

1stats = properties($local.RPG.skill_object);
2player:tell($string_utils:centre(this.name, 40, "-"));
3dep = this.dependant;
4player:tell("Dependant Attributes: ", $string_utils:nn(dep[1], "", "None"));
5player:tell("Dependant     Skills: ", $string_utils:nn(dep[2], "", "None"));
6player:tell("");
7for pn in (setremove(stats, "dependant"))
8  player:tell($string_utils:left(pn, 18), ": ", $string_utils:print(this.(pn)));
9endfor
10player:tell($string_utils:space(40, "-"));

stinkcloud_pen*alty

Spec this none thisDefiner #19051

Referenced by

none

Source

1":stinkcloud_penalty(<OBJ doll>) => NUM penalty that doll should have to a resolve roll for being under the influence of stinkcloud";
2{doll} = args;
3rpg = $local.rpg;
4if ((rpg.magic_db.sc_combat_effect in doll.view_effects) && (data = doll:read_misc_note("stinkcloud")))
5  if (caller != this)
6    "Return some random nonsensical number, just so prospective GMs can practice with resolves and not get E_TYPEs from an E_PERM.";
7    return 99 - random(200);
8  endif
9  {qual, time} = data;
10  qual = (qual > 0) ? qual | 0;
11  cloud_pen = min(max((time - time()) + (qual * toint(sqrt(tofloat(qual)))), 1), qual);
12  if ((rpg.skills.shock:resolve(doll, -cloud_pen) >= 0) || ((time() - time) > 1200))
13    doll:erase_misc_note("stinkcloud");
14    rpg.magic_db.sc_combat_effect:remove(doll);
15    rpg:playertell(doll.character, "You have finally recovered from the effects of the stinking cloud.");
16    cloud_pen = 0;
17  else
18    if (random(4) == 1)
19      rpg:playertell(doll.character, "You are still reeling from the effects of the stinking cloud. . .");
20      rpg:say_action("%N %<hacks> and %<wheezes>.", doll.character);
21    endif
22  endif
23  return cloud_pen;
24endif
25return 0;
26"Irin Mon Sep  9 17:15:12 1996 PDT -- replaced $math_utils:sqrt() with sqrt().  Set max penalty to equal quality.";
27"THX 18-FEB-1997 - tossed in scatters where appropriate to kill list indexings.  Cleaned up a bit.";
28"Profane (#30788) - Tue Jan 13, 1998 - simplify security";
29"THX (#105941) - Wed Jun 13, 2001 - Put security check inside the check for stinkcloud presence and checked for stinkcloud effect in doll.view_effects before doll:read_misc_note(\"stinkcloud\").  This saves ~100 ticks for every single resolve call!  But we should still get rid of this hack.";

fake_resolve pseudoresolve

Spec this none thisDefiner #19051

Referenced by

none

Source

1":fake_resolve(<OBJ character>, <NUM modifier to resolve>, [NUM skill score,LIST dependant, NUM learn, NUM encumbrance pen, NUM insanity pen, NUM injury pen, NUM fatigue pen]) => As a regular resolve, but allows you to pass parameters for various penalty bits.";
2if (!$local.rpg:trusted(caller_perms()))
3  return 100 - random(200);
4elseif (!valid(doll = $local.rpg:get_doll(args[1])))
5  return E_INVARG;
6else
7  mod = args[2];
8  l = length(args);
9  score = (l > 2) ? args[3] | doll.(this:property_name());
10  dependant = (l > 3) ? args[4] | this.dependant;
11  learn = (l > 4) ? args[5] | this.learn;
12  insanity = (l > 5) ? args[6] | this.insanity;
13  injury = (l > 6) ? args[7] | this.injury;
14  fatigue = (l > 7) ? args[8] | this.fatigue;
15  total = score;
16  for dep_att in (dependant[1])
17    total = total + doll.(dep_att.aliases[1]);
18  endfor
19  for dep_att in (dependant[2])
20    total = total + doll:total(dep_att);
21  endfor
22  pen = ((((4 + (injury * doll.inj)) + (insanity * doll.ins)) + (fatigue * doll.fat)) + ((encumbrance * doll:encumbrance()) / 10)) / 10;
23  res = $local.rpg:roll((total + mod) - pen);
24  res = res - this:stinkcloud_pen(doll);
25  doll.last_action = time();
26  return res;
27endif

cap

Spec this none thisDefiner #19051

Referenced by

none

Source

1"#19051:cap(doll) => returns maximum value that the skill can have, for purposes of $local.rpg.doll:improve.";
2$local.rpg:secure();
3if (cn = this.cap_names)
4  {doll} = args;
5  top = 0;
6  for c in (cn)
7    top = max(top, doll.(c));
8  endfor
9  return top;
10else
11  return this.max_level;
12endif
13"Each skill has a list of cap names.  These are compiled by #34595:update_skills, when skills are changed.  Each skill has an individual cap, and each one depends on either its own cap, or if it has none, the caps of all skills higher on it in the hierarchy.  Thus, melee is based on CAPmelee, while rapier is capped by CAPsword and CAPweap1.  Somebody come up with a less obscure method.  Please! ;) -- Irin.";

improve_learn_ok

Spec this none thisDefiner #19051

Referenced by

none

Source

1return this.(verb);

slowness_mod

Spec this none thisDefiner #19051

Referenced by

Source

1"Makes it more difficult to improve if you're hasted. Easier of slowed.";
2"I realize the code is a bit of an eye-sore. So, what it does is take the first argument, `res' and will halve it for a slowness of 2 and make it half again its original value for a slowness of 18. Those are the min and max values and everything in-between is proportionate. A slowness of 10 would be unchanged.";
3{res, doll} = args;
4if (caller == this)
5  return toint(tofloat(res) * doll.slowness_mod);
6else
7  return res;
8endif
9"Mooshie (#106469) - Fri Dec 26, 1997 - Added. I hope I never have to look back on this and wonder how I was doing it.";
10"Mooshie (#106469) - Thu Feb  5, 1998 - Faster version. :set_att now hooks .slowness modifications and sets .slowness_mod appropriately.";

check_improve

Spec this none thisDefiner #19051

Referenced by

Source

1":check_improve(OBJ doll)";
2{doll} = args;
3(rpg = $local.rpg):secure();
4who = doll.character;
5if ((`idle_seconds(who) ! ANY => -1' < 0) && (!(who.owner in rpg.gms)))
6  raise(E_PERM, "No skill improvement for disconnected players.");
7elseif (this.move_dependent && doll:stymied())
8  return;
9endif
10root = $code_utils:verb_loc();
11root.queue = {@root.queue, {doll, this, callers()}};
12"Okay, we're basically checking if the improve_task has ended, or suspended in someone else's queue here.  I.e., some idiot player's :tell verb.";
13if ((!$code_utils:task_valid(root.improve_task)) || (`task_stack(root.improve_task) ! ANY' == E_PERM))
14  fork z (0)
15    root:do_improve();
16  endfork
17  root.improve_task = z;
18endif

do_improve

Spec this none thisDefiner #19051

Referenced by

none

Source

1":do_improve()";
2(rpg = $local.rpg):secure();
3root = $code_utils:verb_loc();
4while (root.queue && (root.improve_task == task_id()))
5  {doll, skill, callers} = root.queue[1];
6  root.queue = root.queue[2..$];
7  if (`doll.(skill.aliases[1]) || 1 ! ANY')
8    doll:improve(skill, 0, callers);
9  endif
10  rpg:s_i_f_i_n();
11endwhile

track_usage

Spec this none thisDefiner #19051

Referenced by

Source

1return;

penalty_trusted

Spec this none thisDefiner #19051

Referenced by

none

Source

1{doll} = args;
2$local.rpg:secure();
3return this:penalty(doll);

stinkcloud_pen(old)

Spec this none thisDefiner #19051

Referenced by

none

Source

1":stinkcloud_penalty(<OBJ doll>) => NUM penalty that doll should have to a resolve roll for being under the influence of stinkcloud";
2if (caller != this)
3  "Return some random nonsensical number, just so prospective GMs can practice with resolves and not get E_TYPEs from an E_PERM.";
4  return 99 - random(200);
5else
6  {doll} = args;
7  rpg = $local.rpg;
8  if (data = doll:read_misc_note("stinkcloud"))
9    {qual, time} = data;
10    qual = (qual > 0) ? qual | 0;
11    cloud_pen = min(max((time - time()) + (qual * toint(sqrt(tofloat(qual)))), 1), qual);
12    if ((rpg.skills.shock:resolve(doll, -cloud_pen) >= 0) || ((time() - time) > 1200))
13      doll:erase_misc_note("stinkcloud");
14      rpg.magic_db.sc_combat_effect:remove(doll);
15      rpg:playertell(doll.character, "You have finally recovered from the effects of the stinking cloud.");
16      cloud_pen = 0;
17    else
18      if (random(4) == 1)
19        rpg:playertell(doll.character, "You are still reeling from the effects of the stinking cloud. . .");
20        rpg:say_action("%N %<hacks> and %<wheezes>.", doll.character);
21      endif
22    endif
23    return cloud_pen;
24  endif
25endif
26"Irin Mon Sep  9 17:15:12 1996 PDT -- replaced $math_utils:sqrt() with sqrt().  Set max penalty to equal quality.";
27"THX1138 18-FEB-1997 - tossed in scatters where appropriate to kill list indexings.  Cleaned up a bit.";
28"Profane (#30788) - Tue Jan 13, 1998 - simplify security";