The incomplete fspecial functions cause quite a bit of attribute-lookups, so I'm putting them in a #define until they get implemented (if ever).

#define KARMA_MODULE is you want to use fspecial in the future.
This commit is contained in:
Enno Rehling 2006-02-17 22:59:03 +00:00
parent da213e5f16
commit dceb83c6a7
25 changed files with 244 additions and 190 deletions

View File

@ -629,8 +629,10 @@ cr_output_unit(FILE * F, const region * r,
assert(u);
#ifdef KARMA_MODULE
if (fspecial(u->faction, FS_HIDDEN))
a_fshidden = a_find(u->attribs, &at_fshidden);
#endif /* KARMA_MODULE */
fprintf(F, "EINHEIT %d\n", u->no);
fprintf(F, "\"%s\";Name\n", u->name);

View File

@ -226,7 +226,9 @@ add_recruits(unit * u, int number, int wanted)
assert(number<=wanted);
if (number > 0) {
unit * unew;
#ifdef KARMA_MODULE
int i = fspecial(u->faction, FS_MILITIA);
#endif /* KARMA_MODULE */
if (u->number==0) {
set_number(u, number);
@ -244,6 +246,7 @@ add_recruits(unit * u, int number, int wanted)
change_level(unew, SK_RIDING, 1);
}
#ifdef KARMA_MODULE
if (i > 0) {
if (unew->race->bonus[SK_SPEAR] >= 0)
change_level(unew, SK_SPEAR, i);
@ -258,6 +261,7 @@ add_recruits(unit * u, int number, int wanted)
if (unew->race->bonus[SK_AUSDAUER] >= 0)
change_level(unew, SK_AUSDAUER, i);
}
#endif /* KARMA_MODULE */
if (unew!=u) {
transfermen(unew, u, unew->number);
destroy_unit(unew);

View File

@ -2705,9 +2705,11 @@ instant_orders(void)
case K_SETSTEALTH:
setstealth_cmd(u, ord);
break;
#ifdef KARMA_MODULE
case K_WEREWOLF:
setwere_cmd(u, ord);
break;
#endif /* KARMA_MODULE */
case K_STATUS:
/* KAEMPFE [ NICHT | AGGRESSIV | DEFENSIV | HINTEN | FLIEHE ] */
status_cmd(u, ord);
@ -2875,7 +2877,6 @@ renumber_factions(void)
funhash(f);
f->no = rp->want;
fhash(f);
register_faction_id(rp->want);
fset(f, FF_NEWID);
}
while (renum) {
@ -3351,18 +3352,23 @@ static int
maxunits(const faction *f)
{
if (global.unitsperalliance == true) {
faction *f2;
float mult = 1.0;
#ifdef KARMA_MODULE
faction *f2;
for (f2 = factions; f2; f2 = f2->next) {
if (f2->alliance == f->alliance) {
mult += 0.4f * fspecial(f2, FS_ADMINISTRATOR);
}
}
#endif /* KARMA_MODULE */
return (int) (global.maxunits * mult);
}
#ifdef KARMA_MODULE
return (int) (global.maxunits * (1 + 0.4 * fspecial(f, FS_ADMINISTRATOR)));
#else
return global.maxunits;
#endif /* KARMA_MODULE */
}
static boolean
@ -3654,16 +3660,19 @@ monthly_healing(void)
if (u->race->flags & RCF_NOHEAL) continue;
if (fval(u, UFL_HUNGER)) continue;
if (fspecial(u->faction, FS_UNDEAD)) continue;
if (fval(r->terrain, SEA_REGION) && u->ship==NULL && !(canswim(u) || canfly(u))) {
continue;
}
#ifdef KARMA_MODULE
if (fspecial(u->faction, FS_UNDEAD)) continue;
if(fspecial(u->faction, FS_REGENERATION)) {
u->hp = umhp;
continue;
}
#endif /* KARMA_MODULE */
p *= heal_factor(u->race);
if (u->hp < umhp) {

View File

@ -53,6 +53,8 @@
#include <math.h>
#include <stdlib.h>
#ifdef KARMA_MODULE
#define STANDARD_LUCK 0
static void
@ -182,4 +184,4 @@ check_luck(void)
lucky_event(f);
}
}
#endif /* KARMA_MODULE */

View File

@ -676,8 +676,11 @@ drown(region *r)
unit ** up = up=&r->units;
while (*up) {
unit *u = *up;
#ifdef KARMA_MODULE
int amphibian_level = fspecial(u->faction, FS_AMPHIBIAN);
#else
int amphibian_level = 0;
#endif
if (u->ship || u->race == new_race[RC_SPELL]) {
up=&u->next;
continue;
@ -1180,7 +1183,9 @@ icebergs(void)
void
randomevents(void)
{
#ifdef KARMA_MODULE
faction *f;
#endif /* KARMA_MODULE */
region *r;
building *b, *b2;
unit *u;
@ -1274,6 +1279,7 @@ randomevents(void)
}
}
#ifdef KARMA_MODULE
/* lycanthropen werden werwölfe */
for (f = factions; f; f=f->next) {
int level = fspecial(f, FS_LYCANTROPE);
@ -1287,6 +1293,7 @@ randomevents(void)
}
}
}
#endif
/* Chaos */
for (r = regions; r; r = r->next) {
@ -1324,8 +1331,9 @@ randomevents(void)
}
#endif
dissolve_units();
check_split();
#ifdef KARMA_MODULE
check_luck();
#endif /* KARMA_MODULE */
}

