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);
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,9 @@ extern "C" {
|
||||||
#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_COMBATDEBUG (1<<14)
|
||||||
|
|
||||||
#define RF_DH (1<<18)
|
#define RF_DH (1<<18)
|
||||||
|
|
||||||
#define RF_ALL 0xFFFFFF
|
#define RF_ALL 0xFFFFFF
|
||||||
|
|
|
@ -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