sedit.c

./mudd/src/sedit.c · 70.3 KB

From the archive emlen.tar.gz

Download the archive   « Back to the archive contents

/*Spell editor */
#include <sys/types.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "mud.h"
#define KEY( literal, field, value ) if ( !str_cmp( buf, literal ) ) {field=value; fMatch=TRUE;}

static bool prereq_count[SKILL_COUNT];
/* This function places all spells in the correct hashed spell list by
   name spots... called whenever a spell name is changed :) */



void update_prereq (void)
{
  SPELL_DATA *spell;
  SPELL_DATA *prereq;
  int i, j, counter;
  
  /* The idea here is to set up something so that its alot faster
     doing the bigass prereq trees. */

  for (i = 0; i < SPELL_HASH; i++)
    {
      for (spell = spell_list[i]; spell != NULL; spell = spell->next)
	{
	  
	  if ((prereq = skill_lookup(spell->prereq_1, -1)) != NULL)
	    {
	      spell->pre1 = prereq;
	    }
	  if ((prereq = skill_lookup(spell->prereq_2, -1)) != NULL)
	    {
	      spell->pre2 = prereq;
	    }
	  
	}
    }

  /* This is so that we dont have to recalc the number of prereqs for
     any given skill each time it asks for it. */

  for (i = 0; i < SPELL_HASH; i++)
    {
      for (spell = spell_list[i]; spell != NULL; spell = spell->next)
	{
	  for (j = 0; j < SKILL_COUNT; j++)
	    {
	      prereq_count[j] = FALSE;
	    }
	  check_prereq(spell);
	  counter = 0;
	  for (j = 0; j < 300; j++)
	    {
	      if (prereq_count[j] == TRUE)
		{
		  counter++;
		}
	    }
	  spell->num_prereqs[1] = counter;
	  counter = 0;
	  for (j = 300; j < 400; j++)
	    {
	      if (prereq_count[j] == TRUE)
		{
		  counter++;
		}
	    }
	  spell->num_prereqs[2] = counter;
	  counter = 0;
	  for (j = 490; j < SKILL_COUNT; j++)
	    {
	      if (prereq_count[j] == TRUE)
		{
		  counter++;
		}
	    }
	  spell->num_prereqs[0] = counter;
	  
        /* Now we set up the check for whether or not we make a vert line
           to the second prereq in the spell tree. */
          if(spell->pre1 && spell->pre2 && spell->pre1 != spell->pre2)
             {
                spell->go_to_second = check_prereq_depth(spell,spell->pre2);
             }
           else
            spell->go_to_second = FALSE;
	}
    }
  return;
  
}

void check_prereq(SPELL_DATA *spell)
{
  prereq_count[spell->gsn] = TRUE;
  if (spell->pre1 != NULL && !prereq_count[spell->pre1->gsn])
    check_prereq(spell->pre1);
  if (spell->pre2 != NULL && !prereq_count[spell->pre2->gsn])
    check_prereq(spell->pre2);
  return;
}




void 
update_name_hash (void)
{
  SPELL_DATA *spell;
  int i;
  bzero (spell_list_2, sizeof (spell_list_2));
  for (i = 0; i < SPELL_HASH; i++)
    {
      for (spell = spell_list[i]; spell != NULL; spell = spell->next)
	{
	  spell->next_a = spell_list_2[UPPER (spell->spell_name[0]) % SPELL_HASH];
	  spell_list_2[UPPER (spell->spell_name[0]) % SPELL_HASH] = spell;
	}
    }
  return;
}

/* This function is called when gsn's are changed... for instance,
   right at bootup when it assigns a high gsn to a skill... */
void 
update_gsn_hash (void)
{
  SPELL_DATA *spell;
  int i;
  bzero (spell_list, sizeof (spell_list));
  for (i = 0; i < SPELL_HASH; i++)
    {
      for (spell = spell_list_2[i]; spell != NULL; spell = spell->next_a)
	{
	  spell->next = spell_list[spell->gsn % SPELL_HASH];
	  spell_list[spell->gsn % SPELL_HASH] = spell;
	}
    }
  return;
}

bool 
is_digit (char test)
{
  if (test >= '0' && test <= '9')
    return TRUE;
  else
    return FALSE;
}

/* SPELLS/SKILLS are now hashed by name and spell gsn... fast lookups */
SPELL_DATA *
skill_lookup (char *txt, int sn)
{
  SPELL_DATA *spell;
  if (sn < 0 && !txt)
    return NULL;
  if (sn < 0)
    {
      for (spell = spell_list_2[UPPER (txt[0]) % SPELL_HASH]; spell != NULL; spell = spell->next_a)
	{
	  if (!str_prefix (txt, spell->spell_name))
	    return spell;
	}
      return NULL;
    }
  else
    for (spell = spell_list[sn % SPELL_HASH]; spell != NULL; spell = spell->next)
      {
	if (spell->gsn == sn)
	  return spell;
      }
  return NULL;
}

void 
fix_skillst (void)
{
  gsn_invest = lookup_gsn ("Invest");
  gsn_patch = lookup_gsn ("Patch");
  gsn_detrap = lookup_gsn ("Detrap");
  gsn_locate_trap = lookup_gsn ("Locate Traps");
  gsn_awareness = lookup_gsn ("Alertness");
  gsn_block = lookup_gsn ("Block");
   gsn_mine = lookup_gsn ("Mine");
   gsn_destroy = lookup_gsn ("Destroy");
  gsn_forge = lookup_gsn ("Forge");
  gsn_graft = lookup_gsn ("Graft");
  gsn_weave = lookup_gsn ("Weave");
  gsn_stitch = lookup_gsn ("Stitch");
  gsn_fire = lookup_gsn ("Siege Fire");
  gsn_lore = lookup_gsn ("Lore");
  gsn_brew = lookup_gsn ("Brew"); 
  gsn_enchant = lookup_gsn ("Enchant");
  gsn_chop = lookup_gsn ("Chop");
  gsn_shoot = lookup_gsn ("Shoot");
  gsn_ranged = lookup_gsn ("Ranged");
  gsn_build = lookup_gsn ("Build");
  gsn_alchemy = lookup_gsn ("Alchemy");
  gsn_throw = lookup_gsn ("Throw");
  gsn_critical = lookup_gsn ("Critical");
  gsn_skin = lookup_gsn ("Skin");
  gsn_tanning = lookup_gsn ("Tanning");
  gsn_riding = lookup_gsn ("Riding");
  gsn_flail = lookup_gsn ("Flail");
  gsn_warcry = lookup_gsn ("Warcry");
  gsn_circle = lookup_gsn ("Circle");
  gsn_penetration = lookup_gsn ("Armor Penetration");
  gsn_grapple = lookup_gsn ("Grapple");
  gsn_trapset = lookup_gsn ("Trapset");
  gsn_swim = lookup_gsn ("Swim");
  gsn_butcher = lookup_gsn ("Butcher");
  gsn_backstab = lookup_gsn ("Backstab");
  gsn_dodge = lookup_gsn ("Dodge");
  gsn_hide = lookup_gsn ("Hide");
  gsn_peek = lookup_gsn ("Peek");
  gsn_pick_lock = lookup_gsn ("Lock");
  gsn_sneak = lookup_gsn ("Sneak");
  gsn_unarmed_combat = lookup_gsn ("Unarmed");
  gsn_double_backstab = lookup_gsn ("Double Backstab");
  gsn_double_circle = lookup_gsn ("Double Circle");
  gsn_double_cast = lookup_gsn ("Double Cast");
  gsn_steal = lookup_gsn ("Steal");
  gsn_bash = lookup_gsn ("Bash");
  gsn_track = lookup_gsn ("Track"); 
  gsn_disarm = lookup_gsn ("Disarm");
  gsn_enhanced_damage = lookup_gsn ("Enhanced Dam");
  gsn_enhanced_damage_two = lookup_gsn ("Enhanced Two");
  gsn_accuracy = lookup_gsn ("Accuracy");
  gsn_resilience = lookup_gsn ("Resilience");
  gsn_kick = lookup_gsn ("Kick");
  gsn_impale = lookup_gsn ("Impale");
  gsn_double_kick = lookup_gsn ("Double Kick");
  gsn_smash = lookup_gsn ("Smash");
  gsn_tackle = lookup_gsn ("Tackle");
  gsn_flurry = lookup_gsn ("Flurry");
  gsn_flash = lookup_gsn ("Flash");
  gsn_parry = lookup_gsn ("Parry");
  gsn_riposte = lookup_gsn ("Riposte");
  gsn_enhanced_dodge = lookup_gsn ("Enhanced Dodge");
  gsn_shieldbash = lookup_gsn ("Shieldbash");
  gsn_blink = lookup_gsn ("Blink");
  gsn_guard = lookup_gsn ("Guard");
  gsn_steadiness = lookup_gsn ("Steadiness");
  gsn_shield_block = lookup_gsn ("Shield Block");
  gsn_rescue = lookup_gsn ("Rescue");
  gsn_second_attack = lookup_gsn ("Second Attack");
  gsn_third_attack = lookup_gsn ("Third Attack");
  gsn_fourth_attack = lookup_gsn ("Fourth Attack");
  gsn_fifth_attack = lookup_gsn ("Fifth Attack");
  gsn_dual_wield = lookup_gsn ("Dual Wield");
  gsn_dual_second = lookup_gsn ("Dual Second");
  gsn_dual_third = lookup_gsn ("Dual Third");
  gsn_pierce = lookup_gsn ("Pierc");
  gsn_slashing = lookup_gsn ("Slash");
  gsn_concussion = lookup_gsn ("Concus");
  gsn_polearm = lookup_gsn ("Polearm");
  gsn_whip = lookup_gsn ("Whip");
  gsn_search = lookup_gsn ("Search");
  gsn_sixth_sense = lookup_gsn("Sixth Sense");
  update_name_hash ();
  update_gsn_hash ();
  update_prereq ();
  return;
}

void 
write_spells (void)
{
  //This section was modified by Flatline
  //Thursday, March 2, 2000 to group skills/spells/profs in the spells.dat file
  SPELL_DATA *spell;
  FILE *sfp;
  int i,
    slots;  //Added so i didn't have to copy paste a bunch and cut down on size
  if ((spell = skill_lookup ("Slashing", -1)) == NULL || spell->spell_level == -1)
    setup_skills ();
  update_name_hash ();
  update_gsn_hash ();
  update_prereq();
  if ((sfp = fopen ("spells.dat", "w")) == NULL)
    {
      fprintf (stderr, "Shit, failed on spell write!!\n");
      exit (99);
    }
  for (i = 0; i < SPELL_HASH; i++)
    {
      for (slots = 0;slots < 3;slots ++)
      {
      for (spell = spell_list[i]; spell != NULL; spell = spell->next)
	{
	  //This section used to be sarintf (sfp, "#SPELL\n");
	  //I modified it to distinguish between different slots
	  if (slots == spell->slot)
	  {
	  if (spell->slot == 1)
	    fprintf (sfp, "#SPELL\n");
	  if (spell->slot == 0)
	    fprintf (sfp, "#SKILL\n");
	  if (spell->slot == 2)
	    fprintf (sfp, "#PROF\n");
	  fprintf (sfp, "Gsn %d\n", spell->gsn);
	  if (spell->slot == 1)
	    fprintf (sfp, "SType %d\n", spell->spell_type);
	  if (spell->spell_bits != 0 || spell->spell_bits2 != 0)
	    fprintf (sfp, "SplBits %d %d\n", spell->spell_bits, spell->spell_bits2);
	  if (spell->aff[0] != 0 || spell->aff[1] != 0 || spell->aff[2] != 0 || spell->aff[3] != 0)
	    fprintf(sfp, "Aff %d %d %d %d\n", spell->aff[HURT], spell->aff[PROT], spell->aff[AFF], spell->aff[DET]);
	  
	  fprintf (sfp, "Sname %s~\n", spell->spell_name);
	  fprintf (sfp, "SLev %d\n", spell->spell_level);
	  if (spell->multi_mana != 0)
	    {
	      fprintf (sfp, "Multi %d\n", spell->multi_mana);
	      if(spell->multi_mana != 0)
		{
		  fprintf (sfp, "MultiM %d %d %d %d %d\n", spell->multi_mana_level[0], spell->multi_mana_level[1], spell->multi_mana_level[2], spell->multi_mana_level[3], spell->multi_mana_level[4]);
		}
	    }
	  if (spell->prereq_1 != NULL && str_cmp(spell->prereq_1, "none") && str_cmp(spell->prereq_1, "None"))
	    fprintf (sfp, "Pr1 %s~\n", spell->prereq_1);
	  if (spell->prereq_2 != NULL && str_cmp(spell->prereq_2, "nonemap")
&& str_cmp(spell->prereq_2, "None"))
	    fprintf (sfp, "Pr2 %s~\n", spell->prereq_2);
	  if (spell->slot == 1 ||
	      spell->gsn == gsn_throw || spell->gsn == gsn_shoot ||
	      spell->gsn == gsn_kick || spell->gsn == gsn_impale ||
	      spell->gsn == gsn_bash || spell->gsn == gsn_trapset ||
	      spell->gsn == gsn_smash)
	    fprintf (sfp, "Noun %s~\n", spell->noun_damage);
	  if (spell->act_to_ch_1 != NULL)
	    fprintf (sfp, "A2C1 %s~\n", spell->act_to_ch_1);
	  if (spell->act_to_ch_2 != NULL)
	    fprintf (sfp, "A2C2 %s~\n", spell->act_to_ch_2);
	  if (spell->act_to_vict_1 != NULL)
	    fprintf (sfp, "A2V1 %s~\n", spell->act_to_vict_1);
	  if (spell->act_to_vict_2 != NULL)
	    fprintf (sfp, "A2V2 %s~\n", spell->act_to_vict_2);
	  if (spell->act_to_notvict_1 != NULL)
	    fprintf (sfp, "A2NV1 %s~\n", spell->act_to_notvict_1);
	  if (spell->act_to_notvict_2 != NULL)
	    fprintf (sfp, "A2NV2 %s~\n", spell->act_to_notvict_2);
	  fprintf (sfp, "Durat %s~\n", (spell->duration == NULL ? "0" : spell->duration));
	  if (spell->duration != NULL)
	    {
	      int jj;
	      for (jj = 0; jj < 5; jj++)
		{
		  if(spell->location[jj] > 0)
		    fprintf(sfp, "Locat%d %d\n", jj, spell->location[jj]);
		  if(spell->modifier[jj] != NULL && str_cmp(spell->modifier[jj], "0"))
		    fprintf(sfp, "Modif%d  %s~\n", jj, spell->modifier[jj]);
		}
	      if(spell->slot == 1)
		fprintf (sfp, "WearO %s~\n", spell->wear_off_msg);
	    }
	  if (spell->damage != NULL && spell->slot == 1)
	    fprintf (sfp, "Dam %s~\n", spell->damage);
	  if (spell->mana > 1)
	    fprintf (sfp, "Mana %d\n", spell->mana);
	  if (spell->mana_type > 0)
	    fprintf (sfp, "ManaT %d\n", spell->mana_type);
	  if (spell->position != POSITION_RESTING)
	    fprintf (sfp, "Pos %d\n", spell->position);
	  fprintf (sfp, "CastT %d\n", spell->casting_time);
	  if (spell->creates_obj != 0)
	    fprintf (sfp, "CrObj %d\n", spell->creates_obj);
	  {
	    int jj;
	    fprintf(sfp, "MinStat ");
	    for (jj = 0; jj < NUM_STATS; jj++)
	      fprintf(sfp, "%d ", spell->min_stat[jj]);
	    fprintf(sfp, "\n\n");
	  }
	  {
	    int jj;
	    bool found = FALSE;
	    for (jj = 0; jj < NUM_GUILDS; jj++)
	      {
		if (spell->guilds[jj] > 0)
		  {
		    found = TRUE;
		    break;
		  }
	      }
	    if (found)
	      {
		fprintf(sfp, "\nGuildTiers ");
		for (jj = 0; jj < NUM_GUILDS; jj++)
		  {
		    fprintf(sfp, " %d", spell->guilds[jj]);
		  }
                fprintf(sfp, "\n");
	      }
            fprintf(sfp, "\n");
	  }
	  if(spell->in_room != 0)
	    fprintf (sfp, "InRoom %d\n", spell->in_room);
	  if(spell->spell_lag != 0)
	    fprintf (sfp, "SplLag %d\n", spell->spell_lag);
	  if(spell->fail_chance != 0)
	    fprintf (sfp, "FailChan %d\n", spell->fail_chance);
	  if(spell->pk_fail_chance != 0)
	    fprintf (sfp, "PKChan %d\n", spell->pk_fail_chance);
	  }
        }  
      }
    }
  fprintf (sfp, "#END");
  fclose (sfp);
  return;
}

void 
load_spells (void)
{
  SPELL_DATA *spell = NULL;
  FILE *sfp;
  char buf[500];
  bool fMatch;
  if ((sfp = fopen ("spells.dat", "r")) == NULL)
    {
      write_spells ();
      return;
    }
  for (;;)
    {
      strcpy (buf, fread_word (sfp));
      fMatch = FALSE;
      if (!str_cmp ("END", buf) || !str_cmp ("#END", buf))
	break;
      if (!str_cmp (buf, "SPELL") || !str_cmp ("#SPELL", buf) ||
          !str_cmp(buf, "SKILL")  || !str_cmp ("#SKILL", buf) ||
          !str_cmp(buf, "PROF")   || !str_cmp("#PROF", buf))
	{
	  spell = new_spell ();
	  free_string (spell->spell_name);
	  free_string (spell->noun_damage);
	  free_string (spell->wear_off_msg);
	  spell->multi_mana = 0;
	  continue;
	}
      if (spell == NULL)
	{
	  fprintf (stderr, "BAD FIRST HEADER IN SPELLS.DAT - %s!\n", buf);
	  exit (99);
	}
      KEY ("SPELL", spell->slot, 0 );
      KEY ("PROF", spell->slot, 1);
      KEY ("SKILL", spell->slot, 2);
      KEY ("SType", spell->spell_type, fread_number (sfp));
      if (!str_cmp(buf, "SplBits"))
	{
	  spell->spell_bits = fread_number(sfp);
	  spell->spell_bits2 = fread_number(sfp);
	  fMatch = TRUE;
	  continue;
	}
      if (!str_cmp(buf, "Aff"))
	{
	  fMatch = TRUE;
	  spell->aff[0] = fread_number(sfp);
	  spell->aff[1] = fread_number(sfp);
	  spell->aff[2] = fread_number(sfp);
	  spell->aff[3] = fread_number(sfp);
	  continue;
	}      
      KEY ("Gsn", spell->gsn, fread_number (sfp));
      KEY ("Sname", spell->spell_name, fread_string (sfp, NULL));
      KEY ("SLev", spell->spell_level, fread_number (sfp));
      KEY ("Multi", spell->multi_mana, fread_number (sfp));
      KEY ("FLvl", spell->multi_mana_level[0], fread_number (sfp));
      KEY ("ELvl", spell->multi_mana_level[1], fread_number (sfp));
      KEY ("ALvl", spell->multi_mana_level[2], fread_number (sfp));
      KEY ("WLvl", spell->multi_mana_level[3], fread_number (sfp));
      KEY ("SLvl", spell->multi_mana_level[4], fread_number (sfp));  
      KEY ("Pr1", spell->prereq_1, fread_string (sfp, NULL));
      KEY ("Pr2", spell->prereq_2, fread_string (sfp, NULL));
      KEY ("Noun", spell->noun_damage, fread_string (sfp, NULL));
      KEY ("A2C1", spell->act_to_ch_1, fread_string (sfp, NULL));
      KEY ("A2C2", spell->act_to_ch_2, fread_string (sfp, NULL));
      KEY ("A2V1", spell->act_to_vict_1, fread_string (sfp, NULL));
      KEY ("A2V2", spell->act_to_vict_2, fread_string (sfp, NULL));
      KEY ("A2NV1", spell->act_to_notvict_1, fread_string (sfp, NULL));
      KEY ("A2NV2", spell->act_to_notvict_2, fread_string (sfp, NULL));
      KEY ("Durat", spell->duration, fread_string (sfp, NULL));
      KEY ("Modif0", spell->modifier[0], fread_string (sfp, NULL));
      KEY ("Locat0", spell->location[0], fread_number (sfp)); 
      KEY ("Modif1", spell->modifier[1], fread_string (sfp, NULL));
      KEY ("Locat1", spell->location[1], fread_number (sfp));
      KEY ("Modif2", spell->modifier[2], fread_string (sfp, NULL));
      KEY ("Locat2", spell->location[2], fread_number (sfp));
      KEY ("Modif3", spell->modifier[3], fread_string (sfp, NULL));
      KEY ("Locat3", spell->location[3], fread_number (sfp));
      KEY ("Modif4", spell->modifier[4], fread_string (sfp, NULL));
      KEY ("Locat4", spell->location[4], fread_number (sfp));
      KEY ("Dam", spell->damage, fread_string (sfp, NULL));
      KEY ("Mana", spell->mana, fread_number (sfp));
      KEY ("ManaT", spell->mana_type, fread_number (sfp));
      KEY ("CastT", spell->casting_time, fread_number (sfp));
      KEY ("Pos", spell->position, fread_number (sfp));
      KEY ("WearO", spell->wear_off_msg, fread_string (sfp, NULL));
      KEY ("CrObj", spell->creates_obj, fread_number (sfp));
      if (!str_cmp(buf, "MultiM"))
	{
	  int jj;
	  for (jj = 0; jj < 5; jj++)
	    spell->multi_mana_level[jj] = fread_number(sfp);
	  fMatch = TRUE;
	}
      if (!str_cmp(buf, "MinStat"))
	{
	  int jj;
	  for (jj = 0; jj < NUM_STATS; jj++)
	    spell->min_stat[jj] = fread_number(sfp);
	  fMatch = TRUE;
	}
      if (!str_cmp(buf, "GuildTiers"))
	{
	  int jj; 
	  for (jj = 0; jj < NUM_GUILDS; jj++)
	    {
	      spell->guilds[jj] = fread_number(sfp);
	    }
	  fMatch = TRUE;
	}
      KEY ("InRoom", spell->in_room, fread_number (sfp));
      KEY ("SplLag", spell->spell_lag, fread_number (sfp));
      KEY ("FailChan", spell->fail_chance, fread_number (sfp));
      KEY ("PKChan", spell->pk_fail_chance, fread_number (sfp));
      
      if (!fMatch)
	{
	  fprintf (stderr, "%s\n", buf);
	  bug ("Fread_spell: no match.", 0);
	  if (!feof (sfp))
	    fread_to_eol (sfp);
	}
      if (spell->gsn < 300)
	{
	  spell->slot = 1;
	}
      else if (spell->gsn > 340 && spell->gsn < 400)
	{
	  spell->slot = 2;
	  spell->multi_mana = 0;
	}
      else 
	{
	  spell->slot = 0;
	  spell->multi_mana = 0;
	}
     
  
}
  fclose (sfp);
  update_name_hash ();
  update_gsn_hash ();
  fix_skillst ();
  update_name_hash ();
  update_gsn_hash ();
  update_prereq();
  return;
}

int 
lookup_gsn (char *nm)
{
  SPELL_DATA *spell = NULL;
  spell = skill_lookup (nm, -1);
  if (spell)
    return spell->gsn;
  else
    return -1;
}

int 
tally_spsk (CHAR_DATA * ch, int slot)
{
  int tally = 0;
  int i, j, low_gsn, high_gsn;
  if (IS_MOB (ch))
    return 0;
  if (slot < 0 || slot > 2) 
    return 0;
  for (j = 0; j < 3; j++)
    {
       ch->pcdata->learned[race_info[ch->pcdata->race].nat_skills[j]] = 0;
       
       ch->pcdata->learned[align_info[ch->pcdata->alignment].nat_skills[j]] = 0;
     }
  if (slot == 0)
    {
      low_gsn = 500;
      high_gsn = SKILL_COUNT;
    }
  else if (slot == 1)
    {
      low_gsn = 1;
      high_gsn = 200;
    }
  else if (slot == 2)
    {
      low_gsn = 349;
      high_gsn = 400;
    }
  for (i = low_gsn; i < high_gsn; i++)
    {
      if (ch->pcdata->learned[i] > 0)
	{
	      tally++;
	}
    }
  for (j = 0; j < 3; j++)
    {
       ch->pcdata->learned[race_info[ch->pcdata->race].nat_skills[j]] = 100;
       
       ch->pcdata->learned[align_info[ch->pcdata->alignment].nat_skills[j]] = 100;
     }
  return tally;
}


void 
setup_skills (void)
{
  SPELL_DATA * spell;

  /*  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 550;
  gsn_circle = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Circle");
  free_string (spell->noun_damage);
  spell->noun_damage = str_dup ("circle");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 551;
  gsn_penetration = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Armor Penetration");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 552;
  gsn_block = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Block");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 352;
  gsn_swim = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Swim");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 350;
  gsn_patch = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Patch");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 351;
  gsn_detrap = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Detrap");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 368;
  gsn_stitch = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Stitch");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 367;
  gsn_weave = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Weave");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 366;
  gsn_tanning = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Tanning");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 365;
  gsn_skin = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Skin");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 501;
  gsn_destroy = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Destroy");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 364;
  gsn_mine = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Mine");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 353;
  gsn_butcher = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Butcher");;
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 370;
  gsn_chop = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Chop");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 371;
  gsn_build = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Build");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 354;
  gsn_locate_trap = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Locate Traps");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 585;
  gsn_awareness = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Alertness");
  spell->gsn = 554;
  gsn_backstab = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Backstab");
  free_string (spell->noun_damage);
  spell->noun_damage = str_dup ("backstab");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 555;
  gsn_dodge = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Dodge");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 553;
  gsn_guard = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Guard");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 356;
  gsn_hide = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Hide");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 357;
  gsn_peek = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Peek");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 358;
  gsn_pick_lock = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Locksmithy");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 359;
  gsn_sneak = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Sneaking");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 360;
  gsn_steal = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Steal");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 561;
  gsn_bash = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Bash");
  free_string (spell->noun_damage);
  spell->noun_damage = str_dup ("bash");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 362;
  gsn_track = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Tracking");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 361;
  gsn_forge = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Forge");
spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 363;
  gsn_brew = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Brew");
spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 371;
  gsn_enchant = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Enchant");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 372;
  gsn_brew = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Lore");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 563;
  gsn_disarm = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Disarm");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 564;
  gsn_enhanced_damage = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Enhanced Damage");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 565;
  gsn_kick = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Kick");
  free_string (spell->noun_damage);
  spell->noun_damage = str_dup ("kick");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 588;
  gsn_impale = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Impale");
  free_string (spell->noun_damage);
  spell->noun_damage = str_dup ("impale");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 590;
  gsn_tackle = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Tackle");
  free_string (spell->noun_damage);
  spell->noun_damage = str_dup ("tackle");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 591;
  gsn_flurry = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Flurry");
  free_string (spell->noun_damage);
  spell->noun_damage = str_dup ("flurry");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 589;
  gsn_flash = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Flash");
  free_string (spell->noun_damage);
  spell->noun_damage = str_dup ("flash");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 566;
  gsn_parry = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Parry");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 592;
  gsn_steadiness = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Steadiness");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 593;
  gsn_double_kick = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Double Kick");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 594;
  gsn_smash = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Smash");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 595;
  gsn_accuracy = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Accuracy");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 596;
  gsn_resilience = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Resilience");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 397;
  gsn_sixth_sense = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Sixth Sense");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 576;
  gsn_shoot = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Shoot");
spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 577;
  gsn_throw = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Throw");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 567;
  gsn_shield_block = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Shield Block");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 568;
  gsn_rescue = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Rescue");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 569;
  gsn_second_attack = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Second Attack");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 570;
  gsn_third_attack = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Third Attack");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 571;
  gsn_dual_wield = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Dual Wield");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 572;
  gsn_pierce = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Piercing Weapons");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 573;
  gsn_slashing = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Slashing Weapons");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 574;
  gsn_concussion = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Concussion Weapons");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 575;
  gsn_whip = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Whipping Weapons");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 376;
  gsn_search = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Searching");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 378;
  gsn_invest = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Investigation");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 377;
  gsn_riding = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Riding");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 580;
  gsn_flail= spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Flail");
    spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 579;
  gsn_warcry = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Warcry");
    spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 583;
  gsn_polearm = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Polearm Weapons");
    spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 584;
  gsn_critical = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Critical Hit");
  spell = new_spell ();
  spell->slot = 0;
  spell->gsn = 599;
  gsn_grapple = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Grapple");
  spell = new_spell ();
  spell->slot = 2;
  spell->gsn = 398;
  gsn_grapple = spell->gsn;
  free_string (spell->spell_name);
  spell->spell_name = str_dup ("Trapset"); */
  update_name_hash ();
  update_gsn_hash ();
  update_prereq();
  return;
}

char *
stpos (int pos)
{
  static char retb[25];
  retb[0] = '\0';
  if (pos == POSITION_STANDING)
    {
      strcpy (retb, "Standing");
    }
  if (pos == POSITION_RESTING)
    {
      strcpy (retb, "Resting");
    }
  if (pos == POSITION_FIGHTING)
    {
      strcpy (retb, "Fighting");
    }
  return retb;
}

int 
stpos_rev (char *pos)
{
  if (!str_cmp (pos, "standing"))
    return POSITION_STANDING;
  if (!str_cmp (pos, "resting"))
    return POSITION_RESTING;
  if (!str_cmp (pos, "fighting"))
    return POSITION_FIGHTING;
  return -99;
}

char *
mtype (int mana)
{
  static char retb[50];
  int i;
  bool found = FALSE;
  retb[0] = '\0';
  for (i = 0; str_cmp(mana_data[i].what_you_type, "end_of_list"); i++ )
    {
      if (mana & mana_data[i].flagname)
	{
	  strcat(retb, mana_data[i].how_it_appears);
	  found = TRUE;
	}
    }
  if (!found)
    {
      strcat(retb, "None");
    }
  
  return retb;
}




int 
mtype_rev (char *mana)
{
  int i;
  if (!str_cmp (mana, "none"))
    return MANA_NONE;
  for (i = 0; str_cmp(mana_data[i].what_you_type, "end_of_list"); i++ )
    {
      if (!str_cmp(mana, mana_data[i].what_you_type))
	return mana_data[i].flagname;
    }
  return -99;
}


int
spell_extra_bits2_rev (char *wrd)
{
 int i;
  for (i = 0; str_cmp(spell_flags2[i].what_you_type, "end_of_list"); i++)
    if (!str_cmp(wrd, spell_flags2[i].what_you_type))
      return spell_flags2[i].flagname; 
  return -99;
}


int
spell_extra_bits_rev (char *wrd)
{
  int i;
  for (i = 0; str_cmp(spell_flagss[i].what_you_type, "end_of_list"); i++)
    if (!str_cmp(wrd, spell_flagss[i].what_you_type))
      return spell_flagss[i].flagname;
  return -99;
}



char * 
spell_extra_bits2 (int bits)
{
   int i;
  static char retb[200];
  retb[0] = '\0';
  for (i = 0; str_cmp(spell_flags2[i].what_you_type, "end_of_list"); i ++)
    if (bits & spell_flags2[i].flagname)
      strcat(retb, spell_flags2[i].how_it_appears);
  return retb;
}

char *
spell_extra_bits (int bits)
{
  int i;
  static char retb[200];
  retb[0] = '\0';
  for (i = 0; str_cmp(spell_flagss[i].what_you_type, "end_of_list"); i ++)
    if (bits & spell_flagss[i].flagname)
      strcat(retb, spell_flagss[i].how_it_appears);
  return retb;
}

char *
styp (int stype)
{
  static char retb[20];
  retb[0] = '\0';
  if (stype == TAR_IGNORE)
    {
      strcpy (retb, "None");
    }
  if (stype == TAR_CHAR_OFFENSIVE)
    {
      strcpy (retb, "Offensive");
    }
  if (stype == TAR_CHAR_DEFENSIVE)
    {
      strcpy (retb, "Defensive");
    }
  if (stype == TAR_CHAR_SELF)
    {
      strcpy (retb, "Self");
    }
  if (stype == TAR_OBJ_INV)
    {
      strcpy (retb, "Object Inventory");
    }
  return retb;
}

int 
styp_rev (char *stype)
{
  if (!str_cmp (stype, "none"))
    return TAR_IGNORE;
  if (!str_cmp (stype, "offensive"))
    return TAR_CHAR_OFFENSIVE;
  if (!str_cmp (stype, "defensive"))
    return TAR_CHAR_DEFENSIVE;
  if (!str_cmp (stype, "self"))
    return TAR_CHAR_SELF;
  if (!str_cmp (stype, "objinv"))
    return TAR_OBJ_INV;
  return -99;
}




void 
show_gen_skill (CHAR_DATA * ch, SPELL_DATA * spell)
{
  char buf[500];
  char buf2[500];
  bool prev = FALSE;
  int i;

  buf2[0] = '\0';

 for (i = 0; i < NUM_GUILDS; i++)
	{
	  if (spell->guilds[i])
	    {
	      if (prev)
                strcat(buf, "\x1B[1;32m,");
              sprintf(buf2 +strlen(buf2), "\x1B[0;32m%s tier %d", guild_data[i].what_you_see, spell->guilds[i]);
	      prev = TRUE;
	    }
	}
      if (!prev)
	{
          strcat(buf2, " \x1B[0;32mNone\x1B[1m.\x1B[0m");
	}
      else
	{
          strcat(buf2, "\x1B[1;32m.\x1B[0m");
	}

  if IS_SET(ch->pcdata->act2, PLR_ASCII)
    {
      sprintf (buf, "\n\r\x1B[1;30mÄÄÄÄÄÄ\x1B[0;31mÄÄÄÄÄÄÄÄÄÄÄÄÄ\x1B[1;31mÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ\x1B[0;31mÄÄÄÄÄÄÄÄÄÄÄÄÄ\x1B[1;30mÄÄÄÄÄÄ\x1B[0m\n\r");
      send_to_char(buf, ch);
    }
  else
    {
      sprintf (buf, "\n\r\x1B[1;30m------\x1B[0;31m-------------\x1B[1;31m-----------------------------------------\x1B[0;31m-------------\x1B[1;30m------\x1B[0m\n\r");
      send_to_char(buf, ch);
    }
  if (spell->gsn == gsn_backstab || spell->gsn == gsn_circle)
    {
      sprintf (buf, "Skill %s \x1B[1;32m(\x1B[0;32m#%d\x1B[1;32m)\x1B[0m  Delay (Post): \x1B[0;32m%d\x1B[1m.\x1B[0m  Moves=(Pre-%s delay): \x1B[0;32m%d\x1B[1m.\x1B[0m\n\r",
             spell->spell_name, spell->gsn, spell->casting_time, spell->spell_name, spell->mana);
      send_to_char(buf, ch);
      sprintf (buf, "Level: \x1B[1;32m[\x1B[0;32m%d\x1B[1m]\x1B[0m Guild(s):%s\n\r", spell->spell_level, buf2);
      send_to_char(buf, ch);
    }
  else
    {
      sprintf (buf, "Skill %s \x1B[1;32m(\x1B[0;32m#%d\x1B[1;32m)\x1B[0m.  Delay: \x1B[0;32m%d\x1B[1m.\x1B[0m  Moves: \x1B[0;32m%d\x1B[1m.\x1B[0m Level: \x1B[0;32m%d\x1B[1m.\x1B[0m\n\r",
	     spell->spell_name, spell->gsn, spell->casting_time, spell->mana, spell->spell_level);
      send_to_char (buf, ch);
      sprintf (buf, "Guild(s):%s\n\r", buf2);
      send_to_char (buf, ch);
    }
 for (i = 0; i < NUM_STATS; i++)
   {
     if (spell->min_stat[i] > 0)
       {
	 sprintf(buf, "M%s: %d ", stat_short_name[i], spell->min_stat[i]);
	 send_to_char(buf, ch);
       }
   }
  if IS_SET(ch->pcdata->act2, PLR_ASCII)
    {
      sprintf (buf, "\x1B[1;30mÄÄÄÄÄÄ\x1B[0;31mÄÄÄÄÄÄÄÄÄÄÄÄÄ\x1B[1;31mÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ\x1B[0;31mÄÄÄÄÄÄÄÄÄÄÄÄÄ\x1B[1;30mÄÄÄÄÄÄ\x1B[0;37m\n\r");
      send_to_char(buf, ch);
    }
  else
    {
      sprintf (buf, "\x1B[1;30m------\x1B[0;31m-------------\x1B[1;31m-----------------------------------------\x1B[0;31m-------------\x1B[1;30m------\x1B[0;37m\n\r");
      send_to_char(buf, ch);
    }
  if (spell->gsn > 300 && spell->gsn < 350) spell->slot = 2;
  else if (spell->gsn >= 500) spell->slot = 0;
  return;
}

void 
show_spell (CHAR_DATA * ch, SPELL_DATA * spell)
{
  char buf[500];
  char buff[500];
  bool prev = FALSE;
  int i;
  if (spell->gsn >= 300)
    {
      show_gen_skill (ch, spell);
      spell->slot = 0;
      return;
    }
  if IS_SET(ch->pcdata->act2, PLR_ASCII)
    {
      sprintf (buf, "\n\r\x1B[1;30mÄÄÄÄÄÄ\x1B[0;31mÄÄÄÄÄÄÄÄÄÄÄÄÄ\x1B[1;31mÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ\x1B[0;31mÄÄÄÄÄÄÄÄÄÄÄÄÄ\x1B[1;30mÄÄÄÄÄÄ\x1B[0m\n\r");
    }
  else
    {
      sprintf (buf, "\n\r\x1B[1;30m------\x1B[0;31m-------------\x1B[1;31m-----------------------------------------\x1B[0;31m-------------\x1B[1;30m------\x1B[0m\n\r");
    }
      send_to_char(buf, ch);
      sprintf (buf, "Spell Vnum: \x1B[1;32m(\x1B[0;32m%d\x1B[1m)\x1B[0m Name: \x1B[1;32m'\x1B[0;32m%s\x1B[1m'\x1B[0m Spell type: \x1B[1;32m[\x1B[0;32m%s\x1B[1m]\x1B[0m\n\r",
	       spell->gsn, spell->spell_name, styp (spell->spell_type));
      send_to_char (buf, ch);
      if(spell->multi_mana != 0)
	{
	  sprintf (buf, "Cast Position: \x1B[1;32m[\x1B[0;32m%s\x1B[1m]\x1B[0m Learn Lvl: \x1B[1;32m[\x1B[0;32m%d\x1B[1m]\x1B[0m Mana: \x1B[1;32m[\x1B[0;32m%d\x1B[1m]\x1B[0m Drained: \x1B[1;32m[\x1B[0;32m%s\x1B[1m]\x1B[0m\n\r",
	       stpos (spell->position), spell->spell_level, spell->mana, mtype (spell->mana_type));
	  send_to_char (buf, ch);
	}
      else
	{
	  sprintf (buf, "Cast Position: \x1B[1;32m[\x1B[0;32m%s\x1B[1m]\x1B[0m Level: \x1B[1;32m[\x1B[0;32m%d\x1B[1m]\x1B[0m Mana: \x1B[1;32m[\x1B[0;32m%d\x1B[1m]\x1B[0m Mana Type: \x1B[1;32m[\x1B[0;32m%s\x1B[1m]\x1B[0m\n\r",
	       stpos (spell->position), spell->spell_level, spell->mana, mtype (spell->mana_type));
	  send_to_char (buf, ch);
	}
      sprintf (buf, "Cast Time: \x1B[1;32m[\x1B[0;32m%d\x1B[1m]\x1B[0m Creates Obj Vnum: \x1B[1;32m'\x1B[0;32m%d\x1B[1m'\x1B[0m Pktimer: \x1B[1;32m[\x1B[0;32m%d\x1B[1m]\x1B[0m Affect Duration: \x1B[1;32m[\x1B[0;32m%s\x1B[1m]\x1B[0m\n\r", spell->casting_time, spell->creates_obj, spell->spell_lag, (spell->duration == NULL ? "N/A" : spell->duration));
      send_to_char (buf, ch);
      sprintf (buf, "Prerequisite one: \x1B[1;32m'\x1B[0;32m%s\x1B[1m'\x1B[0m Prerequisite two: \x1B[1;32m'\x1B[0;32m%s\x1B[1m'\x1B[0m\n\r", (spell->prereq_1 == NULL ? "None" : spell->prereq_1), (spell->prereq_2 == NULL ? "None" : spell->prereq_2));
      send_to_char (buf, ch);
      sprintf (buf, "Damage: \x1B[1;32m[\x1B[0;32m%s\x1B[1m]\x1B[0m Type: \x1B[1;32m[\x1B[0;32m%s\x1B[1m]\x1B[0m Wear off msg: \x1B[1;32m'\x1B[0;32m%s\x1B[1m'\x1B[0m\n\r",
	       (spell->damage == NULL ? "N/A" : spell->damage), (spell->slot == 1 ? "Spell" : spell->slot == 5 ? "NUKED" : spell->slot == 2 ? "Skill" : spell->slot == 3 ? "Proficiency" : "error"), (spell->wear_off_msg == NULL ? "none" : spell->wear_off_msg));
      send_to_char (buf, ch);
      
      sprintf (buf, "Damage Name: \x1B[1;32m'\x1B[0;32m%s\x1B[1m'\x1B[0m Extra Bits: \x1B[1;32m'\x1B[0;32m%s\x1B[1m'\x1B[0m \x1B[1;32m'\x1B[0;32m%s\x1B[1m'\x1B[0m",
               (spell->noun_damage == NULL ? "N/S" : spell->noun_damage), (spell->spell_bits == 0 ? "None" : spell_extra_bits (spell->spell_bits)), (spell->spell_bits2 == 0 ? "None" : spell_extra_bits2 (spell->spell_bits2)));
      act (buf, ch, NULL, NULL, TO_CHAR);

      for (i = 0; i < NUM_STATS; i++)
	{
	  if (spell->min_stat[i] > 0)
	    {
              sprintf(buf, "Minimum %s: \x1B[0;32m%d\x1B[1m.\x1B[0m", stat_short_name[i], spell->min_stat[i]);
              send_to_char (buf, ch);
              send_to_char ("\n\r", ch);
	    }
	}

     if (spell->aff[0] != 0 || spell->aff[1] != 0 || spell->aff[2] != 0 || spell->aff[3] != 0)
          {
            sprintf (buf, "Bits: \x1B[1;32m[\x1B[0;32m%s\x1B[1;32m]\x1B[0m\n\r", affect_bit_name(spell->aff[0], spell->aff[1], spell->aff[2], spell->aff[3]));
            send_to_char (buf, ch);
          }
     if (spell->multi_mana != 0)
       {
	 sprintf (buf, "Multiple Mana Types: \n\r");
	 send_to_char (buf, ch);
	 if(spell->multi_mana_level[0] > 0)
	   {
	     sprintf (buf, "\x1B[0mFire Level: \x1B[1;32m[\x1B[0;32m%d\x1B[1;32m] ", spell->multi_mana_level[0]);
	     send_to_char (buf, ch);
	   }
	 if(spell->multi_mana_level[1] > 0)
	   {
	     sprintf (buf, "\x1B[0mEarth Level: \x1B[1;32m[\x1B[0;32m%d\x1B[1;32m] ", spell->multi_mana_level[1]);
	     send_to_char (buf, ch);
	   }
	 if(spell->multi_mana_level[2] > 0)
	   {
	     sprintf(buf, "\x1B[0mAir Level: \x1B[1;32m[\x1B[0;32m%d\x1B[1;32m] ", spell->multi_mana_level[2]);
	     send_to_char (buf, ch);
	   }
	 if(spell->multi_mana_level[3] > 0)
	   {
	     sprintf (buf, "\x1B[0mWater Level: \x1B[1;32m[\x1B[0;32m%d\x1B[1;32m] ", spell->multi_mana_level[3]);
	     send_to_char (buf, ch);
	   }
	 if(spell->multi_mana_level[4] > 0)
	   {
	     sprintf (buf, "\x1B[0mSpirit Level: \x1B[1;32m[\x1B[0;32m%d\x1B[1;32m]", spell->multi_mana_level[4]);
	     send_to_char (buf, ch);
	   }
         send_to_char ("\x1B[0m\n\r", ch);
       }
      sprintf (buf, "TO CHAR ONE  : %s", (spell->act_to_ch_1 == NULL ? "" : spell->act_to_ch_1));
      act (buf, ch, NULL, NULL, TO_CHAR);
      sprintf (buf, "TO CHAR TWO  : %s", (spell->act_to_ch_2 == NULL ? "" : spell->act_to_ch_2));
      act (buf, ch, NULL, NULL, TO_CHAR);
      sprintf (buf, "TO VICT ONE  : %s", (spell->act_to_vict_1 == NULL ? "" : spell->act_to_vict_1));
      act (buf, ch, NULL, NULL, TO_CHAR);
      sprintf (buf, "TO VICT TWO  : %s", (spell->act_to_vict_2 == NULL ? "" : spell->act_to_vict_2));
      act (buf, ch, NULL, NULL, TO_CHAR);
      sprintf (buf, "TO NOTVICT 1 : %s", (spell->act_to_notvict_1 == NULL ? "" : spell->act_to_notvict_1));
      act (buf, ch, NULL, NULL, TO_CHAR);
      sprintf (buf, "TO NOTVICT 2 : %s", (spell->act_to_notvict_2 == NULL ? "" : spell->act_to_notvict_2));
      act (buf, ch, NULL, NULL, TO_CHAR);
      sprintf (buf, "Guild(s):");
      send_to_char(buf, ch);
      buf[0] = '\0';
      for (i = 0; i < NUM_GUILDS; i++)
	{
	  if (spell->guilds[i])
	    {
	      if (prev)
		strcat(buf, "\x1B[1;32m,");
	      sprintf(buf +strlen(buf), "\x1B[0;32m%s tier %d", guild_data[i].what_you_see, spell->guilds[i]);
	  prev = TRUE;
	    }
	}
      if (!prev)
	{
	  send_to_char(" \x1B[0;32mNone\x1B[1;32m.\x1B[0m\n\r", ch);
	}
      else
	{
	  send_to_char(buf, ch);
	  send_to_char("\x1B[1;32m.\x1B[0m\n\r", ch);
	}
      sprintf (buf, "Locations:   \x1B[0;32m");
      for (i = 0; i < 5; i ++)
        {
	  sprintf (buff, "%-13s ", (spell->location[i] == 0 ? "\x1B[1;32m<\x1B[0;32mnowhere\x1B[1m>\x1B[0;32m " : affect_loc_name(spell->location[i])));
	  strcat (buf, buff);
	}
      strcat (buf, "\n\r");
      send_to_char (buf, ch);
      sprintf(buf, "\x1B[0;37mModifier:    ");
      for (i = 0; i < 5; i ++)
	{
	  sprintf (buff, "\x1B[0;32m%-13s ", (spell->modifier[i] == NULL ? "\x1B[1;32m<\x1B[0;32mnothing\x1B[1m>\x1B[0;32m " : spell->modifier[i]));
	  strcat (buf, buff);
	}
      strcat (buf, "\n\r");
      send_to_char (buf, ch);
  if IS_SET(ch->pcdata->act2, PLR_ASCII)
    {
      sprintf (buf, "\x1B[1;30mÄÄÄÄÄÄ\x1B[0;31mÄÄÄÄÄÄÄÄÄÄÄÄÄ\x1B[1;31mÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ\x1B[0;31mÄÄÄÄÄÄÄÄÄÄÄÄÄ\x1B[1;30mÄÄÄÄÄÄ\x1B[0m\n\r");
    }
  else
    {
      sprintf (buf, "\x1B[1;30m------\x1B[0;31m-------------\x1B[1;31m-----------------------------------------\x1B[0;31m-------------\x1B[1;30m------\x1B[0m\n\r");
    }
      send_to_char(buf, ch);
      return;
}

void 
do_sedit (CHAR_DATA * ch, char *argy)
{
  char arg1[SML_LENGTH];
  char buf[500];
  int value;
  SPELL_DATA *spell;
  DEFINE_COMMAND ("sedit", do_sedit, POSITION_DEAD, MAX_LEVEL, LOG_NORMAL, "The spell editor... use with caution!")

    if (IS_MOB (ch))
      return;
  
  argy = one_argy (argy, arg1);
  if (is_number (arg1))
    {
      value = atoi (arg1);
      if ((spell = skill_lookup (NULL, value)) == NULL)
	{
	  send_to_char ("That spell number was not found.\n\r", ch);
	  return;
	}
     
      ch->desc->pEdit = (void *) spell;
      ch->desc->connected = CON_SEDITOR;
      show_spell (ch, spell);
      return;
    }
  if (!str_cmp (arg1, "delete"))
    {
      if(is_number(argy))
        {
	  value = atoi (argy);
	  if((spell = skill_lookup (NULL, value)) == NULL)
	    {
	      send_to_char ("That spell number was not found. \n\r", ch);
	      return;
	    }
	  sprintf(buf, "%s sNum %d Type Set to Nuke.", spell->spell_name, value);
	  send_to_char (buf, ch);
	  send_to_char ("\n\r", ch);
	  spell->slot = 5;
	  ch->desc->pEdit = NULL;
	  ch->desc->connected = CON_PLAYING;
	  return;
	}
      else
	{
	  send_to_char ("Syntax: sedit delete <num> \n\r", ch);
	  return;
	}
    }
  if (!str_cmp (arg1, "create"))
    {
      if (is_number(argy) && argy != NULL)
	{
	  value = atoi (argy);
	  if ((spell = skill_lookup (NULL, value)) != NULL)
	    {
	      send_to_char ("sNum Taken.\n\r", ch);
	      return;
	    }
	  if (value >= 350 || value < 0)
	    {
	      send_to_char ("sNum is limited in range to 0-349.\n\r", ch);
	      return;
	    }
	  spell = create_spell(value);
	  changed_spells = TRUE;
	  ch->desc->pEdit = (void *) spell;
	  ch->desc->connected = CON_SEDITOR;
	  update_name_hash ();
	  update_gsn_hash ();
          show_spell (ch, spell);
	  return;
	}
      spell = new_spell ();
      changed_spells = TRUE;
      ch->desc->pEdit = (void *) spell;
      ch->desc->connected = CON_SEDITOR;
      update_name_hash ();
      update_gsn_hash ();
      show_spell (ch, spell);
      return;
    }
  if (arg1[0] != '\0' && (spell = skill_lookup (arg1, -1)) != NULL)
    {
      ch->desc->pEdit = (void *) spell;
      ch->desc->connected = CON_SEDITOR;
      show_spell (ch, spell);
      if (spell->gsn > 300)
	spell->slot = 2;
      if (spell->gsn > 500) 
        spell->slot = 0;
      return;
    }
  send_to_char ("Syntax: SEDIT #, SEDIT 'Spell_name', or SEDIT CREATE.\n\r", ch);
  return;
}

