generic usable device with charges #335

Parent #5Owner #361Flags read, fertileSource hellcore/hellcore.db

Aliases: generic usable device with charges

10 verbs · 49 properties · 1 children

Verbs

VerbSpecFlagsDefinerLines
usethis any anyrxd#33535
do_use_startthis none thisrxd#33538
do_use_finishthis none thisrxd#33521
use_startthis none thisrxd#3355
use_finishthis none thisrxd#33515
descriptionthis none thisrxd#33512
can_use_onthis none thisrxd#3352
can_globthis none thisrxd#3354
match_targetthis none thisrxd#3352
spend_chargethis none thisrxd#33510

Properties

PropertyDefinerFlagsOwnerValue
self_only#335rc#3611
recycle_when_empty#335rc#3611
charges#335rc#3611
use_start_msg#335rc#361"%N preps a %t for use."
use_on_start_msg#335rc#361"%N preps a %t for use on %dd."
speed#335rc#3611.0
charges_msg#335rc#361"It's got %t charges left."
throwaway_msg#335rc#361"%N tosses away %p empty %t."
use_finish_msg#335rc#361"%N injects %dt into %p arm."
use_on_finish_msg#335rc#361"%N injects %dt into %d's arm."
use_action#335rc#361#626
charges_max#335rc#3611
empty_msg#335rc#361"%DT is empty."
in_use#335rc#3610
hold_to_use#335rc#3611
self_allowed#335rc#3611
must_allow#335rc#361"medical"
empty_form#335rc#361#-1
hurts_target#335rc#3610
handed#5rc#361<clear>
wield_msg#5rc#361<clear>
unwield_msg#5rc#361<clear>
size#5rc#361<clear>
look_place_msg#5rc#361<clear>
value#5rc#361<clear>
get_msg#5rc#361<clear>
drop_msg#5rc#361<clear>
get_fail_msg#5rc#361<clear>
junk_ok#5rc#361<clear>
floats#5rc#361<clear>
long_name_msg#5rc#361<clear>
article#5rc#361<clear>
setup_list#5rc#361<clear>
health#5rc#361<clear>
health_max#5rc#361<clear>
min_skill#5rc#361<clear>
skill#5rc#361<clear>
recipe_for#5rc#361<clear>
carried_msg#5rc#361<clear>
aliases#1rc#361{"generic usable device with charges"}
description#1rc#361<clear>
object_size#1r#29{8222, 1298433815}
hidden_verbs#1rc#361<clear>
phelp_msg#1rc#361<clear>
weight#1rc#361<clear>
owner_verbs#1rc#361<clear>
plural_name#1rc#361<clear>
client_image#1rc#361<clear>
listening#1rc#361<clear>

Ancestry

Ancestors (nearest first): #5 generic thing#1 root

Children: #128 generic lighter

Call graph

calls n335_0 #335:use n335_8 #335:match_target n335_0->n335_8 n107_43 #107:tell n335_0->n107_43 n5_9 #5:iname n335_0->n5_9 n1_39 #1:dnamec n335_0->n1_39 n335_6 #335:can_use_on n335_0->n335_6 n92_2 #92:queue_action n335_0->n92_2 n44_0 #44:match n335_8->n44_0 n335_1 #335:do_use_start n335_1->n5_9 n335_1->n335_6 n1_31 #1:dname n335_1->n1_31 n20_34 #20:pronoun_sub n335_1->n20_34 n335_3 #335:use_start n335_1->n335_3 n335_2 #335:do_use_finish n335_2->n20_34 n335_4 #335:use_finish n335_2->n335_4 n1_58 #1:junk_ok n335_2->n1_58 n103_1 #103:spawn n335_2->n103_1 n1_46 #1:room n335_2->n1_46 n103_2 #103:junk n335_2->n103_2 n335_4->n20_34 n335_5 #335:description n5_4 #5:description n335_5->n5_4 n20_27 #20:english_number n335_5->n20_27 n335_7 #335:can_glob n5_21 #5:can_glob n335_7->n5_21 n335_9 #335:spend_charge n335_9->n103_2

Source

use

Spec this any anyFlags rxdOwner #361Definer #335

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

Spec this none thisFlags rxdOwner #361Definer #335

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

Spec this none thisFlags rxdOwner #361Definer #335

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

Spec this none thisFlags rxdOwner #361Definer #335

Referenced by

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

Spec this none thisFlags rxdOwner #361Definer #335

Referenced by

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

Spec this none thisFlags rxdOwner #361Definer #335

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

Spec this none thisFlags rxdOwner #361Definer #335

Referenced by

Source

1":can_use_on(OBJ who)";
2return 1;

can_glob

Spec this none thisFlags rxdOwner #361Definer #335

Referenced by

none

Source

1if (this.charges != parent(this).charges)
2return 0;
3endif
4return pass(@args);

match_target

Spec this none thisFlags rxdOwner #361Definer #335

Referenced by

Source

1target = $mu:match(args[1], player.location:occupants($living));
2return target;

spend_charge

Spec this none thisFlags rxdOwner #361Definer #335

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