/***************************************************************************
 *                                            ,_  .--.                     *
 *                                          _)\/    ;--.                   *
 *                            . ' .    _.-'`   |  .'    \                  *
 *                           -= * =-  (.-,    /  /       |                 *
 *                            ' .\'    ). `))/ .'   _/\ /                  *
 *                                \_   \_  /( /     \ /(                   *
 * ___,                           /_\ .--'   `-.    //  \                  *
 *(-|_\_,  _   _      _  .-.      ||\/        , '._//    |                 *
 * _|  )  (_| (/_    (_) |-       ||/ /`(_ (_,;`-._/     /                 *
 *(       ,_|            |        \_.'   )   /`\       .'                  *
 *                                     .' .  |  ;.   /`                    *
 *                                    /      |\(  `.(                      *
 * ___,                              |   |/  | `    `                      *
 *(-|_) ,_  _   _  |_   _   _        |   |  /                              *
 * _|   |  (_) |_) | | (/_ (_ \/     |   |.'                               *
 *(            |            ,_/   __/'  /                                  *
 *                            _ .'  _.-`                                   *
 *                          _.` `.-;`/                                     *
 *                        /_.-'` / /                                       *
 *                              / /                                        *
 *                             ( /                                         *
 *                            /_/                                          *
 *            Age of Prophecy 1.9 is copyright 2001-2002                   *
 *   Brought to you by: Richard Kicklighter (Ostoles@directvinternet.com   *
 *                      Mike McDonald (0mm28@qlink.queensu.ca)             *
 ***************************************************************************/

/**************************************************************************
 *Snippet: Object Requirements                                            *
 *Instead of objects being worn based on level, its based on stats and    *
 *object size. A word of caution, this might not work on your mud without *
 *some editing as AoP has some unique code. If you have any questions     *
 *please do not hesitate to ask. Also, thanks to Kender, Muerte, and      *
 *everyone else that has helped me out from #Rom@acestar.foreverchat.net  *
 *Have fun, and enjoy. If you use this, please let me know.               *
 *-Ostoles                                                                *
 **************************************************************************/

/*Reqs:
 *
 *Olc 1.81
 *Rom 2.4b6
 */


