ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/c_misc.C
(Generate patch)

Comparing deliantra/server/server/c_misc.C (file contents):
Revision 1.72 by root, Fri Dec 19 22:47:29 2008 UTC vs.
Revision 1.75 by root, Mon Oct 12 14:00:59 2009 UTC

3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * it under the terms of the GNU General Public License as published by 9 * the terms of the Affero GNU General Public License as published by the
10 * the Free Software Foundation, either version 3 of the License, or 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * (at your option) any later version. 11 * option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
20 * 21 *
21 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 23 */
23 24
24#include <global.h> 25#include <global.h>
85 } 86 }
86 return 0; 87 return 0;
87} 88}
88 89
89int 90int
90command_dumpfriendlyobjects (object *op, char *params)
91{
92 dump_friendly_objects ();
93 return 0;
94}
95
96int
97command_version (object *op, char *params) 91command_version (object *op, char *params)
98{ 92{
99 version (op); 93 version (op);
100 return 0; 94 return 0;
101}
102
103#ifndef BUG_LOG
104# define BUG_LOG "bug_log"
105#endif
106void
107bug_report (const char *reportstring)
108{
109 FILE *fp;
110
111 if ((fp = fopen (BUG_LOG, "a")) != NULL)
112 {
113 fprintf (fp, "%s\n", reportstring);
114 fclose (fp);
115 }
116 else
117 {
118 LOG (llevError, "Cannot write bugs file %s: %s\n", BUG_LOG, strerror (errno));
119 }
120} 95}
121 96
122/* Prints out some useful information for the character. Everything we print 97/* Prints out some useful information for the character. Everything we print
123 * out can be determined by the docs, so we aren't revealing anything extra - 98 * out can be determined by the docs, so we aren't revealing anything extra -
124 * rather, we are making it convenient to find the values. params have 99 * rather, we are making it convenient to find the values. params have
127int 102int
128command_statistics (object *pl, char *params) 103command_statistics (object *pl, char *params)
129{ 104{
130 if (!pl->contr) 105 if (!pl->contr)
131 return 1; 106 return 1;
132 new_draw_info_format (NDI_UNIQUE, 0, pl, " Experience: %" PRId64, pl->stats.exp);
133 new_draw_info_format (NDI_UNIQUE, 0, pl, " Next Level: %" PRId64, level_exp (pl->level + 1, pl->expmul));
134 new_draw_info (NDI_UNIQUE, 0, pl, "\nStat Nat/Real/Max");
135 107
136 new_draw_info_format (NDI_UNIQUE, 0, pl, "Str %2d/ %3d/%3d", 108 dynbuf_text &msg = msg_dynbuf; msg.clear ();
137 pl->contr->orig_stats.Str, pl->stats.Str, 20 + pl->arch->stats.Str); 109
138 new_draw_info_format (NDI_UNIQUE, 0, pl, "Dex %2d/ %3d/%3d", 110 msg << " Experience: " << pl->stats.exp << '\n'
139 pl->contr->orig_stats.Dex, pl->stats.Dex, 20 + pl->arch->stats.Dex); 111 << " Next Level: " << level_exp (pl->level + 1, pl->expmul) << '\n'
140 new_draw_info_format (NDI_UNIQUE, 0, pl, "Con %2d/ %3d/%3d", 112 << "\n Stat Nat/Real/Max\n";
141 pl->contr->orig_stats.Con, pl->stats.Con, 20 + pl->arch->stats.Con); 113
142 new_draw_info_format (NDI_UNIQUE, 0, pl, "Int %2d/ %3d/%3d", 114 for (int i = 0; i < NUM_STATS; ++i)
143 pl->contr->orig_stats.Int, pl->stats.Int, 20 + pl->arch->stats.Int); 115 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));
144 new_draw_info_format (NDI_UNIQUE, 0, pl, "Wis %2d/ %3d/%3d", 116
145 pl->contr->orig_stats.Wis, pl->stats.Wis, 20 + pl->arch->stats.Wis); 117 msg << "\nYou are " << (pl->contr->peaceful ? "peaceful" : "hostile") << '.';
146 new_draw_info_format (NDI_UNIQUE, 0, pl, "Pow %2d/ %3d/%3d", 118
147 pl->contr->orig_stats.Pow, pl->stats.Pow, 20 + pl->arch->stats.Pow); 119 pl->contr->infobox (MSG_CHANNEL ("statistics"), msg);
148 new_draw_info_format (NDI_UNIQUE, 0, pl, "Cha %2d/ %3d/%3d",
149 pl->contr->orig_stats.Cha, pl->stats.Cha, 20 + pl->arch->stats.Cha);
150 new_draw_info_format (NDI_UNIQUE, 0, pl, "\nAttack Mode: %s", pl->contr->peaceful ? "Peaceful" : "Hostile");
151 120
152 /* Can't think of anything else to print right now */ 121 /* Can't think of anything else to print right now */
153 return 0; 122 return 0;
154} 123}
155 124
165 134
166int 135int
167command_bowmode (object *op, char *params) 136command_bowmode (object *op, char *params)
168{ 137{
169 bowtype_t oldtype = op->contr->bowtype; 138 bowtype_t oldtype = op->contr->bowtype;
170 static const char *const types[] = { "normal", "threewide", "spreadshot", "firenorth", 139 static const char *const types[] = {
140 "normal", "threewide", "spreadshot", "firenorth",
171 "firene", "fireeast", "firese", "firesouth", 141 "firene", "fireeast", "firese", "firesouth",
172 "firesw", "firewest", "firenw", "bestarrow" 142 "firesw", "firewest", "firenw", "bestarrow"
173 }; 143 };
174 char buf[MAX_BUF]; 144 char buf[MAX_BUF];
175 int i, found; 145 int i, found;
191 } 161 }
192 162
193 if (!found) 163 if (!found)
194 { 164 {
195 sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); 165 sprintf (buf, "bowmode: Unknown options %s, valid options are:", params);
166
196 for (i = 0; i <= bow_bestarrow; i++) 167 for (i = 0; i <= bow_bestarrow; i++)
197 { 168 {
198 strcat (buf, " "); 169 strcat (buf, " ");
199 strcat (buf, types[i]); 170 strcat (buf, types[i]);
200 if (i < bow_nw) 171 if (i < bow_nw)
211} 182}
212 183
213int 184int
214command_showpets (object *op, char *params) 185command_showpets (object *op, char *params)
215{ 186{
216 objectlink *obl, *next;
217 int counter = 0, target = 0; 187 int counter = 0, target = 0;
218 int have_shown_pet = 0; 188 int have_shown_pet = 0;
219 189
190 dynbuf_text &msg = msg_dynbuf; msg.clear ();
191
220 if (params != NULL) 192 if (params)
221 target = atoi (params); 193 target = atoi (params);
194
222 for (obl = first_friendly_object; obl != NULL; obl = next) 195 for (objectlink *obl = first_friendly_object; obl; obl = obl->next)
223 { 196 {
224 object *ob = obl->ob; 197 object *ob = obl->ob;
225 198
226 next = obl->next;
227 if (ob->owner == op) 199 if (ob->owner == op)
228 { 200 {
229 if (target == 0) 201 if (target == 0)
230 { 202 {
231 if (counter == 0) 203 if (counter == 0)
232 new_draw_info (NDI_UNIQUE, 0, op, "Pets:"); 204 msg << "T<Pets>\n\n";
205
233 new_draw_info_format (NDI_UNIQUE, 0, op, "%d %s - level %d", ++counter, &ob->name, ob->level); 206 msg.printf (" %3d %s, level %d\n", ++counter, &ob->name, ob->level);
234 } 207 }
235 else if (!have_shown_pet && ++counter == target) 208 else if (!have_shown_pet && ++counter == target)
236 { 209 {
237 new_draw_info_format (NDI_UNIQUE, 0, op, "level %d %s", ob->level, &ob->name); 210 msg.printf ("T<%s>\n\n"
238 new_draw_info_format (NDI_UNIQUE, 0, op, "%d/%d HP, %d/%d SP", ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp); 211 " level %d\n"
239 /* this is not a nice way to do this, it should be made to be more like the statistics command */ 212 " %d/%d HP, %d/%d SP\n"
240 new_draw_info_format (NDI_UNIQUE, 0, op, "Str %d", ob->stats.Str); 213 " Str %2d\n"
241 new_draw_info_format (NDI_UNIQUE, 0, op, "Dex %d", ob->stats.Dex); 214 " Dex %2d\n"
242 new_draw_info_format (NDI_UNIQUE, 0, op, "Con %d", ob->stats.Con); 215 " Con %2d\n"
243 new_draw_info_format (NDI_UNIQUE, 0, op, "Int %d", ob->stats.Int); 216 " Int %2d\n"
244 new_draw_info_format (NDI_UNIQUE, 0, op, "Wis %d", ob->stats.Wis); 217 " Wis %2d\n"
245 new_draw_info_format (NDI_UNIQUE, 0, op, "Cha %d", ob->stats.Cha); 218 " Cha %2d\n"
246 new_draw_info_format (NDI_UNIQUE, 0, op, "Pow %d", ob->stats.Pow); 219 " Pow %2d\n"
247 new_draw_info_format (NDI_UNIQUE, 0, op, "wc %d damage %d ac %d ", ob->stats.wc, ob->stats.dam, ob->stats.ac); 220 " wc %d damage %d ac %d\n",
221 &ob->name,
222 &ob->name,
223 ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp,
224 ob->stats.Str,
225 ob->stats.Dex,
226 ob->stats.Con,
227 ob->stats.Int,
228 ob->stats.Wis,
229 ob->stats.Cha,
230 ob->stats.Pow,
231 ob->stats.wc, ob->stats.dam, ob->stats.ac);
232
248 have_shown_pet = 1; 233 have_shown_pet = 1;
249 } 234 }
250 } 235 }
251 } 236 }
237
252 if (counter == 0) 238 if (counter == 0)
253 new_draw_info (NDI_UNIQUE, 0, op, "you have no pets."); 239 msg << "you have no pets.";
254 else if (target != 0 && have_shown_pet == 0) 240 else if (target != 0 && have_shown_pet == 0)
255 new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); 241 msg << "no such pet.";
242
243 op->contr->infobox (MSG_CHANNEL ("pets"), msg);
244
256 return 0; 245 return 0;
257} 246}
258 247
259int 248int
260command_resistances (object *op, char *params) 249command_resistances (object *op, char *params)
261{ 250{
262 int i; 251 dynbuf_text &msg = msg_dynbuf; msg.clear ();
263 252
264 if (!op) 253 msg << "Resistances:\n\n";
265 return 0;
266 254
267 for (i = 0; i < NROFATTACKS; i++) 255 for (int i = 0; i < NROFATTACKS; i++)
268 {
269 if (i == ATNR_INTERNAL) 256 if (i != ATNR_INTERNAL)
270 continue; 257 msg.printf (" %-20s %+4d\n", attacktype_desc [i], op->resist [i]);
271
272 new_draw_info_format (NDI_UNIQUE, 0, op, "%-20s %+5d", attacktype_desc[i], op->resist[i]);
273 }
274 258
275 /* If dragon player, let's display natural resistances */ 259 /* If dragon player, let's display natural resistances */
276 if (is_dragon_pl (op)) 260 if (is_dragon_pl (op))
277 {
278 int attack;
279 object *tmp;
280
281 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 261 for (object *tmp = op->inv; tmp; tmp = tmp->below)
282 {
283 if ((tmp->type == FORCE) && tmp->arch->archname == shstr_dragon_skin_force) 262 if ((tmp->type == FORCE) && tmp->arch->archname == shstr_dragon_skin_force)
284 { 263 {
285 new_draw_info (NDI_UNIQUE, 0, op, "\nNatural skin resistances:"); 264 msg << "\nOf those, these are natural skin resistances:\n\n";
265
286 for (attack = 0; attack < NROFATTACKS; attack++) 266 for (int attack = 0; attack < NROFATTACKS; attack++)
287 {
288 if (atnr_is_dragon_enabled (attack)) 267 if (atnr_is_dragon_enabled (attack))
289 { 268 msg.printf (" %-20s %+4d\n", change_resist_msg [attack], tmp->resist [attack]);
290 new_draw_info_format (NDI_UNIQUE, 0, op, "%s: %d", change_resist_msg[attack], tmp->resist[attack]); 269
291 }
292 }
293 break; 270 break;
294 } 271 }
295 } 272
296 } 273 op->contr->infobox (MSG_CHANNEL ("resistances"), msg);
297 274
298 return 0; 275 return 0;
299} 276}
300 277
301/* 278/*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines