Crossfire Server, Trunk
info.c
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5  * Copyright (c) 1992 Frank Tore Johansen
6  *
7  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8  * welcome to redistribute it under certain conditions. For details, please
9  * see COPYING and LICENSE.
10  *
11  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
12  */
13 
14 #include "global.h"
15 
16 #include <stdlib.h>
17 
39 static void bitstostring(long bits, int num, char *str) {
40  int i, j = 0;
41 
42  if (num > 32)
43  num = 32;
44 
45  for (i = 0; i < num; i++) {
46  if (i && (i%3) == 0) {
47  str[i+j] = ' ';
48  j++;
49  }
50  if (bits&1)
51  str[i+j] = '1';
52  else
53  str[i+j] = '0';
54  bits >>= 1;
55  }
56  str[i+j] = '\0';
57  return;
58 }
59 
63 void dump_abilities(void) {
64  archetype *at;
65  char *name;
66 
67  for (at = get_next_archetype(NULL); at; at = get_next_archetype(at)) {
68  const char *gen_name = "";
69  archetype *gen;
70 
71  if (!QUERY_FLAG(&at->clone, FLAG_MONSTER))
72  continue;
73 
74  /* Get rid of e.g. multiple black puddings */
75  if (QUERY_FLAG(&at->clone, FLAG_CHANGING))
76  continue;
77 
78  /* Dont print a row for each piece of a multipart object
79  * Doing so confounds the documentation generators that use the -m2 flag.
80  */
81  if (HEAD(&at->clone) != &at->clone)
82  continue;
83 
84  for (gen = get_next_archetype(NULL); gen; gen = get_next_archetype(gen)) {
85  if (gen->clone.other_arch && gen->clone.other_arch == at) {
86  gen_name = gen->name;
87  break;
88  }
89  }
90 
91  name = stringbuffer_finish(describe_item(&at->clone, NULL, 0, NULL));
92  printf("%-16s|%6"FMT64"|%4d|%3d|%s|%s|%s\n", at->clone.name, at->clone.stats.exp,
93  at->clone.stats.hp, at->clone.stats.ac, name, at->name, gen_name);
94  free(name);
95  }
96 }
97 
101 void print_monsters(void) {
102  archetype *at;
103  object *op;
104  char attbuf[34];
105  int i;
106 
107  printf(" | | | | | attack | resistances |\n");
108  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");
109  printf("---------------------------------------------------------------------------------------------------------------------------------------------------\n");
110  for (at = get_next_archetype(NULL); at != NULL; at = get_next_archetype(at)) {
111  op = arch_to_object(at);
112  if (QUERY_FLAG(op, FLAG_MONSTER)) {
113  bitstostring((long)op->attacktype, NROFATTACKS, attbuf);
114  printf("%-15s|%5d|%3d|%4d|%4d|%s|",
115  op->arch->name, op->stats.maxhp, op->stats.dam, op->stats.ac,
116  op->stats.wc, attbuf);
117  for (i = 0; i < NROFATTACKS; i++)
118  printf("%4d", op->resist[i]);
119  printf("|%8"FMT64"|%9"FMT64"|\n", op->stats.exp, new_exp(op));
120  }
122  }
123 }
global.h
new_exp
int64_t new_exp(const object *ob)
Definition: exp.c:100
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
get_next_archetype
archetype * get_next_archetype(archetype *current)
Definition: assets.cpp:280
dump_abilities
void dump_abilities(void)
Definition: info.c:63
liv::hp
int16_t hp
Definition: living.h:40
NROFATTACKS
#define NROFATTACKS
Definition: attack.h:17
describe_item
StringBuffer * describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf)
Definition: item.c:941
archt
Definition: object.h:469
liv::exp
int64_t exp
Definition: living.h:47
FMT64
#define FMT64
Definition: compat.h:16
obj::name
sstring name
Definition: object.h:314
HEAD
#define HEAD(op)
Definition: object.h:593
make_face_from_files.str
str
Definition: make_face_from_files.py:24
stringbuffer_finish
char * stringbuffer_finish(StringBuffer *sb)
Definition: stringbuffer.c:76
obj::other_arch
struct archt * other_arch
Definition: object.h:418
FLAG_MONSTER
#define FLAG_MONSTER
Definition: define.h:245
print_monsters
void print_monsters(void)
Definition: info.c:101
obj::stats
living stats
Definition: object.h:373
archt::clone
object clone
Definition: object.h:473
give.op
op
Definition: give.py:33
bitstostring
static void bitstostring(long bits, int num, char *str)
Definition: info.c:39
arch_to_object
object * arch_to_object(archetype *at)
Definition: arch.cpp:232
liv::ac
int8_t ac
Definition: living.h:38
object_free_drop_inventory
void object_free_drop_inventory(object *ob)
Definition: object.c:1546
archt::name
sstring name
Definition: object.h:470
FLAG_CHANGING
#define FLAG_CHANGING
Definition: define.h:263
give.name
name
Definition: give.py:27