/***************************************************************************
* Yet another credit:) This snippet modified by Ghreth, origional author   *
* listed below, credits to the code go to them, more credits to Kyndig for *
* the timed events code being used. Special thanks to Aidan_Rod with an    *
* early bug fix, and other members of the mudmagic community.              *
***************************************************************************/

/*First things first*/
/*Install Kyndigs timed events code or this wont work.*/
/*Install forger V2 or this wont work.*/
/*Once you get these working, continue:*/

/*In merc.h under pc_data add*/
sh_int forge_check;
/*The forge_check is NOT added into save.c/fwrite_char, ect because
it isnt that important. If a char logs off before his forged weapon
gets returned to him, its extracted. The forger doesnt hold on to the
weapons very long, so if a char cant wait a few minutes then he can log
off with out his weapon, who cares, his loss:)*/

/*In act_obj in do_steal, if you dont have sendf, change it to sprintf format*/
if ( IS_NPC(victim) && IS_SET(victim->act, ACT_FORGER) )
    {
	    sendf(ch, "%s is far too alert for such actions to take place!\n\r", 
		capitalize(victim->short_descr));
		percent = 0;
    }
/*The check in do_steal is so people dont steal weapons that are being forged,
im thinking of just adding a new bit later, ACT_NO_STEAL, but for now this
will do since its the only mob I dont want stolen from.*/

/*Replace event_update with this one.*/
/*
 * Handle events.
 */
void event_update(void)
{
   EVENT_DATA *ev = NULL, *ev_next, *ev_last = ev;
   
   /*Begin modification*/
   CHAR_DATA *ch, *ch_next;

    for ( ch = char_list; ch != NULL; ch = ch_next )
    {
        ch_next = ch->next;

	/*This ticks off the forge_check tha same time the
   event ticks are going off, they stay in sync.*/
		if (!IS_NPC(ch)) 
	{
		if(ch->pcdata->forge_check > 0)
	{
		   ch->pcdata->forge_check--;
	}
	}
	}
	/*End Modification.*/

   if(!events) return;

   for( ev = events; ev; ev = ev_next)
   {
        ev_next = ev->next;
        if(ev->delay-- <= 0)
        {
            switch(ev->action)
            {
                case ACTION_PRINT:
                  if( ( !ev->args[0]) || (! ev->argv[0] ) )
                  {
                      kill_event
                  }
                  send_to_char( ev->args[0], ev->argv[0] );
                  break;

                case ACTION_FUNCTION:
                  if( !ev->args[0] )
                  {
                      kill_event
                  }
                  do_function(ev->argv[0], ev->do_fun, ev->args[0]);
                  break;

                case ACTION_WAIT:
                  if(!ev->argv[0])
                  {
                      kill_event
                  }
                  DAZE_STATE(ev->to,PULSE_PER_SECOND*ev->argi[0]);
                  break;

                case ACTION_ACT:
                  if(!ev->args[0] || !ev->argv[0])
                  {
                       kill_event
                  }
                  act(ev->args[0], ev->argv[0], ev->argv[1],ev->argv[2],ev->argi[0]);
                  break;
            }

            if(!ev_next)
            {
                 if( (ev != events) && (ev_last != NULL) )
                 {
                      if( ev_last->next == ev )
                         ev_last->next=NULL;
                 }
                 else
                 {
                 if( ev == events)
                    events = NULL;
                 }
                 free_event( ev );
                 return;
            }

            if( ev_last != NULL)
                ev_last->next = ev_next;
            else
                events = ev_next;

            free_event( ev );
            continue;
        } /* end delay */

        ev_last = ev;

   } /* end loop */
return;
}

/*This code no longer needs the spells of spell_flame_blade and the rest,
the code now sets the weapon flag and sends an act. The spells have been
included with the snippet in case you want to use them someday for something
else or whatnot.*/

/*If you have all your forger code in one .c file, replace that file with
everything below this comment.*/

/***************************************************************************
 *      This snippet was origionaly written by Donut & Buba for the Khrooon* 
 *      Mud.  Original Coded by Yago Diaz <yago@cerberus.uab.es>           *
 *	  (C) November 1996             		   	   	                       *
 *	  (C) Last Modification September 1997          		               *
 ***************************************************************************/
