/*******************************************************************************
Save this file to your ./src directory, and if necessary, add zoom.o to your
Makefile.  Alternately, just paste spell_warp into magic.c.  Now, follow the
rest of these instructions...
-------------------------------------------------------------------------merc.h-
Now, add this to struct area_data:
	int			  warp_room;
	int			  warp_cost;
------------------------------------------------------------------------magic.h-
Add this to the bottom of the file.

DECLARE_SPELL_FUN(	spell_warp			);
------------------------------------------------------------------------const.c-
Add this to your skill table.

    {
     "warp", {15, 20, 35, 45}, {2, 2, 3, 4},
     spell_warp, TAR_IGNORE, POS_STANDING,
     NULL, SLOT (0), 5, 12,
     "", "!Warp!", ""},
----------------------------------------------------------------------olc_act.c-
Add this to aedit_show, wherever you'd like:
    sprintf (buf, "Warp:     %s (room %d, %dmp)\n\r",
			 get_room_index (pArea->warp_room) ?
			 get_room_index (pArea->warp_room)->name : "none",
			 pArea->warp_room, pArea->warp_cost);
    send_to_char (buf, ch);

Add this function amongst the other aedit functions:
AEDIT (aedit_warp)
{
    AREA_DATA *pArea;
    char arg[MSL];

    EDIT_AREA (ch, pArea);

    argument = one_argument (argument, arg);

	if (!str_prefix (arg, "room"))
	{
		ROOM_INDEX_DATA * pRoom;
		int vnum;

		if (!is_number (argument) || argument[0] == '\0')
		{
			send_to_char ("Syntax:  warp room [vnum]\n\r", ch);
			return FALSE;
		}

		vnum = atoi (argument);
		
		if ((pRoom = get_room_index (vnum)) == NULL)
		{
			send_to_char ("No such room!\n\r", ch);
			return FALSE;
		}

		pArea->warp_room = vnum;
	    send_to_char ("Warp room set.\n\r", ch);
		return TRUE;
	}
	else if (!str_prefix (arg, "cost"))
	{
		if (!is_number (argument) || argument[0] == '\0')
		{
			send_to_char ("Syntax:  warp cost [cost]\n\r", ch);
			return FALSE;
		}

		pArea->warp_cost = atoi (argument);
	    send_to_char ("Warp cost set.\n\r", ch);
		return TRUE;
	}
	else
	{
		send_to_char ("Syntax:  warp [room|cost] [#]\n\r", ch);
		return FALSE;
	}
}
--------------------------------------------------------------------olc.c/olc.h-
Add the prototype and command entry for aedit_warp.
---------------------------------------------------------------------olc_save.c-
Find the following line in save_area():
    fprintf (fp, "End\n\n\n\n");
Put this above it:
	fprintf (fp, "Warp %d %d\n", pArea->warp_room, pArea->warp_cost);

**** IMPORTANT: Now, do a clean compile, copyover, and asave world.
---------------------------------------------------------------------------db.c-
Add this to the switch in new_load_area():
			case 'W':
                if (!str_cmp (word, "Warp"))
                {
                    pArea->warp_room = fread_number (fp);
                    pArea->warp_cost = fread_number (fp);
                }
                break;

Now compile and copyover again.  If it crashes, you ignored the important note.
Otherwise, enjoy.  I've included a default helpfile if you don't wish to write
your own.
--------------------------------------------------------------------------------
-1 'WARP'~
Syntax: cast warp

The Warp spell will take you to a predefined place, usually the entrance to,
the area you're in.  The actual casting cost differs from place to place.
~

*******************************************************************************/
/***************************************************************************
 * You may use this code as you see fit within any non-commercial MUD.     *
 * My only conditions are that my comments remain in tact, that you do not *
 * hesitate to give me feedback on the code, and that you don't claim my   *
 * work as your own.  Enjoy.                                    -- Midboss *
 * *********************************************************************** *
 * "Warp" spell for instant transportation out of dungeons.                *
 ***************************************************************************/
#include <stdio.h>
#include "merc.h"
#include "interp.h"

/*
 * Comment this out if you want it to be user only.
 */
#define GROUP


void spell_warp (int sn, int level, CHAR_DATA * ch, void *vo, int target)
{
	ROOM_INDEX_DATA * to_room, * was_in;
	AREA_DATA * pArea;
	CHAR_DATA * gch, * gch_next;
	int cost = 0, members = 1;

	pArea = ch->in_room->area;
	to_room = get_room_index (pArea->warp_room);
	was_in = ch->in_room;

	/*
	 * Are we allowed?
	 */
	if (IS_SET (ch->in_room->room_flags, ROOM_NO_RECALL)
		|| to_room == NULL)
	{
		send_to_char ("You can't warp out of here.\n\r", ch);
		return;
	}

#ifdef GROUP
	for (gch = ch->in_room->people; gch != NULL; gch = gch->next_in_room)
		if (is_same_group (gch, ch) && gch != ch)
			++members;
#endif

	/*
	 * Check the mana cost.
	 */
	cost = pArea->warp_cost * members;

	if (ch->mana < cost)
	{
		send_to_char ("You don't have enough mana.\n\r", ch);
		return;
	}

	ch->mana = UMAX (0, ch->mana - cost);

	/*
	 * Now move the character.
	 */
	act ("You disappear in a flash of light.",
			ch, NULL, NULL, TO_CHAR);
    act ("$n disappears in a flash of light.",
			ch, NULL, NULL, TO_ROOM);

    char_from_room (ch);
    char_to_room (ch, to_room);

    act ("$n suddenly appears in a flash of light.",
			ch, NULL, NULL, TO_ROOM);
    do_function (ch, &do_look, "auto");

	/*
	 * Move the group if necessary.
	 */
#ifdef GROUP
	for (gch = was_in->people; gch != NULL; gch = gch_next)
	{
		gch_next = gch->next_in_room;

		if (is_same_group (gch, ch) && gch != ch)
		{
			act ("You disappear in a flash of light.",
					gch, NULL, NULL, TO_CHAR);
			act ("$n disappears in a flash of light.",
					gch, NULL, NULL, TO_ROOM);

			char_from_room (gch);
			char_to_room (gch, to_room);

			act ("$n suddenly appears in a flash of light.",
					gch, NULL, NULL, TO_ROOM);
			do_function (gch, &do_look, "auto");
		}
	}
#endif

}