tired.txt.1
snippets · 5.8 KB · 2010-03-30
Tired (second copy of the tired/rest system).
Download « Back to the snippets list
/*\
* Tired.txt Written by Steve Bretzke (ammoski@aol.com) and Jef Waite
* (secondary-weapon check) for Adventures Unlimited.
* The idea was first seen by the author on Aeon mud (no longer exists).
* This code makes PC's fall asleep on their feet if they go too long
* without normal sleep. Players that are too tired will drop their weapon,
* and secondary weapon (if your code supports this) or held item. Recovery
* rate for sleep will have to be set by you. I have it based on current con,
* the same for the rate at which the player gets tired. Anyhow, if you use,
* please drop me a mail and let me know. If you make a help file for this
* a mention in the code would be nice but not necessary. Read it THOROUGHLY
* before you add it. If you don't understand it, don't add it. Updated
* June 2001 for ROM 2.4b6. Remove references to secondary if your code does
* not support secondary weapons.
\*/
/*** In merc.h ***/
Add this with the rest of the conditions:
#define COND_TIRED 4
/*** In update.c add these lines ***/
/*** In gain_condition after case COND_DRUNK ***/
case COND_TIRED:
if ( condition != 0 )
send_to_char( "You are getting {mtired{x.\n\r", ch);
break;
/*** In char_update ***/
At the top of the function add:
OBJ_DATA *wield;
OBJ_DATA *secondary;
OBJ_DATA *hold;
Right after the if ( ++ch->timer >= 12 ), send-character-to-the-void stuff
add:
if ( !IS_NPC(ch) && ch->position > POS_SLEEPING
&& ch->pcdata->condition[COND_TIRED] == 0
&& ch->timer < 12 && ch->desc ) /*so they don't lose stuff in the void*/
{
wield = get_eq_char( ch, WEAR_WIELD );
secondary = get_eq_char( ch, WEAR_SECONDARY );
hold = get_eq_char( ch, WEAR_HOLD );
act( "{w$n is sleeping on $s feet!{x",ch,NULL,NULL,TO_ROOM);
if ( wield )
{
act( "{w$p {wclatters to the ground.",ch,wield,NULL,TO_ROOM );
send_to_char( "{wSomething clatters to the ground waking you.{x\n\r", ch );
obj_from_char( wield );
obj_to_room( wield, ch->in_room );
}
if( secondary && !wield )
{
act( "{w$p {wclatters to the ground.",ch,secondary,NULL,TO_ROOM );
send_to_char( "{wSomething clatters to the ground waking you.{x\n\r", ch );
obj_from_char( secondary );
obj_to_room( secondary, ch->in_room );
}
if( hold && !wield && !secondary )
{
act( "{w$p {wclatters to the ground.",ch,hold,NULL,TO_ROOM );
send_to_char( "{wSomething clatters to the ground waking you.{x\n\r", ch );
obj_from_char( hold );
obj_to_room( hold, ch->in_room );
}
}
After
gain_condition( ch, COND_DRUNK, -1 );
gain_condition( ch, COND_FULL, ch->size > SIZE_MEDIUM ? -4 : -2 );
gain_condition( ch, COND_THIRST, -1 );
gain_condition( ch, COND_HUNGER, ch->size > SIZE_MEDIUM ? -2 : -1);
Add:
if ( !IS_NPC(ch) && !IS_IMMORTAL(ch) )
{
if ( ch->position == POS_RESTING )
gain_condition( ch, COND_TIRED, 0 );
else if (ch->position == POS_SLEEPING )
gain_condition( ch, COND_TIRED,
get_curr_stat(ch,STAT_CON) / 2 );
else
gain_condition( ch, COND_TIRED,
get_curr_stat(ch,STAT_CON) > 19 ? -1 : -2 );
}
/*** That's all for update.c ***/
/*** act_info.c ***/
At the top of the do_score function add:
int percent; <--only if you don't already have this there
/*** In act_info.c under do_score add these lines under the thirsty message ***/
if ( ch->pcdata->condition[COND_TIRED] > 0 )
percent = ( 100 * ch->pcdata->condition[COND_TIRED] / 48 );
else
percent = -1;
if ( percent >= 90 )
send_to_char( "You are well rested.\n\r", ch );
else if ( percent >= 75 )
send_to_char( "You feel rested.\n\r", ch );
else if ( percent >= 50 )
send_to_char( "You are a bit tired.\n\r", ch );
else if ( percent >= 25 )
send_to_char( "You feel fatigued.\n\r", ch );
else if ( percent >= 7 )
send_to_char( "You are tired.\n\r", ch );
else
send_to_char( "You are asleep on your feet!\n\r", ch );
/*** act_wiz.c ***/
Change this in do_mstat:
if ( !IS_NPC(victim) )
{
sprintf( buf,
"Thirst: %d Hunger: %d Full: %d Drunk: %d Tired: %d\n\r", <--added tired
victim->pcdata->condition[COND_THIRST],
victim->pcdata->condition[COND_HUNGER],
victim->pcdata->condition[COND_FULL],
victim->pcdata->condition[COND_DRUNK],
+ victim->pcdata->condition[COND_TIRED] );
send_to_char( buf, ch );
}
In do_restore:
Add tired updates for the three restore types.
In do_mset add this after the cond_hunger stuff:
if ( !str_prefix( arg2, "tired" ) )
{
if ( IS_NPC(victim) )
{
send_to_char( "Not on NPC's.\n\r", ch );
return;
}
if ( value < -1 || value > 48 )
{
send_to_char( "Tired range is -1 to 48.\n\r", ch );
return;
}
victim->pcdata->condition[COND_TIRED] = value;
return;
}
/*** In save.c ***/
Under load_char_obj add this:
ch->pcdata->condition[COND_THIRST] = 48;
ch->pcdata->condition[COND_FULL] = 48;
ch->pcdata->condition[COND_HUNGER] = 48;
+ ch->pcdata->condition[COND_TIRED] = 48;
Also, where it reads and writes under Cnd, add appropriate lines.
i.e. ch->pcdata->condition[4];
That should do it for the snippet. I also made the refresh spell add
a couple points to the tired condition too. Hope you enjoy.
/*** END ***/