
#include <stdio.h>
#include "config.h"
#include "utils.h"
#include "structs.h"
#include "functions.h"


/******************************************************************************
	Shit!!!!! (7/12/99)
	I must remeber to comment code. I must remember to comment code...
	Right.  For future implementors.  Return (0) to say I ain't processing
	this damn request!  This means that the special function associated with
	an object/room/etc... didn't find anything relevant to its routine, thus
	enabling the command parser to process the (original) main commands.
******************************************************************************/

int	dummy(void);
int	int_special(struct char_data *ch, char *arg);
int	bow_special(struct char_data *ch, struct object_data *object, char *arg);

/* EXTERNAL GLOBALS */
extern char	buf[SMALL_BUFSIZE];

/* THE STRUCTURE FOR OBJECT SPECIALS */
int	(*obj_spec[])() = {
	dummy,			/* A dummy routine to catch errors? */
	bow_special,	/* The routine for controlling bows */
};

/* THE STRUCTURE FOR ROOM SPECIALS */
int	(*room_spec[])() = {
	dummy,			/* To catch what errors? */
	int_special,	/* Intelligence room */
};

/*************************************************
	The object special routines
*************************************************/
int	bow_special(struct char_data *ch, struct object_data *object, char *arg)
{
	struct object_data *arrow;

	/* GET THE COMMAND NAME */
	get_arg(buf,arg,0);

	if(!shrt_cmp(buf,"load")) {
		if(get_target(buf,arg,2)) {
			if(object->contains) {
				send_2_output("The bow is already loaded!\n\r",ch->desc);
				return(1);
			} else if(!(arrow=check_carried(ch,buf))) {
				send_2_output("You don't have that!\n\r",ch->desc);
				return(1);
			} else if(!(BTST(arrow->TYPE,OBJ_ARROW))) {
				send_2_output("You can't load the bow with that!\n\r",ch->desc);
				return(1);
			} else {
				obj_from_char(arrow);
				obj_2_obj(arrow,object);
				send_2_output("You load the bow.\n\r",ch->desc);
				sprintf(buf,"loads %s with %s",object->name,arrow->name);
				send_2_room(ch,IGNR_INVIS,buf);
				return(1);
			}
		} else {
			return(0);
		}
	} else if(!shrt_cmp(buf,"unload")) {
		if((get_arg(buf,arg,1)) && !shrt_cmp(buf,"bow")) {
			if(!object->contains) {
				send_2_output("The bow is already unloaded.\n\r",ch->desc);
				return(1);
			} else {
				arrow=object->contains;
				obj_from_obj(arrow);
				obj_2_char(arrow,ch);
				send_2_output("You unload the bow.\n\r",ch->desc);
				sprintf(buf,"unloads %s",object->name);
				send_2_room(ch,IGNR_INVIS,buf);
				return(1);
			}
		}
	} else if(!shrt_cmp(buf,"fire")) {
		if(!get_target(buf,arg,2)) {
			send_2_output("At whom, or what?\n\r",ch->desc);
			return(1);
		} else if(!object->contains) {
			send_2_output("The bow is not loaded!\n\r",ch->desc);
			return(1);
		}
	} else if(!shrt_cmp(buf,"check")) {
		if(object->contains) {
			sprintf(buf,"It is loaded with %s\n\r",object->contains->name);
			send_2_output(buf,ch->desc);
			return(1);
		}
	}
	return(0);
}

/*************************************************
	The room special routines
*************************************************/
int	int_special(struct char_data *ch, char *arg)
{
	return(0);
}

int	dummy(void)
{
	printf("ERROR: SPECIAL 0\n");
	return(2);
}


