decapmob.txt
snippets · 10.0 KB · 2010-03-30
Decapitation code forward-engineered from Dystopia 1.2 for Devil's Rift MUD.
Download « Back to the snippets list
/****************************************************************************
* *
* The following code was forward engineered from dystopia 1.2 for use on *
* Devil's Rift MUD, based on dystopia 1.4. If you find this useful and are*
* interested in more programs being ported between versions, please contact*
* me at cecilia@darkkeep.net *
* *
*I do ask that if you use this that you'd send me an email to the address *
* above so that I have an idea how many are using the code. *
* *
* Thanks and happy mudding!! *
* *
* - Cecilia *
* *
****************************************************************************/
/****************************************************************************
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. *
* *
* Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* *
* In order to use any part of this Merc Diku Mud, you must comply with *
* both the original Diku license in 'license.doc' as well the Merc *
* license in 'license.txt'. In particular, you may not remove either of *
* these copyright notices. *
* *
* Dystopia Mud improvements copyright (C) 2000, 2001 by Brian Graversen *
* *
* Much time and thought has gone into this software and you are *
* benefitting. We hope that you share your changes too. What goes *
* around, comes around. *
****************************************************************************/
//add this line in your list of special functions at the top of the special.c file
DECLARE_SPEC_FUN( spec_decap );
//this is the actual program. it may look messy at the bottom, but it works
bool spec_decap( CHAR_DATA *ch, char *argument)
{
if (!str_cmp(argument, "update"))
{
CHAR_DATA *vch;
CHAR_DATA *gch;
char buf[MAX_STRING_LENGTH];
OBJ_DATA *object;
OBJ_DATA *obj2;
OBJ_DATA *object_next;
bool found = FALSE;
for (vch = ch->in_room->people; vch && !found; vch = vch->next_in_room)
{
if (vch == ch) continue;
if (number_range(1,2) == 1) continue;
found = TRUE;
gch = vch;
}
if (!found) return FALSE;
if (gch->hit < -5)
{
switch(number_range(1,4))
{
case 1:
behead(gch);
gch->level = 2;
sprintf(buf, "Die, %s, DIE!!!", gch->name);
do_chat(ch, buf);
sprintf(buf,"%s has been decapitated by %s.",gch->name,ch->short_descr);
do_info(ch,buf);
break;
case 2:
behead(gch);
gch->level = 2;
sprintf( buf, "You would have to go and lose your head, now wouldn't you?");
do_chat(ch, buf);
sprintf(buf,"%s has been decapitated by %s.",gch->name,ch->short_descr);
do_info(ch,buf);
break;
case 3:
behead(gch);
gch->level = 2;
sprintf( buf, "Time to die....%s!",gch->name);
do_chat(ch, buf);
sprintf(buf,"%s has been decapitated by %s.",gch->name,ch->short_descr);
do_info(ch,buf);
break;
case 4:
behead(gch);
gch->level = 2;
sprintf( buf, "DIE, FREAK!");
do_chat(ch, buf);
sprintf(buf,"%s has been decapitated by %s.",gch->name,ch->short_descr);
do_info(ch,buf);
break;
}
}
/*wear stuff??*/
for ( object = ch->in_room->contents; object; object = object_next )
{
object_next = object->next_content;
if ( object == NULL )
continue;
if ( !IS_SET( object->wear_flags, ITEM_TAKE ) )
continue;
if ( object->item_type == ITEM_CORPSE_NPC )
continue;
if ( ( object->item_type != ITEM_DRINK_CON
&& object->item_type != ITEM_TRASH )
&&
!(( IS_OBJ_STAT( object, ITEM_ANTI_EVIL ) && IS_EVIL ( ch ) ) ||
( IS_OBJ_STAT( object, ITEM_ANTI_GOOD ) && IS_GOOD ( ch ) ) ||
( IS_OBJ_STAT( object, ITEM_ANTI_NEUTRAL) && IS_NEUTRAL( ch ) ) ) )
{
act( "$n picks up $p and examines it carefully.", ch, object, NULL, TO_ROOM );
obj_from_room( object );
obj_to_char( object, ch );
/*Now compare it to what we already have*/
for ( obj2 = ch->carrying; obj2; obj2 = obj2->next_content )
{
if ( obj2->wear_loc != WEAR_NONE
&& can_see_obj( ch, obj2 )
&& object->item_type == obj2->item_type
&& ( object->wear_flags & obj2->wear_flags & ~ITEM_TAKE) != 0 )
break;
}
if (!obj2)
{
switch (object->item_type)
{
default:
sprintf(buf,"Hey, what a find!");
do_say(ch,buf);
break;
case ITEM_FOOD:
sprintf(buf, "This looks like a tasty morsel!");
do_say(ch,buf);
do_eat(ch,object->name);
break;
case ITEM_WAND:
sprintf(buf,"Wow, a magic wand!");
do_say(ch,buf);
wear_obj(ch,object,FALSE);
break;
case ITEM_STAFF:
sprintf(buf,"Kewl, a magic staff!");
do_say(ch,buf);
wear_obj(ch,object,FALSE);
break;
case ITEM_WEAPON:
sprintf(buf,"Hey, this looks like a nifty weapon!");
do_say(ch,buf);
wear_obj(ch,object,FALSE);
break;
case ITEM_ARMOR:
sprintf(buf,"Oooh...a nice piece of armor!");
do_say(ch,buf);
wear_obj(ch,object,FALSE);
break;/*
case ITEM_POTION:
sprintf(buf, "Great! I was feeling a little thirsty!");
do_say(ch,buf);
act( "You quaff $p.", ch, object, NULL ,TO_CHAR );
act( "$n quaffs $p.", ch, object, NULL, TO_ROOM );
obj_cast_spell( object->value[1], object->level, ch, ch, NULL );
obj_cast_spell( object->value[2], object->level, ch, ch, NULL );
obj_cast_spell( object->value[3], object->level, ch, ch, NULL );
extract_obj( object );
break;
case ITEM_SCROLL:
sprintf(buf,"Hmmm I wonder what this says?");
do_say(ch,buf);
act( "You recite $p.", ch, object, NULL, TO_CHAR );
act( "$n recites $p.", ch, object, NULL, TO_ROOM );
obj_cast_spell( object->value[1], object->level, ch, NULL, object );
obj_cast_spell( object->value[2], object->level, ch, NULL, object );
obj_cast_spell( object->value[3], object->level, ch, NULL, object );
extract_obj( object );
break;*/
}
return TRUE;
}
if ((object->level > obj2->level))
{
sprintf(buf,"Now THIS looks like an improvement!");
do_say(ch,buf);
remove_obj(ch,obj2->wear_loc,TRUE);
wear_obj(ch,object,FALSE);
}
else
{
sprintf(buf,"I don't want this piece of junk!");
do_say(ch,buf);
act("You don't like the look of $p.",ch,object,NULL,TO_CHAR);
do_drop(ch,object->name);
do_sacrifice(ch,object->name);
}
return TRUE;
}
}
return TRUE;
//if (ch->fighting) return FALSE;
}
else if (!str_cmp(argument, "midround"))
{
CHAR_DATA *victim;
char buf[MAX_STRING_LENGTH];
if ((victim = ch->fighting) == NULL)
return FALSE;
if (victim->hit <= -5)
{
sprintf(buf, "What can I do for you today, %s?", victim->name);
do_say(ch, buf);
//raw_kill(victim);
}
}
return FALSE;
}
//put the following line in your special table at the bottom of the file
{ "spec_decap", spec_decap },