home *** CD-ROM | disk | FTP | other *** search
/ Amiga Special: Spiele Hits / Hits-CD.iso / aminet / spiele / ammud1_1.lha / AmigaMUD / Src / Extras / spells.m < prev   
Text File  |  1997-08-07  |  14KB  |  584 lines

  1. /*
  2.  * Amiga MUD
  3.  *
  4.  * Copyright (c) 1997 by Chris Gray
  5.  */
  6.  
  7. /*
  8.  * spells.m - some handy wizard spells for use with 'cast'.
  9.  */
  10.  
  11. use t_base
  12. use t_icons
  13. use t_graphics
  14. use t_util
  15. use t_fight
  16. use t_quests
  17.  
  18. /* Make sure the sourcer of this file has a spell table. */
  19. if LookupTable(PrivateTable(), "t_spells") = nil then
  20.     ignore DefineTable(PrivateTable(), "t_spells", CreateTable());
  21. fi$
  22.  
  23. private tp_spellStuff CreateTable()$
  24. use tp_spellStuff
  25.  
  26. /* a 'spells' spell which lists the spells we have here */
  27.  
  28. define t_spells proc spells()void:
  29.  
  30.     Print("Known spells:\n\n");
  31.     Print("find <who> - show what <who> sees\n");
  32.     Print("poofto <who> - teleport to same location as <who>\n");
  33.     Print("look <who> - look at <who>, even if not nearby\n");
  34.     Print("sendto <who> <stuff> - send <stuff> to <who> as mindsend\n");
  35.     Print("heal <who> - heal <who> upto max hitpoints\n");
  36.     Print("enrich <who> <amount> - give <amount> blutos to <who>\n");
  37.     Print("force <who> <what> - force <who> to do <what>\n");
  38.     Print("teleport <who> {here | <dir> | <roomname>} - teleport <who> ...\n");
  39.     Print("showmachines - show machines in entire system\n");
  40.     Print("Words in spell table:\n");
  41.     ShowTable(t_spells);
  42. corp;
  43.  
  44. define tp_spellStuff proc findMachine(string w1, w2)thing:
  45.     int index;
  46.  
  47.     index := 1;
  48.     if w2 ~= "" then
  49.     index := StringToInt(w2);
  50.     if index < 0 then
  51.         Print("Invalid index '" + w2 + "' - 1 assumed.\n");
  52.         index := 1;
  53.     fi;
  54.     fi;
  55.     FindMachineIndexed(w1, index)
  56. corp;
  57.  
  58. /* a 'find' spell which will print the location info for the given character */
  59.  
  60. define t_spells proc find()void:
  61.     string name;
  62.     character ch;
  63.     thing where, agent;
  64.     action a;
  65.     bool found;
  66.  
  67.     name := GetWord();
  68.     if name = "" then
  69.     Print("Find who?\n");
  70.     else
  71.     found := true;
  72.     ch := Character(name);
  73.     if ch = nil then
  74.         agent := findMachine(name, GetWord());
  75.         if agent = nil then
  76.         Print("There is no character or machine called '" +
  77.               name + "'.\n");
  78.         found := false;
  79.         else
  80.         where := AgentLocation(agent);
  81.         fi;
  82.     else
  83.         where := CharacterLocation(ch);
  84.     fi;
  85.     if found then
  86.         if where = nil then
  87.         Print(Capitalize(CharacterNameS(agent)) +
  88.             " is not currently anywhere.\n");
  89.         else
  90.         a := where@p_rNameAction;
  91.         if a = nil then
  92.             Print(name + " is " + where@p_rName + ".\n");
  93.         else
  94.             Print(name + ": " + call(a, string)() + ".\n");
  95.         fi;
  96.         a := where@p_rDescAction;
  97.         if a = nil then
  98.             if where@p_rDesc ~= "" then
  99.             Print(where@p_rDesc + "\n");
  100.             fi;
  101.             ShowExits(where);
  102.             ignore ShowList(where@p_rContents, "Nearby:\n");
  103.         else
  104.             Print(name + ": " + call(a, string)() + ".\n");
  105.         fi;
  106.         fi;
  107.     fi;
  108.     fi;
  109. corp;
  110.  
  111. /* a 'poofto' spell which will poof to where the given character is */
  112.  
  113. define t_spells proc poofto()void:
  114.     string name;
  115.     character ch;
  116.     thing who, where;
  117.  
  118.     name := GetWord();
  119.     if name = "" then
  120.     Print("Poofto who?\n");
  121.     else
  122.     ch := Character(name);
  123.     if ch = nil then
  124.         who := findMachine(name, GetWord());
  125.         if who = nil then
  126.         Print("There is no character or machine called '" +
  127.               name + "'.\n");
  128.         fi;
  129.     else
  130.         who := CharacterThing(ch);
  131.         if who = nil then
  132.         Print(name + " has no thing????\n");
  133.         fi;
  134.     fi;
  135.     if who ~= nil then
  136.         where := AgentLocation(who);
  137.         if where = nil then
  138.         Print(Capitalize(CharacterNameS(who)) +
  139.             " is not currently active or anywhere.\n");
  140.         else
  141.         LeaveRoomStuff(where, 0, MOVE_POOF);
  142.         EnterRoomStuff(where, 0, MOVE_POOF);
  143.         fi;
  144.     fi;
  145.     fi;
  146. corp;
  147.  
  148. /* a 'look' spell which will look at a given character */
  149.  
  150. define t_spells proc look()void:
  151.     string name, s;
  152.     character ch;
  153.     thing who;
  154.     action a;
  155.  
  156.     name := GetWord();
  157.     if name = "" then
  158.     Print("Look who?\n");
  159.     else
  160.     ch := Character(name);
  161.     if ch = nil then
  162.         who := findMachine(name, GetWord());
  163.         if who = nil then
  164.         Print("There is no character or machine called '" +
  165.               name + "'.\n");
  166.         fi;
  167.     else
  168.         who := CharacterThing(ch);
  169.         if who = nil then
  170.         Print(name + " has no thing????\n");
  171.         fi;
  172.     fi;
  173.     if who ~= nil then
  174.         if LookAtCharacter(who) then
  175.         if who@p_pMoney ~= 0 then
  176.             Print(Capitalize(CharacterNameS(who)) + " has " +
  177.             IntToString(who@p_pMoney) + " blutos.\n");
  178.         fi;
  179.         ignore ShowQuests(who, true);
  180.         fi;
  181.     fi;
  182.     fi;
  183. corp;
  184.  
  185. /* a 'sendto' spell which will say something to the given character */
  186.  
  187. define t_spells proc sendto()void:
  188.     string name;
  189.     character ch;
  190.     thing who;
  191.  
  192.     name := GetWord();
  193.     if name = "" then
  194.     Print("Sendto who?\n");
  195.     else
  196.     ch := Character(name);
  197.     if ch = nil then
  198.         if findMachine(name, GetWord()) = nil then
  199.         Print("There is no character or machine called '" +
  200.               name + "'.\n");
  201.         fi;
  202.     else
  203.         who := CharacterThing(ch);
  204.         if who = nil then
  205.         Print(name + " has no thing????\n");
  206.         else
  207.         SPrint(who, Me()@p_pName + " mindsends: " + GetTail());
  208.         fi;
  209.     fi;
  210.     fi;
  211. corp;
  212.  
  213. /* a 'heal' spell to heal someone up */
  214.  
  215. define t_spells proc heal()void:
  216.     string name;
  217.     character ch;
  218.     thing who;
  219.     int max;
  220.  
  221.     name := GetWord();
  222.     if name = "" then
  223.     Print("Heal who?\n");
  224.     else
  225.     ch := Character(name);
  226.     if ch = nil then
  227.         who := findMachine(name, GetWord());
  228.         if who = nil then
  229.         Print("There is no character or machine called '" +
  230.               name + "'.\n");
  231.         fi;
  232.     else
  233.         who := CharacterThing(ch);
  234.         if who = nil then
  235.         Print(name + " has no thing????\n");
  236.         fi;
  237.     fi;
  238.     if who ~= nil then
  239.         max := who@p_pHitMax;
  240.         if max = 0 then
  241.         Print(name + " has no maximum hitpoints.\n");
  242.         elif who@p_pHitNow = max then
  243.         Print(name + " needs no healing.\n");
  244.         else
  245.         who@p_pHitNow := max;
  246.         Print(name + " healed.\n");
  247.         SPrint(who, "You suddenly feel better!\n");
  248.         fi;
  249.     fi;
  250.     fi;
  251. corp;
  252.  
  253. /* an 'enrich' spell to give someone some blutos */
  254.  
  255. define t_spells proc enrich()void:
  256.     string name, s;
  257.     character ch;
  258.     thing who;
  259.     int amount;
  260.  
  261.     name := GetWord();
  262.     if name = "" then
  263.     Print("Enrich who?\n");
  264.     else
  265.     ch := Character(name);
  266.     if ch = nil then
  267.         who := findMachine(name, GetWord());
  268.         if who = nil then
  269.         Print("There is no character or machine called '" +
  270.               name + "'.\n");
  271.         fi;
  272.     else
  273.         who := CharacterThing(ch);
  274.         if who = nil then
  275.         Print(name + " has no thing????\n");
  276.         fi;
  277.     fi;
  278.     if who ~= nil then
  279.         s := GetWord();
  280.         if s = "" then
  281.         Print("You must specify an amount to enrich by.\n");
  282.         else
  283.         amount := StringToInt(s);
  284.         if amount <= 0 then
  285.             Print("Invalid amount - must be positive integer.\n");
  286.         else
  287.             who@p_pMoney := who@p_pMoney + amount;
  288.             Print(name + " enriched - now has " +
  289.               IntToString(who@p_pMoney) + " blutos.\n");
  290.             SPrint(who, "You suddenly feel richer!\n");
  291.         fi;
  292.         fi;
  293.     fi;
  294.     fi;
  295. corp;
  296.  
  297. /* a 'force' spell which will make someone do something */
  298.  
  299. define tp_spellStuff p_pForceAction CreateStringProp()$
  300.  
  301. define tp_spellStuff proc doForceAction()void:
  302.     string s;
  303.  
  304.     s := Me()@p_pForceAction;
  305.     if s ~= "" then
  306.     Me() -- p_pForceAction;
  307.     ignore Parse(G, s);
  308.     fi;
  309. corp;
  310.  
  311. define tp_spellStuff proc forceAnAction()status:
  312.     After(0.0, doForceAction);
  313.     continue
  314. corp;
  315.  
  316. define tp_spellStuff proc forceCharacter(thing who; string what)void:
  317.     who@p_pForceAction := what;
  318.     ignore ForceAction(who, forceAnAction);
  319. corp;
  320.  
  321. define t_spells proc force()void:
  322.     string name, w, what;
  323.     character ch;
  324.     thing who;
  325.     int n;
  326.  
  327.     name := GetWord();
  328.     if name = "" then
  329.     Print("Force who?\n");
  330.     else
  331.     w := GetWord();
  332.     what := GetTail();
  333.     ch := Character(name);
  334.     if ch = nil then
  335.         n := StringToInt(w);
  336.         if n < 0 then
  337.         what := w + " " + what;
  338.         w := "";
  339.         fi;
  340.         who := findMachine(name, w);
  341.         if who = nil then
  342.         Print("There is no character or machine called '" +
  343.               name + "'.\n");
  344.         fi;
  345.     else
  346.         what := w + " " + what;
  347.         who := CharacterThing(ch);
  348.         if who = nil then
  349.         Print(name + " has no thing????\n");
  350.         fi;
  351.     fi;
  352.     if who ~= nil then
  353.         if what = "" then
  354.         Print("You must say what you want " + name + " to do.\n");
  355.         else
  356.         SPrint(who, "***\n" + Me()@p_pName + " forces you: " +
  357.             what +