1 |
/* |
2 |
CrossFire, A Multiplayer game for X-windows |
3 |
|
4 |
Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 |
Copyright (C) 1992 Frank Tore Johansen |
6 |
|
7 |
This program is free software; you can redistribute it and/or modify |
8 |
it under the terms of the GNU General Public License as published by |
9 |
the Free Software Foundation; either version 2 of the License, or |
10 |
(at your option) any later version. |
11 |
|
12 |
This program is distributed in the hope that it will be useful, |
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
GNU General Public License for more details. |
16 |
|
17 |
You should have received a copy of the GNU General Public License |
18 |
along with this program; if not, write to the Free Software |
19 |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 |
|
21 |
The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 |
*/ |
23 |
|
24 |
#include <global.h> |
25 |
|
26 |
/* |
27 |
* The functions in this file are purely mean to generate information |
28 |
* in differently formatted output, mainly about monsters. |
29 |
*/ |
30 |
|
31 |
/* |
32 |
* Dump to standard out the abilities of all monsters. |
33 |
*/ |
34 |
|
35 |
void |
36 |
dump_abilities (void) |
37 |
{ |
38 |
archetype *at; |
39 |
|
40 |
for (at = first_archetype; at; at = at->next) |
41 |
{ |
42 |
char *ch; |
43 |
const char *gen_name = ""; |
44 |
archetype *gen; |
45 |
|
46 |
if (!QUERY_FLAG (&at->clone, FLAG_MONSTER)) |
47 |
continue; |
48 |
|
49 |
/* Get rid of e.g. multiple black puddings */ |
50 |
if (QUERY_FLAG (&at->clone, FLAG_CHANGING)) |
51 |
continue; |
52 |
|
53 |
for (gen = first_archetype; gen; gen = gen->next) |
54 |
{ |
55 |
if (gen->clone.other_arch && gen->clone.other_arch == at) |
56 |
{ |
57 |
gen_name = gen->name; |
58 |
break; |
59 |
} |
60 |
} |
61 |
|
62 |
ch = describe_item (&at->clone, NULL); |
63 |
printf ("%-16s|%6lld|%4d|%3d|%s|%s|%s\n", &at->clone.name, (long long) at->clone.stats.exp, |
64 |
at->clone.stats.hp, at->clone.stats.ac, ch, &at->name, gen_name); |
65 |
} |
66 |
} |
67 |
|
68 |
/* |
69 |
* As dump_abilities(), but with an alternative way of output. |
70 |
*/ |
71 |
|
72 |
void |
73 |
print_monsters (void) |
74 |
{ |
75 |
archetype *at; |
76 |
object *op; |
77 |
char attbuf[34]; |
78 |
int i; |
79 |
|
80 |
printf |
81 |
(" | | | | | attack | resistances |\n"); |
82 |
printf |
83 |
("monster | hp |dam| ac | wc |pmf ecw adw gpd ptf|phy mag fir ele cld cfs acd drn wmg ght poi slo par tud fer cnc dep dth chs csp gpw hwd bln int | exp | new exp |\n"); |
84 |
printf |
85 |
("---------------------------------------------------------------------------------------------------------------------------------------------------\n"); |
86 |
for (at = first_archetype; at != NULL; at = at->next) |
87 |
{ |
88 |
op = arch_to_object (at); |
89 |
|
90 |
if (QUERY_FLAG (op, FLAG_MONSTER)) |
91 |
{ |
92 |
bitstostring ((long) op->attacktype, NROFATTACKS, attbuf); |
93 |
printf ("%-15s|%5d|%3d|%4d|%4d|%s|", &op->arch->name, op->stats.maxhp, op->stats.dam, op->stats.ac, op->stats.wc, attbuf); |
94 |
for (i = 0; i < NROFATTACKS; i++) |
95 |
printf ("%4d", op->resist[i]); |
96 |
printf ("|%8lld|%9d|\n", (long long) op->stats.exp, new_exp (op)); |
97 |
} |
98 |
|
99 |
op->destroy (); |
100 |
} |
101 |
} |
102 |
|
103 |
/* |
104 |
* Writes <num> ones and zeros to the given string based on the |
105 |
* <bits> variable. |
106 |
*/ |
107 |
|
108 |
void |
109 |
bitstostring (long bits, int num, char *str) |
110 |
{ |
111 |
int i, j = 0; |
112 |
|
113 |
if (num > 32) |
114 |
num = 32; |
115 |
|
116 |
for (i = 0; i < num; i++) |
117 |
{ |
118 |
if (i && (i % 3) == 0) |
119 |
{ |
120 |
str[i + j] = ' '; |
121 |
j++; |
122 |
} |
123 |
if (bits & 1) |
124 |
str[i + j] = '1'; |
125 |
else |
126 |
str[i + j] = '0'; |
127 |
bits >>= 1; |
128 |
} |
129 |
str[i + j] = '\0'; |
130 |
return; |
131 |
} |