Guest User

Untitled

a guest
Jan 11th, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.88 KB | None | 0 0
  1. @create $action named drop:drop
  2. ;;#270.("aliases") = {"drop"}
  3. ;;#270.("object_size") = {0, 0}
  4.  
  5. @verb #270:"_start" this none this
  6. @program #270:_start
  7. "$actions.drop:_start(OBJ who, LIST callback) => ";
  8. " This is the entry point for a queued drop action. The callback args ";
  9. " are as follows: ";
  10. " { LIST what, OBJ container, LIST dropped } ";
  11. " -- what is the list of things we'd eventually like to drop or put ";
  12. " -- container is the container we'd like to drop or put the object in ";
  13. " -- dropped is the list of things we've already dropped in this session";
  14. who = args[1];
  15. callback = args[2];
  16. "Remove any invalid drops.";
  17. what = $lu:list_is_a((typeof(callback[1]) == LIST) ? callback[1] | {callback[1]}, #1);
  18. container = (length(callback) > 1) ? callback[2] | #-1;
  19. dropped = (length(callback) > 2) ? callback[3] | {};
  20. first_drop = dropped ? 0 | 1;
  21. total_weight = 0;
  22. dropping = {};
  23. for item in (what)
  24. "Here we exclude anything the container or room won't accept, as well ";
  25. " as wristpads, which people don't want to lose ";
  26. if ((!is_a(item, $wristpad)) && (item.location in {who, who.location}))
  27. if (container:acceptable(item))
  28. dropping = setadd(dropping, item);
  29. elseif (is_a(item, $thing))
  30. who:tell(item:dnamec(), " won't fit in ", container:dname(), ".");
  31. endif
  32. endif
  33. endfor
  34. if (!dropping)
  35. "If they can drop anything in the list, tell them so and exit with ";
  36. "E_INVARG, which will halt the execution of this action altogether. ";
  37. "Note that 'what' may be empty, in case whatever was queued was recycled ";
  38. "before we got here. ";
  39. if (what)
  40. if ($api.container:is_on(container))
  41. who:tell("You can't seem to get ", what[1]:dname(), " into ", container:dname(), ".");
  42. else
  43. who:tell("You can't drop ", what[1]:dname(), " here.");
  44. endif
  45. endif
  46. return E_INVARG;
  47. endif
  48. if (valid(container) && (container.location == who))
  49. pronoun = who.pp;
  50. else
  51. pronoun = "the";
  52. endif
  53. "If this is the first item we're dropping, we need to print messages to ";
  54. " the room to let people know what's happening. From there on out ";
  55. " we will only print a message periodically, or when they're finished. ";
  56. if (first_drop)
  57. names = $su:message_db(dropping, "iname");
  58. namestrs = {};
  59. for x in (names)
  60. if (len = length(x[1]) > 1)
  61. namestrs = setadd(namestrs, x[1][1]:pname(len));
  62. else
  63. namestrs = setadd(namestrs, x[2]);
  64. endif
  65. endfor
  66. if (length(namestrs) > 1)
  67. things = "things";
  68. else
  69. things = namestrs[1];
  70. endif
  71. if (length(dropping) > 3)
  72. if ($api.container:is_on(container))
  73. who:aat(((((((who:dnamec() + " starts putting ") + things) + " in ") + pronoun) + " ") + container:name()) + ".");
  74. else
  75. who:aat(((who:dnamec() + " starts dropping ") + things) + ".");
  76. endif
  77. elseif (length(dropping) > 1)
  78. if (is_a(container, $container))
  79. who:aat(((((((who:dnamec() + " starts putting ") + $su:english_list(namestrs)) + " into ") + pronoun) + " ") + container:name()) + ".");
  80. else
  81. who:aat(((who:dnamec() + " starts dropping ") + $su:english_list(namestrs)) + ".");
  82. endif
  83. endif
  84. endif
  85. "Note that we are passing a possibly revised copy of the callback args to ";
  86. ":_finish, so that it need not reprocess anything. ";
  87. who.location:broadcast_event(1, $actions.put, who, {dropping[1], container});
  88. return {this:duration(), {dropping, container, dropped}};
  89. .
  90.  
  91. @verb #270:"_finish" this none this
  92. @program #270:_finish
  93. "$actions.drop:_finish(OBJ who, LIST callback, LIST from_start) => ";
  94. " This is the second phase of a get action, in which the player actually ";
  95. " finished dropping the object (or putting it in a container). ";
  96. " The callback args look like this: ";
  97. " { LIST what, OBJ container, LIST pick } ";
  98. " -- what is the list of objects we wanted to pick up ";
  99. " -- container is the container we want to put something in (or the room)";
  100. " -- dropped is the list of objects we've already dropped in this session";
  101. "Since this is the finish phase, we basically ignore the callback args in ";
  102. " favor of the args we were passed from the :_start phase. The from_start ";
  103. " list looks just like the callback args, but has already been pruned of ";
  104. " objects we can't work with. ";
  105. who = args[1];
  106. callback = args[2];
  107. from_start = args[3];
  108. what = callback[1];
  109. dropping = $lu:remove_if_not($rpg, "valid", from_start[1]);
  110. dropped = $lu:remove_if_not($rpg, "valid", (length(callback) > 2) ? callback[3] | {});
  111. container = callback[2];
  112. if (dropping)
  113. target = dropping[1];
  114. dropping = listdelete(dropping, 1);
  115. put = this:put(who, target, container);
  116. if (typeof(put == ERR))
  117. return E_NONE;
  118. endif
  119. dropped = setadd(dropped, target);
  120. finalnames = $su:message_db(dropped, "iname");
  121. finalnamestrs = {};
  122. for x in (finalnames)
  123. finalnamestrs = setadd(finalnamestrs, ((len = length(x[1])) > 1) ? x[1][1]:pname() | x[2]);
  124. endfor
  125. if (length(finalnamestrs) > 1)
  126. things = "stuff";
  127. else
  128. things = finalnamestrs[1];
  129. endif
  130. elseif (dropped)
  131. target = dropped[$];
  132. else
  133. target = #-1;
  134. endif
  135. if (valid(container) && (container.location == who))
  136. pronoun = who.pp;
  137. else
  138. pronoun = "the";
  139. endif
  140. if (dropping)
  141. if (!(length(dropping) % 5))
  142. if (length(finalnamestrs) > 1)
  143. if ($api.container:is_on(container))
  144. who.location:announce_all_but({who}, ((((((((("You notice " + who:dnamec()) + " stowing ") + target:iname()) + " as ") + who.ps) + " continues putting things into ") + pronoun) + " ") + container:name()) + ".");
  145. else
  146. who.location:announce_all_but({who}, ((((("You notice " + who:dnamec()) + " dropping ") + target:iname()) + " as ") + who.ps) + " continues to unload.");
  147. endif
  148. else
  149. if ($api.container:is_on(container))
  150. who.location:announce_all_but({who}, ((((((who:dnamec() + " continues putting ") + dropping[1]:pname()) + " into ") + pronoun) + " ") + container:name()) + ".");
  151. else
  152. who.location:announce_all_but({who}, ((who:dnamec() + " continues dropping ") + dropping[1]:pname()) + ".");
  153. endif
  154. endif
  155. endif
  156. who:queue_action(this, {dropping, container, dropped}, 0, (this.name + " ") + dropping[1]:name());
  157. else
  158. if (length(dropped) > 3)
  159. if ($api.container:is_on(container))
  160. who:aat(((((((who:dnamec() + " stops putting ") + things) + " in ") + pronoun) + " ") + container:name()) + ".");
  161. else
  162. who:aat(((who:dnamec() + " finishes dropping ") + things) + ".");
  163. endif
  164. elseif (length(dropped) > 1)
  165. if ($api.container:is_on(container))
  166. who:aat(((((((who:dnamec() + " finishes putting ") + $su:english_list(finalnamestrs)) + " in ") + pronoun) + " ") + container:name()) + ".");
  167. else
  168. who:aat(((who:dnamec() + " finishes dropping ") + $su:english_list(finalnamestrs)) + ".");
  169. endif
  170. else
  171. if ($api.container:is_on(container))
  172. if (!(m = `container.put_msg ! E_PROPNF => 0'))
  173. m = ((("%DN puts %id into " + pronoun) + " ") + container.name) + ".";
  174. endif
  175. who:aat($su:ps(m, who, container, dropped[1], target, container));
  176. elseif (valid(target))
  177. if (m = `who.drop_msg ? who.drop_msg | (target.drop_msg ? target.drop_msg | who.location.drop_msg) ! ANY => 0')
  178. who:aat($su:ps(m, who, target, target));
  179. endif
  180. endif
  181. endif
  182. endif
  183. .
  184.  
  185. @verb #270:"put" this none this
  186. @program #270:put
  187. who = args[1];
  188. what = args[2];
  189. container = (length(args) > 2) ? args[3] | who.location;
  190. if ($api.container:is_on(container) && (m = container:cant_put_into(what, who)))
  191. who:tell("You can't get ", what:dname(), " into ", container:dname(), " because ", m, ".");
  192. return E_INVARG;
  193. endif
  194. who:_put(what, container);
  195. .
  196.  
  197. @verb #270:"doing_msg" this none this
  198. @program #270:doing_msg
  199. who = args[1];
  200. if (args[2])
  201. callback = args[2];
  202. what = callback[1];
  203. container = (length(callback) > 1) ? callback[2] | #-1;
  204. if (length(what) > 1)
  205. if ($api.container:is_on(container))
  206. return (("putting some things into " + who.pp) + " ") + container:name();
  207. else
  208. return "dropping some things";
  209. endif
  210. else
  211. if ($api.container:is_on(container))
  212. return (((("putting " + what[1]:iname()) + " into ") + who.pp) + " ") + container:name();
  213. else
  214. return "dropping " + what[1]:iname();
  215. endif
  216. endif
  217. else
  218. return "dropping";
  219. endif
  220. .
  221.  
  222. @verb #270:"_abort" this none this
  223. @program #270:_abort
  224. who = args[1];
  225. callback = args[2];
  226. what = callback[1];
  227. container = callback[2];
  228. dropped = callback[3];
  229. if (dropped)
  230. names = $su:message_db(dropped, "iname");
  231. namestrs = {};
  232. for x in (names)
  233. if (len = length(x[1]) > 1)
  234. namestrs = setadd(namestrs, x[1][1]:pname(len));
  235. else
  236. namestrs = setadd(namestrs, x[2]);
  237. endif
  238. endfor
  239. if (length(namestrs) > 1)
  240. things = "stuff";
  241. else
  242. things = namestrs[1];
  243. endif
  244. if (length(dropped) > 3)
  245. if ($api.container:is_on(container))
  246. who:aat(((((((who:dnamec() + " stops putting ") + things) + " in ") + who.pp) + " ") + container:name()) + ".");
  247. else
  248. who:aat(((who:dnamec() + " stops dropping ") + things) + ".");
  249. endif
  250. elseif (length(dropped) > 1)
  251. if ($api.container:is_on(container))
  252. who:aat(((((((who:dnamec() + " managed to put ") + $su:english_list(namestrs)) + " into ") + who.pp) + " ") + container:name()) + ".");
  253. else
  254. who:aat(((who:dnamec() + " managed to drop ") + $su:english_list(namestrs)) + ".");
  255. endif
  256. endif
  257. endif
  258. .
  259.  
  260. "***finished***
Add Comment
Please, Sign In to add comment