/
area/city/
area/crypts/
area/guilds/
area/psuedowild/
area/religion/
data/documents/MPDocs/
data/html/
data/mobprogs/
data/quest/
data/world/
data/world/_utilities/
data/world/images/
design/html/
notes/
player/
#if defined(macintosh)
#include <types.h>
#include <time.h>
#else
#include <sys/types.h>
#include <sys/time.h>
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "merc.h"
#include "interp.h"
#include "recycle.h"
#include "tables.h"
#include "lookup.h"
#include "rig.h"

#define ptc printf_to_char
void setcryptname   (ROOM_INDEX_DATA * room, int room_type, char * famname, char * diety);
int cnt_exits       (ROOM_INDEX_DATA * room);

#define CRYPT_HALLWAY           0   /* 2 exits  */
#define CRYPT_INTERSECTION      1   /* 3+ exits */
#define CRYPT_CATACOMBS         2   /* 2 exits  */
#define CRYPT_SHRINE            3   /* 1 exit   */
#define CRYPT_EMPTY_ROOM        4   /* 1 exit   */
#define CRYPT_ALTAR             5   /* 1 exit   */
#define CRYPT_EMPTY_GRAVE       6   /* 1 exit   */
#define CRYPT_COLLAPSED_ROOM    7
#define CRYPT_HIDDEN_TREASURE   8   /* no exit  */

/*
 * cryptset()
 *
 * Well, i need a crap load of non-descript crypts/tombs and stuff
 * to fill the world. Since i'm mucho lazy, Cryptset here will
 * Do all the details per-room for me! wheeww
 *
 * Arg1     = Family Name
 * Arg2     = Diety's name
 */
void cmd_cryptset(CHAR_DATA * ch, char *argument)
{
    char arg1[MSL], arg2[MSL];
    ROOM_INDEX_DATA *pRoom;
    int x, room_type, chance;
    
    argument = one_argument (argument, arg1);
    argument = one_argument (argument, arg2);

    if (arg1[0] == '\0' || arg2[0] == '\0')
    {
        stc("Syntax: cryptset <family name> <diety>\n\r", ch);
        return;
    }
    
    /* Captialize first letters of Family name and Diety */
    arg1[0] = UPPER(arg1[0]);
    arg2[0] = UPPER(arg2[0]);
    
    chance = number_range(0, 100);
    
    for(x = ch->in_room->area->min_vnum; x != ch->in_room->area->max_vnum; x++)
    {
        if((pRoom = get_room_index(x)) != NULL)
        {
            switch(cnt_exits(pRoom))
            {   default:
                case 0:
                    room_type = CRYPT_HIDDEN_TREASURE;
                    break;
                case 1:
                    switch(number_range(1, 21))
                    {   default:
                        case 1: case 2: case 3: case 4: case 5:
                            room_type = CRYPT_EMPTY_GRAVE;
                            break;
                        case 6: case 7: case 8: case 9: case 10:
                        case 11: case 12: case 13: case 14: case 15:
                            room_type = CRYPT_EMPTY_ROOM;
                            break;
                        case 16: case 17: case 18:
                            room_type = CRYPT_ALTAR;
                            break;
                        case 19: case 20:
                            room_type = CRYPT_SHRINE;
                            break;
                        case 21:
                            room_type = CRYPT_COLLAPSED_ROOM;
                            break;
                    }
                    break;
                case 2:
                    switch(number_range(1, 2))
                    {   default:
                        case 1:
                            room_type = CRYPT_HALLWAY;
                            break;
                        case 2:
                            room_type = CRYPT_CATACOMBS;
                            break;
                    }
                    break;
                case 3:
                case 4:
                case 5:
                case 6:
                    room_type = CRYPT_INTERSECTION;
                    break;
            }
                    
            /* Set the name */
            setcryptname(pRoom, room_type, arg1, arg2);
            /* Set the Description */
            //setcryptdescr(pRoom, room_type, arg1, arg2);
        }
    }
    do_asave(ch, "area");
    ptc(ch, "Current area is now a Crypt for the Family %s, whorshiping the diety %s\n\r",
        arg1, arg2);
    return;
}


void setcryptname (ROOM_INDEX_DATA * room, int room_type, char * famname, char * diety)
{
    static char buf[MSL];

    switch(room_type)
    {
        case CRYPT_HALLWAY:
            sprintf(buf, "A hallway in the %s crypt.", famname);
            break;
        case CRYPT_INTERSECTION:
            sprintf(buf, "Inside the %s crypt.", famname);
            break;
        case CRYPT_CATACOMBS:
            sprintf(buf, "Catacombs within the %s family crypt.", famname);
            break;
        case CRYPT_SHRINE:
            sprintf(buf, "A shrine to %s.", diety);
            break;
        case CRYPT_EMPTY_ROOM:
            sprintf(buf, "An empty room in the %s family crypt.", famname);
            break;
        case CRYPT_ALTAR:
            sprintf(buf, "An altar to %s.", diety);
            break;
        case CRYPT_EMPTY_GRAVE:
            sprintf(buf, "An empty grave.");
            break;
        case CRYPT_COLLAPSED_ROOM:
            sprintf(buf, "a Collapsed passageway.");
            break;
        case CRYPT_HIDDEN_TREASURE:
            sprintf(buf, "a blocked off room in the %s family crypt.", famname);
            break;
        default:
            sprintf(buf, "<ERROR> %s/%s", famname, diety);
            break;
    }
    free_string(room->name);
    room->name = str_dup(buf);
}

