weapon-sock.txt
snippets · 3.4 KB · 2010-03-30
Weapon sockets: insert sockets into weapons that add hitroll or damroll.
Download « Back to the snippets list
/*
* This snippet allows for you to insert "sockets" into weapons. The sockets
* will add HITROLL or DAMROLL. This snippet was made up by me (IceCool) and Tornach.
* All we ask is you give us some credit and email any bugs or fixes you might find.
* sprintf( buf1, "{G[{W*{G]{x %s", obj2->short_descr );
* obj2->short_descr = buf1;
* This spot we found something wrong because after you save the object will take on
* anything for a short description. Other wise we haven't found anything else wrong.
*/
void do_newforge( CHAR_DATA *ch, char *argument )
{
char arg[MAX_STRING_LENGTH];
char arg2[MAX_STRING_LENGTH];
char buf1[MAX_STRING_LENGTH];
OBJ_DATA *obj;
OBJ_DATA *obj2;
char buf2[MAX_STRING_LENGTH];
AFFECT_DATA *pAf;
int to_hit;
int to_dam;
argument = one_argument( argument, arg );
argument = one_argument( argument, arg2 );
if ( ( arg == '\0' ) || ( arg2 == '\0' ) )
{
send_to_char( "Syntax: forge (item) (weapon)\n\r", ch );
return;
}
if ( ( obj = get_obj_carry( ch, arg ) ) == NULL )
{
send_to_char( "You do not have that item.\n\r", ch );
return;
}
if ( ( obj2 = get_obj_carry( ch, arg2 ) ) == NULL )
{
send_to_char( "You do not have that item.\n\r", ch );
return;
}
if ( obj->item_type != ITEM_SOCKET )
{
send_to_char( "That isn't a socket.\n\r", ch );
return;
}
if ( obj2->item_type != ITEM_WEAPON )
{
send_to_char( "That is not a weapon!\n\r", ch );
return;
}
to_hit = obj->value[0];
to_dam = obj->value[1];
extract_obj( obj );
if ( to_hit != 0 )
{
pAf = new_affect();
pAf->location = APPLY_HITROLL;
pAf->modifier = to_hit;
pAf->where = TO_OBJECT;
pAf->type = 0;
pAf->duration = -1;
pAf->bitvector = 0;
pAf->level = obj2->level;
pAf->next = obj2->affected;
obj2->affected = pAf;
/* affect_to_obj (obj2, pAf); */
}
if ( to_dam != 0 )
{
pAf = new_affect();
pAf->location = APPLY_DAMROLL;
pAf->modifier = to_dam;
pAf->where = TO_OBJECT;
pAf->type = 0;
pAf->duration = -1;
pAf->bitvector = 0;
pAf->level = obj2->level;
pAf->next = obj2->affected;
obj2->affected = pAf;
/* affect_to_obj (obj2, pAf); */
}
sprintf( buf1, "{G[{W*{G]{x %s", obj2->short_descr );
obj2->short_descr = buf1;
free_string( buf1 );
send_to_char( "You have inserted the socket into your weapon, it glows and humms for an instant and now seems much more powerful.\n\r", ch);
return;
}
add the following case to show_object_values ( olc_act.c ) :
case ITEM_SOCKET:
sprintf( buf,
"{G[{Yv0{G]{R to hit: {W[{C%d{W]{x\n\r"
"{G[{Yv1{G]{R to dam: {W[{C%d{W]{x\n\r",
obj->value[0],
obj->value[1] );
send_to_char( buf,ch );
break;
add the following case to set_object_values ( olc_act.c ) :
case ITEM_SOCKET:
switch ( value_num )
{
default:
do_help( ch, "ITEM_SOCKET" );
return FALSE;
case 0:
send_to_char( "HIT modifier SET.\n\r\n\r", ch );
pObj->value[0] = atoi( argument );
break;
case 1:
send_to_char( "DAM modifier SET.\n\r\n\r", ch );
pObj->value[1] = atoi( argument );
break;
}
break;
there might be some more i'm forgetting too, but try this.