void 
sedit (CHAR_DATA * ch, char *argy)
{
  char *orarg = argy;
  char arg1[SML_LENGTH];
  char arg2[SML_LENGTH];
  char buf[SML_LENGTH];
  bool fnn;
  int i;
  SPELL_DATA *spell;
  spell = (SPELL_DATA *) ch->desc->pEdit;
  if (!spell)
    {
      interpret (ch, argy);
      return;
    } 
  arg1[0] = '\0';
  arg2[0] = '\0';
  argy = one_argy (argy, arg1);
  if (arg1[0] == '\0')
    {
      show_spell (ch, spell);
      return;
    }
  if (!str_cmp (arg1, "done"))
    {
      ch->desc->pEdit = NULL;
      ch->desc->connected = CON_PLAYING;
      if (!IS_SET (ch->pcdata->act2, PLR_ASCII))
	do_clear (ch, "");
      
      return;
    }
  if ((!str_cmp (arg1, "time") || !str_cmp (arg1, "delay")) && is_number (argy))
    {
      int ii;
      ii = atoi (argy);
      spell->casting_time = ii;
      changed_spells = TRUE;
      sprintf(buf, "Casting time set to \x1B[1m%s\x1B[0m.\n\r", argy);
      send_to_char (buf, ch);
      return;
    }
  if ((!str_cmp (arg1, "mana") || !str_cmp (arg1, "moves")) && is_number (argy))
    {
      int ii;
      ii = atoi (argy);
      spell->mana = ii;
      changed_spells = TRUE;
      sprintf(buf, "Mana set to \x1B[1m%s\x1B[0m.\n\r", argy);
      send_to_char (buf, ch);
      return;
    }
  if (!str_cmp (arg1, "lvl") && is_number (argy))
    {
      int ii;
      ii = atoi (argy);
      spell->spell_level = ii;
      changed_spells = TRUE;
      sprintf(buf, "Level set to \x1B[1m%s\x1B[0m.\n\r", argy);
      send_to_char (buf, ch);
      return;
    }
  if (spell->gsn > 350)
    {
      for (i = 0; i < NUM_GUILDS; i++)
	{
	  if (!str_cmp(arg1, guild_data[i].what_you_type))
	    {
	  
	      if (!is_number(argy) || atoi(argy) < 0 || atoi(argy) > 5)
		{
		  send_to_char("Pick a tier from 0 to 5.\n\r", ch);
		  return;
		}
	      sprintf(buf, "%s set to tier %d.\n\r", guild_data[i].what_you_see, atoi(argy));
	      send_to_char(buf, ch);
	      spell->guilds[i] = atoi(argy);
	      changed_spells = TRUE;
	      return;
	    }
	}
	fnn = FALSE;
	if (!fnn)
	  interpret (ch, orarg);
	return;
    }
  else
  {      
  for (i = 0; i < NUM_GUILDS; i++)
    {
      if (!str_cmp(arg1, guild_data[i].what_you_type))
	{
	  
	  if (!is_number(argy) || atoi(argy) < 0 || atoi(argy) > 5)
	    {
	      send_to_char("Pick a tier from 0 to 5.\n\r", ch);
	      return;
	    }
	  sprintf(buf, "%s set to tier %d.\n\r", guild_data[i].what_you_see, atoi(argy));
	  send_to_char(buf, ch);
	  spell->guilds[i] = atoi(argy);
	  changed_spells = TRUE;
	  return;
	}
    }
    if (!str_cmp (arg1, "name"))
    {
      if (argy == NULL || argy[0] == '\0' || argy == "")
	{
	  send_to_char ("Syntax: Name <spell_name>.\n\r", ch);
	  return;
	}
      free_string (spell->spell_name);
      spell->spell_name = str_dup (argy);
      changed_spells = TRUE;
      update_name_hash ();
      sprintf(buf, "Name set to \x1B[1m%s\x1B[0m.\n\r", argy);
      send_to_char (buf, ch);
      return;
    }
  if (!str_cmp (arg1, "ndam"))
    {
      if (argy == NULL || argy[0] == '\0' || argy == "")
	{
	  send_to_char ("Syntax: Ndam <word>.\n\r", ch);
	  return;
	}
      if (spell->noun_damage != NULL)
	free_string (spell->noun_damage);
      spell->noun_damage = str_dup (argy);
      changed_spells = TRUE;
      sprintf(buf, "Ndam set to \x1B[1m%s\x1B[0m.\n\r", argy);
      send_to_char (buf, ch);
      return;
    }
  if (!str_cmp (arg1, "damg"))
    {
      if (argy == NULL || argy[0] == '\0' || argy == "")
	{
	  send_to_char ("Syntax: Damg <string>.\n\r", ch);
	  return;
	}
      if (!is_number(argy))
        {                                                                                 
          send_to_char ("Make sure to use the formula standards before trying to cast this spell.\n\r", ch);
	}
      if (spell->damage != NULL)
	free_string (spell->damage);
      spell->damage = str_dup (argy);
      changed_spells = TRUE;
      sprintf(buf, "Damg set to \x1B[1m%s\x1B[0m.\n\r", argy);
      send_to_char (buf, ch);
      return;
    }
  
  if (!str_cmp (arg1, "wear_off"))
    {
      if (argy == NULL || argy[0] == '\0' || argy == "")
	{
	  send_to_char ("Syntax: wear_off <string>.\n\r", ch);
	  return;
	}
      free_string (spell->wear_off_msg);
      spell->wear_off_msg = str_dup (argy);
      changed_spells = TRUE;
      sprintf(buf, "Wear_off set to \x1B[1m%s\x1B[0m.\n\r", argy);
      send_to_char (buf, ch);
      return;
    }
  if (!str_cmp (arg1, "duration"))
    {
      if (argy == NULL || argy[0] == '\0' || argy == "")
	{
	  send_to_char ("Syntax: duration <duration val>.\n\r", ch);
	  return;
	}
      if (spell->duration != NULL)
	free_string (spell->duration);
      spell->duration = str_dup (argy);
      changed_spells = TRUE;
      sprintf(buf, "Duration set to \x1B[1m%s\x1B[0m.\n\r", argy);
      send_to_char (buf, ch);
      return;
    }
  if (!str_cmp (arg1, "to_char1"))
    {
      if (argy == NULL || argy[0] == '\0' || argy == "")
	{
	  if (spell->act_to_ch_1 != NULL)
	    free_string (spell->act_to_ch_1);
	  spell->act_to_ch_1 = NULL;
	  return;
	}
      if (spell->act_to_ch_1 != NULL)
	free_string (spell->act_to_ch_1);
      spell->act_to_ch_1 = str_dup (argy);
      changed_spells = TRUE;
      sprintf(buf, "To_char1 set to %s\x1B[0m\n\r", argy);
      act (buf, ch, NULL, NULL, TO_CHAR);
      return;
    }
  if (!str_cmp (arg1, "to_char2"))
    {
      if (argy == NULL || argy[0] == '\0' || argy == "")
	{
	  if (spell->act_to_ch_2 != NULL)
	    free_string (spell->act_to_ch_2);
	  spell->act_to_ch_2 = NULL;
	  return;
	}
      if (spell->act_to_ch_2 != NULL)
	free_string (spell->act_to_ch_2);
      changed_spells = TRUE;
      spell->act_to_ch_2 = str_dup (argy);
      sprintf(buf, "To_char2 set to %s\x1B[0m\n\r", argy);
      act (buf, ch, NULL, NULL, TO_CHAR);
      return;
    }
  if ((!str_cmp (arg1, "mana") || !str_cmp (arg1, "moves")) && is_number (argy))
    {
      int ii;
      ii = atoi (argy);
      spell->mana = ii;
      changed_spells = TRUE;
      sprintf(buf, "Mana set to \x1B[1m%d\x1B[0m.\n\r", ii);
      send_to_char (buf, ch);
      return;
    } 
  if (!str_cmp (arg1, "to_vict1"))
    {
      if (argy == NULL || argy[0] == '\0' || argy == "")
	{
	  if (spell->act_to_vict_1 != NULL)
	    free_string (spell->act_to_vict_1);
	  spell->act_to_vict_1 = NULL;
	  return;
	}
      if (spell->act_to_vict_1 != NULL)
	free_string (spell->act_to_vict_1);
      spell->act_to_vict_1 = str_dup (argy);
      changed_spells = TRUE;
      sprintf(buf, "To_vict1 set to %s\x1B[0m\n\r", argy);
      act (buf, ch, NULL, NULL, TO_CHAR);
      return;
    }
  if (!str_cmp (arg1, "to_vict2"))
    {
      if (argy == NULL || argy[0] == '\0' || argy == "")
	{
	  if (spell->act_to_vict_2 != NULL)
	    free_string (spell->act_to_vict_2);
	  spell->act_to_vict_2 = NULL;
	  return;
	}
      if (spell->act_to_vict_2 != NULL)
	free_string (spell->act_to_vict_2);
      spell->act_to_vict_2 = str_dup (argy);
      changed_spells = TRUE;
      sprintf(buf, "To_vict2 set to %s\x1B[0m\n\r", argy);
      act (buf, ch, NULL, NULL, TO_CHAR);
      return;
    }
  if (!str_cmp (arg1, "to_notvict1"))
    {
      if (argy == NULL || argy[0] == '\0' || argy == "")
	{
	  if (spell->act_to_notvict_1 != NULL)
	    free_string (spell->act_to_notvict_1);
	  spell->act_to_notvict_1 = NULL;
	  return;
	}
      if (spell->act_to_notvict_1 != NULL)
	free_string (spell->act_to_notvict_1);
      spell->act_to_notvict_1 = str_dup (argy);
      changed_spells = TRUE;
      sprintf(buf, "To_novict1 set to %s\x1B[0m\n\r", argy);
      act (buf, ch, NULL, NULL, TO_CHAR);
      return;
    }
  if (!str_cmp (arg1, "to_notvict2"))
    {
      if (argy == NULL || argy[0] == '\0' || argy == "")
	{
	  if (spell->act_to_notvict_2 != NULL)
	    free_string (spell->act_to_notvict_2);
          spell->act_to_notvict_2 = NULL;
	  return;
	}
      if (spell->act_to_notvict_2 != NULL)
	free_string (spell->act_to_notvict_2);
      spell->act_to_notvict_2 = str_dup (argy);
      changed_spells = TRUE;
      sprintf(buf, "To_novict2 set to %s\x1B[0m\n\r", argy);
      act (buf, ch, NULL, NULL, TO_CHAR);
      return;
    }
  if (!str_cmp (arg1, "pre1"))
    {
      if (argy == NULL || argy[0] == '\0' || argy == "")
	{
	  if (spell->prereq_1 != NULL)
	    free_string (spell->prereq_1);
	  spell->prereq_1 = NULL;
	  return;
	}
      if (spell->prereq_1 != NULL)
	free_string (spell->prereq_1);
      spell->prereq_1 = str_dup (argy);
      changed_spells = TRUE;
      sprintf(buf, "First prerequisite set to \x1B[1m%s\x1B[0m.\n\r", argy);
      send_to_char (buf, ch);
      return;
    }
  if (!str_cmp (arg1, "pre2"))
    {
      if (argy == NULL || argy[0] == '\0' || argy == "")
	{
	  if (spell->prereq_2 != NULL)
	    free_string (spell->prereq_2);
	  spell->prereq_2 = NULL;
	  return;
	}
      if (spell->prereq_2 != NULL)
	free_string (spell->prereq_2);
      spell->prereq_2 = str_dup (argy);
      changed_spells = TRUE;
      sprintf(buf, "Second prerequisite set to \x1B[1m%s\x1B[0m.\n\r", argy);
      send_to_char (buf, ch);
      return;
    }
  if (!str_cmp (arg1, "modifier"))
    {
      char arg2[SML_LENGTH];
      int num;
      argy = one_argy(argy, arg2);
      if (!is_number(arg2))
	{
	  send_to_char("Syntax: modifier <number> <modifier val>\n\r", ch);
	  return;
	}
      num = atoi(arg2);
      if (num < 0 || num > 4)
	{
	  send_to_char("Pick a number from 0-4 to modify.\n\r", ch);
	  return;
	}
      if (argy == NULL || argy[0] == '\0' || argy == "")
	{
	  send_to_char ("Syntax: modifier <number> <modifier val>.\n\r", ch);
	  return;
	}
      if ((argy[0] == '-' && !is_number(argy + 1)) || !is_number(argy))
        {
          send_to_char("Make sure you use the right formulas before trying your spell.\n\r", ch);
        }
      if (spell->modifier[num] != NULL)
	free_string (spell->modifier[num]);
      spell->modifier[num] = str_dup (argy);
      changed_spells = TRUE;
      sprintf(buf, "Modifier %d set to \x1B[1m%s\x1B[0m.\n\r", num, argy);
      send_to_char (buf, ch);
      return;
    }
  if (!str_cmp (arg1, "lvl") && is_number (argy))
    {
      int ii;
      ii = atoi (argy);
      spell->spell_level = ii;
      changed_spells = TRUE;
      sprintf(buf, "Level set to \x1B[1m%d\x1B[0m.\n\r", ii);
      send_to_char (buf, ch);
      return;
    }
  if (!str_cmp (arg1, "room") && is_number (argy))
    {
      int ii;
      ii = atoi (argy);
      spell->in_room = ii;
      changed_spells = TRUE;
      sprintf(buf, "Room set to \x1B[1m%d\x1B[0m.\n\r", ii);
      send_to_char (buf, ch);
      return;
    }
  if (!str_cmp (arg1, "fail_chance") && is_number (argy))
    {
      int ii;
      ii = atoi (argy);
      spell->fail_chance = ii;
      changed_spells = TRUE;
      sprintf(buf, "Fail chance set to \x1B[1m%d\x1B[0m.\n\r", ii);
      send_to_char (buf, ch);
      return;
    }
  if (!str_cmp (arg1, "spell_lag") && is_number (argy))
    {
      int ii;
      ii = atoi (argy);
      spell->spell_lag = ii;
      changed_spells = TRUE;
      sprintf(buf, "The lag of this spell is now set to \x1B[1m%d\x1B[0m.\n\r", ii);
      send_to_char (buf, ch);
      return;
    }  
  if (!str_cmp (arg1, "pk_fail") && is_number (argy))
    {
      int ii;
      ii = atoi (argy);
      spell->pk_fail_chance = ii;
      changed_spells = TRUE;
      sprintf(buf, "Spell will have a chance pk failing with a pk timer of \x1B[1m%d\x1B[0m.\n\r", ii);
      send_to_char (buf, ch);
      return;
    }
  if ((!str_cmp (arg1, "creates_obj") ||
       !str_cmp (arg1, "create_obj")) 
       && is_number (argy))
    {
      int ii;
      ii = atoi (argy);
      spell->creates_obj = ii;
      changed_spells = TRUE;
      sprintf(buf, "Spell will now create the object vnum \x1B[1m%d\x1B[0m.\n\r", ii);
      send_to_char (buf, ch);
      return;
    }
  if (!str_cmp (arg1, "nuke"))
    {
      spell->slot = 5;
      changed_spells = TRUE;
      send_to_char ("Spell type set to nuke.\n\r", ch);
      send_to_char ("Saving a spell with this flag will delete it upon reboot.\n\r", ch);
      return;
    }
  if (!str_cmp (arg1, "spell"))
    {
      spell->slot = 1;
      changed_spells = TRUE;
      send_to_char ("Type changed to Spell.\n\r", ch);
      return;
    }
  if (!str_cmp (arg1, "skill") || !str_cmp (arg1, "prof") || !str_cmp (arg1, "proficiency"))
    {
      send_to_char ("Cannot make a Skill or Proficiency it needs to be coded!\n\r", ch);
      return;
    }
  fnn = FALSE;
  if (stpos_rev (arg1) != -99)
    {
      spell->position = stpos_rev (arg1);
      changed_spells = TRUE;
      sprintf(buf, "Position set to \x1B[1m%d\x1B[0m.\n\r", stpos_rev (arg1));
      send_to_char (buf, ch);
      fnn = TRUE;
    }
  if (mtype_rev (arg1) != -99 && !is_number(argy))
    {
      spell->mana_type ^= mtype_rev (arg1);
      changed_spells = TRUE;
      sprintf(buf, "Mtype_rev set to \x1B[1m%d\x1B[0m.\n\r", mtype_rev (arg1));
      send_to_char (buf, ch);
      fnn = TRUE;
    }
  if (styp_rev (arg1) != -99)
    {
      spell->spell_type = styp_rev (arg1);
      changed_spells = TRUE;
      sprintf(buf, "Styp_rev set to \x1B[1m%d\x1B[0m.\n\r", styp_rev (arg1));
      send_to_char (buf, ch);
      fnn = TRUE;
    }
  if (spell_extra_bits_rev (arg1) != -99)
    {
      spell->spell_bits ^= spell_extra_bits_rev (arg1);
      changed_spells = TRUE;
      sprintf(buf, "Spell_extra_bits_rev set to \x1B[1m%d\x1B[0m.\n\r", spell_extra_bits_rev (arg1));
      send_to_char (buf, ch);
      fnn = TRUE;
    }
  if (spell_extra_bits2_rev (arg1) != -99)
    {
      spell->spell_bits2 ^= spell_extra_bits2_rev (arg1);
      changed_spells = TRUE;
      sprintf(buf, "Spell_extra_bits2_rev set to \x1B[1m%d\x1B[0m.\n\r", spell_extra_bits2_rev (arg1));
      send_to_char (buf, ch);
      fnn = TRUE;
    }
  if (!str_cmp(arg1, "aff") || !str_cmp(arg1, "affect"))
      {
	int value;
	if ((value = affect_name_bit(AFF, argy)) != AFFECT_NONE)
	  {
	    spell->aff[AFF] ^= value;
	    changed_spells = TRUE;
	    send_to_char ("Affect flag toggled.\n\r", ch);
	    return;
	  }
      }
  if (!str_cmp(arg1, "hurt") || !str_cmp(arg1, "hurts"))
    {
      int value;
      if ((value = affect_name_bit(HURT, argy)) != AFFECT_NONE)
	{
	  spell->aff[HURT] ^= value;
	  changed_spells = TRUE;
	  send_to_char ("Hurt flag toggled.\n\r", ch);
	  return;
	}
    }
  if (!str_cmp(arg1, "multi_mana"))
    {
      if(spell->multi_mana != 0)
	spell->multi_mana = 0;
      else
	spell->multi_mana = 1;
      changed_spells = TRUE;
      send_to_char ("Multiple Mana Types Toggled", ch);
      return;
    }
  if (!str_cmp(arg1, "firelvl") && is_number(argy))
    {
      spell->multi_mana_level[0] = atoi(argy);
      send_to_char ("Fire Mana Level Changed\n\r", ch);
      changed_spells = TRUE;
      return;
    }
  if (!str_cmp(arg1, "earthlvl") && is_number(argy))
    {
      spell->multi_mana_level[1] = atoi(argy);
      send_to_char ("Earth Mana Level Changed\n\r", ch);
      changed_spells = TRUE;
      return;
    }
  if (!str_cmp(arg1, "airlvl") && is_number(argy))
    {
      spell->multi_mana_level[2] = atoi(argy);
      send_to_char ("Air Mana Level Changed\n\r", ch);
      changed_spells = TRUE;
      return;
    }
  if (!str_cmp(arg1, "waterlvl") && is_number(argy))
    {
      spell->multi_mana_level[3] = atoi(argy);
      send_to_char ("Water Mana Level Changed\n\r", ch);
      changed_spells = TRUE;
      return;
    }
  if (!str_cmp(arg1, "spiritlvl") && is_number(argy))
    {
      spell->multi_mana_level[4] = atoi(argy);
      send_to_char ("Spirit Mana Level Changed\n\r", ch);
      changed_spells = TRUE;
      return;
    }
  if (!str_cmp(arg1, "det") || !str_cmp(arg1, "detect"))
    {
      int value;
      if ((value = affect_name_bit(DET, argy)) != AFFECT_NONE)
	{
	  spell->aff[DET] ^= value;
	  changed_spells = TRUE;
	  send_to_char ("Detect flag toggled.\n\r", ch);
	  return;
	}
    }
  if (!str_cmp(arg1, "prot") || !str_cmp(arg1, "protect"))
    {
      int value;
      if ((value = affect_name_bit(PROT, argy)) != AFFECT_NONE)
	{
	  spell->aff[PROT] ^= value;
	  changed_spells = TRUE;
	  send_to_char ("Protect flag toggled.\n\r", ch);
	  return;
	}
    }
  
  for (i = 0; i < NUM_STATS; i++)
    {
      if (!str_cmp(arg1, stat_short_name[i]) &&
	  is_number(argy) && atoi(argy) >= 3 && atoi(argy) <= 32)
	{
	  spell->min_stat[i] = atoi(argy);
	  changed_spells = TRUE;
          sprintf(buf, "Minimum %s set to \x1B[1m%d\x1B[0m.\n\r", stat_short_name[i], atoi(argy));
          send_to_char (buf, ch);
	  return;
	}
    }
  if (arg1[0] == 'm')
    {
      char *t;
      char argnew[100];
      argnew[0] = '\0';
      strcpy (argnew, arg1);
      for (t = argnew; *t; t++)
	{
	  *t = *(t+1);
	}
      for (i = 0; i < NUM_STATS; i++)
	{
	  if (!str_cmp(argnew, stat_short_name[i]) && 
	      is_number(argy) && atoi(argy) >= 3 && atoi(argy) <= 32)
	    {
	      spell->min_stat[i] = atoi(argy);
	      changed_spells = TRUE;
              sprintf(buf, "Minimum %s set to \x1B[1m%d\x1B[0m.\n\r", stat_short_name[i], atoi(argy));
              send_to_char (buf, ch);
	      return;
	    }
	}
    }


  if( !str_cmp(arg1, "location"))
    {
      char arg2[SML_LENGTH];
      int num;
      argy = one_argy(argy, arg2);
      if (!is_number(arg2))
	{
	  send_to_char("Syntax: location <number> <type>\n\r", ch);
	  return;
	}
      num = atoi(arg2);
      if (num < 0 || num > 4)
	{
	  send_to_char("Pick a number from 0-4 to set the location.\n\r", ch);
	  return;
	}
      if (argy == NULL || argy[0] == '\0' || argy == "")
	{
	  send_to_char ("Syntax: location <number> <modifier val>.\n\r", ch);
	  return;
	}
      if (affect_name_loc (argy) != -99)
	{
	  spell->location[num] = affect_name_loc (argy);
	  changed_spells = TRUE;
          sprintf(buf, "Location \x1B[1m%d\x1B[0m set to \x1B[1m%s\x1B[0m.\n\r", num, argy);
          send_to_char (buf, ch);
	  fnn = TRUE;
	}
      else
	{
	  send_to_char("Location not found.\n\r", ch);
	  return;
	}
    }
    }
  if (!fnn)
    interpret (ch, orarg);
  return;
}

