Adding New Attributes

Posted by Harlaquin on Fri 15 Oct 2004 06:10 AM — 13 posts, 37,819 views.

#0
Having trouble locating all the nessary places i need to add the new attribute to. I know some places are obvious but if there's something that could point me in a better more concreate direction that'd be sweet.

-Mirrodan/Harlaquin
USA #1
What do you mean by attribute?
USA #2
by new attribute i'm reffering to str/con/dex etc.

-Mirrodan

also anyone have any input on how to get do look to show the vnum properly in a list ? I've got to show the object vnum but if there's multiple objects in your inventory it places all the vnums off to the top the lists the objects.

USA #3
Basically, just add the variable to mud.h in the char_data struct, and then in fwrite_char and fread_char in save.c, you may need to add get_curr_<newstat> function in handler.c, just in case.
USA #4
What Zeno said is correct. The get_curr_* functions are for ensuring that the values are 'sane' e.g. within allowed limits.

As for your second question you'll have to be a bit more precise about what you've done, what it does and what you need it to do. :)
USA #5
Thanks sorry i'm a noob with grand ideas when it comes to coding..
I just want it to show an imm the objects vnum when they look i.e. type inventory or look into a room.



USA #6
OK. So you said you did something and it doesn't work - what did you do and how does it not work?
USA #7
I added this to char *format_obj_to_char( OBJ_DATA *obj, CHAR_DATA *ch, bool fShort )

under the local functions in act_info.c

if( !IS_NPC(ch) && IS_IMMORTAL(ch) ) // helpmeiamlost
{
ch_printf( ch, "&Y(Ovnum %d)", obj->pIndexData->vnum );
}

I figured it'd show me the vnum of the object and it does but, if the object is in your inventory and you've got 2 different objects i.e. ones that wont combine. the vnums are displayed at the top of the inventory to the left and the objects are pused down towards the right.

-mirro
USA #8
Could you show me what it does? And the whole function for format_obj_to_char, so that I know what we're working with.

Also could you please format it using the [code] forum tag? Proper indents make it so much easier to follow. :)
USA #9
This is how it looks within someone's inventory ......

You are carrying:
(Ovnum 103)(Ovnum 10333) The key to %s's house.
The Adventurer's Guide(3)

and when some one just looks

(Ovnum 100)(Ovnum 10333)The Immortal Update and Note Board
A book with "DON'T PANIC, LOOK AT ME!" written on the cover lies here.(2)

the code in act_info i moded is below....


