forked from github/server
setting RF_COMBATDEBUG (bit 14) in a region triggers a summary of the weapons/skills in the battle
This commit is contained in:
parent
1ed345b5bc
commit
cc21a19831
4 changed files with 132 additions and 55 deletions
|
@ -3581,6 +3581,62 @@ init_battle(region * r, battle **bp)
|
||||||
return fighting;
|
return fighting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
battle_stats(FILE * F, battle * b)
|
||||||
|
{
|
||||||
|
typedef struct stat_info {
|
||||||
|
struct stat_info * next;
|
||||||
|
weapon * wp;
|
||||||
|
int level;
|
||||||
|
int number;
|
||||||
|
} stat_info;
|
||||||
|
side * s;
|
||||||
|
cv_foreach(s, b->sides) {
|
||||||
|
fighter * df;
|
||||||
|
stat_info * stats = NULL, * stat;
|
||||||
|
cv_foreach(df, s->fighters) {
|
||||||
|
unit *du = df->unit;
|
||||||
|
troop dt;
|
||||||
|
stat_info * slast = NULL;
|
||||||
|
|
||||||
|
dt.fighter = df;
|
||||||
|
for (dt.index=0;dt.index!=du->number;++dt.index) {
|
||||||
|
weapon * wp = preferred_weapon(dt, true);
|
||||||
|
int level = wp->attackskill;
|
||||||
|
stat_info ** slist = &stats;
|
||||||
|
|
||||||
|
if (slast && slast->wp==wp && slast->level==level) {
|
||||||
|
++slast->number;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
while (*slist && (*slist)->wp!=wp) {
|
||||||
|
slist = &(*slist)->next;
|
||||||
|
}
|
||||||
|
while (*slist && (*slist)->wp==wp && (*slist)->level>level) {
|
||||||
|
slist = &(*slist)->next;
|
||||||
|
}
|
||||||
|
stat = *slist;
|
||||||
|
if (stat->wp!=wp || stat->level!=level) {
|
||||||
|
stat = calloc(1, sizeof(stat_info));
|
||||||
|
stat->wp = wp;
|
||||||
|
stat->level = level;
|
||||||
|
stat->next = *slist;
|
||||||
|
*slist = stat;
|
||||||
|
}
|
||||||
|
slast = stat;
|
||||||
|
++slast->number;
|
||||||
|
}
|
||||||
|
} cv_next(df);
|
||||||
|
|
||||||
|
fprintf(F, "##STATS## Heer %u - %s:\n", s->index, factionname(s->bf->faction));
|
||||||
|
for (stat=stats;stat!=NULL;stat=stat->next) {
|
||||||
|
const weapon_type * wtype = stat->wp->type;
|
||||||
|
fprintf(F, "%s %u : %u\n", wtype->itype->rtype->_name[0], stat->level, stat->number);
|
||||||
|
}
|
||||||
|
freelist(stats);
|
||||||
|
} cv_next(s);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
do_battle(void)
|
do_battle(void)
|
||||||
{
|
{
|
||||||
|
@ -3631,6 +3687,8 @@ do_battle(void)
|
||||||
b->has_tactics_turn = false;
|
b->has_tactics_turn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (b->region->flags & RF_COMBATDEBUG) battle_stats(bdebug, b);
|
||||||
|
|
||||||
/* PRECOMBATSPELLS */
|
/* PRECOMBATSPELLS */
|
||||||
do_combatmagic(b, DO_PRECOMBATSPELL);
|
do_combatmagic(b, DO_PRECOMBATSPELL);
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ extern "C" {
|
||||||
# define E_ENEMY 1
|
# define E_ENEMY 1
|
||||||
# define E_ATTACKING 2
|
# define E_ATTACKING 2
|
||||||
int enemy[128];
|
int enemy[128];
|
||||||
struct side * enemies[128];
|
struct side * enemies[128];
|
||||||
cvector fighters; /* vector der Einheiten dieser Fraktion */
|
cvector fighters; /* vector der Einheiten dieser Fraktion */
|
||||||
int index; /* Eintrag der Fraktion in b->matrix/b->enemies */
|
int index; /* Eintrag der Fraktion in b->matrix/b->enemies */
|
||||||
int size[NUMROWS]; /* Anzahl Personen in Reihe X. 0 = Summe */
|
int size[NUMROWS]; /* Anzahl Personen in Reihe X. 0 = Summe */
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* vi: set ts=2:
|
/* vi: set ts=2:
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||||
|
@ -23,22 +23,25 @@ extern "C" {
|
||||||
|
|
||||||
#define FAST_CONNECT
|
#define FAST_CONNECT
|
||||||
|
|
||||||
#define RF_CHAOTIC (1<<0)
|
#define RF_CHAOTIC (1<<0)
|
||||||
#define RF_MALLORN (1<<1)
|
#define RF_MALLORN (1<<1)
|
||||||
#define RF_BLOCKED (1<<2)
|
#define RF_BLOCKED (1<<2)
|
||||||
|
|
||||||
#define RF_BLOCK_NORTHWEST (1<<3)
|
#define RF_BLOCK_NORTHWEST (1<<3)
|
||||||
#define RF_BLOCK_NORTHEAST (1<<4)
|
#define RF_BLOCK_NORTHEAST (1<<4)
|
||||||
#define RF_BLOCK_EAST (1<<5)
|
#define RF_BLOCK_EAST (1<<5)
|
||||||
#define RF_BLOCK_SOUTHEAST (1<<6)
|
#define RF_BLOCK_SOUTHEAST (1<<6)
|
||||||
#define RF_BLOCK_SOUTHWEST (1<<7)
|
#define RF_BLOCK_SOUTHWEST (1<<7)
|
||||||
#define RF_BLOCK_WEST (1<<8)
|
#define RF_BLOCK_WEST (1<<8)
|
||||||
|
|
||||||
#define RF_ENCOUNTER (1<<9)
|
#define RF_ENCOUNTER (1<<9)
|
||||||
#define RF_MIGRATION (1<<10)
|
#define RF_MIGRATION (1<<10)
|
||||||
#define RF_UNUSED_1 (1<<11)
|
#define RF_UNUSED_1 (1<<11)
|
||||||
#define RF_ORCIFIED (1<<12)
|
#define RF_ORCIFIED (1<<12)
|
||||||
#define RF_DH (1<<18)
|
|
||||||
|
#define RF_COMBATDEBUG (1<<14)
|
||||||
|
|
||||||
|
#define RF_DH (1<<18)
|
||||||
|
|
||||||
#define RF_ALL 0xFFFFFF
|
#define RF_ALL 0xFFFFFF
|
||||||
|
|
||||||
|
@ -48,54 +51,54 @@ struct message_list;
|
||||||
struct rawmaterial;
|
struct rawmaterial;
|
||||||
|
|
||||||
typedef struct land_region {
|
typedef struct land_region {
|
||||||
char *name;
|
char *name;
|
||||||
/* TODO: demand kann nach Konvertierung entfernt werden. */
|
/* TODO: demand kann nach Konvertierung entfernt werden. */
|
||||||
struct demand {
|
struct demand {
|
||||||
struct demand * next;
|
struct demand * next;
|
||||||
const struct luxury_type * type;
|
const struct luxury_type * type;
|
||||||
int value;
|
int value;
|
||||||
} * demands;
|
} * demands;
|
||||||
const struct herb_type * herbtype;
|
const struct herb_type * herbtype;
|
||||||
short herbs;
|
short herbs;
|
||||||
#if GROWING_TREES
|
#if GROWING_TREES
|
||||||
int trees[3]; /* 0 -> Samen, 1 -> Sprößlinge, 2 -> Bäume */
|
int trees[3]; /* 0 -> Samen, 1 -> Sprößlinge, 2 -> Bäume */
|
||||||
#else
|
#else
|
||||||
int trees;
|
int trees;
|
||||||
#endif
|
#endif
|
||||||
int horses;
|
int horses;
|
||||||
int peasants;
|
int peasants;
|
||||||
int newpeasants;
|
int newpeasants;
|
||||||
int money;
|
int money;
|
||||||
#if NEW_RESOURCEGROWTH == 0
|
#if NEW_RESOURCEGROWTH == 0
|
||||||
int iron;
|
int iron;
|
||||||
#endif
|
#endif
|
||||||
} land_region;
|
} land_region;
|
||||||
|
|
||||||
typedef struct region {
|
typedef struct region {
|
||||||
struct region *next;
|
struct region *next;
|
||||||
struct land_region *land;
|
struct land_region *land;
|
||||||
struct unit *units;
|
struct unit *units;
|
||||||
struct ship *ships;
|
struct ship *ships;
|
||||||
struct building *buildings;
|
struct building *buildings;
|
||||||
int x, y;
|
int x, y;
|
||||||
struct plane *planep;
|
struct plane *planep;
|
||||||
char *display;
|
char *display;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
unsigned short age;
|
unsigned short age;
|
||||||
struct message_list *msgs;
|
struct message_list *msgs;
|
||||||
struct individual_message {
|
struct individual_message {
|
||||||
struct individual_message * next;
|
struct individual_message * next;
|
||||||
const struct faction * viewer;
|
const struct faction * viewer;
|
||||||
struct message_list *msgs;
|
struct message_list *msgs;
|
||||||
} * individual_messages;
|
} * individual_messages;
|
||||||
struct attrib *attribs;
|
struct attrib *attribs;
|
||||||
struct region *nexthash;
|
struct region *nexthash;
|
||||||
terrain_t terrain;
|
terrain_t terrain;
|
||||||
#ifdef WEATHER
|
#ifdef WEATHER
|
||||||
weather_t weathertype;
|
weather_t weathertype;
|
||||||
#endif
|
#endif
|
||||||
#if NEW_RESOURCEGROWTH
|
#if NEW_RESOURCEGROWTH
|
||||||
struct rawmaterial * resources;
|
struct rawmaterial * resources;
|
||||||
#endif
|
#endif
|
||||||
#ifdef FAST_CONNECT
|
#ifdef FAST_CONNECT
|
||||||
struct region * connect[MAXDIRECTIONS];
|
struct region * connect[MAXDIRECTIONS];
|
||||||
|
@ -120,7 +123,7 @@ typedef struct spec_direction {
|
||||||
} spec_direction;
|
} spec_direction;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
direction_t dir;
|
direction_t dir;
|
||||||
} moveblock;
|
} moveblock;
|
||||||
|
|
||||||
#define region_hashkey(r) (abs((r)->x + 0x100 * (r)->y))
|
#define region_hashkey(r) (abs((r)->x + 0x100 * (r)->y))
|
||||||
|
|
|
@ -89,6 +89,20 @@ operator==(const region& a, const region&b)
|
||||||
return a.x==b.x && a.y==b.y;
|
return a.x==b.x && a.y==b.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
region_getflag(const region& r, int bit)
|
||||||
|
{
|
||||||
|
if (r.flags & (1<<bit)) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
region_setflag(region& r, int bit, bool set)
|
||||||
|
{
|
||||||
|
if (set) r.flags |= (1<<bit);
|
||||||
|
else r.flags &= ~(1<<bit);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
bind_region(lua_State * L)
|
bind_region(lua_State * L)
|
||||||
{
|
{
|
||||||
|
@ -103,6 +117,8 @@ bind_region(lua_State * L)
|
||||||
.property("info", ®ion_getinfo, ®ion_setinfo)
|
.property("info", ®ion_getinfo, ®ion_setinfo)
|
||||||
.property("terrain", ®ion_getterrain)
|
.property("terrain", ®ion_getterrain)
|
||||||
.def("add_notice", ®ion_addnotice)
|
.def("add_notice", ®ion_addnotice)
|
||||||
|
.def("get_flag", ®ion_setflag)
|
||||||
|
.def("set_flag", ®ion_getflag)
|
||||||
.def_readonly("x", ®ion::x)
|
.def_readonly("x", ®ion::x)
|
||||||
.def_readonly("y", ®ion::y)
|
.def_readonly("y", ®ion::y)
|
||||||
.def_readwrite("age", ®ion::age)
|
.def_readwrite("age", ®ion::age)
|
||||||
|
|
Loading…
Reference in a new issue