generic drug #125

Parent #1Owner #29Flags read, fertileSource hellcore/hellcore.db

Aliases: generic drug

25 verbs · 45 properties · 3 children

Verbs

VerbSpecFlagsDefinerLines
effectthis none thisrxd#12521
metabolizethis none thisrxd#12535
skill_modthis none thisrxd#12513
reupthis none thisrxd#12514
onsetthis none thisrxd#1257
overdosethis none thisrxd#1254
doses_forthis none thisrxd#12510
remove_fromthis none thisrxd#12533
look_self_msgthis none thisrxd#12513
recoverthis none thisrxd#1255
_look_self_msgthis none thisrxd#1251
tell_diagnosisthis none thisrxd#12510
try_curethis none thisrxd#12513
victim_tell_msgthis none thisrxd#1256
brainscan_msgthis none thisrxd#1253
onset_timethis none thisrxd#1257
resist_drugthis none thisrxd#1255
addiction_dosesthis none thisrxd#1253
xp_bonusthis none thisrxd#1255
tactical_msgthis none thisrxd#1251
max_doses max_doses_forthis none thisrxd#1251
effect_descriptionthis none thisrxd#1257
tree_tagthis none thisrxd#12514
impose_side_effectsthis none thisrxd#1258
side_effectsthis none thisrxd#1252

Properties

PropertyDefinerFlagsOwnerValue
halflife#125rc#29{50, 0, 1}
overdosage#125rc#295
skill_mods#125rc#29{}
decay_msg#125rc#29""
onset_msg#125rc#29""
overdose_msg#125rc#29""
reup_msg#125rc#29""
overdose_chance#125rc#2950
help_msg#125rc#29
list of 23{"Drugs are a way for you to effect a players stats or cause some action on every heartbeat.", "", "Verbs:", "", "$creature:ingest(OBJ drug, INT doses) -- add this many doses of the drug to the creature's bloodstream", "$drug:onset(user, doses) -- do whatever needs doing when use first takes the drug. By default this just prints a the drug's .onset_msg to the user, if it exists.", "$drug:reup(OBJ drug, INT doses) -- do whatever needs doing when the user takes this many more doses of the drug. By default this just prints the drug's .reup_msg to the user, if it exists.", "$drug:overdose(OBJ user) -- do whatever needs doing when user overdoses on this drug. By default this just prints the drug's .overdose_msg to the user.", "$drug:metabolize(OBJ user) -- this verb is responsible for removing the drug from the user's bloodstream when his heart beats. How this happens is governed by the properties defined below. This verb also checks for an overdose condition and triggers that. If the drug is metabolized in part, the verb will print the drug's .decay_msg, if it exists. If the drug is completely metabolized, the verb will print the drug's .final_decay_msg, if it exists.", "$drug:effect(OBJ user) -- this is the verb that calls :metabolism on every heartbeat. This is what you would override to cause the drug to perform some action on every heartbeat, like inserting actions into the action queue, etc.", "", "Properties:", "", ".onset_msg -- what's printed to the user when they first take the drug, if anything", ".reup_msg -- what's printed to the user when they take more of the drug, if anything", ".decay_msg -- what's printed when the user partially metabolizes the drug, if anything", ".final_decay_msg -- what's printed when all of the drug is metabolized, if anything", ".overdose_msg -- what's printed when the user overdoses on this drug, if anything", "** Note that the _msg properties can also be lists of strings. If so, the drug will pick one of these strings at random when printing the message", "", ".halflife -- this is a list {INT chance, INT min, INT max} that determines how the drug gets metabolized. First, the drug rolls to see if the metabolization happens at all. This is where 'chance' comes in. Chance is the percentage chance (0-100) that any of the drug gets metabolized. If roll succeeds then the drug eliminated between 'min' and 'max' doses from the user's bloodstream, at random.", ".overdosage -- the threshold number of doses that can trigger an overdose", ".skill_mods -- a list of lists, with each sublist containing {OBJ skill, FLOAT modifier}. For each dose in the user's bloodstream (up to the .overdosage level) this modifier will be added to that skill for the user. Negative numbers mean a penalty, positive numbers are a bonus. Note that these can be fractional, so that if you set it mod to be {skill, 0.25} you will only get a +1 when you have four doses (the fractional part is ignored in the final comparison)."}
diagnosis_msg#125rc#29"%DN is under the influence of %t."
look_self_msg#125rc#29""
notice_difficulty#125rc#29{1, 5}
effect_msg#125rc#29""
recover_msg#125rc#29""
cure#125rc#29#-1
value#125rc#290
max_doses#125rc#2950
doc_diagnosis_msg#125rc#29""
victim_tell_msg#125rc#29""
tactical_msg#125rc#29""
message_chance#125rc#29100
min_lifetime#125rc#290
min_dose#125rc#291
brainscan_msg#125rc#29""
resist_drugs#125rc#29{}
endurance_resist#125rc#29-999
endure_msg#125rc#29"You wince and shrug off %dt."
oonset_msg#125rc#29""
smell_msg#125rc#29""
effect_on_reup#125rc#291
resists#125rc#29{}
effect_description_msg#125rc#29"contract %t"
side_effects#125rc#29{}
vaporizable#125rc#291
oreup_msg#125rc#29""
aliases#1rc#29{"generic drug"}
description#1rc#29<clear>
object_size#1r#29{18129, 1298433815}
hidden_verbs#1rc#29<clear>
phelp_msg#1rc#29<clear>
weight#1rc#29<clear>
owner_verbs#1rc#29<clear>
plural_name#1rc#29<clear>
client_image#1rc#29<clear>
listening#1rc#29<clear>

