Crossfire Server, Trunk  R20513
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 = first_archetype; at; at = at->next) {
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  for (gen = first_archetype; gen; gen = gen->next) {
79  if (gen->clone.other_arch && gen->clone.other_arch == at) {
80  gen_name = gen->name;
81  break;
82  }
83  }
84 
85  name = stringbuffer_finish(describe_item(&at->clone, NULL, 0, NULL));
86  printf("%-16s|%6"FMT64"|%4d|%3d|%s|%s|%s\n", at->clone.name, at->clone.stats.exp,
87  at->clone.stats.hp, at->clone.stats.ac, name, at->name, gen_name);
88  free(name);
89  }
90 }
91 
95 void print_monsters(void) {
96  archetype *at;
97  object *op;
98  char attbuf[34];
99  int i;
100 
101  printf(" | | | | | attack | resistances |\n");
102  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");
103  printf("---------------------------------------------------------------------------------------------------------------------------------------------------\n");
104  for (at = first_archetype; at != NULL; at = at->next) {
105  op = arch_to_object(at);
106  if (QUERY_FLAG(op, FLAG_MONSTER)) {
107  bitstostring((long)op->attacktype, NROFATTACKS, attbuf);
108  printf("%-15s|%5d|%3d|%4d|%4d|%s|",
109  op->arch->name, op->stats.maxhp, op->stats.dam, op->stats.ac,
110  op->stats.wc, attbuf);
111  for (i = 0; i < NROFATTACKS; i++)
112  printf("%4d", op->resist[i]);
113  printf("|%8"FMT64"|%9"FMT64"|\n", op->stats.exp, new_exp(op));
114  }
116  }
117 }
int8_t ac
Armour Class, how hard to hit, the lower the better.
Definition: living.h:37
void print_monsters(void)
As dump_abilities(), but with an alternative way of output.
Definition: info.c:95
object clone
An object from which to do object_copy()
Definition: object.h:470
int64_t exp
Experience.
Definition: living.h:46
Global type definitions and header inclusions.
struct archt * other_arch
Pointer used for various things - mostly used for what this objects turns into or what this object cr...
Definition: object.h:413
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:465
int16_t hp
Hit Points.
Definition: living.h:39
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
Definition: object.c:1368
int16_t maxhp
Max hit points.
Definition: living.h:40
static void bitstostring(long bits, int num, char *str)
Writes num ones and zeros to the given string based on the bits variable.
Definition: info.c:39
#define FMT64
Definition: compat.h:12
int16_t dam
How much damage this object does when hitting.
Definition: living.h:45
const char * name
The name of the object, obviously...
Definition: object.h:311
#define FLAG_CHANGING
Changes to other_arch when anim is done.
Definition: define.h:263
#define QUERY_FLAG(xyz, p)
Definition: define.h:225
int8_t wc
Weapon Class, how skilled, the lower the better.
Definition: living.h:36
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
Definition: object.h:341
int64_t new_exp(const object *ob)
Alternative way to calculate experience based on the ability of a monster.
Definition: exp.c:100
uint32_t attacktype
Bitmask of attacks this object does.
Definition: object.h:342
StringBuffer * describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf)
Describes an item, in all its details.
Definition: item.c:980
void dump_abilities(void)
Dump to standard out the abilities of all monsters.
Definition: info.c:63
living stats
Str, Con, Dex, etc.
Definition: object.h:368
struct archt * arch
Pointer to archetype.
Definition: object.h:412
struct archt * next
Next archetype in a linked list.
Definition: object.h:467
#define NROFATTACKS
Definition: attack.h:17
#define FLAG_MONSTER
Will attack players.
Definition: define.h:245
EXTERN archetype * first_archetype
First archetype.
Definition: global.h:122
object * arch_to_object(archetype *at)
Creates and returns a new object which is a copy of the given archetype.
Definition: arch.c:571
const char * name
More definite name, like "generate_kobold".
Definition: object.h:466
char * stringbuffer_finish(StringBuffer *sb)
Deallocate the string buffer instance and return the string.
Definition: stringbuffer.c:76