empiremud/cnf/
empiremud/doc/
empiremud/lib/boards/
empiremud/lib/etc/
empiremud/lib/misc/
empiremud/lib/plralias/F-J/
empiremud/lib/plralias/K-O/
empiremud/lib/plralias/P-T/
empiremud/lib/plralias/U-Z/
empiremud/lib/plrobjs/
empiremud/lib/plrobjs/F-J/
empiremud/lib/plrobjs/K-O/
empiremud/lib/plrobjs/P-T/
empiremud/lib/plrobjs/U-Z/
empiremud/lib/world/
empiremud/lib/world/mob/
empiremud/lib/world/obj/
empiremud/log/
/* ************************************************************************
*   File: act.god.c                                      EmpireMUD AD 1.0 *
*  Usage: Player-level God commands                                       *
*                                                                         *
*  All rights reserved.  See license.doc for complete information.        *
*                                                                         *
*  Code base by Paul Clarke.  EmpireMUD Project, a tbgMUD Production.     *
*  Based upon CircleMUD 3.0, beta patch level 17, by Jeremy Elson.        *
*                                                                         *
*  Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
*  CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991.               *
************************************************************************ */

#include "conf.h"
#include "sysdep.h"

#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "vnums.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"
#include "skills.h"
#include "empire.h"


#define GOD_LINE_BREAK	{ "\t",	NOTHING, { 0, 0, 0, 0, 0, 0, 0, 0, 0 } }


