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