static int sock_arg(conn_t *conn) { if (conn->ctx.numargs < 1) return 0; /* CANCEL <name> [<cmd>] */ if (!strcmp(conn->ctx.arglist[0], "CANCEL")) { if (conn->ctx.numargs < 3) cancel_timer(conn->ctx.arglist[1], NULL); else cancel_timer(conn->ctx.arglist[1], conn->ctx.arglist[2]); send_to_one(conn, "OK\n"); return 1; } if (conn->ctx.numargs < 3) return 0; /* START <name> <length> */ if (!strcmp(conn->ctx.arglist[0], "START")) { start_timer(conn->ctx.arglist[1], conn->ctx.arglist[2]); send_to_one(conn, "OK\n"); return 1; } /* unknown */ return 0; }
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; }
void do_iclan( CHAR_DATA *ch, char *argument ) { char arg[MSL]; // char arg2[MSL]; int clan; DESCRIPTOR_DATA *d; argument = one_argument(argument,arg); // argument = one_argument(argument,ar2); if(IS_NPC(ch)) return; if( argument[0] == '\0' || arg[0] == '\0') //|| arg2[0] == '\0') { send_to_one(ch,"Syntax: iclan <clan> <message>"); return; } clan = clan_lookup(arg); if(clan == -1) { send_to_one(ch,"There is no such clan."); return; } if(clan == ch->clan) { send_to_one(ch,"How about you use YOUR clan channel?"); return; } send_to_one(ch,"You [ %s ] clan '%s'",clan_table[clan].name,argument); for(d = descriptor_list; d; d = d->next) { if(d->connected == CON_PLAYING && d->character != ch && d->character->clan == clan && !IS_SET(d->character->comm,COMM_NOCLAN) && !IS_SET(d->character->comm,COMM_QUIET)) { send_to_one(d->character,"%s clans '%s'",ch->name,argument); } } return; }
/* clan channels */ void do_clantalk( CHAR_DATA *ch, char *argument ) { char buf[MAX_STRING_LENGTH]; DESCRIPTOR_DATA *d; if (!is_clan(ch)) { send_to_char("You aren't in a clan.\n\r",ch); return; } if ( argument[0] == '\0' ) { if (IS_SET(ch->comm,COMM_NOCLAN)) { send_to_char("Clan channel is now ON\n\r",ch); REMOVE_BIT(ch->comm,COMM_NOCLAN); } else { send_to_char("Clan channel is now OFF\n\r",ch); SET_BIT(ch->comm,COMM_NOCLAN); } return; } if (IS_SET(ch->comm,COMM_NOCHANNELS)) { send_to_char("The gods have revoked your channel priviliges.\n\r",ch); return; } REMOVE_BIT(ch->comm,COMM_NOCLAN); if(!IS_NPC(ch) && ch->pcdata->condition[COND_DRUNK] > 10) argument = makedrunk(argument,ch); sprintf( buf, "You clan '%s'{x\n\r", argument ); send_to_char( buf, ch ); sprintf( buf, "$n clans '%s'{x", argument ); for ( d = descriptor_list; d != NULL; d = d->next ) { if ( d->connected == CON_PLAYING && is_same_clan(ch,d->character) && is_same_clan(ch,d->character) && !IS_SET(d->character->comm,COMM_NOCLAN) && !IS_SET(d->character->comm,COMM_QUIET) ) { act_new("$n clans '$t'{x",ch,argument,d->character,TO_VICT,POS_DEAD); } if(IS_SET(d->character->comm,COMM_ALLCLAN) && d->connected == CON_PLAYING && d->character != ch && !is_same_clan(d->character, ch)) { send_to_one(d->character,"[ %s ] %s clans '%s'{x",clan_table[ch->clan].name,ch->name, argument); } } return; }
void do_hero( CHAR_DATA *ch, char *argument ) { // char buf[MAX_STRING_LENGTH]; DESCRIPTOR_DATA *d; if (ch->level < LEVEL_HERO) { send_to_one(ch, "You must be a hero to use this command."); return; } if (argument[0] == '\0' ) { TOGGLE_BIT(ch->comm,COMM_NOHERO); send_to_one(ch, "Hero channel toggled."); return; } else { if (IS_SET(ch->comm,COMM_QUIET)|| IS_SET(ch->comm,COMM_NOCHANNELS) || IS_SET(ch->comm, COMM_NOHERO)) { send_to_one(ch, "You can't herotalk like that!"); return; } } send_to_one( ch, "{B[{Y%s{B] %s{x", ch->name, argument ); for ( d = descriptor_list; d != NULL; d = d->next ) { CHAR_DATA *victim; victim = d->original ? d->original : d->character; if ( d->connected == CON_PLAYING && d->character != ch && d->character->level >= LEVEL_HERO && !IS_SET(victim->comm,COMM_NOHERO) && !IS_SET(victim->comm,COMM_QUIET) ) { send_to_one(d->character,"{B[{Y%s{B] %s{x", ch->name,argument); } } }
void do_allclan( CHAR_DATA *ch, char *argument ) { if(IS_NPC(ch)) return; if(!IS_SET(ch->comm,COMM_ALLCLAN)) { SET_BIT(ch->comm,COMM_ALLCLAN); send_to_one(ch,"All clan channels will now be heard."); return; } else { REMOVE_BIT(ch->comm,COMM_ALLCLAN); send_to_one(ch,"You cease listening to all clans."); return; } return; }
static int cmd_dump_conn(conn_t *conn) { cmdlist_t *cmd; for (cmd = cmdhead; cmd; cmd = cmd->next) { if (!send_to_one(conn, "ADDCMD %s\n", cmd->name)) { return 0; } } return 1; }
//Keith's compressed channels void do_auction( CHAR_DATA *ch, char *argument ) { // char buf[MAX_STRING_LENGTH]; DESCRIPTOR_DATA *d; if (argument[0] == '\0' ) { TOGGLE_BIT(ch->comm,COMM_NOAUCTION); send_to_one(ch, "{aAuction channel toggled.{x"); return; } else /* auction message sent, turn auction on if it is off */ { if (IS_SET(ch->comm,COMM_QUIET)|| IS_SET(ch->comm,COMM_NOCHANNELS) || IS_SET(ch->comm, COMM_NOAUCTION)) { send_to_char("You can't auction like that!\n\r",ch); return; } } send_to_one( ch, "{aYou auction {A'%s{a'{x\n\r", argument ); for ( d = descriptor_list; d != NULL; d = d->next ) { CHAR_DATA *victim; victim = d->original ? d->original : d->character; if ( d->connected == CON_PLAYING && d->character != ch && !IS_SET(victim->comm,COMM_NOAUCTION) && !IS_SET(victim->comm,COMM_QUIET) ) { send_to_one(d->character,"{a%s auctions '{A%s{a'{x", ch->name,argument); } } }
void room::send_server_message(const char* message, network::connection sock, simple_wml::document* docptr) const { simple_wml::document docbuf; if(docptr == NULL) { docptr = &docbuf; } simple_wml::document& doc = *docptr; simple_wml::node& msg = doc.root().add_child("message"); msg.set_attr("sender", "server"); msg.set_attr_dup("message", message); if(sock) { send_to_one(doc, sock, "message"); } }
static int sock_read(conn_t *conn) { int i, ret; char ch; for (i = 0; i < US_MAX_READ; i++) { ret = read(conn->fd, &ch, 1); if (ret < 1) { /* short read = no parsing, come back later */ if ((ret == -1) && (errno == EAGAIN)) return 0; /* some other problem */ return -1; /* error */ } ret = pconf_char(&conn->ctx, ch); if (ret == 0) /* nothing to parse yet */ continue; if (ret == -1) { upslogx(LOG_NOTICE, "Parse error on sock: %s", conn->ctx.errmsg); return 0; /* nothing parsed */ } /* try to use it, and complain about unknown commands */ if (!sock_arg(conn)) { log_unknown(conn->ctx.numargs, conn->ctx.arglist); send_to_one(conn, "ERR UNKNOWN\n"); } return 1; /* we did some work */ } return 0; /* fell out without parsing anything */ }
static int sock_arg(conn_t *conn, int numarg, char **arg) { if (numarg < 1) { return 0; } if (!strcasecmp(arg[0], "DUMPALL")) { /* first thing: the staleness flag */ if ((stale == 1) && !send_to_one(conn, "DATASTALE\n")) { return 1; } if (!st_tree_dump_conn(dtree_root, conn)) { return 1; } if (!cmd_dump_conn(conn)) { return 1; } if ((stale == 0) && !send_to_one(conn, "DATAOK\n")) { return 1; } send_to_one(conn, "DUMPDONE\n"); return 1; } if (!strcasecmp(arg[0], "PING")) { send_to_one(conn, "PONG\n"); return 1; } if (numarg < 2) { return 0; } /* INSTCMD <cmdname> [<value>]*/ if (!strcasecmp(arg[0], "INSTCMD")) { /* try the new handler first if present */ if (upsh.instcmd) { if (numarg > 2) { upsh.instcmd(arg[1], arg[2]); return 1; } upsh.instcmd(arg[1], NULL); return 1; } upslogx(LOG_NOTICE, "Got INSTCMD, but driver lacks a handler"); return 1; } if (numarg < 3) { return 0; } /* SET <var> <value> */ if (!strcasecmp(arg[0], "SET")) { /* try the new handler first if present */ if (upsh.setvar) { upsh.setvar(arg[1], arg[2]); return 1; } upslogx(LOG_NOTICE, "Got SET, but driver lacks a handler"); return 1; } /* unknown */ return 0; }
static int st_tree_dump_conn(st_tree_t *node, conn_t *conn) { int ret; enum_t *etmp; range_t *rtmp; if (!node) { return 1; /* not an error */ } if (node->left) { ret = st_tree_dump_conn(node->left, conn); if (!ret) { return 0; /* write failed in the child */ } } if (!send_to_one(conn, "SETINFO %s \"%s\"\n", node->var, node->val)) { return 0; /* write failed, bail out */ } /* send any enums */ for (etmp = node->enum_list; etmp; etmp = etmp->next) { if (!send_to_one(conn, "ADDENUM %s \"%s\"\n", node->var, etmp->val)) { return 0; } } /* send any ranges */ for (rtmp = node->range_list; rtmp; rtmp = rtmp->next) { if (!send_to_one(conn, "ADDRANGE %s %i %i\n", node->var, rtmp->min, rtmp->max)) { return 0; } } /* provide any auxiliary data */ if (node->aux) { if (!send_to_one(conn, "SETAUX %s %d\n", node->var, node->aux)) { return 0; } } /* finally report any flags */ if (node->flags) { char flist[SMALLBUF]; /* build the list */ snprintf(flist, sizeof(flist), "%s", node->var); if (node->flags & ST_FLAG_RW) { snprintfcat(flist, sizeof(flist), " RW"); } if (node->flags & ST_FLAG_STRING) { snprintfcat(flist, sizeof(flist), " STRING"); } if (!send_to_one(conn, "SETFLAGS %s\n", flist)) { return 0; } } if (node->right) { return st_tree_dump_conn(node->right, conn); } return 1; /* everything's OK here ... */ }
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; }
void do_channels( CHAR_DATA *ch, char *argument) { char buf[MAX_STRING_LENGTH]; /* lists all channels and their status */ send_to_char(" channel status\n\r",ch); send_to_char("---------------------\n\r",ch); send_to_char("{dgossip{x ",ch); if (!IS_SET(ch->comm,COMM_NOGOSSIP)) send_to_char("ON\n\r",ch); else send_to_char("OFF\n\r",ch); send_to_char("{aauction{x ",ch); if (!IS_SET(ch->comm,COMM_NOAUCTION)) send_to_char("ON\n\r",ch); else send_to_char("OFF\n\r",ch); send_to_char("{emusic{x ",ch); if (!IS_SET(ch->comm,COMM_NOMUSIC)) send_to_char("ON\n\r",ch); else send_to_char("OFF\n\r",ch); send_to_char("{qQ{x/{fA{x ",ch); if (!IS_SET(ch->comm,COMM_NOQUESTION)) send_to_char("ON\n\r",ch); else send_to_char("OFF\n\r",ch); send_to_char("{hQuote{x ",ch); if (!IS_SET(ch->comm,COMM_NOQUOTE)) send_to_char("ON\n\r",ch); else send_to_char("OFF\n\r",ch); send_to_char("city ",ch); if(!IS_SET(ch->comm, COMM_NOCITY)) send_to_one(ch,"ON"); else send_to_one(ch,"OFF"); send_to_char("{tgrats{x ",ch); if (!IS_SET(ch->comm,COMM_NOGRATS)) send_to_char("ON\n\r",ch); else send_to_char("OFF\n\r",ch); if (is_granted_name(ch,"immtalk") || is_granted_name(ch,":")) { send_to_char("{igod channel{x ",ch); if(!IS_SET(ch->comm,COMM_NOWIZ)) send_to_char("ON\n\r",ch); else send_to_char("OFF\n\r",ch); } if (ch->level >= LEVEL_HERO) { send_to_char("Hero channel ",ch); if(!IS_SET(ch->comm,COMM_NOHERO)) send_to_one(ch,"ON"); else send_to_one(ch,"OFF"); } send_to_char("{tshouts{x ",ch); if (!IS_SET(ch->comm,COMM_SHOUTSOFF)) send_to_char("ON\n\r",ch); else send_to_char("OFF\n\r",ch); send_to_char("{ktells{x ",ch); if (!IS_SET(ch->comm,COMM_DEAF)) send_to_char("ON\n\r",ch); else send_to_char("OFF\n\r",ch); send_to_char("{tquiet mode{x ",ch); if (IS_SET(ch->comm,COMM_QUIET)) send_to_char("ON\n\r",ch); else send_to_char("OFF\n\r",ch); if (IS_SET(ch->comm,COMM_AFK)) send_to_char("You are AFK.\n\r",ch); if (IS_SET(ch->comm,COMM_SNOOP_PROOF)) send_to_char("You are immune to snooping.\n\r",ch); if (ch->lines != PAGELEN) { if (ch->lines) { sprintf(buf,"You display %d lines of scroll.\n\r",ch->lines+2); send_to_char(buf,ch); } else send_to_char("Scroll buffering is off.\n\r",ch); } if (ch->prompt != NULL) { sprintf(buf,"Your current prompt is: %s\n\r",ch->prompt); send_to_char(buf,ch); } if (IS_SET(ch->comm,COMM_NOSHOUT)) send_to_char("You cannot shout.\n\r",ch); if (IS_SET(ch->comm,COMM_NOTELL)) send_to_char("You cannot use tell.\n\r",ch); if (IS_SET(ch->comm,COMM_NOCHANNELS)) send_to_char("You cannot use channels.\n\r",ch); if (IS_SET(ch->comm,COMM_NOEMOTE)) send_to_char("You cannot show emotions.\n\r",ch); }
void do_deaf( CHAR_DATA *ch, char *argument) { TOGGLE_BIT(ch->comm,COMM_DEAF); send_to_one(ch, "Deaf mode toggled."); }
void do_afk ( CHAR_DATA *ch, char * argument) { TOGGLE_BIT(ch->comm,COMM_AFK); send_to_one(ch, "AFK mode toggled."); }
void do_quiet ( CHAR_DATA *ch, char * argument) { TOGGLE_BIT(ch->comm,COMM_QUIET); send_to_one(ch, "Quiet mode toggled."); }
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_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; }