lore.txt
snippets · 10.7 KB · 2010-03-30
Lore command by Photic: can be its own command or part of do_look.
Download « Back to the snippets list
From: Photic <dognus@san.rr.com>
heres a little lore command i made, you can make it a command itself, or
you can add do_lore to do_look somewhere im sure, its basically just a
slightly modified version of ostat. feel free to hack at it if needed, i
just made it a command itself, cause looking
at something and seeing all this can be annoying.
void do_lore( CHAR_DATA *ch, char *argument )
{
char buf[MAX_STRING_LENGTH];
char arg[MAX_INPUT_LENGTH];
AFFECT_DATA *paf;
OBJ_DATA *obj;
if ( !IS_NPC(ch)
&& ch->level < skill_table[gsn_lore].skill_level[ch->class] )
{
send_to_char(
"You would like to what?\n\r", ch );
return;
}
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
send_to_char( "What Would you like to know more about?\n\r", ch );
return;
}
if ( ( obj = get_obj_carry( ch, arg, ch ) ) == NULL )
{
send_to_char( "You cannot lore that because you do not have
that.\n\r", ch );
return;
}
if ( number_percent( ) < get_skill(ch,gsn_lore))
{
send_to_char( "You learn more about this object:\n\r", ch );
check_improve(ch,gsn_lore,TRUE,4);
sprintf( buf, "Name(s): %s\n\r",
obj->name );
send_to_char( buf, ch );
sprintf( buf, "Short description: %s\n\rLong description: %s\n\r",
obj->short_descr, obj->description );
send_to_char( buf, ch );
sprintf( buf, "Wear bits: %s\n\rExtra bits: %s\n\r",
wear_bit_name(obj->wear_flags), extra_bit_name( obj->extra_flags ) );
send_to_char( buf, ch );
sprintf( buf, "Weight: %d/%d/%d (10th pounds)\n\r",
obj->weight / 10);
send_to_char( buf, ch );
sprintf( buf, "Level: %d Cost: %d\n\r",
obj->level, obj->cost);
send_to_char( buf, ch );
/* now give out vital statistics as per identify */
switch ( obj->item_type )
{
case ITEM_SCROLL:
case ITEM_POTION:
case ITEM_PILL:
sprintf( buf, "Level %d spells of:", obj->value[0] );
send_to_char( buf, ch );
if ( obj->value[1] >= 0 && obj->value[1] < MAX_SKILL )
{
send_to_char( " '", ch );
send_to_char( skill_table[obj->value[1]].name, ch );
send_to_char( "'", ch );
}
if ( obj->value[2] >= 0 && obj->value[2] < MAX_SKILL )
{
send_to_char( " '", ch );
send_to_char( skill_table[obj->value[2]].name, ch );
send_to_char( "'", ch );
}
if ( obj->value[3] >= 0 && obj->value[3] < MAX_SKILL )
{
send_to_char( " '", ch );
send_to_char( skill_table[obj->value[3]].name, ch );
send_to_char( "'", ch );
}
if (obj->value[4] >= 0 && obj->value[4] < MAX_SKILL)
{
send_to_char(" '",ch);
send_to_char(skill_table[obj->value[4]].name,ch);
send_to_char("'",ch);
}
send_to_char( ".\n\r", ch );
break;
case ITEM_WAND:
case ITEM_STAFF:
sprintf( buf, "Has %d(%d) charges of level %d",
obj->value[1], obj->value[2], obj->value[0] );
send_to_char( buf, ch );
if ( obj->value[3] >= 0 && obj->value[3] < MAX_SKILL )
{
send_to_char( " '", ch );
send_to_char( skill_table[obj->value[3]].name, ch );
send_to_char( "'", ch );
}
send_to_char( ".\n\r", ch );
break;
case ITEM_DRINK_CON:
sprintf(buf,"It holds %s-colored %s.\n\r",
liq_table[obj->value[2]].liq_color,
liq_table[obj->value[2]].liq_name);
send_to_char(buf,ch);
break;
case ITEM_WEAPON:
send_to_char("Weapon type is ",ch);
switch (obj->value[0])
{
case(WEAPON_EXOTIC):
send_to_char("exotic\n\r",ch);
break;
case(WEAPON_SWORD):
send_to_char("sword\n\r",ch);
break;
case(WEAPON_DAGGER):
send_to_char("dagger\n\r",ch);
break;
case(WEAPON_SPEAR):
send_to_char("spear/staff\n\r",ch);
break;
case(WEAPON_MACE):
send_to_char("mace/club\n\r",ch);
break;
case(WEAPON_AXE):
send_to_char("axe\n\r",ch);
break;
case(WEAPON_FLAIL):
send_to_char("flail\n\r",ch);
break;
case(WEAPON_WHIP):
send_to_char("whip\n\r",ch);
break;
case(WEAPON_POLEARM):
send_to_char("polearm\n\r",ch);
break;
default:
send_to_char("unknown\n\r",ch);
break;
}
if (obj->pIndexData->new_format)
sprintf(buf,"Damage is %dd%d (average %d)\n\r",
obj->value[1],obj->value[2],
(1 + obj->value[2]) * obj->value[1] / 2);
else
sprintf( buf, "Damage is %d to %d (average %d)\n\r",
obj->value[1], obj->value[2],
( obj->value[1] + obj->value[2] ) / 2 );
send_to_char( buf, ch );
sprintf(buf,"Damage noun is %s.\n\r",
(obj->value[3] > 0 && obj->value[3] < MAX_DAMAGE_MESSAGE) ?
attack_table[obj->value[3]].noun : "undefined");
send_to_char(buf,ch);
if (obj->value[4]) /* weapon flags */
{
sprintf(buf,"Weapons flags: %s\n\r",
weapon_bit_name(obj->value[4]));
send_to_char(buf,ch);
}
break;
case ITEM_ARMOR:
sprintf( buf,
"Armor class is %d pierce, %d bash, %d slash, and %d vs.
magic\n\r",
obj->value[0], obj->value[1], obj->value[2], obj->value[3] );
send_to_char( buf, ch );
break;
case ITEM_CONTAINER:
sprintf(buf,"Capacity: %d# Maximum weight: %d# flags: %s\n\r",
obj->value[0], obj->value[3], cont_bit_name(obj->value[1]));
send_to_char(buf,ch);
if (obj->value[4] != 100)
{
sprintf(buf,"Weight multiplier: %d%%\n\r",
obj->value[4]);
send_to_char(buf,ch);
}
break;
}
if ( obj->extra_descr != NULL || obj->pIndexData->extra_descr != NULL )
{
EXTRA_DESCR_DATA *ed;
send_to_char( "Extra description keywords: '", ch );
for ( ed = obj->extra_descr; ed != NULL; ed = ed->next )
{
send_to_char( ed->keyword, ch );
if ( ed->next != NULL )
send_to_char( " ", ch );
}
for ( ed = obj->pIndexData->extra_descr; ed != NULL; ed = ed->next )
{
send_to_char( ed->keyword, ch );
if ( ed->next != NULL )
send_to_char( " ", ch );
}
send_to_char( "'\n\r", ch );
}
for ( paf = obj->affected; paf != NULL; paf = paf->next )
{
sprintf( buf, "Affects %s by %d, level %d",
affect_loc_name( paf->location ), paf->modifier,paf->level );
send_to_char(buf,ch);
if ( paf->duration > -1)
sprintf(buf,", %d hours.\n\r",paf->duration);
else
sprintf(buf,".\n\r");
send_to_char( buf, ch );
if (paf->bitvector)
{
switch(paf->where)
{
case TO_AFFECTS:
sprintf(buf,"Adds %s affect.\n",
affect_bit_name(paf->bitvector));
break;
case TO_WEAPON:
sprintf(buf,"Adds %s weapon flags.\n",
weapon_bit_name(paf->bitvector));
break;
case TO_OBJECT:
sprintf(buf,"Adds %s object flag.\n",
extra_bit_name(paf->bitvector));
break;
case TO_IMMUNE:
sprintf(buf,"Adds immunity to %s.\n",
imm_bit_name(paf->bitvector));
break;
case TO_RESIST:
sprintf(buf,"Adds resistance to %s.\n\r",
imm_bit_name(paf->bitvector));
break;
case TO_VULN:
sprintf(buf,"Adds vulnerability to %s.\n\r",
imm_bit_name(paf->bitvector));
break;
default:
sprintf(buf,"Unknown bit %d: %d\n\r",
paf->where,paf->bitvector);
break;
}
send_to_char(buf,ch);
}
}
if (!obj->enchanted)
for ( paf = obj->pIndexData->affected; paf != NULL; paf = paf->next )
{
sprintf( buf, "Affects %s by %d, level %d.\n\r",
affect_loc_name( paf->location ), paf->modifier,paf->level );
send_to_char( buf, ch );
if (paf->bitvector)
{
switch(paf->where)
{
case TO_AFFECTS:
sprintf(buf,"Adds %s affect.\n",
affect_bit_name(paf->bitvector));
break;
case TO_OBJECT:
sprintf(buf,"Adds %s object flag.\n",
extra_bit_name(paf->bitvector));
break;
case TO_IMMUNE:
sprintf(buf,"Adds immunity to %s.\n",
imm_bit_name(paf->bitvector));
break;
case TO_RESIST:
sprintf(buf,"Adds resistance to %s.\n\r",
imm_bit_name(paf->bitvector));
break;
case TO_VULN:
sprintf(buf,"Adds vulnerability to %s.\n\r",
imm_bit_name(paf->bitvector));
break;
default:
sprintf(buf,"Unknown bit %d: %d\n\r",
paf->where,paf->bitvector);
break;
}
send_to_char(buf,ch);
}
}
}
return;
}