save-death.txt
snippets · 6.7 KB · 2010-03-30
Save death: records a player's death state (credit request).
Download « Back to the snippets list
/***************************************************************************
* ALL I ASK FOR MY WORK: *
* 1) Is that you do not remove or modify this comment block. *
* 2) Finally any improvements or snippets you make please forward them *
* to me so we can imcorperate them into the latest version. I will *
* post all snippets with the authors named and credited. *
* *
* Last thank you to all the ROM amd MERC folks for this wounderful code *
* base know as ROM. *
* *
* TAKA *
* a_ghost_dancer@excite.com *
* *
* (C) 2000 TAKA and Ghost Dancer Mud Project *
* *** All rights reserved *
* *
***************************************************************************/
/*
* (c) TAKA 2000 of Ghost Dancer MUD Project
* This snippet allows you to save the number of kills and deaths
* for a player.
*/
in SAVE.C fwrite_char find
fprintf( fp, "Scro %d\n", ch->lines );
add this somewhere after that
fprintf( fp, "Kill %d %d\n", ch->pcdata->kills_mob, ch->pcdata->kills_pc);
fprintf( fp, "Deat %d %d\n", ch->pcdata->deaths_mob, ch->pcdata->deaths_pc);
in load_char_obj find
ch->pcdata->condition[COND_HUNGER] = 48;
add this after that
ch->pcdata->kills_mob = 0;
ch->pcdata->kills_pc = 0;
ch->pcdata->deaths_mob = 0;
ch->pcdata->deaths_pc = 0;
in fread_char find
KEY( "Desc", ch->description, fread_string( fp ) );
add this after
if ( !str_cmp( word, "Deat" ))
{
ch->pcdata->deaths_mob = fread_number( fp );
ch->pcdata->deaths_pc = fread_number( fp );
fMatch = TRUE;
break;
}
also in fread_char find
case 'I':
KEY( "Id", ch->id, fread_number( fp ) );
KEY( "InvisLevel", ch->invis_level, fread_number( fp ) );
KEY( "Inco", ch->incog_level, fread_number( fp ) );
KEY( "Invi", ch->invis_level, fread_number( fp ) );
KEY( "Incr", ch->pcdata->incarnations, fread_number(fp) );
break;
add this after
case 'K':
if ( !str_cmp( word, "Kill" ))
{
ch->pcdata->kills_mob = fread_number( fp );
ch->pcdata->kills_pc = fread_number( fp );
fMatch = TRUE;
break;
}
break;
in MERC.H in struct pc_data find
char * alias_sub[MAX_ALIAS];
add this after
int kills_mob;
int kills_pc;
int deaths_mob;
int deaths_pc;
in FIGHT.C in bool damage find
/*
* Death trigger
*/
if (IS_NPC (victim) && HAS_TRIGGER (victim, TRIG_DEATH)) {
victim->position = POS_STANDING;
mp_percent_trigger (victim, ch, NULL, NULL, TRIG_DEATH);
}
raw_kill (victim);
add this after
/*
* (c) 2000 TAKA of GhostMud and the Ghost Dancer MUD Project
* this adds to the counters for deaths and kills
*/
if (IS_NPC(ch)) /* is a mob */
{
if (!IS_NPC(victim)) /* mob kills character */
victim->pcdata->deaths_mob += 1;
}
else /* is a character */
{
if IS_NPC(victim) /* character kills a mob */
{
ch->pcdata->kills_mob += 1;
}
else /* character kills a pc */
{
victim->pcdata->deaths_pc += 1;
ch->pcdata->kills_pc += 1;
}
}
** optional **
in ACT_WIZ.C in do_mstat
find short description display and add this after that
/*
* TAKA (c) 2000
* kill and death counters display in stat
*/
if (!IS_NPC(victim))
{
sprintf(buf,
"{GMobile deaths/kills {W%5d{G/{W%-5d{x\n\r{GPC deaths/kills {W%5d{G/{W%-5d{x\n\r",
victim->pcdata->deaths_mob, victim->pcdata->kills_mob,
victim->pcdata->deaths_pc, victim->pcdata->kills_pc );
send_to_char(buf,ch);
}
in do_mset
find the syntax listing and add these
send_to_char( " {Gpckill pcdeath mobkill mobdeath{x\n\r", ch );
also near the bottom add these
/*
* TAKA (c) 2000 set kills and deaths
* these should be places somewhere after thirst and hunger
* sets
*/
if ( !str_prefix( arg2, "pckill" ) )
{
if ( IS_NPC( victim ) )
{
send_to_char( "{RNot on NPC's.{x\n\r", ch );
return;
}
if ( !is_number( arg3 ) )
{
send_to_char( "{RValue must be numeric.{x\n\r", ch );
return;
}
value = atoi( arg3 );
if ( value < 0 || value > 30000 )
{
send_to_char( "{RPC Kills value must be 0 to 30,000!{x\n\r", ch );
return;
}
victim->pcdata->kills_pc = value;
return;
}
if ( !str_prefix( arg2, "pcdeaths" ) )
{
if ( IS_NPC( victim ) )
{
send_to_char( "{RNot on NPC's.{x\n\r", ch );
return;
}
if ( !is_number( arg3 ) )
{
send_to_char( "{RValue must be numeric.{x\n\r", ch );
return;
}
value = atoi( arg3 );
if ( value < 0 || value > 30000 )
{
send_to_char( "{RPC Deaths value must be 0 to 30,000!{x\n\r", ch );
return;
}
victim->pcdata->deaths_pc = value;
return;
}
if ( !str_prefix( arg2, "mobkill" ) )
{
if ( IS_NPC( victim ) )
{
send_to_char( "{RNot on NPC's.{x\n\r", ch );
return;
}
if ( !is_number( arg3 ) )
{
send_to_char( "{RValue must be numeric.{x\n\r", ch );
return;
}
value = atoi( arg3 );
if ( value < 0 || value > 30000 )
{
send_to_char( "{RMob Kills value must be 0 to 30,000!{x\n\r", ch );
return;
}
victim->pcdata->kills_mob = value;
return;
}
if ( !str_prefix( arg2, "mobdeaths" ) )
{
if ( IS_NPC( victim ) )
{
send_to_char( "{RNot on NPC's.{x\n\r", ch );
return;
}
if ( !is_number( arg3 ) )
{
send_to_char( "{RValue must be numeric.{x\n\r", ch );
return;
}
value = atoi( arg3 );
if ( value < 0 || value > 30000 )
{
send_to_char( "{RMob Deaths value must be 0 to 30,000!{x\n\r", ch );
return;
}
victim->pcdata->deaths_mob = value;
return;
}
/* end of taka set kills/deaths logic */
Please include in your help file that death and kill counters is a Taka snippet with my
email address of a_ghost_dancer@excite.com
Also please email me and let me know you are using my snippet we now have 30+
muds using snippets and 3 muds running the GhostMud codebase.
I always like to know my code is put to good use and people like it.