From dd667aa7528b7aa164cb17b07f0a0bb4c531ddf3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 22 Aug 2015 17:56:36 +0200 Subject: [PATCH] cursed factions get to fight a wolfhowl if they attack (WIP) --- src/battle.c | 35 +++++++++++++++++++++++++++++++++++ src/kernel/faction.h | 4 ++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/battle.c b/src/battle.c index ebfde1548..bf1b0aa88 100644 --- a/src/battle.c +++ b/src/battle.c @@ -194,6 +194,7 @@ static void message_faction(battle * b, faction * f, struct message *m) { region *r = b->region; + assert(f); if (f->battles == NULL || f->battles->r != r) { struct bmsg *bm = (struct bmsg *)calloc(1, sizeof(struct bmsg)); bm->next = f->battles; @@ -210,6 +211,7 @@ void message_all(battle * b, message * m) watcher *w; for (bf = b->factions; bf; bf = bf->next) { + assert(bf->faction); message_faction(b, bf->faction, m); } if (p) @@ -1687,6 +1689,39 @@ void do_combatmagic(battle * b, combatmagic_t was) memset(spellranks, 0, sizeof(spellranks)); +#ifdef FFL_CURSED + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *fig = 0; + if (s->bf->attacker) { + spell *sp = find_spell("wolfhowl"); + if (sp && fval(s->faction, FFL_CURSED)) { + int si; + for (si = 0; s->enemies[si]; ++si) { + side *se = s->enemies[si]; + if (se && !fval(se->faction, FFL_NPC)) { + fighter *fi; + for (fi = se->fighters; fi; fi = fi->next) { + if (fi && (!fig || fig->unit->number > fi->unit->number)) { + fig = fi; + if (fig->unit->number == 1) { + break; + } + } + } + if (fig && fig->unit->number == 1) { + break; + } + } + } + if (fig) { + co = create_castorder(0, fig->unit, 0, sp, r, 10, 10, 0, 0, 0); + add_castorder(&spellranks[sp->rank], co); + break; + } + } + } + } +#endif for (s = b->sides; s != b->sides + b->nsides; ++s) { fighter *fig; for (fig = s->fighters; fig; fig = fig->next) { diff --git a/src/kernel/faction.h b/src/kernel/faction.h index db8ce4389..614b50d75 100644 --- a/src/kernel/faction.h +++ b/src/kernel/faction.h @@ -39,6 +39,7 @@ extern "C" { #define FFL_ISNEW (1<<1) #define FFL_RESTART (1<<2) #define FFL_QUIT (1<<3) +#define FFL_CURSED (1<<4) /* you're going to have a bad time */ #define FFL_DEFENDER (1<<10) #define FFL_SELECT (1<<18) /* ehemals f->dh, u->dh, r->dh, etc... */ #define FFL_NOAID (1<<21) /* Hilfsflag Kampf */ @@ -49,8 +50,7 @@ extern "C" { #define FFL_NOIDLEOUT (1<<24) /* Partei stirbt nicht an NMRs */ #define FFL_NPC (1<<25) /* eine Partei mit Monstern */ #define FFL_DBENTRY (1<<28) /* Partei ist in Datenbank eingetragen */ - -#define FFL_SAVEMASK (FFL_DEFENDER|FFL_NEWID|FFL_NPC|FFL_DBENTRY|FFL_NOIDLEOUT) +#define FFL_SAVEMASK (FFL_DEFENDER|FFL_NEWID|FFL_NPC|FFL_DBENTRY|FFL_NOIDLEOUT|FFL_CURSED) typedef struct faction { struct faction *next;