use.txt
snippets · 2.5 KB · 2010-03-30
Use snippet: item type use (const.c changes).
Download « Back to the snippets list
/* I do not require any type of credits */
/*---Const.c---*/
/* Add the following to the ::item type list:: */
{ ITEM_SOURCE, "source" },
/*---Handler.c---*/
/* Add the following to the ::*item_type_name:: */
case ITEM_SOURCE: return "source";
/*---Merc.h---*/
/* Add by all the other ITEM_TYPES */
#define ITEM_SOURCE 41
/*---OLC_ACT.C---*/
/* Add to show_obj_values */
case ITEM_SOURCE:
sprintf( buf,
"[v0] to hp: [%d]\n\r"
"[v1] to mn: [%d]\n\r"
"[v2] to mv: [%d]\n\r",
obj->value[0],
obj->value[1],
obj->value[2] );
send_to_char( buf,ch );
break;
/* And Add this to set_obj_values */
case ITEM_SOURCE:
switch ( value_num )
{
default:
do_help( ch, "ITEM_SOURCE" );
return FALSE;
case 0:
send_to_char( "HP modifier SET.\n\r\n\r", ch );
pObj->value[0] = atoi( argument );
break;
case 1:
send_to_char( "MN modifier SET.\n\r\n\r", ch );
pObj->value[1] = atoi( argument );
break;
case 2:
send_to_char( "MV modifier SET.\n\r\n\r", ch );
pObj->value[2] = atoi( argument );
break;
}
break;
/*---Tables.c---*/
/* add this to the item_type table */
{ "source", ITEM_SOURCE, TRUE },
/*--------------------CUT HERE FOR SOURCE.C--------------------*/
#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "merc.h"
#include "magic.h"
#include "recycle.h"
void do_use( CHAR_DATA *ch, char *argument )
{
char arg[MAX_STRING_LENGTH];
char buf[MAX_STRING_LENGTH];
OBJ_DATA *obj;
int to_hp;
int to_mn;
int to_mv;
argument = one_argument( argument, arg );
if ( ( arg == '\0' ) )
{
send_to_char( "Syntax: use (item)\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 ( obj->item_type != ITEM_SOURCE )
{
send_to_char( "That isn't a source.\n\r", ch );
return;
}
to_hp = obj->value[0];
to_mn = obj->value[1];
to_mv = obj->value[2];
ch->max_hit = ( to_hp + ch->max_hit );
ch->max_mana = ( to_mn + ch->max_mana );
ch->max_move = ( to_mv + ch->max_move );
sprintf( buf, "%s brightly glows green and disappears.\n\r", obj->short_descr );
send_to_char( buf, ch );
extract_obj( obj );
}