Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Making a Corpse

Making a Corpse

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Gregar   (20 posts)  Bio
Date Thu 04 Mar 2004 10:09 PM (UTC)
Message
Hi everyone,

I added some code to create a random amount of gold on an NPC corpse. The function works fine, except that as a result, it no longer creates a player corpse. The player wakes up in our infirmary, however there is no player corpse anywhere. Attached is the code, if someone can point out where the problem is, I would appreciate it.


void make_corpse( CHAR_DATA *ch, CHAR_DATA *killer ) 
{   
    char buf[MAX_STRING_LENGTH];
    OBJ_DATA *corpse;
    OBJ_DATA *obj;
    OBJ_DATA *obj_next;
    ROOM_INDEX_DATA *location;
    char *name;


    if ( IS_NPC(ch) )
    {
	name		= ch->short_descr;
	corpse		= create_object(get_obj_index(OBJ_VNUM_CORPSE_NPC), 0);
	corpse->timer	= 6;
	if ( ch->gold <= 0 )
	{
	    if ( ch->in_room )
	    {
	      ch->in_room->area->gold_looted += ch->gold;
	      sysdata.global_looted += ch->gold/100;
	    }
	    obj_to_obj( create_money( ch->gold ), corpse );
	    ch->gold = 0;
	}
	else if( ch->gold > 0 && !IS_NPC( killer ) )
	   {
        int tchance;
        int level = corpse->level;

        tchance = number_range( 1, 100 );

         if( tchance <= 20 ) 
           {
	         if( !str_cmp( corpse->name, "corpse random" ) )
	         log_string( "Generated nothing" );
	        return;
            }  

         else if( tchance <= 100 )
          {
	       int x, gold;

	       if( level <= 10 )
	           x = 30;
	       else if( level <= 15 )
	           x = 40;
	       else if( level <= 20 )
	           x = 60;
	       else if( level <= 25 )
	           x = 90;
	       else if( level <= 30 )
	           x = 150;
	       else if( level <= 35 )
	           x = 170;
	       else if( level <= 40 )
	           x = 200;
	       else if( level <= 45 )
	          x = 300;
	       else if( level <= 50 )
	          x = 400;
	       else
	          x = 500;

	gold = ( dice( level, x ) + ( dice( level, x / 10 ) + dice( get_curr_lck( ch ), x / 3 ) ) );
	gold = gold + ( gold * ( ch->gold / 100 ) );
	obj_to_obj( create_money( gold ), corpse ); 
   }

	corpse->cost     = (-(int)ch->pIndexData->vnum);
        corpse->value[2] = corpse->timer;
    } 
    else
    {
	name		= ch->name;
	corpse		= create_object(get_obj_index(OBJ_VNUM_CORPSE_PC), 0); 
	corpse->timer = 40;
      corpse->value[2] = (int)(corpse->timer/8);
	corpse->value[4] = ch->level;
    location = get_room_index ( ROOM_VNUM_MORGUE ); 

	if ( CAN_PKILL( ch ) && sysdata.pk_loot )
	  xSET_BIT( corpse->extra_flags, ITEM_CLANCORPSE );
	  
	if ( !IS_NPC(ch) && !IS_NPC(killer) )
	  corpse->value[3] = 1;
	else
	  corpse->value[3] = 0;
    }

    if ( CAN_PKILL( ch ) && CAN_PKILL( killer ) && ch != killer )
    {
	sprintf( buf, "%s", killer->name );
	STRFREE( corpse->action_desc );
	corpse->action_desc = STRALLOC( buf );
    } 

    sprintf( buf, "corpse %s", name );
    STRFREE( corpse->name );
    corpse->name = STRALLOC( buf );

    sprintf( buf, corpse->short_descr, name );
    STRFREE( corpse->short_descr );
    corpse->short_descr = STRALLOC( buf );

    sprintf( buf, corpse->description, name );
    STRFREE( corpse->description );
    corpse->description = STRALLOC( buf );
 
    for ( obj = ch->first_carrying; obj; obj = obj_next )
    {
	obj_next = obj->next_content;
	obj_from_char( obj );
	if ( IS_OBJ_STAT( obj, ITEM_INVENTORY )
	  || IS_OBJ_STAT( obj, ITEM_DEATHROT ) )
	    extract_obj( obj );
	else
        obj_to_obj( obj, corpse );
    }
    if (IS_NPC(ch))
        obj_to_room( corpse, ch->in_room ); 
	else
        obj_to_room ( corpse, location );   
    return;
}  
} 
Top

Posted by Gregar   (20 posts)  Bio
Date Reply #1 on Fri 05 Mar 2004 08:32 AM (UTC)
Message
Duh.

Is an open bracket in there, once closed it works fine.
Feel free to use it if you want to, is a great addition.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


10,406 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.