forked from github/server
Merge pull request #283 from ennorehling/cursed-faction
The revenge of Igjarjuk
This commit is contained in:
commit
70aff6f567
|
@ -304,6 +304,9 @@
|
|||
<spell name="wolfhowl" rank="5" index="94" variable="true" combat="1">
|
||||
<resource name="aura" amount="2" cost="level"/>
|
||||
</spell>
|
||||
<spell name="igjarjuk" rank="5" index="94" variable="true" combat="1">
|
||||
<function name="cast" value="igjarjuk"/>
|
||||
</spell>
|
||||
<spell name="resist_magic" rank="2" index="97" parameters="u+" los="true" ship="true" variable="true">
|
||||
<resource name="aura" amount="5" cost="level"/>
|
||||
</spell>
|
||||
|
|
50
src/battle.c
50
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)
|
||||
|
@ -1668,6 +1670,12 @@ static void report_failed_spell(struct battle * b, struct unit * mage, const str
|
|||
msg_release(m);
|
||||
}
|
||||
|
||||
static castorder * create_castorder_combat(castorder *co, fighter *fig, const spell * sp, int level, double force) {
|
||||
co = create_castorder(co, fig->unit, 0, sp, fig->unit->region, level, force, 0, 0, 0);
|
||||
co->magician.fig = fig;
|
||||
return co;
|
||||
}
|
||||
|
||||
void do_combatmagic(battle * b, combatmagic_t was)
|
||||
{
|
||||
side *s;
|
||||
|
@ -1678,6 +1686,42 @@ void do_combatmagic(battle * b, combatmagic_t was)
|
|||
|
||||
memset(spellranks, 0, sizeof(spellranks));
|
||||
|
||||
#ifdef FFL_CURSED
|
||||
if (was == DO_PRECOMBATSPELL) {
|
||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||
fighter *fig = 0;
|
||||
if (s->bf->attacker) {
|
||||
spell *sp = find_spell("igjarjuk");
|
||||
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_combat(0, fig, sp, 10, 10);
|
||||
co->magician.fig = fig;
|
||||
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) {
|
||||
|
@ -1735,8 +1779,7 @@ void do_combatmagic(battle * b, combatmagic_t was)
|
|||
pay_spell(mage, sp, level, 1);
|
||||
}
|
||||
else {
|
||||
co = create_castorder(0, fig->unit, 0, sp, r, level, power, 0, 0, 0);
|
||||
co->magician.fig = fig;
|
||||
co = create_castorder_combat(0, fig, sp, level, power);
|
||||
add_castorder(&spellranks[sp->rank], co);
|
||||
}
|
||||
}
|
||||
|
@ -1768,8 +1811,7 @@ static int cast_combatspell(troop at, const spell * sp, int level, double force)
|
|||
{
|
||||
castorder co;
|
||||
|
||||
create_castorder(&co, at.fighter->unit, 0, sp, at.fighter->unit->region, level, force, 0, 0, 0);
|
||||
co.magician.fig = at.fighter;
|
||||
create_castorder_combat(&co, at.fighter, sp, level, force);
|
||||
level = sp->cast(&co);
|
||||
free_castorder(&co);
|
||||
if (level > 0) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -6516,6 +6516,7 @@ static spelldata spell_functions[] = {
|
|||
{ "stormwinds", sp_stormwinds, 0 },
|
||||
{ "homestone", sp_homestone, 0 },
|
||||
{ "wolfhowl", sp_wolfhowl, 0 },
|
||||
{ "igjarjuk", sp_igjarjuk, 0 },
|
||||
{ "versteinern", sp_petrify, 0 },
|
||||
{ "strongwall", sp_strong_wall, 0 },
|
||||
{ "gwyrrddestroymagic", sp_destroy_magic, 0 },
|
||||
|
|
|
@ -848,44 +848,63 @@ int sp_shadowcall(struct castorder * co)
|
|||
return level;
|
||||
}
|
||||
|
||||
int sp_wolfhowl(struct castorder * co)
|
||||
static fighter *summon_allies(const fighter *fi, const race *rc, int number) {
|
||||
attrib *a;
|
||||
unit *mage = fi->unit;
|
||||
side *si = fi->side;
|
||||
battle *b = si->battle;
|
||||
region *r = b->region;
|
||||
message *msg;
|
||||
unit *u =
|
||||
create_unit(r, mage->faction, number, rc, 0, NULL, mage);
|
||||
leave(u, true);
|
||||
setstatus(u, ST_FIGHT);
|
||||
|
||||
u->hp = u->number * unit_max_hp(u);
|
||||
|
||||
if (fval(mage, UFL_ANON_FACTION)) {
|
||||
fset(u, UFL_ANON_FACTION);
|
||||
}
|
||||
|
||||
a = a_new(&at_unitdissolve);
|
||||
a->data.ca[0] = 0;
|
||||
a->data.ca[1] = 100;
|
||||
a_add(&u->attribs, a);
|
||||
|
||||
msg =
|
||||
msg_message("sp_wolfhowl_effect", "mage amount race",
|
||||
mage, u->number, rc);
|
||||
message_all(b, msg);
|
||||
msg_release(msg);
|
||||
|
||||
return make_fighter(b, u, si, is_attacker(fi));
|
||||
}
|
||||
|
||||
int sp_igjarjuk(castorder *co) {
|
||||
unit *u;
|
||||
fighter * fi = co->magician.fig;
|
||||
const race *rc = get_race(RC_WYRM);
|
||||
fi = summon_allies(fi, rc, 1);
|
||||
u = fi->unit;
|
||||
unit_setname(u, "Igjarjuk");
|
||||
return co->level;
|
||||
}
|
||||
|
||||
int sp_wolfhowl(castorder * co)
|
||||
{
|
||||
fighter * fi = co->magician.fig;
|
||||
int level = co->level;
|
||||
double power = co->force;
|
||||
battle *b = fi->side->battle;
|
||||
region *r = b->region;
|
||||
unit *mage = fi->unit;
|
||||
attrib *a;
|
||||
message *msg;
|
||||
int force = (int)(get_force(power, 3) / 2);
|
||||
const race * rc = get_race(RC_WOLF);
|
||||
if (force > 0) {
|
||||
unit *u =
|
||||
create_unit(r, mage->faction, force, rc, 0, NULL, mage);
|
||||
leave(u, true);
|
||||
setstatus(u, ST_FIGHT);
|
||||
|
||||
set_level(u, SK_WEAPONLESS, (int)(power / 3));
|
||||
set_level(u, SK_STAMINA, (int)(power / 3));
|
||||
u->hp = u->number * unit_max_hp(u);
|
||||
|
||||
if (fval(mage, UFL_ANON_FACTION)) {
|
||||
fset(u, UFL_ANON_FACTION);
|
||||
}
|
||||
|
||||
a = a_new(&at_unitdissolve);
|
||||
a->data.ca[0] = 0;
|
||||
a->data.ca[1] = 100;
|
||||
a_add(&u->attribs, a);
|
||||
|
||||
make_fighter(b, u, fi->side, is_attacker(fi));
|
||||
unit *u;
|
||||
int skills = (int)(power/3);
|
||||
fi = summon_allies(fi, rc, force);
|
||||
u = fi->unit;
|
||||
set_level(u, SK_WEAPONLESS, skills);
|
||||
set_level(u, SK_STAMINA, skills);
|
||||
}
|
||||
msg =
|
||||
msg_message("sp_wolfhowl_effect", "mage amount race", mage, force, rc);
|
||||
message_all(b, msg);
|
||||
msg_release(msg);
|
||||
|
||||
return level;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ extern "C" {
|
|||
extern int sp_mindblast_temp(struct castorder * co);
|
||||
extern int sp_speed(struct castorder * co);
|
||||
extern int sp_wolfhowl(struct castorder * co);
|
||||
extern int sp_igjarjuk(struct castorder * co);
|
||||
extern int sp_dragonodem(struct castorder * co);
|
||||
extern int sp_reduceshield(struct castorder * co);
|
||||
extern int sp_armorshield(struct castorder * co);
|
||||
|
|
|
@ -42,8 +42,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
void register_triggers(void)
|
||||
{
|
||||
if (verbosity >= 2)
|
||||
printf("- registering triggers\n");
|
||||
tt_register(&tt_changefaction);
|
||||
tt_register(&tt_changerace);
|
||||
tt_register(&tt_createcurse);
|
||||
|
|
Loading…
Reference in New Issue