Level 51 Member
  
Group: Immortal
Posts: 245
Member No.: 5
Joined: 9-March 06

|
For those of you not in the know, a 'pelt' is a rare item dropped by a monster, which is then given to another monster to convert into a second object. Here's how RD can hardcode it, making the whole process MUCH easier and simpler.
| CODE | In fight.c or RD-equivalent, find the function raw_kill( ch ):
Find THIS LINE: REMOVE_BIT(obj->extra_flags,ITEM_VIS_DEATH);
Directly under it, add THIS:
if (obj->item_type == ITEM_PELT && IS_NPC(ch) && ch->in_room != NULL) act("$n leaves behind a useful body part!",ch,NULL,NULL,TO_ROOM);
In OLC_ACT.c, find the function show_obj_values(): Directly after 'case ITEM_LIGHT:'s whole break statement (Directly before ITEM_WAND) add THIS block:
case ITEM_PELT: sprintf( buf, "[v0] Difficulty: [%d]\n\r" "[v1] Result Vnum: [%d]\n\r", obj->value[0], obj->value[1]); send_to_char( buf, ch ); break;
In set_obj_values(), find case ITEM_WAND: and add this directly after it:
case ITEM_PELT: switch ( value_num ) { default: do_help( ch, "ITEM_PELT" ); return FALSE; case 0: send_to_char( "PELT DIFFICULTY SET.\n\r\n\r", ch ); pObj->value[2] = atoi( argument ); break; case 1: send_to_char( "RESULTING OBJECT SET.\n\r\n\r", ch ); pObj->value[2] = atoi( argument ); break; } break;
In MERC.H, find '#define ITEM_LIGHT 1' and add this to the bottom: #define ITEM_PELT <last ## plus one>
Also add this somewhere: #define VNUM_MOB_PELTMASTER 3011 (this is Tetragon, obviously might want to use a different vnum)
In CONST.C (or wherever it is) find item_type item_table [] =, and just before the NULL entry add this:
{ ITEM_PELT, "pelt" },
In TABLES.C or wherever your 'type_flags[] = ' table is, add this to the bottom:
{ "pelt", ITEM_PELT, TRUE },
And finally, find the do_give() function, it should be in act_obj. Head down to the very bottom of it and find ' mp_give_trigger( victim, ch, obj );' Just after that (before the return) add this:
/* First, check if it's the peltmaster */ if (IS_NPC(victim) && victim->pIndexData->vnum == VNUM_MOB_PELTMASTER) { OBJ_DATA *result; /* First, error checking, initialize our pelt results */ if ((result = get_obj_index(obj->value[1])) == NULL || obj->item_type != ITEM_PELT) { act("$N refuses to take that item from you.",ch,NULL,victim,TO_CHAR); obj_from_char( obj ); obj_to_char( obj, ch ); return; } /* Ut oh, no cheating! */ if (obj->pIndexData->area->security < 9) { send_to_char("$N does not accept pelts from unfinished areas. $e eats it. Burp!",ch,NULL,victim,TO_CHAR); extract_obj( obj ); return; } /* First, random value, v0 %-based */ act("$n begins to carefully work on $p!",victim,obj,NULL,TO_ROOM); if (obj->value[0] < number_percent()) { /* Failed! Destroy the pelt, no reward */ act("$n {rbotches{x the craft and $p is ruined!", victim, obj, NULL ,TO_ROOM); do_say(victim,"Woops, sorry about that. Find me another one."); extract_obj( obj ); return; }
/* Woo! Make the results, eat the pelt, give result to them */ create_object( result, result->level ); act("Success!! $n manages to create $p!",victim,result,NULL, TO_ROOM); do_say(victim,"Here you go."); extract_obj ( obj ); obj_to_char(result, ch); act( "$n gives $p to $N.", victim, result, ch, TO_NOTVICT ); act( "$n gives you $p.", victim, result, ch, TO_VICT ); act( "You give $p to $N.", victim, result, ch, TO_CHAR ); return; }
Note: 'do_say' might have to be redefined if it's not a global function. easiest way is to pluck its declaration from act_comm.c and stick it in merc.h.
|
Okay, let's go over a few things.
Here's how the pelts would work-- a builder puts the pelt item in their area, with a low respawn % rate, no more than 10% or so (but usually something like 1% or 2%). ALL pelts should be set vis_death, so they will appear only when the mob dies and cannot be located. The v0 of the pelt item is the % chance that the craftsman will destroy it, while the v1 is the resulting object vnum. When the mob dies and was carrying a pelt, everyone in the room gets a special message and they can pick it up and do whatever with it, just like a normal item. You can even set them wearable and put stats and stuff on them if you wanted to.
The v1 can be set to -any- object in the game, regardless of what area it's from. Thus it's a good idea to make sure people don't tinker with the pelt items after their areas are imped.
|