Ancestry

Ancestors (nearest first): #1 root

Children: #132 generic disease, #195 generic mood, #196 generic poison

Call graph

calls n125_0 #125:effect n20_81 #20:msg n125_0->n20_81 n125_6 #125:doses_for n125_0->n125_6 n20_34 #20:pronoun_sub n125_0->n20_34 n125_1 #125:metabolize n125_0->n125_1 n125_5 #125:overdose n125_0->n125_5 n125_23 #125:impose_side_effects n125_0->n125_23 n125_7 #125:remove_from n125_1->n125_7 n125_5->n20_81 n125_5->n20_34 n125_24 #125:side_effects n125_23->n125_24 n125_7->n20_81 n125_7->n20_34 n125_9 #125:recover n125_7->n125_9 n125_3 #125:reup n125_3->n125_0 n125_3->n20_81 n125_3->n20_34 n125_4 #125:onset n125_4->n20_81 n125_4->n20_34 n125_9->n20_81 n125_9->n20_34 n125_8 #125:look_self_msg n125_10 #125:_look_self_msg n125_8->n125_10 n125_11 #125:tell_diagnosis n125_11->n125_6 n125_11->n20_34 n107_43 #107:tell n125_11->n107_43 n125_12 #125:try_cure n45_5 #45:isa n125_12->n45_5 n125_21 #125:effect_description n125_21->n20_34 n125_22 #125:tree_tag n20_2 #20:right n125_22->n20_2

Source

effect

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

Source

1":effect(OBJ user, INT doses_for, INT time ingested) => cause user to feel the effects of this drug";
2"Stat mods, speed bonuses, etc.";
3"Any actions forced on the player or messages should be processed here";
4user = args[1];
5if (msg = $su:msg(this.effect_msg))
6chance = tofloat(this:doses_for(user)) / tofloat(this.overdosage);
7chance = chance * 100.0;
8if (tofloat(random(100)) < chance)
9if (random(100) <= this.message_chance)
10user:tell($su:ps(msg, user, this));
11endif
12endif
13endif
14this:metabolize(user);
15df = this:doses_for(user) + 1;
16if (df > this.overdosage)
17if (random(100) <= this.overdose_chance)
18this:overdose(user, df - this.overdosage);
19endif
20endif
21this:impose_side_effects(user, df);