/***************************************************************************
 *     ANATOLIA 2.1 is copyright 1996-1997 Serdar BULUT, Ibrahim CANPUNAR  *
 *     ANATOLIA has been brought to you by ANATOLIA consortium		       *
 *	 Serdar BULUT {Chronos}		bulut@rorqual.cc.metu.edu.tr               *
 *	 Ibrahim Canpunar  {Asena}	canpunar@rorqual.cc.metu.edu.tr            *	
 *	 Murat BICER  {KIO}		mbicer@rorqual.cc.metu.edu.tr	               *
 *	 D.Baris ACAR {Powerman}	dbacar@rorqual.cc.metu.edu.tr	           *	
 *     By using this code, you have agreed to follow the terms of the      *
 *     ANATOLIA license, in the file Anatolia/anatolia.licence             *	
 ***************************************************************************/

/***************************************************************************
 *  Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,	   *
 *  Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe.   *
 *									   *
 *  Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael	   *
 *  Chastain, Michael Quan, and Mitchell Tse.				   *
 *									   *
 *  In order to use any part of this Merc Diku Mud, you must comply with   *
 *  both the original Diku license in 'license.doc' as well the Merc	   *
 *  license in 'license.txt'.  In particular, you may not remove either of *
 *  these copyright notices.						   *
 *									   *
 *  Much time and thought has gone into this software and you are	   *
 *  benefitting.  We hope that you share your changes too.  What goes	   *
 *  around, comes around.						   *
 ***************************************************************************/
 
/***************************************************************************
*	ROM 2.4 is copyright 1993-1995 Russ Taylor			   *
*	ROM has been brought to you by the ROM consortium		   *
*	    Russ Taylor (rtaylor@pacinfo.com)				   *
*	    Gabrielle Taylor (gtaylor@pacinfo.com)			   *
*	    Brian Moore (rom@rom.efn.org)				   *
*	By using this code, you have agreed to follow the terms of the	   *
*	ROM license, in the file Rom24/doc/rom.license			   *
***************************************************************************/

#if defined(macintosh)
#include <types.h>
#include <time.h>
#else
#include <sys/types.h>
#include <sys/time.h>
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "merc.h"
#include "magic.h"
#include "tables.h"
#include "interp.h"

DECLARE_DO_FUN(	do_say	);

CHAR_DATA * find_forger ( CHAR_DATA *ch )
{
    CHAR_DATA * forger;

    for ( forger = ch->in_room->people; forger != NULL; forger = forger->next_in_room ) {
	if (!IS_NPC(forger))
	    continue;

        if ( IS_NPC(forger) && IS_SET(forger->act, ACT_FORGER) )
	    return forger;
    }

    if ( forger == NULL ) {
	send_to_char("You can't do that here.\n\r", ch);
	return NULL;
    }

    return NULL;
}

/*I needed a way to have the wait_function use the
obj_to_char and obj_from_char, so I came up with this.*/
void do_obj_from_to_char( CHAR_DATA *ch, char *argument )
{
	char arg1[MAX_INPUT_LENGTH];
	char arg2[MAX_INPUT_LENGTH];
	OBJ_DATA *obj;
	CHAR_DATA *victim;

	argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );

  /*Check the args*/
	if( arg1[0] == '\0' || arg2[0] == '\0')
    {
        send_to_char( "obj_from_to_char no arg?\n\r", ch );
        return;
    }

  /*Make sure we have the obj*/  
  if ( ( obj = get_obj_carry( ch, arg1, ch ) ) == NULL )
    {
	send_to_char( "You do not have that item.\n\r", ch );
	return;
    }

    /*Is the char still logged on? If not, extract the object*/	
  if ( ( victim = get_char_world( ch, arg2 ) ) == NULL )
    {
	send_to_char( "They aren't here.\n\r", ch );
	extract_obj(obj);
	return;
    }

    /*All goes well, get the item to the char*/	    
        obj_from_char( obj );
		obj_to_char( obj, victim );
	    return;
}

/*I wrote this to shorten up some repetitive code*/
void send_it ( CHAR_DATA *forger, CHAR_DATA *ch, OBJ_DATA *obj )
{
	char buf[MSL];

	/*Set the forge_check to as long as it takes to
	play out the entire wait_acts.*/
	ch->pcdata->forge_check = 31;	
	
	    xprintf(buf,"%s tells you '{R%s is finished, i'm sending it to you now.{x'",
			capitalize(forger->short_descr), obj->short_descr);
	    wait_act(30, buf,ch, NULL, NULL, TO_CHAR);

		/*Get the item to the CHAR via wait_function*/
		xprintf(buf,"'%s' '%s'", obj->name, ch->name);
        wait_function(forger, 31, do_obj_from_to_char, (char *)(buf));

		xprintf(buf,"{y%s appears in your inventory.{x",capitalize(obj->short_descr));
	    wait_act(31, buf,ch, NULL, NULL, TO_CHAR);
		return;
}

void do_forge( CHAR_DATA *ch, char *argument )
{
    OBJ_DATA  *	obj;
    CHAR_DATA * forger;
    char	weapon[MAX_INPUT_LENGTH];
	/*I have long long bits, if you dont, change the long long back to long.*/
    long long cost;
    char buf[MAX_STRING_LENGTH];
	bool is_affected = FALSE;

    forger = find_forger(ch);
	/*I set a base cost, you can easily make different costs for the
	different flags, cost2 = 26000, cost3 = 51000, ect ect. Then change
	the cost in the proper args from 'cost' to 'cost1' or 'cost2', ect ect.*/
	cost = 35000;
				    
    /*Room check for the Forger*/
	if (!forger)
	return;

    /*First check for the proper args*/    
	if (argument[0] == '\0') 
    {	
	    xprintf(buf, "My possible fashions are..");
        do_sayto (forger, ch,buf);
        wait_act(0, "$N explains his possible fashions to $n.", 
        ch, NULL, forger, TO_NOTVICT);
	
	    send_to_char("\n\r[Price -- ] Type\n\r", ch);
        send_to_char("[35000 -- ] {Ddrain{x\n\r",ch);
		send_to_char("[35000 -- ] {Yshocking{x\n\r",ch);
		send_to_char("[35000 -- ] {cfrost{x\n\r",ch);
		send_to_char("[35000 -- ] {Wsharp{x\n\r",ch);
		send_to_char("[35000 -- ] {Rflame{x\n\r",ch);
		send_to_char("[35000 -- ] {mvorpal{x\n\r",ch);
        send_to_char("\n\rSyntax: fashion <your weapon> <type>\n\r",ch);
	    return;
    }
    
        argument = one_argument ( argument, weapon);

        /*Is the char carrying the obj?*/
		if ( ( obj = get_obj_carry( ch, weapon, ch) ) == NULL ) 
    {
		xprintf(buf, "You don't seem to be carrying that.");
        do_sayto (forger, ch, buf);
        return;
    }
    
        /*Is the obj a weapon?*/
		if(obj->item_type != ITEM_WEAPON) 
    {
		xprintf(buf, "%s is not a weapon.", capitalize(obj->short_descr));
        do_sayto (forger, ch, buf);
        return;
    }

	    /*Another arg check*/
		if ( argument[0] == '\0' ) 
    {
        xprintf(buf, "Type 'fashion' to see the list of modifications.");
        do_sayto (forger, ch, buf);
		return;
    }

	    /*Does the char have enough gold?*/
		if ( cost > ch->gold ) 
    {
	    xprintf(buf, "Sorry, you do not have enough gold for my services.");
        do_sayto (forger, ch, buf);
	    return;
    }

		/*I added a forge_check to prevent multiple forges at the same time.*/
		if(ch->pcdata->forge_check >= 1) 
    {
		xprintf(buf, "I am already doing something for you, come back later.");
        do_sayto (forger, ch, buf);
        return;
    }

		/*Check the args and check the weapon for the weapon flag*/
		if ((!str_prefix(argument,"flaming") 
			|| !str_prefix(argument,"flam") )
			&& IS_WEAPON_STAT( obj, WEAPON_FLAMING))
			is_affected = TRUE;
		if ((!str_prefix(argument,"vampiric")  
			|| !str_prefix(argument,"vamp") )
			&& IS_WEAPON_STAT( obj, WEAPON_VAMPIRIC))
			is_affected = TRUE;
		if ((!str_prefix(argument,"shocking")  
			|| !str_prefix(argument,"shock") )
			&& IS_WEAPON_STAT( obj, WEAPON_SHOCKING))
			is_affected = TRUE;
		if ((!str_prefix(argument,"frosty")  
			|| !str_prefix(argument,"frost") )
			&& IS_WEAPON_STAT( obj, WEAPON_FROST))
			is_affected = TRUE;
		if ((!str_prefix(argument,"sharp")  
			|| !str_prefix(argument,"shar")) 
			&& IS_WEAPON_STAT( obj, WEAPON_SHARP))
			is_affected = TRUE;
		if ((!str_prefix(argument,"vorpal")  
			|| !str_prefix(argument,"vorp") )
			&& IS_WEAPON_STAT( obj, WEAPON_VORPAL))
			is_affected = TRUE;

		/*Returned check from above, you cannot add flaming to a weapon
		thats already flaming, ect ect*/
		if (is_affected)
	{
		xprintf(buf, "%s is already affected by that.", capitalize(obj->short_descr));
        do_sayto (forger, ch, buf);
        return;
    }
	
        /*First call, repeated for all weapon flags*/
		/*Check the args*/
		if (!str_prefix(argument,"flaming") || !str_prefix(argument,"flam") ) 
    {
	    /*Make the char GIVE the item to the forger, show for RP*/
		xprintf(buf, "'%s' '%s'", obj->name, forger->name);
	    wait_function(ch, 0, do_give, (char *)(buf));

		/*Set the flag*/
		SET_BIT(obj->value[4], WEAPON_FLAMING);
	
	    /*If the flag is set, go through the motions, things like
		this take time, hence the wait_acts instead of just acts.*/
		if ( IS_WEAPON_STAT ( obj, WEAPON_FLAMING)) 
	{	    	    	              	             
		xprintf(buf, "This will take a little while, ill get it to you when its done.");
        do_sayto (forger, ch, buf);

		wait_act(10, "$n licks his mouth then begins working on $p.", 
	    forger,obj,ch,TO_ROOM);
	    wait_act(20, "A wave of heat fills the air as $n's hands grip the $p.", 
	    forger,obj,0,TO_ROOM);
	    wait_act(30, "$n admires the $p as it ignites, bursting into flame.", 
	    forger, obj, NULL, TO_ROOM );

		/*Get the obj back to the char*/
		send_it ( forger, ch, obj );
	}
	    else
	{
	    /*Something screwy, inform the char of a bug.*/
		xprintf(buf, "[BUG!!]Im sorry %s, I cannot help you, Inform an Immortal.", ch->name);
        do_sayto (forger, ch,buf);
		return;
	}
        /*Make the char pay for the service since all went well.*/
		deduct_cost(ch, forger, cost); 
        return;
    }
    
        if (!str_prefix(argument,"vampiric") || !str_prefix(argument,"vamp") ) 
    {
        xprintf(buf, "'%s' '%s'", obj->name, forger->name);
	    wait_function(ch, 0, do_give, (char *)(buf));

        SET_BIT(obj->value[4], WEAPON_VAMPIRIC);

        if ( IS_WEAPON_STAT ( obj, WEAPON_VAMPIRIC) ) 
	{
        xprintf(buf, "This will take a little while, ill get it to you when its done.");
        do_sayto (forger, ch, buf);
		
		wait_act(10, "$n grins evilly at $p, then begins working on it.", 
        forger,obj,ch,TO_ROOM);
        wait_act(20, "Coating a $p with a dark fluid, $n continues his work.", 
        forger,obj,0,TO_ROOM);
        wait_act(30, "$n admires the $p as it drips a black taint.", 
        forger, obj, NULL, TO_ROOM );

		send_it ( forger, ch, obj );
	}
        else
	{
	    xprintf(buf, "[BUG!!]Im sorry %s, I cannot help you, Inform an Immortal.", ch->name);
        do_sayto (forger, ch,buf);
		return;
	}
        deduct_cost(ch, forger, cost); 
        return;
    }

        if (!str_prefix(argument,"shocking") || !str_prefix(argument,"shock") ) 
    {
        xprintf(buf, "'%s' '%s'", obj->name, forger->name);
	    wait_function(ch, 0, do_give, (char *)(buf));

        SET_BIT(obj->value[4], WEAPON_SHOCKING);
            
        if ( IS_WEAPON_STAT ( obj, WEAPON_SHOCKING) ) 
	{
        xprintf(buf, "This will take a little while, ill get it to you when its done.");
        do_sayto (forger, ch, buf);
		
		wait_act(10, "$n nods, then begins working on $p.", 
        forger,obj,ch,TO_ROOM);
        wait_act(20, "As a strange energy corses through $n's hands, the $p lets off a few sparks.", 
        forger,obj,0,TO_ROOM);
        wait_act(30, "$n admires the $p as it surges with energy.", 
        forger, obj, NULL, TO_ROOM );

		send_it ( forger, ch, obj );
	}
        else
	{
	    xprintf(buf, "[BUG!!]Im sorry %s, I cannot help you, Inform an Immortal.", ch->name);
        do_sayto (forger, ch,buf);
		return;
	}
        deduct_cost(forger,ch,cost); 
        return;
    }

        if (!str_prefix(argument,"frosty") || !str_prefix(argument,"frost") ) 
    {
        xprintf(buf, "'%s' '%s'", obj->name, forger->name);
	    wait_function(ch, 0, do_give, (char *)(buf));

        SET_BIT(obj->value[4], WEAPON_FROST);
	
        if ( IS_WEAPON_STAT ( obj, WEAPON_FROST) ) 
	{
        xprintf(buf, "This will take a little while, ill get it to you when its done.");
        do_sayto (forger, ch, buf);
		
		wait_act(10, "$n shivers uncomfortably, then begins working on $p.", 
        forger,obj,ch,TO_ROOM);
        wait_act(20, "A cold chill fills the air as $n's hands grip the $p.", 
        forger,obj,0,TO_ROOM);
        wait_act(30, "$n admires the $p as it slowly frosts over.", 
        forger, obj, NULL, TO_ROOM );

		send_it ( forger, ch, obj );
	}
        else
	{
	    xprintf(buf, "[BUG!!]Im sorry %s, I cannot help you, Inform an Immortal.", ch->name);
        do_sayto (forger, ch,buf);
		return;
	}
        deduct_cost(forger,ch,cost); 
        return;
    }

        if (!str_prefix(argument,"sharp") || !str_prefix(argument,"shar") ) 
    {
        xprintf(buf, "'%s' '%s'", obj->name, forger->name);
	    wait_function(ch, 0, do_give, (char *)(buf));

        SET_BIT(obj->value[4], WEAPON_SHARP);
	
        if ( IS_WEAPON_STAT ( obj, WEAPON_SHARP) ) 
	{
        xprintf(buf, "This will take a little while, ill get it to you when its done.");
        do_sayto (forger, ch, buf);
		
		wait_act(10, "$n winks, then begins working on $p.", 
        forger,obj,ch,TO_ROOM);
        wait_act(20, "Pounding the anvil, $n hammers away at $p.", 
        forger,obj,0,TO_ROOM);
        wait_act(30, "$n admires the craftmanship on $p as its blade gleams.", 
        forger, obj, NULL, TO_ROOM );

		send_it ( forger, ch, obj );
	}
        else
	{
	    xprintf(buf, "[BUG!!]Im sorry %s, I cannot help you, Inform an Immortal.", ch->name);
        do_sayto (forger, ch,buf);
		return;
	}
        deduct_cost(forger,ch,cost); 
        return;
    }

        if (!str_prefix(argument,"vorpal") || !str_prefix(argument,"vorp") ) 
    {
        xprintf(buf, "'%s' '%s'", obj->name, forger->name);
	    wait_function(ch, 0, do_give, (char *)(buf));

        SET_BIT(obj->value[4], WEAPON_VORPAL);
	
        if ( IS_WEAPON_STAT ( obj, WEAPON_VORPAL) ) 
	{
        xprintf(buf, "This will take a little while, ill get it to you when its done.");
        do_sayto (forger, ch, buf);

		wait_act(10, "$n coughs, then begins working on $p.", 
        forger,obj,ch,TO_ROOM);
        wait_act(20, "Pounding the anvil, $n forges a dual blade on $p.", 
        forger,obj,0,TO_ROOM);
        wait_act(30, "$n admires the craftmanship on $p as its dual blade seems to rotate.", 
        forger, obj, NULL, TO_ROOM );

		send_it ( forger, ch, obj );
	}
        else
	{
	    xprintf(buf, "[BUG!!]Im sorry %s, I cannot help you, Inform an Immortal.", ch->name);
        do_sayto (forger, ch,buf);
		return;
	}
        deduct_cost(forger,ch,cost); 
        return;
    }

        xprintf(buf, "I repeat, my possible fashions are..");
        do_sayto (forger, ch,buf);
        wait_act(0, "$N explains his possible fashions to $n.", 
        ch, NULL, forger, TO_NOTVICT);
		wait_act(0, "And $N explains his possible fashions to you yet again.", 
        ch, NULL, forger, TO_CHAR);
	
	    send_to_char("\n\r[Price -- ] Type\n\r", ch);
		send_to_char("[35000 -- ] {Ddrain{x\n\r",ch);
		send_to_char("[35000 -- ] {Yshocking{x\n\r",ch);
		send_to_char("[35000 -- ] {cfrost{x\n\r",ch);
		send_to_char("[35000 -- ] {Wsharp{x\n\r",ch);
		send_to_char("[35000 -- ] {Rflame{x\n\r",ch);
		send_to_char("[35000 -- ] {mvorpal{x\n\r",ch);
        send_to_char("\n\rSyntax: fashion <your weapon> <type>\n\r",ch);
        return;								 
}


void spell_drain_blade( int sn, int level, CHAR_DATA *ch, void *vo, int target )
{
    OBJ_DATA * obj = (OBJ_DATA *) vo;
    AFFECT_DATA af;
   
    if(obj->item_type != ITEM_WEAPON) {
	send_to_char("You can only cast this spell on weapons.\n\r",ch);
	return;
    }

    if(IS_WEAPON_STAT(obj,WEAPON_VAMPIRIC)) {
	send_to_char("This weapon is already vampiric.\n\r", ch);
	return;
    }

    if(IS_OBJ_STAT(obj,ITEM_BLESS)) {
	send_to_char("This weapon is too blessed.\n\r", ch);
	return;
    }

    af.where    = TO_WEAPON;
    af.type     = sn;
    af.level    = 20;
    af.duration = 50;
    af.location = 0;
    af.modifier = 0;
    af.bitvector = WEAPON_VAMPIRIC;
    affect_to_obj(obj, &af);

    act("$p carried by $n turns dark and vampiric.", ch, obj, NULL, TO_ROOM);
    act("$p carried by you turns dark and vampiric.", ch, obj, NULL, TO_CHAR);
    return;
}

void spell_shocking_blade( int sn, int level, CHAR_DATA *ch, void *vo, int target )
{
    OBJ_DATA * obj = (OBJ_DATA *) vo;
    AFFECT_DATA af;

    if(obj->item_type != ITEM_WEAPON) {
	send_to_char("You can only cast this spell on weapons.\n\r",ch);
	return;
    }

    if(IS_WEAPON_STAT(obj,WEAPON_SHOCKING)) {
	send_to_char("This weapon is already electrical.\n\r", ch);
	return;
    }

    af.where    = TO_WEAPON;
    af.type     = sn;
    af.level    = 20;
    af.duration = 50;
    af.location = 0;
    af.modifier = 0;
    af.bitvector = WEAPON_SHOCKING;
    affect_to_obj(obj, &af);

    act("$p carried by $n sparks with electricity.", ch, obj, NULL, TO_ROOM);
    act("$p carried by you sparks with electricity.", ch, obj, NULL, TO_CHAR);
    return;
}


