void armor_load (CHAR_DATA * ch)
{
OBJ_DATA *armor;
char buf[512];
int anum = number_range(armor_num[0], armor_num[10]);
int wnum = number_range(0, 11);
int ldnum = number_range (0, 2);
char aname[MSL];
armor = create_object (get_obj_index (OBJ_VNUM_RARMOR), 0);
// free_string(aname);
if(wnum == 0)
strcat(aname, "ring");
else if(wnum == 1)
{
if(number_chance(50))
strcat(aname, "talisman");
else
strcat(aname, "amulet");
}
else if (wnum == 2)
strcat(aname, "breastplate");
else if (wnum == 3)
{
if(number_chance(15))
strcat(aname, "tiara");
else if(number_chance(30))
strcat(aname, "crown");
else
strcat(aname, "helmet");
}
else if (wnum == 4)
strcat(aname, "leggings");
else if (wnum == 5)
strcat(aname, "boots");
else if (wnum == 6)
strcat(aname, "gauntlets");
else if (wnum == 7)
strcat(aname,"sleeves");
else if (wnum == 8)
strcat(aname, "shield");
else if (wnum == 9)
strcat(aname, "cloak");
else if (wnum == 10)
strcat(aname, "belt");
else
strcat(aname, "bracer");
sprintf (buf, "%s %s", armor_name[anum], aname);
free_string (armor->name);
armor->name = str_dup (buf);
sprintf (buf, "%s %s", armor_short[anum], aname);
free_string (armor->short_descr);
armor->short_descr = str_dup (buf);
sprintf (buf, "%s %s %s", armor_long[anum], aname, armor_long2[ldnum]);
free_string (armor->description);
armor->description = str_dup (buf);
armor->timer = -1;
armor->cost = number_range(100, 1000);
armor->weight = number_range(1, 3);
armor->level = number_range(ch->level - 5, ch->level + 5);
armor->value[0] = number_range((ch->level / 3) - 5, (ch->level / 3) + 5);
armor->value[1] = number_range((ch->level / 3) - 5, (ch->level / 3) + 5);
armor->value[2] = number_range((ch->level / 3) - 5, (ch->level / 3) + 5);
armor->value[3] = number_range((ch->level / 3) - 5, (ch->level / 3) + 5);
obj_to_char (armor, ch);
sprintf(buf, "You grab %s from the corpse.\n\r", armor->short_descr);
stc(buf, ch);
return;
}
if(wnum == 0)
aname = (char) 'ring'; //Works fine, no warnings.
else if(wnum == 1)
{
if(number_chance(50))
aname = 'talisman'; //warning: overflow in implicit constant conversion
else
aname = "amulet"; //warning: assignment makes integer from pointer without a cast
}
else if (wnum == 2)
aname = "breastplate";
else if (wnum == 3)
{
if(number_chance(33))
aname = "tiara";
else if(number_chance(34))
aname = "crown";
else
aname = "helmet";
}
Question:
Where RING is defined, does setting it as a (char) change it to a variable
that can be manipulated other places within the code?
…..
While typing this I realized I forgot to define char aname with a string
length, but still, the question above.^^^