home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / d / d-linux.zip / dm-dist / spells2.c < prev    next >
C/C++ Source or Header  |  1991-03-01  |  30KB  |  1,124 lines

  1. /* ************************************************************************
  2. *  file: spells2.c , Implementation of magic.             Part of DIKUMUD *
  3. *  Usage : All the non-offensive magic handling routines.                 *
  4. *  Copyright (C) 1990, 1991 - see 'license.doc' for complete information. *
  5. ************************************************************************* */
  6.  
  7. #include <stdio.h>
  8.  
  9. #include "structs.h"
  10. #include "utils.h"
  11. #include "comm.h"
  12. #include "db.h"
  13. #include "interpreter.h"
  14. #include "spells.h"
  15. #include "handler.h"
  16.  
  17.  
  18. /* Global data */
  19.  
  20. extern struct room_data *world;
  21. extern struct char_data *character_list;
  22. extern struct spell_info_type spell_info[MAX_SPL_LIST];
  23. extern struct obj_data  *object_list;
  24.  
  25.  
  26. /* Extern procedures */
  27.  
  28. void die(struct char_data *ch);
  29. void update_pos( struct char_data *victim );
  30. void damage(struct char_data *ch, struct char_data *victim,
  31.             int damage, int weapontype);
  32. void clone_char(struct char_data *ch);
  33. void say_spell( struct char_data *ch, int si );
  34. bool saves_spell(struct char_data *ch, sh_int spell);
  35. void add_follower(struct char_data *ch, struct char_data *victim);
  36. char *strdup(char *str);
  37.  
  38.  
  39. void cast_armor( byte level, struct char_data *ch, char *arg, int type,
  40.     struct char_data *tar_ch, struct obj_data *tar_obj )
  41. {
  42.   switch (type) {
  43.         case SPELL_TYPE_SPELL:
  44.             if ( affected_by_spell(tar_ch, SPELL_ARMOR) ){
  45.                 send_to_char("Nothing seems to happen.\n\r", ch);
  46.                 return;
  47.             }
  48.             if (ch != tar_ch)
  49.                 act("$N is protected by your deity.", FALSE, ch, 0, tar_ch, TO_CHAR);
  50.  
  51.             spell_armor(level,ch,tar_ch,0);
  52.             break;
  53.         case SPELL_TYPE_POTION:
  54.             if ( affected_by_spell(ch, SPELL_ARMOR) )
  55.                 return;
  56.             spell_armor(level,ch,ch,0);
  57.             break;
  58.         case SPELL_TYPE_SCROLL:
  59.             if (tar_obj) return;
  60.          if (!tar_ch) tar_ch = ch;
  61.             if ( affected_by_spell(tar_ch, SPELL_ARMOR) )
  62.                 return;
  63.             spell_armor(level,ch,ch,0);
  64.             break;
  65.         case SPELL_TYPE_WAND:
  66.             if (tar_obj) return;
  67.             if ( affected_by_spell(tar_ch, SPELL_ARMOR) )
  68.                 return;
  69.             spell_armor(level,ch,ch,0);
  70.             break;
  71.       default : 
  72.          log("Serious screw-up in armor!");
  73.          break;
  74.     }
  75. }
  76.  
  77.  
  78.  
  79. void cast_teleport( byte level, struct char_data *ch, char *arg, int type,
  80.   struct char_data *tar_ch, struct obj_data *tar_obj )
  81. {
  82.   switch (type) {
  83.         case SPELL_TYPE_SCROLL:
  84.         case SPELL_TYPE_POTION:
  85.     case SPELL_TYPE_SPELL:
  86.             if (!tar_ch)
  87.                 tar_ch = ch;
  88.             spell_teleport(level, ch, tar_ch, 0);
  89.             break;
  90.  
  91.         case SPELL_TYPE_WAND:
  92.             if(!tar_ch) return;
  93.             spell_teleport(level, ch, tar_ch, 0);
  94.             break;
  95.  
  96.     case SPELL_TYPE_STAFF:
  97.       for (tar_ch = world[ch->in_room].people ; 
  98.            tar_ch ; tar_ch = tar_ch->next_in_room)
  99.          if (tar_ch != ch) 
  100.             spell_teleport(level, ch, tar_ch, 0);
  101.       break;
  102.             
  103.     default : 
  104.       log("Serious screw-up in teleport!");
  105.       break;
  106.     }
  107. }
  108.  
  109.  
  110. void cast_bless( byte level, struct char_data *ch, char *arg, int type,
  111.   struct char_data *tar_ch, struct obj_data *tar_obj )
  112. {
  113.     struct affected_type af;
  114.  
  115.   switch (type) {
  116.     case SPELL_TYPE_SPELL:
  117.             if (tar_obj) {        /* It's an object */
  118.                 if ( IS_SET(tar_obj->obj_flags.extra_flags, ITEM_BLESS) ) {
  119.                     send_to_char("Nothing seems to happen.\n\r", ch);
  120.                     return;
  121.                 }
  122.                 spell_bless(level,ch,0,tar_obj);
  123.  
  124.             } else {              /* Then it is a PC | NPC */
  125.  
  126.                 if ( affected_by_spell(tar_ch, SPELL_BLESS) ||
  127.                     (GET_POS(tar_ch) == POSITION_FIGHTING)) {
  128.                     send_to_char("Nothing seems to happen.\n\r", ch);
  129.                     return;
  130.                 } 
  131.                 spell_bless(level,ch,tar_ch,0);
  132.             }
  133.             break;
  134.      case SPELL_TYPE_POTION:
  135.            if ( affected_by_spell(ch, SPELL_BLESS) ||
  136.                 (GET_POS(ch) == POSITION_FIGHTING))
  137.                 return;
  138.             spell_bless(level,ch,ch,0);
  139.          break;
  140.     case SPELL_TYPE_SCROLL:
  141.             if (tar_obj) {        /* It's an object */
  142.                 if ( IS_SET(tar_obj->obj_flags.extra_flags, ITEM_BLESS) )
  143.                     return;
  144.                 spell_bless(level,ch,0,tar_obj);
  145.  
  146.             } else {              /* Then it is a PC | NPC */
  147.  
  148.                 if (!tar_ch) tar_ch = ch;
  149.                 
  150.                 if ( affected_by_spell(tar_ch, SPELL_BLESS) ||
  151.                     (GET_POS(tar_ch) == POSITION_FIGHTING))
  152.                     return;
  153.                 spell_bless(level,ch,tar_ch,0);
  154.             }
  155.             break;
  156.     case SPELL_TYPE_WAND:
  157.             if (tar_obj) {        /* It's an object */
  158.                 if ( IS_SET(tar_obj->obj_flags.extra_flags, ITEM_BLESS) )
  159.                     return;
  160.                 spell_bless(level,ch,0,tar_obj);
  161.  
  162.             } else {              /* Then it is a PC | NPC */
  163.  
  164.                 if ( affected_by_spell(tar_ch, SPELL_BLESS) ||
  165.                     (GET_POS(tar_ch) == POSITION_FIGHTING))
  166.                     return;
  167.                 spell_bless(level,ch,tar_ch,0);
  168.             }
  169.             break;
  170.     default : 
  171.          log("Serious screw-up in bless!");
  172.          break;
  173.     }
  174. }
  175.  
  176.  
  177.  
  178. void cast_blindness( byte level, struct char_data *ch, char *arg, int type,
  179.   struct char_data *tar_ch, struct obj_data *tar_obj )
  180. {
  181.     struct affected_type af;
  182.  
  183.   switch (type) {
  184.     case SPELL_TYPE_SPELL:
  185.             if ( IS_AFFECTED(tar_ch, AFF_BLIND) ){
  186.                 send_to_char("Nothing seems to happen.\n\r", ch);
  187.                 return;
  188.             }
  189.             spell_blindness(level,ch,tar_ch,0);
  190.             break;
  191.     case SPELL_TYPE_POTION:
  192.             if ( IS_AFFECTED(ch, AFF_BLIND) )
  193.                 return;
  194.             spell_blindness(level,ch,ch,0);
  195.             break;
  196.     case SPELL_TYPE_SCROLL:
  197.          if (tar_obj) return;
  198.          if (!tar_ch) tar_ch = ch;
  199.             if ( IS_AFFECTED(ch, AFF_BLIND) )
  200.                 return;
  201.             spell_blindness(level,ch,ch,0);
  202.             break;
  203.     case SPELL_TYPE_WAND:
  204.          if (tar_obj) return;
  205.             if ( IS_AFFECTED(ch, AFF_BLIND) )
  206.                 return;
  207.             spell_blindness(level,ch,ch,0);
  208.             break;
  209.     case SPELL_TYPE_STAFF:
  210.          for (tar_ch = world[ch->in_room].people ; 
  211.               tar_ch ; tar_ch = tar_ch->next_in_room)
  212.             if (tar_ch != ch) 
  213.                if (!(IS_AFFECTED(tar_ch, AFF_BLIND)))
  214.                   spell_blindness(level,ch,tar_ch,0);
  215.          break;
  216.     default : 
  217.          log("Serious screw-up in blindness!");
  218.          break;
  219.     }
  220. }
  221.  
  222.  
  223. void cast_clone( byte level, struct char_data *ch, char *arg, int type,
  224.   struct char_data *tar_ch, struct obj_data *tar_obj )
  225. {
  226.     struct char_data *vict;
  227.     char buf[MAX_STRING_LENGTH];
  228.  
  229.     send_to_char("Not *YET* implemented.", ch);
  230.     return;
  231.  
  232.   /* clone both char and obj !!*/
  233.  
  234. /*
  235.   switch (type) {
  236.     case SPELL_TYPE_SPELL:
  237.             if (tar_ch) {    
  238.                 sprintf(buf, "You create a duplicate of %s.\n\r", GET_NAME(tar_ch));
  239.                 send_to_char(buf, ch);
  240.                 sprintf(buf, "%%s creates a duplicate of %s,\n\r", GET_NAME(tar_ch));
  241.                 perform(buf, ch, FALSE);
  242.  
  243.                 spell_clone(level,ch,tar_ch,0);
  244.             } else {
  245.                 sprintf(buf, "You create a duplicate of %s %s.\n\r",SANA(tar_obj),tar_obj->short_description);
  246.                 send_to_char(buf, ch);
  247.                 sprintf(buf, "%%s creates a duplicate of %s %s,\n\r",SANA(tar_obj),tar_obj->short_description);
  248.                 perform(buf, ch, FALSE);
  249.  
  250.                 spell_clone(level,ch,0,tar_obj);
  251.             };
  252.             break;
  253.  
  254.  
  255.     default : 
  256.          log("Serious screw-up in clone!");
  257.          break;
  258.     }
  259. */
  260.          /* MISSING REST OF SWITCH -- POTION, SCROLL, WAND */
  261. }
  262.  
  263.  
  264. void cast_control_weather( byte level, struct char_data *ch, char *arg, int type,
  265.   struct char_data *tar_ch, struct obj_data *tar_obj )
  266. {
  267.     char buffer[MAX_STRING_LENGTH];
  268.     extern struct weather_data weather_info;
  269.  
  270.   switch (type) {
  271.     case SPELL_TYPE_SPELL:
  272.  
  273.             one_argument(arg,buffer);
  274.  
  275.             if (str_cmp("better",buffer) && str_cmp("worse",buffer))
  276.             {
  277.                 send_to_char("Do you want it to get better or worse?\n\r",ch);
  278.                 return;
  279.             }
  280.  
  281.             if(!str_cmp("better",buffer))
  282.                 weather_info.change+=(dice(((level)/3),4));
  283.             else
  284.                 weather_info.change-=(dice(((level)/3),4)); 
  285.             break;
  286.       default : 
  287.          log("Serious screw-up in control weather!");
  288.          break;
  289.     }
  290. }
  291.  
  292.  
  293.  
  294. void cast_create_food( byte level, struct char_data *ch, char *arg, int type,
  295.   struct char_data *tar_ch, struct obj_data *tar_obj )
  296. {
  297.  
  298.   switch (type) {
  299.     case SPELL_TYPE_SPELL:
  300.             act("$n magically creates a mushroom.",FALSE, ch, 0, 0, TO_ROOM);
  301.          spell_create_food(level,ch,0,0);
  302.             break;
  303.     case SPELL_TYPE_SCROLL:
  304.          if(tar_obj) return;
  305.          if(tar_ch) return;
  306.          spell_create_food(level,ch,0,0);
  307.             break;
  308.     default : 
  309.          log("Serious screw-up in create food!");
  310.          break;
  311.     }
  312. }
  313.  
  314.  
  315.  
  316. void cast_create_water( byte level, struct char_data *ch, char *arg, int type,
  317.   struct char_data *tar_ch, struct obj_data *tar_obj )
  318. {
  319.   switch (type) {
  320.     case SPELL_TYPE_SPELL:
  321.             if (tar_obj->obj_flags.type_flag != ITEM_DRINKCON) {
  322.                 send_to_char("It is unable to hold water.\n\r", ch);
  323.                 return;
  324.             }
  325.             spell_create_water(level,ch,0,tar_obj);
  326.             break;
  327.       default : 
  328.          log("Serious screw-up in create water!");
  329.          break;
  330.     }
  331. }
  332.  
  333.  
  334.  
  335. void cast_cure_blind( byte level, struct char_data *ch, char *arg, int type,
  336.   struct char_data *tar_ch, struct obj_data *tar_obj )
  337. {
  338.   switch (type) {
  339.     case SPELL_TYPE_SPELL:
  340.             spell_cure_blind(level,ch,tar_ch,0);
  341.             break;
  342.     case SPELL_TYPE_POTION:
  343.             spell_cure_blind(level,ch,ch,0);
  344.             break;
  345.     case SPELL_TYPE_STAFF:
  346.          for (tar_ch = world[ch->in_room].people ; 
  347.               tar_ch ; tar_ch = tar_ch->next_in_room)
  348.             if (tar_ch != ch) 
  349.                spell_cure_blind(level,ch,tar_ch,0);
  350.          break;
  351.     default : 
  352.          log("Serious screw-up in cure blind!");
  353.          break;
  354.     }
  355. }
  356.  
  357.  
  358.  
  359. void cast_cure_critic( byte level, struct char_data *ch, char *arg, int type,
  360.   struct char_data *tar_ch, struct obj_data *tar_obj )
  361. {
  362.   switch (type) {
  363.     case SPELL_TYPE_SPELL:
  364.             spell_cure_critic(level,ch,tar_ch,0);
  365.             break;
  366.     case SPELL_TYPE_POTION:
  367.             spell_cure_critic(level,ch,ch,0);
  368.             break;
  369.     case SPELL_TYPE_STAFF:
  370.          for (tar_ch = world[ch->in_room].people ; 
  371.               tar_ch ; tar_ch = tar_ch->next_in_room)
  372.             if (tar_ch != ch) 
  373.                spell_cure_critic(level,ch,tar_ch,0);
  374.          break;
  375.       default : 
  376.          log("Serious screw-up in cure critic!");
  377.          break;
  378.  
  379.     }
  380. }
  381.  
  382.  
  383.  
  384. void cast_cure_light( byte level, struct char_data *ch, char *arg, int type,
  385.   struct char_data *tar_ch, struct obj_data *tar_obj )
  386. {
  387.   switch (type) {
  388.     case SPELL_TYPE_SPELL:
  389.       spell_cure_light(level,ch,tar_ch,0);
  390.       break;
  391.     case SPELL_TYPE_POTION:
  392.             spell_cure_light(level,ch,ch,0);
  393.             break;
  394.     case SPELL_TYPE_STAFF:
  395.          for (tar_ch = world[ch->in_room].people ; 
  396.               tar_ch ; tar_ch = tar_ch->next_in_room)
  397.             if (tar_ch != ch) 
  398.                spell_cure_light(level,ch,tar_ch,0);
  399.          break;
  400.     default : 
  401.          log("Serious screw-up in cure light!");
  402.          break;
  403.   }
  404. }
  405.  
  406.  
  407. void cast_curse( byte level, struct char_data *ch, char *arg, int type,
  408.   struct char_data *tar_ch, struct obj_data *tar_obj )
  409. {
  410.   switch (type) {
  411.     case SPELL_TYPE_SPELL:
  412.             if (tar_obj)   /* It is an object */ 
  413.                 spell_curse(level,ch,0,tar_obj);
  414.             else {              /* Then it is a PC | NPC */
  415.                 spell_curse(level,ch,tar_ch,0);
  416.             }
  417.             break;
  418.     case SPELL_TYPE_POTION:
  419.             spell_curse(level,ch,ch,0);
  420.             break;
  421.     case SPELL_TYPE_SCROLL:
  422.             if (tar_obj)   /* It is an object */ 
  423.                 spell_curse(level,ch,0,tar_obj);
  424.             else {              /* Then it is a PC | NPC */
  425.                 if (!tar_ch) tar_ch = ch;
  426.                 spell_curse(level,ch,tar_ch,0);
  427.             }
  428.             break;
  429.     case SPELL_TYPE_STAFF:
  430.          for (tar_ch = world[ch->in_room].people ; 
  431.               tar_ch ; tar_ch = tar_ch->next_in_room)
  432.             if (tar_ch != ch) 
  433.                spell_curse(level,ch,tar_ch,0);
  434.          break;
  435.     default : 
  436.          log("Serious screw-up in curse!");
  437.          break;
  438.     }
  439. }
  440.  
  441.  
  442. void cast_detect_evil( byte level, struct char_data *ch, char *arg, int type,
  443.   struct char_data *tar_ch, struct obj_data *tar_obj )
  444. {
  445.   switch (type) {
  446.     case SPELL_TYPE_SPELL:
  447.             if ( affected_by_spell(tar_ch, SPELL_DETECT_EVIL) ){
  448.                 send_to_char("Nothing seems to happen.\n\r", tar_ch);
  449.                 return;
  450.             }
  451.             spell_detect_evil(level,ch,tar_ch,0);
  452.             break;
  453.     case SPELL_TYPE_POTION:
  454.             if ( affected_by_spell(ch, SPELL_DETECT_EVIL) )
  455.                 return;
  456.             spell_detect_evil(level,ch,ch,0);
  457.             break;
  458.     case SPELL_TYPE_STAFF:
  459.          for (tar_ch = world[ch->in_room].people ; 
  460.               tar_ch ; tar_ch = tar_ch->next_in_room)
  461.             if (tar_ch != ch) 
  462.                if(!(IS_AFFECTED(tar_ch, SPELL_DETECT_EVIL)))
  463.                   spell_detect_evil(level,ch,tar_ch,0);
  464.          break;
  465.     default : 
  466.          log("Serious screw-up in detect evil!");
  467.          break;
  468.     }
  469. }
  470.  
  471.  
  472.  
  473. void cast_detect_invisibility( byte level, struct char_data *ch, char *arg, int type,
  474.   struct char_data *tar_ch, struct obj_data *tar_obj )
  475. {
  476.   switch (type) {
  477.     case SPELL_TYPE_SPELL:
  478.             if ( affected_by_spell(tar_ch, SPELL_DETECT_INVISIBLE) ){
  479.                 send_to_char("Nothing seems to happen.\n\r", tar_ch);
  480.                 return;
  481.             }
  482.             spell_detect_invisibility(level,ch,tar_ch,0);
  483.             break;
  484.     case SPELL_TYPE_POTION:
  485.             if ( affected_by_spell(ch, SPELL_DETECT_INVISIBLE) )
  486.                 return;
  487.             spell_detect_invisibility(level,ch,ch,0);
  488.             break;
  489.     case SPELL_TYPE_STAFF:
  490.          for (tar_ch = world[ch->in_room].people ; 
  491.               tar_ch ; tar_ch = tar_ch->next_in_room)
  492.             if (tar_ch != ch) 
  493.                if(!(IS_AFFECTED(tar_ch, SPELL_DETECT_INVISIBLE)))
  494.                   spell_detect_invisibility(level,ch,tar_ch,0);
  495.          break;
  496.     default : 
  497.          log("Serious screw-up in detect invisibility!");
  498.          break;
  499.     }
  500. }
  501.  
  502.  
  503.  
  504. void cast_detect_magic( byte level, struct char_data *ch, char *arg, int type,
  505.   struct char_data *tar_ch, struct obj_data *tar_obj )
  506. {
  507.   switch (type) {
  508.     case SPELL_TYPE_SPELL:
  509.             if ( affected_by_spell(tar_ch, SPELL_DETECT_MAGIC) ){
  510.                 send_to_char("Nothing seems to happen.\n\r", tar_ch);
  511.                 return;
  512.             }
  513.             spell_detect_magic(level,ch,tar_ch,0);
  514.             break;
  515.     case SPELL_TYPE_POTION:
  516.             if ( affected_by_spell(ch, SPELL_DETECT_MAGIC) )
  517.                 return;
  518.             spell_detect_magic(level,ch,ch,0);
  519.             break;
  520.     case SPELL_TYPE_STAFF:
  521.          for (tar_ch = world[ch->in_room].people ; 
  522.               tar_ch ; tar_ch = tar_ch->next_in_room)
  523.             if (tar_ch != ch) 
  524.                if (!(IS_AFFECTED(tar_ch, SPELL_DETECT_MAGIC)))
  525.                   spell_detect_magic(level,ch,tar_ch,0);
  526.          break;
  527.     default : 
  528.          log("Serious screw-up in detect magic!");
  529.          break;
  530.     }
  531. }
  532.  
  533.  
  534.  
  535. void cast_detect_poison( byte level, struct char_data *ch, char *arg, int type,
  536.   struct char_data *tar_ch, struct obj_data *tar_obj )
  537. {
  538.   switch (type) {
  539.     case SPELL_TYPE_SPELL:
  540.             spell_detect_poison(level, ch, tar_ch,tar_obj);
  541.             break;
  542.     case SPELL_TYPE_POTION:
  543.             spell_detect_poison(level, ch, ch,0);
  544.             break;
  545.     case SPELL_TYPE_SCROLL:
  546.          if (tar_obj) {
  547.                 spell_detect_poison(level, ch, 0, tar_obj);
  548.             return;
  549.          }
  550.          if (!tar_ch) tar_ch = ch;
  551.             spell_detect_poison(level, ch, tar_ch, 0);
  552.             break;
  553.     default : 
  554.          log("Serious screw-up in detect poison!");
  555.          break;
  556.     }
  557. }
  558.  
  559.  
  560.  
  561. void cast_dispel_evil( byte level, struct char_data *ch, char *arg, int type,
  562.   struct char_data *tar_ch, struct obj_data *tar_obj )
  563. {
  564.   switch (type) {
  565.     case SPELL_TYPE_SPELL:
  566.             spell_dispel_evil(level, ch, tar_ch,0);
  567.             break;
  568.     case SPELL_TYPE_POTION:
  569.             spell_dispel_evil(level,ch,ch,0);
  570.             break;
  571.     case SPELL_TYPE_SCROLL:
  572.       if (tar_obj) return;
  573.       if (!tar_ch) tar_ch = ch;
  574.             spell_dispel_evil(level, ch, tar_ch,0);
  575.             break;
  576.     case SPELL_TYPE_WAND:
  577.       if (tar_obj) return;
  578.             spell_dispel_evil(level, ch, tar_ch,0);
  579.             break;
  580.     case SPELL_TYPE_STAFF:
  581.          for (tar_ch = world[ch->in_room].people ; 
  582.               tar_ch ; tar_ch = tar_ch->next_in_room)
  583.             if (tar_ch != ch) 
  584.               spell_dispel_evil(level,ch,tar_ch,0);
  585.          break;
  586.     default : 
  587.          log("Serious screw-up in dispel evil!");
  588.          break;
  589.     }
  590. }
  591.  
  592.  
  593. void cast_enchant_weapon( byte level, struct char_data *ch, char *arg, int type,
  594.   struct char_data *tar_ch, struct obj_data *tar_obj )
  595. {
  596.   switch (type) {
  597.     case SPELL_TYPE_SPELL:
  598.             spell_enchant_weapon(level, ch, 0,tar_obj);
  599.             break;
  600.  
  601.     case SPELL_TYPE_SCROLL:
  602.             if(!tar_obj) return;
  603.             spell_enchant_weapon(level, ch, 0,tar_obj);
  604.             break;
  605.     default : 
  606.       log("Serious screw-up in enchant weapon!");
  607.       break;
  608.     }
  609. }
  610.  
  611.  
  612. void cast_heal( byte level, struct char_data *ch, char *arg, int type,
  613.   struct char_data *tar_ch, struct obj_data *tar_obj )
  614. {
  615.   switch (type) {
  616.     case SPELL_TYPE_SPELL:
  617.             act("$n heals $N.", FALSE, ch, 0, tar_ch, TO_NOTVICT);
  618.             act("You heal $N.", FALSE, ch, 0, tar_ch, TO_CHAR);
  619.             spell_heal(level, ch, tar_ch, 0);
  620.             break;
  621.     case SPELL_TYPE_POTION:
  622.          spell_heal(level, ch, ch, 0);
  623.          break;
  624.     case SPELL_TYPE_STAFF:
  625.          for (tar_ch = world[ch->in_room].people ; 
  626.               tar_ch ; tar_ch = tar_ch->next_in_room)
  627.             if (tar_ch != ch) 
  628.               spell_heal(level,ch,tar_ch,0);
  629.          break;
  630.     default : 
  631.          log("Serious screw-up in heal!");
  632.          break;
  633.     }
  634. }
  635.  
  636.  
  637. void cast_invisibility( byte level, struct char_data *ch, char *arg, int type,
  638.   struct char_data *tar_ch, struct obj_data *tar_obj )
  639. {
  640.   switch (type) {
  641.     case SPELL_TYPE_SPELL:
  642.             if (tar_obj) {
  643.                 if ( IS_SET(tar_obj->obj_flags.extra_flags, ITEM_INVISIBLE) )
  644.                     send_to_char("Nothing new seems to happen.\n\r", ch);
  645.                 else
  646.                     spell_invisibility(level, ch, 0, tar_obj);
  647.             } else { /* tar_ch */
  648.                 if ( IS_AFFECTED(tar_ch, AFF_INVISIBLE) )
  649.                     send_to_char("Nothing new seems to happen.\n\r", ch);
  650.                 else
  651.                     spell_invisibility(level, ch, tar_ch, 0);
  652.             }
  653.             break;
  654.     case SPELL_TYPE_POTION:
  655.          if (!IS_AFFECTED(ch, AFF_INVISIBLE) )
  656.             spell_invisibility(level, ch, ch, 0);
  657.          break;
  658.     case SPELL_TYPE_SCROLL:
  659.             if (tar_obj) {
  660.                 if (!(IS_SET(tar_obj->obj_flags.extra_flags, ITEM_INVISIBLE)) )
  661.                     spell_invisibility(level, ch, 0, tar_obj);
  662.             } else { /* tar_ch */
  663.             if (!tar_ch) tar_ch = ch;
  664.  
  665.                 if (!( IS_AFFECTED(tar_ch, AFF_INVISIBLE)) )
  666.                     spell_invisibility(level, ch, tar_ch, 0);
  667.             }
  668.             break;
  669.     case SPELL_TYPE_WAND:
  670.             if (tar_obj) {
  671.                 if (!(IS_SET(tar_obj->obj_flags.extra_flags, ITEM_INVISIBLE)) )
  672.                     spell_invisibility(level, ch, 0, tar_obj);
  673.             } else { /* tar_ch */
  674.                 if (!( IS_AFFECTED(tar_ch, AFF_INVISIBLE)) )
  675.                     spell_invisibility(level, ch, tar_ch, 0);
  676.             }
  677.             break;
  678.     case SPELL_TYPE_STAFF:
  679.          for (tar_ch = world[ch->in_room].people ; 
  680.               tar_ch ; tar_ch = tar_ch->next_in_room)
  681.             if (tar_ch != ch)
  682.                if (!( IS_AFFECTED(tar_ch, AFF_INVISIBLE)) )
  683.                   spell_invisibility(level,ch,tar_ch,0);
  684.          break;
  685.     default : 
  686.          log("Serious screw-up in invisibility!");
  687.          break;
  688.     }
  689. }
  690.  
  691.  
  692.  
  693.  
  694. void cast_locate_object( byte level, struct char_data *ch, char *arg, int type,
  695.   struct char_data *tar_ch, struct obj_data *tar_obj )
  696. {
  697.   switch (type) {
  698.     case SPELL_TYPE_SPELL:
  699.             spell_locate_object(level, ch, 0, tar_obj);
  700.             break;
  701.       default : 
  702.          log("Serious screw-up in locate object!");
  703.          break;
  704.     }
  705. }
  706.  
  707.  
  708. void cast_poison( byte level, struct char_data *ch, char *arg, int type,
  709.   struct char_data *tar_ch, struct obj_data *tar_obj )
  710. {
  711.   switch (type) {
  712.     case SPELL_TYPE_SPELL:
  713.             spell_poison(level, ch, tar_ch, tar_obj);
  714.             break;
  715.     case SPELL_TYPE_POTION:
  716.             spell_poison(level, ch, ch, 0);
  717.             break;
  718.     case SPELL_TYPE_STAFF:
  719.          for (tar_ch = world[ch->in_room].people ; 
  720.               tar_ch ; tar_ch = tar_ch->next_in_room)
  721.             if (tar_ch != ch) 
  722.                   spell_poison(level,ch,tar_ch,0);
  723.          break;
  724.     default : 
  725.          log("Serious screw-up in poison!");
  726.          break;
  727.     }
  728. }
  729.  
  730.  
  731. void cast_protection_from_evil( byte level, struct char_data *ch, char *arg, int type,
  732.   struct char_data *tar_ch, struct obj_data *tar_obj )
  733. {
  734.   switch (type) {
  735.     case SPELL_TYPE_SPELL:
  736.             spell_protection_from_evil(level, ch, tar_ch, 0);
  737.             break;
  738.     case SPELL_TYPE_POTION:
  739.          spell_protection_from_evil(level, ch, ch, 0);
  740.          break;
  741.     case SPELL_TYPE_SCROLL:
  742.          if(tar_obj) return;
  743.          if(!tar_ch) tar_ch = ch;
  744.             spell_protection_from_evil(level, ch, tar_ch, 0);
  745.             break;
  746.     case SPELL_TYPE_STAFF:
  747.          for (tar_ch = world[ch->in_room].people ; 
  748.               tar_ch ; tar_ch = tar_ch->next_in_room)
  749.             if (tar_ch != ch) 
  750.                   spell_protection_from_evil(level,ch,tar_ch,0);
  751.          break;
  752.     default : 
  753.          log("Serious screw-up in protection from evil!");
  754.          break;
  755.     }
  756. }
  757.  
  758.  
  759. void cast_remove_curse( byte level, struct char_data *ch, char *arg, int type,
  760.   struct char_data *tar_ch, struct obj_data *tar_obj )
  761. {
  762.   switch (type) {
  763.     case SPELL_TYPE_SPELL:
  764.             spell_remove_curse(level, ch, tar_ch, tar_obj);
  765.             break;
  766.     case SPELL_TYPE_POTION:
  767.          spell_remove_curse(level, ch, ch, 0);
  768.          break;
  769.     case SPELL_TYPE_SCROLL:
  770.          if(tar_obj) {
  771.                 spell_remove_curse(level, ch, 0, tar_obj);
  772.                  return;
  773.             }
  774.          if(!tar_ch) tar_ch = ch;
  775.             spell_remove_curse(level, ch, tar_ch, 0);
  776.             break;
  777.     case SPELL_TYPE_STAFF:
  778.          for (tar_ch = world[ch->in_room].people ; 
  779.               tar_ch ; tar_ch = tar_ch->next_in_room)
  780.             if (tar_ch != ch) 
  781.                   spell_remove_curse(level,ch,tar_ch,0);
  782.          break;
  783.     default : 
  784.          log("Serious screw-up in remove curse!");
  785.          break;
  786.     }
  787. }
  788.  
  789.  
  790.  
  791. void cast_remove_poison( byte level, struct char_data *ch, char *arg, int type,
  792.   struct char_data *tar_ch, struct obj_data *tar_obj )
  793. {
  794.   switch (type) {
  795.     case SPELL_TYPE_SPELL:
  796.             spell_remove_poison(level, ch, tar_ch, tar_obj);
  797.             break;
  798.     case SPELL_TYPE_POTION:
  799.          spell_remove_poison(level, ch, ch, 0);
  800.          break;
  801.     case SPELL_TYPE_STAFF:
  802.          for (tar_ch = world[ch->in_room].people ; 
  803.               tar_ch ; tar_ch = tar_ch->next_in_room)
  804.             if (tar_ch != ch) 
  805.                   spell_remove_poison(level,ch,tar_ch,0);
  806.          break;
  807.     default : 
  808.          log("Serious screw-up in remove poison!");
  809.          break;
  810.     }
  811. }
  812.  
  813.  
  814.  
  815. void cast_sanctuary( byte level, struct char_data *ch, char *arg, int type,
  816.   struct char_data *tar_ch, struct obj_data *tar_obj )
  817. {
  818.   switch (type) {
  819.     case SPELL_TYPE_SPELL:
  820.             spell_sanctuary(level, ch, tar_ch, 0);
  821.             break;
  822.     case SPELL_TYPE_POTION:
  823.          spell_sanctuary(level, ch, ch, 0);
  824.          break;
  825.     case SPELL_TYPE_SCROLL:
  826.          if(tar_obj)
  827.                  return;
  828.          if(!tar_ch) tar_ch = ch;
  829.             spell_sanctuary(level, ch, tar_ch, 0);
  830.             break;
  831.     case SPELL_TYPE_STAFF:
  832.          for (tar_ch = world[ch->in_room].people ; 
  833.               tar_ch ; tar_ch = tar_ch->next_in_room)
  834.             if (tar_ch != ch) 
  835.                   spell_sanctuary(level,ch,tar_ch,0);
  836.          break;
  837.     default : 
  838.          log("Serious screw-up in sanctuary!");
  839.          break;
  840.     }
  841. }
  842.  
  843.  
  844. void cast_sleep( byte level, struct char_data *ch, char *arg, int type,
  845.   struct char_data *tar_ch, struct obj_data *tar_obj )
  846. {
  847.   switch (type) {
  848.     case SPELL_TYPE_SPELL:
  849.             spell_sleep(level, ch, tar_ch, 0);
  850.             break;
  851.     case SPELL_TYPE_POTION:
  852.             spell_sleep(level, ch, ch, 0);
  853.             break;
  854.     case SPELL_TYPE_SCROLL:
  855.          if(tar_obj) return;
  856.          if (!tar_ch) tar_ch = ch;
  857.          spell_sleep(level, ch, tar_ch, 0);
  858.          break;
  859.     case SPELL_TYPE_WAND:
  860.          if(tar_obj) return;
  861.          spell_sleep(level, ch, tar_ch, 0);
  862.          break;
  863.     case SPELL_TYPE_STAFF:
  864.          for (tar_ch = world[ch->in_room].people ; 
  865.               tar_ch ; tar_ch = tar_ch->next_in_room)
  866.             if (tar_ch != ch) 
  867.                   spell_sleep(level,ch,tar_ch,0);
  868.          break;
  869.     default : 
  870.          log("Serious screw-up in sleep!");
  871.          break;
  872.     }
  873. }
  874.  
  875.  
  876. void cast_strength( byte level, struct char_data *ch, char *arg, int type,
  877.   struct char_data *tar_ch, struct obj_data *tar_obj )
  878. {
  879.   switch (type) {
  880.     case SPELL_TYPE_SPELL:
  881.             spell_strength(level, ch, tar_ch, 0);
  882.             break;
  883.     case SPELL_TYPE_POTION:
  884.             spell_strength(level, ch, ch, 0);
  885.             break;
  886.     case SPELL_TYPE_SCROLL:
  887.          if(tar_obj) return;
  888.          if (!tar_ch) tar_ch = ch;
  889.          spell_strength(level, ch, tar_ch, 0);
  890.          break;
  891.     case SPELL_TYPE_STAFF:
  892.          for (tar_ch = world[ch->in_room].people ; 
  893.               tar_ch ; tar_ch = tar_ch->next_in_room)
  894.             if (tar_ch != ch) 
  895.                   spell_strength(level,ch,tar_ch,0);
  896.          break;
  897.     default : 
  898.          log("Serious screw-up in strength!");
  899.          break;
  900.     }
  901. }
  902.  
  903.  
  904. void cast_ventriloquate( byte level, struct char_data *ch, char *arg, int type,
  905.   struct char_data *tar_ch, struct obj_data *tar_obj )
  906. {
  907.     struct char_data *tmp_ch;
  908.     char buf1[MAX_STRING_LENGTH];
  909.     char buf2[MAX_STRING_LENGTH];
  910.     char buf3[MAX_STRING_LENGTH];
  911.  
  912.     if (type != SPELL_TYPE_SPELL) {
  913.         log("Attempt to ventriloquate by non-cast-spell.");
  914.         return;
  915.     }
  916.     for(; *arg && (*arg == ' '); arg++);
  917.     if (tar_obj) {
  918.         sprintf(buf1, "The %s says '%s'\n\r", fname(tar_obj->name), arg);
  919.         sprintf(buf2, "Someone makes it sound like the %s says '%s'.\n\r",
  920.           fname(tar_obj->name), arg);
  921.     }    else {
  922.         sprintf(buf1, "%s says '%s'\n\r", GET_NAME(tar_ch), arg);
  923.         sprintf(buf2, "Someone makes it sound like %s says '%s'\n\r",
  924.           GET_NAME(tar_ch), arg);
  925.     }
  926.  
  927.     sprintf(buf3, "Someone says, '%s'\n\r", arg);
  928.  
  929.     for (tmp_ch = world[ch->in_room].people; tmp_ch;
  930.       tmp_ch = tmp_ch->next_in_room) {
  931.  
  932.         if ((tmp_ch != ch) && (tmp_ch != tar_ch)) {
  933.             if ( saves_spell(tmp_ch, SAVING_SPELL) )
  934.                 send_to_char(buf2, tmp_ch);
  935.             else
  936.                 send_to_char(buf1, tmp_ch);
  937.         } else {
  938.             if (tmp_ch == tar_ch)
  939.                 send_to_char(buf3, tar_ch);
  940.         }
  941.     }
  942. }
  943.  
  944.  
  945.  
  946. void cast_word_of_recall( byte level, struct char_data *ch, char *arg, int type,
  947.   struct char_data *tar_ch, struct obj_data *tar_obj )
  948. {
  949.   switch (type) {
  950.     case SPELL_TYPE_SPELL:
  951.             spell_word_of_recall(level, ch, ch, 0);
  952.             break;
  953.     case SPELL_TYPE_POTION:
  954.             spell_word_of_recall(level, ch, ch, 0);
  955.             break;
  956.     case SPELL_TYPE_SCROLL:
  957.          if(tar_obj) return;
  958.          if (!tar_ch) tar_ch = ch;
  959.          spell_word_of_recall(level, ch, tar_ch, 0);
  960.          break;
  961.     case SPELL_TYPE_WAND:
  962.          if(tar_obj) return;
  963.          spell_word_of_recall(level, ch, tar_ch, 0);
  964.          break;
  965.     case SPELL_TYPE_STAFF:
  966.          for (tar_ch = world[ch->in_room].people ; 
  967.               tar_ch ; tar_ch = tar_ch->next_in_room)
  968.             if (tar_ch != ch) 
  969.                   spell_word_of_recall(level,ch,tar_ch,0);
  970.          break;
  971.     default : 
  972.          log("Serious screw-up in word of recall!");
  973.          break;
  974.     }
  975. }
  976.  
  977.  
  978.  
  979. void cast_summon( byte level, struct char_data *ch, char *arg, int type,
  980.   struct char_data *tar_ch, struct obj_data *tar_obj )
  981. {
  982.   switch (type) {
  983.     case SPELL_TYPE_SPELL:
  984.             spell_summon(level, ch, tar_ch, 0);
  985.             break;
  986.       default : 
  987.          log("Serious screw-up in summon!");
  988.          break;
  989.     }
  990. }
  991.  
  992.  
  993.  
  994. void cast_charm_person( byte level, struct char_data *ch, char *arg, int type,
  995.   struct char_data *tar_ch, struct obj_data *tar_obj )
  996. {
  997.   switch (type) {
  998.         case SPELL_TYPE_SPELL:
  999.             spell_charm_person(level, ch, tar_ch, 0);
  1000.             break;
  1001.       case SPELL_TYPE_SCROLL:
  1002.          if(!tar_ch) return;
  1003.          spell_charm_person(level, ch, tar_ch, 0);
  1004.          break;
  1005.       case SPELL_TYPE_STAFF:
  1006.          for (tar_ch = world[ch->in_room].people ; 
  1007.               tar_ch ; tar_ch = tar_ch->next_in_room)
  1008.             if (tar_ch != ch) 
  1009.                   spell_charm_person(level,ch,tar_ch,0);
  1010.          break;
  1011.       default : 
  1012.          log("Serious screw-up in charm person!");
  1013.          break;
  1014.     }
  1015. }
  1016.  
  1017.  
  1018.  
  1019. void cast_sense_life( byte level, struct char_data *ch, char *arg, int type,
  1020.   struct char_data *tar_ch, struct obj_data *tar_obj )
  1021. {
  1022.   switch (type) {
  1023.         case SPELL_TYPE_SPELL:
  1024.             spell_sense_life(level, ch, ch, 0);
  1025.             break;
  1026.       case SPELL_TYPE_POTION:
  1027.          spell_sense_life(level, ch, ch, 0);
  1028.          break;
  1029.       case SPELL_TYPE_STAFF:
  1030.          for (tar_ch = world[ch->in_room].people ; 
  1031.               tar_ch ; tar_ch = tar_ch->next_in_room)
  1032.             if (tar_ch != ch) 
  1033.                   spell_sense_life(level,ch,tar_ch,0);
  1034.          break;
  1035.       default : 
  1036.          log("Serious screw-up in sense life!");
  1037.          break;
  1038.     }
  1039. }
  1040.  
  1041.  
  1042. void cast_identify( byte level, struct char_data *ch, char *arg, int type,
  1043.   struct char_data *tar_ch, struct obj_data *tar_obj )
  1044. {
  1045.   switch (type) {
  1046.         case SPELL_TYPE_SCROLL:
  1047.             spell_identify(level, ch, tar_ch, tar_obj);
  1048.             break;
  1049.         default : 
  1050.             log("Serious screw-up in identify!");
  1051.             break;
  1052.     }
  1053. }
  1054.  
  1055.  
  1056. void cast_fire_breath( byte level, struct char_data *ch, char *arg, int type,
  1057.   struct char_data *tar_ch, struct obj_data *tar_obj )
  1058. {
  1059.   switch (type) {
  1060.     case SPELL_TYPE_SPELL:
  1061.             spell_fire_breath(level, ch, tar_ch, 0);
  1062.             break;   /* It's a spell.. But people can'c cast it! */
  1063.       default : 
  1064.          log("Serious screw-up in firebreath!");
  1065.          break;
  1066.     }
  1067. }
  1068.  
  1069. void cast_frost_breath( byte level, struct char_data *ch, char *arg, int type,
  1070.   struct char_data *tar_ch, struct obj_data *tar_obj )
  1071. {
  1072.   switch (type) {
  1073.     case SPELL_TYPE_SPELL:
  1074.             spell_frost_breath(level, ch, tar_ch, 0);
  1075.             break;   /* It's a spell.. But people can'c cast it! */
  1076.       default : 
  1077.          log("Serious screw-up in frostbreath!");
  1078.          break;
  1079.     }
  1080. }
  1081.  
  1082. void cast_acid_breath( byte level, struct char_data *ch, char *arg, int type,
  1083.   struct char_data *tar_ch, struct obj_data *tar_obj )
  1084. {
  1085.   switch (type) {
  1086.     case SPELL_TYPE_SPELL:
  1087.             spell_acid_breath(level, ch, tar_ch, 0);
  1088.             break;   /* It's a spell.. But people can'c cast it! */
  1089.       default : 
  1090.          log("Serious screw-up in acidbreath!");
  1091.          break;
  1092.     }
  1093. }
  1094.  
  1095. void cast_gas_breath( byte level, struct char_data *ch, char *arg, int type,
  1096.   struct char_data *tar_ch, struct obj_data *tar_obj )
  1097. {
  1098.   switch (type) {
  1099.     case SPELL_TYPE_SPELL:
  1100.         for (tar_ch = world[ch->in_room].people ; 
  1101.                 tar_ch ; tar_ch = tar_ch->next_in_room)
  1102.             if (tar_ch != ch) 
  1103.                 spell_gas_breath(level,ch,tar_ch,0);
  1104.          break;
  1105.             /* THIS ONE HURTS!! */
  1106.       default : 
  1107.          log("Serious screw-up in gasbreath!");
  1108.          break;
  1109.     }
  1110. }
  1111.  
  1112. void cast_lightning_breath( byte level, struct char_data *ch, char *arg, int type,
  1113.   struct char_data *tar_ch, struct obj_data *tar_obj )
  1114. {
  1115.   switch (type) {
  1116.     case SPELL_TYPE_SPELL:
  1117.             spell_lightning_breath(level, ch, tar_ch, 0);
  1118.             break;   /* It's a spell.. But people can'c cast it! */
  1119.       default : 
  1120.          log("Serious screw-up in lightningbreath!");
  1121.          break;
  1122.     }
  1123. }
  1124.