sistergaraele.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. module.exports = class SisterGaraele {
  2. constructor() {
  3. this.id = 1;
  4. this.name = "Sister Garaele";
  5. this.description = "A zealous young elf who tends the shrine. She appears battered and {hint}bruised{/hint}.";
  6. this.type = "mobile";
  7. this.roomId = "PhandalinGaraeleHouse";
  8. this.idleDelay = 30000;
  9. this.filename = "phandalin/sistergaraele.js";
  10. this.lastIdle = 0;
  11. this.keywords = ["sister", "garaele"];
  12. this.items = [];
  13. this.commandQueue = [];
  14. this.waitTime = 0;
  15. this.memory = {};
  16. }
  17. mud_init() {
  18. world.mud_addMobileToRoom("PhandalinGaraeleHouse", this.id);
  19. world.mud_addItemToMobile(this.id, builder.mud_spawnItem("UnassumingKey").id);
  20. }
  21. mud_sendMessage(source, message) {
  22. message = message.replace(/\{.*?\}/g, "");
  23. var cleanMessage = message.trim().toLowerCase();
  24. if(source == this) {
  25. return;
  26. }
  27. if(source == null) {
  28. if(cleanMessage.indexOf("dawn") != -1 || cleanMessage.indexOf("twilight") != -1) {
  29. this.mud_addCommand(this, "tend");
  30. return;
  31. }
  32. return;
  33. }
  34. if(cleanMessage.indexOf("shout") != -1) {
  35. return;
  36. }
  37. if(this.commandQueue.length > 1) {
  38. return;
  39. }
  40. if(libs.Conversation.basicDecency(source, cleanMessage, this)) {
  41. return;
  42. }
  43. if(cleanMessage.indexOf("enters the room") != -1 || cleanMessage.indexOf("walks in") != -1 ) {
  44. this.mud_addCommand(this, "emote looks up.");
  45. this.mud_addCommand(this, "say Oh, hello! Welcome to my home.");
  46. return;
  47. }
  48. if(cleanMessage.indexOf("shrine") != -1) {
  49. this.addCommand(this, "say Oh yes, I take care of the Shrine of Tymora.");
  50. this.addCommand(this, "emote remembers something and lays out a few new candles on the table by the door.");
  51. return;
  52. }
  53. if(cleanMessage.indexOf("bruise") != -1 || cleanMessage.indexOf("happened") != -1) {
  54. this.mud_addCommand(this, "emote grimaces.");
  55. this.mud_addCommand(this, "say I had an unfortunate run-in with a {hint}banshee{/hint}.");
  56. this.mud_addCommand(this, "emote rubs a large bruise on her arm.");
  57. return;
  58. }
  59. if(cleanMessage.indexOf("banshee") != -1) {
  60. this.mud_addCommand(this, "say The banshee Agatha off the trail near Triboar. I was going to ask her a {hint}question{/hint}.");
  61. return;
  62. }
  63. if(cleanMessage.indexOf("question") != -1 || cleanMessage.indexOf("ask") != -1) {
  64. this.mud_addCommand(this, "say I was going to ask her about the whereabouts of the Spellbook of {hint}Bowgentle{/hint}.");
  65. return;
  66. }
  67. if(cleanMessage.indexOf("bowgentle") != -1 || cleanMessage.indexOf("spellbook") != -1) {
  68. this.mud_addCommand(this, "say Bowgentle was a member of the {hint}Harpers{/hint} and an adventurous wizard.");
  69. this.mud_addCommand(this, "say He wrote up his life's research on magic into a spellbook that was lost after his death.");
  70. return;
  71. }
  72. if(cleanMessage.indexOf("harper") != -1) {
  73. this.mud_addCommand(this, "say The Harpers are a secret organization dedicated to promoting good, preserving history and maintaining a balance between civilization and nature.");
  74. this.mud_addCommand(this, "say I happen to be a member myself!");
  75. this.mud_addCommand(this, "emote looks embarrassed.");
  76. this.mud_addCommand(this, "say Although, for a secret organization, I did kinda give it away...");
  77. return;
  78. }
  79. if(cleanMessage.indexOf("quest") != -1) {
  80. this.mud_addCommand(this, "say Do you think you could find Agatha the banshee and ask her where the spellbook is?");
  81. return;
  82. }
  83. }
  84. mud_addMemory(section, newMemory) {
  85. if(!this.memory.hasOwnProperty(section)) {
  86. this.memory[section] = [];
  87. }
  88. this.memory[section].push(memory);
  89. }
  90. mud_checkMemory(section, memoryToCheck) {
  91. if(this.memory.hasOwnProperty(section)) {
  92. if(this.memory[section].hasOwnProperty(memory)) {
  93. return true;
  94. }
  95. }
  96. return false;
  97. }
  98. tend() {
  99. this.mud_addCommand(this, "say Excuse me for a moment.");
  100. this.mud_addCommand(this, "unlock door");
  101. this.mud_addCommand(this, "open door");
  102. this.mud_addCommand(this, "leave");
  103. this.mud_addCommand(this, "emote approaches the shrine.");
  104. this.mud_addCommand(this, "wait 6");
  105. this.mud_addCommand(this, "emote replaces the candles on the altar in the shrine.");
  106. this.mud_addCommand(this, "wait 12");
  107. this.mud_addCommand(this, "emote adds another stick of incense.");
  108. this.mud_addCommand(this, "wait 12");
  109. this.mud_addCommand(this, "emote kneels and prays quietly.");
  110. this.mud_addCommand(this, "wait 24");
  111. this.mud_addCommand(this, "emote kneels and prays quietly.");
  112. this.mud_addCommand(this, "wait 24");
  113. this.mud_addCommand(this, "emote stands and nods.");
  114. this.mud_addCommand(this, "wait 6");
  115. this.mud_addCommand(this, "unlock door");
  116. this.mud_addCommand(this, "open door");
  117. this.mud_addCommand(this, "enter");
  118. return true;
  119. }
  120. mud_addCommand(source, message) {
  121. this.commandQueue.push(message);
  122. }
  123. mud_addInterruptCommand(source, message) {
  124. this.commandQueue.shift(message);
  125. }
  126. mud_tick(time) {
  127. if(time >= this.lastIdle) {
  128. var idleMessages = [
  129. "emote winces and lightly touches a bruise.",
  130. "emote closes her eyes and whispers a short prayer to Tymora.",
  131. "emote busies herself around her house, straightening things.",
  132. "emote idly plays with her prayer beads, silently whispering to Tymora."];
  133. var randomIdle = idleMessages[parseInt(Math.random() * idleMessages.length)];
  134. this.mud_addCommand(this, randomIdle);
  135. this.lastIdle = time + this.idleDelay;
  136. }
  137. if(this.waitTime > 0) {
  138. this.waitTime--;
  139. }
  140. if(this.commandQueue.length > 0 && this.waitTime <= 0) {
  141. world.mud_handleInput(this.roomId, this.id, this.commandQueue.shift().split(" "));
  142. this.lastIdle = time + this.idleDelay;
  143. this.waitTime = 0;
  144. }
  145. }
  146. wait(room, mobile, input) {
  147. this.waitTime = parseInt(input.join(" "));
  148. return true;
  149. }
  150. look(room, mobile, input) {
  151. switch(input[0]) {
  152. case "bruise":
  153. libs.Output.toMobile(mobile.id, "You can't see it very well. Maybe you can {hint}say{/hint} something to her about it.");
  154. return true;
  155. }
  156. }
  157. mud_enterRoom(direction) {
  158. if(direction != null) {
  159. return this.name + " " + direction + ".";
  160. }
  161. return this.name + " enters the room.";
  162. }
  163. mud_leaveRoom(direction) {
  164. if(direction != null) {
  165. return this.name + " " + direction + ".";
  166. }
  167. return this.name + " leaves.";
  168. }
  169. };