metabolize

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

Source

1":metabolize(OBJ user) => send some of this drug through user's liver or kidneys";
2"$player.blood = { { OBJ drug, INT inception, INT dosage } [, { ... } ]}";
3"this.halflife = { INT percent_chance, INT min, INT max } -- the percentage chance that the user will lose between min and max doses";
4user = args[1];
5chance = this.halflife[1];
6if (this.min_lifetime)
7for x in (user.blood)
8if (x[1] == this)
9dose_time = x[2];
10if ((time() - dose_time) < this.min_lifetime)
11return;
12endif
13break;
14endif
15endfor
16endif
17if (random(100) < chance)
18min = this.halflife[2];
19max = this.halflife[3];
20range = max - min;
21if (range == 0)
22doses = min;
23elseif (range < 0)
24doses = 0 - random(abs(range));
25doses = doses + min;
26else
27doses = random(range);
28doses = doses + min;
29endif
30if (doses > 0)
31this:remove_from(user, doses);
32else
33user:ingest(this, 0 - doses, 0);
34endif
35endif

skill_mod

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

none

Source

1":skill_mod(OBJ skill, OBJ user) => Returns the modifier this drug has on this skill for user";
2user = args[2];
3skill = args[1];
4doses = args[3];
5doses = min(doses, this.overdosage);
6for x in (this.skill_mods)
7if (x[1] == skill)
8mod_per_dose = x[2];
9result = tofloat(doses) * tofloat(mod_per_dose);
10result = toint(result);
11return result;
12endif
13endfor

reup

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

none

Source

1{user, change, oldlevel, timestamp} = args;
2if (is_a(user, $creature))
3if (random(100) <= this.message_chance)
4if (msg = $su:msg(this.reup_msg))
5user:tell($su:ps(msg, user, this));
6endif
7if (msg = $su:msg(this.oreup_msg))
8user:aat($su:ps(msg, user, this));
9endif
10endif
11if (this.effect_on_reup)
12this:effect(user, min(this.max_doses, oldlevel + change), timestamp);
13endif
14endif

onset

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

none

Source

1user = args[1];
2if (msg = $su:msg(this.onset_msg))
3user:tell($su:ps(msg, user, this));
4endif
5if (m = $su:msg(this.oonset_msg))
6user:aat($su:ps(m, user, this));
7endif

overdose

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

Source

1user = args[1];
2if (msg = $su:msg(this.overdose_msg))
3user:tell($su:ps(msg, user, this));
4endif

doses_for

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

Source

1who = args[1];
2if (!is_a(who, $creature))
3return 0;
4endif
5for x in (who.blood)
6if (x[1] == this)
7return x[3];
8endif
9endfor
10return 0;

remove_from

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

Source

1":remove_from(OBJ who, INT doses)";
2"Remove this many doses from who's blood, if he has them.  Return a pair of the old and new amount of doses.";
3who = args[1];
4doses = (length(args) > 1) ? args[2] | 99999;
5bi = 0;
6if (is_a(who, $creature))
7for x in [1..length(who.blood)]
8if (is_a(who.blood[x][1], this))
9bi = x;
10endif
11endfor
12if (bi)
13olddoses = who.blood[bi][3];
14who.blood[bi][3] = who.blood[bi][3] - doses;
15newdoses = max(who.blood[bi][3], 0);
16if (newdoses < 1)
17this:recover(who);
18who.blood = listdelete(who.blood, bi);
19if (this.tell_healthnet && is_a(who, $player))
20$nets.healthnet:announce_event(who, this, "been cured of");
21endif
22elseif (m = this.decay_msg)
23if (random(100) <= this.message_chance)
24who:tell($su:ps($su:msg(m), who, this));
25endif
26endif
27for x in (this.skill_mods)
28x[1]:flush(who);
29endfor
30return {olddoses, newdoses};
31endif
32endif
33return {0, 0};

look_self_msg

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

none

Source