/*Start of snippet*/

 /*File: act_obj.c
  *Function: wear_obj()
  *Instructions:
  *-Remove the level check.
  *-Add in:
  */

	if (!IS_IMMORTAL(ch) && !IS_NPC(ch))
	{
    	if ((obj->requirements[SIZ_REQ] != SIZE_MAGIC) && (ch->size != obj->requirements[SIZ_REQ]))
    	{
			send_to_char("The object does not even fit you.",ch);
		    return;
    	}
    	if (get_curr_stat(ch,STAT_STR) < obj->requirements[STR_REQ])
    	{
		    send_to_char("You do not have enough strength to wear this object.",ch);
		    return;
		}
	    if (get_curr_stat(ch,STAT_DEX) < obj->requirements[DEX_REQ])
    	{
	    	send_to_char("You do not have enough dexterity to wear this object.",ch);
	    	return;
		}
		if (get_curr_stat(ch,STAT_CON) < obj->requirements[CON_REQ])
	    {
		    send_to_char("You do not have enough constitution to wear this object.",ch);
	    	return;
		}
		if (get_curr_stat(ch,STAT_INT) < obj->requirements[INT_REQ])
    	{
		    send_to_char("You do not have enough Inteligence to wear this object.",ch);
		    return;
		}
		if (get_curr_stat(ch,STAT_WIS) < obj->requirements[WIS_REQ])
    	{
	    	send_to_char("You do not have enough wisdom to wear this object.",ch);
	    	return;
		}
		if (get_curr_stat(ch,STAT_CHA) < obj->requirements[CHA_REQ])
    	{
		    send_to_char("You do not have enough charisma to wear this object.",ch);
		    return;
		}
	}

 /*File: db2.c
  *Function: load_objects()
  *Instructions:
  *-I started using a versioning system so this might differ from your mud.
  *-Add in:
  */
  /*Note: I put mine under "pObjIndex->wear_flags           = fread_flag( fp );"*/

		if (pObjIndex->area->version < 1)
		{
			pObjIndex->requirements[SIZ_REQ]	= 0;
        	pObjIndex->requirements[STR_REQ]	= 0;
        	pObjIndex->requirements[DEX_REQ]	= 0;
        	pObjIndex->requirements[CON_REQ]	= 0;
        	pObjIndex->requirements[INT_REQ]	= 0;
        	pObjIndex->requirements[WIS_REQ]	= 0;
        	pObjIndex->requirements[CHA_REQ]	= 0;
		}
		else
		{
        	pObjIndex->requirements[SIZ_REQ]	= fread_number( fp );
        	pObjIndex->requirements[STR_REQ]	= fread_number( fp );
        	pObjIndex->requirements[DEX_REQ]	= fread_number( fp );
        	pObjIndex->requirements[CON_REQ]	= fread_number( fp );
        	pObjIndex->requirements[INT_REQ]	= fread_number( fp );
        	pObjIndex->requirements[WIS_REQ]	= fread_number( fp );
        	pObjIndex->requirements[CHA_REQ]	= fread_number( fp );
        }

 /*File: db.c
  *Function: create_object()
  *Instructions:
  *-Add in:
  */

	obj->requirements[SIZ_REQ]	= pObjIndex->requirements[SIZ_REQ];
	obj->requirements[STR_REQ]	= pObjIndex->requirements[STR_REQ];
	obj->requirements[DEX_REQ]	= pObjIndex->requirements[DEX_REQ];
	obj->requirements[CON_REQ]	= pObjIndex->requirements[CON_REQ];
	obj->requirements[INT_REQ]	= pObjIndex->requirements[INT_REQ];
	obj->requirements[WIS_REQ]	= pObjIndex->requirements[WIS_REQ];
	obj->requirements[CHA_REQ]	= pObjIndex->requirements[CHA_REQ];

 /*File: olc_save.c
  *Function: save_object()
  *Instructions:
  *-Add in:
  */
  /*Note: I put mine under "fprintf( fp, "%s\n",     fwrite_flag( pObjIndex->wear_flags,  buf ) );"*/

    fprintf( fp, "%d %d %d %d %d %d %d\n",
    pObjIndex->requirements[SIZ_REQ],
    pObjIndex->requirements[STR_REQ],
    pObjIndex->requirements[DEX_REQ],
    pObjIndex->requirements[CON_REQ],
    pObjIndex->requirements[INT_REQ],
    pObjIndex->requirements[WIS_REQ],
    pObjIndex->requirements[CHA_REQ]);

 /*File: save.c
  *Function: fwrite_obj()
  *Instructions:
  *-Add in:
  */

	fprintf( fp, "Requirements %d %d %d %d %d %d %d\n",
    obj->requirements[SIZ_REQ],
    obj->requirements[STR_REQ],
    obj->requirements[DEX_REQ],
    obj->requirements[CON_REQ],
    obj->requirements[INT_REQ],
    obj->requirements[WIS_REQ],
    obj->requirements[CHA_REQ]);


 /*File: save.c
  *Function: fread_obj()
  *Instructions:
  *-Add in:
  */
  /*Note: I did not have a case R so if you do, just add the if part.*/
	case 'R':
		if ( !str_cmp( word, "Requirements" ))
	    {
		obj->requirements[SIZ_REQ]	= fread_number( fp );
		obj->requirements[STR_REQ]	= fread_number( fp );
		obj->requirements[DEX_REQ]	= fread_number( fp );
		obj->requirements[CON_REQ]	= fread_number( fp );
		obj->requirements[INT_REQ]	= fread_number( fp );
		obj->requirements[WIS_REQ]	= fread_number( fp );
		obj->requirements[CHA_REQ]	= fread_number( fp );
		fMatch		= TRUE;
		break;
	    }

 /*File: merc.h
  *Section: defines
  *Instructions:
  *-Add in:
  */

#define MAX_REQ 7
#define SIZ_REQ 0
#define STR_REQ 1
#define DEX_REQ 2
#define CON_REQ 3
#define INT_REQ 4
#define WIS_REQ 5
#define CHA_REQ 6

 /*File: merc.h
  *Structure: obj_index_data and obj_data
  *Instructions:
  *-Add in:
  */

    char      requirements[MAX_REQ];

 /*File: olc_act.c
  *Instructions:
  *-Add the oedit commands to the command table and define them.
  *-Add in:
  */

