#include #include #include #include #include #include #include attrib_type at_stealth = { "stealth", NULL, NULL, NULL, a_writeint, a_readint }; void u_seteffstealth(unit * u, int value) { if (skill_enabled(SK_STEALTH)) { attrib *a = NULL; if (u->flags & UFL_STEALTH) { a = a_find(u->attribs, &at_stealth); } if (value < 0) { if (a != NULL) { u->flags &= ~UFL_STEALTH; a_remove(&u->attribs, a); } return; } if (a == NULL) { a = a_add(&u->attribs, a_new(&at_stealth)); u->flags |= UFL_STEALTH; } a->data.i = value; } } int u_geteffstealth(const unit *u) { if (skill_enabled(SK_STEALTH)) { if (u->flags & UFL_STEALTH) { attrib *a = a_find(u->attribs, &at_stealth); if (a != NULL) return a->data.i; } } return -1; } int eff_stealth(const unit * u, const region * r) { int e = 0; /* Auf Schiffen keine Tarnung! */ if (!u->ship && skill_enabled(SK_STEALTH)) { e = eff_skill(u, SK_STEALTH, r); if (u->flags & UFL_STEALTH) { int es = u_geteffstealth(u); if (es >= 0 && es < e) return es; } } return e; }