Crossfire Server, Branches 1.12  R18729
info.c
Go to the documentation of this file.
1 /*
2  * static char *rcsid_info_c =
3  * "$Id: info.c 11578 2009-02-23 22:02:27Z lalo $";
4  */
5 
6 /*
7  CrossFire, A Multiplayer game for X-windows
8 
9  Copyright (C) 2006 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 
29 #include <global.h>
30 
40 void dump_abilities(void) {
41  archetype *at;
42  char name[VERY_BIG_BUF];
43 
44  for (at = first_archetype; at; at = at->next) {
45  const char *gen_name = "";
46  archetype *gen;
47 
48  if (!QUERY_FLAG(&at->clone, FLAG_MONSTER))
49  continue;
50 
51  /* Get rid of e.g. multiple black puddings */
52  if (QUERY_FLAG(&at->clone, FLAG_CHANGING))
53  continue;
54 
55  for (gen = first_archetype; gen; gen = gen->next) {
56  if (gen->clone.other_arch && gen->clone.other_arch == at) {
57  gen_name = gen->name;
58  break;
59  }
60  }
61 
62  describe_item(&at->clone, NULL, name, VERY_BIG_BUF);
63  printf("%-16s|%6"FMT64"|%4d|%3d|%s|%s|%s\n", at->clone.name, at->clone.stats.exp,
64  at->clone.stats.hp, at->clone.stats.ac, name, at->name, gen_name);
65  }
66 }
67 
71 void print_monsters(void) {
72  archetype *at;
73  object *op;
74  char attbuf[34];
75  int i;
76 
77  printf(" | | | | | attack | resistances |\n");
78  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");
79  printf("---------------------------------------------------------------------------------------------------------------------------------------------------\n");
80  for (at = first_archetype; at != NULL; at = at->next) {
81  op = arch_to_object(at);
82  if (QUERY_FLAG(op, FLAG_MONSTER)) {
83  bitstostring((long)op->attacktype, NROFATTACKS, attbuf);
84  printf("%-15s|%5d|%3d|%4d|%4d|%s|",
85  op->arch->name, op->stats.maxhp, op->stats.dam, op->stats.ac,
86  op->stats.wc, attbuf);
87  for (i = 0; i < NROFATTACKS; i++)
88  printf("%4d", op->resist[i]);
89  printf("|%8"FMT64"|%9"FMT64"|\n", op->stats.exp, new_exp(op));
90  }
91  free_object(op);
92  }
93 }
94 
110 void bitstostring(long bits, int num, char *str) {
111  int i, j = 0;
112 
113  if (num > 32)
114  num = 32;
115 
116  for (i = 0; i < num; i++) {
117  if (i && (i%3) == 0) {
118  str[i+j] = ' ';
119  j++;
120  }
121  if (bits&1)
122  str[i+j] = '1';
123  else
124  str[i+j] = '0';
125  bits >>= 1;
126  }
127  str[i+j] = '\0';
128  return;
129 }
sint8 ac
Definition: living.h:79
void print_monsters(void)
Definition: info.c:71
char * name
Definition: image.c:53
object clone
Definition: object.h:326
sint64 exp
Definition: living.h:88
struct archt * other_arch
Definition: object.h:264
Definition: object.h:321
sint16 hp
Definition: living.h:81
sint16 maxhp
Definition: living.h:82
#define FLAG_CHANGING
Definition: define.h:559
sint16 dam
Definition: living.h:87
const char * name
Definition: object.h:167
sint64 new_exp(const object *ob)
Definition: exp.c:104
#define QUERY_FLAG(xyz, p)
Definition: define.h:514
sint8 wc
Definition: living.h:79
sint16 resist[NROFATTACKS]
Definition: object.h:192
uint32 attacktype
Definition: object.h:193
void bitstostring(long bits, int num, char *str)
Definition: info.c:110
#define VERY_BIG_BUF
Definition: define.h:82
void dump_abilities(void)
Definition: info.c:40
living stats
Definition: object.h:219
struct archt * arch
Definition: object.h:263
struct archt * next
Definition: object.h:323
#define NROFATTACKS
Definition: attack.h:45
void describe_item(const object *op, const object *owner, char *retbuf, size_t size)
Definition: item.c:1018
#define FLAG_MONSTER
Definition: define.h:541
void free_object(object *ob)
Definition: object.c:1238
EXTERN archetype * first_archetype
Definition: global.h:195
object * arch_to_object(archetype *at)
Definition: arch.c:576
const char * name
Definition: object.h:322