instructions for autoweapon and autoarmor installation.
this code is freeware, by Blade of E (franzj@fxlab.net)
use at your own discretion, have fun, and please give me credit
somewhere or at least email me...

===========

note: requires ivans olc

cut and paste the functions into your olc_act.c file, then
add, in olc.h, the following:

>>>>>>>
DECLARE_OLC_FUN( oedit_autoweapon );
DECLARE_OLC_FUN( oedit_autoarmor );
<<<<<<<

in olc.c, in the command table for oedit, add this:

>>>>>>>
        {   "autoweapon", oedit_autoweapon },
	{   "autoarmor", oedit_autoarmor },
<<<<<<<

then do a clean recompile and you're set.

NOTE: make sure you set the value in the avg calculation to an appropriate
value for you mud... the value used here is .76, which means that weapons
created with autoweapon will come as close to an average dmg of 76% as possible...
in my experience, the .76 setting seems to yield weapons that do between 70 and 73%
of thier level in avg dmg...
if you want more dmg, raise the .76 slightly, if you want less, lower it slightly.



>>>>>>>>
OEDIT( oedit_autoweapon )
{
	OBJ_INDEX_DATA *pObj;
	AFFECT_DATA *pAf;
	int dice, size, bonus;
	double avg;

	EDIT_OBJ(ch, pObj);
	if (pObj->item_type != ITEM_WEAPON)
	{
		 send_to_char( " {rAutoweapn only works on weapons...{x\n\r", ch);
	return FALSE;
	}
	if (pObj->level < 1)
	{
		send_to_char( " {cAutoweapon requires a level to be set on the weapon first.{x\n\r", ch);
		return FALSE;
	}
   bonus = UMAX(0, pObj->level/10 - 1);
/* adjust this next line to change the avg dmg your weapons will get! */
	avg = (pObj->level * .76);
	dice = (pObj->level/10 + 1);
	size = dice/2;
/* loop through dice sizes until we find that the Next dice size's avg
will be too high... ie, find the "best fit" */
	for (size=dice/2 ; dice * (size +2)/2 < avg ; size++ )
	{ }

	dice = UMAX(1, dice);
	size = UMAX(2, size);

	switch (pObj->value[0]) {
	default:
	case WEAPON_EXOTIC:
	case WEAPON_SWORD:
		break;
	case WEAPON_DAGGER:
		dice = UMAX(1, dice - 1);
		size = UMAX(2, size - 1);
	  break;
	case WEAPON_SPEAR:
	case WEAPON_POLEARM:
		size++;
		break;
	case WEAPON_MACE:
	case WEAPON_AXE:
		size = UMAX(2,size - 1);
		break;
	case WEAPON_FLAIL:
	case WEAPON_WHIP:
		dice = UMAX(1, dice - 1);
		break;
	}
	dice = UMAX(1, dice);
	size = UMAX(2, size);
	
	
	pObj->cost = 25 * (size * (dice + 1)) + 20 * bonus + 20 * pObj->level;
	pObj->weight = pObj->level + 1;
	pObj->value[1] = dice;
pObj->value[2] = size;
if (bonus > 0) {
pAf             =   new_affect();
    pAf->location   =   APPLY_DAMROLL;
    pAf->modifier   =   bonus;
    pAf->where	    =   TO_OBJECT;
    pAf->type       =   -1;
    pAf->duration   =   -1;
    pAf->bitvector  =   0;
    pAf->level      =	pObj->level;
    pAf->next       =   pObj->affected;
    pObj->affected  =   pAf;

pAf             =   new_affect();
    pAf->location   =   APPLY_HITROLL;
    pAf->modifier   =   bonus;
    pAf->where	    =   TO_OBJECT;
    pAf->type       =   -1;
    pAf->duration   =   -1;
    pAf->bitvector  =   0;
    pAf->level      =	pObj->level;
    pAf->next       =   pObj->affected;
    pObj->affected  =   pAf;
}
send_to_char(" {cExperimental values set on weapon...{x\n\r", ch);
return TRUE;
}

OEDIT( oedit_autoarmor )
{
   OBJ_INDEX_DATA *pObj;
	int size;

	EDIT_OBJ(ch, pObj);
	if (pObj->item_type != ITEM_ARMOR)
	{
		 send_to_char( " {rAutoArmor only works on Armor ...{x\n\r", ch);
	return FALSE;
	}
	if (pObj->level < 1)
	{
		send_to_char( " {cAutoArmor requires a level to be set on the armor first.{x\n\r", ch);
		return FALSE;
	}
	size = UMAX(1, pObj->level/2.8 + 1);
	pObj->weight = pObj->level + 1;
pObj->cost = pObj->level^2 * 2;	
pObj->value[0] = size;
	pObj->value[1] = size;
	pObj->value[2] = size;
		pObj->value[3] = (size - 1);
		send_to_char( " {cAutoArmor has set experimental values for AC.{x\n\r", ch);
		return TRUE;
}
<<<<<<<