View File

@ -1759,6 +1759,7 @@ report_plaintext(const char * filename, report_context * ctx)
centre(F, alliancename(f->alliance), true);
}
#ifdef KARMA_MODULE
buf[0] = 0;
dh = 0;
for (a=a_find(f->attribs, &at_faction_special); a; a=a->nexttype) {
@ -1773,13 +1774,14 @@ report_plaintext(const char * filename, report_context * ctx)
strcat(buf, buf2);
}
if(dh > 0) centre(F, buf, true);
dh = 0;
if (f->karma > 0) {
sprintf(buf, "Deine Partei hat %d Karma.", f->karma);
centre(F, buf, true);
}
#endif
dh = 0;
if (f->age <= 2) {
if (f->age <= 1) {
ADDMSG(&f->msgs, msg_message("changepasswd",

View File

@ -118,6 +118,7 @@ spy_cmd(unit * u, struct order * ord)
int
setwere_cmd(unit *u, struct order * ord)
{
#ifdef KARMA_MODULE
int level = fspecial(u->faction, FS_LYCANTROPE);
const char *s;
@ -148,7 +149,7 @@ setwere_cmd(unit *u, struct order * ord)
}
}
#endif /* KARMA_MODULE */
return 0;
}
@ -158,7 +159,6 @@ setstealth_cmd(unit * u, struct order * ord)
const char *s;
char level;
const race * trace;
attrib *a;
init_tokens(ord);
skip_token();
@ -264,6 +264,7 @@ setstealth_cmd(unit * u, struct order * ord)
/* TARNE ALLES (was nicht so alles geht?) */
u_seteffstealth(u, -1);
break;
#ifdef KARMA_MODULE
case P_NUMBER:
/* TARNE ANZAHL [NICHT] */
if (!fspecial(u->faction, FS_HIDDEN)) {
@ -272,15 +273,17 @@ setstealth_cmd(unit * u, struct order * ord)
}
s = getstrtoken();
if (findparam(s, u->faction->locale) == P_NOT) {
a = a_find(u->attribs, &at_fshidden);
if(a) a->data.ca[0] = 0;
attrib * a = a_find(u->attribs, &at_fshidden);
if (a==NULL) a->data.ca[0] = 0;
if (a->data.i == 0) a_remove(&u->attribs, a);
} else {
a = a_find(u->attribs, &at_fshidden);
if(!a) a = a_add(&u->attribs, a_new(&at_fshidden));
attrib * a = a_find(u->attribs, &at_fshidden);
if (a!=NULL) a = a_add(&u->attribs, a_new(&at_fshidden));
a->data.ca[0] = 1;
}
break;
#endif /* KARMA_MODULE */
#ifdef KARMA_MODULE
case P_ITEMS:
/* TARNE GEGENSTÄNDE [NICHT] */
if(!fspecial(u->faction, FS_HIDDEN)) {
@ -288,15 +291,16 @@ setstealth_cmd(unit * u, struct order * ord)
return 0;
}
if (findparam(s, u->faction->locale) == P_NOT) {
a = a_find(u->attribs, &at_fshidden);
if(a) a->data.ca[1] = 0;
attrib * a = a_find(u->attribs, &at_fshidden);
if (a!=NULL) a->data.ca[1] = 0;
if (a->data.i == 0) a_remove(&u->attribs, a);
} else {
a = a_find(u->attribs, &at_fshidden);
if(!a) a = a_add(&u->attribs, a_new(&at_fshidden));
attrib * a = a_find(u->attribs, &at_fshidden);
if (a==NULL) a = a_add(&u->attribs, a_new(&at_fshidden));
a->data.ca[1] = 1;
}
break;
#endif /* KARMA_MODULE */
case P_NOT:
u_seteffstealth(u, -1);
break;

View File

@ -447,7 +447,6 @@ learn(void)
int p;
magic_t mtyp;
int l;
int warrior_skill;
int studycost;
/* lernen nach lehren */
@ -645,18 +644,20 @@ learn(void)
change_effect(u, oldpotiontype[P_FOOL], -l);
}
warrior_skill = fspecial(u->faction, FS_WARRIOR);
if(warrior_skill > 0) {
#ifdef KARMA_MODULE
l = fspecial(u->faction, FS_WARRIOR);
if (l > 0) {
if (sk == SK_CROSSBOW || sk == SK_LONGBOW
|| sk == SK_CATAPULT || sk == SK_MELEE || sk == SK_SPEAR
|| sk == SK_AUSDAUER || sk == SK_WEAPONLESS)
{
teach->value += u->number * (5+warrior_skill*5);
teach->value += u->number * 5 * (l+1);
} else {
teach->value -= u->number * (5+warrior_skill*5);
teach->value -= u->number * 5 * (l+1);
teach->value = max(0, teach->value);
}
}
#endif /* KARMA_MODULE */
if (p != studycost) {
/* ist_in_gebaeude(r, u, BT_UNIVERSITAET) == 1) { */

View File

@ -905,7 +905,6 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
unit *du = df->unit;
battle *b = df->side->battle;
int heiltrank = 0;
int faerie_level;
char debugbuf[512];
/* Schild */
@ -929,10 +928,12 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
++at.fighter->hits;
#endif
#ifdef KARMA_MODULE
if (fval(au, UFL_WERE)) {
int level = fspecial(du->faction, FS_LYCANTROPE);
da += level;
}
#endif /* KARMA_MODULE */
switch (type) {
case AT_STANDARD:
@ -964,11 +965,14 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
/* magische Rüstung durch Artefakte oder Sprüche */
/* Momentan nur Trollgürtel und Werwolf-Eigenschaft */
am = select_magicarmor(dt);
#ifdef KARMA_MODULE
if(fval(du, UFL_WERE)) {
/* this counts as magical armor */
int level = fspecial(du->faction, FS_LYCANTROPE);
am += level;
}
#endif /* KARMA_MODULE */
#if CHANGED_CROSSBOWS == 1
if(awtype && fval(awtype,WTF_ARMORPIERCING)) {
@ -989,6 +993,22 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
if (type!=AT_COMBATSPELL && type!=AT_SPELL) {
/* Kein Zauber, normaler Waffenschaden */
double kritchance = (sk * 3 - sd) / 200.0;
#ifdef KARMA_MODULE
int faerie_level = fspecial(du->faction, FS_FAERIE);
da += jihad(au->faction, du->race);
if (type == AT_STANDARD && faerie_level) {
int c;
for (c=0;weapon->type->itype->construction->materials[c].number; c++) {
if(weapon->type->itype->construction->materials[c].rtype == oldresourcetype[R_IRON]) {
da += faerie_level;
break;
}
}
}
#endif /* KARMA_MODULE */
kritchance = max(kritchance, 0.005);
kritchance = min(0.9, kritchance);
@ -1000,20 +1020,6 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
}
da += rc_specialdamage(au->race, du->race, awtype);
#ifdef KARMA_MODULE
da += jihad(au->faction, du->race);
#endif
faerie_level = fspecial(du->faction, FS_FAERIE);
if (type == AT_STANDARD && faerie_level) {
int c;
for (c=0;weapon->type->itype->construction->materials[c].number; c++) {
if(weapon->type->itype->construction->materials[c].rtype == oldresourcetype[R_IRON]) {
da += faerie_level;
break;
}
}
}
if (awtype!=NULL && fval(awtype, WTF_MISSILE)) {
/* Fernkampfschadenbonus */
@ -1615,10 +1621,12 @@ skilldiff(troop at, troop dt, int dist)
skdiff += 5;
}
#ifdef KARMA_MODULE
/* Werwolf */
if(fval(au, UFL_WERE)) {
skdiff += fspecial(au->faction, FS_LYCANTROPE);
}
#endif /* KARMA_MODULE */
if (au->race == new_race[RC_GOBLIN] &&
af->side->size[SUM_ROW] >= df->side->size[SUM_ROW] * 10)
@ -1640,13 +1648,16 @@ skilldiff(troop at, troop dt, int dist)
init=true;
}
if (df->building->type->flags & BTF_PROTECTION) {
int beff = buildingeffsize(df->building, false)-1;
/* -1 because the tradepost has no protection value */
#ifdef KARMA_MODULE
if (fspecial(au->faction, FS_SAPPER)) {
/* Halbe Schutzwirkung, aufgerundet */
/* -1 because the tradepost has no protection value */
skdiff -= (buildingeffsize(df->building, false)-1+1)/2;
} else {
skdiff -= buildingeffsize(df->building, false)-1;
beff = (beff+1)/2;
}
#endif /* KARMA_MODULE */
skdiff -= beff;
is_protected = 2;
}
if (strongwall_ct) {
@ -2342,14 +2353,16 @@ aftermath(battle * b)
fighter *df = *fi;
unit *du = df->unit;
int dead = du->number - df->alive - df->run.number;
const attrib *a;
int pr_mercy = 0;
#ifdef KARMA_MODULE
const attrib *a;
for (a = a_find(du->attribs, &at_prayer_effect); a; a = a->nexttype) {
if (a->data.sa[0] == PR_MERCY) {
pr_mercy = a->data.sa[1];
}
}
#endif /* KARMA_MODULE */
#ifdef TROLLSAVE
/* Trolle können regenerieren */
@ -2900,12 +2913,14 @@ make_fighter(battle * b, unit * u, side * s1, boolean attack)
/* Effekte von Artefakten */
strongmen = min(fig->unit->number, get_item(u, I_TROLLBELT));
#ifdef KARMA_MODULE
for (a = a_find(u->attribs, &at_prayer_effect); a; a = a->nexttype) {
if (a->data.sa[0] == PR_AID) {
pr_aid = true;
break;
}
}
#endif /* KARMA_MODULE */
/* Hitpoints, Attack- und Defence-Boni für alle Personen */
for (i = 0; i < fig->alive; i++) {
@ -3916,6 +3931,7 @@ do_battle(void)
do_attack(fig);
}
#ifdef KARMA_MODULE
/* Regeneration */
for (fi = b->fighters.begin; fi != b->fighters.end; ++fi) {
fighter *fig = *fi;
@ -3926,6 +3942,7 @@ do_battle(void)
do_regenerate(fig);
}
}
#endif /* KARMA_MODULE */
}
printf("\n");

View File

@ -530,7 +530,9 @@ max_skill(faction * f, skill_t sk)
m = MAXMAGICIANS;
}
if (f->race == new_race[RC_ELF]) m += 1;
#ifdef KARMA_MODULE
m += fspecial(f, FS_MAGOCRACY) * 2;
#endif /* KARMA_MODULE */
break;
case SK_ALCHEMY:
m = MAXALCHEMISTS;
@ -1166,20 +1168,22 @@ static attrib_type at_lighthouse = {
void
update_lighthouse(building * lh)
{
region * r = lh->region;
short d = (short)log10(lh->size) + 1;
short x, y;
static boolean init_lighthouse = false;
static const struct building_type * bt_lighthouse = 0;
if (!init_lighthouse) {
bt_lighthouse = bt_find("lighthouse");
if (bt_lighthouse==NULL) return;
init_lighthouse = true;
}
if (bt_lighthouse==NULL || lh->type!=bt_lighthouse) return;
if (lh->type==bt_lighthouse) {
region * r = lh->region;
short d = (short)log10(lh->size) + 1;
short x;
for (x=-d;x<=d;++x) {
short y;
for (y=-d;y<=d;++y) {
attrib * a;
region * r2 = findregion(x+r->x, y+r->y);
@ -1200,6 +1204,8 @@ update_lighthouse(building * lh)
}
}
}
int
count_all(const faction * f)
{
@ -2549,38 +2555,17 @@ remove_empty_units(void)
}
}
int *used_faction_ids = NULL;
int no_used_faction_ids = 0;
static int
_cmp_int(const void *i1, const void *i2)
{
if(i2==NULL)
return(*(int*)i1);
return (*(int*)i1 - *(int *)i2);
}
void
register_faction_id(int id)
{
no_used_faction_ids++;
used_faction_ids = realloc(used_faction_ids, no_used_faction_ids*sizeof(int));
used_faction_ids[no_used_faction_ids-1] = id;
if(no_used_faction_ids > 1)
qsort(used_faction_ids, (size_t)no_used_faction_ids, sizeof(int), _cmp_int);
}
boolean
faction_id_is_unused(int id)
{
return findfaction(id)==NULL;
return findfaction(id)==NULL && id!=MONSTER_FACTION;
}
int
weight(const unit * u)
{
int w, n = 0, in_bag = 0;
int faerie_level;
int faerie_level = 0;
item * itm;
for (itm=u->items;itm;itm=itm->next) {
@ -2590,7 +2575,10 @@ weight(const unit * u)
in_bag += w;
}
#ifdef KARMA_MODULE
faerie_level = fspecial(u->faction, FS_FAERIE);
#endif /* KARMA_MODULE */
if (faerie_level) {
n += (u->number * u->race->weight)/(1+faerie_level);
} else {
@ -2605,18 +2593,6 @@ weight(const unit * u)
return n;
}
void
init_used_faction_ids(void)
{
faction *f;
no_used_faction_ids = 0;
for(f = factions; f; f = f->next) {
register_faction_id(f->no);
}
}
void
make_undead_unit(unit * u)
{
@ -2683,13 +2659,14 @@ lifestyle(const unit * u)
if(u->region->planep && fval(u->region->planep, PFL_NOFEED))
return 0;
#ifdef KARMA_MODULE
if(fspecial(u->faction, FS_REGENERATION))
need += 1;
if(fspecial(u->faction, FS_ADMINISTRATOR))
need += 1;
if(fspecial(u->faction, FS_WYRM) && u->race == new_race[RC_WYRM])
need *= 500;
#endif /* KARMA_MODULE */
return need;
}
@ -2812,9 +2789,11 @@ default_wage(const region *r, const faction * f, const race * rc)
index = 1;
}
wage = wagetable[esize][index];
#ifdef KARMA_MODULE
if (fspecial(f, FS_URBAN)) {
wage += wagetable[esize][3];
}
#endif /* KARMA_MODULE */
} else {
if (fval(r->terrain, SEA_REGION)) {
wage = 11;
@ -3121,9 +3100,14 @@ attrib_init(void)
at_register(&at_icastle);
at_register(&at_guard);
at_register(&at_group);
#ifdef KARMA_MODULE
at_register(&at_faction_special);
at_register(&at_prayer_timeout);
at_register(&at_wyrm);
at_register(&at_jihad);
#endif /* KARMA_MODULE */
at_register(&at_building_generic_type);
at_register(&at_maxmagicians);
at_register(&at_npcfaction);
@ -3136,7 +3120,6 @@ attrib_init(void)
register_bordertype(&bt_road);
register_bordertype(&bt_questportal);
at_register(&at_jihad);
at_register(&at_germs);
at_register(&at_laen); /* required for old datafiles */
#ifdef XECMD_MODULE

View File

@ -848,9 +848,6 @@ extern int turn;
extern int quiet;
/* parteinummern */
extern int *used_faction_ids;
extern int no_used_faction_ids;
extern void register_faction_id(int id);
extern boolean faction_id_is_unused(int);
/* leuchtturm */

View File

@ -128,7 +128,6 @@ addfaction(const char *email, const char * password,
f->options = Pow(O_REPORT) | Pow(O_ZUGVORLAGE) | Pow(O_SILBERPOOL) | Pow(O_COMPUTER) | Pow(O_COMPRESS) | Pow(O_ADRESSEN) | Pow(O_STATISTICS);
f->no = unused_faction_id();
register_faction_id(f->no);
addlist(&factions, f);
fhash(f);

View File

@ -76,7 +76,6 @@ typedef struct faction {
int num_total; /* Anzahl Personen mit Monstern */
int options;
int no_units;
int karma;
struct ally *allies;
struct group *groups;
boolean alive; /* enno: sollte ein flag werden */
@ -84,6 +83,9 @@ typedef struct faction {
int money;
#ifdef SCORE_MODULE
int score;
#endif
#ifdef KARMA_MODULE
int karma;
#endif
struct alliance * alliance;
#ifdef VICTORY_DELAY

View File

@ -68,6 +68,7 @@ attrib_type at_jihad = {
"jihad", NULL, NULL, NULL, a_writeshorts, a_readshorts
};
#ifdef KARMA_MODULE
struct fspecialdata fspecials[MAXFACTIONSPECIALS] = {
{
"Regeneration",
@ -352,13 +353,11 @@ buy_special(unit *u, struct order * ord, fspecial_t special)
int
fspecial(const faction *f, fspecial_t special)
{
#ifdef KARMA_MODULE
attrib *a;
for (a=a_find(f->attribs, &at_faction_special); a; a=a->nexttype) {
if(a->data.sa[0] == special) return a->data.sa[1];
}
#endif
return 0;
}
@ -604,3 +603,4 @@ karma(void)
parse(K_SETJIHAD, jihad_cmd, false);
parse(K_SACRIFICE, sacrifice_cmd, true);
}
#endif

View File

@ -16,8 +16,6 @@
extern "C" {
#endif
struct faction;
typedef enum {
FS_REGENERATION,
FS_URBAN,
@ -44,18 +42,18 @@ typedef enum {
MAXFACTIONSPECIALS
} fspecial_t;
#ifdef KARMA_MODULE
typedef enum {
PR_AID,
PR_MERCY,
MAXPRAYEREFFECTS
} prayereffect_t;
typedef struct fspecialdata fspecialdata;
struct fspecialdata {
typedef struct fspecialdata {
const char *name;
const char *description;
const short maxlevel;
};
} fspecialdata;
extern struct attrib_type at_faction_special;
extern struct attrib_type at_prayer_timeout;
@ -67,7 +65,6 @@ extern struct attrib_type at_jihad;
extern struct fspecialdata fspecials[];
extern int fspecial(const struct faction *f, fspecial_t special);
#ifdef KARMA_MODULE
extern void karma(void);
extern int jihad(struct faction *, const struct race *);
extern void jihad_attacks(void);

View File

@ -418,9 +418,12 @@ updatespelllist(unit * u)
/* Nur Wyrm-Magier bekommen den Wyrmtransformationszauber */
sp = find_spellbyid(M_GRAU, SPL_BECOMEWYRM);
#ifdef KARMA_MODULE
if (fspecial(u->faction, FS_WYRM) && !has_spell(u, sp) && sp->level<=sk) {
add_spell(mage, find_spellbyid(M_GRAU, SPL_BECOMEWYRM));
}
#endif /* KARMA_MODULE */
/* Transformierte Wyrm-Magier bekommen Drachenodem */
if (dragonrace(u->race)) {
@ -1159,8 +1162,9 @@ target_resists_magic(unit *magician, void *obj, int objtyp, int t_bonus)
skill * sv;
unit * u = (unit*)obj;
#ifdef KARMA_MODULE
if (fspecial(u->faction, FS_MAGICIMMUNE)) return true;
#endif /* KARMA_MODULE */
at = effskill(magician, SK_MAGIC);
for (sv = u->skills; sv != u->skills + u->skill_size; ++sv) {
@ -1396,7 +1400,9 @@ regeneration(unit * u)
double potenz = 1.5;
double divisor = 2.0;
#ifdef KARMA_MODULE
if (fspecial(u->faction, FS_MAGICIMMUNE)) return 0;
#endif /* KARMA_MODULE */
sk = effskill(u, SK_MAGIC);
/* Rassenbonus/-malus */

View File

@ -210,8 +210,10 @@ personcapacity(const unit *u)
{
int cap = u->race->weight+u->race->capacity;
#ifdef KARMA_MODULE
if (fspecial(u->faction, FS_QUICK))
cap -= 200;
#endif /* KARMA_MODULE */
return cap;
}
@ -391,8 +393,9 @@ canswim(unit *u)
if (get_item(u, I_DOLPHIN) >= u->number && effskill(u, SK_RIDING) >= 4)
return true;
#ifdef KARMA_MODULE
if (fspecial(u->faction, FS_AMPHIBIAN)) return true;
#endif /* KARMA_MODULE */
if (u->race->flags & RCF_FLY) return true;
if (u->race->flags & RCF_SWIM) return true;
@ -1259,8 +1262,10 @@ movement_speed(unit * u)
default:
mp = BP_WALKING;
#ifdef KARMA_MODULE
/* faction special */
if (fspecial(u->faction, FS_QUICK)) mp = BP_RIDING;
#endif /* KARMA_MODULE */
/* Siebenmeilentee */
if (!fval(u->region->terrain, SEA_REGION) && get_effect(u, oldpotiontype[P_FAST]) >= u->number) {

View File

@ -207,9 +207,11 @@ unit_max_hp(const unit * u)
p = pow(effskill(u, SK_AUSDAUER) / 2.0, 1.5) * 0.2;
h += (int) (h * p + 0.5);
#ifdef KARMA_MODULE
if (fspecial(u->faction, FS_UNDEAD)) {
h *= 2;
}
#endif /* KARMA_MODULE */
/* der healing curse verändert die maximalen hp */
if (heal_ct) {

View File

@ -203,7 +203,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
const char *pzTmp;
building * b;
boolean isbattle = (boolean)(mode == see_battle);
int telepath_see = fspecial(f, FS_TELEPATHY);
int telepath_see = 0;
attrib *a_fshidden = NULL;
item * itm;
item * show;
@ -222,8 +222,12 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
itemcloak = curse_active(get_curse(u->attribs, itemcloak_ct));
}
if (fspecial(u->faction, FS_HIDDEN))
#ifdef KARMA_MODULE
if (fspecial(u->faction, FS_HIDDEN)) {
a_fshidden = a_find(u->attribs, &at_fshidden);
}
telepath_see = fspecial(f, FS_TELEPATHY);
#endif /* KARMA_MODULE */
rsize = strlcpy(bufp, unitname(u), size);
if (rsize>size) rsize = size-1;

View File

@ -1528,7 +1528,14 @@ readfaction(FILE * F)
convertunique(f);
#endif
f->magiegebiet = (magic_t)ri(F);
#ifdef KARMA_MODULE
f->karma = ri(F);
#else
/* ignore karma */
ri(F);
#endif /* KARMA_MODULE */
f->flags = ri(F);
freset(f, FFL_OVERRIDE);
@ -1620,7 +1627,12 @@ writefaction(FILE * F, const faction * f)
ws(F, f->race->_name[0]);
wnl(F);
wi(F, f->magiegebiet);
#ifdef KARMA_MODULE
wi(F, f->karma);
#else
wi(F, 0);
#endif /* KARMA_MODULE */
wi(F, f->flags);
a_write(F, f->attribs);
wnl(F);
@ -1663,7 +1675,7 @@ readgame(const char * filename, int backup)
faction *f, **fp;
region *r;
building *b, **bp;
ship *sh, **shp;
ship **shp;
unit *u;
FILE * F;
int rmax = maxregions;
@ -1752,18 +1764,18 @@ readgame(const char * filename, int backup)
while (--n >= 0) {
faction * f = readfaction(F);
addlist2(fp, f);
*fp = f;
fp = &f->next;
fhash(f);
}
*fp = 0;
/* Benutzte Faction-Ids */
no_used_faction_ids = ri(F);
/* used_faction_ids = gc_add(malloc(no_used_faction_ids*sizeof(int))); */
used_faction_ids = malloc(no_used_faction_ids*sizeof(int));
for(i=0; i < no_used_faction_ids; i++) {
used_faction_ids[i] = ri(F);
i = ri(F);
while (i--) {
ri(F); /* used faction ids. ignore. */
}
/* Regionen */
@ -1795,7 +1807,7 @@ readgame(const char * filename, int backup)
if (dirtyload) break;
skip = true;
}
if ((n%1024)==0) { /* das spart extrem Zeit */
if ((n & 0x3FF) == 0) { /* das spart extrem Zeit */
printf(" - Einzulesende Regionen: %d/%d ", rmax, n);
printf("* %d,%d \r", x, y);
}
@ -1818,6 +1830,8 @@ readgame(const char * filename, int backup)
b = (building *) calloc(1, sizeof(building));
b->no = rid(F);
*bp = b;
bp = &b->next;
bhash(b);
rds(F, &b->name);
if (lomem) rds(F, 0);
@ -1837,7 +1851,6 @@ readgame(const char * filename, int backup)
}
b->region = r;
a_read(F, &b->attribs);
addlist2(bp, b);
}
/* Schiffe */
@ -1845,10 +1858,11 @@ readgame(const char * filename, int backup)
shp = &r->ships;
while (--p >= 0) {
sh = (ship *) calloc(1, sizeof(ship));
ship * sh = (ship *) calloc(1, sizeof(ship));
sh->region = r;
sh->no = rid(F);
*shp = sh;
shp = &sh->next;
shash(sh);
rds(F, &sh->name);
if (lomem) rds(F, 0);
@ -1868,8 +1882,6 @@ readgame(const char * filename, int backup)
sh->coast = (direction_t)ri(F);
a_read(F, &sh->attribs);
addlist2(shp, sh);
}
*shp = 0;
@ -1882,9 +1894,12 @@ readgame(const char * filename, int backup)
while (--p >= 0) {
unit * u = readunit(F);
sc_mage * mage;
assert(u->region==NULL);
u->region = r;
addlist2(up,u);
*up = u;
up = &u->next;
update_interval(u->faction, u->region);
mage = get_mage(u);
if (mage && mage->spellcount<0) {
@ -1943,7 +1958,7 @@ int
writegame(const char *filename, char quiet)
{
char *base;
int i,n;
int n;
faction *f;
region *r;
building *b;
@ -2035,14 +2050,7 @@ writegame(const char *filename, char quiet)
writefaction(F, f);
}
wi(F, no_used_faction_ids);
wnl(F);
for(i=0; i<no_used_faction_ids; i++) {
wi(F, used_faction_ids[i]);
wnl(F);
}
wi(F, 0); /* used faction ids. old stuff */
wnl(F);
/* Write regions */

View File

@ -1124,6 +1124,7 @@ get_modifier(const unit *u, skill_t sk, int level, const region *r, boolean noit
}
skill = skillmod(u->attribs, u, r, sk, skill, SMF_ALWAYS);
#ifdef KARMA_MODULE
if (fspecial(u->faction, FS_TELEPATHY)) {
switch(sk) {
case SK_ALCHEMY:
@ -1137,6 +1138,7 @@ get_modifier(const unit *u, skill_t sk, int level, const region *r, boolean noit
skill -= 2;
}
}
#endif
#ifdef HUNGER_REDUCES_SKILL
if (fval(u, UFL_HUNGER)) {

View File

@ -7046,9 +7046,10 @@ sp_destroy_curse(castorder *co)
int
sp_becomewyrm(castorder *co)
{
#ifdef KARMA_MODULE
unit *u = co->magician.u;
int wyrms_already_created = 0;
int wyrms_allowed;
int wyrms_allowed = 0;
attrib *a;
wyrms_allowed = fspecial(u->faction, FS_WYRM);
@ -7073,6 +7074,9 @@ sp_becomewyrm(castorder *co)
ADDMSG(&u->faction->msgs, msg_message("becomewyrm", "u", u));
return co->level;
#else
return 0;
#endif /* KARMA_MODULE */
}
/* ------------------------------------------------------------- */

View File

@ -310,7 +310,6 @@ game_done(void)
faction *f, *f2;
ship *s, *s2;
free(used_faction_ids);
for (r = regions; r; r = r2) {
for (u = r->units; u; u = u2) {
u2 = u->next;

View File

@ -356,8 +356,6 @@ game_done(void)
* nicht freigegebenem Speicher sucht, der nicht bis zum Ende benötigt
* wird (temporäre Hilsstrukturen) */
free(used_faction_ids);
while (regions) {
region *r = regions;
regions = r->next;

View File

@ -1525,7 +1525,6 @@ makemonsters(void)
factions=f;
f->options = Pow(O_REPORT);
f->no=MONSTER_FACTION;
register_faction_id(f->no);
f->subscription = 0;
f->name=strdup("Monster");
f->passw=strdup("abc123");