void spell_flame_blade( int sn, int level, CHAR_DATA *ch, void *vo, int target )
{
    OBJ_DATA *obj = (OBJ_DATA *) vo;
    AFFECT_DATA af;

    if(obj->item_type != ITEM_WEAPON) {
	send_to_char("You can only cast this spell on weapons.\n\r",ch);
	return;
    }

    if(IS_WEAPON_STAT(obj,WEAPON_FLAMING)) {
	send_to_char("This weapon is already flaming.\n\r", ch);
	return;
    }

    if(IS_WEAPON_STAT(obj,WEAPON_FROST)) {
	send_to_char("This weapon is too frost to handle this magic.\n\r", ch);
	return;
    }
          
    af.where    = TO_WEAPON;
    af.type     = sn;
    af.level    = 20;
    af.duration = 50;
    af.location = 0;
    af.modifier = 0;
    af.bitvector = WEAPON_FLAMING;
    affect_to_obj(obj, &af);

    act("$p carried by $n gets a fiery aura.", ch, obj, NULL, TO_ROOM);
    act("$p carried by you gets a fiery aura.", ch, obj, NULL, TO_CHAR);
    return;
}

void spell_frost_blade( int sn, int level, CHAR_DATA *ch, void *vo, int target )
{
    OBJ_DATA *obj = (OBJ_DATA *) vo;
    AFFECT_DATA af;

    if(obj->item_type != ITEM_WEAPON) {
	send_to_char("You can only cast this spell on weapons.\n\r",ch);
	return;
    }

    if(IS_WEAPON_STAT(obj,WEAPON_FROST)) {
	send_to_char("This weapon is already frost.\n\r", ch);
	return;
      }

    if(IS_WEAPON_STAT(obj,WEAPON_FLAMING)) {
	send_to_char("This weapon is too cold to handle this magic.\n\r", ch);
	return;
    }

    af.where    = TO_WEAPON;
    af.type     = sn;
    af.level    = 20;
    af.duration = 50;
    af.location = 0;
    af.modifier = 0;
    af.bitvector = WEAPON_FROST;
    affect_to_obj(obj, &af);

    act("$p carried by $n grows wickedly cold.", ch, obj, NULL, TO_ROOM);
    act("$p carried by you grows wickedly cold.", ch, obj, NULL, TO_CHAR);
    return;
}