void show_obj_requirements( CHAR_DATA *ch, OBJ_INDEX_DATA *obj )
{
    char buf[MAX_STRING_LENGTH];

	send_to_char("Requirements:\n\r",ch);
	sprintf( buf,
		"[r0] Size:          [%d]\n\r"
		"[r1] Strength:      [%d]\n\r"
		"[r2] Dexterity:     [%d]\n\r"
		"[r3] Constitution:  [%d]\n\r"
		"[r4] Inteligence:   [%d]\n\r"
		"[r5] Wisdom:        [%d]\n\r"
		"[r6] Charisma:      [%d]\n\r",
		obj->requirements[SIZ_REQ], obj->requirements[STR_REQ],
		obj->requirements[DEX_REQ], obj->requirements[CON_REQ],
		obj->requirements[INT_REQ], obj->requirements[WIS_REQ],
		obj->requirements[CHA_REQ]);
		send_to_char(buf, ch);
		send_to_char("\n\r",ch);
    return;
}

OEDIT( oedit_req0 )
{
	char buf[MSL];
    OBJ_INDEX_DATA *pObj;

    EDIT_OBJ(ch, pObj);

    if ( argument[0] == '\0' || !is_number( argument ) )
    {
	send_to_char( "Syntax:  r0 [number]\n\r", ch );
	send_to_char( "For numbers use:\n\r", ch );
	sprintf(buf,"%d: Tiny\n\r%d: Small\n\r%d: Medium\n\r%d: Large\n\r%d: Huge\n\r%d: Giant\n\r%d: All\n\r",
	SIZE_TINY, SIZE_SMALL, SIZE_MEDIUM, SIZE_LARGE, SIZE_HUGE, SIZE_GIANT, SIZE_MAGIC);
	send_to_char(buf,ch);
	return FALSE;
    }

    pObj->requirements[SIZ_REQ] = atoi( argument );

    send_to_char( "Size Requirement set.\n\r", ch);
    return TRUE;

}

OEDIT( oedit_req1 )
{
    OBJ_INDEX_DATA *pObj;

    EDIT_OBJ(ch, pObj);

    if ( argument[0] == '\0' || !is_number( argument ) )
    {
	send_to_char( "Syntax:  r1 [number]\n\r", ch );
	return FALSE;
    }

    pObj->requirements[STR_REQ] = atoi( argument );

    send_to_char( "Str Requirement set.\n\r", ch);
    return TRUE;

}
OEDIT( oedit_req2 )
{
    OBJ_INDEX_DATA *pObj;

    EDIT_OBJ(ch, pObj);

    if ( argument[0] == '\0' || !is_number( argument ) )
    {
	send_to_char( "Syntax:  r2 [number]\n\r", ch );
	return FALSE;
    }

    pObj->requirements[DEX_REQ] = atoi( argument );

    send_to_char( "Dex Requirement set.\n\r", ch);
    return TRUE;

}
OEDIT( oedit_req3 )
{
    OBJ_INDEX_DATA *pObj;

    EDIT_OBJ(ch, pObj);

    if ( argument[0] == '\0' || !is_number( argument ) )
    {
	send_to_char( "Syntax:  r3 [number]\n\r", ch );
	return FALSE;
    }

    pObj->requirements[CON_REQ] = atoi( argument );

    send_to_char( "Con Requirement set.\n\r", ch);
    return TRUE;

}
OEDIT( oedit_req4 )
{
    OBJ_INDEX_DATA *pObj;

    EDIT_OBJ(ch, pObj);

    if ( argument[0] == '\0' || !is_number( argument ) )
    {
	send_to_char( "Syntax:  r4 [number]\n\r", ch );
	return FALSE;
    }

    pObj->requirements[INT_REQ] = atoi( argument );

    send_to_char( "Int Requirement set.\n\r", ch);
    return TRUE;

}
OEDIT( oedit_req5 )
{
    OBJ_INDEX_DATA *pObj;

    EDIT_OBJ(ch, pObj);

    if ( argument[0] == '\0' || !is_number( argument ) )
    {
	send_to_char( "Syntax:  r5 [number]\n\r", ch );
	return FALSE;
    }

    pObj->requirements[WIS_REQ] = atoi( argument );

    send_to_char( "Wis Requirement set.\n\r", ch);
    return TRUE;

}
OEDIT( oedit_req6 )
{
    OBJ_INDEX_DATA *pObj;

    EDIT_OBJ(ch, pObj);

    if ( argument[0] == '\0' || !is_number( argument ) )
    {
	send_to_char( "Syntax:  r6 [number]\n\r", ch );
	return FALSE;
    }

    pObj->requirements[CHA_REQ] = atoi( argument );

    send_to_char( "Cha Requirement set.\n\r", ch);
    return TRUE;

}
/*End of snippet*/
/*I think thats about it, if I forgot something let me know.
 *-Ostoles
 *--Age of Prophecy
 *--mud.darktech.org port 7000
 */