home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #7 / amigamamagazinepolishissue1998.iso / rozrywka / rpg / amigamud / src / extras / frog.m < prev    next >
Text File  |  1996-11-03  |  3KB  |  112 lines

  1. /* grab some stuff from the scenario: */
  2. use t_util
  3.  
  4. /* a new table to put new symbols in: */
  5. private tp_frog CreateTable()$
  6. use tp_frog
  7.  
  8. /* the routine which Frog executes on each "step": */
  9. define tp_frog proc frogStep()void:
  10.     int direction;
  11.  
  12.     if not ClientsActive() then
  13.     After(60.0, frogStep);
  14.     else
  15.     direction := Random(12);
  16.     if TryToMove(direction) then
  17.         MachineMove(direction);
  18.     fi;
  19.     After(IntToFixed(10 + Random(10)), frogStep);
  20.     fi;
  21. corp;
  22.  
  23. /* the routine used to start up Frog */
  24. define tp_frog proc frogStart()void:
  25.  
  26.     After(10.0, frogStep);
  27. corp;
  28.  
  29. /* the routine used to restart Frog: */
  30. define tp_frog proc frogRestart()void:
  31.  
  32.     After(10.0, frogStep);
  33. corp;
  34.  
  35. /* the routine to handle Frog overhearing normal speech */
  36. define tp_frog proc frogHear(string what)void:
  37.     string speaker, word;
  38.  
  39.     speaker := SetSay(what);
  40.     /* Frog croaks if he hears his name */
  41.     while
  42.     word := GetWord();
  43.     word ~= ""
  44.     do
  45.     if word == "Frog" then
  46.         DoSay("Croak!");
  47.     fi;
  48.     od;
  49. corp;
  50.  
  51. /* the routine to handle someone whispering to Frog: */
  52. define tp_frog proc frogWhispered(string what)void:
  53.     string whisperer, word;
  54.  
  55.     whisperer := SetWhisperMe(what);
  56.     /* Frog ribbets if he is whispered his name */
  57.     while
  58.     word := GetWord();
  59.     word ~= ""
  60.     do
  61.     if word == "Frog" then
  62.         DoSay("Ribbet!");
  63.     fi;
  64.     od;
  65. corp;
  66.  
  67. /* the routine to handle Frog overhearing a whisper: */
  68. define tp_frog proc frogOverhear(string what)void:
  69.     string whisperer, whisperedTo, word;
  70.  
  71.     whisperer := SetWhisperOther(what);
  72.     whisperedTo := GetWord();
  73.     /* Frog simply blabs out loud whatever he overhears. */
  74.     DoSay(whisperer + " whispered to " + whisperedTo + ": " + GetTail());
  75. corp;
  76.  
  77. /* the routine to see someone doing a pose: */
  78. define tp_frog proc frogSaw(string what)void:
  79.     string poser, word;
  80.  
  81.     SetTail(what);
  82.     poser := GetWord();
  83.     /* Frog gets excited if you reference him in a pose. */
  84.     while
  85.     word := GetWord();
  86.     word ~= ""
  87.     do
  88.     if word == "Frog" then
  89.         Pose("", "jumps up and down excitedly.");
  90.     fi;
  91.     od;
  92. corp;
  93.  
  94. /* the function to create the Frog: */
  95. define tp_frog proc createFrog(thing where)void:
  96.     thing frog;
  97.  
  98.     frog := CreateThing(nil);
  99.     frog@p_pDesc := "Frog is just a plain old frog.");
  100.     frog@p_pStandard := true;
  101.     SetupMachine(frog);
  102.     CreateMachine("Frog", frog, where, frogStart);
  103.     ignore SetMachineActive(frog, frogRestart);
  104.     ignore SetMachineSay(frog, frogHear);
  105.     ignore SetMachineWhisperMe(frog, frogWhispered);
  106.     ignore SetMachineWhisperOther(frog, frogOverhear);
  107.     ignore SetMachinePose(frog, frogSaw);
  108. corp;
  109.  
  110. /* create Frog and start him up: */
  111. createFrog(Here())$
  112.