Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @create $action named drop:drop
- ;;#270.("aliases") = {"drop"}
- ;;#270.("object_size") = {0, 0}
- @verb #270:"_start" this none this
- @program #270:_start
- "$actions.drop:_start(OBJ who, LIST callback) => ";
- " This is the entry point for a queued drop action. The callback args ";
- " are as follows: ";
- " { LIST what, OBJ container, LIST dropped } ";
- " -- what is the list of things we'd eventually like to drop or put ";
- " -- container is the container we'd like to drop or put the object in ";
- " -- dropped is the list of things we've already dropped in this session";
- who = args[1];
- callback = args[2];
- "Remove any invalid drops.";
- what = $lu:list_is_a((typeof(callback[1]) == LIST) ? callback[1] | {callback[1]}, #1);
- container = (length(callback) > 1) ? callback[2] | #-1;
- dropped = (length(callback) > 2) ? callback[3] | {};
- first_drop = dropped ? 0 | 1;
- total_weight = 0;
- dropping = {};
- for item in (what)
- "Here we exclude anything the container or room won't accept, as well ";
- " as wristpads, which people don't want to lose ";
- if ((!is_a(item, $wristpad)) && (item.location in {who, who.location}))
- if (container:acceptable(item))
- dropping = setadd(dropping, item);
- elseif (is_a(item, $thing))
- who:tell(item:dnamec(), " won't fit in ", container:dname(), ".");
- endif
- endif
- endfor
- if (!dropping)
- "If they can drop anything in the list, tell them so and exit with ";
- "E_INVARG, which will halt the execution of this action altogether. ";
- "Note that 'what' may be empty, in case whatever was queued was recycled ";
- "before we got here. ";
- if (what)
- if ($api.container:is_on(container))
- who:tell("You can't seem to get ", what[1]:dname(), " into ", container:dname(), ".");
- else
- who:tell("You can't drop ", what[1]:dname(), " here.");
- endif
- endif
- return E_INVARG;
- endif
- if (valid(container) && (container.location == who))
- pronoun = who.pp;
- else
- pronoun = "the";
- endif
- "If this is the first item we're dropping, we need to print messages to ";
- " the room to let people know what's happening. From there on out ";
- " we will only print a message periodically, or when they're finished. ";
- if (first_drop)
- names = $su:message_db(dropping, "iname");
- namestrs = {};
- for x in (names)
- if (len = length(x[1]) > 1)
- namestrs = setadd(namestrs, x[1][1]:pname(len));
- else
- namestrs = setadd(namestrs, x[2]);
- endif
- endfor
- if (length(namestrs) > 1)
- things = "things";
- else
- things = namestrs[1];
- endif
- if (length(dropping) > 3)
- if ($api.container:is_on(container))
- who:aat(((((((who:dnamec() + " starts putting ") + things) + " in ") + pronoun) + " ") + container:name()) + ".");
- else
- who:aat(((who:dnamec() + " starts dropping ") + things) + ".");
- endif
- elseif (length(dropping) > 1)
- if (is_a(container, $container))
- who:aat(((((((who:dnamec() + " starts putting ") + $su:english_list(namestrs)) + " into ") + pronoun) + " ") + container:name()) + ".");
- else
- who:aat(((who:dnamec() + " starts dropping ") + $su:english_list(namestrs)) + ".");
- endif
- endif
- endif
- "Note that we are passing a possibly revised copy of the callback args to ";
- ":_finish, so that it need not reprocess anything. ";
- who.location:broadcast_event(1, $actions.put, who, {dropping[1], container});
- return {this:duration(), {dropping, container, dropped}};
- .
- @verb #270:"_finish" this none this
- @program #270:_finish
- "$actions.drop:_finish(OBJ who, LIST callback, LIST from_start) => ";
- " This is the second phase of a get action, in which the player actually ";
- " finished dropping the object (or putting it in a container). ";
- " The callback args look like this: ";
- " { LIST what, OBJ container, LIST pick } ";
- " -- what is the list of objects we wanted to pick up ";
- " -- container is the container we want to put something in (or the room)";
- " -- dropped is the list of objects we've already dropped in this session";
- "Since this is the finish phase, we basically ignore the callback args in ";
- " favor of the args we were passed from the :_start phase. The from_start ";
- " list looks just like the callback args, but has already been pruned of ";
- " objects we can't work with. ";
- who = args[1];
- callback = args[2];
- from_start = args[3];
- what = callback[1];
- dropping = $lu:remove_if_not($rpg, "valid", from_start[1]);
- dropped = $lu:remove_if_not($rpg, "valid", (length(callback) > 2) ? callback[3] | {});
- container = callback[2];
- if (dropping)
- target = dropping[1];
- dropping = listdelete(dropping, 1);
- put = this:put(who, target, container);
- if (typeof(put == ERR))
- return E_NONE;
- endif
- dropped = setadd(dropped, target);
- finalnames = $su:message_db(dropped, "iname");
- finalnamestrs = {};
- for x in (finalnames)
- finalnamestrs = setadd(finalnamestrs, ((len = length(x[1])) > 1) ? x[1][1]:pname() | x[2]);
- endfor
- if (length(finalnamestrs) > 1)
- things = "stuff";
- else
- things = finalnamestrs[1];
- endif
- elseif (dropped)
- target = dropped[$];
- else
- target = #-1;
- endif
- if (valid(container) && (container.location == who))
- pronoun = who.pp;
- else
- pronoun = "the";
- endif
- if (dropping)
- if (!(length(dropping) % 5))
- if (length(finalnamestrs) > 1)
- if ($api.container:is_on(container))
- who.location:announce_all_but({who}, ((((((((("You notice " + who:dnamec()) + " stowing ") + target:iname()) + " as ") + who.ps) + " continues putting things into ") + pronoun) + " ") + container:name()) + ".");
- else
- who.location:announce_all_but({who}, ((((("You notice " + who:dnamec()) + " dropping ") + target:iname()) + " as ") + who.ps) + " continues to unload.");
- endif
- else
- if ($api.container:is_on(container))
- who.location:announce_all_but({who}, ((((((who:dnamec() + " continues putting ") + dropping[1]:pname()) + " into ") + pronoun) + " ") + container:name()) + ".");
- else
- who.location:announce_all_but({who}, ((who:dnamec() + " continues dropping ") + dropping[1]:pname()) + ".");
- endif
- endif
- endif
- who:queue_action(this, {dropping, container, dropped}, 0, (this.name + " ") + dropping[1]:name());
- else
- if (length(dropped) > 3)
- if ($api.container:is_on(container))
- who:aat(((((((who:dnamec() + " stops putting ") + things) + " in ") + pronoun) + " ") + container:name()) + ".");
- else
- who:aat(((who:dnamec() + " finishes dropping ") + things) + ".");
- endif
- elseif (length(dropped) > 1)
- if ($api.container:is_on(container))
- who:aat(((((((who:dnamec() + " finishes putting ") + $su:english_list(finalnamestrs)) + " in ") + pronoun) + " ") + container:name()) + ".");
- else
- who:aat(((who:dnamec() + " finishes dropping ") + $su:english_list(finalnamestrs)) + ".");
- endif
- else
- if ($api.container:is_on(container))
- if (!(m = `container.put_msg ! E_PROPNF => 0'))
- m = ((("%DN puts %id into " + pronoun) + " ") + container.name) + ".";
- endif
- who:aat($su:ps(m, who, container, dropped[1], target, container));
- elseif (valid(target))
- if (m = `who.drop_msg ? who.drop_msg | (target.drop_msg ? target.drop_msg | who.location.drop_msg) ! ANY => 0')
- who:aat($su:ps(m, who, target, target));
- endif
- endif
- endif
- endif
- .
- @verb #270:"put" this none this
- @program #270:put
- who = args[1];
- what = args[2];
- container = (length(args) > 2) ? args[3] | who.location;
- if ($api.container:is_on(container) && (m = container:cant_put_into(what, who)))
- who:tell("You can't get ", what:dname(), " into ", container:dname(), " because ", m, ".");
- return E_INVARG;
- endif
- who:_put(what, container);
- .
- @verb #270:"doing_msg" this none this
- @program #270:doing_msg
- who = args[1];
- if (args[2])
- callback = args[2];
- what = callback[1];
- container = (length(callback) > 1) ? callback[2] | #-1;
- if (length(what) > 1)
- if ($api.container:is_on(container))
- return (("putting some things into " + who.pp) + " ") + container:name();
- else
- return "dropping some things";
- endif
- else
- if ($api.container:is_on(container))
- return (((("putting " + what[1]:iname()) + " into ") + who.pp) + " ") + container:name();
- else
- return "dropping " + what[1]:iname();
- endif
- endif
- else
- return "dropping";
- endif
- .
- @verb #270:"_abort" this none this
- @program #270:_abort
- who = args[1];
- callback = args[2];
- what = callback[1];
- container = callback[2];
- dropped = callback[3];
- if (dropped)
- names = $su:message_db(dropped, "iname");
- namestrs = {};
- for x in (names)
- if (len = length(x[1]) > 1)
- namestrs = setadd(namestrs, x[1][1]:pname(len));
- else
- namestrs = setadd(namestrs, x[2]);
- endif
- endfor
- if (length(namestrs) > 1)
- things = "stuff";
- else
- things = namestrs[1];
- endif
- if (length(dropped) > 3)
- if ($api.container:is_on(container))
- who:aat(((((((who:dnamec() + " stops putting ") + things) + " in ") + who.pp) + " ") + container:name()) + ".");
- else
- who:aat(((who:dnamec() + " stops dropping ") + things) + ".");
- endif
- elseif (length(dropped) > 1)
- if ($api.container:is_on(container))
- who:aat(((((((who:dnamec() + " managed to put ") + $su:english_list(namestrs)) + " into ") + who.pp) + " ") + container:name()) + ".");
- else
- who:aat(((who:dnamec() + " managed to drop ") + $su:english_list(namestrs)) + ".");
- endif
- endif
- endif
- .
- "***finished***
Add Comment
Please, Sign In to add comment