void spell_sharp_blade( int sn, int level, CHAR_DATA *ch, void *vo, int target )
{
    OBJ_DATA *obj = (OBJ_DATA *) vo;
    AFFECT_DATA af;

    if(obj->item_type != ITEM_WEAPON) {
	send_to_char("You can only cast this spell on weapons.\n\r",ch);
	return;
    }

    if(IS_WEAPON_STAT(obj,WEAPON_SHARP)) {
	send_to_char("This weapon is already sharp.\n\r", ch);
	return;
    }

    af.where    = TO_WEAPON;
    af.type     = sn;
    af.level    = 20;
    af.duration = 50;
    af.location = 0;
    af.modifier = 0;
    af.bitvector = WEAPON_SHARP;
    affect_to_obj(obj, &af);

    act("$p carried by $n looks newly honed.", ch, obj, NULL, TO_ROOM);
    act("$p carried by you looks newly honed.", ch, obj, NULL, TO_CHAR);
    return;
}

void spell_vorpal_blade( int sn, int level, CHAR_DATA *ch, void *vo, int target )
{
    OBJ_DATA *obj = (OBJ_DATA *) vo;
    AFFECT_DATA af;

    if(obj->item_type != ITEM_WEAPON) {
	send_to_char("You can only cast this spell on weapons.\n\r",ch);
	return ;
    }

    if(IS_WEAPON_STAT(obj,WEAPON_VORPAL)) {
	send_to_char("This weapon is already vorpal.\n\r", ch);
	return;
    }

    af.where    = TO_WEAPON;
    af.type     = sn;
    af.level    = level/2;
    af.duration = level;
    af.location = 0;
    af.modifier = 0;
    af.bitvector = WEAPON_VORPAL;
    affect_to_obj(obj, &af);

    act("$p carried by $n gleams with magical strength.", ch, obj, NULL, TO_ROOM);
    act("$p carried by you gleams with magical strength.", ch, obj, NULL, TO_CHAR);
    return;
}