void do_token(CHAR_DATA *ch, char *argument) { OBJ_DATA *obj; char arg1[MSL]; char arg2[MSL]; char arg3[MSL]; char arg4[MSL]; CHAR_DATA *to,*to_next; argument = one_argument(argument,arg1); argument = one_argument(argument,arg2); argument = one_argument(argument,arg3); if( arg1[0] == '\0'|| arg2[0] == '\0' || arg3[0] == '\0' || argument[0] == '\0') { send_to_one(ch,"Syntax: token <type> <winchance> <max_win> <min_win>\n\r" "Token Types are:\n\r" "Normal 0\n\r" "Practice 1\n\r" "Train 2\n\r" "Quest 3\n\r" "Exp 4\n\r" "All arguments must be numerical."); return; } obj = create_object(get_obj_index(OBJ_VNUM_TOKEN),0); obj->value[0] = atoi(arg1); obj->value[1] = atoi(arg2); obj->value[2] = atoi(arg3); obj->value[3] = atoi(argument); obj->name = str_dup(token_table[obj->value[0]].name); free_string(obj->short_descr); obj->short_descr = str_dup(token_table[obj->value[0]].short_descr); free_string(obj->description); obj->description = str_dup(token_table[obj->value[0]].long_descr); obj_to_char(obj,ch); send_to_one(ch,"You have created a %s token.",token_table[obj->value[0]].name); for(to = ch->in_room->people; to; to = to_next) { to_next = to->next_in_room; if(to->in_room == ch->in_room && to != ch) { send_to_one(to,"%s has created %s token.",PERS(ch,to),token_table[obj->value[0]].name); } } return; }
/** * This is called by the morphing action, as well as the instamorph in do_morph. * It sends messages and finishes the morph. * * @param char_data *ch the morpher * @param int morph_to any MORPH_x const */ void finish_morphing(char_data *ch, int morph_to) { char lbuf[MAX_STRING_LENGTH]; sprintf(lbuf, "%s has become $n!", PERS(ch, ch, FALSE)); perform_morph(ch, morph_to); act(lbuf, TRUE, ch, 0, 0, TO_ROOM); act("You have become $n!", FALSE, ch, 0, 0, TO_CHAR); if (morph_data[morph_to].ability != NOTHING) { gain_ability_exp(ch, morph_data[morph_to].ability, 33.4); } }
void do_showbugs( CHAR_DATA * ch, char *argument ) { DESCRIPTOR_DATA *d; CHAR_DATA *victim; int schance; char buf2[MAX_STRING_LENGTH]; SHIP_DATA *ship; BUG_DATA *pbug; char buf[MAX_STRING_LENGTH]; schance = number_percent( ) - 20; if( schance > ch->pcdata->learned[gsn_showbugs] ) { send_to_char( "You can't figure out what to do.\n\r", ch ); learn_from_failure( ch, gsn_showbugs ); return; } send_to_char( "Player Planet/Ship Room Name\n\r", ch ); send_to_char( "------ ----------- ---------\n\r", ch ); for( d = first_descriptor; d; d = d->next ) if( ( d->connected == CON_PLAYING || d->connected == CON_EDITING ) && ( victim = d->character ) != NULL ) { for( pbug = victim->first_bug; pbug; pbug = pbug->next_in_bug ) if( !str_cmp( pbug->name, ch->name ) ) { if( victim->in_room->area && victim->in_room->area->planet ) sprintf( buf2, "%s", victim->in_room->area->planet->name ); else if( ( ship = ship_from_room( victim->in_room->vnum ) ) != NULL ) sprintf( buf2, "%s", ship->name ); else sprintf( buf2, "Unknown" ); sprintf( buf, "%-21.21s %-18.18s %s\n\r", PERS( victim, ch ), buf2, victim->in_room->name ); send_to_char( buf, ch ); break; } } learn_from_success( ch, gsn_showbugs ); }
void scan_char(CHAR_DATA *victim, CHAR_DATA *ch, sh_int depth, sh_int door) { extern char *const dir_name[]; extern char *const distance[]; char buf[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH]; buf[0] = '\0'; if ( IS_AFFECTED(ch, AFF_FARSIGHT) || depth == 0 ) { strcat(buf, PERS(victim, ch)); strcat(buf, ", "); } else { strcat(buf, "Something is moving "); } sprintf(buf2, distance[depth], dir_name[door]); strcat(buf, buf2); strcat(buf, "\n\r"); send_to_char(buf, ch); return; }
void do_plantbug( CHAR_DATA * ch, char *argument ) { CHAR_DATA *victim; BUG_DATA *pbug; BUG_DATA *cbug; OBJ_DATA *obj; bool checkbug = FALSE; int schance; if( IS_NPC( ch ) ) return; if( ( victim = get_char_room( ch, argument ) ) == NULL ) { send_to_char( "They aren't here.\n\r", ch ); return; } if( IS_NPC( victim ) ) { send_to_char( "You can't bug NPC's!\n\r", ch ); return; } if( IS_IMMORTAL( victim ) ) { send_to_char( "Don't try to plant bugs on immortals.\n\r", ch ); return; } if( in_arena( ch ) ) { send_to_char( "You're here to FIGHT, not spy.\n\r", ch ); return; } if( ch == victim ) { send_to_char( "You can't bug yourself!\n\r", ch ); return; } for( obj = ch->last_carrying; obj; obj = obj->prev_content ) if( obj->item_type == ITEM_BUG ) checkbug = TRUE; if( checkbug == FALSE ) { send_to_char( "You don't have any bugs to plant.\n\r", ch ); return; } for( cbug = victim->first_bug; cbug; cbug = cbug->next_in_bug ) if( !str_cmp( ch->name, cbug->name ) ) { send_to_char( "You have already planted a bug on this person.\n\r", ch ); return; } schance = number_percent( ) - UMIN( 0, ( get_curr_lck( ch ) - 14 ) ) + UMIN( 0, ( get_curr_lck( victim ) - 13 ) ); if( schance < ch->pcdata->learned[gsn_plantbug] ) { act( AT_WHITE, "You carefully reach into $N's pocket and place a bug.", ch, NULL, victim, TO_CHAR ); CREATE( pbug, BUG_DATA, 1 ); pbug->name = ch->name; LINK( pbug, victim->first_bug, victim->last_bug, next_in_bug, prev_in_bug ); learn_from_success( ch, gsn_plantbug ); for( obj = ch->last_carrying; obj; obj = obj->prev_content ) { if( obj->item_type == ITEM_BUG ) { separate_obj( obj ); obj_from_char( obj ); extract_obj( obj ); break; } } return; } else { send_to_char( "&RYou try to find a pocket to plant the bug in but fail!\n\r", ch ); learn_from_failure( ch, gsn_plantbug ); if( number_bits( 0 ) == 0 ) ch_printf( victim, "You feel a slight brush against your pocket to find %s's hand there.\n\r", PERS( ch, victim ) ); return; } }
void do_immlocate( CHAR_DATA *ch, char *argument ) { char buf[MAX_STRING_LENGTH]; char type[10]; OBJ_DATA *obj; OBJ_DATA *in_obj; CHAR_DATA *victim; bool found; int count=0; int nVnum = 0; if ( IS_NPC(ch) ) return; argument = one_argument(argument,type); if ( argument[0] == '\0' || type[0] == '\0' ) return stcf(ch, "Syntax: immlocate <mob/obj> <vnum>.\n\r"); if ( !is_number(argument) ) return stcf(ch, "A Number.\n\r"); nVnum = atoi(argument); found = FALSE; if ( !str_cmp(type,"obj" ) ) { for ( obj = object_list; obj != NULL; obj = obj->next ) { if (obj->pIndexData->vnum != nVnum) continue; found = TRUE; for ( in_obj = obj; in_obj->in_obj != NULL; in_obj = in_obj->in_obj ); if ( in_obj->carried_by != NULL ) { sprintf( buf, "%s carried by %s.\n\r", obj->short_descr, PERS(in_obj->carried_by, ch) ); } else { sprintf( buf, "%s in %s.\n\r", obj->short_descr, in_obj->in_room == NULL ? "somewhere" : in_obj->in_room->name ); } buf[0] = UPPER(buf[0]); send_to_char( buf, ch ); if (count > 50 ) break; else count++; } if ( !found ) send_to_char( "Nothing like that in hell, earth, or heaven.\n\r", ch ); } if ( !str_cmp(type,"mob" ) ) { for ( victim = char_list; victim != NULL; victim = victim->next ) { if (!IS_NPC(victim) || victim->pIndexData->vnum != nVnum) continue; found = TRUE; sprintf( buf, "%s at %s #R[#yVnum:#L%d#R]#n.\n\r", victim->short_descr, victim->in_room->name, victim->in_room->vnum); buf[0] = UPPER(buf[0]); send_to_char( buf, ch ); if (count > 50 ) break; else count++; } if ( !found ) send_to_char( "Nothing like that in hell, earth, or heaven.\n\r", ch ); } return; }
/** * owhere <var> <value> */ void do_owhere(struct char_data *ch, const char *argument) { struct buf_type *buffer; OBJ_CMP_FN *cmp_fn; char buf[MAX_INPUT_LENGTH]; char arg[MAX_INPUT_LENGTH]; int iter; if (ch == NULL || IS_NPC(ch)) return; if (argument[0] == '\0') { send_to_char("\n\rFind what?\n\r", ch); return; } cmp_fn = NULL; one_argument(argument, arg); if (argument[0] == '?' || !str_prefix(argument, "help")) { show_help(ch->desc, "owhere", NULL); return; } buffer = new_buf(); if (!str_prefix(argument, "list")) { add_buf(buffer, "owhere: searchable property list\n\r"); for (iter = 0; obj_flags[iter].var[0] != '\0'; iter++) { sprintf(buf, "%-18.17s", obj_flags[iter].var); add_buf(buffer, buf); if ((iter % 2) == 1) add_buf(buffer, "\n\r"); } add_buf(buffer, "\n\r"); page_to_char(buf_string(buffer), ch); return; } sprintf(buf, "`#QUERY``: owhere %s\n\r\n\r", argument); add_buf(buffer, buf); for (iter = 0; obj_flags[iter].var[0] != '\0'; iter++) { if (!str_prefix(arg, obj_flags[iter].var)) { cmp_fn = (OBJ_CMP_FN *)obj_flags[iter].fn; argument = one_argument(argument, arg); break; } } if (cmp_fn == NULL) cmp_fn = obj_cmp_name; if (argument[0] == '?' || argument[0] == '\0') { clear_buf(buffer); sprintf(buf, "`#SYNTAX``:\n\r owhere %s <value>:\n\r\n\r", arg); add_buf(buffer, buf); (*cmp_fn)(object_iterator_start(&object_empty_filter), argument, buffer); page_to_char(buf_string(buffer), ch); } else { struct gameobject *obj, *opending; struct gameobject *in_obj; char *clr1; char *clr2; int number; number = 0; opending = object_iterator_start(&object_empty_filter); while ((obj = opending) != NULL) { opending = object_iterator(obj, &object_empty_filter); if (can_see_obj(ch, obj) && (*cmp_fn)(obj, argument, NULL)) { number++; if (number == 1) { sprintf(buf, "# vnum name where room\n\r"); add_buf(buffer, buf); sprintf(buf, "=== ====== =========================== ========================== =====\n\r"); add_buf(buffer, buf); } for (in_obj = obj; in_obj->in_obj != NULL; in_obj = in_obj->in_obj) continue; if (in_obj->carried_by != NULL && can_see(ch, in_obj->carried_by) && in_obj->carried_by->in_room != NULL) { clr1 = uncolor_str(obj->short_descr); clr2 = uncolor_str(PERS(in_obj->carried_by, ch)); sprintf(buf, "%-3d %-7ld %-26.26s %-25.25s %-7ld\n\r", number, obj->objprototype->vnum, clr1, clr2, in_obj->carried_by->in_room->vnum); free_string(clr1); free_string(clr2); } else if (in_obj->in_room != NULL && can_see_room(ch, in_obj->in_room)) { clr1 = uncolor_str(obj->short_descr); clr2 = uncolor_str(in_obj->in_room->name); sprintf(buf, "%-3d %-7ld %-26.26s %-25.25s %-7ld\n\r", number, obj->objprototype->vnum, clr1, clr2, in_obj->in_room->vnum); free_string(clr1); free_string(clr2); } else { clr1 = uncolor_str(obj->short_descr); sprintf(buf, "%-3d %-7ld %-26.26s\n\r", number, obj->objprototype->vnum, clr1); free_string(clr1); } buf[0] = UPPER(buf[0]); add_buf(buffer, buf); if (number >= MAX_RETURN) break; } } if (number == 0) send_to_char("Nothing like that in heaven or earth.\n\r", ch); else page_to_char(buf_string(buffer), ch); } free_buf(buffer); }
void sub_write_to_char(char_data *ch, char *tokens[], void *otokens[], char type[]) { char sb[MAX_STRING_LENGTH]; int i; strcpy(sb, ""); for (i = 0; tokens[i + 1]; i++) { strcat(sb,tokens[i]); switch (type[i]) { case '~': { if (!otokens[i]) strcat(sb,"someone"); else if ((char_data*)otokens[i] == ch) strcat(sb, "you"); else strcat(sb,PERS((char_data*)otokens[i], ch, FALSE)); break; } case '|': { if (!otokens[i]) strcat(sb, "someone's"); else if ((char_data*)otokens[i] == ch) strcat(sb, "your"); else { strcat(sb,PERS((char_data*) otokens[i], ch, FALSE)); strcat(sb,"'s"); } break; } case '^': { if (!otokens[i] || !CAN_SEE(ch, (char_data*) otokens[i])) strcat(sb,"its"); else if ((char_data*)otokens[i] == ch) strcat(sb,"your"); else strcat(sb,HSHR((char_data*) otokens[i])); break; } /* case '&': { if (!otokens[i] || !CAN_SEE(ch, (char_data*) otokens[i])) strcat(sb,"it"); else if ((char_data*)otokens[i] == ch) strcat(sb,"you"); else strcat(sb,HSSH((char_data*) otokens[i])); break; } */ case '*': { if (!otokens[i] || !CAN_SEE(ch, (char_data*) otokens[i])) strcat(sb,"it"); else if ((char_data*)otokens[i] == ch) strcat(sb,"you"); else strcat(sb,HMHR((char_data*) otokens[i])); break; } case '@': { if (!otokens[i]) strcat(sb,"something"); else strcat(sb,OBJS(((obj_data*) otokens[i]), ch)); break; } } } strcat(sb,tokens[i]); strcat(sb, "&0\r\n"); sb[0] = toupper(sb[0]); send_to_char(sb, ch); }
static void sub_write_to_char(char_data *ch, char *tokens[], void *otokens[], char type[]) { char sb[MAX_STRING_LENGTH]; int i; strcpy(sb,""); for (i = 0; tokens[i + 1]; i++) { strcat(sb,tokens[i]); switch (type[i]) { case '~': if (!otokens[i]) strcat(sb,"someone"); else if ((char_data *)otokens[i] == ch) strcat(sb,"you"); else strcat(sb,PERS((char_data *)otokens[i], ch)); break; case '|': if (!otokens[i]) strcat(sb,"someone's"); else if ((char_data *)otokens[i] == ch) strcat(sb,"your"); else { strcat(sb,PERS((char_data *) otokens[i], ch)); strcat(sb,"'s"); } break; case '^': if (!otokens[i] || !CAN_SEE(ch, (char_data *) otokens[i])) strcat(sb,"its"); else if (otokens[i] == ch) strcat(sb,"your"); else strcat(sb,HSHR((char_data *) otokens[i])); break; case '&': if (!otokens[i] || !CAN_SEE(ch, (char_data *) otokens[i])) strcat(sb,"it"); else if (otokens[i] == ch) strcat(sb,"you"); else strcat(sb,HSSH((char_data *) otokens[i])); break; case '*': if (!otokens[i] || !CAN_SEE(ch, (char_data *) otokens[i])) strcat(sb,"it"); else if (otokens[i] == ch) strcat(sb,"you"); else strcat(sb,HMHR((char_data *) otokens[i])); break; case '`': if (!otokens[i]) strcat(sb,"something"); else strcat(sb,OBJS(((obj_data *) otokens[i]), ch)); break; } } strcat(sb,tokens[i]); strcat(sb,"\n\r"); send_to_char(ch, "%s", sb); }
void do_tell( CHAR_DATA *ch, char *argument ) { char arg[MAX_INPUT_LENGTH],buf[MAX_STRING_LENGTH]; CHAR_DATA *victim; if ( IS_SET(ch->comm, COMM_NOTELL) || IS_SET(ch->comm,COMM_DEAF)) { send_to_char( "Your message didn't get through.\n\r", ch ); return; } if ( IS_SET(ch->comm, COMM_QUIET) ) { send_to_char( "You must turn off quiet mode first.\n\r", ch); return; } if (IS_SET(ch->comm,COMM_DEAF)) { send_to_char("You must turn off deaf mode first.\n\r",ch); return; } argument = one_argument( argument, arg ); if ( arg[0] == '\0' || argument[0] == '\0' ) { send_to_char( "Tell whom what?\n\r", ch ); return; } /* * Can tell to PC's anywhere, but NPC's only in same room. * -- Furey */ if ( ( victim = get_char_world( ch, arg ) ) == NULL || ( IS_NPC(victim) && victim->in_room != ch->in_room ) ) { send_to_char( "They aren't here.\n\r", ch ); return; } if ( victim->desc == NULL && !IS_NPC(victim)) { act("$N seems to have misplaced $S link...try again later.", ch,NULL,victim,TO_CHAR); sprintf(buf,"{k%s tells you '{K%s{k'{x\n\r",PERS(ch,victim),argument); buf[0] = UPPER(buf[0]); add_buf(victim->pcdata->buffer,buf); return; } if ( !(IS_IMMORTAL(ch) && ch->level > LEVEL_IMMORTAL) && !IS_AWAKE(victim) ) { act( "$E can't hear you.", ch, 0, victim, TO_CHAR ); return; } if ((IS_SET(victim->comm,COMM_QUIET) || IS_SET(victim->comm,COMM_DEAF)) && !IS_IMMORTAL(ch)) { act( "$E is not receiving tells.", ch, 0, victim, TO_CHAR ); return; } if (IS_SET(victim->comm,COMM_AFK)) { if (IS_NPC(victim)) { act("$E is AFK, and not receiving tells.",ch,NULL,victim,TO_CHAR); return; } act("$E is AFK, but your tell will go through when $E returns.", ch,NULL,victim,TO_CHAR); sprintf(buf,"{k%s tells you '{K%s{k'{x\n\r",PERS(ch,victim),argument); buf[0] = UPPER(buf[0]); add_buf(victim->pcdata->buffer,buf); return; } act( "{kYou tell $N '{K$t{k'{x", ch, argument, victim, TO_CHAR ); act_new("{k$n tells you '{K$t{k'{x",ch,argument,victim,TO_VICT,POS_DEAD); victim->reply = ch; if (!IS_NPC(ch) && IS_NPC(victim)&& HAS_TRIGGER_MOB(victim,TRIG_SPEECH) ) p_act_trigger( argument, victim, NULL, NULL, ch, NULL, NULL, TRIG_SPEECH); return; }
//********************KONIEC PRZYTRZYMUJACYCH*******************// //to jest do_owhere() tylko zmodyfikowany na potrzeby do_astat() void awhere( CHAR_DATA *ch, char *argument ) { char buf[ MAX_INPUT_LENGTH ]; BUFFER *buffer = NULL; OBJ_DATA *obj; OBJ_DATA *in_obj; bool found; int vnum = -1; found = FALSE; buffer = new_buf(); if ( argument[ 0 ] == '\0' ) { send_to_char( "Find what?\n\r", ch ); return ; } if ( is_number( argument ) ) vnum = atoi( argument ); for ( obj = object_list; obj != NULL; obj = obj->next ) { if ( vnum > 0 ) { if ( !can_see_obj( ch, obj ) || obj->pIndexData->vnum != vnum ) continue; } else { if ( !can_see_obj( ch, obj ) || !is_name( argument, obj->name ) ) continue; } found = TRUE; for ( in_obj = obj; in_obj->in_obj != NULL; in_obj = in_obj->in_obj ); if ( in_obj->carried_by != NULL && can_see( ch, in_obj->carried_by ) && in_obj->carried_by->in_room != NULL ) sprintf( buf, " %s jest noszone przez %s [Room %d]\n\r", obj->short_descr, PERS( in_obj->carried_by, ch ), in_obj->carried_by->in_room->vnum ); else if ( in_obj->in_room != NULL && can_see_room( ch, in_obj->in_room ) ) sprintf( buf, " %s jest w %s [Room %d]\n\r", obj->short_descr, in_obj->in_room->name, in_obj->in_room->vnum ); else sprintf( buf, " %s jest gdzies\n\r", obj->short_descr ); sprintf( buf, "%s", capitalize( buf ) ); add_buf( buffer, buf ); } if ( !found ) send_to_char( " Niczego takiego nie ma aktualnie w grze.\n\r", ch ); else page_to_char( buf_string( buffer ), ch ); free_buf( buffer ); }
void do_say( CHAR_DATA *ch, char *argument ) { // char arg[MIL]; // char arg2[MIL]; // CHAR_DATA *victim; CHAR_DATA *to, *to_next; // DESCRIPTOR_DATA *d, *d_next; // int sn; if ( argument[0] == '\0' ) { send_to_char( "Say what?\n\r", ch ); return; } if(!IS_NPC(ch) && ch->pcdata->condition[COND_DRUNK] > 10) argument = makedrunk(argument,ch); crushcaps(argument); send_to_one(ch, "{6You say '{7%s{6'{x",argument ); for(to = ch->in_room->people; to; to = to_next) { to_next = to->next_in_room; if(to->in_room == ch->in_room && to != ch) { if(!IS_SET(ch->act,PLR_DEAD)) send_to_one(to, "{6%s says '{7%s{6'{x", PERS(ch,to),argument ); else send_to_one(to,"{6The spirit of %s says '{7%s{6'{x",PERS(ch,to),argument); } } if (!IS_NPC(ch) ) { CHAR_DATA *mob, *mob_next; OBJ_DATA *obj, *obj_next; for(mob = ch->in_room->people; mob != NULL; mob = mob_next) { mob_next = mob->next_in_room; if (IS_NPC(mob) && HAS_TRIGGER_MOB( mob, TRIG_SPEECH ) && mob->position == mob->pIndexData->default_pos) p_act_trigger( argument, mob, NULL, NULL, ch, NULL, NULL, TRIG_SPEECH); for ( obj = mob->carrying; obj; obj = obj_next ) { obj_next = obj->next_content; if ( HAS_TRIGGER_OBJ( obj, TRIG_SPEECH ) ) p_act_trigger( argument, NULL, obj, NULL, ch, NULL, NULL, TRIG_SPEECH ); } } for ( obj = ch->in_room->contents; obj; obj = obj_next ) { obj_next = obj->next_content; if ( HAS_TRIGGER_OBJ( obj, TRIG_SPEECH ) ) p_act_trigger( argument, NULL, obj, NULL, ch, NULL, NULL, TRIG_SPEECH ); } if ( HAS_TRIGGER_ROOM( ch->in_room, TRIG_SPEECH ) ) p_act_trigger( argument, NULL, NULL, ch->in_room, ch, NULL, NULL, TRIG_SPEECH ); } return; }
void do_reply( CHAR_DATA *ch, char *argument ) { CHAR_DATA *victim; char buf[MAX_STRING_LENGTH]; if ( IS_SET(ch->comm, COMM_NOTELL) ) { send_to_char( "Your message didn't get through.\n\r", ch ); return; } if ( ( victim = ch->reply ) == NULL ) { send_to_char( "They aren't here.\n\r", ch ); return; } if ( victim->desc == NULL && !IS_NPC(victim)) { act("$N seems to have misplaced $S link...try again later.", ch,NULL,victim,TO_CHAR); sprintf(buf,"{k%s tells you '{K%s{k'{x\n\r",PERS(ch,victim),argument); buf[0] = UPPER(buf[0]); add_buf(victim->pcdata->buffer,buf); return; } if ( !IS_IMMORTAL(ch) && !IS_AWAKE(victim) ) { act( "$E can't hear you.", ch, 0, victim, TO_CHAR ); return; } if ((IS_SET(victim->comm,COMM_QUIET) || IS_SET(victim->comm,COMM_DEAF)) && !IS_IMMORTAL(ch) && !IS_IMMORTAL(victim)) { act_new( "$E is not receiving tells.", ch, 0, victim, TO_CHAR,POS_DEAD); return; } if (!IS_IMMORTAL(victim) && !IS_AWAKE(ch)) { send_to_char( "In your dreams, or what?\n\r", ch ); return; } if (IS_SET(victim->comm,COMM_AFK)) { if (IS_NPC(victim)) { act_new("$E is AFK, and not receiving tells.", ch,NULL,victim,TO_CHAR,POS_DEAD); return; } act_new("$E is AFK, but your tell will go through when $E returns.", ch,NULL,victim,TO_CHAR,POS_DEAD); sprintf(buf,"{k%s tells you '{K%s{k'{x\n\r",PERS(ch,victim),argument); buf[0] = UPPER(buf[0]); add_buf(victim->pcdata->buffer,buf); return; } act_new("{kYou tell $N '{K$t{k'{x",ch,argument,victim,TO_CHAR,POS_DEAD); act_new("{k$n tells you '{K$t{k'{x",ch,argument,victim,TO_VICT,POS_DEAD); victim->reply = ch; return; }
OBJ_DATA *generate_token(CHAR_DATA *ch) { char buf[MIL]; OBJ_DATA *obj; int i, token; CHAR_DATA *to, *to_next; obj = create_object(get_obj_index(OBJ_VNUM_TOKEN),0); //for randomizing tokens for( i=0; i < MAX_TOKEN; i++) { if(ch->inserted->value[0] < 4 && (chance(7))) //we win an exp token { obj->value[0] = token_lookup("experience"); obj->value[1] = 100; obj->value[2] = number_fuzzy(token_table[obj->value[0]].max_win); obj->value[3] = number_fuzzy(token_table[obj->value[0]].min_win); obj->value[4] = 0; obj->name = str_dup(token_table[obj->value[0]].name); free_string(obj->short_descr); obj->short_descr = str_dup(token_table[obj->value[0]].short_descr); free_string(obj->description); obj->description = str_dup(token_table[obj->value[0]].long_descr); obj_to_char(obj,ch); if(ch->inserted->value[0] < 4) { send_to_one(ch,"WooHoo!!! You won an experience token."); for(to = ch->in_room->people; to; to = to_next) { to_next = to->next_in_room; if(to != ch && to->in_room == ch->in_room) { send_to_one(to,"%s just won an experience token.",PERS(ch,to)); } } } else send_to_one(ch,"You lost your %s token.",token_table[ch->inserted->value[0]].name); return obj; } else if(ch->inserted->value[0] != 3 && (chance(20)))//20 percent chance you get a quest token { obj->value[0] = token_lookup("quest"); obj->value[1] = number_range(0,100); obj->value[2] = number_fuzzy(token_table[obj->value[0]].max_win); obj->value[3] = number_fuzzy(token_table[obj->value[0]].min_win); obj->value[4] = 0; obj->name = str_dup(token_table[obj->value[0]].name); free_string(obj->short_descr); obj->short_descr = str_dup(token_table[obj->value[0]].short_descr); free_string(obj->description); obj->description = str_dup(token_table[obj->value[0]].long_descr); obj_to_char(obj,ch); if(ch->inserted->value[0] < 3) { send_to_one(ch,"Hot Damn! You won a quest token."); for(to = ch->in_room->people; to; to = to_next) { to_next = to->next_in_room; if(to->in_room == ch->in_room && to != ch) { send_to_one(to,"%s just won a quest token.",PERS(ch,to)); } } } else if( ch->inserted->value[0] > 3) { send_to_one(ch,"Damn you just won back a quest token."); for(to = ch->in_room->people; to; to = to_next) { to_next = to->next_in_room; if(to->in_room == ch->in_room && to != ch) { send_to_one(to,"%s just won a quest token.",PERS(ch,to)); } } } else send_to_one(ch,"You lost your %s token.",token_table[ch->inserted->value[0]].name); return obj; } else if(ch->inserted->value[0] != 2 && (chance(25))) //25 percent chance you get a train token { //we win a train token obj->value[0] = token_lookup("train"); obj->value[1] = number_range(0,100); obj->value[2] = number_fuzzy(token_table[obj->value[0]].max_win); obj->value[3] = number_fuzzy(token_table[obj->value[0]].min_win); obj->value[4] = 0; obj->name = str_dup(token_table[obj->value[0]].name); free_string(obj->short_descr); obj->short_descr = str_dup(token_table[obj->value[0]].short_descr); free_string(obj->description); obj->description = str_dup(token_table[obj->value[0]].long_descr); obj_to_char(obj,ch); if(ch->inserted->value[0] < 2) { send_to_one(ch,"Nifty, you won a train token."); for(to = ch->in_room->people; to; to = to_next) { to_next = to->next_in_room; if(to->in_room == ch->in_room && to != ch) { send_to_one(to,"%s just won a train token.",PERS(ch,to)); } } } else if( ch->inserted->value[0] > 2) { send_to_one(ch,"Shit you just won back a train token."); for(to = ch->in_room->people; to; to = to_next) { to_next = to->next_in_room; if(to->in_room == ch->in_room && to != ch) { send_to_one(to,"%s just won a train token.",PERS(ch,to)); } } } else send_to_one(ch,"You lost your %s token.",token_table[ch->inserted->value[0]].name); return obj; } else if(ch->inserted->value[0] != 1 && (chance(35))) //35 percent chance you get a practice token { //we win a prac token obj->value[0] = token_lookup("practice"); obj->value[1] = number_range(0,100); obj->value[2] = number_fuzzy(token_table[obj->value[0]].max_win); obj->value[3] = number_fuzzy(token_table[obj->value[0]].min_win); obj->value[4] = 0; obj->name = str_dup(token_table[obj->value[0]].name); free_string(obj->short_descr); obj->short_descr = str_dup(token_table[obj->value[0]].short_descr); free_string(obj->description); obj->description = str_dup(token_table[obj->value[0]].long_descr); obj_to_char(obj,ch); if(ch->inserted->value[0] < 1 ) { send_to_one(ch,"You won a practice token."); for(to = ch->in_room->people; to; to = to_next) { to_next = to->next_in_room; if(to->in_room == ch->in_room && to != ch) { send_to_one(to,"%s just won a practice token.",PERS(ch,to)); } } } else if (ch->inserted->value[0] > 1) { send_to_one(ch,"Bah, you won back a practice token."); for(to = ch->in_room->people; to; to = to_next) { to_next = to->next_in_room; if(to->in_room == ch->in_room && to != ch) { send_to_one(to,"%s just won a practice token.",PERS(ch,to)); } } } else send_to_one(ch,"You lost your %s token.",token_table[ch->inserted->value[0]].name); return obj; } else if(ch->inserted->value[0] !=0 && (chance(15))) { //win back a normal token obj->value[0] = token_lookup("normal"); obj->value[1] = number_range(0,100); obj->value[2] = number_range(250,400); obj->value[3] = number_range(25,249); obj->value[4] = 0; obj->name = str_dup(token_table[obj->value[0]].name); free_string(obj->short_descr); obj->short_descr = str_dup(token_table[obj->value[0]].short_descr); free_string(obj->description); obj->description = str_dup(token_table[obj->value[0]].long_descr); obj_to_char(obj,ch); if(ch->inserted->value[0] > 1) { send_to_one(ch,"You just won back a normal token."); for(to = ch->in_room->people; to; to = to_next) { to_next = to->next_in_room; if(to->in_room == ch->in_room && to != ch) { send_to_one(to,"%s just won a normal token.",PERS(ch,to)); } } } else send_to_one(ch,"You lost your %s token.",token_table[ch->inserted->value[0]].name); return obj; } } return NULL; }
//Contract System by Tawnos. void do_contract( CHAR_DATA * ch, char *argument ) { CHAR_DATA *victim; CHAR_DATA *target; char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char arg3[MAX_INPUT_LENGTH]; long amount = 0; CONTRACT_DATA *ccontract; CONTRACT_DATA *contract; argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); argument = one_argument( argument, arg3 ); if( IS_NPC( ch ) ) return; if( arg1[0] == '\0' || arg2[0] == '\0' || arg3[0] == '\0' ) { send_to_char( "&RSyntax: contract <person> <target> <amount>\n\r", ch ); return; } if( ( victim = get_char_room( ch, arg1 ) ) == NULL ) { send_to_char( "They aren't here.\n\r", ch ); return; } if( ( target = get_char_world_ooc( ch, arg2 ) ) == NULL ) { send_to_char( "Your target is currently not online.\n\r", ch ); return; } if( ch == victim ) { send_to_char( "You can't contract yourself!\n\r", ch ); return; } if( IS_NPC( victim ) || IS_NPC( target ) ) { send_to_char( "You can't contract NPC's.\n\r", ch ); return; } if( ch == target ) { send_to_char( "You can't contract against yourself!\n\r", ch ); return; } if( target == victim ) { send_to_char( "You can't contract them to kill themself!\n\r", ch ); return; } amount = atoi( arg3 ); if( amount < 5000 ) { send_to_char( "&RYour contract must be for at least 5000 credits.\n\r", ch ); return; } if( ch->gold < amount ) { send_to_char( "&RYou don't have enough credits!\n\r", ch ); return; } for( ccontract = victim->first_contract; ccontract; ccontract = ccontract->next_in_contract ) { if( !str_cmp( ccontract->target, target->name ) ) { ch->gold -= amount; ccontract->amount += amount; ch_printf( ch, "&GYou have contracted %s to kill %s for an amount of %d credits.\n\r", PERS( victim, ch ), target->name, amount ); ch_printf( victim, "&G%s has contracted you to kill %s, raising your contract reward by %d credits.\n\r", PERS( ch, victim ), target->name, amount ); return; } } CREATE( contract, CONTRACT_DATA, 1 ); contract->target = target->name; contract->amount = amount; LINK( contract, victim->first_contract, victim->last_contract, next_in_contract, prev_in_contract ); ch->gold -= amount; ch_printf( ch, "&GYou have contracted %s to kill %s for an amount of %d credits.\n\r", PERS( victim, ch ), target->name, amount ); ch_printf( victim, "&G%s has contracted you to kill %s for an amount of %d credits.\n\r", PERS( ch, victim ), target->name, amount ); }
/*** Personaliza um arquivo dado. Parametros: FileName: Nome do arquivo a personalizar Name: Nome do usuario Company: Nome da compania Serial: Serial Number ActKey: Chave de ativacao Inportante: · O número serial deve estar na forma 11.222222.3333.444444 com pontos separando os campos. Ele deve sempre ter o strlen() <= 32. . O campo 1 eh de tamanho fixo. Os demais sao de tamanho variavel ate o limite maximo de 32 caracteres. · 11 = tipo da cópia · 222222 = Data. Se começar com número > 0 é data absoluta. Se começar (ATENCAO) com 0 é time bomb e se começar com letra indica cópia não demo. · 3333 = Número de terminais · 444444 = Um número serial Retorna: PE_DATA: Chave com data absoluta ja expirou PE_TYPE: Tipo nao bate PE_ACTKEY: Chave de ativacao nao bate PE_SERIAL: Numero de serie com formacao ou tamanho errado PE_PARAM: Parametros invalidos PE_TIMEBOMB: Tentando personalizar copia time-bomb de novo. Deve Re-instalar PE_LOCALIZA: Nao achou marca no arquivo PE_POSERROR: Falhou no seek PE_WRITEERROR: Falhou ao tentar escrever no arquivo PE_OK: Ok ***/ int Personalize( char *szFileName, char *szName, char *szCompany, char*szSerial, char *szActKey ) { char data_hoje[MAXDATAINST+1]; time_t time_aux; FILE *fp; int check = 0; char data[MAXDATA+1]; char szBufAux[MAXDATA+1]; struct tm *dma; long tloc; if( szFileName == NULL || szName == NULL || szCompany == NULL || szSerial == NULL || szActKey == NULL ){ return( PE_PARAM ); } if( strlen( szSerial ) > MAXSIZESERIAL ){ return( PE_SERIAL ); } if( !ValidKey( szSerial, szActKey ) ){ return( PE_ACTKEY ); } // Calculo os deslocamentos variaveis em relacao ao serial passado if( CalculaDeslocamentos( szSerial ) != PE_OK ){ return( PE_SERIAL ); } // Verifico se eh uma data absoluta e se ja expirou. if( isdigit( szSerial[DESLOCDATA] ) && szSerial[DESLOCDATA]>'0' ){ /* Eh uma copia demo com data absoluta. VAMOS VERIFICAR!!! */ time( &tloc ); dma = localtime( &tloc ); sprintf( szBufAux, "%04.2d%02.2d", dma->tm_year + 1900, dma->tm_mon + 1 ); // MAXDATA deve ser 6 ; yyyymm. Assim mesmo nos protegemos procurando o '.' istrncpychar( data, szSerial+DESLOCDATA, MAXDATA, '.' ); if( strncmp( szBufAux, data, MAXDATA ) > 0 ) { return( PE_DATA ); } } /* procura a estrutura str_pers */ if( (fp = localiza( szFileName, str_pers )) == NULL ) { return( PE_LOCALIZA ); } // Verifico TIPO da copia antes de decriptografar pois esta em // area nao criptografada. if( strncmp( TIPO( str_pers ), szSerial+DESLOCTIPO, MAXTIPO ) != 0 ){ return( PE_TYPE ); } if( PERS( str_pers ) == PE_PERS ) { /* Jah passou o "person" por aqui antes. * decriptografo a estrutura, para nao perder as * demais informacoes nela contidas: data_instalacao, num_serie, etc. */ Decriptografa( DATAINST(str_pers), CHECKSUM( str_pers ) ); iIsDecrypt = TRUE; } if( szSerial[DESLOCDATA] == '0' ){ // Eh um numero de serie time-bomb if( PERS( str_pers ) == PE_PERS ){ /* Tentando fazer person de time bomb sobre uma copia * previamente personalizada. Nao deixo!!!! Que o filho * da mae re-instale o produto. */ fclose( fp ); return( PE_TIMEBOMB ); } } // Posiciono no inicio da marca para gravar estrutura de // personalizacao if( fseek( fp, lPosicao, 0 ) == -1 ) { fclose( fp ); return( PE_POSERROR ); } // Monto a estrutura de personalizacao time_aux = time( &time_aux ); strftime( data_hoje, sizeof( data_hoje ), "%Y%m%d", localtime( &time_aux ) ); istrncpy( DATAINST( str_pers ), data_hoje, MAXDATAINST ); istrncpy( NOME( str_pers ), szName, MAXNOME ); istrncpy( NAMECOMPANY( str_pers ), szCompany, MAXCOMPANY ); istrncpy( SERIE( str_pers ), szSerial, MAXSIZESERIAL ); // O tipo da copia ja vem pre-gravado e nao preciso colocar. /* indica que o produto estah personalizado */ PERS( str_pers ) = PE_PERS; check = Criptografa( DATAINST( str_pers ), CHECKSUM( str_pers ) ); CHECKSUM( str_pers )[ 0 ] = ( check & 0xFF00 ) >> 8; CHECKSUM( str_pers )[ 1 ] = ( check & 0x00FF ); if( fwrite( (char *) str_pers, sizeof str_pers, 1, fp ) != 1 ) { fclose( fp ); return( PE_WRITEERROR ); } fclose( fp ); return( PE_OK ); }
void show_char_to_char_0(struct char_data *victim, struct char_data *ch) { char buf[MAX_STRING_LENGTH], message[MAX_STRING_LENGTH]; buf[0] = '\0'; if (IS_SET(victim->comm, COMM_AFK)) strcat(buf, "```!A```@F```OK ``"); if (IS_SET(victim->comm, COMM_BUSY)) strcat(buf, "[`1Busy``] "); if (IS_SET(victim->comm, COMM_CODING)) strcat(buf, "[`@CODING``] "); if (IS_SET(victim->comm, COMM_BUILD)) strcat(buf, "[`3BUILDING``] "); if (IS_AFFECTED(victim, AFF_INVISIBLE)) strcat(buf, "``(`iInvis``) "); if (victim->invis_level >= LEVEL_HERO) strcat(buf, "`8(`wWiZi`8) ``"); if (!IS_NPC(victim)) if (IS_AFFECTED(victim, AFF_HIDE)) strcat(buf, "```4(`hHide```4) ``"); if (IS_AFFECTED(victim, AFF_CHARM)) strcat(buf, "```#(`cCharmed```#) ``"); if (IS_AFFECTED(victim, AFF_PASS_DOOR)) strcat(buf, "```6(```^Translucent```6) ``"); if (IS_AFFECTED(victim, AFF_FAERIE_FIRE)) strcat(buf, "```!(```PPink Aura```!) ``"); if (IS_AFFECTED(victim, AFF_SANCTUARY)) strcat(buf, "(```&White Aura``) "); if (IS_AFFECTED(victim, AFF_DRUID_CALL)) strcat(buf, "(`8Grey Aura``) "); if (IS_AFFECTED(victim, AFF_CALLOUSED)) strcat(buf, "`&(`6C`^a`6ll`^ou`6s`^e`6d`&)`` "); if (is_affected(victim, gsp_web)) strcat(buf, "`8(`2St`@i`2c`@k`2y`8)`` "); if (!IS_NPC(victim) && IS_SET(victim->act, PLR_KILLER)) strcat(buf, "-```1K```!i```1LLER``- "); if (!IS_NPC(victim) && IS_SET(victim->act, PLR_THIEF)) strcat(buf, "-```8TH``i```8EF``- "); if (!IS_NPC(victim) && IS_SET(victim->act, PLR_LINKDEAD)) strcat(buf, "`7[`8LINKDEAD`7] "); if (victim->position == victim->start_pos && victim->long_descr[0] != '\0') { strcat(buf, victim->long_descr); send_to_char(buf, ch); return; } strcat(buf, PERS(victim, ch)); if (!IS_NPC(victim) && !IS_SET(ch->comm, COMM_BRIEF) && victim->position == POS_STANDING && ch->on == NULL) strcat(buf, victim->pcdata->title); switch (victim->position) { case POS_DEAD: strcat(buf, " is ```1D```8E```1A```8D``!!"); break; case POS_MORTAL: strcat(buf, " is mortally wounded."); break; case POS_INCAP: strcat(buf, " is incapacitated."); break; case POS_STUNNED: strcat(buf, " is lying here stunned."); break; case POS_SLEEPING: if (victim->on != NULL) { if (IS_SET(victim->on->value[2], SLEEP_AT)) { sprintf(message, " is sleeping at %s.", victim->on->short_descr); strcat(buf, message); } else if (IS_SET(victim->on->value[2], SLEEP_ON)) { sprintf(message, " is sleeping on %s.", victim->on->short_descr); strcat(buf, message); } else { sprintf(message, " is sleeping in %s.", victim->on->short_descr); strcat(buf, message); } } else { strcat(buf, " is sleeping here."); } break; case POS_RESTING: if (victim->on != NULL) { if (IS_SET(victim->on->value[2], REST_AT)) { sprintf(message, " is resting at %s.", victim->on->short_descr); strcat(buf, message); } else if (IS_SET(victim->on->value[2], REST_ON)) { sprintf(message, " is resting on %s.", victim->on->short_descr); strcat(buf, message); } else { sprintf(message, " is resting in %s.", victim->on->short_descr); strcat(buf, message); } } else { strcat(buf, " is resting here."); } break; case POS_SITTING: if (victim->on != NULL) { if (IS_SET(victim->on->value[2], SIT_AT)) { sprintf(message, " is sitting at %s.", victim->on->short_descr); strcat(buf, message); } else if (IS_SET(victim->on->value[2], SIT_ON)) { sprintf(message, " is sitting on %s.", victim->on->short_descr); strcat(buf, message); } else { sprintf(message, " is sitting in %s.", victim->on->short_descr); strcat(buf, message); } } else { strcat(buf, " is sitting here."); } break; case POS_STANDING: if (victim->on != NULL) { if (IS_SET(victim->on->value[2], STAND_AT)) { sprintf(message, " is standing at %s.", victim->on->short_descr); strcat(buf, message); } else if (IS_SET(victim->on->value[2], STAND_ON)) { sprintf(message, " is standing on %s.", victim->on->short_descr); strcat(buf, message); } else { sprintf(message, " is standing in %s.", victim->on->short_descr); strcat(buf, message); } } else { strcat(buf, " is here."); } break; case POS_FIGHTING: strcat(buf, " is here, `!fighting`` "); if (victim->fighting == NULL) { strcat(buf, "thin air??"); } else if (victim->fighting == ch) { strcat(buf, "```!YOU``!"); } else if (victim->in_room == victim->fighting->in_room) { strcat(buf, PERS(victim->fighting, ch)); strcat(buf, "."); } else { strcat(buf, "someone who left??"); } break; } strcat(buf, "\n\r"); buf[0] = UPPER(buf[0]); send_to_char(buf, ch); return; }
/*** Verifica se a copia pode executar normalmente. Parametros: nenhum Retorno: PE_INSTALA - Copia nao personalizada PE_DATA - Copia Out of date (estouro de data) PE_OK - Pode executar numa boa. ***/ int CheckForRun() { int iIsTimeBomb = FALSE; int check = 0; int chk_check; char data[MAXDATA+1]; char szBufAux[MAXDATA+1]; struct tm *dma; struct tm data_aux; time_t t1; time_t t2; int num_dias; long tloc; if( !iIsDecrypt ){ check = Decriptografa( DATAINST(str_pers), CHECKSUM( str_pers ) ); iIsDecrypt = TRUE; chk_check = ((CHECKSUM( str_pers )[0]&0xFF)<<8) | (CHECKSUM( str_pers )[1] & 0xFF); chk_check &= 0xFFFF; if( check != chk_check ) { return( PE_INSTALA ); } } if( PERS( str_pers ) != PE_PERS ){ return( PE_INSTALA ); // Copia nao personalizada } // Calcula os deslocamentos para DATA, NUMTTY, SERIE, ETC. if( CalculaDeslocamentos( SERIE( str_pers ) ) != PE_OK ){ return( PE_INSTALA ); // algum pau no numero de serie } /* Verificando Time Bomb */ if( DATA( str_pers )[0] == '0' ){ iIsTimeBomb = TRUE; } if( iIsTimeBomb ){ /* Tem time bomb */ t1 = time( &t1 ); /* Dia de hoje em segundos */ memset( &data_aux, 0, sizeof(data_aux) ); // Pego o dia da instalacao do produto e somo o numero de dias // do time bomb. Tudo em segundos. data_aux.tm_year = (1000*(DATAINST(str_pers)[0]-'0')) + (100*(DATAINST(str_pers)[1]-'0')) + (10*(DATAINST(str_pers)[2]-'0')) + DATAINST(str_pers)[3] - '0' - 1900; data_aux.tm_mon = (10* (DATAINST(str_pers)[4]-'0') ) + DATAINST(str_pers)[5] - '0' - 1 ; data_aux.tm_mday = (10* (DATAINST(str_pers)[6]-'0') ) + DATAINST(str_pers)[7] - '0'; t2 = mktime( &data_aux ); /* Dia da instalacao do produto */ if( t1 < t2 ) { /* O sacana mudou a data voltou a data para tras * para rodar o aplicativo. * Pau nele. */ return( PE_DATA ); } /* o dia de instalacao nao guarda horas/minutos e portanto * eh como se tivessemos instalado a meia noite do dia. * por isso, dah um dia de graca. Pegamos agora o * numero de dias do time bomb. */ istrncpychar( data, DATA(str_pers), MAXDATA, '.' ); t2 += ( atol(data) + 1 ) * 3600 * 24; num_dias = CmpDatas( t2, t1 ); if( num_dias < 0 ) { return( PE_DATA ); } return( PE_OK ); } if( isdigit( DATA(str_pers)[0] ) && DATA(str_pers)[0]>'0' ){ /* Eh uma copia demo com data absoluta. VAMOS VERIFICAR!!! */ time( &tloc ); dma = localtime( &tloc ); sprintf( szBufAux, "%04.2d%02.2d", dma->tm_year + 1900, dma->tm_mon + 1 ); // MAXDATA deve ser 6 ; yyyymm. Assim mesmo nos protegemos procurando o '.' istrncpychar( data, DATA(str_pers), MAXDATA, '.' ); if( strncmp( szBufAux, data, MAXDATA ) > 0 ) { return( PE_DATA ); } return( PE_OK ); } // Qualquer outra coisa no campo data indica uma copia // Full (nao demo). Logo, retornamos PE_OK para a galera. return( PE_OK ); }
void broadcast_shout(const CHANNEL_DEFINITION const *channel, struct char_data *sender, const char *argument) { struct descriptor_iterator_filter playing_filter = { .must_playing = true, .skip_character = sender }; struct descriptor_data *d; struct descriptor_data *dpending; struct char_data *actual; struct char_data *receiver; act_new("`1You shout '`!$T`1'``", sender, NULL, argument, TO_CHAR, POS_DEAD, channel->mob_trigger); dpending = descriptor_iterator_start(&playing_filter); while ((d = dpending) != NULL) { dpending = descriptor_iterator(d, &playing_filter); actual = CH(d); receiver = d->character; if (receiver->in_room != NULL && receiver->in_room->area == sender->in_room->area && CHAN_ENABLED(actual, channel->flag) && !CHAN_DENIED(actual, channel->flag)) { act_new("`1$n shouts '`!$t`1'``", sender, argument, receiver, TO_VICT, channel->receiver_position, false); } } } void broadcast_global(const CHANNEL_DEFINITION const *channel, struct char_data *sender, const char *argument) { static char buf[2*MAX_INPUT_LENGTH]; struct descriptor_iterator_filter playing_filter = { .must_playing = true, .skip_character = sender }; struct descriptor_data *dpending; struct descriptor_data *d; struct char_data *actual; (void)snprintf(buf, 2 * MAX_INPUT_LENGTH, "``$n %s: %s``", channel->print_name, argument); if (sender != NULL) { act_new("$n `2I`8M`2P`8:`` $t``", sender, argument, NULL, TO_CHAR, POS_DEAD, channel->mob_trigger); } dpending = descriptor_iterator_start(&playing_filter); while ((d = dpending) != NULL) { dpending = descriptor_iterator(d, &playing_filter); actual = CH(d); (void)snprintf(buf, 2 * MAX_INPUT_LENGTH, "``$t %s: %s``", channel->print_name, argument); if (CHAN_ENABLED(actual, channel->flag) && !CHAN_DENIED(actual, channel->flag)) { act_new(buf, sender, argument, d->character, TO_VICT, channel->receiver_position, false); } } } void broadcast_say(const CHANNEL_DEFINITION const *channel, struct char_data *sender, const char *argument) { #define VERBSIZE 20 static char buf[2*MAX_INPUT_LENGTH]; static char verb[VERBSIZE]; int len = strlen(argument); int puncpos = len - 1; int puncpos2 = len - 2; switch (puncpos) { case '!': { if (puncpos2 >= 0) { switch (argument[puncpos2]) { case '!': snprintf(verb, VERBSIZE, "%s", "shout"); break; case '?': snprintf(verb, VERBSIZE, "%s", "angrily demand"); break; default: snprintf(verb, VERBSIZE, "%s", "exclaim"); break; } } else { snprintf(verb, VERBSIZE, "%s", "exclaim"); } break; } case '?': { if (puncpos2 >= 0) { switch (argument[puncpos2]) { case '?': snprintf(verb, VERBSIZE, "%s", "in confusion, ask"); break; case '!': snprintf(verb, VERBSIZE, "%s", "angrily demand"); break; default: snprintf(verb, VERBSIZE, "%s", "ask"); break; } } else { snprintf(verb, VERBSIZE, "%s", "ask"); } break; } default: snprintf(verb, VERBSIZE, "%s", "say"); break; } (void)snprintf(buf, 2 * MAX_INPUT_LENGTH, "`7You %s '`s$T`7'``", verb); act_new(buf, sender, NULL, argument, TO_CHAR, POS_RESTING, channel->mob_trigger); (void)snprintf(buf, 2 * MAX_INPUT_LENGTH, "`7$n %ss '`s$T`7'``", verb); act_new(buf, sender, NULL, argument, TO_ROOM, channel->receiver_position, false); } void broadcast_emote(const CHANNEL_DEFINITION const *channel, struct char_data *sender, const char *argument) { act_new("$n $T", sender, NULL, emote_parse(argument), TO_CHAR, POS_RESTING, channel->mob_trigger); act_new("$n $T", sender, NULL, emote_parse(argument), TO_ROOM, channel->receiver_position, false); } void broadcast_pmote(const CHANNEL_DEFINITION const *channel, struct char_data *sender, const char *argument) { struct char_data *vch; char *letter; char *name; char last[MAX_INPUT_LENGTH]; char temp[MAX_STRING_LENGTH]; int matches = 0; act_new("$n $t", sender, argument, NULL, TO_CHAR, POS_DEAD, channel->mob_trigger); for (vch = sender->in_room->people; vch != NULL; vch = vch->next_in_room) { if (vch->desc == NULL || vch == sender) continue; if ((letter = strstr(argument, vch->name)) == NULL) { act_new("$N $t", vch, argument, sender, TO_CHAR, channel->receiver_position, false); continue; } strcpy(temp, argument); temp[strlen(argument) - strlen(letter)] = '\0'; last[0] = '\0'; name = vch->name; for (; *letter != '\0'; letter++) { if (*letter == '\'' && matches == (int)strlen(vch->name)) { strcat(temp, "r"); continue; } if (*letter == 's' && matches == (int)strlen(vch->name)) { matches = 0; continue; } if (matches == (int)strlen(vch->name)) matches = 0; if (*letter == *name) { matches++; name++; if (matches == (int)strlen(vch->name)) { strcat(temp, "you"); last[0] = '\0'; name = vch->name; continue; } strncat(last, letter, 1); continue; } matches = 0; strcat(temp, last); strncat(temp, letter, 1); last[0] = '\0'; name = vch->name; } act_new("$N $t", vch, temp, sender, TO_CHAR, channel->receiver_position, false); } } void broadcast_smote(const CHANNEL_DEFINITION const *channel, struct char_data *sender, const char *argument) { struct char_data *vch; char *letter; char *name; char last[MAX_INPUT_LENGTH]; char temp[MAX_STRING_LENGTH]; int matches = 0; if (strstr(argument, sender->name) == NULL) { send_to_char("You must include your name in an smote.\n\r", sender); return; } printf_to_char(sender, "%s\n\r", argument); for (vch = sender->in_room->people; vch != NULL; vch = vch->next_in_room) { if (vch->desc == NULL || vch == sender) continue; if ((letter = strstr(argument, vch->name)) == NULL) { printf_to_char(vch, "%s\n\r", argument); continue; } strcpy(temp, argument); temp[strlen(argument) - strlen(letter)] = '\0'; last[0] = '\0'; name = vch->name; for (; *letter != '\0'; letter++) { if (*letter == '\'' && matches == (int)strlen(vch->name)) { strcat(temp, "r"); continue; } if (*letter == 's' && matches == (int)strlen(vch->name)) { matches = 0; continue; } if (matches == (int)strlen(vch->name)) matches = 0; if (*letter == *name) { matches++; name++; if (matches == (int)strlen(vch->name)) { strcat(temp, "you"); last[0] = '\0'; name = vch->name; continue; } strncat(last, letter, 1); continue; } matches = 0; strcat(temp, last); strncat(temp, letter, 1); last[0] = '\0'; name = vch->name; } printf_to_char(vch, "%s\n\r", temp); } } void broadcast_reply(const CHANNEL_DEFINITION const *channel, struct char_data *sender, const char *argument) { struct char_data *whom; if ((whom = sender->reply) == NULL) { send_to_char("They aren't here.\n\r", sender); return; } if (send_tell(sender, whom, argument)) { whom->reply = sender; } return; } void broadcast_gtell(const CHANNEL_DEFINITION const *channel, struct char_data *sender, const char *argument) { struct char_data *gch; for (gch = char_list; gch != NULL; gch = gch->next) { if (is_same_group(gch, sender)) { printf_to_char(gch, "```5%s tells the group '```P%s```5'``\n\r", sender->name, argument); } } } /*** * Targetted Broadcasters */ void broadcast_sayto(const CHANNEL_DEFINITION const *channel, struct char_data *sender, struct char_data *whom, const char *argument) { struct descriptor_iterator_filter playing_filter = { .must_playing = true, .skip_character = sender }; struct descriptor_data *d; struct descriptor_data *dpending; if (IS_SET(whom->comm, COMM_AFK) && IS_NPC(whom)) { act("$E is `!A`@F`OK``, and is unable to pay attention.", sender, NULL, whom, TO_CHAR); return; } printf_to_char(sender, "``You say to %s '`P%s``'\n\r", whom->name, argument); printf_to_char(whom, "``%s says to you '`P%s``'\n\r", sender->name, argument); dpending = descriptor_iterator_start(&playing_filter); while ((d = dpending) != NULL) { dpending = descriptor_iterator(d, &playing_filter); if (d->character->in_room == sender->in_room && d->character->position != POS_SLEEPING && d->character != whom) { printf_to_char(d->character, "%s says to %s, '`P%s``'.\n\r", PERS(sender, d->character), PERS(whom, d->character), argument); } } } void broadcast_tell(const CHANNEL_DEFINITION const *channel, struct char_data *sender, struct char_data *whom, const char *argument) { if (send_tell(sender, whom, argument)) { whom->reply = sender; if (!IS_NPC(sender) && IS_NPC(whom) && HAS_TRIGGER(whom, TRIG_SPEECH)) { mp_act_trigger(argument, whom, sender, NULL, NULL, TRIG_SPEECH); } } } /*** * Util */ bool is_ignoring(struct char_data *sender, struct char_data *receiver) { int pos; bool found = false; if (IS_NPC(receiver)) { return false; } for (pos = 0; pos < MAX_IGNORE; pos++) { if (receiver->pcdata->ignore[pos] == NULL) { break; } if (!str_cmp(sender->name, receiver->pcdata->ignore[pos])) { found = true; break; } } return found; } bool send_tell(struct char_data *sender, struct char_data *whom, const char* argument) { static char buf[MAX_STRING_LENGTH]; if (!IS_IMMORTAL(whom) && !IS_AWAKE(sender)) { send_to_char("In your dreams, or what?\n\r", sender); return false; } if (IS_SET(whom->comm, COMM_AFK)) { if (IS_NPC(whom)) { act("$E is ```!A```@F```OK``, and not receiving tells.", sender, NULL, whom, TO_CHAR); return false; } act("$E is ```!A```@F```OK``, but your tell will go through when $E returns.", sender, NULL, whom, TO_CHAR); (void)snprintf(buf, 2 * MAX_INPUT_LENGTH, "```@%s tells you '`t%s```@'``\n\r", PERS(sender, whom), argument); buf[0] = UPPER(buf[0]); add_buf(whom->pcdata->buffer, buf); return true; } if (whom->desc == NULL && !IS_NPC(whom)) { act("$N seems to have misplaced $S link...try again later.", sender, NULL, whom, TO_CHAR); (void)snprintf(buf, 2 * MAX_INPUT_LENGTH, "```@%s tells you '`t%s```@'``\n\r", PERS(sender, whom), argument); buf[0] = UPPER(buf[0]); add_buf(whom->pcdata->buffer, buf); return true; } act_new("`@You tell $N '`r$t`@'``", sender, argument, whom, TO_CHAR, POS_DEAD, false); act_new("`@$n tells you '`r$t`@'``", sender, argument, whom, TO_VICT, POS_DEAD, false); return true; } char *emote_parse(const char *argument) { static char target[MAX_STRING_LENGTH]; char buf[MAX_STRING_LENGTH]; int i = 0, arg_len = 0; int flag = false; /* Reset target each time before use */ memset(target, 0x00, sizeof(target)); arg_len = (int)strlen(argument); for (i = 0; i < arg_len; i++) { if (argument[i] == '"' && flag == false) { flag = true; (void)snprintf(buf, MAX_STRING_LENGTH, "%c", argument[i]); strcat(target, buf); strcat(target, "`P"); continue; } else if (argument[i] == '"' && flag == true) { flag = false; strcat(target, "``"); (void)snprintf(buf, MAX_STRING_LENGTH, "%c", argument[i]); strcat(target, buf); continue; } else { (void)snprintf(buf, MAX_STRING_LENGTH, "%c", argument[i]); strcat(target, buf); } } if (flag) { strcat(target, "``"); (void)snprintf(buf, MAX_STRING_LENGTH, "%c", '"'); strcat(target, buf); } return target; }
void do_insert(CHAR_DATA *ch, char *argument) { OBJ_DATA *obj, *obj_next; OBJ_DATA *obj2; OBJ_DATA *machine, *machine_next; int reward; bool found; CHAR_DATA *to,*to_next; if(argument[0] == '\0') { send_to_one(ch,"Insert what?"); return; } if( ( obj = get_obj_carry(ch,argument,ch)) == NULL) { send_to_one(ch,"You don't have that to insert."); return; } found = FALSE; for(machine = ch->in_room->contents; machine; machine = machine_next) { machine_next = machine->next_content; if( machine->item_type == ITEM_TOKEN && machine->value[4] == 1) { found = TRUE; if( obj->item_type != ITEM_TOKEN) { send_to_one(ch,"You can't insert that."); return; } //alrighty, let's gamble send_to_one(ch,"You insert %s into %s.",obj->short_descr,machine->short_descr); for(to = ch->in_room->people; to; to = to_next) { to_next = to->next_in_room; if(to->in_room == ch->in_room && to != ch) { send_to_one(to,"%s inserts %s into %s.",PERS(ch,to), obj->short_descr,machine->short_descr); } } ch->inserted = obj; machine->value[2] += number_range(75,125); if(chance(obj->value[1])) { if(chance(45) && obj->value[0] != 4)//45 percent chance you win a new token generate_token(ch); else if( chance(5) && machine->value[2] != 0 && obj->value[0] == 0) //5 percent chance you hit jackpot with a normal token { reward = machine->value[2]; send_to_one(ch,"You hit the {RJ{WA{YC{BK{MP{CO{GT{x!"); send_to_one(ch,"You win {Y%d gold!{x",reward); for(to = ch->in_room->people; to; to = to_next) { to_next = to->next_in_room; if(to->in_room == ch->in_room && to != ch) { send_to_one(to,"%s just hit the {RJ{WA{YC{BK{MP{CO{GT{x!\n\r%s won {Y%d gold{x!",PERS(ch,to), PERS(ch,to), reward); } } ch->gold += reward; machine->value[2] = 0; } else { reward = number_range(obj->value[3],obj->value[2]); send_to_one(ch,"You win %d %s!",reward, token_table[obj->value[0]].reward); if (token_table[obj->value[0]].value == 1) ch->gold += reward; else if(token_table[obj->value[0]].value == 2) ch->practice += reward; else if(token_table[obj->value[0]].value == 3) ch->train += reward; else if(token_table[obj->value[0]].value == 4) ch->pcdata->questpoints += reward; else if(token_table[obj->value[0]].value == 5) gain_exp(ch,reward); } obj_from_char(obj); extract_obj(obj); } else { send_to_one(ch,"You lost your %s token.",token_table[obj->value[0]].name); obj_from_char(obj); extract_obj(obj); return; } } } if(!found) { send_to_one(ch,"You see nothing to insert it into."); return; } return; }