/* ************************************************************************
*  file: spec_assign.c , Special module.                  Part of DIKUMUD *
*  Usage: Procedures assigning function pointers.                         *
*  Copyright (C) 1990, 1991 - see 'license.doc' for complete information. *
************************************************************************* */

#include <stdio.h>
#include "structs.h"
#include "db.h"
#include "config.h"

extern struct room_data *world;
extern struct index_data *mob_index;
extern struct index_data *obj_index;
extern int top_of_world;
extern struct obj_data *object_list;
void boot_the_shops();
void assign_the_shopkeepers();

/* ********************************************************************
*  Assignments                                                        *
******************************************************************** */

/* assign special procedures to mobiles */
void assign_mobiles(void)
{
	int cityguard(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int receptionist(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int guild(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int guild_guard(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int puff(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int devour(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int janitor(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int mayor(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int poison(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int thief(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int magic_user(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int offensive(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int brass_dragon(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int sales_spec(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int jester(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int snowbeast(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int snowvulture(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int spiny(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int phalanx(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int skeleton(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int spore_ball(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int clyde(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int waiter(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int cookie(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int mage_anapest(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int guru_anapest(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int farmer(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int taxman(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int albert(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int neophyte(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int bridge_troll(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int citizenship(struct char_data *ch,struct char_data *pl,int cmd,char *arg);

	int apprehender(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int jailkeeper(struct char_data *ch,struct char_data *pl,int cmd,char *arg);
	int witness(struct char_data *ch,struct char_data *pl,int cmd,char *arg);


	mob_index[real_mobile(1)].func = puff;
	mob_index[real_mobile(4)].func = citizenship;
	mob_index[real_mobile(1205)].func = sales_spec;
	mob_index[real_mobile(5005)].func = brass_dragon;
	mob_index[real_mobile(4061)].func = cityguard;

	mob_index[real_mobile(3059)].func = cityguard;
	mob_index[real_mobile(3060)].func = cityguard;
	mob_index[real_mobile(3061)].func = janitor;
#if CONFIG_JAIL
	mob_index[real_mobile(3065)].func = witness;
#endif
	mob_index[real_mobile(3067)].func = cityguard;
	mob_index[real_mobile(3062)].func = devour;
	mob_index[real_mobile(3066)].func = devour;
	mob_index[real_mobile(3068)].func = janitor;
	mob_index[real_mobile(3069)].func = jester;
	mob_index[real_mobile(3070)].func = offensive;
#if CONFIG_JAIL
	mob_index[real_mobile(3072)].func = witness;
	mob_index[real_mobile(3080)].func = jailkeeper;
	mob_index[real_mobile(3081)].func = apprehender;
	mob_index[real_mobile(3082)].func = apprehender;
#endif

	mob_index[real_mobile(3005)].func = receptionist;

	mob_index[real_mobile(3020)].func = guild;
	mob_index[real_mobile(3021)].func = guild;
	mob_index[real_mobile(3022)].func = guild;
	mob_index[real_mobile(3023)].func = guild;

	mob_index[real_mobile(3024)].func = guild_guard;
	mob_index[real_mobile(3025)].func = guild_guard;
	mob_index[real_mobile(3026)].func = guild_guard;
	mob_index[real_mobile(3027)].func = guild_guard;

	mob_index[real_mobile(3143)].func = mayor;

        /* Tombs and Catacombs */
	mob_index[real_mobile(3410)].func = devour;
	mob_index[real_mobile(3411)].func = devour;
	mob_index[real_mobile(3415)].func = cityguard;
	mob_index[real_mobile(3404)].func = poison;

	/* MORIA */
	mob_index[real_mobile(4000)].func = poison;
	mob_index[real_mobile(4001)].func = poison;
	mob_index[real_mobile(4053)].func = poison;

	mob_index[real_mobile(4103)].func = thief;
	mob_index[real_mobile(4100)].func = magic_user;
	mob_index[real_mobile(4102)].func = poison;

	/* SEWERS */
	mob_index[real_mobile(7006)].func = poison;

	/* FOREST */
	mob_index[real_mobile(6113)].func = poison;
	mob_index[real_mobile(6114)].func = poison;

	mob_index[real_mobile(6910)].func = magic_user;

	/* DIROLFILA */
	mob_index[real_mobile(12000)].func = snowbeast;
	mob_index[real_mobile(12001)].func = snowvulture;
	mob_index[real_mobile(12002)].func = spiny;
	mob_index[real_mobile(12003)].func = spiny;
	mob_index[real_mobile(12005)].func = phalanx;
	mob_index[real_mobile(12006)].func = skeleton;
	mob_index[real_mobile(12022)].func = spore_ball;
	mob_index[real_mobile(12023)].func = spore_ball;
	mob_index[real_mobile(12024)].func = skeleton;

	/* ANAPEST */
	mob_index[real_mobile(12503)].func = clyde;
	mob_index[real_mobile(12504)].func = guild;
	mob_index[real_mobile(12505)].func = guild;
	mob_index[real_mobile(12506)].func = guru_anapest;
	mob_index[real_mobile(12507)].func = mage_anapest;
	mob_index[real_mobile(12509)].func = receptionist;
	mob_index[real_mobile(12515)].func = cookie;
	mob_index[real_mobile(12519)].func = farmer;
	mob_index[real_mobile(12520)].func = farmer;
	mob_index[real_mobile(12521)].func = taxman;
	mob_index[real_mobile(12522)].func = albert;
	mob_index[real_mobile(12523)].func = neophyte;
	mob_index[real_mobile(12525)].func = receptionist;
	mob_index[real_mobile(12526)].func = cityguard;
	mob_index[real_mobile(12527)].func = cityguard;
	mob_index[real_mobile(12528)].func = cityguard;
	mob_index[real_mobile(12529)].func = cityguard;
	mob_index[real_mobile(12530)].func = cityguard;
#if CONFIG_JAIL
	mob_index[real_mobile(12580)].func = jailkeeper;
	mob_index[real_mobile(12581)].func = apprehender;
	mob_index[real_mobile(12582)].func = apprehender;
#endif

	mob_index[real_mobile(14202)].func = bridge_troll;

	boot_the_shops();
	assign_the_shopkeepers();

        /* After shop assign so that "extra" stuff will work */
	mob_index[real_mobile(12502)].func = waiter;
}



/* assign special procedures to objects */
void assign_objects(void)
{
	int board(struct obj_data *obj,struct char_data *ch, int cmd, char *arg);
	int crystal_spike(struct obj_data *obj,struct char_data *ch, int cmd, char *arg);
	int jailtally(struct obj_data *obj,struct char_data *ch, int cmd, char *arg);

	obj_index[real_object(12005)].func = board;
	obj_index[real_object(12000)].func = crystal_spike;
	obj_index[real_object(3099)].func = board;
 	obj_index[real_object(3098)].func = board;
 	obj_index[real_object(66)].func = board;
 	obj_index[real_object(59)].func = board;
 	obj_index[real_object(77)].func = board;
 	obj_index[real_object(55)].func = board;
 	obj_index[real_object(9)].func = board;

#if CONFIG_JAIL
	obj_index[real_object(3068)].func = jailtally;
	obj_index[real_object(12586)].func = jailtally;
#endif
}



/* assign special procedures to rooms */
void assign_rooms(void)
{
	int dump(int room, struct char_data *ch, int cmd, char *arg);
	int chalice(int room, struct char_data *ch, int cmd, char *arg);
	int kings_hall(int room, struct char_data *ch, int cmd, char *arg);
  	int pet_shops(int room, struct char_data *ch, int cmd, char *arg);
	int pray_for_items(int room, struct char_data *ch, int cmd, char *arg);
  	int arena_shop(int room, struct char_data *ch, int cmd, char *arg);
	int arena_guard(int room, struct char_data *ch, int cmd, char *arg);
	int remove_team(int room, struct char_data *ch, int cmd, char *arg);
	int do_multiclass(int room, struct char_data *ch, int cmd, char *arg);
	int feed_lock(int room, struct char_data *ch, int cmd, char *arg);

	world[real_room(1212)].funct = feed_lock;

	world[real_room(3751)].funct = remove_team;
	world[real_room(3702)].funct = arena_guard;
	world[real_room(3703)].funct = arena_guard;
	world[real_room(3755)].funct = do_multiclass;
	world[real_room(3030)].funct = dump;
	world[real_room(3054)].funct = pray_for_items;

/*
	world[real_room(704)].funct = chalice;
	world[real_room(2518)].funct = kings_hall;
*/
	world[real_room(1203)].funct = kings_hall;
	world[real_room(3031)].funct = pet_shops;
	world[real_room(3701)].funct = arena_shop;

	world[real_room(12608)].funct = dump;
	world[real_room(12610)].funct = pet_shops;
}


/* ********************************************************************
*  Handling funcs                                                     *
******************************************************************** */

void room_procs()
{
	int i;

	for(i=0;i<top_of_world;i++)
		if(world[i].funct)
			(*world[i].funct)(i,NULL,0,NULL);
}

void item_procs()
{
	struct obj_data *i;

	for(i=object_list;i;i=i->next)
		if(obj_index[i->item_number].func)
			(*obj_index[i->item_number].func)(i,NULL,0,NULL);
}