SPELL_DATA *
new_spell (void)
{
  int jj;
  SPELL_DATA *spell;
  spell = mem_alloc (sizeof (*spell));
  bzero (spell, sizeof (*spell));
  top_spell++;
  spell->slot = 1;
  spell->noun_damage = str_dup ("Spell");
  for(jj = 1;jj < 300;jj ++)
   if (skill_lookup(NULL, jj) == NULL)
     { 
       spell->gsn = jj;
       break;
     }
  spell->spell_type = 0;
  spell->spell_bits = 0;
  spell->spell_name = str_dup ("Newspell");
  spell->spell_level = 0;
  spell->prereq_1 = NULL;
  spell->prereq_2 = NULL;
  spell->act_to_ch_1 = NULL;
  spell->act_to_ch_2 = NULL;
  spell->act_to_vict_1 = NULL;
  spell->act_to_vict_2 = NULL;
  spell->act_to_notvict_1 = NULL;
  spell->act_to_notvict_2 = NULL;
  for (jj = 0; jj < 5; jj++)
    {
      spell->location[jj] = 0;
      spell->modifier[jj] = NULL;
    }
  for (jj = 0; jj < NUM_STATS; jj ++)
    spell->min_stat[jj] = 0;
  for (jj = 0; jj < 4; jj++)
    spell->aff[jj] = 0;
  for (jj = 0; jj < NUM_GUILDS; jj++)
    spell->guilds[jj] = 0;
  spell->duration = NULL;
  spell->damage = NULL;
  spell->mana = 0;
  spell->mana_type = 0;
  spell->multi_mana = 0;
  spell->multi_mana_level[0] = 0;
  spell->multi_mana_level[1] = 0;
  spell->multi_mana_level[2] = 0;
  spell->multi_mana_level[3] = 0;
  spell->multi_mana_level[4] = 0;
  spell->casting_time = 0;
  spell->position = POSITION_RESTING;
  spell->wear_off_msg = str_dup ("The spell has worn off.");
  spell->creates_obj = 0;
  spell->spell_lag = 0;
  spell->in_room = 0;
  spell->fail_chance = 0;
  spell->pk_fail_chance = 0;
  spell->next = spell_list[spell->gsn % SPELL_HASH];
  spell_list[spell->gsn % SPELL_HASH] = spell;
  spell->next_a = spell_list_2[UPPER (spell->spell_name[0]) % SPELL_HASH];
  spell_list_2[UPPER (spell->spell_name[0]) % SPELL_HASH] = spell;
  return spell;
}

