forked from github/server
armor_type wie weapon_type gelöst. Jetzt extern per XML definierbar.
Monster versuchen, Waffen und Rüstungen zu behalten, ehe sie sich bewegen.
This commit is contained in:
parent
0eb91f7ab7
commit
04ac02ebd9
|
@ -82,13 +82,13 @@ reduce_weight(unit * u)
|
||||||
change_resource(u, R_HORSE, - min(horses,(u->number*2)));
|
change_resource(u, R_HORSE, - min(horses,(u->number*2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 1. get rid of anything that isn't silver or really lightweight */
|
/* 1. get rid of anything that isn't silver or really lightweight or helpful in combat */
|
||||||
while (capacity>0 && *itmp!=NULL) {
|
while (capacity>0 && *itmp!=NULL) {
|
||||||
item * itm = *itmp;
|
item * itm = *itmp;
|
||||||
const item_type * itype = itm->type;
|
const item_type * itype = itm->type;
|
||||||
weight += itm->number*itype->weight;
|
weight += itm->number*itype->weight;
|
||||||
if (weight>capacity) {
|
if (weight>capacity) {
|
||||||
if (itype->weight>=10) {
|
if (itype->weight>=10 && itype->rtype->wtype==0 && itype->rtype->atype==0) {
|
||||||
if (itype->capacity < itype->weight) {
|
if (itype->capacity < itype->weight) {
|
||||||
int reduce = min(itm->number, -((capacity-weight)/itype->weight));
|
int reduce = min(itm->number, -((capacity-weight)/itype->weight));
|
||||||
give_item(reduce, itm->type, u, NULL, NULL);
|
give_item(reduce, itm->type, u, NULL, NULL);
|
||||||
|
|
|
@ -651,8 +651,36 @@ chaosfactor(region * r)
|
||||||
return ((double) a->data.i / 1000.0);
|
return ((double) a->data.i / 1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
damage_unit(unit *u, const char *dam, boolean armor, boolean magic)
|
nb_armor(const unit *u, int index)
|
||||||
|
{
|
||||||
|
const item * itm;
|
||||||
|
int av = 0;
|
||||||
|
int s = 0, a = 0;
|
||||||
|
|
||||||
|
if (!(u->race->battle_flags & BF_EQUIPMENT)) return 0;
|
||||||
|
|
||||||
|
/* Normale Rüstung */
|
||||||
|
|
||||||
|
for (itm=u->items;itm;itm=itm->next) {
|
||||||
|
const armor_type * atype = itm->type->rtype->atype;
|
||||||
|
if (atype!=NULL) {
|
||||||
|
int * schutz = &a;
|
||||||
|
if (atype->flags & ATF_SHIELD) schutz = &s;
|
||||||
|
if (*schutz <= index) {
|
||||||
|
*schutz += itm->number;
|
||||||
|
if (*schutz > index) {
|
||||||
|
av += atype->prot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return av;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
damage_unit(unit *u, const char *dam, boolean physical, boolean magic)
|
||||||
{
|
{
|
||||||
int *hp = malloc(u->number * sizeof(int));
|
int *hp = malloc(u->number * sizeof(int));
|
||||||
int h;
|
int h;
|
||||||
|
@ -669,7 +697,7 @@ damage_unit(unit *u, const char *dam, boolean armor, boolean magic)
|
||||||
for (i=0; i<u->number; i++) {
|
for (i=0; i<u->number; i++) {
|
||||||
int damage = dice_rand(dam);
|
int damage = dice_rand(dam);
|
||||||
if (magic) damage = (int)(damage * (1.0 - magic_resistance(u)));
|
if (magic) damage = (int)(damage * (1.0 - magic_resistance(u)));
|
||||||
if (armor) damage -= nb_armor(u, i);
|
if (physical) damage -= nb_armor(u, i);
|
||||||
hp[i] -= damage;
|
hp[i] -= damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -264,6 +264,57 @@ attack_catapult(const troop * at, int * casualties, int row)
|
||||||
return false; /* keine weitren attacken */
|
return false; /* keine weitren attacken */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum {
|
||||||
|
#ifdef COMPATIBILITY
|
||||||
|
AR_MAGICAL,
|
||||||
|
#endif
|
||||||
|
AR_PLATE,
|
||||||
|
AR_CHAIN,
|
||||||
|
AR_RUSTY_CHAIN,
|
||||||
|
AR_SHIELD,
|
||||||
|
AR_RUSTY_SHIELD,
|
||||||
|
AR_EOGSHIELD,
|
||||||
|
AR_EOGCHAIN,
|
||||||
|
AR_MAX
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct armordata {
|
||||||
|
double penalty;
|
||||||
|
double magres;
|
||||||
|
int prot;
|
||||||
|
boolean shield;
|
||||||
|
item_t item;
|
||||||
|
} armordata;
|
||||||
|
|
||||||
|
static armordata armortable[] =
|
||||||
|
/* penalty; magres; prot; shield; item; */
|
||||||
|
{
|
||||||
|
#ifdef COMPATIBILITY
|
||||||
|
{-0.80, 5, 0, I_CLOAK_OF_INVULNERABILITY },
|
||||||
|
#endif
|
||||||
|
{ 0.30, 0.00, 5, 0, I_PLATE_ARMOR},
|
||||||
|
{ 0.15, 0.00, 3, 0, I_CHAIN_MAIL},
|
||||||
|
{ 0.30, 0.00, 3, 0, I_RUSTY_CHAIN_MAIL},
|
||||||
|
{-0.15, 0.00, 1, 1, I_SHIELD},
|
||||||
|
{ 0.00, 0.00, 1, 1, I_RUSTY_SHIELD},
|
||||||
|
{-0.25, 0.30, 2, 1, I_LAENSHIELD},
|
||||||
|
{ 0.00, 0.30, 6, 0, I_LAENCHAIN},
|
||||||
|
{ 0.00, 0.00, 0, 0, MAX_ITEMS }
|
||||||
|
};
|
||||||
|
static void
|
||||||
|
init_oldarmor(void)
|
||||||
|
{
|
||||||
|
armordata * ad = armortable;
|
||||||
|
for (;ad->item!=MAX_ITEMS;++ad) {
|
||||||
|
item_type * itype = olditemtype[ad->item];
|
||||||
|
unsigned int flags = 0;
|
||||||
|
|
||||||
|
if (ad->shield) flags |= ATF_SHIELD;
|
||||||
|
if (ad->item==I_LAENSHIELD) flags |= ATF_LAEN;
|
||||||
|
if (ad->item==I_LAENCHAIN) flags |= ATF_LAEN;
|
||||||
|
new_armortype(itype, ad->penalty, ad->magres, ad->prot, flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init_oldweapons(void)
|
init_oldweapons(void)
|
||||||
|
@ -327,4 +378,5 @@ void
|
||||||
init_weapons(void)
|
init_weapons(void)
|
||||||
{
|
{
|
||||||
init_oldweapons();
|
init_oldweapons();
|
||||||
|
init_oldarmor();
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,31 +112,6 @@ extern weapon_type * oldweapontype[];
|
||||||
static int missile_range[2] = {FIGHT_ROW, BEHIND_ROW};
|
static int missile_range[2] = {FIGHT_ROW, BEHIND_ROW};
|
||||||
static int melee_range[2] = {FIGHT_ROW, FIGHT_ROW};
|
static int melee_range[2] = {FIGHT_ROW, FIGHT_ROW};
|
||||||
|
|
||||||
typedef struct armor_type {
|
|
||||||
double penalty;
|
|
||||||
double magres;
|
|
||||||
int prot;
|
|
||||||
char shield;
|
|
||||||
char item;
|
|
||||||
} armor_type;
|
|
||||||
|
|
||||||
static armor_type armordata[AR_NONE + 1] =
|
|
||||||
/* penalty; magres; prot; shield; item; */
|
|
||||||
{
|
|
||||||
#ifdef COMPATIBILITY
|
|
||||||
{-0.80, 5, 0, I_CLOAK_OF_INVULNERABILITY },
|
|
||||||
#endif
|
|
||||||
{ 0.30, 0.00, 5, 0, I_PLATE_ARMOR},
|
|
||||||
{ 0.15, 0.00, 3, 0, I_CHAIN_MAIL},
|
|
||||||
{ 0.30, 0.00, 3, 0, I_RUSTY_CHAIN_MAIL},
|
|
||||||
{-0.15, 0.00, 1, 1, I_SHIELD},
|
|
||||||
{ 0.00, 0.00, 1, 1, I_RUSTY_SHIELD},
|
|
||||||
{-0.25, 0.30, 2, 1, I_LAENSHIELD},
|
|
||||||
{ 0.00, 0.30, 6, 0, I_LAENCHAIN},
|
|
||||||
{ 0.00, 0.00, 0, 0, I_SWORD},
|
|
||||||
{ 0.00, 0.00, 0, 0, I_SWORD}
|
|
||||||
};
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* not in use */
|
/* not in use */
|
||||||
static void
|
static void
|
||||||
|
@ -553,15 +528,15 @@ reportcasualties(battle * b, fighter * fig, int dead)
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
contest(int skilldiff, armor_t ar, armor_t sh)
|
contest(int skilldiff, const armor_type * ar, const armor_type * sh)
|
||||||
{
|
{
|
||||||
int p, vw = BASE_CHANCE - TDIFF_CHANGE * skilldiff;
|
int p, vw = BASE_CHANCE - TDIFF_CHANGE * skilldiff;
|
||||||
double mod = 1.0;
|
double mod = 1.0;
|
||||||
|
|
||||||
if (ar != AR_NONE)
|
if (ar != NULL)
|
||||||
mod *= (1 + armordata[ar].penalty);
|
mod *= (1 + ar->penalty);
|
||||||
if (sh != AR_NONE)
|
if (sh != NULL)
|
||||||
mod *= (1 + armordata[sh].penalty);
|
mod *= (1 + sh->penalty);
|
||||||
vw = (int)(100 - ((100 - vw) * mod));
|
vw = (int)(100 - ((100 - vw) * mod));
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
@ -747,58 +722,33 @@ weapon_effskill(troop t, troop enemy, const weapon * w, boolean attacking, boole
|
||||||
return skill;
|
return skill;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char
|
static const armor_type *
|
||||||
select_armor(troop t)
|
select_armor(troop t, boolean shield)
|
||||||
{
|
{
|
||||||
armor_t a = 0;
|
unit * u = t.fighter->unit;
|
||||||
|
const armor * a = t.fighter->armors;
|
||||||
int geschuetzt = 0;
|
int geschuetzt = 0;
|
||||||
|
|
||||||
/* Drachen benutzen keine Rüstungen */
|
/* Drachen benutzen keine Rüstungen */
|
||||||
if (!(t.fighter->unit->race->battle_flags & BF_EQUIPMENT))
|
if (!(u->race->battle_flags & BF_EQUIPMENT))
|
||||||
return AR_NONE;
|
return NULL;
|
||||||
|
|
||||||
/* ... und Werwölfe auch nicht */
|
/* ... und Werwölfe auch nicht */
|
||||||
if(fval(t.fighter->unit, UFL_WERE)) {
|
if (fval(u, UFL_WERE)) {
|
||||||
return AR_NONE;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
for (;a;a=a->next) {
|
||||||
if (armordata[a].shield == 0) {
|
if (a->atype->flags & ATF_SHIELD) {
|
||||||
geschuetzt += t.fighter->armor[a];
|
geschuetzt += a->count;
|
||||||
if (geschuetzt > t.index) /* unser Kandidat wird geschuetzt */
|
if (geschuetzt > t.index) /* unser Kandidat wird geschuetzt */
|
||||||
return a;
|
return a->atype;
|
||||||
}
|
}
|
||||||
++a;
|
|
||||||
}
|
}
|
||||||
while (a != AR_MAX);
|
|
||||||
|
|
||||||
return AR_NONE;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char
|
|
||||||
select_shield(troop t)
|
|
||||||
{
|
|
||||||
armor_t a = 0;
|
|
||||||
int geschuetzt = 0;
|
|
||||||
|
|
||||||
/* Drachen benutzen keine Rüstungen */
|
|
||||||
|
|
||||||
if (!(t.fighter->unit->race->battle_flags & BF_EQUIPMENT))
|
|
||||||
return AR_NONE;
|
|
||||||
|
|
||||||
do {
|
|
||||||
if (armordata[a].shield == 1) {
|
|
||||||
geschuetzt += t.fighter->armor[a];
|
|
||||||
if (geschuetzt > t.index) /* unser Kandidat wird
|
|
||||||
* * * geschuetzt */
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
++a;
|
|
||||||
}
|
|
||||||
while (a != AR_MAX);
|
|
||||||
|
|
||||||
return AR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Hier ist zu beachten, ob und wie sich Zauber und Artefakte, die
|
/* Hier ist zu beachten, ob und wie sich Zauber und Artefakte, die
|
||||||
* Rüstungschutz geben, addieren.
|
* Rüstungschutz geben, addieren.
|
||||||
|
@ -974,8 +924,8 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
|
||||||
int hp;
|
int hp;
|
||||||
|
|
||||||
int ar, an, am;
|
int ar, an, am;
|
||||||
int armor = select_armor(dt);
|
const armor_type * armor = select_armor(dt, true);
|
||||||
int shield = select_shield(dt);
|
const armor_type * shield = select_armor(dt, false);
|
||||||
|
|
||||||
const weapon_type *dwtype = NULL;
|
const weapon_type *dwtype = NULL;
|
||||||
const weapon_type *awtype = NULL;
|
const weapon_type *awtype = NULL;
|
||||||
|
@ -1015,8 +965,8 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
|
||||||
sd = weapon_effskill(dt, at, weapon, false, false);
|
sd = weapon_effskill(dt, at, weapon, false, false);
|
||||||
if (weapon!=NULL) dwtype=weapon->type;
|
if (weapon!=NULL) dwtype=weapon->type;
|
||||||
|
|
||||||
ar = armordata[armor].prot;
|
ar = armor->prot;
|
||||||
ar += armordata[shield].prot;
|
ar += shield->prot;
|
||||||
|
|
||||||
/* natürliche Rüstung */
|
/* natürliche Rüstung */
|
||||||
an = du->race->armor;
|
an = du->race->armor;
|
||||||
|
@ -1104,8 +1054,8 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
|
||||||
if (dwp == WP_RUNESWORD) res -= 0.80;
|
if (dwp == WP_RUNESWORD) res -= 0.80;
|
||||||
#endif
|
#endif
|
||||||
/* der Effekt von Laen steigt nicht linear */
|
/* der Effekt von Laen steigt nicht linear */
|
||||||
if (armor == AR_EOGCHAIN) res *= (1-armordata[armor].magres);
|
if (fval(armor, ATF_LAEN)) res *= (1-armor->magres);
|
||||||
if (shield == AR_EOGSHIELD) res *= (1-armordata[shield].magres);
|
if (fval(shield, ATF_LAEN)) res *= (1-shield->magres);
|
||||||
if (dwtype) res *= (1-dwtype->magres);
|
if (dwtype) res *= (1-dwtype->magres);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1802,7 +1752,7 @@ hits(troop at, troop dt, weapon * awp)
|
||||||
fighter *af = at.fighter, *df = dt.fighter;
|
fighter *af = at.fighter, *df = dt.fighter;
|
||||||
unit *au = af->unit, *du = df->unit;
|
unit *au = af->unit, *du = df->unit;
|
||||||
char debugbuf[512];
|
char debugbuf[512];
|
||||||
armor_t armor, shield;
|
const armor_type * armor, * shield;
|
||||||
int skdiff = 0;
|
int skdiff = 0;
|
||||||
int dist = get_unitrow(af) + get_unitrow(df) - 1;
|
int dist = get_unitrow(af) + get_unitrow(df) - 1;
|
||||||
weapon * dwp = select_weapon(dt, false, dist>1);
|
weapon * dwp = select_weapon(dt, false, dist>1);
|
||||||
|
@ -1831,8 +1781,8 @@ hits(troop at, troop dt, weapon * awp)
|
||||||
skdiff = skilldiff(at, dt, dist);
|
skdiff = skilldiff(at, dt, dist);
|
||||||
|
|
||||||
/* Verteidiger bekommt eine Rüstung */
|
/* Verteidiger bekommt eine Rüstung */
|
||||||
armor = select_armor(dt);
|
armor = select_armor(dt, true);
|
||||||
shield = select_shield(dt);
|
shield = select_armor(dt, false);
|
||||||
sprintf(debugbuf, "%.4s/%d [%6s/%d] attackiert %.4s/%d [%6s/%d] mit %d dist %d",
|
sprintf(debugbuf, "%.4s/%d [%6s/%d] attackiert %.4s/%d [%6s/%d] mit %d dist %d",
|
||||||
unitid(au), at.index,
|
unitid(au), at.index,
|
||||||
(awp != NULL) ?
|
(awp != NULL) ?
|
||||||
|
@ -3059,9 +3009,20 @@ make_fighter(battle * b, unit * u, side * s1, boolean attack)
|
||||||
fig->elvenhorses = get_item(u, I_UNICORN);
|
fig->elvenhorses = get_item(u, I_UNICORN);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i != AR_MAX; ++i)
|
if (u->race->battle_flags & BF_EQUIPMENT) {
|
||||||
if (u->race->battle_flags & BF_EQUIPMENT)
|
for (itm=u->items; itm; itm=itm->next) {
|
||||||
fig->armor[i] = get_item(u, armordata[i].item);
|
if (itm->type->rtype->atype) {
|
||||||
|
struct armor * adata = malloc(sizeof(armor)), **aptr;
|
||||||
|
for (aptr=&fig->armors;*aptr;aptr=&(*aptr)->next) {
|
||||||
|
if (adata->atype->prot > (*aptr)->atype->prot) break;
|
||||||
|
}
|
||||||
|
adata->count = itm->number;
|
||||||
|
adata->atype = itm->type->rtype->atype;
|
||||||
|
adata->next = *aptr;
|
||||||
|
*aptr = adata;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Jetzt muß noch geschaut werden, wo die Einheit die jeweils besten
|
/* Jetzt muß noch geschaut werden, wo die Einheit die jeweils besten
|
||||||
|
@ -3962,41 +3923,3 @@ do_battle(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
nb_armor(const unit *u, int index)
|
|
||||||
{
|
|
||||||
int a, av = 0;
|
|
||||||
int geschuetzt = 0;
|
|
||||||
|
|
||||||
if (!(u->race->battle_flags & BF_EQUIPMENT)) return AR_NONE;
|
|
||||||
|
|
||||||
/* Normale Rüstung */
|
|
||||||
|
|
||||||
a = 0;
|
|
||||||
do {
|
|
||||||
if (armordata[a].shield == 0) {
|
|
||||||
geschuetzt += get_item(u, armordata[a].item);
|
|
||||||
if (geschuetzt > index)
|
|
||||||
av += armordata[a].prot;
|
|
||||||
}
|
|
||||||
++a;
|
|
||||||
}
|
|
||||||
while (a != AR_MAX);
|
|
||||||
|
|
||||||
/* Schild */
|
|
||||||
|
|
||||||
a = 0;
|
|
||||||
do {
|
|
||||||
if (armordata[a].shield == 1) {
|
|
||||||
geschuetzt += get_item(u, armordata[a].item);
|
|
||||||
if (geschuetzt > index)
|
|
||||||
av += armordata[a].prot;
|
|
||||||
}
|
|
||||||
++a;
|
|
||||||
}
|
|
||||||
while (a != AR_MAX);
|
|
||||||
|
|
||||||
return av;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -119,34 +119,24 @@ extern "C" {
|
||||||
#define FIG_ATTACKED 1
|
#define FIG_ATTACKED 1
|
||||||
#define FIG_NOLOOT 2
|
#define FIG_NOLOOT 2
|
||||||
|
|
||||||
typedef unsigned char armor_t;
|
|
||||||
enum {
|
|
||||||
#ifdef COMPATIBILITY
|
|
||||||
AR_MAGICAL,
|
|
||||||
#endif
|
|
||||||
AR_PLATE,
|
|
||||||
AR_CHAIN,
|
|
||||||
AR_RUSTY_CHAIN,
|
|
||||||
AR_SHIELD,
|
|
||||||
AR_RUSTY_SHIELD,
|
|
||||||
AR_EOGSHIELD,
|
|
||||||
AR_EOGCHAIN,
|
|
||||||
AR_MAX,
|
|
||||||
AR_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct troop {
|
typedef struct troop {
|
||||||
struct fighter *fighter;
|
struct fighter *fighter;
|
||||||
int index;
|
int index;
|
||||||
} troop;
|
} troop;
|
||||||
|
|
||||||
|
typedef struct armor {
|
||||||
|
struct armor * next;
|
||||||
|
const struct armor_type * atype;
|
||||||
|
int count;
|
||||||
|
} armor;
|
||||||
|
|
||||||
typedef struct fighter {
|
typedef struct fighter {
|
||||||
struct side *side;
|
struct side *side;
|
||||||
struct unit *unit; /* Die Einheit, die hier kämpft */
|
struct unit *unit; /* Die Einheit, die hier kämpft */
|
||||||
struct building *building; /* Gebäude, in dem die Einheit evtl. steht */
|
struct building *building; /* Gebäude, in dem die Einheit evtl. steht */
|
||||||
status_t status; /* Kampfstatus */
|
status_t status; /* Kampfstatus */
|
||||||
struct weapon * weapons;
|
struct weapon * weapons;
|
||||||
int armor[AR_MAX]; /* Anzahl Rüstungen jeden Typs */
|
struct armor *armors; /* Anzahl Rüstungen jeden Typs */
|
||||||
int alive; /* Anzahl der noch nicht Toten in der Einheit */
|
int alive; /* Anzahl der noch nicht Toten in der Einheit */
|
||||||
int fighting; /* Anzahl der Kämpfer in der aktuellen Runde */
|
int fighting; /* Anzahl der Kämpfer in der aktuellen Runde */
|
||||||
int removed; /* Anzahl Kaempfer, die nicht tot sind, aber
|
int removed; /* Anzahl Kaempfer, die nicht tot sind, aber
|
||||||
|
@ -214,7 +204,6 @@ extern "C" {
|
||||||
extern void do_battle(void);
|
extern void do_battle(void);
|
||||||
|
|
||||||
/* for combar spells and special attacks */
|
/* for combar spells and special attacks */
|
||||||
extern int nb_armor(const struct unit *u, int index);
|
|
||||||
extern troop select_enemy(struct battle * b, struct fighter * af, int minrow, int maxrow, boolean advance);
|
extern troop select_enemy(struct battle * b, struct fighter * af, int minrow, int maxrow, boolean advance);
|
||||||
extern int count_enemies(struct battle * b, struct side * as, int minrow, int maxrow, boolean advance);
|
extern int count_enemies(struct battle * b, struct side * as, int minrow, int maxrow, boolean advance);
|
||||||
extern boolean terminate(troop dt, troop at, int type, const char *damage, boolean missile);
|
extern boolean terminate(troop dt, troop at, int type, const char *damage, boolean missile);
|
||||||
|
|
|
@ -49,7 +49,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
resource_type * resourcetypes;
|
resource_type * resourcetypes;
|
||||||
weapon_type * weapontypes;
|
|
||||||
luxury_type * luxurytypes;
|
luxury_type * luxurytypes;
|
||||||
potion_type * potiontypes;
|
potion_type * potiontypes;
|
||||||
herb_type * herbtypes;
|
herb_type * herbtypes;
|
||||||
|
@ -57,22 +56,6 @@ herb_type * herbtypes;
|
||||||
#define IMAXHASH 127
|
#define IMAXHASH 127
|
||||||
static item_type * itemtypes[IMAXHASH];
|
static item_type * itemtypes[IMAXHASH];
|
||||||
|
|
||||||
#ifdef AT_PTYPE
|
|
||||||
static attrib_type at_ptype = { "potion_type" };
|
|
||||||
#endif
|
|
||||||
#ifdef AT_WTYPE
|
|
||||||
static attrib_type at_wtype = { "weapon_type" };
|
|
||||||
#endif
|
|
||||||
#ifdef AT_LTYPE
|
|
||||||
static attrib_type at_ltype = { "luxury_type" };
|
|
||||||
#endif
|
|
||||||
#ifdef AT_ITYPE
|
|
||||||
static attrib_type at_itype = { "item_type" };
|
|
||||||
#endif
|
|
||||||
#ifdef AT_HTYPE
|
|
||||||
static attrib_type at_htype = { "herb_type" };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
res_changeaura(unit * u, const resource_type * rtype, int delta)
|
res_changeaura(unit * u, const resource_type * rtype, int delta)
|
||||||
{
|
{
|
||||||
|
@ -185,11 +168,7 @@ it_register(item_type * itype)
|
||||||
item_type ** p_itype = &itemtypes[key];
|
item_type ** p_itype = &itemtypes[key];
|
||||||
while (*p_itype && *p_itype != itype) p_itype = &(*p_itype)->next;
|
while (*p_itype && *p_itype != itype) p_itype = &(*p_itype)->next;
|
||||||
if (*p_itype==NULL) {
|
if (*p_itype==NULL) {
|
||||||
#ifdef AT_ITYPE
|
|
||||||
a_add(&itype->rtype->attribs, a_new(&at_itype))->data.v = (void*) itype;
|
|
||||||
#else
|
|
||||||
itype->rtype->itype = itype;
|
itype->rtype->itype = itype;
|
||||||
#endif
|
|
||||||
*p_itype = itype;
|
*p_itype = itype;
|
||||||
rt_register(itype->rtype);
|
rt_register(itype->rtype);
|
||||||
}
|
}
|
||||||
|
@ -219,11 +198,7 @@ new_itemtype(resource_type * rtype,
|
||||||
static void
|
static void
|
||||||
lt_register(luxury_type * ltype)
|
lt_register(luxury_type * ltype)
|
||||||
{
|
{
|
||||||
#ifdef AT_LTYPE
|
|
||||||
a_add(<ype->itype->rtype->attribs, a_new(&at_ltype))->data.v = (void*) ltype;
|
|
||||||
#else
|
|
||||||
ltype->itype->rtype->ltype = ltype;
|
ltype->itype->rtype->ltype = ltype;
|
||||||
#endif
|
|
||||||
ltype->next = luxurytypes;
|
ltype->next = luxurytypes;
|
||||||
luxurytypes = ltype;
|
luxurytypes = ltype;
|
||||||
}
|
}
|
||||||
|
@ -244,18 +219,6 @@ new_luxurytype(item_type * itype, int price)
|
||||||
return ltype;
|
return ltype;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
wt_register(weapon_type * wtype)
|
|
||||||
{
|
|
||||||
#ifdef AT_WTYPE
|
|
||||||
a_add(&wtype->itype->rtype->attribs, a_new(&at_wtype))->data.v = (void*) wtype;
|
|
||||||
#else
|
|
||||||
wtype->itype->rtype->wtype = wtype;
|
|
||||||
#endif
|
|
||||||
wtype->next = weapontypes;
|
|
||||||
weapontypes = wtype;
|
|
||||||
}
|
|
||||||
|
|
||||||
weapon_type *
|
weapon_type *
|
||||||
new_weapontype(item_type * itype,
|
new_weapontype(item_type * itype,
|
||||||
int wflags, double magres, const char* damage[], int offmod, int defmod, int reload, skill_t sk, int minskill)
|
int wflags, double magres, const char* damage[], int offmod, int defmod, int reload, skill_t sk, int minskill)
|
||||||
|
@ -278,20 +241,35 @@ new_weapontype(item_type * itype,
|
||||||
wtype->offmod = offmod;
|
wtype->offmod = offmod;
|
||||||
wtype->reload = reload;
|
wtype->reload = reload;
|
||||||
wtype->skill = sk;
|
wtype->skill = sk;
|
||||||
wt_register(wtype);
|
itype->rtype->wtype = wtype;
|
||||||
|
|
||||||
return wtype;
|
return wtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
armor_type *
|
||||||
|
new_armortype(item_type * itype, double penalty, double magres, int prot, unsigned int flags)
|
||||||
|
{
|
||||||
|
armor_type * atype;
|
||||||
|
|
||||||
|
assert(itype->rtype->atype==NULL);
|
||||||
|
|
||||||
|
atype = calloc(sizeof(armor_type), 1);
|
||||||
|
|
||||||
|
atype->itype = itype;
|
||||||
|
atype->penalty = penalty;
|
||||||
|
atype->magres = magres;
|
||||||
|
atype->prot = prot;
|
||||||
|
atype->flags = flags;
|
||||||
|
itype->rtype->atype = atype;
|
||||||
|
|
||||||
|
return atype;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pt_register(potion_type * ptype)
|
pt_register(potion_type * ptype)
|
||||||
{
|
{
|
||||||
#ifdef AT_PTYPE
|
|
||||||
a_add(&ptype->itype->rtype->attribs, a_new(&at_ptype))->data.v = (void*) ptype;
|
|
||||||
#else
|
|
||||||
ptype->itype->rtype->ptype = ptype;
|
ptype->itype->rtype->ptype = ptype;
|
||||||
#endif
|
|
||||||
ptype->next = potiontypes;
|
ptype->next = potiontypes;
|
||||||
potiontypes = ptype;
|
potiontypes = ptype;
|
||||||
}
|
}
|
||||||
|
@ -317,11 +295,7 @@ new_potiontype(item_type * itype,
|
||||||
static void
|
static void
|
||||||
ht_register(herb_type * htype)
|
ht_register(herb_type * htype)
|
||||||
{
|
{
|
||||||
#ifdef AT_HTYPE
|
|
||||||
a_add(&htype->itype->rtype->attribs, a_new(&at_htype))->data.v = (void*) htype;
|
|
||||||
#else
|
|
||||||
htype->itype->rtype->htype = htype;
|
htype->itype->rtype->htype = htype;
|
||||||
#endif
|
|
||||||
htype->next = herbtypes;
|
htype->next = herbtypes;
|
||||||
herbtypes = htype;
|
herbtypes = htype;
|
||||||
}
|
}
|
||||||
|
@ -365,36 +339,18 @@ item2resource(const item_type * itype)
|
||||||
const item_type *
|
const item_type *
|
||||||
resource2item(const resource_type * rtype)
|
resource2item(const resource_type * rtype)
|
||||||
{
|
{
|
||||||
#ifdef AT_ITYPE
|
|
||||||
attrib * a = a_find(rtype->attribs, &at_itype);
|
|
||||||
if (a) return (const item_type *)a->data.v;
|
|
||||||
return NULL;
|
|
||||||
#else
|
|
||||||
return rtype->itype;
|
return rtype->itype;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const herb_type *
|
const herb_type *
|
||||||
resource2herb(const resource_type * rtype)
|
resource2herb(const resource_type * rtype)
|
||||||
{
|
{
|
||||||
#ifdef AT_HTYPE
|
|
||||||
attrib * a = a_find(rtype->attribs, &at_htype);
|
|
||||||
if (a) return (const herb_type *)a->data.v;
|
|
||||||
return NULL;
|
|
||||||
#else
|
|
||||||
return rtype->htype;
|
return rtype->htype;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const weapon_type *
|
const weapon_type *
|
||||||
resource2weapon(const resource_type * rtype) {
|
resource2weapon(const resource_type * rtype) {
|
||||||
#ifdef AT_WTYPE
|
|
||||||
attrib * a = a_find(rtype->attribs, &at_wtype);
|
|
||||||
if (a) return (const weapon_type *)a->data.v;
|
|
||||||
return NULL;
|
|
||||||
#else
|
|
||||||
return rtype->wtype;
|
return rtype->wtype;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const luxury_type *
|
const luxury_type *
|
||||||
|
|
|
@ -40,12 +40,6 @@ typedef struct item {
|
||||||
#define RTF_DYNAMIC (1<<3) /* dynamic type, must be saved */
|
#define RTF_DYNAMIC (1<<3) /* dynamic type, must be saved */
|
||||||
#define RTF_POOLED (1<<4) /* resource is available in pool */
|
#define RTF_POOLED (1<<4) /* resource is available in pool */
|
||||||
|
|
||||||
#undef AT_ITYPE /* should resource_type use an attribute for items ? */
|
|
||||||
#undef AT_HTYPE /* should resource_type use an attribute for herbs ? */
|
|
||||||
#undef AT_PTYPE /* should resource_type use an attribute for potions ? */
|
|
||||||
#undef AT_LTYPE /* should resource_type use an attribute for luxuries ? */
|
|
||||||
#undef AT_WTYPE /* should resource_type use an attribute for weapons ? */
|
|
||||||
|
|
||||||
/* flags for resource_type::name() */
|
/* flags for resource_type::name() */
|
||||||
#define NMF_PLURAL 0x01
|
#define NMF_PLURAL 0x01
|
||||||
#define NMF_APPEARANCE 0x02
|
#define NMF_APPEARANCE 0x02
|
||||||
|
@ -66,21 +60,12 @@ typedef struct resource_type {
|
||||||
struct attrib * attribs;
|
struct attrib * attribs;
|
||||||
struct resource_type * next;
|
struct resource_type * next;
|
||||||
unsigned int hashkey;
|
unsigned int hashkey;
|
||||||
#ifndef AT_ITYPE
|
|
||||||
struct item_type * itype;
|
struct item_type * itype;
|
||||||
#endif
|
|
||||||
#ifndef AT_HTYPE
|
|
||||||
struct herb_type * htype;
|
struct herb_type * htype;
|
||||||
#endif
|
|
||||||
#ifndef AT_PTYPE
|
|
||||||
struct potion_type * ptype;
|
struct potion_type * ptype;
|
||||||
#endif
|
|
||||||
#ifndef AT_LTYPE
|
|
||||||
struct luxury_type * ltype;
|
struct luxury_type * ltype;
|
||||||
#endif
|
|
||||||
#ifndef AT_WTYPE
|
|
||||||
struct weapon_type * wtype;
|
struct weapon_type * wtype;
|
||||||
#endif
|
struct armor_type * atype;
|
||||||
} resource_type;
|
} resource_type;
|
||||||
extern resource_type * resourcetypes;
|
extern resource_type * resourcetypes;
|
||||||
extern const char* resourcename(const resource_type * rtype, int flags);
|
extern const char* resourcename(const resource_type * rtype, int flags);
|
||||||
|
@ -184,6 +169,18 @@ typedef struct weapon_mod {
|
||||||
struct race_list * races;
|
struct race_list * races;
|
||||||
} weapon_mod;
|
} weapon_mod;
|
||||||
|
|
||||||
|
#define ATF_NONE 0x00
|
||||||
|
#define ATF_SHIELD 0x01
|
||||||
|
#define ATF_LAEN 0x02
|
||||||
|
|
||||||
|
typedef struct armor_type {
|
||||||
|
const item_type * itype;
|
||||||
|
double penalty;
|
||||||
|
double magres;
|
||||||
|
int prot;
|
||||||
|
unsigned int flags;
|
||||||
|
} armor_type;
|
||||||
|
|
||||||
#define WTF_NONE 0x00
|
#define WTF_NONE 0x00
|
||||||
#define WTF_MISSILE 0x01
|
#define WTF_MISSILE 0x01
|
||||||
#define WTF_MAGICAL 0x02
|
#define WTF_MAGICAL 0x02
|
||||||
|
@ -205,10 +202,7 @@ typedef struct weapon_type {
|
||||||
weapon_mod * modifiers;
|
weapon_mod * modifiers;
|
||||||
/* --- functions --- */
|
/* --- functions --- */
|
||||||
boolean (*attack)(const struct troop *, int *deaths, int row);
|
boolean (*attack)(const struct troop *, int *deaths, int row);
|
||||||
/* --- pointers --- */
|
|
||||||
struct weapon_type * next;
|
|
||||||
} weapon_type;
|
} weapon_type;
|
||||||
extern weapon_type * weapontypes;
|
|
||||||
|
|
||||||
extern void rt_register(resource_type * it);
|
extern void rt_register(resource_type * it);
|
||||||
extern resource_type * rt_find(const char * name);
|
extern resource_type * rt_find(const char * name);
|
||||||
|
@ -216,7 +210,6 @@ extern item_type * it_find(const char * name);
|
||||||
extern herb_type * ht_find(const char * name);
|
extern herb_type * ht_find(const char * name);
|
||||||
extern luxury_type * lt_find(const char * name);
|
extern luxury_type * lt_find(const char * name);
|
||||||
extern potion_type * pt_find(const char * name);
|
extern potion_type * pt_find(const char * name);
|
||||||
extern weapon_type * wt_find(const char * name);
|
|
||||||
|
|
||||||
extern void it_register(item_type * it);
|
extern void it_register(item_type * it);
|
||||||
extern void wt_register(weapon_type * wt);
|
extern void wt_register(weapon_type * wt);
|
||||||
|
@ -251,6 +244,7 @@ extern resource_type * new_resourcetype(const char ** names, const char ** appea
|
||||||
extern item_type * new_itemtype(resource_type * rtype, int iflags, int weight, int capacity);
|
extern item_type * new_itemtype(resource_type * rtype, int iflags, int weight, int capacity);
|
||||||
extern luxury_type * new_luxurytype(item_type * itype, int price);
|
extern luxury_type * new_luxurytype(item_type * itype, int price);
|
||||||
extern weapon_type * new_weapontype(item_type * itype, int wflags, double magres, const char* damage[], int offmod, int defmod, int reload, skill_t sk, int minskill);
|
extern weapon_type * new_weapontype(item_type * itype, int wflags, double magres, const char* damage[], int offmod, int defmod, int reload, skill_t sk, int minskill);
|
||||||
|
extern armor_type * new_armortype(item_type * itype, double penalty, double magres, int prot, unsigned int flags);
|
||||||
extern potion_type * new_potiontype(item_type * itype, int level);
|
extern potion_type * new_potiontype(item_type * itype, int level);
|
||||||
extern herb_type * new_herbtype(item_type * itype, terrain_t terrain);
|
extern herb_type * new_herbtype(item_type * itype, terrain_t terrain);
|
||||||
|
|
||||||
|
|
|
@ -1130,7 +1130,7 @@ readunit(FILE * F)
|
||||||
log_error(("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT));
|
log_error(("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT));
|
||||||
}
|
}
|
||||||
} else if (n==MAXORDERS) {
|
} else if (n==MAXORDERS) {
|
||||||
log_error(("%s had %d or more orders\n", unitname(u), MAXPERSISTENT));
|
log_error(("%s had %d or more orders\n", unitname(u), MAXORDERS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
freadstr(F, buf, sizeof(buf));
|
freadstr(F, buf, sizeof(buf));
|
||||||
|
|
|
@ -528,6 +528,23 @@ race_compat(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static armor_type *
|
||||||
|
xml_readarmor(xmlXPathContextPtr xpath, item_type * itype)
|
||||||
|
{
|
||||||
|
xmlNodePtr node = xpath->node;
|
||||||
|
armor_type * atype = NULL;
|
||||||
|
unsigned int flags = ATF_NONE;
|
||||||
|
int ac = xml_ivalue(node, "ac", 0);
|
||||||
|
double penalty = xml_fvalue(node, "penalty", 0.0);
|
||||||
|
double magres = xml_fvalue(node, "magres", 0.0);
|
||||||
|
|
||||||
|
if (xml_bvalue(node, "laen", false)) flags |= ATF_LAEN;
|
||||||
|
if (xml_bvalue(node, "shield", false)) flags |= ATF_SHIELD;
|
||||||
|
|
||||||
|
atype = new_armortype(itype, penalty, magres, ac, flags);
|
||||||
|
return atype;
|
||||||
|
}
|
||||||
|
|
||||||
static weapon_type *
|
static weapon_type *
|
||||||
xml_readweapon(xmlXPathContextPtr xpath, item_type * itype)
|
xml_readweapon(xmlXPathContextPtr xpath, item_type * itype)
|
||||||
{
|
{
|
||||||
|
@ -662,6 +679,17 @@ xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype)
|
||||||
}
|
}
|
||||||
xmlXPathFreeObject(result);
|
xmlXPathFreeObject(result);
|
||||||
|
|
||||||
|
/* reading item/armor */
|
||||||
|
xpath->node = node;
|
||||||
|
result = xmlXPathEvalExpression(BAD_CAST "armor", xpath);
|
||||||
|
assert(result->nodesetval->nodeNr<=1);
|
||||||
|
if (result->nodesetval->nodeNr!=0) {
|
||||||
|
itype->flags |= ITF_WEAPON;
|
||||||
|
xpath->node = result->nodesetval->nodeTab[0];
|
||||||
|
rtype->atype = xml_readarmor(xpath, itype);
|
||||||
|
}
|
||||||
|
xmlXPathFreeObject(result);
|
||||||
|
|
||||||
if (gamecode_enabled) {
|
if (gamecode_enabled) {
|
||||||
/* reading item/function */
|
/* reading item/function */
|
||||||
xpath->node = node;
|
xpath->node = node;
|
||||||
|
|
Loading…
Reference in New Issue