/* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * Copyright (©) 2002 Mark Wedel & Crossfire Development Team * Copyright (©) 1992 Frank Tore Johansen * * Deliantra is free software: you can redistribute it and/or modify it under * the terms of the Affero GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the Affero GNU General Public License * and the GNU General Public License along with this program. If not, see * . * * The authors can be reached via e-mail to */ #include #include /* Handles misc. input request - things like hash table, malloc, maps, etc */ typedef struct { char namebuf[MAX_BUF]; int login_order; } chars_names; int command_time (object *op, char *params) { print_tod (op); return 1; } int command_debug (object *op, char *params) { int i; char buf[MAX_BUF]; if (params == NULL || !sscanf (params, "%d", &i)) { sprintf (buf, "Global debug level is %d.", settings.debug); new_draw_info (NDI_UNIQUE, 0, op, buf); return 1; } settings.debug = i; sprintf (buf, "Set debug level to %d.", i); new_draw_info (NDI_UNIQUE, 0, op, buf); return 1; } /* * Those dumps should be just one dump with good parser */ int command_dumpbelow (object *op, char *params) { if (op && op->below) { char *dump = dump_object (op->below); new_draw_info (NDI_UNIQUE, 0, op, dump); free (dump); /* Let's push that item on the dm's stack */ dm_stack_push (op->contr, op->below->count); } return 0; } int command_version (object *op, char *params) { version (op); return 0; } /* Prints out some useful information for the character. Everything we print * out can be determined by the docs, so we aren't revealing anything extra - * rather, we are making it convenient to find the values. params have * no meaning here. */ int command_statistics (object *pl, char *params) { if (!pl->contr) return 1; dynbuf_text &msg = msg_dynbuf; msg.clear (); msg << " Experience: " << pl->stats.exp << '\n' << " Next Level: " << level_exp (pl->level + 1, pl->expmul) << '\n' << "\n Stat Nat/Real/Max\n"; for (int i = 0; i < NUM_STATS; ++i) msg.printf (" %s %2d/ %3d/%3d\n", short_stat_name [i], pl->contr->orig_stats.stat (i), pl->stats.stat (i), 20 + pl->arch->stats.stat (i)); msg << "\nYou are " << (pl->contr->peaceful ? "peaceful" : "hostile") << '.'; pl->contr->infobox (MSG_CHANNEL ("statistics"), msg); /* Can't think of anything else to print right now */ return 0; } int command_fix_me (object *op, char *params) { op->update_weight (); op->update_stats (); new_draw_info (NDI_UNIQUE, 0, op, "Your character was fixed."); return 1; } int command_bowmode (object *op, char *params) { bowtype_t oldtype = op->contr->bowtype; static const char *const types[] = { "normal", "threewide", "spreadshot", "firenorth", "firene", "fireeast", "firese", "firesouth", "firesw", "firewest", "firenw", "bestarrow" }; char buf[MAX_BUF]; int i, found; if (!params) { new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode is set to %s", types[op->contr->bowtype]); return 1; } for (i = 0, found = 0; i <= bow_bestarrow; i++) { if (!strcmp (params, types[i])) { found++; op->contr->bowtype = (bowtype_t) i; break; } } if (!found) { sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); for (i = 0; i <= bow_bestarrow; i++) { strcat (buf, " "); strcat (buf, types[i]); if (i < bow_nw) strcat (buf, ","); else strcat (buf, "."); } new_draw_info_format (NDI_UNIQUE, 0, op, buf); return 0; } new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); return 1; } int command_showpets (object *op, char *params) { int counter = 0, target = 0; int have_shown_pet = 0; dynbuf_text &msg = msg_dynbuf; msg.clear (); if (params) target = atoi (params); for (objectlink *obl = first_friendly_object; obl; obl = obl->next) { object *ob = obl->ob; if (ob->owner == op) { if (target == 0) { if (counter == 0) msg << "T\n\n"; msg.printf (" %3d %s, level %d\n", ++counter, &ob->name, ob->level); } else if (!have_shown_pet && ++counter == target) { msg.printf ("T<%s>\n\n" " level %d\n" " %d/%d HP, %d/%d SP\n" " Str %2d\n" " Dex %2d\n" " Con %2d\n" " Int %2d\n" " Wis %2d\n" " Cha %2d\n" " Pow %2d\n" " wc %d damage %d ac %d\n", &ob->name, ob->level, ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp, ob->stats.Str, ob->stats.Dex, ob->stats.Con, ob->stats.Int, ob->stats.Wis, ob->stats.Cha, ob->stats.Pow, ob->stats.wc, ob->stats.dam, ob->stats.ac); have_shown_pet = 1; } } } if (counter == 0) msg << "you have no pets."; else if (target != 0 && have_shown_pet == 0) msg << "no such pet."; op->contr->infobox (MSG_CHANNEL ("pets"), msg); return 0; } int command_resistances (object *op, char *params) { dynbuf_text &msg = msg_dynbuf; msg.clear (); msg << "Resistances:\n\n"; for (int i = 0; i < NROFATTACKS; i++) if (i != ATNR_INTERNAL) msg.printf (" %-20s %+4d\n", attacktype_desc [i], op->resist [i]); /* If dragon player, let's display natural resistances */ if (op->is_dragon ()) for (object *tmp = op->inv; tmp; tmp = tmp->below) if ((tmp->type == FORCE) && tmp->arch->archname == shstr_dragon_skin_force) { msg << "\nOf those, these are natural skin resistances:\n\n"; for (int attack = 0; attack < NROFATTACKS; attack++) if (atnr_is_dragon_enabled (attack)) msg.printf (" %-20s %+4d\n", change_resist_msg [attack], tmp->resist [attack]); break; } op->contr->infobox (MSG_CHANNEL ("resistances"), msg); return 0; } int command_title (object *op, char *params) { char buf[MAX_BUF]; if (settings.set_title == FALSE) { new_draw_info (NDI_UNIQUE, 0, op, "You cannot change your title."); return 1; } /* dragon players cannot change titles */ if (op->is_dragon ()) { new_draw_info (NDI_UNIQUE, 0, op, "Dragons cannot change titles."); return 1; } if (params == NULL) { if (op->contr->own_title[0] == '\0') sprintf (buf, "Your title is '%s'.", op->contr->title); else sprintf (buf, "Your title is '%s'.", op->contr->own_title); new_draw_info (NDI_UNIQUE, 0, op, buf); return 1; } if (strcmp (params, "clear") == 0 || strcmp (params, "default") == 0) { if (op->contr->own_title[0] == '\0') new_draw_info (NDI_UNIQUE, 0, op, "Your title is the default title."); else new_draw_info (NDI_UNIQUE, 0, op, "Title set to default."); op->contr->own_title[0] = '\0'; return 1; } if ((int) strlen (params) >= MAX_NAME) { new_draw_info (NDI_UNIQUE, 0, op, "Title too long."); return 1; } strcpy (op->contr->own_title, params); return 1; } int command_kill_pets (object *op, char *params) { objectlink *obl, *next; int counter = 0, removecount = 0; if (!params) { terminate_all_pets (op); new_draw_info (NDI_UNIQUE, 0, op, "Your pets have been killed."); } else { int target = atoi (params); for (obl = first_friendly_object; obl; obl = next) { object *ob = obl->ob; next = obl->next; if (ob->owner == op) if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) { ob->destroy (); removecount++; } } if (removecount != 0) new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); else new_draw_info (NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n"); } return 0; }