char *format_obj_to_char( OBJ_DATA *obj, CHAR_DATA *ch, bool fShort )
{
    static char buf[MAX_STRING_LENGTH];
    bool glowsee = FALSE;

    /* can see glowing invis items in the dark */
    if ( IS_OBJ_STAT(obj, ITEM_GLOW) && IS_OBJ_STAT(obj, ITEM_INVIS)
    &&  !IS_AFFECTED(ch, AFF_TRUESIGHT) && !IS_AFFECTED(ch, AFF_DETECT_INVIS) )
	glowsee = TRUE;

    buf[0] = '\0';
    if ( IS_OBJ_STAT(obj, ITEM_INVIS)     )   strcat( buf, "(Invis) "     );
    if (  (IS_AFFECTED(ch, AFF_DETECT_EVIL) || ch->class==CLASS_PALADIN)
	 && IS_OBJ_STAT(obj, ITEM_EVIL)   )   strcat( buf, "(Red Aura) "  );
   if( !IS_NPC(ch) && IS_IMMORTAL(ch) ) // helpmeiamlost
	 {
		 ch_printf( ch, "&Y(Ovnum %d)", obj->pIndexData->vnum );
     }
    if ( ch->class==CLASS_PALADIN
	 && ( IS_OBJ_STAT(obj, ITEM_ANTI_EVIL) && !IS_OBJ_STAT(obj, ITEM_ANTI_NEUTRAL) && !IS_OBJ_STAT(obj, ITEM_ANTI_GOOD))   )
          strcat( buf, "(Flaming Red) "  );
    if ( ch->class==CLASS_PALADIN
	 && ( !IS_OBJ_STAT(obj, ITEM_ANTI_EVIL) && IS_OBJ_STAT(obj, ITEM_ANTI_NEUTRAL) && !IS_OBJ_STAT(obj, ITEM_ANTI_GOOD))   )
          strcat( buf, "(Flaming Grey) "  );
    if ( ch->class==CLASS_PALADIN
	 && (!IS_OBJ_STAT(obj, ITEM_ANTI_EVIL) && !IS_OBJ_STAT(obj, ITEM_ANTI_NEUTRAL) && IS_OBJ_STAT(obj, ITEM_ANTI_GOOD))   )
          strcat( buf, "(Flaming White) "  );


    if ( ch->class==CLASS_PALADIN
	 && ( IS_OBJ_STAT(obj, ITEM_ANTI_EVIL) && IS_OBJ_STAT(obj, ITEM_ANTI_NEUTRAL) && !IS_OBJ_STAT(obj, ITEM_ANTI_GOOD))   )
          strcat( buf, "(Smouldering Red-Grey) "  );
    if ( ch->class==CLASS_PALADIN
	 && ( IS_OBJ_STAT(obj, ITEM_ANTI_EVIL) && !IS_OBJ_STAT(obj, ITEM_ANTI_NEUTRAL) && IS_OBJ_STAT(obj, ITEM_ANTI_GOOD))   )
          strcat( buf, "(Smouldering Red-White) "  );
    if ( ch->class==CLASS_PALADIN
	 && ( !IS_OBJ_STAT(obj, ITEM_ANTI_EVIL) && IS_OBJ_STAT(obj, ITEM_ANTI_NEUTRAL) && IS_OBJ_STAT(obj, ITEM_ANTI_GOOD))   )
          strcat( buf, "(Smouldering Grey-White) "  );

    if ( IS_AFFECTED(ch, AFF_DETECT_MAGIC)
	 && IS_OBJ_STAT(obj, ITEM_MAGIC)  )   strcat( buf, "(Magical) "   );
    if ( !glowsee && IS_OBJ_STAT(obj, ITEM_GLOW) )   strcat( buf, "(Glowing) "   );
    if ( IS_OBJ_STAT(obj, ITEM_HUM)       )   strcat( buf, "(Humming) "   );
    if ( IS_OBJ_STAT(obj, ITEM_HIDDEN)	  )   strcat( buf, "(Hidden) "	  );
    if ( IS_OBJ_STAT(obj, ITEM_BURIED)	  )   strcat( buf, "(Buried) "	  );
    if ( IS_IMMORTAL(ch)
	 && IS_OBJ_STAT(obj, ITEM_PROTOTYPE) ) strcat( buf, "(PROTO) "	  );
    if ( IS_AFFECTED(ch, AFF_DETECTTRAPS)
	 && is_trapped(obj)   )   strcat( buf, "(Trap) "  );

    if ( fShort )
    {
	if ( glowsee && !IS_IMMORTAL(ch) )
	    strcat( buf, "the faint glow of something" );
	else
	if ( obj->short_descr )
	    strcat( buf, obj->short_descr );
    }
    else
    {
	if ( glowsee )
	    strcat( buf, "You see the faint glow of something nearby." );
	if ( obj->description )
	    strcat( buf, obj->description );
    }

    return buf;
}


Thanks for all the help
USA #10
OK, here's the problem. Note that the other commands are appending to a buffer, but you directly print to the character.


if (  (IS_AFFECTED(ch, AFF_DETECT_EVIL) ||
      ch->class==CLASS_PALADIN)
      && IS_OBJ_STAT(obj, ITEM_EVIL)   )
    strcat( buf, "(Red Aura) "  );

if( !IS_NPC(ch) && IS_IMMORTAL(ch) ) // helpmeiamlost
{
    ch_printf( ch, "&Y(Ovnum %d)", obj->pIndexData->vnum );
}


See what the difference is? ch_printf sends text directly to the character. But what the other parts do is to append to a buffer, that is later sent all at once to the character.
USA #11
Thanks again for all your help didn't realize it was that easy of a fix ...used sprintf instead.

-thank,
Mirrodan

USA #12
Be careful though, sprintf will overwrite the string if you don't keep it - you actually want to concatenate your vnum to the end of the string.