/* * Called by go() and move() */ void move_user(UR_OBJECT user, RM_OBJECT rm, int teleport) { RM_OBJECT old_room; if (teleport != 2 && !has_room_access(user, rm)) { write_user(user, "That room is currently private, you cannot enter.\n"); return; } /* Reset invite room if in it */ if (user->invite_room == rm) { user->invite_room = NULL; *user->invite_by = '\0'; } if (user->vis) { switch (teleport) { case 0: vwrite_room(rm, "%s~RS %s.\n", user->recap, user->in_phrase); vwrite_room_except(user->room, user, "%s~RS %s to the %s.\n", user->recap, user->out_phrase, rm->name); break; case 1: vwrite_room(rm, "%s~RS ~FC~OLappears in an explosion of blue magic!\n", user->recap); vwrite_room_except(user->room, user, "%s~RS ~FC~OLchants a spell and vanishes into a magical blue vortex!\n", user->recap); break; case 2: write_user(user, "\n~FC~OLA giant hand grabs you and pulls you into a magical blue vortex!\n"); vwrite_room(rm, "%s~RS ~FC~OLfalls out of a magical blue vortex!\n", user->recap); #ifdef NETLINKS if (!release_nl(user)) #endif { vwrite_room_except(user->room, user, "~FC~OLA giant hand grabs~RS %s~RS ~FC~OLwho is pulled into a magical blue vortex!\n", user->recap); } break; } } else if (user->level < GOD) { write_room(rm, invisenter); write_room_except(user->room, invisleave, user); } old_room = user->room; user->room = rm; reset_access(old_room); look(user); }
/* * Change whether a rooms access is fixed or not */ void change_room_fix(UR_OBJECT user, int fix) { RM_OBJECT rm; const char *name; if (word_count < 2) { rm = user->room; } else { rm = get_room(word[1]); if (!rm) { write_user(user, nosuchroom); return; } } if (fix) { if (is_fixed_room(rm)) { if (rm == user->room) { write_user(user, "This room's access is already fixed.\n"); } else { write_user(user, "That room's access is already fixed.\n"); } return; } } else { if (!is_fixed_room(rm)) { if (rm == user->room) { write_user(user, "This room's access is already unfixed.\n"); } else { write_user(user, "That room's access is already unfixed.\n"); } return; } } rm->access ^= FIXED; reset_access(rm); write_syslog(SYSLOG, 1, "%s %s access to room %s.\n", user->name, is_fixed_room(rm) ? "FIXED" : "UNFIXED", rm->name); name = user->vis ? user->recap : invisname; if (user->room == rm) { vwrite_room_except(rm, user, "%s~RS has %s~RS access for this room.\n", name, is_fixed_room(rm) ? "~FRFIXED" : "~FGUNFIXED"); } else { vwrite_room(rm, "This room's access has been %s~RS.\n", is_fixed_room(rm) ? "~FRFIXED" : "~FGUNFIXED"); } vwrite_user(user, "Access for room %s is now %s~RS.\n", rm->name, is_fixed_room(rm) ? "~FRFIXED" : "~FGUNFIXED"); }
/*** See if timed reboot or shutdown is underway ***/ void check_reboot_shutdown(void) { int secs; char *w[]={ "~FRVypnutie","~FYRestart" }; set_crash(); if (amsys->rs_user==NULL) return; amsys->rs_countdown-=amsys->heartbeat; if (amsys->rs_countdown<=0) talker_shutdown(amsys->rs_user,NULL,amsys->rs_which); /* Print countdown message every minute unless we have less than 1 minute to go when we print every 10 secs */ secs=(int)(time(0)-amsys->rs_announce); if (amsys->rs_countdown>=60 && (secs>=60 || amsys->rs_countdown%60==0)) { vwrite_room(NULL, "~OLSYSTEM: %s za %d minut%s, %d sekund%s.\n", w[amsys->rs_which], amsys->rs_countdown/60, grm_num(1, amsys->rs_countdown/60), amsys->rs_countdown%60, grm_num(1, amsys->rs_countdown%60)); amsys->rs_announce=time(0); } if (amsys->rs_countdown<60 && (secs>=10 || amsys->rs_countdown<=10)) { vwrite_room(NULL,"~OLSYSTEM: %s za %d sekund%s.\n",w[amsys->rs_which],amsys->rs_countdown,grm_num(1, amsys->rs_countdown)); amsys->rs_announce=time(0); } }
void pl00x100_respond(UR_OBJECT user, char *str) { char fname[500], line[150], *name; int i=0, num=0, total=0; FILE *fp; set_crash(); fname[0]='\0'; line[0]='\0'; if (word_count<2) { write_user(user,"The Magic EightBall will only respond to a question.\n"); return; } if (user->vis) name=user->name; else name=invisname; sprintf(fname,"%s/eightball.8", PLFILES); if (!(fp=fopen(fname,"r"))) { write_user(user,"EightBall: Sorry! Response file was not found.\n"); return; } fscanf(fp,"%d\n",&total); /* total file entries */ num=rand()%total; num++; /* Have to increase because the rand() might leave it 0. */ /* get the line from the file that contains the random response */ for (i=0; (i<num && !feof(fp)); i++) fgets(line, 161, fp); fclose(fp); line[strlen(line)-1]='\0'; terminate(line); /* write question to users */ vwrite_user(user, "%s[You ask the EightBall]%s: %s\n", colors[CSELF], colors[CTEXT], str); vwrite_room_except(user->room, user, "%s[%s asks the EightBall]%s: %s\n", colors[CUSER], name, colors[CTEXT], str); record(user->room, text); /* write response to room */ vwrite_room(user->room, "~FG[The Magic EightBall]%s: %s\n", colors[CTEXT], line); record(user->room, text); }
/* * Ask to be let into a private room */ void letmein(UR_OBJECT user) { RM_OBJECT rm; int i; if (word_count < 2) { write_user(user, "Knock on what door?\n"); return; } rm = get_room(word[1]); if (!rm) { write_user(user, nosuchroom); return; } if (rm == user->room) { vwrite_user(user, "You are already in the %s!\n", rm->name); return; } for (i = 0; i < MAX_LINKS; ++i) if (user->room->link[i] == rm) { break; } if (i >= MAX_LINKS) { vwrite_user(user, "The %s is not adjoined to here.\n", rm->name); return; } if (!is_private_room(rm)) { vwrite_user(user, "The %s is currently public.\n", rm->name); return; } vwrite_user(user, "You knock asking to be let into the %s.\n", rm->name); vwrite_room_except(user->room, user, "%s~RS knocks asking to be let into the %s.\n", user->recap, rm->name); vwrite_room(rm, "%s~RS knocks asking to be let in.\n", user->recap); }
/* * Shoot another user... Fun! Fun! Fun! ;) */ void shoot_user(UR_OBJECT user) { UR_OBJECT user2; RM_OBJECT rm; int prob1, prob2; rm = get_room_full(amsys->default_shoot); if (!rm) { write_user(user, "There is nowhere that you can shoot.\n"); return; } if (user->room != rm) { vwrite_user(user, "Do not be shooting in a public place. Go to the ~OL%s~RS to play.\n", rm->name); return; } if (word_count < 2) { if (!user->bullets) { vwrite_room_except(rm, user, "%s~RS's gun goes *click* as they pull the trigger.\n", user->recap); write_user(user, "Your gun goes *click* as you pull the trigger.\n"); return; } vwrite_room_except(rm, user, "%s~RS fires their gun off into the air.\n", user->recap); write_user(user, "You fire your gun off into the air.\n"); --user->bullets; return; } prob1 = rand() % 100; prob2 = rand() % 100; user2 = get_user_name(user, word[1]); if (!user2) { write_user(user, notloggedon); return; } if (!user->vis) { write_user(user, "Be fair! At least make a decent target--do not be invisible!\n"); return; } if ((!user2->vis && user2->level < user->level) || user2->room != rm) { write_user(user, "You cannot see that person around here.\n"); return; } if (user == user2) { write_user(user, "Watch it! You might shoot yourself in the foot!\n"); return; } if (!user->bullets) { vwrite_room_except(rm, user, "%s~RS's gun goes *click* as they pull the trigger.\n", user->recap); write_user(user, "Your gun goes *click* as you pull the trigger.\n"); return; } if (prob1 > prob2) { vwrite_room(rm, "A bullet flies from %s~RS's gun and ~FR~OLhits~RS %s.\n", user->recap, user2->recap); --user->bullets; ++user->hits; --user2->hps; write_user(user2, "~FR~OLYou have been hit!\n"); write_user(user, "~FG~OLGood shot!\n"); if (user2->hps < 1) { ++user2->deaths; vwrite_user(user, "\nYou have won the shoot out, %s~RS is dead! You may now rejoice!\n", user2->recap); write_user(user2, "\nYou have received a fatal wound, and you feel your warm ~FRblood ~OLooze~RS out of you.\n"); write_user(user2, "The room starts to fade and grow grey...\n"); write_user(user2, "In the bleak mist of Death's shroud you see a man walk towards you.\n"); write_user(user2, "The man is wearing a tall black hat, and a wide grin...\n\n"); user2->hps = 5 * user2->level; write_syslog(SYSLOG, 1, "%s shot dead by %s\n", user2->name, user->name); disconnect_user(user2); ++user->kills; user->hps = user->hps + 5; return; } return; } vwrite_room(rm, "A bullet flies from %s~RS's gun and ~FG~OLmisses~RS %s~RS.\n", user->recap, user2->recap); --user->bullets; ++user->misses; write_user(user2, "~FGThat was a close shave!\n"); write_user(user, "~FRYou could not hit the side of a barn!\n"); }
/* * Set rooms to public or private */ void set_room_access(UR_OBJECT user, int priv) { UR_OBJECT u; RM_OBJECT rm; const char *name; if (word_count < 2) { rm = user->room; } else { if (user->level < amsys->gatecrash_level) { write_user(user, "You are not a high enough level to use the room option.\n"); return; } rm = get_room(word[1]); if (!rm) { write_user(user, nosuchroom); return; } } if (is_personal_room(rm)) { if (rm == user->room) { write_user(user, "This room's access is personal.\n"); } else { write_user(user, "That room's access is personal.\n"); } return; } if (is_fixed_room(rm)) { if (rm == user->room) { write_user(user, "This room's access is fixed.\n"); } else { write_user(user, "That room's access is fixed.\n"); } return; } if (priv) { if (is_private_room(rm)) { if (rm == user->room) { write_user(user, "This room is already private.\n"); } else { write_user(user, "That room is already private.\n"); } return; } if (room_visitor_count(rm) < amsys->min_private_users && user->level < amsys->ignore_mp_level) { vwrite_user(user, "You need at least %d users/clones in a room before it can be made private.\n", amsys->min_private_users); return; } } else { if (!is_private_room(rm)) { if (rm == user->room) { write_user(user, "This room is already public.\n"); } else { write_user(user, "That room is already public.\n"); } return; } /* Reset any invites into the room & clear review buffer */ for (u = user_first; u; u = u->next) { if (u->invite_room == rm) { u->invite_room = NULL; } } clear_revbuff(rm); } rm->access ^= PRIVATE; name = user->vis ? user->recap : invisname; if (rm == user->room) { vwrite_room_except(rm, user, "%s~RS has set the room to %s~RS.\n", name, is_private_room(rm) ? "~FRPRIVATE" : "~FGPUBLIC"); } else { vwrite_room(rm, "This room has been set to %s~RS.\n", is_private_room(rm) ? "~FRPRIVATE" : "~FGPUBLIC"); } vwrite_user(user, "Room set to %s~RS.\n", is_private_room(rm) ? "~FRPRIVATE" : "~FGPUBLIC"); }
/* * Allows a user to alter the minimum level which can use the command given */ void set_command_level(UR_OBJECT user) { CMD_OBJECT cmd; size_t len; enum lvl_value lvl; if (word_count < 3) { write_user(user, "Usage: setcmdlev <command name> <level>|norm\n"); return; } /* FIXME: command search order is different than command_table/exec_com() * because it uses the alpha sorted command list instead! */ len = strlen(word[1]); for (cmd = first_command; cmd; cmd = cmd->next) { if (!strncmp(word[1], cmd->name, len)) { break; } } if (!cmd) { vwrite_user(user, "The command \"~OL%s~RS\" could not be found.\n", word[1]); return; } /* levels and "norm" are checked in upper case */ strtoupper(word[2]); if (!strcmp(word[2], "NORM")) { /* FIXME: Permissions are weak setting level via "norm" */ if (cmd->level == (enum lvl_value) command_table[cmd->id].level) { write_user(user, "That command is already at its normal level.\n"); return; } cmd->level = (enum lvl_value) command_table[cmd->id].level; write_syslog(SYSLOG, 1, "%s has returned level to normal for cmd \"%s\"\n", user->name, cmd->name); write_monitor(user, NULL, 0); vwrite_room(NULL, "~OL~FR--==<~RS The level for command ~OL%s~RS has been returned to %s ~OL~FR>==--\n", cmd->name, user_level[cmd->level].name); return; } lvl = get_level(word[2]); if (lvl == NUM_LEVELS) { write_user(user, "Usage: setcmdlev <command> <level>|norm\n"); return; } if (lvl > user->level) { write_user(user, "You cannot set a command level to one greater than your own.\n"); return; } if (user->level < (enum lvl_value) command_table[cmd->id].level) { write_user(user, "You are not a high enough level to alter that command level.\n"); return; } cmd->level = lvl; write_syslog(SYSLOG, 1, "%s has set the level for cmd \"%s\" to %d (%s)\n", user->name, cmd->name, cmd->level, user_level[cmd->level].name); write_monitor(user, NULL, 0); vwrite_room(NULL, "~OL~FR--==<~RS The level for command ~OL%s~RS has been set to %s ~OL~FR>==--\n", cmd->name, user_level[cmd->level].name); }