mgc.c

./mudd/src/mgc.c · 21.1 KB

From the archive emlen.tar.gz

Download the archive   « Back to the archive contents

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "mud.h"

void say_spell (CHAR_DATA * ch, int sn);
void 
renew_affect (CHAR_DATA * ch, AFFECT_DATA * aff)
{
  AFFECT_DATA *paf;
  AFFECT_DATA pasaf;
  bool found;
  int i;
  found = FALSE;
  bzero (&pasaf, sizeof (pasaf));
  pasaf.type = aff->type;
  pasaf.duration = aff->duration;
  pasaf.location = aff->location;
  pasaf.modifier = aff->modifier;
  for (i = 0; i <  4; i++)
    pasaf.aff[i] = aff->aff[i];
  for (paf = ch->affected; paf != NULL; paf = paf->next)
    {
      if (paf->type == aff->type && paf->location == aff->location)
	{
	  paf->duration = aff->duration;
	  found = TRUE;
	}
    }
  if (!found)
    affect_to_char (ch, &pasaf);
  return;
}


void 
do_mana (CHAR_DATA * ch, char *argy)
{
  char bufff[500];
  int mana[MANA_TYPES];
  int level[MANA_TYPES];
  int i, j;
  int nat_level = 0;
  int bonus = 0;

 DEFINE_COMMAND ("mana", do_mana, POSITION_DEAD, 0, LOG_NORMAL, "Allows you to see your mana in different element types, and max spell levels you can cast.")
 
    if (IS_MOB (ch))
    return;
  
 bonus = (is_member(ch, GUILD_WIZARD) ? 1 : 0)+
   (is_member(ch, GUILD_HEALER) ? 1 : 0)+
   (is_member(ch, GUILD_MYSTIC) ? 1 : 0)+
   (is_member(ch, GUILD_SORCERER) ? 1 : 0);
 if (IS_AUGMENTED(ch, AUG_CHANNEL))
   {
     bonus = bonus *3/2;
     bonus ++;
   }
  nat_level = (get_stat (ch, INT) + get_stat (ch, WIS) + get_stat (ch,
  WIL)) / 3 + bonus + (ch->pcdata->remort_times+1)/2;

 /* Set up the base case. */
 if (nat_level > 35) nat_level = 35;
 if (ch->pcdata->n_mana < 0) ch->pcdata->n_mana = 0;
 for (i = 0; i < MANA_TYPES; i++)
   {
     mana[i] = ch->pcdata->n_mana;
     level[i] = 0;
   }
 for (i = 0; i < MAX_HOLD; i++)
   {
     if (ch->hold[i] && ch->hold[i]->pIndexData->item_type == ITEM_GEM)
       {
	 for (j = 0;mana_data[j].flagname != 0; j++)
	   {
	     if (IS_SET(((I_GEM *)ch->hold[i]->more)->gem_type, mana_data[j].flagname))
	       {
		 mana[j] += ((I_GEM *)ch->hold[i]->more)->mana_now;
		 level[j] = UMAX(level[j],((I_GEM *)ch->hold[i]->more)->max_level);
		 
	       }
	   }
       }
   }
 


 for (i = 0; i < MANA_TYPES; i++)
   {
     int lev;
     if (nat_level < 31)
       lev = nat_level + UMIN(nat_level, level[i]);
     else lev = nat_level + UMIN (level[i], nat_level*(nat_level - 25)/5);
           
     sprintf(bufff, "%7s mana available is : [%s%3d\x1b[0;37m] (Max spell level is %s%2d\x1b[0;37m).\n\r",  mana_data[i].how_it_appears, mana_data[i].color, mana[i], mana_data[i].color, lev);
     send_to_char(bufff, ch);
   }
 return;
}



int 
find_char_mana (CHAR_DATA * ch, SPELL_DATA *spell, bool ranged)
{
  SINGLE_OBJECT *gem;
  int level = 0;
  int i, j;
  int mana;
  int addlevel = 0;
  I_GEM *gm;
  if (IS_MOB(ch) || LEVEL(ch) >= 100) return 500;
  level = (is_member(ch, GUILD_WIZARD) ? 1 : 0)+
    (is_member(ch, GUILD_HEALER) ? 1 : 0)+
    (is_member(ch, GUILD_SORCERER) ? 1 : 0)+
    (is_member(ch, GUILD_MYSTIC) ? 1 : 0);
  if (IS_AUGMENTED(ch, AUG_CHANNEL))
    {
      level = level*3/2;
      level++;
    }
   level += ((get_stat (ch, INT) + get_stat(ch, WIS)) / 2) +(ch->pcdata->remort_times+1)/2;
       
  if (ch->pcdata->n_mana < 0) ch->pcdata->n_mana = 0;
  mana = ch->pcdata->n_mana;
  
  if (!IS_SET (spell->spell_bits, SPELL_MULTIMANA))
    {
      for (i = 0; i < MAX_HOLD; i++)
	{
	  if ((gem = ch->hold[i]) != NULL &&
	      gem->pIndexData->item_type == ITEM_GEM)
	    {
	      gm = (I_GEM *)gem->more;
	      if (IS_SET(gm->gem_type, spell->mana_type))
		{	 
		  addlevel = UMAX(addlevel, gm->max_level);
		  mana += gm->mana_now;
		}
	    }
	}
      if (level < 31)
	addlevel = UMIN (addlevel, level);
      else 
	addlevel = UMIN (addlevel, level*(level-25)/5);
      level += addlevel;
      if (level < spell->spell_level)
	return 0;
      return mana;
    }
  else
    {
      int multimana_levels[MANA_TYPES];
      for (j = 0; j < MANA_TYPES; j++)
	{
	  multimana_levels[j] = 0;
	}
      for (i = 0; i < MAX_HOLD; i++)
	{
	  if ((gem = ch->hold[i]) != NULL &&
	      gem->pIndexData->item_type == ITEM_GEM)
	    {
	      gm = (I_GEM *)gem->more;
	      for (j = 0; j < MANA_TYPES; j++)
		{
		  if (spell->multi_mana_level[j] > 0)
		    {
		      multimana_levels[j] = UMAX (multimana_levels[j], gm->max_level);
		      mana += gm->mana_now;
		    }
		}
	    }
	}
      for (i = 0; i < MANA_TYPES; i++)
	{
	  if (spell->multi_mana_level[i] > 0 &&
	      multimana_levels[i] < (spell->multi_mana_level[i]))
	    return 0;
	}
      return mana;
    }
  return 0;
}


void 
say_spell (CHAR_DATA * ch, int sn)
{
  char buf[STD_LENGTH];
  char buf2[STD_LENGTH];
  CHAR_DATA *rch;
  char *pName;
  int iSyl;
  int length;
  SPELL_DATA *spell;
  struct syl_type
    {
      char *old;
      char *new;
    }
   ;
  static const struct syl_type syl_table[] =
  {
    {
      " ", " "
    }
    ,
    {
      "ar", "zad"
    }
    ,
    {
      "au", "lju"
    }
    ,
    {
      "bless", "ufc"
    }
    ,
    {
      "fire", "ignis"
    }
    ,
    {
      "god", "deux"
    }
    ,
    {
      "in the", "ex"
    }
    ,
    {
      "machine", "machina"
    }
    ,
    {
      "blind", "plina"
    }
    ,
    {
      "bur", "gna"
    }
    ,
    {
      "cu", "laq"
    }
    ,
    {
      "de", "byn"
    }
    ,
    {
      "en", "oog"
    }
    ,
    {
      "light", "solg"
    }
    ,
    {
      "lo", "qg"
    }
    ,
    {
      "mor", "fel"
    }
    ,
    {
      "move", "ewa"
    }
    ,
    {
      "ness", "kuj"
    }
    ,
    {
      "ning", "mnab"
    }
    ,
    {
      "per", "dew"
    }
    ,
    {
      "balefire", "Pika......CHHUUUUUUUUU!!!"
    }
    ,
    {
      "ra", "jih"
    }
    ,
    {
      "re", "cus"
    }
    ,
    {
      "son", "bru"
    }
    ,
    {
      "tect", "ira"
    }
    ,
    {
      "tri", "fel"
    }
    ,
    {
      "ven", "xaq"
    }
    ,
    {
      "a", "e"
    }
    ,
    {
      "b", "d"
    }
    ,
    {
      "c", "w"
    }
    ,
    {
      "d", "j"
    }
    ,
    {
      "e", "k"
    }
    ,
    {
      "f", "e"
    }
    ,
    {
      "g", "m"
    }
    ,
    {
      "h", "y"
    }
    ,
    {
      "i", "s"
    }
    ,
    {
      "j", "i"
    }
    ,
    {
      "k", "p"
    }
    ,
    {
      "l", "x"
    }
    ,
    {
      "m", "a"
    }
    ,
    {
      "n", "r"
    }
    ,
    {
      "o", "u"
    }
    ,
    {
      "p", "g"
    }
    ,
    {
      "q", "z"
    }
    ,
    {
      "r", "n"
    }
    ,
    {
      "s", "l"
    }
    ,
    {
      "t", "d"
    }
    ,
    {
      "u", "h"
    }
    ,
    {
      "v", "b"
    }
    ,
    {
      "w", "o"
    }
    ,
    {
      "x", "a"
    }
    ,
    {
      "y", "i"
    }
    ,
    {
      "z", "b"
    }
    ,
    {
      "", ""
    }
  }
   ;
  if ((spell = skill_lookup (NULL, sn)) == NULL)
    return;
  buf[0] = '\0';
  for (pName = spell->spell_name; *pName != '\0'; pName += length)
    {
      for (iSyl = 0; (length = strlen (syl_table[iSyl].old)) != 0; iSyl++)
	{
	  if (!str_prefix (syl_table[iSyl].old, pName))
	    {
	      strcat (buf, syl_table[iSyl].new);
	      break;
	    }
	}
      if (length == 0)
	length = 1;
    }
  sprintf (buf2, "$n utters the words, '%s'", buf);
  sprintf (buf, "$n utters the words, '%s'", spell->spell_name);
  for (rch = ch->in_room->people; rch; rch = rch->next_in_room)
    {
      if (rch != ch)
	{
	  if (IS_MOB (rch))
	    act (buf, ch, NULL, rch, TO_VICT);
	  else if (rch->pcdata->learned[sn] > 30)
	    act (buf, ch, NULL, rch, TO_VICT);
	  else
	    act (buf2, ch, NULL, rch, TO_VICT);
	}
    }
  return;
}

/*
   * Compute a saving throw.
   * Negative apply's make saving throw better.
 */
bool 
saves_spell (int level, CHAR_DATA * victim)
{
  int save;
  save = 40 + (((LEVEL (victim) - level) +
(victim->pcdata->saving_throw)));
  if (IS_AUGMENTED(victim, AUG_MENTAL_ARMOR)) save += 10;
  if (IS_AFF(victim, MINDSHIELD)) save += 15;
  save = URANGE (10, save, 90);
  return number_percent () < save;
}

int 
mana_now (CHAR_DATA * ch)
{
  int mana = 0;
  int i;
  if (IS_MOB (ch)) return 500;
  if (ch->pcdata->n_mana < 0) ch->pcdata->n_mana = 0;
  mana = ch->pcdata->n_mana;
  for (i = 0; i < MAX_HOLD; i++)
    {
      if (ch->hold[i] && ch->hold[i]->pIndexData->item_type == ITEM_GEM)
	mana += ((I_GEM *)ch->hold[i]->more)->mana_now;
    }
  return mana;
}

void 
take_mana_char (CHAR_DATA * ch, int mana, SPELL_DATA *spell)
{
  
  SINGLE_OBJECT *gem;
  int i, j;
  I_GEM *gm;
  if (IS_MOB (ch))
    return;
  
  if (ch->pcdata->n_mana < 0) ch->pcdata->n_mana = 0;
  if (ch->pcdata->n_mana >= mana)
    {
      ch->pcdata->n_mana -= mana;
      return;
    }
  else
    {
      mana -= ch->pcdata->n_mana;
      ch->pcdata->n_mana = 0;
      

      for (i = 0; i < MAX_HOLD && mana > 0; i++)
	{ 
	  if ((gem = ch->hold[i]) != NULL && gem->pIndexData->item_type == ITEM_GEM)
	    {
	      gm = (I_GEM *)gem->more;
	      if (!IS_SET (spell->spell_bits, SPELL_MULTIMANA))
		{
		  if (IS_SET (gm->gem_type, spell->mana_type))
		    {
		      if (mana <= gm->mana_now)
			{
			  gm->mana_now -= mana;
			  break;
			}
		      else
			{
			  mana -= gm->mana_now;
			  gm->mana_now = 0;
			}
		    }
		}
	      else 

		/* For multmana spells we go down gems sucking out mana
		   from each one in turn as long as that particular gem is
		   one of the types of gems required for casting the spell. */
		{
		  for (j = 0; j < MANA_TYPES && mana > 0; j++)
		    {
		      if (spell->multi_mana_level[j] > 0 &&
			  IS_SET (gm->gem_type, mana_data[j].flagname))
			{
			  if (mana <= gm->mana_now)
			    {
			      gm->mana_now -= mana;
			      mana = 0;
			      break;
			    }
			  else
			    {
			      mana -= gm->mana_now;
			      gm->mana_now = 0;
			    }
			}
		    }
		}
	    }
	}
    }
  return;
}


char *target_name;
void 
do_cast (CHAR_DATA * ch, char *argy)
{
  SINGLE_OBJECT *obj;
  int mana;
  CHAR_DATA *victim;
  bool ranged = FALSE;

  SPELL_DATA *spell;
  char arg1[SML_LENGTH];
  char arg2[SML_LENGTH];
  void *vo;
  int sn;
  DEFINE_COMMAND ("cast", do_cast, POSITION_FIGHTING, 0, LOG_NORMAL, "Allows you to cast a spell.  Format is: cast 'spellname' <target>.")

  area_spell = FALSE;
  
  if (!actually_doing)
    {
      if (IS_MOB (ch))
	return;
      
      if (IS_AFF(ch, REFLECT))
	{
	  affect_strip_bits (ch, AFF, REFLECT);
	}
      
      if (ch->pcdata->tickcounts > 5 && (FIGHTING (ch) != NULL))
	{
	  send_to_char ("You can't cast another spell this soon after your last one!\n\r", ch);
	  return;
	} 
      if (ch->position == POSITION_CASTING)
	{
	  send_to_char ("You are already casting a spell!\n\r", ch);
	  return;
	}
    }
  
  if (ch->position == POSITION_GROUNDFIGHTING)
    {
      send_to_char ("You can't concentrate enough! You are groundfighting!\n\r", ch);
      return;
    }
  if (ch->position == POSITION_BASHED)
    {
      send_to_char ("You can't cast while you are sitting on your butt!\n\r", ch);
      return;
    }
  if (strlen (argy) > 140)
    return;
  
  target_name = one_argy (argy, arg1);

  one_argy (target_name, arg2);
  
  if (IS_MOB (ch) && ch->desc == NULL)
    return;
  
  if (IS_SET (ch->in_room->room_flags, ROOM_NOMAGIC) && LEVEL(ch) < MAX_LEVEL)
    {
      send_to_char ("The ground absorbs your magical incantations, preventing you from casting!\n\r", ch);
      return;
    }
  
  if ((spell = skill_lookup (arg1, -1)) == NULL)
    {
      send_to_char("What spell?\n\r", ch);
      return;
    }

  if(IS_PLAYER(ch) && (ch->pcdata->learned[spell->gsn] == 0))
    {
      send_to_char ("You don't know that spell.\n\r", ch);
      return;
    }

  if (IS_SET (spell->spell_bits, SPELL_AREA))
    {
      area_spell = TRUE;
      target_name = one_argy(target_name, arg1);
    }

  if (IS_SET (spell->spell_bits, SPELL_NOCAST))
    {
       send_to_char ("This spell is not castable.\n\r", ch);
       return;
     }
  
  
  if (spell->slot != 1)
    {
      send_to_char ("That is not a spell!\n\r", ch);
      return;
    }
  
  if (ch->position < spell->position && ch->position != POSITION_MEDITATING)
    {
      send_to_char ("You can't concentrate enough.\n\r", ch);
      return;
    }
  switch (spell->spell_type)
    {
    default:
      bug ("Do_cast: bad target for sn %d.", spell->gsn);
      return;
    case TAR_IGNORE:
      mana = spell->mana;
      vo = NULL;
      break;
    case TAR_CHAR_OFFENSIVE:
      {
	if (!actually_doing && !FIGHTING(ch) && IS_HURT(ch, FEAR))
	  { 
	    send_to_char("You are too afraid to initiate combat!\n\r", ch);
	    return;
	  }
	
	victim = NULL;
	if (arg2[0] == '\0')
	  {
	    if  ((victim = FIGHTING (ch)) == NULL)
	      {
		send_to_char ("Cast the spell on whom?\n\r", ch);
		return;
	      }
	  }
	else
	  {
	    if ((victim = get_char_room_near (ch, ch->in_room, 3, arg2)) == NULL)
	      {
		send_to_char ("They aren't here.\n\r", ch);
		return;
	      }
	    if (victim != ch)
	      {
		if (ch->in_room == victim->in_room)
		  ranged = FALSE;
		else
		  ranged = TRUE;
	      }
	  }
	if (!IS_SET (spell->spell_bits, SPELL_RANGED) && (ranged &&
is_member(ch, GUILD_WIZARD) < 3))
	  {
	    send_to_char("You must be a Tier 3 Wizard to range spells!\n\r", ch);
	    return;
	  } 
	if (ch == victim)
	  {
	    send_to_char ("You can't do that to yourself.\n\r", ch);
	    return;
	  }
	mana = (spell->mana);
	mana -= (mana * is_member (ch, GUILD_WIZARD)/20);
	vo = (CHAR_DATA *) victim;
      }
    break;
    case TAR_CHAR_DEFENSIVE:
    case TAR_CHAR_SELF: 
      {
	if (IS_SET(spell->spell_bits, SPELL_HEALS_DAM |
		   SPELL_REMOVES_BIT | SPELL_ADD_MOVE))
	  {
	    victim = NULL;
	    if (arg2[0] == '\0')
	      victim = ch; 
	    else
	      {
		if ((victim = get_char_room_near (ch, ch->in_room, 3, arg2)) == NULL)
		  {
		    send_to_char ("They aren't here.\n\r", ch);
		    return;
		  }
	 	if (ch != victim)
		  {
		    if (ch->in_room == victim->in_room)
		      ranged = FALSE;
		    else
		      ranged = TRUE;
		  }
	      }
	    if (ranged && spell->spell_type == TAR_CHAR_SELF)
	      {
		send_to_char("You cannot cast ranged self only spells.\n\r", ch);
		return;
	      }
	    if (spell->spell_type == TAR_CHAR_SELF &&
		    ch != victim)
	      { 
		send_to_char("You cannot self-only spells on other people.\n\r", ch);
		return;
	      }
	    mana = spell->mana;
	    mana -= (mana * is_member (ch, GUILD_HEALER)/20);
	    
	  }
	else /* These spells are not ranged. */
	  {
	    victim = NULL;
	    if (arg2[0] == '\0')
	      victim = ch;
	    else if ((victim = get_char_room (ch, arg2)) == NULL)
	      {
		send_to_char ("They aren't here.\n\r", ch);
		return;
	      }
	    mana = spell->mana;
	    mana -= (mana * is_member (ch, GUILD_SORCERER)/20);
	    if (spell->spell_type == TAR_CHAR_SELF)
	      {
		if (ch != victim)
		  {
		    send_to_char("You cannot cast self-only spells on other people.\n\r", ch);
		    return;
		  } 

	      }
	  }
	vo = (CHAR_DATA *) victim;
      }
    break;
    case TAR_OBJ_INV:
      {
	if (arg2[0] == '\0')
	  {
	    send_to_char ("What should the spell be cast upon?\n\r", ch);
	    return;
	  }
	if ((obj = get_obj_inv (ch, arg2)) == NULL)
	  {
	    send_to_char ("You are not carrying that.\n\r", ch);
	    return;
	  }
	mana = spell->mana;
	vo = (SINGLE_OBJECT *) obj;
      }
    break;
    } 
  
  if (IS_PLAYER (ch) && LEVEL(ch) < MAX_LEVEL)
    {
      if (find_char_mana (ch, spell, ranged) < mana)
	{
	  switch (spell->mana_type)
	    {
	    default:
	      send_to_char ("You don't have enough mana power to cast that spell.\n\r", ch);
	      break;
	    case MANA_FIRE:
	      send_to_char ("You don't have enough mana power to contain the Fire.\n\r", ch);
	      break;
	    case MANA_AIR:
	      send_to_char ("You require more mana power for Air.\n\r", ch);
	      break;
	    case MANA_WATER:
	      send_to_char ("You don't have enough mana power for Water.\n\r", ch);
	      break;
	    case MANA_EARTH:
	      send_to_char ("Your Earth mana power is insufficient.\n\r", ch);
	      break;
	    case MANA_SPIRIT:
	      send_to_char ("Your Spirit mana power is insufficient.\n\r", ch);
	      break;
	    }		  
	  return;
	}
      else
	{ 
	  if (LEVEL (ch) < (spell->spell_level))
	    {
	      send_to_char ("You aren't powerful enough to cast that kind of spell!\n\r", ch);
	      return;
	    }
	}
    }
  if (strlen (argy) > 140)
    return;
  
  if (!actually_doing)
    {
      if (ch->desc) 
	ch->desc->repeat = 0;
      NEW_POSITION(ch, POSITION_CASTING);
      act ("You begin to utter some strange incantations...", ch, NULL, ch, TO_CHAR);
      act("$N begins to utter some strange incantations...", ch, NULL, ch, TO_ROOM);
      
      check_temp (ch);
      strcpy (ch->pcdata->temp->temp_string, argy);
      if (IS_PLAYER (ch) && (LEVEL (ch) < 100 || IS_SET (ch->pcdata->act2, PLR_HOLYLAG)))
	{
	  int bonus = 
	    is_member(ch, GUILD_MYSTIC) +
	    is_member(ch, GUILD_WIZARD) +
	    is_member(ch, GUILD_HEALER) +
	    is_member(ch, GUILD_SORCERER) +
	    (IS_AUGMENTED(ch, AUG_HEAD_INT) ? 3 : 0) +
	    (IS_AUGMENTED(ch, AUG_HEAD_WIS) ? 3 : 0) +
	    (IS_AUGMENTED(ch, AUG_CONCENTRATION) ? 7 : 0) +
	    ch->pcdata->remort_times;
	  ch->pcdata->tickcounts = ((spell->casting_time) * (100-bonus))/100;
	  if (race_info[ch->pcdata->race].parts[2] > 1)
	    ch->pcdata->tickcounts -= ch->pcdata->tickcounts/4; 
	}
      return;
    }
  
  if (ch->position != POSITION_CASTING)
    {
      send_to_char("Ouch! You just lost your concentration!\n\r", ch);
      return;
    }
  
  

  if (victim != NULL && spell->spell_type == TAR_CHAR_OFFENSIVE &&
      is_safe (ch, victim))
    {
      send_to_char ("You are in a safe zone. No casting nasty spells like that!\n\r", ch);
      return;
    }
  
  if( IS_PLAYER(ch) && (LEVEL(ch) < 100) && 
      (number_range(1,125) >
       (ch->pcdata->learned[spell->gsn] +
	is_member (ch, GUILD_WIZARD) +
	is_member (ch, GUILD_HEALER) + 
	is_member (ch, GUILD_MYSTIC) +
	is_member (ch, GUILD_SORCERER) +
	(IS_AUGMENTED(ch, AUG_CONCENTRATION) ? 7 :0)
	+ (IS_AUGMENTED(ch, AUG_HEAD_INT) ? 3 : 0)
	+ (IS_AUGMENTED(ch, AUG_HEAD_WIS) ? 3 : 0))))
    {
      send_to_char ("You lost your concentration.\n\r", ch);
      take_mana_char (ch, mana / 2, spell);
    }
  else
    {
      say_spell (ch, sn);
      if (IS_PLAYER(ch) && LEVEL(ch) < IMM_LEVEL)
	{
	  int i;
	  if (spell->spell_lag > 0 && ch->pcdata->no_quit > 0)
	    {
	      char buf[200];
	      sprintf(buf, "You must wait %d hours before casting %s!\n\r", ch->pcdata->no_quit, spell->spell_name);
	      send_to_char(buf, ch);
	      return;
	    }
          take_mana_char (ch, mana, spell); 
	  if (number_percent() < spell->fail_chance)
	    {
	      send_to_char("The spell fails to work..\n\r", ch);
	      return;
	    }
	  if (ch->pcdata->no_quit_pk > 0 && number_percent() < spell->pk_fail_chance)
	    {
	      send_to_char("The spell failed...\n\r", ch);
	      return;
	    }
	  for (i = 0; i < NUM_GUILDS; i++)
	    {
	      if (spell->guilds[i] > ch->pcdata->guilds[i])
		{
		  send_to_char("You do not have the proper guilds to cast this!\n\r", ch);
		  return;
		}
	    }
	}
      general_spell (spell, LEVEL (ch), ch, vo);
      if (victim && victim->data_type == 50) 
	{
	  return;
	}
    }
  if (spell->spell_type == TAR_CHAR_OFFENSIVE
      && victim != ch
      && MASTER (victim) != ch)
    {
      CHAR_DATA *vch;
      CHAR_DATA *vch_next;
      for (vch = ch->in_room->people; vch; vch = vch_next)
	{
	  vch_next = vch->next_in_room;
	  if (victim == vch && FIGHTING (victim) == NULL)
	    {
	      multi_hit (victim, ch, TYPE_UNDEFINED);
	      break;
	    }
	}
    }
return;
}

