Advertisement
Slowhand-VI

TUT: Say dialogue usage

Jan 2nd, 2016
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.89 KB | None | 0 0
  1. /**<
  2.  * Tutorial showing how to use the "Say" menu from dialogues.
  3.  * Author: Slowhand.
  4.  */
  5.  
  6. #include "_defines.fos"
  7. #include "_macros.fos"
  8.  
  9.  
  10. /**<
  11.  * This simple script will repeat what you say to it, using the Say menu.
  12.  */
  13. uint dlg_UsingSayDialogue(Critter& player, Critter@ npc, string@ say)
  14. {
  15.     //  Check if the player used the Say dialogue menu said something, if not, return to this same dialogue node.
  16.     if (!IS_DIALOG_SAY_MODE(say))
  17.         return 0;
  18.     //  The text the player gave, will be stored in the say paramter of the function, and this is used to say it back.
  19.     player.Say(SAY_DIALOG, "You said: " + say
  20.                + " using the Say menu. If you want to try again, just press Say or try the given dialogue options.");
  21.  
  22.     //  Returning 0, will call the same dialogue node again, this means,
  23.     //      that the player can type a text using the "Say" menu and the NPC will quote him again.
  24.     //  If you need to jump to a different dialogue, just return the node number, or -1 to exit form dialogue screen.
  25.     //  Note: You should use defines for jumping to dialogue nodes, instead of numbers, unlike I did.
  26.     return 0;
  27. }
  28.  
  29.  
  30. /**<
  31.  * It will ask the user a riddle, which he has to answer using the Say dialogue menu.
  32.  * The question in the dialogue file is: What turns around everything, yet does not move?
  33.  * The answer, as specified below is: Mirror or mirror.
  34.  * If the player does not answer correctly, he can try again.
  35.  */
  36. uint dlg_AskRiddle(Critter& player, Critter@ npc, string@ say)
  37. {
  38.     if (!IS_DIALOG_SAY_MODE(say))
  39.         return 0;
  40.  
  41.     if (say == "Mirror" || say == "mirror")
  42.     {
  43.         //  Jump to dialogue node 4, congratulates the player for guessing the correct answer.
  44.         return 4;
  45.     }
  46.     else
  47.     {
  48.         player.Say(SAY_DIALOG, say + "? This is not the answer I was looking for! Try again.");
  49.         return 0;
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement