get #184

Parent #93Owner #361Flags readSource hellcore/hellcore.db

Aliases: get

6 verbs · 19 properties · 0 children

Verbs

VerbSpecFlagsDefinerLines
_startthis none thisrxd#18484
_finishthis none thisrxd#184109
doing_msgthis none thisrxd#18421
get_from_containerthis none thisrxd#18410
_abortthis none thisrxd#18430
is_gettingthis none thisrxd#18413

Properties

PropertyDefinerFlagsOwnerValue
help_msg#93rc#361<clear>
duration#93rc#361<clear>
preemptible#93rc#361<clear>
unstoppable#93rc#361<clear>
dodge_mod#93rc#361<clear>
doing_msg#93rc#361<clear>
doing_to_msg#93rc#361<clear>
oabort_msg#93rc#361<clear>
can_parry#93rc#361<clear>
aliases#1rc#361{"get"}
description#1rc#361<clear>
object_size#1r#29{0, 0}
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): #93 Generic Action#1 root

Children: none

Call graph

calls n184_0 #184:_start n48_8 #48:suspend_if_needed n184_0->n48_8 n20_83 #20:message_db n184_0->n20_83 n20_6 #20:english_list n184_0->n20_6 n93_3 #93:duration n184_0->n93_3 n184_1 #184:_finish n184_1->n20_83 n184_1->n20_6 n47_60 #47:remove_if n184_1->n47_60 n45_2 #45:has_verb n184_1->n45_2 n20_34 #20:pronoun_sub n184_1->n20_34 n184_4 #184:_abort n184_4->n20_83

Source

_start

Spec this none thisFlags rxdOwner #361Definer #184

Referenced by

none

Source

1"$actions.get:_start(OBJ who, LIST callback) =>";
2"  Causes who to queue try to begin picking something, or perhaps lots";
3"  of things, up, or to remove them from whatever container they happen";
4"  to be in.";
5"The callback args are as follows:";
6"  { LIST what [, OBJ container [, LIST picked_up ]] }";
7"    what is simply a list of objects to try to get";
8"    container is the container that the objects are coming out of";
9"    picked_up is a list of objects we've already picked up in this";
10"      get 'session', meaning continuous successive get actions.";
11who = args[1];
12callback = args[2];
13what = callback[1];
14container = (length(callback) > 1) ? callback[2] | #-1;
15picked_up = (length(callback) > 2) ? callback[3] | {};
16first_get = picked_up ? 0 | 1;
17total_weight = 0;
18"Quick sanity check on the args to make sure we've got a list";
19if (typeof(what) == OBJ)
20what = {what};
21endif
22"Now figure out from the list of potential targets we can get";
23"We prune the list of 'gettable' objects on each successive get,";
24"  since the they may no longer be around or otherwise indisposed";
25"  in the time that has passed since the last get finished.";
26picking_up = {};
27for item in (what)
28if (!(item.location in {who.location, container}))
29"";
30elseif (!(m = who:cant_take(item)))
31picking_up = listappend(picking_up, item);
32else
33who:tell("You can't get ", item:dname(), " because ", m, ".");
34endif
35$cu:sin();
36endfor
37if (!picking_up)
38return E_INVARG;
39endif
40"If this is the first get action in a get session then we need";
41"  to print a message to the room about what's happening.  There";
42"  is quite a lot of special casing here in the name of better";
43"  readability.";
44if (valid(container) && (container.location == who))
45pronoun = who.pp;
46else
47pronoun = "the";
48endif
49if (first_get)
50"Map the unique inames to the objects we're picking up";
51names = $su:message_db(picking_up, "iname");
52namestrs = {};
53for x in (names)
54if (len = length(x[1]) > 1)
55namestrs = listappend(namestrs, x[1][1]:pname(len));
56else
57namestrs = listappend(namestrs, x[2]);
58endif
59endfor
60if (length(namestrs) > 1)
61things = "things";
62else
63things = picking_up[1]:pname();
64endif
65if (length(picking_up) > 3)
66if ($api.container:is_on(container))
67who:aat(((((((who:dnamec() + " starts pulling ") + things) + " out of ") + pronoun) + " ") + container:name()) + ".");
68else
69who:aat(((who:dnamec() + " starts picking ") + things) + " up.");
70endif
71elseif (length(picking_up) > 1)
72"We have the list of inames, why not use it if it's not too spammy?";
73if ($api.container:is_on(container))
74who:aat(((((((who:dnamec() + " starts getting ") + $su:english_list(namestrs)) + " from ") + pronoun) + " ") + container:name()) + ".");
75else
76who:aat(((who:dnamec() + " starts picking up ") + $su:english_list(namestrs)) + ".");
77endif
78endif
79endif
80"Note that we're passing a possibly revised version of the callback";
81"  args for the :_finish verb to use.  This saves some pruning time";
82"  on the back end and also keeps messages from being printed twice.";
83who.location:broadcast_event(1, $actions.get, who, {picking_up[1], container});
84return {this:duration(), {picking_up, container, picked_up}};

