adventurer1.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. module.exports = class ZebedeeAdventurer1 {
  2. constructor() {
  3. this.id = 1;
  4. this.name = "an adventurer";
  5. this.description = "She is a human woman wearing mismatched leather armor and steel plate. Her hair is short and seems to have a leaf in it. She speaks loudly enough for everyone around to hear, and apparently only has good things to say about herself.";
  6. this.type = "mobile";
  7. this.roomId = 1;
  8. this.idleDelay = 30000;
  9. this.filename = "zebedee/adventurer1.js";
  10. this.lastIdle = 0;
  11. this.keywords = ["adventurer", "lady", "miss", "woman", "human"];
  12. this.items = [];
  13. this.commandQueue = [];
  14. this.memory = {};
  15. }
  16. mud_init(mobileName) {
  17. world.mud_addMobileToRoom("ZebedeeAdventurerGuild", this.id);
  18. this.mud_spawnThisMobile("PhandalinRoad6");
  19. }
  20. mud_spawnThisMobile(roomName) {
  21. var id = builder.mud_spawnMobile("ZebedeeAdventurer1").id;
  22. world.mud_addMobileToRoom(roomName, id);
  23. world.mud_addItemToMobile(id, builder.mud_spawnItem("WoodenSword").id);
  24. }
  25. mud_sendMessage(source, message) {
  26. message = message.replace(/\{.*?\}/g, "");
  27. var cleanMessage = message.trim();
  28. if(source == this) {
  29. return;
  30. }
  31. if(cleanMessage.indexOf("shout") != -1) {
  32. return;
  33. }
  34. if(libs.Conversation.basicDecency(source, cleanMessage, this)) {
  35. return;
  36. }
  37. if(this.commandQueue.length <= 0 && cleanMessage.indexOf("adventure") != -1 && cleanMessage.indexOf("lately") != -1 && !this.mud_checkMemory("storytelling", source.name)) {
  38. var sourceRefer = source.keywords[parseInt(Math.random() * source.keywords.length)];
  39. this.mud_addCommand(this, "smile");
  40. this.mud_addCommand(this, "say Ok, so... there I was, right?");
  41. this.mud_addCommand(this, "emote gestures with her hands.");
  42. this.mud_addCommand(this, "say And this HUGE group of goblins was right over here.");
  43. this.mud_addCommand(this, "emote gestures with her hands.");
  44. this.mud_addCommand(this, "say So we climbed up this cliff, see?");
  45. this.mud_addCommand(this, "emote gestures with her hands.");
  46. this.mud_addCommand(this, "say Then I screamed and leaped!");
  47. this.mud_addCommand(this, "say and those dirty gobboes screamed and shit their pants!");
  48. this.mud_addCommand(this, "laugh");
  49. this.mud_addCommand(this, "say then I stabbed one in the belly and");
  50. this.mud_addCommand(this, "emote lurches toward you with her sword drawn.");
  51. this.mud_addCommand(this, "say {red}spilled his guts all over the ground!{/red}");
  52. this.mud_addCommand(this, "laugh");
  53. this.mud_addCommand(this, "say How about you, " +sourceRefer +"? You got any good stories?");
  54. this.mud_addMemory("storytelling", source.name);
  55. return;
  56. }
  57. if(cleanMessage.indexOf("wipes some sweat from her brow") != -1 || cleanMessage.indexOf("wipes some sweat from his brow") != -1) {
  58. var sourceRefer = source.keywords[parseInt(Math.random() * source.keywords.length)];
  59. this.mud_addCommand(this, "say hey " + sourceRefer + ", it's hot in here, right?");
  60. this.mud_addCommand(this, "laugh " + sourceRefer);
  61. return;
  62. }
  63. if(cleanMessage.indexOf("strokes his beard and pulls out a chip of stone") != -1) {
  64. var sourceRefer = source.keywords[parseInt(Math.random() * source.keywords.length)];
  65. this.mud_addCommand(this, "say hey " + sourceRefer + ", you should hit the showers!");
  66. this.mud_addCommand(this, "laugh " + sourceRefer);
  67. return;
  68. }
  69. /*if(libs.Conversation.followsOrders(source, cleanMessage, this)) {
  70. return;
  71. }*/
  72. }
  73. mud_addMemory(section, newMemory) {
  74. if(!this.memory.hasOwnProperty(section)) {
  75. this.memory[section] = [];
  76. }
  77. if(!this.mud_checkMemory(section, newMemory)) {
  78. this.memory[section].push(newMemory);
  79. }
  80. }
  81. mud_checkMemory(section, memoryToCheck) {
  82. if(this.memory.hasOwnProperty(section)) {
  83. if(this.memory[section].indexOf(memoryToCheck) != -1) {
  84. return true;
  85. }
  86. }
  87. return false;
  88. }
  89. mud_addCommand(source, message) {
  90. this.commandQueue.push(message);
  91. }
  92. mud_reset(time) {
  93. var idleMessages = ["emote wipes some sweat from her brow.",
  94. "emote boasts loudly about some goblin she killed in a very {red}visceral{/red} way.",
  95. "emote shoves someone for standing too close to her.",
  96. "emote draws her gleaming sword and very obviously polishes it's perfectly clean blade."
  97. ];
  98. idleMessages = idleMessages.concat(libs.Conversation.getRoomExits(this));
  99. var randomIdle = idleMessages[parseInt(Math.random() * idleMessages.length)];
  100. this.mud_addCommand(this, randomIdle);
  101. this.memory = {};
  102. this.lastIdle = time + this.idleDelay;
  103. }
  104. mud_tick(time) {
  105. if(this.commandQueue.length <= 0 && this.roomId == "ZebedeeCormallenRoad4") {
  106. this.mud_addCommand(this, "emote stumbles out of the guild and looks around, confused.");
  107. this.mud_addCommand(this, "say Aaie, SHIT! You little");
  108. this.mud_addCommand(this, "south");
  109. return;
  110. }
  111. if(time >= this.lastIdle) {
  112. this.mud_reset(time);
  113. }
  114. if(this.commandQueue.length > 0 ) {
  115. world.mud_handleInput(this.roomId, this.id, this.commandQueue.shift().split(" "));
  116. this.lastIdle = time + this.idleDelay;
  117. }
  118. }
  119. mud_getName() {
  120. return "{mobile}" + this.name + "{/mobile}";
  121. }
  122. mud_getDescription() {
  123. return this.description;
  124. }
  125. mud_wearInSlot(itemId, slot) {
  126. if(this.itemSlots.hasOwnProperty(slot) && this.itemSlots[slot] != null) {
  127. return this.itemSlots[slot];
  128. }
  129. this.itemSlots[slot] = itemId;
  130. }
  131. mud_removeSlot(slot) {
  132. if(!this.itemSlots.hasOwnProperty(slot) || this.itemSlots[slot] == null) {
  133. return false;
  134. }
  135. this.itemSlots[slot] = null;
  136. }
  137. mud_addCurrency(amount) {
  138. this.account += amount;
  139. }
  140. mud_removeCurrency(amount) {
  141. this.account -= amount;
  142. this.account = Math.max(0, this.account);
  143. }
  144. };