generic drug #125
Aliases: generic drug
25 verbs · 45 properties · 3 children
Verbs
| Verb | Spec | Flags | Definer | Lines |
|---|---|---|---|---|
effect | this none this | rxd | #125 | 21 |
metabolize | this none this | rxd | #125 | 35 |
skill_mod | this none this | rxd | #125 | 13 |
reup | this none this | rxd | #125 | 14 |
onset | this none this | rxd | #125 | 7 |
overdose | this none this | rxd | #125 | 4 |
doses_for | this none this | rxd | #125 | 10 |
remove_from | this none this | rxd | #125 | 33 |
look_self_msg | this none this | rxd | #125 | 13 |
recover | this none this | rxd | #125 | 5 |
_look_self_msg | this none this | rxd | #125 | 1 |
tell_diagnosis | this none this | rxd | #125 | 10 |
try_cure | this none this | rxd | #125 | 13 |
victim_tell_msg | this none this | rxd | #125 | 6 |
brainscan_msg | this none this | rxd | #125 | 3 |
onset_time | this none this | rxd | #125 | 7 |
resist_drug | this none this | rxd | #125 | 5 |
addiction_doses | this none this | rxd | #125 | 3 |
xp_bonus | this none this | rxd | #125 | 5 |
tactical_msg | this none this | rxd | #125 | 1 |
max_doses max_doses_for | this none this | rxd | #125 | 1 |
effect_description | this none this | rxd | #125 | 7 |
tree_tag | this none this | rxd | #125 | 14 |
impose_side_effects | this none this | rxd | #125 | 8 |
side_effects | this none this | rxd | #125 | 2 |
Properties
| Property | Definer | Flags | Owner | Value |
|---|---|---|---|---|
halflife | #125 | rc | #29 | {50, 0, 1} |
overdosage | #125 | rc | #29 | 5 |
skill_mods | #125 | rc | #29 | {} |
decay_msg | #125 | rc | #29 | "" |
onset_msg | #125 | rc | #29 | "" |
overdose_msg | #125 | rc | #29 | "" |
reup_msg | #125 | rc | #29 | "" |
overdose_chance | #125 | rc | #29 | 50 |
help_msg | #125 | rc | #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 | #125 | rc | #29 | "%DN is under the influence of %t." |
look_self_msg | #125 | rc | #29 | "" |
notice_difficulty | #125 | rc | #29 | {1, 5} |
effect_msg | #125 | rc | #29 | "" |
recover_msg | #125 | rc | #29 | "" |
cure | #125 | rc | #29 | #-1 |
value | #125 | rc | #29 | 0 |
max_doses | #125 | rc | #29 | 50 |
doc_diagnosis_msg | #125 | rc | #29 | "" |
victim_tell_msg | #125 | rc | #29 | "" |
tactical_msg | #125 | rc | #29 | "" |
message_chance | #125 | rc | #29 | 100 |
min_lifetime | #125 | rc | #29 | 0 |
min_dose | #125 | rc | #29 | 1 |
brainscan_msg | #125 | rc | #29 | "" |
resist_drugs | #125 | rc | #29 | {} |
endurance_resist | #125 | rc | #29 | -999 |
endure_msg | #125 | rc | #29 | "You wince and shrug off %dt." |
oonset_msg | #125 | rc | #29 | "" |
smell_msg | #125 | rc | #29 | "" |
effect_on_reup | #125 | rc | #29 | 1 |
resists | #125 | rc | #29 | {} |
effect_description_msg | #125 | rc | #29 | "contract %t" |
side_effects | #125 | rc | #29 | {} |
vaporizable | #125 | rc | #29 | 1 |
oreup_msg | #125 | rc | #29 | "" |
aliases | #1 | rc | #29 | {"generic drug"} |
description | #1 | rc | #29 | <clear> |
object_size | #1 | r | #29 | {18129, 1298433815} |
hidden_verbs | #1 | rc | #29 | <clear> |
phelp_msg | #1 | rc | #29 | <clear> |
weight | #1 | rc | #29 | <clear> |
owner_verbs | #1 | rc | #29 | <clear> |
plural_name | #1 | rc | #29 | <clear> |
client_image | #1 | rc | #29 | <clear> |
listening | #1 | rc | #29 | <clear> |
Ancestry
Ancestors (nearest first): #1 root
Children: #132 generic disease, #195 generic mood, #196 generic poison
Call graph
Source
effect
Referenced by
- #125:reup line 12:
this:effect
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
Referenced by
- #125:effect line 14:
this:metabolize
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
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
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
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
Referenced by
- #125:effect line 18:
this:overdose
Source
1user = args[1]; 2if (msg = $su:msg(this.overdose_msg)) 3user:tell($su:ps(msg, user, this)); 4endif
doses_for
Referenced by
- #125:effect line 6:
this:doses_for - #125:effect line 15:
this:doses_for - #125:tell_diagnosis line 3:
this:doses_for
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
Referenced by
- #125:metabolize line 31:
this:remove_from
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
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
Referenced by
- #125:remove_from line 17:
this:recover
Source
1who = args[1]; 2if (msg = $su:msg(this.recover_msg)) 3who:tell($su:ps(msg, who, this)); 4endif 5return 0;
_look_self_msg
Referenced by
- #125:look_self_msg line 4:
this:_look_self_msg - #125:look_self_msg line 11:
this:_look_self_msg
Source
1return this.look_self_msg;
tell_diagnosis
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
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
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
Referenced by
none
Source
1if (this.(verb)) 2return this.(verb); 3endif
onset_time
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
Referenced by
none
Source
1substance = args[1]; 2if (substance in this.resist_drugs) 3return 1; 4endif 5return 0;
addiction_doses
Referenced by
none
Source
1base_drug_ingested = args[1]; 2who = args[2]; 3return base_drug_ingested;
xp_bonus
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
Referenced by
none
Source
1return this.(verb);
max_doses max_doses_for
Referenced by
none
Source
1return this.max_doses;
effect_description
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
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
Referenced by
- #125:effect line 21:
this:impose_side_effects
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
Referenced by
- #125:impose_side_effects line 3:
this:side_effects
Source
1who = args[1]; 2return this.side_effects;