familiar crap.

This commit is contained in:
Enno Rehling 2006-04-22 21:45:59 +00:00
parent 722e66be41
commit d8a89d7630
1 changed files with 15 additions and 20 deletions

View File

@ -2172,30 +2172,25 @@ remove_familiar(unit *mage)
boolean boolean
create_newfamiliar(unit * mage, unit * familiar) create_newfamiliar(unit * mage, unit * familiar)
{ {
/* if the skill modifier for the mage does not yet exist, add it */ /* if the skill modifier for the mage does not yet exist, add it */
attrib *a; attrib *a;
attrib *afam = a_find(mage->attribs, &at_familiar); attrib *afam = a_find(mage->attribs, &at_familiar);
attrib *amage = a_find(familiar->attribs, &at_familiarmage); attrib *amage = a_find(familiar->attribs, &at_familiarmage);
if ((afam==NULL || afam->data.v==NULL) && (amage==NULL || amage->data.v==NULL)) { if (afam==NULL) {
afam = a_add(&mage->attribs, a_new(&at_familiar)); afam = a_add(&mage->attribs, a_new(&at_familiar));
afam->data.v = familiar;
amage = a_add(&familiar->attribs, a_new(&at_familiarmage));
amage->data.v = mage;
} else {
assert(afam->data.v == familiar);
assert(amage->data.v == mage);
if (afam->data.v != familiar || amage->data.v != mage) {
return false;
}
} }
afam->data.v = familiar;
if (amage==NULL) {
amage = a_add(&familiar->attribs, a_new(&at_familiarmage));
}
amage->data.v = mage;
/* TODO: Diese Attribute beim Tod des Familiars entfernen: */ /* TODO: Diese Attribute beim Tod des Familiars entfernen: */
/* Wenn der Magier stirbt, dann auch der Vertraute */ /* Wenn der Magier stirbt, dann auch der Vertraute */
add_trigger(&mage->attribs, "destroy", trigger_killunit(familiar)); add_trigger(&mage->attribs, "destroy", trigger_killunit(familiar));
/* Wenn der Vertraute stirbt, dann bekommt der Magier einen Schock */ /* Wenn der Vertraute stirbt, dann bekommt der Magier einen Schock */
add_trigger(&familiar->attribs, "destroy", trigger_shock(mage)); add_trigger(&familiar->attribs, "destroy", trigger_shock(mage));
a = a_find(mage->attribs, &at_skillmod); a = a_find(mage->attribs, &at_skillmod);
while (a && a->type==&at_skillmod) { while (a && a->type==&at_skillmod) {