void do_unalias(CHAR_DATA *ch, char *argument) { CHAR_DATA *rch; char arg[MAX_INPUT_LENGTH]; int pos; bool found = FALSE; if (ch->desc == NULL) rch = ch; else rch = ch->desc->original ? ch->desc->original : ch; if (IS_NPC(rch)) return; argument = one_argument(argument,arg); if (arg[0] == '\0') { send_to_char("Unalias what?\n\r",ch); return; } for (pos = 0; pos < MAX_ALIAS; pos++) { if (rch->pcdata->alias[pos] == NULL) break; if (found) { rch->pcdata->alias[pos-1] = rch->pcdata->alias[pos]; rch->pcdata->alias_sub[pos-1] = rch->pcdata->alias_sub[pos]; rch->pcdata->alias[pos] = NULL; rch->pcdata->alias_sub[pos] = NULL; continue; } if(!strcmp(arg,rch->pcdata->alias[pos])) { send_to_char("Alias removed.\n\r",ch); PURGE_DATA(rch->pcdata->alias[pos]); PURGE_DATA(rch->pcdata->alias_sub[pos]); rch->pcdata->alias[pos] = NULL; rch->pcdata->alias_sub[pos] = NULL; found = TRUE; } } if (!found) send_to_char("No alias of that name to remove.\n\r",ch); }
void death_cry( CHAR_DATA *ch ) { ROOM_INDEX_DATA *was_in_room; char *msg; int door; int vnum; vnum = 0; msg = NULL; while(msg == NULL) switch ( number_bits(4)) { case 0: msg = "$n hits the ground ... DEAD."; break; case 1: if (ch->material == 0) { msg = "$n splatters blood on your clothes."; break; } case 2: if (IS_SET(ch->parts,PART_GUTS)) { msg = "$n spills $s guts all over the floor."; vnum = OBJ_VNUM_GUTS; } break; case 3: if (IS_SET(ch->parts,PART_HEAD)) { msg = "$n's severed head plops on the ground."; vnum = OBJ_VNUM_SEVERED_HEAD; } break; case 4: if (IS_SET(ch->parts,PART_HEART)) { msg = "$n's heart is torn from $s chest."; vnum = OBJ_VNUM_TORN_HEART; } break; case 5: if (IS_SET(ch->parts,PART_ARMS)) { msg = "$n's arm is sliced from $s dead body."; vnum = OBJ_VNUM_SLICED_ARM; } break; case 6: if (IS_SET(ch->parts,PART_LEGS)) { msg = "$n's leg is sliced from $s dead body."; vnum = OBJ_VNUM_SLICED_LEG; } break; case 7: if (IS_SET(ch->parts,PART_BRAINS)) { msg = "$n's head is shattered, and $s brains splash all over you."; vnum = OBJ_VNUM_BRAINS; } } act( msg, ch, NULL, NULL, TO_ROOM, 0 ); if ( vnum != 0 ) { char buf[MSL]={'\0'}; OBJ_DATA *obj; char *name; name = IS_NPC(ch) ? ch->short_descr : ch->name; obj = create_object( get_obj_index( vnum ) ); obj->timer = number_range( 4, 7 ); snprintf( buf, sizeof(buf), obj->short_descr, name ); PURGE_DATA( obj->short_descr ); obj->short_descr = str_dup( buf ); snprintf( buf, sizeof(buf), obj->description, name ); PURGE_DATA( obj->description ); obj->description = str_dup( buf ); if (obj->item_type == ITEM_FOOD) { if (IS_SET(ch->form,FORM_POISON)) obj->value[3] = 1; else if (!IS_SET(ch->form,FORM_EDIBLE)) obj->item_type = ITEM_TRASH; } if(!str_cmp(ch->material, "flesh") && !str_cmp(ch->material, "none") && (material_lookup(ch->material) != material_lookup("unknown"))) { PURGE_DATA( obj->material ); obj->material = str_dup(ch->material); } if(IS_SET(ch->act, ACT_UMBRA)) obj_to_plane(obj, 1); if(IS_SET(ch->act, ACT_DREAMING)) obj_to_plane(obj, 2); obj_to_room( obj, ch->in_room ); } was_in_room = ch->in_room; for ( door = 0; door <= 5; door++ ) { EXIT_DATA *pexit; if ( ( pexit = was_in_room->exit[door] ) != NULL && pexit->u1.to_room != NULL && pexit->u1.to_room != was_in_room ) { ch->in_room = pexit->u1.to_room; act( msg, ch, NULL, NULL, TO_ROOM, 0 ); } } ch->in_room = was_in_room; return; }
/* * Make a corpse out of a character. */ void make_corpse( CHAR_DATA *ch ) { char buf[MSL]={'\0'}; OBJ_DATA *corpse; OBJ_DATA *obj; OBJ_DATA *obj_next; char *name; if ( IS_NPC(ch) ) { name = ch->short_descr; corpse = create_object(get_obj_index(OBJ_VNUM_CORPSE_NPC)); corpse->timer = number_range( 3, 6 ); if ( ch->dollars > 0 ) { obj_to_obj( create_money( ch->dollars, ch->cents ), corpse ); ch->cents = 0; ch->dollars = 0; } corpse->cost = 0; } else { name = ch->name; corpse = create_object(get_obj_index(OBJ_VNUM_CORPSE_PC)); corpse->timer = number_range( 25, 40 ); corpse->owner = NULL; if (ch->dollars > 1 || ch->cents > 1) { obj_to_obj(create_money(ch->dollars / 2, ch->cents/2), corpse); ch->cents = 0; ch->dollars = 0; } corpse->cost = 0; } snprintf( buf, sizeof(buf), corpse->short_descr, name ); PURGE_DATA( corpse->short_descr ); corpse->short_descr = str_dup( buf ); snprintf( buf, sizeof(buf), corpse->description, name ); PURGE_DATA( corpse->description ); corpse->description = str_dup( buf ); PURGE_DATA( corpse->full_desc ); corpse->full_desc = str_dup( Format("The corpse of someone who in life looked like:\n\r%s", ch->description) ); if(!str_cmp(ch->material, "flesh") && !str_cmp(ch->material, "none") && (material_lookup(ch->material) != material_lookup("unknown"))) { PURGE_DATA( corpse->material ); corpse->material = str_dup(ch->material); } for ( obj = ch->carrying; obj != NULL; obj = obj_next ) { obj_next = obj->next_content; obj_from_char( obj ); if (obj->item_type == ITEM_POTION) obj->timer = number_range(500,1000); if (obj->item_type == ITEM_SCROLL) obj->timer = number_range(1000,2500); if (IS_SET(obj->extra_flags,ITEM_ROT_DEATH)) { obj->timer = number_range(1,3); REMOVE_BIT(obj->extra_flags,ITEM_ROT_DEATH); } REMOVE_BIT(obj->extra_flags,ITEM_VIS_DEATH); if(obj != NULL) { if(IS_SET(ch->act, ACT_UMBRA)) obj_to_plane(obj, 1); if(IS_SET(ch->act, ACT_DREAMING)) obj_to_plane(obj, 2); } obj_to_obj( obj, corpse ); } if(IS_SET(ch->act, ACT_UMBRA)) obj_to_plane(corpse, 1); if(IS_SET(ch->act, ACT_DREAMING)) obj_to_plane(corpse, 2); obj_to_room( corpse, ch->in_room ); return; }
void note_remove( CHAR_DATA *ch, NOTE_DATA *pnote, bool idelete) { char to_new[MAX_INPUT_LENGTH]; char to_one[MAX_INPUT_LENGTH]; NOTE_DATA *prev; NOTE_DATA **list; char *to_list; if (!idelete) { /* make a new list */ to_new[0] = '\0'; to_list = pnote->to_list; while ( *to_list != '\0' ) { to_list = one_argument( to_list, to_one ); if ( to_one[0] != '\0' && str_cmp( ch->name, to_one ) ) { strcat( to_new, " " ); strcat( to_new, to_one ); } } /* Just a simple recipient removal? */ if ( str_cmp( ch->name, pnote->sender ) && to_new[0] != '\0' ) { PURGE_DATA( pnote->to_list ); pnote->to_list = str_dup( to_new + 1 ); return; } } /* nuke the whole note */ switch(pnote->type) { default: return; case NOTE_NOTE: list = ¬e_list; break; case NOTE_IDEA: list = &idea_list; break; case NOTE_PENALTY: list = &penalty_list; break; case NOTE_NEWS: list = &news_list; break; case NOTE_CHANGES: list = &changes_list; break; } /* * Remove note from linked list. */ if ( pnote == *list ) { *list = pnote->next; } else { for ( prev = *list; prev != NULL; prev = prev->next ) { if ( prev->next == pnote ) break; } if ( prev == NULL ) { bug( "Note_remove: pnote not found.", 0 ); return; } prev->next = pnote->next; } save_notes(pnote->type); free_note(pnote); return; }
void do_alias(CHAR_DATA *ch, char *argument) { CHAR_DATA *rch; char arg[MAX_INPUT_LENGTH]; int pos; smash_tilde(argument); if (ch->desc == NULL) rch = ch; else rch = ch->desc->original ? ch->desc->original : ch; if (IS_NPC(rch)) return; argument = one_argument(argument,arg); if (arg[0] == '\0') { if (rch->pcdata->alias[0] == NULL) { send_to_char("You have no aliases defined.\n\r",ch); return; } send_to_char("Your current aliases are:\n\r",ch); for (pos = 0; pos < MAX_ALIAS; pos++) { if (rch->pcdata->alias[pos] == NULL || rch->pcdata->alias_sub[pos] == NULL) break; send_to_char( Format(" %s: %s\n\r",rch->pcdata->alias[pos], rch->pcdata->alias_sub[pos]), ch); } return; } if (!str_prefix("una",arg) || !str_cmp("alias",arg)) { send_to_char("Sorry, that word is reserved.\n\r",ch); return; } if (argument[0] == '\0') { for (pos = 0; pos < MAX_ALIAS; pos++) { if (rch->pcdata->alias[pos] == NULL || rch->pcdata->alias_sub[pos] == NULL) break; if (!str_cmp(arg,rch->pcdata->alias[pos])) { send_to_char( Format("%s aliases to '%s'.\n\r",rch->pcdata->alias[pos], rch->pcdata->alias_sub[pos]), ch); return; } } send_to_char("That alias is not defined.\n\r",ch); return; } if (!str_prefix(argument,"delete") || !str_prefix(argument,"prefix")) { send_to_char("That shall not be done!\n\r",ch); return; } for (pos = 0; pos < MAX_ALIAS; pos++) { if (rch->pcdata->alias[pos] == NULL) break; if (!str_cmp(arg,rch->pcdata->alias[pos])) /* redefine an alias */ { PURGE_DATA(rch->pcdata->alias_sub[pos]); rch->pcdata->alias_sub[pos] = str_dup(argument); send_to_char( Format("%s is now realiased to '%s'.\n\r",arg,argument), ch); return; } } if (pos >= MAX_ALIAS) { send_to_char("Sorry, you have reached the alias limit.\n\r",ch); return; } /* make a new alias */ rch->pcdata->alias[pos] = str_dup(arg); rch->pcdata->alias_sub[pos] = str_dup(argument); send_to_char( Format("%s is now aliased to '%s'.\n\r",arg,argument), ch); }
void parse_note ( Creature *ch, const char *argument, int type ) { BUFFER *buffer; char buf[MAX_STRING_LENGTH]; char arg[MAX_INPUT_LENGTH]; NOTE_DATA *pnote; NOTE_DATA **list; const char *list_name; int vnum; int anum; if ( IS_NPC ( ch ) ) { return; } switch ( type ) { default: return; case NOTE_NOTE: list = ¬e_list; list_name = "notes"; break; case NOTE_IDEA: list = &idea_list; list_name = "ideas"; break; case NOTE_PENALTY: list = &penalty_list; list_name = "penalties"; break; case NOTE_NEWS: list = &news_list; list_name = "news"; break; case NOTE_CHANGES: list = &changes_list; list_name = "changes"; break; } argument = ChopC ( argument, arg ); smash_tilde ( argument ); if ( arg[0] == '\0' || !str_prefix ( arg, "read" ) ) { bool fAll; if ( SameString ( argument, "all" ) ) { fAll = TRUE; anum = 0; } else if ( argument[0] == '\0' || !str_prefix ( argument, "next" ) ) /* read next unread note */ { vnum = 0; for ( pnote = *list; pnote != NULL; pnote = pnote->next ) { if ( !hide_note ( ch, pnote ) ) { sprintf ( buf, "[%3d] %s: %s\n\r%s\n\rTo: %s\n\r", vnum, pnote->sender, pnote->subject, pnote->date, pnote->to_list ); writeBuffer ( buf, ch ); writePage ( pnote->text, ch ); update_read ( ch, pnote ); return; } else if ( is_note_to ( ch, pnote ) ) { vnum++; } } snprintf ( buf, sizeof ( buf ), "You have no unread %s.\n\r", list_name ); writeBuffer ( buf, ch ); return; } else if ( is_number ( argument ) ) { fAll = FALSE; anum = atoi ( argument ); } else { writeBuffer ( "Read which number?\n\r", ch ); return; } vnum = 0; for ( pnote = *list; pnote != NULL; pnote = pnote->next ) { if ( is_note_to ( ch, pnote ) && ( vnum++ == anum || fAll ) ) { sprintf ( buf, "[%3d] %s: %s\n\r%s\n\rTo: %s\n\r", vnum - 1, pnote->sender, pnote->subject, pnote->date, pnote->to_list ); writeBuffer ( buf, ch ); writePage ( pnote->text, ch ); update_read ( ch, pnote ); return; } } snprintf ( buf, sizeof ( buf ), "There aren't that many %s.\n\r", list_name ); writeBuffer ( buf, ch ); return; } if ( !str_prefix ( arg, "list" ) ) { vnum = 0; for ( pnote = *list; pnote != NULL; pnote = pnote->next ) { if ( is_note_to ( ch, pnote ) ) { sprintf ( buf, "[%3d%s] %s: %s\n\r", vnum, hide_note ( ch, pnote ) ? " " : "N", pnote->sender, pnote->subject ); writeBuffer ( buf, ch ); vnum++; } } if ( !vnum ) { switch ( type ) { case NOTE_NOTE: writeBuffer ( "There are no notes for you.\n\r", ch ); break; case NOTE_IDEA: writeBuffer ( "There are no ideas for you.\n\r", ch ); break; case NOTE_PENALTY: writeBuffer ( "There are no penalties for you.\n\r", ch ); break; case NOTE_NEWS: writeBuffer ( "There is no news for you.\n\r", ch ); break; case NOTE_CHANGES: writeBuffer ( "There are no changes for you.\n\r", ch ); break; } } return; } if ( !str_prefix ( arg, "remove" ) ) { if ( !is_number ( argument ) ) { writeBuffer ( "Note remove which number?\n\r", ch ); return; } anum = atoi ( argument ); vnum = 0; for ( pnote = *list; pnote != NULL; pnote = pnote->next ) { if ( is_note_to ( ch, pnote ) && vnum++ == anum ) { note_remove ( ch, pnote, FALSE ); writeBuffer ( "Ok.\n\r", ch ); return; } } snprintf ( buf, sizeof ( buf ), "There aren't that many %s.", list_name ); writeBuffer ( buf, ch ); return; } if ( !str_prefix ( arg, "delete" ) && get_trust ( ch ) >= MAX_LEVEL - 1 ) { if ( !is_number ( argument ) ) { writeBuffer ( "Note delete which number?\n\r", ch ); return; } anum = atoi ( argument ); vnum = 0; for ( pnote = *list; pnote != NULL; pnote = pnote->next ) { if ( is_note_to ( ch, pnote ) && vnum++ == anum ) { note_remove ( ch, pnote, TRUE ); writeBuffer ( "Ok.\n\r", ch ); return; } } snprintf ( buf, sizeof ( buf ), "There aren't that many %s.", list_name ); writeBuffer ( buf, ch ); return; } if ( !str_prefix ( arg, "catchup" ) ) { switch ( type ) { case NOTE_NOTE: ch->pcdata->last_note = current_time; break; case NOTE_IDEA: ch->pcdata->last_idea = current_time; break; case NOTE_PENALTY: ch->pcdata->last_penalty = current_time; break; case NOTE_NEWS: ch->pcdata->last_news = current_time; break; case NOTE_CHANGES: ch->pcdata->last_changes = current_time; break; } return; } /* below this point only certain people can edit notes */ if ( ( type == NOTE_NEWS && !IS_TRUSTED ( ch, ANGEL ) ) || ( type == NOTE_CHANGES && !IS_TRUSTED ( ch, CREATOR ) ) ) { snprintf ( buf, sizeof ( buf ), "You aren't high enough level to write %s.", list_name ); writeBuffer ( buf, ch ); return; } if ( SameString ( arg, "+" ) ) { note_attach ( ch, type ); if ( ch->pnote->type != type ) { writeBuffer ( "You already have a different note in progress.\n\r", ch ); return; } if ( strlen ( ch->pnote->text ) + strlen ( argument ) >= 4096 ) { writeBuffer ( "Note too long.\n\r", ch ); return; } buffer = new_buf(); add_buf ( buffer, ch->pnote->text ); add_buf ( buffer, argument ); add_buf ( buffer, "\n\r" ); PURGE_DATA ( ch->pnote->text ); ch->pnote->text = assign_string ( buf_string ( buffer ) ); recycle_buf ( buffer ); writeBuffer ( "Ok.\n\r", ch ); return; } if ( SameString ( arg, "-" ) ) { int len; bool found = FALSE; note_attach ( ch, type ); if ( ch->pnote->type != type ) { writeBuffer ( "You already have a different note in progress.\n\r", ch ); return; } if ( ch->pnote->text == NULL || ch->pnote->text[0] == '\0' ) { writeBuffer ( "No lines left to remove.\n\r", ch ); return; } strcpy ( buf, ch->pnote->text ); for ( len = strlen ( buf ); len > 0; len-- ) { if ( buf[len] == '\r' ) { if ( !found ) { /* back it up */ if ( len > 0 ) { len--; } found = TRUE; } else { /* found the second one */ buf[len + 1] = '\0'; PURGE_DATA ( ch->pnote->text ); ch->pnote->text = assign_string ( buf ); return; } } } buf[0] = '\0'; PURGE_DATA ( ch->pnote->text ); ch->pnote->text = assign_string ( buf ); return; } if ( !str_prefix ( arg, "subject" ) ) { note_attach ( ch, type ); if ( ch->pnote->type != type ) { writeBuffer ( "You already have a different note in progress.\n\r", ch ); return; } PURGE_DATA ( ch->pnote->subject ); ch->pnote->subject = assign_string ( argument ); writeBuffer ( "Ok.\n\r", ch ); return; } if ( !str_prefix ( arg, "to" ) ) { note_attach ( ch, type ); if ( ch->pnote->type != type ) { writeBuffer ( "You already have a different note in progress.\n\r", ch ); return; } PURGE_DATA ( ch->pnote->to_list ); ch->pnote->to_list = assign_string ( argument ); writeBuffer ( "Ok.\n\r", ch ); return; } if ( !str_prefix ( arg, "clear" ) ) { if ( ch->pnote != NULL ) { recycle_note ( ch->pnote ); ch->pnote = NULL; } writeBuffer ( "Ok.\n\r", ch ); return; } if ( !str_prefix ( arg, "show" ) ) { if ( ch->pnote == NULL ) { writeBuffer ( "You have no note in progress.\n\r", ch ); return; } if ( ch->pnote->type != type ) { writeBuffer ( "You aren't working on that kind of note.\n\r", ch ); return; } sprintf ( buf, "%s: %s\n\rTo: %s\n\r", ch->pnote->sender, ch->pnote->subject, ch->pnote->to_list ); writeBuffer ( buf, ch ); writeBuffer ( ch->pnote->text, ch ); return; } if ( !str_prefix ( arg, "post" ) || !str_prefix ( arg, "send" ) ) { char *strtime; if ( ch->pnote == NULL ) { writeBuffer ( "You have no note in progress.\n\r", ch ); return; } if ( ch->pnote->type != type ) { writeBuffer ( "You aren't working on that kind of note.\n\r", ch ); return; } if ( SameString ( ch->pnote->to_list, "" ) ) { writeBuffer ( "You need to provide a recipient (name, all, or immortal).\n\r", ch ); return; } if ( SameString ( ch->pnote->subject, "" ) ) { writeBuffer ( "You need to provide a subject.\n\r", ch ); return; } ch->pnote->next = NULL; strtime = ctime ( ¤t_time ); strtime[strlen ( strtime ) - 1] = '\0'; ch->pnote->date = assign_string ( strtime ); ch->pnote->date_stamp = current_time; append_note ( ch->pnote ); ch->pnote = NULL; return; } writeBuffer ( "You can't do that.\n\r", ch ); return; }
void free_mat(MAT_TYPE *mat) { Assert(mat, "Material non-existant! Crashing"); PURGE_DATA(mat->name); PURGE_DATA(mat); }