/*
 * cnt_exits()
 *
 * Returns the number of exits in the room
 */
int cnt_exits(ROOM_INDEX_DATA * room)
{
    int cnt = 0;
    int door = 0;
    EXIT_DATA *pexit;
    
    for (door = 0; door <= 5; door++)
    {
        if ((pexit = room->exit[door]) != NULL)
            cnt++;
    }
    return cnt;
}

/*
 * generate_crypt_loot()
 *
 * Generates Loot for the crypt's graves and urns and
 * chest
 *
 * uses cost for generation purposes.
 *
 * 1:       Poor General        - Gold, nothing, or potion
 * 2:       Normal, general     - Gold + Low weapon/armor
 * 3:       Rich, General       - Gold + Mid Weapon/armor
 * 4:       Scrolls             - 1-2 scrolls, + Potion
 * 5:       Monitary            - Gold + Gem
 * 6:       Extreme Poor        - Gold + Clothing + Potion
 * 7:       Extreme Normal      - Gold + Low Weap/Arm + Potion, 1 scroll
 * 8:       Extreme Rich        - Gold + Gem, + High Weapon/armor + Potion + Scroll
 */
void generate_crypt_loot(OBJ_DATA * chest)
{
    int chance;
    int gold;
    OBJ_DATA * obj;
    
    if (chest->contains != NULL)
        return;
    
    /*
     * Ok Chance 1: Gold, 33 % chance
     */
    chance = number_range(1, 100);
    gold = number_range(10, 75);
    if (chance <= 33)
    {
        obj = create_object (get_obj_index (30), 0);
        create_gold(obj, gold);
        obj_to_obj(obj, chest);
    }
    /*
     * Ok Chance 2: Low Weapon, 10 % chance
     */
    chance = number_range(1, 100);
    if (chance <= 10)
    {
        obj = create_object (get_obj_index (30), 0);
        create_weapon(obj, RIG_RANDOM, number_range(0, rig_material_max() / 2), RIG_RANDOM, FALSE);
        obj_to_obj(obj, chest);
    }
    /*
     * Ok Chance 3: Low Armor, 10 % chance
     */
    chance = number_range(1, 100);
    if (chance <= 10)
    {
        obj = create_object (get_obj_index (30), 0);
        create_armor(obj, RIG_RANDOM, number_range(0, rig_material_max() / 2), RIG_RANDOM, FALSE);
        obj_to_obj(obj, chest);
    }
    /*
     * Ok Chance 4: Potion: 25% chance
     */
    chance = number_range(1, 100);
    if (chance <= 25)
    {
        obj = create_object (get_obj_index (30), 0);
        create_potion(obj, number_range(0, rig_potion_max()));
        obj_to_obj(obj, chest);
    }
    /*
     * Ok Chance 5: Potion: 25% chance Again!
     */
    chance = number_range(1, 100);
    if (chance <= 25)
    {
        obj = create_object (get_obj_index (30), 0);
        create_potion(obj, number_range(0, rig_potion_max()));
        obj_to_obj(obj, chest);
    }
    /*
     * Ok Chance 6: Gem, 20%
     */
    chance = number_range(1, 100);
    if (chance <= 20)
    {
        obj = create_object (get_obj_index (30), 0);
        create_gem(obj, 1);
        obj_to_obj(obj, chest);
    }
    /*
     * Chance 7: Clothing, 60%
     */
    chance = number_range(1, 100);
    if (chance <= 60)
    {
        obj = create_object (get_obj_index (30), 0);
        create_clothing(obj, RIG_RANDOM, FALSE, FALSE);
        obj_to_obj(obj, chest);
    }
    /*
     * Chance 8: Clothing, 60%
     */
    chance = number_range(1, 100);
    if (chance <= 60)
    {
        obj = create_object (get_obj_index (30), 0);
        create_clothing(obj, RIG_RANDOM, FALSE, FALSE);
        obj_to_obj(obj, chest);
    }
    /*
     * Chance 9: Clothing, 60%
     */
    chance = number_range(1, 100);
    if (chance <= 60)
    {
        obj = create_object (get_obj_index (30), 0);
        create_clothing(obj, RIG_RANDOM, FALSE, FALSE);
        obj_to_obj(obj, chest);
    }
    
    return;
}