forked from github/server
Spell resistance
This commit is contained in:
parent
a5d98c8efe
commit
4fc7a7a741
1 changed files with 103 additions and 101 deletions
|
@ -1578,25 +1578,25 @@ verify_unit(region * r, unit * mage, const spell * sp, spllprm * spobj, order *
|
||||||
static void
|
static void
|
||||||
verify_targets(castorder *co, int * invalid, int * resist, int * success)
|
verify_targets(castorder *co, int * invalid, int * resist, int * success)
|
||||||
{
|
{
|
||||||
unit *mage = co->magician.u;
|
unit *mage = co->magician.u;
|
||||||
const spell *sp = co->sp;
|
const spell *sp = co->sp;
|
||||||
region *target_r = co->rt;
|
region *target_r = co->rt;
|
||||||
spellparameter *sa = co->par;
|
spellparameter *sa = co->par;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
*invalid = 0;
|
*invalid = 0;
|
||||||
*resist = 0;
|
*resist = 0;
|
||||||
*success = 0;
|
*success = 0;
|
||||||
|
|
||||||
if (sa) {
|
if (sa) {
|
||||||
/* zuerst versuchen wir vorher nicht gefundene Objekte zu finden.
|
/* zuerst versuchen wir vorher nicht gefundene Objekte zu finden.
|
||||||
* Wurde ein Objekt durch globalsuche gefunden, obwohl der Zauber
|
* Wurde ein Objekt durch globalsuche gefunden, obwohl der Zauber
|
||||||
* gar nicht global hätte suchen dürften, setzen wir das Objekt
|
* gar nicht global hätte suchen dürften, setzen wir das Objekt
|
||||||
* zurück. */
|
* zurück. */
|
||||||
for (i=0;i<sa->length;i++) {
|
for (i=0;i<sa->length;i++) {
|
||||||
spllprm * spobj = sa->param[i];
|
spllprm * spobj = sa->param[i];
|
||||||
|
|
||||||
switch(spobj->typ) {
|
switch(spobj->typ) {
|
||||||
case SPP_TEMP:
|
case SPP_TEMP:
|
||||||
case SPP_UNIT:
|
case SPP_UNIT:
|
||||||
if (!verify_unit(target_r, mage, sp, spobj, co->order)) ++*invalid;
|
if (!verify_unit(target_r, mage, sp, spobj, co->order)) ++*invalid;
|
||||||
|
@ -1609,128 +1609,130 @@ verify_targets(castorder *co, int * invalid, int * resist, int * success)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Nun folgen die Tests auf cansee und Magieresistenz */
|
/* Nun folgen die Tests auf cansee und Magieresistenz */
|
||||||
for (i=0;i<sa->length;i++) {
|
for (i=0;i<sa->length;i++) {
|
||||||
spllprm * spobj = sa->param[i];
|
spllprm * spobj = sa->param[i];
|
||||||
unit * u;
|
unit * u;
|
||||||
building * b;
|
building * b;
|
||||||
ship * sh;
|
ship * sh;
|
||||||
region * tr;
|
region * tr;
|
||||||
|
|
||||||
if (spobj->flag == TARGET_NOTFOUND) continue;
|
if (spobj->flag == TARGET_NOTFOUND) continue;
|
||||||
switch(spobj->typ) {
|
switch(spobj->typ) {
|
||||||
case SPP_TEMP:
|
case SPP_TEMP:
|
||||||
case SPP_UNIT:
|
case SPP_UNIT:
|
||||||
u = spobj->data.u;
|
u = spobj->data.u;
|
||||||
|
|
||||||
if ((sp->sptyp & TESTRESISTANCE)
|
if ((sp->sptyp & TESTRESISTANCE)
|
||||||
&& target_resists_magic(mage, u, TYP_UNIT, 0))
|
&& target_resists_magic(mage, u, TYP_UNIT, 0))
|
||||||
{
|
{
|
||||||
/* Fehlermeldung */
|
/* Fehlermeldung */
|
||||||
spobj->data.i = u->no;
|
spobj->data.i = u->no;
|
||||||
spobj->flag = TARGET_RESISTS;
|
spobj->flag = TARGET_RESISTS;
|
||||||
++*resist;
|
++*resist;
|
||||||
ADDMSG(&mage->faction->msgs, msg_message("spellunitresists",
|
ADDMSG(&mage->faction->msgs, msg_message("spellunitresists",
|
||||||
"unit region command target",
|
"unit region command target",
|
||||||
mage, mage->region, co->order, u));
|
mage, mage->region, co->order, u));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Test auf Parteieigenschaft Magieresistsenz */
|
/* TODO: Test auf Parteieigenschaft Magieresistsenz */
|
||||||
++*success;
|
++*success;
|
||||||
break;
|
break;
|
||||||
case SPP_BUILDING:
|
case SPP_BUILDING:
|
||||||
b = spobj->data.b;
|
b = spobj->data.b;
|
||||||
|
|
||||||
if ((sp->sptyp & TESTRESISTANCE)
|
if ((sp->sptyp & TESTRESISTANCE)
|
||||||
&& target_resists_magic(mage, b, TYP_BUILDING, 0))
|
&& target_resists_magic(mage, b, TYP_BUILDING, 0))
|
||||||
{ /* Fehlermeldung */
|
{ /* Fehlermeldung */
|
||||||
spobj->data.i = b->no;
|
spobj->data.i = b->no;
|
||||||
spobj->flag = TARGET_RESISTS;
|
spobj->flag = TARGET_RESISTS;
|
||||||
++*resist;
|
++*resist;
|
||||||
ADDMSG(&mage->faction->msgs, msg_message("spellbuildingresists",
|
ADDMSG(&mage->faction->msgs, msg_message("spellbuildingresists",
|
||||||
"unit region command id",
|
"unit region command id",
|
||||||
mage, mage->region, co->order, spobj->data.i));
|
mage, mage->region, co->order, spobj->data.i));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++*success;
|
++*success;
|
||||||
break;
|
break;
|
||||||
case SPP_SHIP:
|
case SPP_SHIP:
|
||||||
sh = spobj->data.sh;
|
sh = spobj->data.sh;
|
||||||
|
|
||||||
if ((sp->sptyp & TESTRESISTANCE)
|
if ((sp->sptyp & TESTRESISTANCE)
|
||||||
&& target_resists_magic(mage, sh, TYP_SHIP, 0))
|
&& target_resists_magic(mage, sh, TYP_SHIP, 0))
|
||||||
{ /* Fehlermeldung */
|
{ /* Fehlermeldung */
|
||||||
spobj->data.i = sh->no;
|
spobj->data.i = sh->no;
|
||||||
spobj->flag = TARGET_RESISTS;
|
spobj->flag = TARGET_RESISTS;
|
||||||
++*resist;
|
++*resist;
|
||||||
ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order,
|
ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order,
|
||||||
"spellshipresists", "ship", sh));
|
"spellshipresists", "ship", sh));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++*success;
|
++*success;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SPP_REGION:
|
case SPP_REGION:
|
||||||
/* haben wir ein Regionsobjekt, dann wird auch dieses und
|
/* haben wir ein Regionsobjekt, dann wird auch dieses und
|
||||||
nicht target_r überprüft. */
|
nicht target_r überprüft. */
|
||||||
tr = spobj->data.r;
|
tr = spobj->data.r;
|
||||||
|
|
||||||
if ((sp->sptyp & TESTRESISTANCE)
|
if ((sp->sptyp & TESTRESISTANCE)
|
||||||
&& target_resists_magic(mage, tr, TYP_REGION, 0))
|
&& target_resists_magic(mage, tr, TYP_REGION, 0))
|
||||||
{ /* Fehlermeldung */
|
{ /* Fehlermeldung */
|
||||||
spobj->flag = TARGET_RESISTS;
|
spobj->flag = TARGET_RESISTS;
|
||||||
++*resist;
|
++*resist;
|
||||||
ADDMSG(&mage->faction->msgs, msg_message("spellregionresists",
|
ADDMSG(&mage->faction->msgs, msg_message("spellregionresists",
|
||||||
"unit region command", mage, mage->region, co->order));
|
"unit region command", mage, mage->region, co->order));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++*success;
|
++*success;
|
||||||
break;
|
break;
|
||||||
case SPP_INT:
|
case SPP_INT:
|
||||||
case SPP_STRING:
|
case SPP_STRING:
|
||||||
++*success;
|
++*success;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* der Zauber hat keine expliziten Parameter/Ziele, es kann sich
|
/* der Zauber hat keine expliziten Parameter/Ziele, es kann sich
|
||||||
* aber um einen Regionszauber handeln. Wenn notwendig hier die
|
* aber um einen Regionszauber handeln. Wenn notwendig hier die
|
||||||
* Magieresistenz der Region prüfen. */
|
* Magieresistenz der Region prüfen. */
|
||||||
if ((sp->sptyp & REGIONSPELL)) {
|
if ((sp->sptyp & REGIONSPELL)) {
|
||||||
/* Zielobjekt Region anlegen */
|
/* Zielobjekt Region anlegen */
|
||||||
spllprm * spobj = malloc(sizeof(spllprm));
|
spllprm * spobj = malloc(sizeof(spllprm));
|
||||||
spobj->flag = 0;
|
spobj->flag = 0;
|
||||||
spobj->typ = SPP_REGION;
|
spobj->typ = SPP_REGION;
|
||||||
spobj->data.r = target_r;
|
spobj->data.r = target_r;
|
||||||
|
|
||||||
sa = calloc(1, sizeof(spellparameter));
|
|
||||||
sa->length = 1;
|
|
||||||
sa->param = calloc(sa->length, sizeof(spllprm *));
|
|
||||||
sa->param[0] = spobj;
|
|
||||||
co->par = sa;
|
|
||||||
|
|
||||||
if ((sp->sptyp & TESTRESISTANCE)) {
|
sa = calloc(1, sizeof(spellparameter));
|
||||||
if (target_resists_magic(mage, target_r, TYP_REGION, 0)) {
|
sa->length = 1;
|
||||||
/* Fehlermeldung */
|
sa->param = calloc(sa->length, sizeof(spllprm *));
|
||||||
|
sa->param[0] = spobj;
|
||||||
|
co->par = sa;
|
||||||
|
|
||||||
|
if ((sp->sptyp & TESTRESISTANCE)) {
|
||||||
|
if (target_resists_magic(mage, target_r, TYP_REGION, 0)) {
|
||||||
|
/* Fehlermeldung */
|
||||||
ADDMSG(&mage->faction->msgs, msg_message("spellregionresists",
|
ADDMSG(&mage->faction->msgs, msg_message("spellregionresists",
|
||||||
"unit region command", mage, mage->region, co->order));
|
"unit region command", mage, mage->region, co->order));
|
||||||
spobj->flag = TARGET_RESISTS;
|
spobj->flag = TARGET_RESISTS;
|
||||||
++*resist;
|
++*resist;
|
||||||
} else {
|
} else {
|
||||||
++*success;
|
++*success;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
++*success;
|
++*success;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
}
|
++*success;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
|
Loading…
Reference in a new issue