void do_sforce (CHAR_DATA * ch, char *argy) { char person[100]; DESCRIPTOR_DATA *d; CHAR_DATA *vict; DEFINE_COMMAND ("sforce", do_sforce, POSITION_DEAD, MAX_LEVEL, LOG_ALWAYS, "This command forces a character to do something, yet redirects output to your console instead of the character's.") person[0] = '\0'; argy = one_argy (argy, person); if (person[0] == '\0') { send_to_char ("Reminder: DON'T use this command if you don't know what you're doing! :)\n\r", ch); return; } if ((vict = get_char_world (ch, person)) == NULL || IS_MOB (vict)) { send_to_char ("Target sforce not found.\n\r", ch); return; } d = vict->desc; vict->desc = ch->desc; interpret (vict, argy); if (vict->data_type == 50) return; vict->desc = d; return; }
void do_dam (CHAR_DATA * ch, char *argy) { DEFINE_COMMAND ("damage", do_dam, POSITION_DEAD, MAX_LEVEL, LOG_NORMAL, "Checks kick damage.") display_dam_stuff (ch); return; }
void reload_power_dat (CHAR_DATA * ch, char *argy) { DEFINE_COMMAND ("z_reload_power_data", reload_power_dat, POSITION_DEAD, MAX_LEVEL, LOG_NORMAL, "Reloads the power.dat data from disk.") read_power_dat (); read_align_info (); read_race_info (); return; }
void do_drawrooms (CHAR_DATA * ch, char *argy) { DEFINE_COMMAND ("codeone", do_drawrooms, POSITION_DEAD, IMM_LEVEL, LOG_NORMAL, "This shows an overhead map of the current area around you.") reset_data(); do_rawclear(ch); if (!ch->desc) return; drawstuff(ch, argy, 22, 78); return; }
void grab_hostnames (CHAR_DATA * ch, char *argy) { #ifndef WINDOWS struct sockaddr_in sock; struct hostent *from; int size; char buf[500]; int b, e; DESCRIPTOR_DATA *d; DEFINE_COMMAND ("z_grab_hostnames", grab_hostnames, POSITION_DEAD, MAX_LEVEL, LOG_NORMAL, "Grabs hostnames give a specified fd range.") argy = one_argy (argy, buf); if (buf[0] == '\0' || argy[0] == '\0') return; if (!is_number (buf) || !is_number (argy)) return; b = atoi (buf); e = atoi (argy); size = sizeof (sock); for (d = descriptor_list; d != NULL; d = d->next) { if (d->descriptor > e || d->descriptor < b) continue; if (getpeername (d->descriptor, (struct sockaddr *) &sock, &size) < 0) { continue; } else { int addr; addr = ntohl (sock.sin_addr.s_addr); from = NULL; from = gethostbyaddr ((char *) &sock.sin_addr, sizeof (sock.sin_addr), AF_INET); free_string (d->hostname); d->hostname = str_dup (from ? from->h_name : "unknown"); } } send_to_char ("Grabbed hostnames in that descriptor range.\n\r", ch); #endif return; }
int process_cmd(char *cmd) { if (*cmd == '#') return 0; if (*cmd == '\0') return 0; else if (!strcmp("exit", cmd)) return 1; else if (!strcmp("q", cmd)) return 1; /* Define custom commands below DEFINE_COMMAND( function_name, function_to_call ); function_to_call should accept one parameter which is pointer to arguments */ DEFINE_COMMAND(kernel, load_kernel); DEFINE_COMMAND(initrd, load_initrd); DEFINE_COMMAND(dtb, load_dtb); DEFINE_COMMAND(script, load_script); DEFINE_COMMAND(dump, dump_settings); DEFINE_COMMAND(free, show_mem); DEFINE_COMMAND(mach, setget_mach); DEFINE_COMMAND(phys, setget_phys); DEFINE_COMMAND(rdsize, setget_rdisksize); DEFINE_COMMAND(cmdline, kernel_cmdline); DEFINE_COMMAND(boot, kernel_boot); DEFINE_COMMAND(probemem, force_guess_memory); DEFINE_COMMAND(poke, poke); DEFINE_COMMAND(peek, peek); DEFINE_COMMAND(enterbkpt, break_on_entry); /* End command list. Do not add any more after here */ else { printl("Unknown command" NEWLINE); }
void do_spells (CHAR_DATA * ch, char *argy) { char buf[STD_LENGTH]; char bbb[50]; char hg[300]; SPELL_DATA *spell; bool fnd = FALSE; int sn; int col; DEFINE_COMMAND ("spells", do_spells, POSITION_DEAD, 0, LOG_NORMAL, "This command shows you all the spells you currently know.") hugebuf_o[0] = '\0'; if (IS_MOB (ch)) { send_to_char ("You do not know how to cast spells!\n\r", ch); return; } hugebuf_o[0] = '\0'; col = 0; for (sn = 0; sn < SKILL_COUNT; sn++) { if ((spell = skill_lookup (NULL, sn)) == NULL) continue; if ((LEVEL (ch) < spell->spell_level) || (spell->spell_level > 80)) continue; if (spell->slot != 1) continue; if (ch->pcdata->learned[sn] == -100) continue; fnd = TRUE; { bool found = FALSE; int i; for (i = 0; str_cmp(mana_data[i].what_you_type, "end_of_list") && !found; i ++) { if (spell->mana_type == mana_data[i].flagname) { char buf[50]; sprintf (buf, "%s%s\x1b[0;37m", mana_data[i].color, mana_data[i].letter); strcpy(bbb, buf); found = TRUE; } } if (!found) strcpy(bbb, " "); } strcpy (hg, how_good (ch, sn)); if (LEVEL (ch) >= 100) sprintf (buf, "%s %3dM (%3d) %-20s ", bbb, ((2 + LEVEL (ch) - spell->spell_level == 0) ? spell->mana : (UMAX (spell->mana, 100 / (2 + LEVEL (ch) - spell->spell_level)))), ch->pcdata->learned[sn], spell->spell_funky_name); else sprintf (buf, "%s %3dM %10s %-20s ", bbb, ((2 + LEVEL (ch) - spell->spell_level == 0) ? spell->mana : (UMAX (spell->mana, 100 / (2 + LEVEL (ch) - spell->spell_level)))), hg, spell->spell_funky_name); strcat (hugebuf_o, buf); if (++col % 2 == 0) strcat (hugebuf_o, "\n\r"); } if (col % 2 != 0) strcat (hugebuf_o, "\n\r"); if (!fnd) strcpy (hugebuf_o, "You know no spells at the moment.\n\r"); page_to_char (hugebuf_o, ch); return; }
void do_practice (CHAR_DATA * ch, char *argy) { char buf[STD_LENGTH]; char hg[500]; bool found; int sn; int cnttt; SPELL_DATA *spell; CHAR_DATA *mob; int adept; DEFINE_COMMAND ("practice", do_practice, POSITION_STANDING, 0, LOG_NORMAL, "This command can be used to list all skills/spells you know, or, at a practitioner, can be used to practice a spell or skill.") hugebuf_o[0] = '\0'; cnttt = 0; if (IS_MOB (ch)) return; for (mob = ch->in_room->more->people; mob != NULL; mob = mob->next_in_room) { if (IS_MOB (mob) && IS_SET (mob->act, ACT_PRACTICE) && mob->pIndexData->opt) break; } if (mob != NULL && (!IS_SET (mob->act, ACT_PRACTICE) || IS_PLAYER (mob))) { if (argy[0] != '\0') { send_to_char ("You cannot practice here!\n\r", ch); return; } } if (mob == NULL && argy[0] == '\0') { int col; int oldtrack; int oldtrap; int oldpick; sprintf (hugebuf_o, "You have knowledge in the following:\n\r\n\r"); sprintf (hugebuf_o,"\x1B[1;37mYou have knowledge in the following:\x1B[37;0m\n\r"); sprintf (hugebuf_o+strlen(hugebuf_o),"\x1B[1;34m------------------------------------\x1B[37;0m\n\r"); col = 0; oldtrack = ch->pcdata->learned[gsn_track]; if (is_member (ch, GUILD_RANGER)) ch->pcdata->learned[gsn_track] = 100; oldtrap = ch->pcdata->learned[gsn_trapset]; if (is_member (ch, GUILD_RANGER) && is_member(ch, GUILD_THIEFG) && is_member(ch, GUILD_TINKER)) ch->pcdata->learned[gsn_trapset] = 100; oldpick = ch->pcdata->learned[gsn_pick_lock]; if (is_member (ch, GUILD_THIEFG)) ch->pcdata->learned[gsn_pick_lock] = 100; ch->pcdata->learned[gsn_sneak] += ch->pcdata->plus_sneak; ch->pcdata->learned[gsn_hide] += ch->pcdata->plus_hide; for (sn = 0; sn < SKILL_COUNT; sn++) { if ((spell = skill_lookup (NULL, sn)) == NULL) continue; if ((LEVEL (ch) < spell->spell_level) || (ch->pcdata->learned[sn] < -1)) continue; strcpy (hg, how_good (ch, sn)); if (LEVEL (ch) >= 100) sprintf (buf, "%22s %3d%% ", spell->spell_funky_name, ch->pcdata->learned[sn]); else sprintf (buf, " %22s %10s", spell->spell_funky_name, hg); strcat (hugebuf_o, buf); if (++col % 2 == 0) strcat (hugebuf_o, "\n\r"); } ch->pcdata->learned[gsn_track] = oldtrack; ch->pcdata->learned[gsn_trapset] = oldtrap; ch->pcdata->learned[gsn_pick_lock] = oldpick; ch->pcdata->learned[gsn_sneak] -= ch->pcdata->plus_sneak; ch->pcdata->learned[gsn_hide] -= ch->pcdata->plus_hide; if (col % 2 != 0) strcat (hugebuf_o, "\n\r"); sprintf (buf, "\n\rYou have %d practices and %d learns left.\x1B[0m\n\r", ch->pcdata->practice, ch->pcdata->learn); strcat (hugebuf_o, buf); page_to_char (hugebuf_o, ch); return; } if (!IS_AWAKE (ch)) { send_to_char ("In your dreams? Good luck!\n\r", ch); return; } if (argy[0] == '\0') { int col; int oldtrack; int oldtrap; int oldpick; hugebuf_o[0] = '\0'; send_to_char("\x1B[1;37mYou have knowledge in the following:\x1B[37;0m\n\r", ch); send_to_char("\x1B[1;34m------------------------------------\x1B[37;0m\n\r", ch); found = FALSE; col = 0; if (mob == NULL || IS_PLAYER (mob)) return; oldpick = ch->pcdata->learned[gsn_pick_lock]; if (is_member (ch, GUILD_THIEFG)) ch->pcdata->learned[gsn_pick_lock] = 100; oldtrack = ch->pcdata->learned[gsn_track]; if (is_member (ch, GUILD_RANGER) && is_member(ch, GUILD_THIEFG) && is_member(ch, GUILD_TINKER)) ch->pcdata->learned[gsn_trapset] = 100; oldtrap = ch->pcdata->learned[gsn_trapset]; if (is_member (ch, GUILD_RANGER)) ch->pcdata->learned[gsn_track] = 100; ch->pcdata->learned[gsn_sneak] += ch->pcdata->plus_sneak; ch->pcdata->learned[gsn_hide] += ch->pcdata->plus_hide; for (sn = 0; sn <= 28; sn++) { if (mob->pIndexData->opt->skltaught[sn] > 0 && (spell = skill_lookup (NULL, mob->pIndexData->opt->skltaught[sn])) != NULL) { if (LEVEL (ch) >= spell->spell_level) { char hg[300]; found = TRUE; strcpy (hg, how_good (ch, spell->gsn)); sprintf (buf, " %22s %10s", spell->spell_funky_name, hg); strcat (hugebuf_o, buf); if (++col % 2 == 0) strcat (hugebuf_o, "\n\r"); } } } ch->pcdata->learned[gsn_trapset] = oldtrap; ch->pcdata->learned[gsn_track] = oldtrack; ch->pcdata->learned[gsn_pick_lock] = oldpick; ch->pcdata->learned[gsn_sneak] -= ch->pcdata->plus_sneak; ch->pcdata->learned[gsn_hide] -= ch->pcdata->plus_hide; if (!found) strcat (hugebuf_o, "Nothing.\n\r"); if (col % 2 != 0) strcat (hugebuf_o, "\n\r"); sprintf (buf, "\n\rYou have %d practice sessions left.\n\r", ch->pcdata->practice); strcat (hugebuf_o, buf); page_to_char (hugebuf_o, ch); return; } spell = skill_lookup (argy, -1); if (spell == NULL) { send_to_char ("What's that?\n\r", ch); return; } if (spell == NULL || (IS_PLAYER (ch) && (LEVEL (ch) < spell->spell_level || ch->pcdata->learned[spell->gsn] == -100))) { if (spell->gsn > 0 && spell->gsn < SKILL_COUNT && ch->pcdata->learned[spell->gsn] == -100) { do_learn (ch, argy); if (ch->pcdata->learned[spell->gsn] == -100) { send_to_char ("For some reason or another, you could not LEARN this spell/skill.\n\r", ch); send_to_char ("Perhaps you are out of learns? Type 'learn' for more information.\n\r", ch); return; } goto lerned_it; } send_to_char ("I have no knowledge in that area.\n\r", ch); return; } lerned_it: if (mob == NULL) return; while (cnttt <= 30) { if (IS_MOB (mob) && mob->pIndexData->opt->skltaught[cnttt] == spell->gsn) { cnttt = 50; break; } cnttt++; } if (cnttt != 50) { send_to_char ("I have too little knowledge in that area to help you practice.\n\r", ch); return; } if (ch->pcdata->practice < 1) { send_to_char ("You have no practice sessions left!\n\r", ch); return; } if (spell->slot != 0) adept = pow.max_prac_spells; else adept = pow.max_prac_skills; if (spell->slot == 0) { if(get_curr_dex (ch) < spell->min_wis) { adept -= (spell->min_wis - get_curr_dex (ch)) * 8; } if(get_curr_str (ch) < spell->min_int) { adept -= (spell->min_int - get_curr_str (ch)) * 8; if (adept < 20) adept = 20; } } else if (spell->slot == 1) { if (get_curr_wis (ch) < spell->min_wis) { adept -= (spell->min_wis - get_curr_wis (ch)) * 8; } if (get_curr_int (ch) < spell->min_int) { adept -= (spell->min_int - get_curr_int (ch)) * 8; if (adept < 20) adept = 20; } } else if (spell->slot == 2) { if (get_curr_dex (ch) < spell->min_wis) { adept -= (spell->min_wis - get_curr_dex (ch)) * 8; } if (get_curr_int (ch) < spell->min_int) { adept -= (spell->min_int - get_curr_int (ch)) * 8; if (adept < 20) adept = 20; } } if (IS_PLAYER (ch)) { SPELL_DATA *spl; if (spell->prereq_1 != NULL && (spl = skill_lookup(spell->prereq_1, -1)) != NULL && ch->pcdata->learned[spl->gsn] < pow.prereq) { sprintf (buf, "You need to be skilled in %s first.\n\r", spl->spell_funky_name); send_to_char (buf, ch); return; } if (spell->prereq_2 != NULL && (spl = skill_lookup(spell->prereq_2, -1)) != NULL && ch->pcdata->learned[spl->gsn] < pow.prereq) { sprintf (buf, "You need to be skilled in %s first.\n\r", spl->spell_funky_name); send_to_char (buf, ch); return; } } if (ch->pcdata->learned[spell->gsn] >= adept) { sprintf (buf, "You are already quite good at %s.\n\r", spell->spell_funky_name); send_to_char (buf, ch); return; } if (spell->guilds != 0) { int i; for (i = 0; str_cmp(guild_data[i].what_you_type, "end_of_list"); i++) { if(IS_SET(spell->guilds, guild_data[i].mob_guildmaster_bit) && !IS_SET(ch->pcdata->guilds, guild_data[i].mob_guildmaster_bit)) { send_to_char("You do not have the proper guilds to practice this!\n\r", ch); return; } } } ch->pcdata->practice--; if (spell->slot == 1) ch->pcdata->learned[spell->gsn] += int_app[get_curr_int (ch) - 1].learn; if (spell->slot != 1) ch->pcdata->learned[spell->gsn] += int_app[get_curr_int (ch) - 1].learn - 1; if (ch->pcdata->learned[spell->gsn] < adept) { act ("You practice $T.", ch, NULL, spell->spell_funky_name, TO_CHAR); } else { ch->pcdata->learned[spell->gsn] = adept; act ("You now have a good understanding of $T.", ch, NULL, spell->spell_funky_name, TO_CHAR); if (spell->gsn > 549 && IS_PLAYER(ch) && !str_cmp(race_info[ch->pcdata->race].name, "orc") && adept == pow.max_prac_skills) ch->pcdata->learned[spell->gsn]+= 15; } return; }
void do_learn (CHAR_DATA * ch, char *argy) { char buf[STD_LENGTH]; int sn; int skl, spl, prf, i; SPELL_DATA *spell; int cntt; CHAR_DATA *mob; DEFINE_COMMAND ("learn", do_learn, POSITION_STANDING, 0, LOG_NORMAL, "This command allows you to learn a skill or spell. You must be at a practitioner.") cntt = 0; if (IS_MOB (ch)) return; if (!IS_AWAKE (ch)) { send_to_char ("In your dreams, or what?\n\r", ch); return; } for (mob = ch->in_room->more->people; mob != NULL; mob = mob->next_in_room) { if (IS_MOB (mob) && IS_SET (mob->act, ACT_PRACTICE) && mob->pIndexData->opt) break; } if (mob == NULL || !IS_SET (mob->act, ACT_PRACTICE) || IS_PLAYER (mob)) { send_to_char ("You can't learn anything here!\n\r", ch); return; } skl = tally_spsk (ch, 0); spl = tally_spsk (ch, 1); prf = tally_spsk (ch, 2); if (mob != NULL && (IS_MOB (mob)) && argy[0] == '\0') { int col; send_to_char ("\x1B[1;37m You may learn these skills (that you do not already know):\x1B[37;0m\n\r", ch); send_to_char ("\x1B[1;34m---------------------------------------------------------------------------\x1B[37;0m\n\r", ch); col = 0; for (sn = 0; sn < 28; sn++) { if (mob->pIndexData->opt->skltaught[sn] != 0 && ch->pcdata->learned[mob->pIndexData->opt->skltaught[sn]] == -100 && (spell = skill_lookup (NULL, mob->pIndexData->opt->skltaught[sn])) != NULL && LEVEL (ch) >= spell->spell_level) { sprintf (buf, "[Level \x1B[1;37m%-2d\x1B[0;37m]\x1b[1;30m (\x1b[1;31m%2s\x1b[0;31m)\x1B[1;34m%18s\x1B[37;0m ", spell->spell_level,(spell->slot == 0 ? "Sk" : (spell->slot == 1 ? "Sp" : "Pr")),(spell->spell_funky_name)); send_to_char (buf, ch); if (++col % 2 == 0) send_to_char ("\n\r", ch); } } sprintf (buf, "\n\r\n\rYou have \x1B[1;37m%d\x1B[37;0m learning sessions left.\n\rYou may learn \x1B[1;33m%d\x1B[37;0m more skills,\x1B[1;33m%d\x1B[37;0m more proficiencies and \x1B[1;33m%d\x1B[37;0m more spells.\n\r", ch->pcdata->learn, (race_info[ch->pcdata->race].max_skills + align_info[ch->pcdata->alignment].max_skills +(ch->pcdata->remort_times +1)/2 - skl), ( race_info[ch->pcdata->race].max_profs + align_info[ch->pcdata->alignment].max_profs + (ch->pcdata->remort_times +1)/2 - prf), (race_info[ch->pcdata->race].max_spells + align_info[ch->pcdata->alignment].max_spells +(ch->pcdata->remort_times)-spl)); send_to_char (buf, ch); return; } if (ch->pcdata->learn <= 0) { send_to_char ("You have no learning sessions left.\n\r", ch); return; } if ((spell = skill_lookup (argy, -1)) == NULL || IS_MOB (ch)) { send_to_char ("I know nothing about that.\n\r", ch); return; } if (spell->slot == 0 && skl >= (race_info[ch->pcdata->race].max_skills + align_info[ch->pcdata->alignment].max_skills + (ch->pcdata->remort_times +1)/2)) { send_to_char ("You have already learned the maximum skills for your race.\n\r", ch); return; } if (spell->slot == 2 && prf >= (race_info[ch->pcdata->race].max_profs + align_info[ch->pcdata->alignment].max_profs + (ch->pcdata->remort_times +1)/2)) { send_to_char ("You have already learned the maximum proficiencies for your race.\n\r", ch); return; } if (spell->slot == 1 && spl >= (race_info[ch->pcdata->race].max_spells + align_info[ch->pcdata->alignment].max_spells + (ch->pcdata->remort_times))) { send_to_char ("You have already learned the maximum spells for your race.\n\r", ch); return; } if (mob == NULL || IS_PLAYER (mob)) return; while (cntt <= 28) { if (spell->gsn == mob->pIndexData->opt->skltaught[cntt]) { cntt = 50; break; } cntt++; } if (cntt != 50) { send_to_char ("I have no knowledge of that to teach you.\n\r", ch); return; } if (LEVEL (ch) < spell->spell_level) { send_to_char ("You find it too difficult to understand.\n\r", ch); return; } if (IS_PLAYER (ch)) { SPELL_DATA *spl; if (spell->prereq_1 != NULL && (spl = skill_lookup(spell->prereq_1, -1)) != NULL && ch->pcdata->learned[spl->gsn] < pow.prereq) { sprintf (buf, "You need to be skilled in %s first.\n\r", spl->spell_funky_name); send_to_char (buf, ch); return; } if (spell->prereq_2 != NULL && (spl = skill_lookup(spell->prereq_2, -1)) != NULL && ch->pcdata->learned[spl->gsn] < pow.prereq) { sprintf (buf, "You need to be skilled in %s first.\n\r", spl->spell_funky_name); send_to_char (buf, ch); return; } } if (ch->pcdata->learned[spell->gsn] != -100) { sprintf (buf, "You already know %s.\n\r", spell->spell_funky_name); send_to_char (buf, ch); return; } if (spell->guilds != 0) { int i; for (i = 0; str_cmp(guild_data[i].what_you_type, "end_of_list"); i++) { if(IS_SET(spell->guilds, guild_data[i].mob_guildmaster_bit) && !IS_SET(ch->pcdata->guilds, guild_data[i].mob_guildmaster_bit)) { send_to_char("You do not have the proper guilds to learn this!\n\r", ch); return; } } } { ch->pcdata->learn--; ch->pcdata->learned[spell->gsn] = 1; act ("You learn $T.", ch, NULL, spell->spell_funky_name, TO_CHAR); /*act( "$n learns $T.", ch, NULL,spell->spell_funky_name,TO_ROOM); */ } return; }