_finish

Spec this none thisFlags rxdOwner #361Definer #184

Referenced by

none

Source

1"$actions.get:_finish(OBJ who, LIST callback, LIST from_start) =>";
2"  This verb is the second phase of the get action.  It actually";
3"  completes the transaction, moving the object in question into";
4"  the person doing the getting.";
5who = args[1];
6callback = args[2];
7what = callback[1];
8"We are ignoring the callback args in favor of the data we get from";
9"  the :_start verb, which may have already pruned a bunch of crap";
10"  that we no longer need to deal with.  This comes to us as args[3].";
11from_start = args[3];
12picking_up = $lu:remove_if_not($rpg, "valid", from_start[1]);
13picked_up = $lu:remove_if_not($rpg, "valid", from_start[3]);
14container = from_start[2];
15for x in (picking_up)
16m = who:cant_take(x);
17if (typeof(m == STR))
18picking_up = setremove(picking_up, x);
19endif
20endfor
21if (picking_up)
22target = picking_up[1];
23picking_up = listdelete(picking_up, 1);
24if (who:_get(target, container))
25picked_up = listappend(picked_up, target);
26else
27target = #-1;
28endif
29elseif (picked_up)
30target = picked_up[$];
31else
32target = #-1;
33endif
34"All of this calculation around the inames of the objects we're dealing";
35"  with is just to figure out if this is a 'homogenous' get, meaning";
36"  we are picking up multiple objects of a single type.";
37"We figure out whether this is the case by mapping the unique inames to";
38"  the objects in question, then seeing how many unique names we actually";
39"  have.  If it's more than one, then there must have been more than one";
40"  object type.";
41names = $su:message_db(picked_up, "iname");
42namestrs = {};
43if (valid(container) && (container.location == who))
44pronoun = who.pp;
45else
46pronoun = "the";
47endif
48for x in (names)
49namestrs = listappend(namestrs, ((len = length(x[1])) > 1) ? x[1][1]:pname() | x[2]);
50endfor
51"If they are picking up multiple kinds of things, we just refer to it";
52"  collectively as 'stuff' or 'things'.";
53if ((length(namestrs) > 1) || (!namestrs))
54things = "stuff";
55else
56things = namestrs[1];
57endif
58"And now the actual announcement of the appropriate messages.  There are";
59"  two cases when we actually want to announce something:";
60"  -- When we are finished picking up everything we could";
61"  -- Every five get actions, to let people know it's still happening";
62"First we handle the case of printing a message every five gets. Note";
63"  that if we have nothing left to pick up this won't get printed, and";
64"  will be caught by the other case instead.";
65if (picking_up && valid(target))
66if (!(length(picking_up) % 5))
67if (length(names) > 1)
68if ($ou:has_verb(container, "get_from") && $ou:has_verb(container, "cant_get_from"))
69who.location:announce_all_but({who}, ((((((((("You notice " + who:dnamec()) + " grabbing ") + target:iname()) + " as ") + who.ps) + " continues taking things out of ") + pronoun) + " ") + container:name()) + ".");
70else
71who.location:announce_all_but({who}, ((((("You notice " + who:dnamec()) + " grabbing ") + target:iname()) + " as ") + who.ps) + " continues picking things up.");
72endif
73else
74if ($ou:has_verb(container, "get_from") && $ou:has_verb(container, "cant_get_from"))
75who.location:announce_all_but({who}, ((((((who:dnamec() + " continues taking ") + things) + " out of ") + pronoun) + " ") + container:name()) + ".");
76else
77who.location:announce_all_but({who}, ((who:dnamec() + " continues picking up ") + things) + ".");
78endif
79endif
80endif
81who:queue_action(this, {picking_up, container, picked_up}, 0, (this.name + " ") + picking_up[1]:name());
82else
83"If we made it here it's because we have nothing left to pick up.  In";
84"  this case we print messages to the room to let everyone know that";
85"  we're done picking things up.";
86if (length(picked_up) > 3)
87if ($ou:has_verb(container, "get_from") && $ou:has_verb(container, "cant_get_from"))
88who:aat(((((((who:dnamec() + " stops pulling ") + things) + " out of ") + pronoun) + " ") + container:name()) + ".");
89else
90who:aat(((who:dnamec() + " seems to have finished picking up ") + things) + ".");
91endif
92elseif (length(picked_up) > 1)
93if ($ou:has_verb(container, "get_from") && $ou:has_verb(container, "cant_get_from"))
94who:aat(((((((who:dnamec() + " finishes getting ") + $su:english_list(namestrs)) + " from ") + pronoun) + " ") + container:name()) + ".");
95else
96who:aat(((who:dnamec() + " finishes picking up ") + $su:english_list(namestrs)) + ".");
97endif
98elseif (valid(target))
99if ($ou:has_verb(container, "get_from") && $ou:has_verb(container, "cant_get_from"))
100if (!(m = container.get_from_msg))
101m = ("%DN gets %id from " + pronoun) + " %t.";
102endif
103who:aat($su:ps(m, who, container, who.location, target, container));
104elseif (target.location == who)
105m = who.get_msg ? who.get_msg | (`tm = target:get_msg() ! ANY => 0' ? tm | who.location.get_msg);
106who:aat($su:ps(m, who, target, target, who));
107endif
108endif
109endif

doing_msg

Spec this none thisFlags rxdOwner #361Definer #184

Referenced by

none

Source

1who = args[1];
2if (args[2])
3callback = args[2];
4what = callback[1];
5container = (length(callback) > 1) ? callback[2] | #-1;
6if (typeof(what) == LIST)
7if ($api.container:is_on(container))
8return "getting some things from " + container:iname();
9else
10return "picking some things up";
11endif
12else
13if ($api.container:is_on(container))
14return (("getting " + what:iname()) + " from ") + container:iname();
15else
16return "picking up " + what:iname();
17endif
18endif
19else
20return "getting";
21endif

get_from_container

Spec this none thisFlags rxdOwner #361Definer #184

Referenced by

none

Source

1who = args[1];
2what = args[2];
3container = args[3];
4if (typeof(what) == LIST)
5who:_get_many_from_container(what);
6else
7if ((container.location == who.location) || (container.location == who))
8who:_get_from_container(what, container);
9endif
10endif

_abort

Spec this none thisFlags rxdOwner #361Definer #184

Referenced by

none

Source

1"$actions.get:_abort(OBJ who, LIST callback, LIST from_start) =>";
2"  This verb handles the case of players aborting their get action before";
3"  it is actually completed.  All we need to do is print the appropriate";
4"  messages.";
5who = args[1];
6callback = args[2];
7what = callback[1];
8container = (length(callback) > 1) ? callback[2] | #-1;
9picked_up = (length(callback) > 2) ? callback[3] | {};
10if (picked_up)
11names = $su:message_db(picked_up, "iname");
12namestrs = {};
13for x in (names)
14if (len = length(x[1]) > 1)
15namestrs = listappend(namestrs, x[1][1]:pname(len));
16else
17namestrs = listappend(namestrs, x[2]);
18endif
19endfor
20if (length(namestrs) > 1)
21things = "stuff";
22else
23things = namestrs[1];
24endif
25if ($api.container:is_on(container))
26who:aat(((((((who:dnamec() + " stops getting ") + things) + " from ") + who.pp) + " ") + container:name()) + ".");
27else
28who:aat(((who:dnamec() + " stops picking ") + things) + " up.");
29endif
30endif

is_getting

Spec this none thisFlags rxdOwner #361Definer #184

Referenced by

none

Source

1who = args[1];
2what = args[2];
3for x in ({who.executing, @who.queue})
4if (x && (x[1] == $actions.get))
5callback = x[2];
6picking_up = callback[1];
7container = callback[2];
8picked_up = callback[3];
9if (what in picking_up)
10return 1;
11endif
12endif
13endfor