SPELL_DATA *
create_spell (int jj)
{
  SPELL_DATA *spell;
  spell = mem_alloc (sizeof (*spell));
  bzero (spell, sizeof (*spell));
  top_spell++;
  spell->slot = 1;
  spell->noun_damage = str_dup ("Spell");
  spell->gsn = jj;
  spell->spell_type = 0;
  spell->spell_bits = 0;
  spell->spell_name = str_dup ("Newspell");
  spell->spell_level = 0;
  spell->prereq_1 = NULL;
  spell->prereq_2 = NULL;
  spell->act_to_ch_1 = NULL;
  spell->act_to_ch_2 = NULL;
  spell->act_to_vict_1 = NULL;
  spell->act_to_vict_2 = NULL;
  spell->act_to_notvict_1 = NULL;
  spell->act_to_notvict_2 = NULL;
  for (jj = 0; jj < 5; jj++)
    {
      spell->location[jj] = 0;
      spell->modifier[jj] = NULL;
    }
  for (jj = 0; jj < NUM_STATS; jj ++)
    spell->min_stat[jj] = 0;
  for (jj = 0; jj < 4; jj++)
    spell->aff[jj] = 0;
  for (jj = 0; jj < NUM_GUILDS; jj++)
    spell->guilds[jj] = 0;
  spell->duration = NULL;
  spell->damage = NULL;
  spell->mana = 0;
  spell->mana_type = 0;
  spell->multi_mana = 0;
  spell->multi_mana_level[0] = 0;
  spell->multi_mana_level[1] = 0;
  spell->multi_mana_level[2] = 0;
  spell->multi_mana_level[3] = 0;
  spell->multi_mana_level[4] = 0;
  spell->casting_time = 0;
  spell->position = POSITION_RESTING;
  spell->wear_off_msg = str_dup ("The spell has worn off.");
  spell->creates_obj = 0; 
  spell->spell_lag = 0;
  spell->in_room = 0;
  spell->fail_chance = 0;
  spell->pk_fail_chance = 0;
  spell->next = spell_list[spell->gsn % SPELL_HASH];
  spell_list[spell->gsn % SPELL_HASH] = spell;
  spell->next_a = spell_list_2[UPPER (spell->spell_name[0]) % SPELL_HASH];
  spell_list_2[UPPER (spell->spell_name[0]) % SPELL_HASH] = spell;
  return spell;
}

/* Below is my translator. Variables accepted:
   l = level
   i = char's intelligence
   w = char's wisdom
   a = random from 1-10
   b = random from 10-20
   c = random from 20-30
   d = random from 1-level
   m = Syntax m42 would be max of 42 damage (numeric only)
   z = Syntax z3 would be minimum 3 damage (numeric only)
   k = kick damage
   t = max hit points... used for mob exp calc.
   please note: all operations are performed from left to right. This makes
   for simple coding, and a damn quick pass thru a complicated expression.
   sample:
   l+w/3 would be written in real terms as: l/3 + w/3 or (l+w)/3
   i+w+l*2/3+l would be written in real terms as: (((i+w)+l)*2)/3)+l
   You can now use parens :)
 */
char *pos;
long 
translate (char *line, int level, CHAR_DATA * ch)
{
  long dam = 0;
  long cur_num = 0;
  char *tp;
  char cur_op = '+';
  long ctt;
  if (!line)
    return 0;
  pos = line;
  for (pos = line; *pos != '\0'; pos++)
    {
      if (is_digit (*pos))
	{
	  cur_num *= 10;
	  cur_num += (*pos - '0');
	  continue;
	}
      if (*pos == ')')
	{
	  if (cur_op == '*')
	    dam *= cur_num;
	  if (cur_op == '/')
	    dam /= cur_num;
	  if (cur_op == '+')
	    dam += cur_num;
	  if (cur_op == '-')
	    dam -= cur_num;
	  if (cur_op == '\0')
	    dam = cur_num;
	  return dam;
	}
      if (*pos == '(')
	{
	  cur_num = translate (pos + 1, level, ch);
	  continue;
	}
      if (*pos == 't')
	{
	  cur_num = ch->max_hit;
	}
      
      if (*pos == 'z')
	{
	  int tnn = 0;
	  if (cur_op == '*')
	    dam *= cur_num;
	  if (cur_op == '/')
	    dam /= cur_num;
	  if (cur_op == '+')
	    dam += cur_num;
	  if (cur_op == '-')
	    dam -= cur_num;
	  if (cur_op == '\0')
	    dam = cur_num;
	  cur_op = '[';
	  cur_num = 0;
	  ctt = 0;
	  for (tp = pos + 1; *tp != '\0' && is_digit ((*tp)); tp++)
	    {
	      ctt++;
	      tnn *= 10;
	      tnn += (*tp - '0');
	    }
	  if (dam < tnn)
	    {
	      dam = tnn;
	      cur_num = tnn;
	    }
	  pos += ctt;
	  continue;
	}
      if (*pos == 'm')
	{
	  int tnn = 0;
	  if (cur_op == '*')
	    dam *= cur_num;
	  if (cur_op == '/')
	    dam /= cur_num;
	  if (cur_op == '+')
	    dam += cur_num;
	  if (cur_op == '-')
	    dam -= cur_num;
	  if (cur_op == '\0')
	    dam = cur_num;
	  cur_op = '[';
	  cur_num = 0;
	  ctt = 0;
	  for (tp = pos + 1; *tp != '\0' && is_digit ((*tp)); tp++)
	    {
	      ctt++;
	      tnn *= 10;
	      tnn += (*tp - '0');
	    }
	  if (dam > tnn)
	    {
	      dam = tnn;
	      cur_num = tnn;
	    }
	  pos += ctt;
	  continue;
	}
      if (*pos == '+')
	{
	  if (cur_op == '*')
	    dam *= cur_num;
	  if (cur_op == '/')
	    dam /= cur_num;
	  if (cur_op == '+')
	    dam += cur_num;
	  if (cur_op == '-')
	    dam -= cur_num;
	  if (cur_op == '\0')
	    dam = cur_num;
	  cur_op = '+';
	  cur_num = 0;
	}
      if (*pos == '-')
	{
	  if (cur_op == '*')
	    dam *= cur_num;
	  if (cur_op == '/')
	    dam /= cur_num;
	  if (cur_op == '+')
	    dam += cur_num;
	  if (cur_op == '-')
	    dam -= cur_num;
	  if (cur_op == '\0')
	    dam = cur_num;
	  cur_op = '-';
	  cur_num = 0;
	}
      if (*pos == '/')
	{
	  if (cur_op == '*')
	    dam *= cur_num;
	  if (cur_op == '/')
	    dam /= cur_num;
	  if (cur_op == '+')
	    dam += cur_num;
	  if (cur_op == '-')
	    dam -= cur_num;
	  if (cur_op == '\0')
	    dam = cur_num;
	  cur_op = '/';
	  cur_num = 0;
	}
      if (*pos == '*')
	{
	  if (cur_op == '*')
	    dam *= cur_num;
	  if (cur_op == '/')
	    dam /= cur_num;
	  if (cur_op == '+')
	    dam += cur_num;
	  if (cur_op == '-')
	    dam -= cur_num;
	  if (cur_op == '\0')
	    dam = cur_num;
	  cur_op = '*';
	  cur_num = 0;
	}
      if (*pos == 'd')
	cur_num = number_range (1, level);
      if (*pos == 'k')
	cur_num = ch->pcdata->plus_kick;
      if (*pos == 'l')
	cur_num = level;
      if (*pos == 'w' && ch)
	cur_num = get_curr_wis (ch);
      if (*pos == 'i' && ch)
	cur_num = get_curr_int (ch);
      if (*pos == 's' && ch)
	cur_num = get_curr_str (ch);
      if (*pos == 'x' && ch)
	cur_num = get_curr_con (ch);
      if (*pos == 'y' && ch)
	cur_num = get_curr_dex (ch);
      if (*pos == 'a')
	cur_num = number_range (1, 10);
      if (*pos == 'b')
	cur_num = number_range (10, 20);
      if (*pos == 'c')
	cur_num = number_range (20, 30);
    }
  if (cur_op == '*')
    dam *= cur_num;
  if (cur_op == '/')
    dam /= cur_num;
  if (cur_op == '+')
    dam += cur_num;
  if (cur_op == '-')
    dam -= cur_num;
  if (cur_op == '\0')
    dam = cur_num;
  return dam;
}













Site Stats

Snippets: 1791
Codebases: 571