struct create_data {
	char *name;
	obj_vnum vnum;
	int res[NUM_ITEM_MATS];
	} resource[] = {
								/*     W   R   I   S   G   F   C   F   G     */
								/*     o   o   r   l   o   l   l   l   l     */
								/*     o   c   o   v   l   n   a   s   a     */
								/*     d   k   n   r   d   t   y   h   s     */
		/* Wood */
		{ "stick",		o_STICK,	{  1,  0,  0,  0,  0,  0,  0,  0,  0 } },
		{ "handle",		o_HANDLE,	{  1,  0,  0,  0,  0,  0,  0,  0,  0 } },
		{ "tree",		o_TREE,		{ 15,  0,  0,  0,  0,  0,  0,  0,  0 } },
		{ "log",		o_LOG,		{ 10,  0,  0,  0,  0,  0,  0,  0,  0 } },
		{ "torch",		o_TORCH,	{  1,  0,  0,  0,  0,  0,  0,  0,  0 } },
		{ "canoe",		o_CANOE,	{ 10,  0,  0,  0,  0,  0,  0,  0,  0 } },
		{ "chair",		o_CHAIR,	{ 22,  0,  1,  0,  0,  0,  0,  0,  0 } },
		{ "bench",		o_BENCH,	{ 42,  0,  3,  0,  0,  0,  0,  0,  0 } },
		{ "table",		o_TABLE,	{ 42,  0,  3,  0,  0,  0,  0,  0,  0 } },
		{ "stool",		o_STOOL,	{ 12,  0,  1,  0,  0,  0,  0,  0,  0 } },
		{ "beehive",	o_BEEHIVE,	{ 35,  0,  8,  0,  0,  0,  0,  0,  0 } },
		{ "arrow",		o_ARROW,	{  1,  0,  0,  0,  0,  0,  0,  0,  0 } },
		{ "shortbow",	o_SHORTBOW,	{  2,  0,  0,  0,  0,  0,  0, 20,  0 } },
		{ "longbow",	o_LONGBOW,	{  3,  0,  0,  0,  0,  0,  0, 20,  0 } },
		{ "lyre",		o_LYRE,		{ 10,  0,  0,  0,  0,  0,  0,  0,  0 } },
		{ "flute",		o_FLUTE,	{  1,  0,  0,  0,  0,  0,  0,  0,  0 } },
		{ "walkingstick",o_WALKING_STICK,	{  1,  0,  0,  0,  0,  0,  0,  0,  0 } },
		{ "stake",		o_STAKE,	{  1,  0,  0,  0,  0,  0,  0,  0,  0 } },
		GOD_LINE_BREAK,

		/* Food */
		{ "apple",		o_APPLES,	{  1,  0,  0,  0,  0,  0,  0,  1,  0 } },
		{ "corn",		o_CORN,		{  0,  0,  0,  0,  0,  1,  0,  1,  0 } },
		{ "wheat",		o_WHEAT,	{  0,  1,  0,  0,  0,  0,  0,  1,  0 } },
		{ "flour",		o_FLOUR,	{  0,  1,  0,  0,  0,  0,  0,  1,  0 } },
		{ "bread",		o_BREAD,	{  0,  1,  0,  0,  0,  0,  0,  1,  0 } },
		{ "flower",		o_FLOWER,	{  0,  0,  0,  0,  0,  0,  0,  1,  0 } },
		GOD_LINE_BREAK,

		/* Rocks */
		{ "rock",		o_ROCK,		{  0,  1,  0,  0,  0,  0,  0,  0,  0 } },
		{ "chippedrock", o_CHIPPED,	{  0,  1,  0,  0,  0,  0,  0,  0,  0 } },
		{ "handaxe",	o_HANDAXE,	{  0,  1,  0,  0,  0,  0,  0,  0,  0 } },
		{ "axe",		o_AXE,		{  1,  1,  0,  0,  0,  0,  0,  0,  0 } },
		{ "spear",		o_SPEAR,	{  1,  1,  0,  0,  0,  0,  0,  0,  0 } },
		{ "spearhead",	o_SPEARHEAD,{  0,  1,  0,  0,  0,  0,  0,  0,  0 } },
		GOD_LINE_BREAK,

		/* Flints */
		{ "flint",		o_FLINT,	{  0,  0,  0,  0,  0,  1,  0,  0,  0 } },
		{ "flintset",	o_FLINT_SET,{  0,  1,  0,  0,  0,  1,  0,  0,  0 } },
		GOD_LINE_BREAK,

		/* Flesh */
		{ "rope",		o_ROPE,		{  0,  0,  0,  0,  0,  0,  0, 20,  0 } },
		{ "gloves",		o_GLOVES,	{  0,  0,  0,  0,  0,  0,  0, 25,  0 } },
		{ "shawl",		o_SHAWL,	{  0,  0,  0,  0,  0,  0,  0,200,  0 } },
		{ "hood",		o_HOOD,		{  0,  0,  0,  0,  0,  0,  0, 25,  0 } },
		{ "cloak",		o_CLOAK,	{  0,  0,  0,  0,  0,  0,  0,220,  0 } },
		{ "shoes",		o_SHOES,	{  0,  0,  0,  0,  0,  0,  0, 50,  0 } },
		{ "cape",		o_CAPE,		{  0,  0,  0,  0,  0,  0,  0,170,  0 } },
		{ "pants",		o_PANTS,	{  0,  0,  0,  0,  0,  0,  0,180,  0 } },
		{ "tunic",		o_TUNIC,	{  0,  0,  0,  0,  0,  0,  0,150,  0 } },
		{ "shirt",		o_SHIRT,	{  0,  0,  0,  0,  0,  0,  0,130,  0 } },
		{ "blouse",		o_BLOUSE,	{  0,  0,  0,  0,  0,  0,  0,130,  0 } },
		{ "toga",		o_TOGA,		{  0,  0,  0,  0,  0,  0,  0,130,  0 } },
		{ "gauntlets",	o_GAUNTLETS,{  0,  0,  0,  0,  0,  0,  0, 75,  0 } },
		{ "boots",		o_BOOTS,	{  0,  0,  0,  0,  0,  0,  0, 80,  0 } },
		{ "canteen",	o_CANTEEN,	{  0,  0,  0,  0,  0,  0,  0,100,  0 } },
		{ "wineskin",	o_WINESKIN,	{  0,  0,  0,  0,  0,  0,  0,120,  0 } },
		{ "sack",		o_SACK,		{  0,  0,  0,  0,  0,  0,  0, 80,  0 } },
		{ "pack",		o_PACK,		{  0,  0,  0,  0,  0,  0,  0,120,  0 } },
		{ "jacket",		o_JACKET,	{  0,  0,  0,  0,  0,  0,  0,150,  0 } },
		{ "dress",		o_DRESS,	{  0,  0,  0,  0,  0,  0,  0,220,  0 } },
		{ "hat",		o_HAT,		{  0,  0,  0,  0,  0,  0,  0, 30,  0 } },
		{ "bracers",	o_BRACERS,	{  0,  0,  0,  0,  0,  0,  0, 60,  0 } },
		{ "shield",		o_SHIELD,	{  0,  0,  0,  0,  0,  0,  0, 90,  0 } },
		{ "whip",		o_WHIP,		{  0,  0,  0,  0,  0,  0,  0,120,  0 } },
		{ "ridingboots",o_RIDINGBOOTS,{0,  0,  0,  0,  0,  0,  0, 80,  0 } },
		{ "quiver",		o_QUIVER,	{  0,  0,  0,  0,  0,  0,  0,100,  0 } },
		{ "sheath",		o_SHEATH,	{  0,  0,  0,  0,  0,  0,  0, 40,  0 } },
		{ "scabbard",	o_SCABBARD,	{  0,  0,  0,  0,  0,  0,  0, 40,  0 } },
		{ "belt",		o_BELT,		{  0,  0,  0,  0,  0,  0,  0, 25,  0 } },
		{ "sash",		o_SASH,		{  0,  0,  0,  0,  0,  0,  0, 25,  0 } },
		{ "beltloop",	o_BELTLOOP,	{  0,  0,  0,  0,  0,  0,  0, 10,  0 } },
		GOD_LINE_BREAK,

		/* Clay */
		{ "clay",		o_CLAY,		{  0,  0,  0,  0,  0,  0,  1,  0,  0 } },
		GOD_LINE_BREAK,

		/* Precious Metal */
		{ "silvernugget",o_SILVER,	{  0,  0,  0,  2,  0,  0,  0,  0,  0 } },
		{ "silverdisc",	o_SILVER_DISC,{0,  0,  0,  4,  0,  0,  0,  0,  0 } },
		{ "silverbar",	o_SILVER_BAR,{ 0,  0,  0,  8,  0,  0,  0,  0,  0 } },
		{ "goldflake",	o_GOLD_SMALL,{ 0,  0,  0,  0,  1,  0,  0,  0,  0 } },
		{ "golddust",	o_GOLD,		{  0,  0,  0,  0,  2,  0,  0,  0,  0 } },
		{ "golddisc",	o_GOLD_DISC,{  0,  0,  0,  0,  4,  0,  0,  0,  0 } },
		{ "goldbar",	o_GOLD_BAR,	{  0,  0,  0,  0,  8,  0,  0,  0,  0 } },
		GOD_LINE_BREAK,

		/* Glass */
		{ "flask",		o_FLASK,	{  0,  0,  0,  0,  0,  0,  0,  0,  5 } },
		{ "jar",		o_JAR,		{  0,  0,  0,  0,  0,  0,  0,  0,  5 } },
		{ "smallpane",	o_PANE_SMALL,{  0,  0,  0,  0,  0,  0,  0,  0,  5 } },
		{ "mirror",		o_MIRROR,	{  0,  0,  1,  0,  0,  0,  0,  0,  5 } },
		{ "silvermirror",o_MIRROR_SILVER, { 0, 0, 0, 6, 0, 0,  0,  0,  5 } },
		{ "goldmirror",	o_MIRROR_GOLD, { 0, 0, 0,  2,  4,  0,  0,  0,  5 } },
		{ "lantern",	o_LANTERN,	{  0,  0,  5,  0,  0,  0,  0,  2, 10 } },
		{ "litlantern",	o_LANTERN_LIT,	{  0,  0,  5,  0,  0,  0,  0,  2, 10 } },
		GOD_LINE_BREAK,

		/* Wax */
		{ "beeswax",	o_WAX,		{  0,  0,  0,  0,  0,  0,  0,  0,  0, 1 } },
		{ "candle",		o_CANDLE,	{  0,  0,  0,  0,  0,  0,  0,  0,  0, 1 } },
		{ "litcandle",	o_CANDLE_LIT,{  0,  0,  0,  0,  0,  0,  0,  0,  0, 1 } },
		GOD_LINE_BREAK,

		/* Iron */
		{ "iron",		o_IRON,		{  0,  0,  1,  0,  0,  0,  0,  0,  0 } },
		{ "waraxe",		f_AXE,		{  1,  0,  2,  0,  0,  0,  0,  0,  0 } },
		{ "hammer",		f_HAMMER,	{  1,  0,  2,  0,  0,  0,  0,  0,  0 } },
		{ "pick",		f_PICK,		{  1,  0,  2,  0,  0,  0,  0,  0,  0 } },
		{ "helm",		f_HELM,		{  0,  0,  3,  0,  0,  0,  0,  0,  0 } },
		{ "dagger",		f_DAGGER,	{  0,  0,  2,  0,  0,  0,  0,  0,  0 } },
		{ "breastplate",f_BREASTPLATE,{0,  0,  6,  0,  0,  0,  0,  0,  0 } },
		{ "sword",		f_SWORD,	{  0,  0,  4,  0,  0,  0,  0,  0,  0 } },
		{ "ringarmor",	f_RING,		{  0,  0,  8,  0,  0,  0,  0,  0,  0 } },
		{ "chainarmor",	f_CHAIN,	{  0,  0,  7,  0,  0,  0,  0,  0,  0 } },
		{ "platearmor",	f_PLATE,	{  0,  0, 12,  0,  0,  0,  0,  0,  0 } },
		{ "shovel",		f_SHOVEL,	{  1,  0,  2,  0,  0,  0,  0,  0,  0 } },
		{ "scythe",		f_SCYTHE,	{  1,  0,  3,  0,  0,  0,  0,  0,  0 } },
		{ "ironshield",	f_SHIELD,	{  0,  0,  4,  0,  0,  0,  0,  0,  0 } },
		{ "mace",		f_MACE,		{  1,  0,  3,  0,  0,  0,  0,  0,  0 } },
		{ "shortsword", f_SHORTSWORD,{ 0,  0,  2,  0,  0,  0,  0,  0,  0 } },
		{ "pike",		f_PIKE,		{  1,  0,  2,  0,  0,  0,  0,  0,  0 } },
		{ "halbert",	f_HALBERT,	{  1,  0,  2,  0,  0,  0,  0,  0,  0 } },
		{ "dirk",		f_DIRK,		{  0,  0,  2,  0,  0,  0,  0,  0,  0 } },
		{ "pan",		f_PAN,		{  0,  0,  2,  0,  0,  0,  0,  0,  0 } },
		GOD_LINE_BREAK,

		{ "broadsword",	f_BROADSWORD,	{  0,  0,  4,  0,  0,  0,  0,  0,  0 } },
		{ "poleaxe",	f_POLEAXE,		{  1,  0,  2,  0,  0,  0,  0,  0,  0 } },
		{ "rapier",		f_RAPIER,		{  0,  0,  2,  0,  0,  0,  0,  0,  0 } },
		{ "scimitar",	f_SCIMITAR,		{  0,  0,  3,  0,  0,  0,  0,  0,  0 } },
		{ "claymore",	f_CLAYMORE,		{  1,  0,  3,  0,  0,  0,  0,  0,  0 } },
		{ "flamberge",	f_FLAMBERGE,	{  1,  0,  4,  0,  0,  0,  0,  0,  0 } },
		{ "platedbelt",	f_BELT,			{  0,  0,  2,  0,  0,  0,  0,  0,  0 } },
		{ "clip",		f_BELTCLIP,		{  0,  0,  1,  0,  0,  0,  0,  0,  0 } },
		{ "greathelm",	f_GREAT_HELM,	{  0,  0,  3,  0,  0,  0,  0,  0,  0 } },
		{ "fullplate",	f_FULL_PLATE,	{  0,  0, 16,  0,  0,  0,  0,  0,  0 } },
		GOD_LINE_BREAK,

		{ "silverring",	f_RING_SILVER,{  0,  0,  0,  2,  0,  0,  0,  0,  0 } },
		{ "silverearring",f_EARRING_SILVER,{  0,  0,  0,  4,  0,  0,  0,  0,  0 } },
		{ "goldring",	f_RING_GOLD,{  0,  0,  0,  0,  2,  0,  0,  0,  0 } },
		{ "goldearring",f_EARRING_GOLD,{  0,  0,  0,  0,  4,  0,  0,  0,  0 } },
		{ "engagementring",f_RING_ENGAGEMENT,{  0,  0,  0,  0,  2,  0,  0,  0,  0 } },
		{ "weddingring",f_RING_WEDDING,{  0,  0,  0,  0,  2,  0,  0,  0,  0 } },
		{ "crown",		f_CROWN,	{  0,  0,  0,  0,  8,  0,  0,  0,  0 } },
		GOD_LINE_BREAK,

		{ "maul",		f_MAUL,			{  1, 12,  2,  0,  0,  0,  0,  0, 12 } },
		{ "kiteshield",	f_KITE,			{  2, 16,  8,  0,  0,  0,  0,  6,  6 } },
		{ "towershield",f_TOWER,		{  4, 20, 12,  0,  0,  0,  0,  6,  6 } },
		GOD_LINE_BREAK,

		{ "woodblock",	WOOD_BLOCK,		{ 1000, 0, 0, 0, 0, 0, 0, 0, 0 } },
		{ "rockblock",	ROCK_BLOCK,		{ 0, 1000, 0, 0, 0, 0, 0, 0, 0 } },
		{ "ironblock",	IRON_BLOCK,		{ 0, 0, 500, 0, 0, 0, 0, 0, 0 } },
		{ "silverblock",SILVER_BLOCK,	{ 0, 0, 0, 10, 0, 0, 0, 0, 0 } },
		{ "goldblock",	GOLD_BLOCK,		{ 0, 0, 0, 0, 10, 0, 0, 0, 0 } },
		{ "flintblock",	FLINT_BLOCK,	{ 0, 0, 0, 0, 0, 1000, 0, 0, 0 } },
		{ "clayblock",	CLAY_BLOCK,		{ 0, 0, 0, 0, 0, 0, 50, 0, 0 } },
		{ "fleshblock",	FLESH_BLOCK,	{ 0, 0, 0, 0, 0, 0, 0, 1000, 0 } },
		{ "glassblock",	GLASS_BLOCK,	{ 0, 0, 0, 0, 0, 0, 0, 0, 100 } },
		{ "totalblock",	TOTAL_BLOCK,	{ 1000, 1000, 500, 10, 10, 1000, 50, 1000, 100 } },

		/* This must go last */
		{ "\n", NOTHING, { 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
	};


ACMD(do_create) {
	Object obj = NULL;
	int i = 0, j = 0, count = 0, num = 1, done = 0;
	bool ok, low_res = FALSE;

	*buf = '\0';
	two_arguments(argument, arg, buf);

	if (!*buf)
		strcpy(buf, arg);
	else {
		num = atoi(arg);
		if (num < 1) {
			msg_to_char(ch, "You need to create at LEAST one.\r\n");
			return;
			}
		}

	if (!*buf) {
		msg_to_char(ch, "You can create:\r\n");

		*buf = '\0';
		for (i = 0, ok = 1; str_cmp(resource[i].name, "\n"); i++, ok = 1) {
			for (j = 0; j < NUM_ITEM_MATS; j++)
				if (GET_RESOURCE(ch, j) < resource[i].res[j])
					ok = 0;
			if (!ok)
				continue;
			if (!str_cmp(resource[i].name, "\t")) {
				if (count > 0)
					strcat(buf, "\r\n");
				count = 0;
				continue;
				}
			if (count + strlen(resource[i].name) + 1 > 78) {
				strcat(buf, "\r\n");
				count = 0;
				}
			sprintf(buf + strlen(buf), " %s", resource[i].name);
			count += strlen(resource[i].name) + 1;
			}
		if (*buf)
			msg_to_char(ch, "%s\r\n", buf);
		else
			msg_to_char(ch, " nothing\r\n");
		return;
		}

	for (i = 0, ok = 1; str_cmp(resource[i].name, "\n"); i++, ok = 1) {
		if (!is_abbrev(buf, resource[i].name))
			continue;
		for (j = 0; j < NUM_ITEM_MATS; j++)
			if (GET_RESOURCE(ch, j) < resource[i].res[j])
				ok = 0;
		if (ok)
			break;
		}

	if (!str_cmp(resource[i].name, "\n")) {
		msg_to_char(ch, "You can't create that.\r\n");
		return;
		}

	/* We KNOW we can create at least one.  We'll check after that. */
	for (done = 0; done < num; done++) {
		for (j = 0; j < NUM_ITEM_MATS; j++)
			if (GET_RESOURCE(ch, j) < resource[i].res[j])
				low_res = 1;

		if (low_res)
			break;

		for (j = 0; j < NUM_ITEM_MATS; j++)
			GET_RESOURCE(ch, j) -= resource[i].res[j];

		obj = read_object(resource[i].vnum, VIRTUAL);

		if (IS_CARRYING_N(ch) >= CAN_CARRY_N(ch) || GET_OBJ_WEIGHT(obj) + IS_CARRYING_W(ch) > CAN_CARRY_W(ch))
			obj_to_room(obj, ch->in_room);
		else
			obj_to_char(obj, ch);

		SET_BIT(obj->obj_flags.extra_flags, ITEM_CREATED);
		}

	if (!done) {
		msg_to_char(ch, "You fail to create it.\r\n");
		if (obj)
			extract_obj(obj);
		}
	else if (done == 1) {
		act("You create $p!", FALSE, ch, obj, 0, TO_CHAR);
		act("$n creates $p from thin air!", TRUE, ch, obj, 0, TO_ROOM);
		}
	else {
		sprintf(buf, "You create $p (x%d)!", done);
		sprintf(buf1, "$n creates $p (x%d) from thin air!", done);
		act(buf, FALSE, ch, obj, 0, TO_CHAR);
		act(buf1, TRUE, ch, obj, 0, TO_ROOM);
		}

	if (low_res)
		msg_to_char(ch, "You have insufficient resources to create more.\r\n");
	}


int perform_sacrifice(Creature ch, Creature god, Object obj, bool mode) {
	int i, j, amt;
	float bonus = 1;

	/* Determine monument bonus */
	if (world[ch->in_room].spare == GET_IDNUM(god)) {
		if (CLOSED_MONUMENT_TYPE(ch->in_room) == MONUMENT_C_SHRINE)
			bonus = 1.25;
		else if (CLOSED_MONUMENT_TYPE(ch->in_room) == MONUMENT_C_TEMPLE_UL)
			bonus = 1.50;
		else if (CLOSED_MONUMENT_TYPE(ch->in_room) == MONUMENT_C_HIGHTEMPLE_UC)
			bonus = 1.75;
		}

	/* Oops, it was created */
	if (IS_OBJ_STAT(obj, ITEM_CREATED))
		bonus = 1;

	/* Find it in the list.  If it's not there, they still get 1 point for it */
	for (i = 0; str_cmp(resource[i].name, "\n") && resource[i].vnum != GET_OBJ_VNUM(obj); i++);

	for (j = 0; j < NUM_ITEM_MATS; j++)
		GET_RESOURCE(god, j) += resource[i].res[j] * bonus;

	if (!str_cmp(resource[i].name, "\n")) {
		if (GET_OBJ_VNUM(obj) == o_CORPSE) {
			amt = GET_OBJ_VAL(obj, 1);
			if (IS_SET(GET_OBJ_VAL(obj, 2), CORPSE_EATEN))
				amt /= 2;
			if (IS_SET(GET_OBJ_VAL(obj, 2), CORPSE_SKINNED))
				amt /= 2;
			GET_RESOURCE(god, ITEM_MAT_FLESH) += amt;
			}
		else if (GET_OBJ_VNUM(obj) == o_SKIN)
			GET_RESOURCE(god, ITEM_MAT_FLESH) += GET_OBJ_VAL(obj, 0);
		else
			GET_RESOURCE(god, GET_OBJ_MATERIAL(obj)) += 1 + bonus;
		}

	if (mode) {
		*buf2 = '\0';
		if (ch == god) {
			sprintf(buf, "You sacrifice $p to yourself!");
			sprintf(buf1, "$n sacrifices $p to $mself!");
			}
		else {
			sprintf(buf, "You sacrifice $p to %s!", PERS(god, god, 1));
			sprintf(buf1, "$n sacrifices $p to %s!", PERS(god, god, 1));
			sprintf(buf2, "$n sacrifices $p to you!");
			}
		act(buf, TRUE, ch, obj, god, TO_CHAR);
		act(buf1, TRUE, ch, obj, god, TO_NOTVICT);
		if (ch->in_room == god->in_room && ch != god)
			act(buf2, TRUE, ch, obj, god, TO_VICT);
		}
	while (obj->contains)
		perform_sacrifice(ch, god, obj->contains, 0);
	extract_obj(obj);

	return 1;
	}


ACMD(do_sacrifice) {
	extern FILE *player_fl;

	Object obj, next_obj;
	Creature god = NULL, cbuf = NULL;
	Descr d;
	int amount = 0, dotmode, player_i = 0;
	bool file = FALSE;
	struct char_file_u tmp_store;

	two_arguments(argument, arg, buf);

	if (!*arg || !*buf) {
		msg_to_char(ch, "What do you wish to sacrifice, and to whom?\r\n");
		return;
		}

	/* Do this in-file */
	for (d = descriptor_list; d; d = d->next) {
		if (STATE(d) != CON_PLAYING || !d->character)
			continue;
		if (!isname(buf, GET_NAME(d->character)))
			continue;
		god = d->character;
		break;
		}
	if (!god) {
		CREATE(cbuf, struct char_data, 1);
		clear_char(cbuf);
		if ((player_i = load_char(buf, &tmp_store)) > NOBODY) {
			store_to_char(&tmp_store, cbuf);
			god = cbuf;
			file = TRUE;
			}
		else {
			free(cbuf);
			send_to_char("There is no such god.\r\n", ch);
			return;
			}
		}

	if (!IS_GOD(god) && !IS_IMMORTAL(god)) {
		msg_to_char(ch, "You can only sacrifice to gods.\r\n");
		if (file)
			free_char(cbuf);
		return;
		}

	dotmode = find_all_dots(arg);

	if (dotmode == FIND_ALL) {
		if (!ch->carrying && (!world[ch->in_room].contents || !CAN_USE_ROOM(ch, ch->in_room, 0)))
			msg_to_char(ch, "You don't seem to have anything to sacrifice.\r\n");
		else {
			for (obj = ch->carrying; obj; obj = next_obj) {
				next_obj = obj->next_content;
				amount += perform_sacrifice(ch, god, obj, 1);
				}
			for (obj = world[ch->in_room].contents; obj; obj = next_obj) {
				next_obj = obj->next_content;

				if (!CAN_USE_ROOM(ch, ch->in_room, 0))
					continue;

				if (!CAN_WEAR(obj, ITEM_WEAR_TAKE))
					continue;

				amount += perform_sacrifice(ch, god, obj, 1);
				}
			}
		}
	else if (dotmode == FIND_ALLDOT) {
		if (!*arg) {
			msg_to_char(ch, "What do you want to sacrifice all of?\r\n");
			return;
			}
		if (!(obj = get_obj_in_list_vis(ch, arg, ch->carrying)))
			if (!CAN_USE_ROOM(ch, ch->in_room, 0) || !(obj = get_obj_in_list_vis(ch, arg, world[ch->in_room].contents)))
				msg_to_char(ch, "You don't seem to have any %ss to sacrifice.\r\n", arg);

		while (obj) {
			next_obj = get_obj_in_list_vis(ch, arg, obj->next_content);
			if (!next_obj && CAN_USE_ROOM(ch, ch->in_room, 0) && obj->in_room == NOWHERE)
				next_obj = get_obj_in_list_vis(ch, arg, world[ch->in_room].contents);
			amount += perform_sacrifice(ch, god, obj, 1);
			obj = next_obj;
			}
		}
	else {
		if (!(obj = get_obj_in_list_vis(ch, arg, ch->carrying)) && (!CAN_USE_ROOM(ch, ch->in_room, 0) || !(obj = get_obj_in_list_vis(ch, arg, world[ch->in_room].contents))))
			msg_to_char(ch, "You don't seem to have any %ss to sacrifice.\r\n", arg);
		else
			amount += perform_sacrifice(ch, god, obj, 1);
		}

	if (!file)
		SAVE_CHAR(god);
	if (file) {
		char_to_store(god, &tmp_store);
		fseek(player_fl, (player_i) * sizeof(struct char_file_u), SEEK_SET);
		fwrite(&tmp_store, sizeof(struct char_file_u), 1, player_fl);
		}

	if (file)
		free_char(cbuf);
	}