generic usable device with charges #335
Aliases: generic usable device with charges
10 verbs · 49 properties · 1 children
Verbs
| Verb | Spec | Flags | Definer | Lines |
|---|---|---|---|---|
use | this any any | rxd | #335 | 35 |
do_use_start | this none this | rxd | #335 | 38 |
do_use_finish | this none this | rxd | #335 | 21 |
use_start | this none this | rxd | #335 | 5 |
use_finish | this none this | rxd | #335 | 15 |
description | this none this | rxd | #335 | 12 |
can_use_on | this none this | rxd | #335 | 2 |
can_glob | this none this | rxd | #335 | 4 |
match_target | this none this | rxd | #335 | 2 |
spend_charge | this none this | rxd | #335 | 10 |
Properties
| Property | Definer | Flags | Owner | Value |
|---|---|---|---|---|
self_only | #335 | rc | #361 | 1 |
recycle_when_empty | #335 | rc | #361 | 1 |
charges | #335 | rc | #361 | 1 |
use_start_msg | #335 | rc | #361 | "%N preps a %t for use." |
use_on_start_msg | #335 | rc | #361 | "%N preps a %t for use on %dd." |
speed | #335 | rc | #361 | 1.0 |
charges_msg | #335 | rc | #361 | "It's got %t charges left." |
throwaway_msg | #335 | rc | #361 | "%N tosses away %p empty %t." |
use_finish_msg | #335 | rc | #361 | "%N injects %dt into %p arm." |
use_on_finish_msg | #335 | rc | #361 | "%N injects %dt into %d's arm." |
use_action | #335 | rc | #361 | #626 |
charges_max | #335 | rc | #361 | 1 |
empty_msg | #335 | rc | #361 | "%DT is empty." |
in_use | #335 | rc | #361 | 0 |
hold_to_use | #335 | rc | #361 | 1 |
self_allowed | #335 | rc | #361 | 1 |
must_allow | #335 | rc | #361 | "medical" |
empty_form | #335 | rc | #361 | #-1 |
hurts_target | #335 | rc | #361 | 0 |
handed | #5 | rc | #361 | <clear> |
wield_msg | #5 | rc | #361 | <clear> |
unwield_msg | #5 | rc | #361 | <clear> |
size | #5 | rc | #361 | <clear> |
look_place_msg | #5 | rc | #361 | <clear> |
value | #5 | rc | #361 | <clear> |
get_msg | #5 | rc | #361 | <clear> |
drop_msg | #5 | rc | #361 | <clear> |
get_fail_msg | #5 | rc | #361 | <clear> |
junk_ok | #5 | rc | #361 | <clear> |
floats | #5 | rc | #361 | <clear> |
long_name_msg | #5 | rc | #361 | <clear> |
article | #5 | rc | #361 | <clear> |
setup_list | #5 | rc | #361 | <clear> |
health | #5 | rc | #361 | <clear> |
health_max | #5 | rc | #361 | <clear> |
min_skill | #5 | rc | #361 | <clear> |
skill | #5 | rc | #361 | <clear> |
recipe_for | #5 | rc | #361 | <clear> |
carried_msg | #5 | rc | #361 | <clear> |
aliases | #1 | rc | #361 | {"generic usable device with charges"} |
description | #1 | rc | #361 | <clear> |
object_size | #1 | r | #29 | {8222, 1298433815} |
hidden_verbs | #1 | rc | #361 | <clear> |
phelp_msg | #1 | rc | #361 | <clear> |
weight | #1 | rc | #361 | <clear> |
owner_verbs | #1 | rc | #361 | <clear> |
plural_name | #1 | rc | #361 | <clear> |
client_image | #1 | rc | #361 | <clear> |
listening | #1 | rc | #361 | <clear> |
Ancestry
Ancestors (nearest first): #5 generic thing → #1 root
Children: #128 generic lighter
Call graph
Source
use
Referenced by
none
Source
1"Use this on yourself (or, for some items, another person, with 'use this on <person>')."; 2if (prepstr) 3target = this:match_target(iobjstr); 4if (!valid(target)) 5player:tell("You can't use ", this:iname(), " on ", iobjstr, "."); 6return; 7endif 8else 9target = player; 10endif 11if (this.self_only && (target != player)) 12player:tell("You can only use ", this:iname(), " on yourself."); 13return; 14endif 15if ((!this.self_allowed) && (target == player)) 16player:tell("You can't use ", this:iname(), " on yourself!"); 17return; 18endif 19if ((is_a(target, $creature) && this.must_allow) && (!target:_allows(this.must_allow, player))) 20player:tell(target:dnamec(), " won't allow ", this.must_allow, " from you."); 21return; 22endif 23if (this.in_use) 24player:tell(this:dnamec(), " is already being used at the moment."); 25return; 26endif 27if ((target in player.fighting) || (player in target.fighting)) 28player:tell("You're one sick bastard. Beat on a guy and then heal him?"); 29return; 30endif 31if (this:can_use_on(target)) 32player:queue_action(this.use_action, {this, target}, 1, "use " + this.name); 33else 34player:tell("You see no reason to use ", this:iname(), " on ", target:dname(), "."); 35endif
do_use_start
Referenced by
none
Source
1who = args[1]; 2on = args[2]; 3if (!this:can_use_on(on)) 4who:tell("You see no reason to use ", this:iname(), " on ", on:dname(), "."); 5return E_NONE; 6endif 7if (is_a(this, #627)) 8if (this.hold_to_use && (this.location != player)) 9who:tell("You can't use ", this:dname(), " if you don't have it."); 10return E_NONE; 11elseif (((on.location != who.location) && (on.location != who)) && (on != who.location)) 12try 13who:tell("You can't use ", this:dname(), " on ", on:dname(), ", ", on.ps, " isn't even here!"); 14except (ANY) 15endtry 16return E_NONE; 17elseif (this.charges < 1) 18who:tell($su:ps(this.empty_msg, who, this, on)); 19return E_NONE; 20else 21if ((!this.hold_to_use) || who:_wield(this, 0, 1)) 22if (on == who) 23if (this.use_start_msg) 24who:aat($su:ps(this.use_start_msg, who, this)); 25endif 26else 27if (this.use_on_start_msg) 28who:aat($su:ps(this.use_on_start_msg, who, this, on, on)); 29endif 30endif 31return {this.speed, this:use_start(@args)}; 32else 33return E_INVARG; 34endif 35endif 36else 37return E_INVARG; 38endif
do_use_finish
Referenced by
none
Source
1who = args[1]; 2on = args[2]; 3if (is_a(this, #627) && this.charges) 4r = this:use_finish(@args); 5this.charges = this.charges - 1; 6if (this.charges < 1) 7if (this.recycle_when_empty && this:junk_ok()) 8fork (0) 9if (!(who.fighting || (is_a(on, $creature) && on.fighting))) 10who:aat($su:ps(this.throwaway_msg, who, this)); 11endif 12if (valid(this.empty_form)) 13empty = $rpg:spawn(this.empty_form); 14empty:moveto(this:room()); 15endif 16$rpg:junk(this); 17endfork 18endif 19endif 20return r; 21endif
use_start
Referenced by
- #335:do_use_start line 31:
this:use_start
Source
1":use_start(OBJ who, OBJ on)"; 2"Do what has to be done when 'who' uses this on 'on'."; 3"This is what children of #627 should override."; 4args[1].location:broadcast_event(1, this.use_action, args[1], {this, args[2]}); 5return 1;
use_finish
Referenced by
- #335:do_use_finish line 4:
this:use_finish
Source
1":use_finish(OBJ who, OBJ on)"; 2"Do stuff at the end of using."; 3"This is what children of #627 should override."; 4who = args[1]; 5on = args[2]; 6if (!(who.fighting || on.fighting)) 7if (who == on) 8m = $su:ps(this.use_finish_msg, who, this, on); 9else 10m = $su:ps(this.use_on_finish_msg, who, this, on, on); 11endif 12who:aat(m); 13endif 14who.location:broadcast_event(0, this.use_action, who, {this, on}); 15return 1;
description
Referenced by
none
Source
1d = pass(@args); 2ap = strsub(this.charges_msg, "%tmax", $su:english_number(this.charges_max)); 3ap = strsub(ap, "%t", $su:english_number(this.charges)); 4if (this.charges == 1) 5ap = strsub(ap, "charges", "charge"); 6endif 7if (typeof(d) == STR) 8return (d + " ") + ap; 9else 10d[$] = (d[$] + " ") + ap; 11return d; 12endif
can_use_on
Referenced by
- #335:use line 31:
this:can_use_on - #335:do_use_start line 3:
this:can_use_on
Source
1":can_use_on(OBJ who)"; 2return 1;
can_glob
Referenced by
none
Source
1if (this.charges != parent(this).charges) 2return 0; 3endif 4return pass(@args);
match_target
Referenced by
- #335:use line 3:
this:match_target
Source
1target = $mu:match(args[1], player.location:occupants($living)); 2return target;
spend_charge
Referenced by
none
Source
1if (!this.charges) 2return E_INVARG; 3endif 4this.charges = this.charges - 1; 5if (this.charges < 1) 6this.charges = 0; 7if (this.recycle_when_empty) 8$rpg:junk(this); 9endif 10endif