/*
   * Cast spells at targets using a magical object.
 */
void 
obj_cast_spell (int sn, int level, CHAR_DATA * ch, CHAR_DATA * victim, SINGLE_OBJECT * obj)
{
  void *vo;
  SPELL_DATA *spell;
  if (IS_SET (ch->in_room->room_flags, ROOM_NOMAGIC))
    {
      send_to_char ("The ground seems to absorb the spell...!\n\r", ch);
      return;
    }
  if (sn <= 0 || (spell = skill_lookup (NULL, sn)) == NULL)
    return;
  switch (spell->spell_type)
    {
    default:
      bug ("Obj_cast_spell: bad target for sn %d.", sn);
      return;
    case TAR_IGNORE:
      vo = NULL;
      break;
    case TAR_CHAR_OFFENSIVE:
      if (victim == NULL)
	victim = FIGHTING (ch);
      if (victim == NULL)
	{
	  send_to_char ("You can't do that.\n\r", ch);
	  return;
	}
      if (IS_PLAYER (ch))
	{
	  if (ch->pcdata->tickcounts > 2)
	    {
	      send_to_char ("The wand refuses to respond!\n\r", ch);
	      return;
	    }
	}
      vo = (void *) victim;
      break;
    case TAR_CHAR_DEFENSIVE:
      if (victim == NULL)
	victim = ch;
      vo = (void *) victim;
      break;
    case TAR_CHAR_SELF:
      vo = (void *) ch;
      break;
    case TAR_OBJ_INV:
      if (obj == NULL)
	{
	  send_to_char ("You can't do that.\n\r", ch);
	  return;
	}
      vo = (void *) obj;
      break;
    }
  target_name = "";
  general_spell (spell, level, ch, vo);
  if (IS_PLAYER (ch))
    ch->pcdata->tickcounts = spell->casting_time/2 +10;
  if (spell->spell_type == TAR_CHAR_OFFENSIVE
      && victim != ch
      && MASTER (victim) != ch)
    {
      CHAR_DATA *vch;
      CHAR_DATA *vch_next;
      for (vch = ch->in_room->people; vch; vch = vch_next)
	{
	  vch_next = vch->next_in_room;
	  if (victim == vch && FIGHTING (victim) == NULL)
	    {
	      check_fgt (victim);
	      multi_hit (victim, ch, TYPE_UNDEFINED);
	      victim->fgt->fighting = ch;
	      NEW_POSITION(victim, POSITION_FIGHTING);
	      break;
	    }
	}
    }
  return;
}









Site Stats

Snippets: 1791
Codebases: 571