1who = args[1];
2doses = args[2];
3if (player == who)
4return this:_look_self_msg(@args);
5else
6notice = this.notice_difficulty[1];
7if (this.notice_difficulty[2])
8notice = notice + (doses / this.notice_difficulty[2]);
9endif
10if ($skills.senses:check(player, notice))
11return this:_look_self_msg(@args);
12endif
13endif

recover

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

Source

1who = args[1];
2if (msg = $su:msg(this.recover_msg))
3who:tell($su:ps(msg, who, this));
4endif
5return 0;

_look_self_msg

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

Source

1return this.look_self_msg;

tell_diagnosis

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

none

Source

1who = args[1];
2if (this.diagnosis_msg)
3doses = this:doses_for(who);
4if (valid(this.cure))
5post = ("  You could treat it with " + this.cure:iname()) + ".";
6else
7post = "";
8endif
9player:tell($su:ps(strsub(this.diagnosis_msg, "%doses", tostr(doses)), who, this) + post);
10endif

try_cure

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

none

Source

1victim = args[1];
2medic = args[2];
3cure = #-1;
4for x in (medic.contents)
5if ($ou:isa(x, this.cure))
6cure = x;
7endif
8endfor
9if (!valid(cure))
10medic:tell("You're pretty sure you could cure ", victim:dname(), "'s ", this.name, " if you had ", this.cure:iname(), ".");
11else
12medic:queue_action(cure.use_action, {cure, victim}, 1, "cure " + this.name);
13endif

victim_tell_msg

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

none

Source

1doses = args[1];
2if (typeof(this.(verb)) == LIST)
3l = this.(verb);
4return l[max(1, min(length(l), doses))];
5endif
6return this.(verb);

brainscan_msg

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

none

Source

1if (this.(verb))
2return this.(verb);
3endif

onset_time

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

none

Source

1who = args[1];
2for x in (who.blood)
3if (x[1] == this)
4return x[2];
5endif
6endfor
7return 0;

resist_drug

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

none

Source

1substance = args[1];
2if (substance in this.resist_drugs)
3return 1;
4endif
5return 0;

addiction_doses

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

none

Source

1base_drug_ingested = args[1];
2who = args[2];
3return base_drug_ingested;

xp_bonus

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

none

Source

1if (!this.xp)
2return 0;
3endif
4xp = min(5, max(1, toint(tofloat(args[1]) * tofloat(this.xp))));
5return xp;

tactical_msg

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

none

Source

1return this.(verb);

max_doses max_doses_for

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

none

Source

1return this.max_doses;

effect_description

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

none

Source

1{?doses = 1} = args;
2if (typeof(this.effect_description_msg) == LIST)
3level = tofloat(doses) / tofloat(this.max_doses);
4return $su:ps(this.effect_description_msg[min($, max(1, toint(level * tofloat($))))]);
5else
6return $su:ps(this.effect_description_msg);
7endif

tree_tag

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

none

Source

1{decaychance, decaymin, decaymax} = this.halflife;
2hl = tostr($su:right(tostr(decaychance), 3), "% ", decaymin, "-", decaymax);
3skillstr = "";
4for skillmod in (this.skill_mods)
5{skill, mod} = skillmod;
6mod = tofloat(mod);
7col = (mod > 0.0) ? $ansi.green | $ansi.red;
8s = tostr(col, skill.abbrev, $ansi.reset);
9skillstr = (skillstr + " ") + s;
10endfor
11if (skillstr)
12skillstr = skillstr[2..$];
13endif
14return tostr("hl", hl, " od", this.overdosage, " ", skillstr);

impose_side_effects

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

Source

1"If the drug has side effects possibly infect user with them.";
2{user, doses} = args;
3for x in (this:side_effects(user))
4{effect, chance} = x;
5if (random(1000) <= toint((tofloat(chance) * tofloat(doses)) * 10.0))
6user:ingest(effect, 1, 0);
7endif
8endfor

side_effects

Spec this none thisFlags rxdOwner #361Definer #125

Referenced by

Source

1who = args[1];
2return this.side_effects;