area/
build/testing/
log/
player/
player/backup/
/***************************************************************************
 *  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.                                                  *
 ***************************************************************************/
#include <glib.h>

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

/*
 * Wraith stuff to go here :P
 */
void do_wraith(CHAR_DATA *ch, char *argument){
	if (ch->plane != PLANE_DEAD){
		send_to_char("huh?\n\r",ch);
		return;
	}
	if (IS_CLASS(ch,CLASS_VAMPIRE)){
		send_to_char("Umm your already classed.. You can only type killme.\n\r",ch);
		return;
	}
	if (IS_CLASS(ch,CLASS_SWWF)){
		send_to_char("Umm your already classed.. You can only type killme.\n\r",ch);
		return;
	}
	if (IS_CLASS(ch,CLASS_MAGE)){
		send_to_char("Umm your already classed.. You can only type killme.\n\r",ch);
		return;
	}

	REMOVE_BIT(ch->added,ADDED_HARDCORE);
	ch->sect = SECT_INDEPENDENT;
	ch->clan = CLAN_NONE;
	ch->plane = PLANE_SPIRIT;
	ch->creature = CLASS_WRAITH;
	shift_obj_plane(ch);
	send_to_char("Welcome to Lurking Fear spirit!\n\r",ch);
        send_to_char("Please type help wraith for more information.\n\r",ch);
	return;	
}

void do_killme(CHAR_DATA *ch, char *argument){
	if (ch->plane != PLANE_DEAD){
		send_to_char("huh?\n\r",ch);
		return;
	}
}

int max_pathos(CHAR_DATA *ch){
	int max_pathos = 0;
	return max_pathos;
}

int max_corpus(CHAR_DATA *ch){
	int max_corpus = 0;
	return max_corpus;
}

//This is how many Hp you get vs how much pathos you put in to corpus
int get_corpus_hp(CHAR_DATA *ch){
	int hit_amount = 0;
	 
	if (IS_NPC(ch))
		return 0;

	hit_amount = (ch->pcdata->ghost_hit * 100);
	return hit_amount;
}

int get_corpus_mana(CHAR_DATA *ch){
	int mana_amount = 0;
	 
	if (IS_NPC(ch))
		return 0;

	mana_amount = (ch->pcdata->ghost_mana * 100);
	return mana_amount;
}

int get_corpus_move(CHAR_DATA *ch){
	int move_amount = 0;
	 
	if (IS_NPC(ch))
		return 0;

	move_amount = (ch->pcdata->ghost_move * 100);
	return move_amount;
}

//Show list of affects char has purchase
void get_corpus_affects(CHAR_DATA *ch){
	char 	buf[MSL];
	int	loop; 

	//loop through the affect table and if set display the name in the table.

	for (loop = 0; ghostaffect_table[loop].name != NULL;loop++){
		if (IS_SET(ch->pcdata->ghost_affects,ghostaffect_table[loop].ghost_flag))
			sprintf(buf,"%s		[x]",ghostaffect_table[loop].name);
		else
			sprintf(buf,"%s		[ ]",ghostaffect_table[loop].name);
	}
	send_to_char(buf,ch);
	return;
}

int get_corpus_damroll(CHAR_DATA *ch){
	int damroll_amount = 0;

	if (IS_NPC(ch))
		return 0;

	damroll_amount = (ch->pcdata->ghost_damroll * 100);
	return damroll_amount;
}

int get_corpus_hitroll(CHAR_DATA *ch){
	int hitroll_amount = 0;

	if (IS_NPC(ch))
		return 0;

	hitroll_amount = (ch->pcdata->ghost_hitroll * 100);
	return hitroll_amount;
}

int get_corpus_ac(CHAR_DATA *ch){
	int ac_amount = 0;
	 
	if (IS_NPC(ch))
		return 0;

	ac_amount = (ch->pcdata->ghost_ac * 100);
	return ac_amount;
}


/*
 * This is the command to assign points from the Corpus pool
 * so when the cross over, they have real stats
 */
void do_corpus( CHAR_DATA *ch, char *argument){
	char arg1[MSL];
	char arg2[MSL];
	char buf[MSL];
	int loop;
	int value=0;

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

	if (IS_NPC(ch))
		return;

	if (!IS_CLASS(ch,CLASS_WRAITH)){
		send_to_char("Huh?\n\r",ch);
		return;
	}

	//Show commands with a blank arg1
	if (arg1[0] == '\0'){
		send_to_char("Syntax: corpus (field) (value)\n\r",ch);
		send_to_char("Fields: reset,show,hp,mana,move,affects,damroll,hitroll,ac\n\r",ch);
		return;
	}	

	if (!strcmp(arg1,"reset")){
		ch->pcdata->ghost_hit = 0;
		ch->pcdata->ghost_mana = 0;
		ch->pcdata->ghost_move = 0;
		ch->pcdata->ghost_hitroll = 0;
		ch->pcdata->ghost_damroll = 0;
		ch->pcdata->ghost_ac = 0;
		ch->pcdata->ghost_affects = 0;
		return;
	}

	if (!strcmp(arg1,"show")){

		return;
	}

	if (arg2[0] == '\0'){
		send_to_char("You must have a value to set.\n\r",ch);
		return;
	}


	if (ch->pcdata->gnosis >=  max_corpus(ch)){
		send_to_char("You have already converted your max pathos points to corpus, you can spend no more.\n\r You may reset your stats by using 'corpus reset'\n\r",ch);
		return;
	}

	if (!strcmp(arg1,"affects")){
		for (loop=0;ghostaffect_table[loop].name != NULL;loop++){
			if (!str_prefix(arg2,ghostaffect_table[loop].name)){
				if (IS_SET(ch->pcdata->ghost_affects,ghostaffect_table[loop].ghost_flag)){
					REMOVE_BIT(ch->pcdata->ghost_affects,ghostaffect_table[loop].ghost_flag);
					send_to_char("affect removed\n\r",ch);
					ch->pcdata->gnosis -= 50;
					return;
				}
				else{
					SET_BIT(ch->pcdata->ghost_affects,ghostaffect_table[loop].ghost_flag);
					send_to_char("affect removed\n\r",ch);
					ch->pcdata->gnosis += 50;
					return;
				}
			}
		}
		send_to_char("Affect not found.\n\r Valid affects are:\n\r",ch);
		for (loop=0;ghostaffect_table[loop].name != NULL;loop++){
			sprintf(buf,"%s\n\r",ghostaffect_table[loop].name);
		}
		return;
	}

	value = atoi(arg2);

	if (!strcmp(arg1,"hp")){
		ch->pcdata->ghost_hit += value;
		ch->pcdata->gnosis += value;
		return;
	}

	if (!strcmp(arg1,"mana")){
		ch->pcdata->ghost_mana += value;
		ch->pcdata->gnosis += value;
		return;
	}

	if (!strcmp(arg1,"move")){
		ch->pcdata->ghost_move += value;
		ch->pcdata->gnosis += value;
		return;
	}

	if (!strcmp(arg1,"damroll")){
		ch->pcdata->ghost_damroll += value;
		ch->pcdata->gnosis += value;
		return;
	}

	if (!strcmp(arg1,"hitroll")){
		ch->pcdata->ghost_hitroll += value;
		ch->pcdata->gnosis += value;
		return;
	}

	if (!strcmp(arg1,"ac")){
		ch->pcdata->ghost_ac += value;
		ch->pcdata->gnosis += value;
		return;
	}

	send_to_char("Field not found.\n\r",ch);
	return;
}