autoeq.c
./mudd/src/autoeq.c · 20.7 KB
From the archive emlen.tar.gz
Download the archive « Back to the archive contents
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "mud.h"
#ifndef WINDOWS
#include <sys/errno.h>
#include <netinet/in.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/time.h>
#include <dirent.h>
#endif
int aan(int i)
{
if (materials[i].name[0] == 'a' ||
materials[i].name[0] == 'e' ||
materials[i].name[0] == 'i' ||
materials[i].name[0] == 'o' ||
materials[i].name[0] == 'u')
return 1;
return 0;
}
const struct weapon_damage wdt[] =
{
{1,3},
{1,4},
{3,1},
{2,2},
{1,5},
{1,6},
{4,1},
{2,3},
{1,7},
{3,2},
{1,8},
{5,1},
{2,4},
{1,9},
{1,10},
{6,1},
{3,3},
{2,5},
{1,11},
{1,12},
{7,1},
{2,6},
{1,13},
{5,2},
{3,4},
{1,14},
{8,1},
{4,3},
{2,7},
{9,1},
{6,2},
{3,5},
{2,8},
{10,1},
{5,3},
{4,4},
{2,9},
{7,2},
{3,6},
{2,10},
{8,2},
{6,3},
{4,5},
{3,7},
{2,11},
{5,4},
{9,2},
{7,3},
{10,2},
};
void
create_standards(CHAR_DATA *ch, char *argy)
{
int mat=0;
int loc=0;
AREA_DATA *pArea;
char buf[STD_LENGTH];
int iHash;
bool firstraw = FALSE;
char strr[STD_LENGTH];
DEFINE_COMMAND("standards", create_standards, POSITION_STANDING, MAX_LEVEL, LOG_ALWAYS, "This creates the standard items for forging 90000-90999 area.")
if (IS_MOB(ch)) return;
if (LEVEL(ch) != MAX_LEVEL) return;
if (!ch->in_room) return;
if (ch->in_room->vnum != 90000)
{
send_to_char("You must be in room 90000 to use this command with a 2000 room area set up.\n\r", ch);
return;
}
pArea = ch->in_room->area;
if (str_cmp(NAME(ch), "Mephistos"))
{
send_to_char("Only Mephistos can do this cuz if you do this more than once it REALLY screws things up.\n\r", ch);
return;
}
/* This loop makes the forged equipment. */
for (mat = 0; str_cmp(materials[mat].name,"END"); mat++)
{
for (loc = 0; str_cmp(forged[loc].name, "end_of_list"); loc++)
{
OBJ_PROTOTYPE *pObj;
pObj = new_obj_index ();
/* set up general information These are special items..be careful */
pObj->item_type = forged[loc].item_type;
pObj->made_of = mat+1;
pObj->max_in_room = 0;
pObj->timer = 0;
pObj->weight = materials[mat].weight/forged[loc].weight_divisor;
pObj->cost = materials[mat].cost/forged[loc].cost_divisor;
pObj->wear_flags = (ITEM_TAKE | forged[loc].wear_loc);
pObj->vnum = 90000 + 40*mat + loc;
pObj->extra_flags = materials[mat].initflags;
pObj->affected = NULL;
if (materials[mat].bigbonus != 0)
pObj->extra_flags |= ITEM_NOSTORE;
pObj->area = pArea;
if (pObj->vnum > top_vnum_obj)
top_vnum_obj = pObj->vnum;
iHash = pObj->vnum % HASH_MAX;
pObj->next = obj_index_hash[iHash];
obj_index_hash[iHash] = pObj;
pArea->obj_count++;
/* Set up the name */
free_string(pObj->name);
sprintf(buf, "%s %s %s", materials[mat].name, forged[loc].name, (!str_infix(forged[loc].name, "bow") ? "bow" : ""));
pObj->name = str_dup (buf);
/* Set up the short descr If it is a wpn or armor use name, otherwise
use name and name2 as descriptive name. */
free_string(pObj->short_descr);
strr[0] = '\0';
buf[0] = '\0';
sprintf(buf, materials[mat].colorname);
strcpy(strr, anseval (str_dup(buf), ch));
sprintf(buf, "%s %s %s", forged[loc].name2, strr, forged[loc].name);
pObj->short_descr = str_dup(buf);
/* Set up the desc you see in the room. */
free_string(pObj->long_descr);
sprintf(buf, "%s %s %s %s\n\r", forged[loc].name2, materials[mat].name, forged[loc].name, (number_range(1,3) == 2 ? "has been left here." : (number_range(1,2) == 2 ? "lies here gathering dust." : "is here.")));
buf[0] = UPPER(buf[0]);
pObj->long_descr = str_dup(buf);
switch(pObj->item_type)
{
case ITEM_ARMOR:
{
pObj->value[6] = materials[mat].strength;
pObj->value[7] = materials[mat].strength;
pObj->value[9] = (mat+4)/4;
switch(forged[loc].armor_location)
{
case 0:
case 1:
case 2:
case 3:
{
pObj->value[forged[loc].armor_location] = materials[mat].armor + forged[loc].adjust;
}
break;
case 4:
{
int i;
for (i = 0; i < 4; i++)
{
pObj->value[i] = UMAX(1, (materials[mat].armor + forged[loc].adjust)*2/3);
}
}
}
/* Now set up extra affects */
if (materials[mat].bigbonus > 0 && (forged[loc].location != 2 || forged[loc].num_wear_slots != 2))
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = 1;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
switch (forged[loc].location)
{
case 0:
pAf->location = (forged[loc].num_wear_slots == 1 ? APPLY_INT : APPLY_WIS);
break;
case 1:
pAf->location = APPLY_DAMROLL;
break;
case 2:
pAf->location = APPLY_DEX;
break;
}
}
if (materials[mat].kickbonus/forged[loc].num_wear_slots > 0 && forged[loc].location == 2)
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = materials[mat].kickbonus/forged[loc].num_wear_slots;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
pAf->location = APPLY_KICK_DAMAGE;
}
if (materials[mat].bigbonus > 0 && (loc == 0 || loc == 6))
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = 1;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
pAf->location = APPLY_STR;
}
if ((materials[mat].bonushit)/forged[loc].num_wear_slots > 0)
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = (materials[mat].bonushit)/forged[loc].num_wear_slots;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
pAf->location = APPLY_HITROLL;
}
if ((materials[mat].bonushp)/forged[loc].num_wear_slots> 0)
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = (materials[mat].bonushp)/forged[loc].num_wear_slots;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
pAf->location = APPLY_HIT;
}
if ((materials[mat].bonusmove)/forged[loc].num_wear_slots > 0)
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = (materials[mat].bonusmove)/forged[loc].num_wear_slots;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
pAf->location = APPLY_MOVE;
}
if ((materials[mat].bonushit)/forged[loc].num_wear_slots > 0 && forged[loc].location == 0)
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = (materials[mat].bonushit)/forged[loc].num_wear_slots;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
pAf->location = APPLY_SAVING_THROW;
}
}
break;
case ITEM_AMMO: /* Ammo has no affects on it. */
{
pObj->value[7] = wdt[UMAX(0, 3*mat+forged[loc].adjust)].firstdice;
pObj->value[8] = wdt[UMAX(0, 3*mat+forged[loc].adjust)].seconddice;
pObj->value[4] = (loc > 28 ? (loc-29) %3 +1 : 0);
pObj->value[0] = 10;
pObj->value[1] = 10;
}
break;
case ITEM_MISSILE:
{
pObj->value[1] = materials[mat].strength;
pObj->value[2] = 15;
pObj->value[3] = 1 + loc % 3;
pObj->value[4] = (loc > 25 ? (loc-26) %3 +1 : 0);
pObj->value[5] = 1 + mat/6;
}
break;
case ITEM_WEAPON:
{
pObj->value[3] = forged[loc].armor_location;
pObj->extra_flags |= forged[loc].location;
pObj->value[1] = materials[mat].strength;
pObj->value[7] = wdt[UMAX(0, 3*mat+forged[loc].adjust)].firstdice;
pObj->value[8] = wdt[UMAX(0, 3*mat+forged[loc].adjust)].seconddice;
pObj->value[4] = (loc > 28 ? (loc-29) % 3 +1 : 0); /* Only ranged wpns and ammo get item types... */
if (mat > 12)
pObj->extra_flags |= ITEM_POWER;
if (mat > 10)
pObj->extra_flags |= ITEM_WOUND;
if (mat == 9 || mat == 10)
pObj->extra_flags |= ITEM_ELEMENTAL;
if (loc <= 28)
{
if (materials[mat].bonushit + UMIN(2,(26-loc)) != 0)
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = materials[mat].bonushit + UMIN(2,(26-loc));
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
pAf->location = APPLY_HITROLL;
}
if (mat/7+loc-22 > 0)
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = URANGE(1, mat/7+loc-24, 3);
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
pAf->location = APPLY_DAMROLL;
}
}
}
break;
case ITEM_TOOL:
case ITEM_FURNITURE:
{
pObj->value[0] = forged[loc].adjust;
}
break;
case ITEM_CONTAINER:
{
pObj->value[1] = forged[loc].adjust;
pObj->value[0] = 100;
}
break;
case ITEM_RAW:
{
pObj->value[0] = RAW_MINERAL;
pObj->value[1] = mat+1;
pObj->weight = 2;
}
break;
}
}
}
for (mat = 0; str_cmp(hide_types[mat].name,"end_of_list"); mat++)
{
firstraw = FALSE;
for (loc = 0; str_cmp(textiles[loc].name, "end_of_list"); loc++)
{
OBJ_PROTOTYPE *pObj;
pObj = new_obj_index ();
/* set up general information These are special items..be careful */
pObj->item_type = textiles[loc].item_type;
pObj->made_of = mat+1;
pObj->max_in_room = 0;
pObj->timer = 0;
pObj->weight = hide_types[mat].weight/textiles[loc].weight_divisor;
pObj->cost = hide_types[mat].cost/textiles[loc].cost_divisor;
pObj->wear_flags = (ITEM_TAKE | textiles[loc].wear_loc);
pObj->vnum = 90700 + 20*mat + loc;
pObj->extra_flags = hide_types[mat].initflags;
pObj->affected = NULL;
if (hide_types[mat].bigbonus != 0)
pObj->extra_flags |= ITEM_NOSTORE;
pObj->area = pArea;
if (pObj->vnum > top_vnum_obj)
top_vnum_obj = pObj->vnum;
iHash = pObj->vnum % HASH_MAX;
pObj->next = obj_index_hash[iHash];
obj_index_hash[iHash] = pObj;
pArea->obj_count++;
/* Set up the name */
free_string(pObj->name);
sprintf(buf, "%s %s leather", hide_types[mat].name, textiles[loc].name);
pObj->name = str_dup (buf);
/* Set up the short descr If it is a wpn or armor use name, otherwise
use name and name2 as descriptive name. */
free_string(pObj->short_descr);
strr[0] = '\0';
buf[0] = '\0';
sprintf(buf, hide_types[mat].colorname);
strcpy(strr, anseval (str_dup(buf), ch));
/* Set up the short desc of the object. */
sprintf(buf, "%s %s %s", textiles[loc].name2, strr, textiles[loc].name);
pObj->short_descr = str_dup(buf);
/* Set up the desc you see in the room. */
free_string(pObj->long_descr);
sprintf(buf, "A %sskin %s %s\n\r", hide_types[mat].name, textiles[loc].name, (number_range(1,3) == 2 ? "has been left here." : (number_range(1,2) == 2 ? "lies here gathering dust." : "is here.")));
buf[0] = UPPER(buf[0]);
pObj->long_descr = str_dup(buf);
switch(pObj->item_type)
{
default:
break;
case ITEM_ARMOR:
{
pObj->value[6] = hide_types[mat].strength;
pObj->value[7] = hide_types[mat].strength;
pObj->value[9] = (mat+4)/4;
switch(textiles[loc].armor_location)
{
case 0:
case 1:
case 2:
case 3:
{
pObj->value[textiles[loc].armor_location] = hide_types[mat].armor + textiles[loc].adjust;
}
break;
case 4:
{
int i;
for (i = 0; i < 4; i++)
{
pObj->value[i] = UMAX(1, (hide_types[mat].armor + textiles[loc].adjust)*2/3);
}
}
}
/* Now set up extra affects */
if (hide_types[mat].bigbonus > 0 && (textiles[loc].location != 2 || textiles[loc].num_wear_slots != 2))
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = 1;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
switch (textiles[loc].location)
{
case 0:
pAf->location = (textiles[loc].num_wear_slots == 1 ? APPLY_INT : APPLY_WIS);
break;
case 1:
pAf->location = APPLY_DAMROLL;
break;
case 2:
pAf->location = APPLY_DEX;
break;
}
}
if (hide_types[mat].kickbonus/textiles[loc].num_wear_slots > 0 && textiles[loc].location == 2)
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = hide_types[mat].kickbonus/textiles[loc].num_wear_slots;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
pAf->location = APPLY_KICK_DAMAGE;
}
if (hide_types[mat].bigbonus > 0 && (loc == 0 || loc == 6))
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = 1;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
pAf->location = APPLY_STR;
}
if ((hide_types[mat].bonushit)/textiles[loc].num_wear_slots > 0)
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = (hide_types[mat].bonushit)/textiles[loc].num_wear_slots;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
pAf->location = APPLY_HITROLL;
}
if ((hide_types[mat].bonushp)/textiles[loc].num_wear_slots> 0)
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = (hide_types[mat].bonushp)/textiles[loc].num_wear_slots;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
pAf->location = APPLY_HIT;
}
if ((hide_types[mat].bonusmove)/textiles[loc].num_wear_slots > 0)
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = (hide_types[mat].bonusmove)/textiles[loc].num_wear_slots;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
pAf->location = APPLY_MOVE;
}
if ((hide_types[mat].bonushit)/textiles[loc].num_wear_slots > 0 && textiles[loc].location == 0)
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = (hide_types[mat].bonushit)/textiles[loc].num_wear_slots;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
pAf->location = APPLY_SAVING_THROW;
}
}
break;
case ITEM_RAW:
{
firstraw = TRUE;
free_string(pObj->name);
sprintf(buf, "%s %s hide skin", hide_types[mat].name, textiles[loc].name);
pObj->name = str_dup (buf);
free_string(pObj->short_descr);
sprintf(buf, hide_types[mat].colorname);
strcpy(strr, anseval (str_dup(buf), ch));
sprintf(buf, "a %s %s", strr, textiles[loc].name );
pObj->short_descr = str_dup(buf);
free_string(pObj->long_descr);
sprintf(buf, "A %sskin %s %s\n\r", hide_types[mat].name, textiles[loc].name, (number_range(1,3) == 2 ? "has been left here." : (number_range(1,2) == 2 ? "lies here gathering dust." : "is here.")));
buf[0] = UPPER(buf[0]);
pObj->long_descr = str_dup(buf);
pObj->value[0] = RAW_HIDE + firstraw;
firstraw = TRUE;
pObj->value[1] = mat+1;
pObj->weight = 2;
}
break;
}
}
}
for (mat = 0; str_cmp(cloth_types[mat].name,"end_of_list"); mat++)
{
firstraw = FALSE;
for (loc = 0; str_cmp(textiles[loc].name, "end_of_list"); loc++)
{
OBJ_PROTOTYPE *pObj;
pObj = new_obj_index ();
/* set up general information These are special items..be careful */
pObj->item_type = textiles[loc].item_type;
pObj->made_of = mat+1;
pObj->max_in_room = 0;
pObj->timer = 0;
pObj->weight = cloth_types[mat].weight/textiles[loc].weight_divisor;
pObj->cost = cloth_types[mat].cost/textiles[loc].cost_divisor;
pObj->wear_flags = (ITEM_TAKE | textiles[loc].wear_loc);
pObj->vnum = 91200 + 20*mat + loc;
pObj->extra_flags = cloth_types[mat].initflags;
pObj->affected = NULL;
if (cloth_types[mat].bigbonus != 0)
pObj->extra_flags |= ITEM_NOSTORE;
pObj->area = pArea;
if (pObj->vnum > top_vnum_obj)
top_vnum_obj = pObj->vnum;
iHash = pObj->vnum % HASH_MAX;
pObj->next = obj_index_hash[iHash];
obj_index_hash[iHash] = pObj;
pArea->obj_count++;
/* Set up the name */
switch(pObj->item_type)
{
default:
break;
case ITEM_ARMOR:
{
free_string(pObj->name);
sprintf(buf, "%s %s textile", cloth_types[mat].name, textiles[loc].name);
pObj->name = str_dup (buf);
free_string(pObj->short_descr);
sprintf(buf, cloth_types[mat].colorname);
strcpy(strr, anseval (str_dup(buf), ch));
sprintf(buf, "%s %s %s", textiles[loc].name2, strr, textiles[loc].name);
pObj->short_descr = str_dup(buf);
free_string(pObj->long_descr);
sprintf(buf, "%s %s %s %s\n\r", textiles[loc].name2, cloth_types[mat].name, textiles[loc].name, (number_range(1,3) == 2 ? "has been left here." : (number_range(1,2) == 2 ? "is here gathering dust." : "is here.")));
buf[0] = UPPER(buf[0]);
pObj->long_descr = str_dup(buf);
pObj->value[6] = cloth_types[mat].strength;
pObj->value[7] = cloth_types[mat].strength;
pObj->value[9] = (mat+4)/4;
switch(textiles[loc].armor_location)
{
case 0:
case 1:
case 2:
case 3:
{
pObj->value[textiles[loc].armor_location] = cloth_types[mat].armor + textiles[loc].adjust;
}
break;
case 4:
{
int i;
for (i = 0; i < 4; i++)
{
pObj->value[i] = UMAX(1, (cloth_types[mat].armor + textiles[loc].adjust)*2/3);
}
}
}
/* Now set up extra affects */
if (cloth_types[mat].bigbonus > 0 && (textiles[loc].location != 2 || textiles[loc].num_wear_slots != 2))
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = 1;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
switch (textiles[loc].location)
{
case 0:
pAf->location = (textiles[loc].num_wear_slots == 1 ? APPLY_INT : APPLY_WIS);
break;
case 1:
pAf->location = APPLY_DAMROLL;
break;
case 2:
pAf->location = APPLY_DEX;
break;
}
}
if (cloth_types[mat].kickbonus/textiles[loc].num_wear_slots > 0 && textiles[loc].location == 2)
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = cloth_types[mat].kickbonus/textiles[loc].num_wear_slots;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
pAf->location = APPLY_KICK_DAMAGE;
}
if (cloth_types[mat].bigbonus > 0 && (loc == 0 || loc == 6))
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = 1;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
pAf->location = APPLY_STR;
}
if ((cloth_types[mat].bonushit)/textiles[loc].num_wear_slots > 0)
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = (cloth_types[mat].bonushit)/textiles[loc].num_wear_slots;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
pAf->location = APPLY_HITROLL;
}
if ((cloth_types[mat].bonushp)/textiles[loc].num_wear_slots> 0)
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = (cloth_types[mat].bonushp)/textiles[loc].num_wear_slots;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
pAf->location = APPLY_HIT;
}
if ((cloth_types[mat].bonusmove)/textiles[loc].num_wear_slots > 0)
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = (cloth_types[mat].bonusmove)/textiles[loc].num_wear_slots;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
pAf->location = APPLY_MOVE;
}
if ((cloth_types[mat].bonushit)/textiles[loc].num_wear_slots > 0 && textiles[loc].location == 0)
{
AFFECT_DATA *pAf;
pAf = new_affect ();
pAf->modifier = (cloth_types[mat].bonushit)/textiles[loc].num_wear_slots;
pAf->type = 1;
pAf->next = pObj->affected;
pObj->affected = pAf;
pAf->location = APPLY_SAVING_THROW;
}
}
break;
case ITEM_RAW:
{
firstraw = TRUE;
free_string(pObj->name);
sprintf(buf, "%s %s", cloth_types[mat].name, textiles[loc].name2);
pObj->name = str_dup (buf);
free_string(pObj->short_descr);
sprintf(buf, cloth_types[mat].colorname);
strcpy(strr, anseval (str_dup(buf), ch));
sprintf(buf, "some %s %s", cloth_types[mat].name, textiles[loc].name2);
pObj->short_descr = str_dup(buf);
free_string(pObj->long_descr);
sprintf(buf, "Some %s %s %s\n\r", cloth_types[mat].name, textiles[loc].name2, (number_range(1,3) == 2 ? "has been left here." : (number_range(1,2) == 2 ? "lies here gathering dust." : "is here.")));
buf[0] = UPPER(buf[0]);
pObj->long_descr = str_dup(buf);
pObj->value[0] = RAW_FIBER + firstraw;
firstraw = TRUE;
pObj->value[1] = mat+1;
pObj->weight = 2;
}
}
}
}
return;
}