Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2014
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.52 KB | None | 0 0
  1. /*=============================================================
  2. ======================MIAUW'S SAY REWRITE======================
  3. ===============================================================
  4.  
  5. This is a basic explanation of how say() works. Read this if you don't understand something.
  6.  
  7. The basic "flow" of say() is that a speaker says a message, which is heard by hearers. What appears on screen
  8. is constructed by each hearer seperately, and not by the speaker.
  9.  
  10. This rewrite was needed, but is far from perfect. Report any bugs you come across and feel free to fix things up.
  11. Radio code, while very much related to saycode, is not something I wanted to touch, so the code related to that may be messy.
  12.  
  13. If you came here to see how to use saycode, all you will ever really need to call is say(message).
  14. To have things react when other things speak around them, add the HEAR flag to their flags variable and
  15. override their Hear() proc.
  16. =======================PROCS & VARIABLES=======================
  17. Here follows a list of say()-related procs and variables.
  18. global procs
  19. get_radio_span(freq)
  20. Returns the span class associated with that frequency.
  21.  
  22. get_radio_name(freq)
  23. Returns the name of that frequency.
  24.  
  25. get_hearers_in_view(R, atom/source)
  26. Self-explanatory. Calls get_hear() and then calls recursive_hear_check on everything that get_hear() returns.
  27.  
  28. recursive_hear_check(atom/O)
  29. Checks for hearers by looping through the contents of O and the contents of the contents of O and etc and checking
  30. each object for the HEAR flag. Returns a list of objects with the HEAR flag.
  31.  
  32. get_hear(range, atom/source)
  33. Like view(), but ignores luminosity.
  34.  
  35. /atom/movable
  36. flags
  37. The HEAR flag determines whether something is a hearer or not.
  38. Hear() is only called on procs with this flag.
  39.  
  40. languages
  41. Bitmask variable.
  42. What languages this object speaks/understands. If the languages of the speaker don't match the languages
  43. of the hearer, the message will be modified in the hearer's lang_treat().
  44.  
  45. say(message)
  46. Say() is the "mother-proc". It calls all the other procs required for speaking, but does little itself.
  47. At the atom/movable level, say() just calls send_speech.
  48.  
  49. Hear(message, atom/movable/speaker, message_langs, raw_message, radio_freq)
  50. This proc handles hearing. What it does varies. For mobs, it treats the message with hearer-specific things
  51. like language and deafness, then outputs it to the hearer.
  52.  
  53. IMPORTANT NOTE: If radio_freq is not null, the code will assume that the speaker is virtual! (more info on this in the Radios section below)
  54.  
  55. send_speech(message, range)
  56. This proc composes a list of hearers (things with the HEAR flag + dead people) and calls Hear() on them.
  57. Message treatment or composition of output are not done by this proc, these are handled by the rest of
  58. say() and the hearer respectively.
  59.  
  60. lang_treat(message, atom/movable/speaker, message_langs, raw_message)
  61. Modifies the message by comparing the languages of the speaker with the languages of the hearer.
  62. Called on the hearer.
  63.  
  64. say_quote(text)
  65. Adds a verb and quotes to a message, according to the type of mob. Called on the speaker.
  66.  
  67. /mob
  68. say_dead(message)
  69. Sends a message to all dead people. Does not use Hear().
  70.  
  71. compose_message(message, atom/movable/speaker, message_langs, raw_message, radio_freq)
  72. Composes the message mobs see on their screen when they hear something.
  73.  
  74. compose_track_href(message, atom/movable/speaker, message_langs, raw_message, radio_freq)
  75. Composes the href tags used by the AI for tracking. Returns "" for all mobs except AIs.
  76.  
  77. compose_job(message, atom/movable/speaker, message_langs, raw_message, radio_freq)
  78. Composes the job and the end tag for tracking hrefs. Returns "" for all mobs except AIs.
  79.  
  80. hivecheck()
  81. Returns 1 if the mob can hear and talk in the alien hivemind.
  82.  
  83. lingcheck()
  84. Returns 1 if the mob can hear and talk in the changeling hivemind.
  85.  
  86. /mob/living
  87. say(message)
  88. The say() of mob_living is significantly more complex than that of objects.
  89. Most of the extra code has to do with radios and message treatment.
  90.  
  91. check_emote(message)
  92. Checks if the message begins with an * and is thus an emote.
  93.  
  94. can_speak(message)
  95. Calls can_speak_basic() and can_speak_vocal()
  96.  
  97. can_speak_basic(message)
  98. Sees if the mob can "think" the message. Does not include vocalization or stat checks.
  99. Vocalization checks are in can_speak_vocal, stat checks have to be done manually.
  100. Will call say_dead() if the speaker is dead.
  101. Called right before handle_inherent_channels()
  102.  
  103. can_speak_vocal(message)
  104. Checks if the mob can vocalize their message. This is seperate so, for example, muzzles don't block
  105. hivemind chat.
  106. Called right after handle_inherent_channels()
  107.  
  108. get_message_mode(message)
  109. Checks the start of the message for a message mode, then returns said message mode.
  110. DOES NOT TRIM THE MESSAGE. This is done manually.
  111.  
  112. handle_inherent_channels(message, message_mode)
  113. If message_mode is MODE_BINARY, MODE_ALIEN or MODE_CHANGELING (or, for AIs, MODE_HOLOPAD), this will
  114. handle speaking in those modes. Return 1 to exit say().
  115.  
  116. treat_message(message)
  117. What it says on the tin. Treats the message according to masks, mutantraces, mutations, etc.
  118. Please try to keep things in a logical order (e.g. don't have masks handled before mutations),
  119. even if that means you have to call ..() in the middle of the proc.
  120.  
  121. radio(message, message_mode)
  122. Handles talking into radios. Uses a switch to determine what radio to speak into and in which manner to do so.
  123.  
  124. Return is a bitflag.
  125. NOPASS = terminate say() (used for whispers)
  126. ITALICS = add italics to the message
  127. REDUCE_RANGE = reduce the message range to one tile.
  128.  
  129. Return 0 if no radio was spoken into.
  130. IMPORTANT: remember to call ..() and check for ..()'s return value properly!
  131.  
  132. ============================RADIOS=============================
  133.  
  134. I did not want to interfere with radios too much, but I sort of had to.
  135. For future generations, here is how radio code works:
  136. First, talk_into() is called on a radio. This sends a signal datum into the magic machine that is tcomms, which
  137. eventually results in broadcast_message() being called.
  138.  
  139. Broadcast_message() does NOT call say() on radios, but rather calls Hear() on everyone in range of a radio.
  140. This is because the system does not like repeating says.
  141.  
  142. Furthermore, I changed radios to not be in the radio_controller. Instead, they are in a global list called all_radios.
  143. This is an associative list, and the numbers as strings are the keys. The values are lists of radios that can hear said frequency.
  144.  
  145. To add a radio, simply use add_radio(radio, frequency). To remove a radio, use remove_radio(radio, frequency).
  146. To remove a radio from ALL frequencies, use remove_radio_all(radio).
  147.  
  148. VIRTUAL SPEAKERS:
  149. Virtual speakers are simply atom/movables with a few extra variables.
  150. If radio_freq is not null, the code will rely on the fact that the speaker is virtual. This means that several procs will return something:
  151. (all of these procs are defined at the atom/movable level and return "" at that level.)
  152. GetJob()
  153. Returns the job string variable of the virtual speaker.
  154. GetTrack()
  155. Returns wether the tracking href should be fake or not.
  156. GetSource()
  157. Returns the source of the virtual speaker.
  158. GetRadio()
  159. Returns the radio that was spoken through by the source.
  160.  
  161. This is fairly hacky, but it means that I can advoid using istypes. It's mainly relevant for AI tracking and AI job display.
  162.  
  163. That's all, folks!*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement