/* * C_SPARKLE */ static message *cinfo_sparkle(const void *obj, objtype_t typ, const curse * c, int self) { const char *effects[] = { NULL, /* end grau */ "sparkle_1", "sparkle_2", NULL, /* end traum */ "sparkle_3", "sparkle_4", NULL, /* end tybied */ "sparkle_5", "sparkle_6", "sparkle_7", "sparkle_8", NULL, /* end cerrdor */ "sparkle_9", "sparkle_10", "sparkle_11", "sparkle_12", NULL, /* end gwyrrd */ "sparkle_13", "sparkle_14", "sparkle_15", "sparkle_16", "sparkle_17", "sparkle_18", NULL, /* end draig */ }; int m, begin = 0, end = 0; unit *u; unused_arg(typ); assert(typ == TYP_UNIT); u = (unit *)obj; if (!c->magician || !c->magician->faction) return NULL; for (m = 0; m != c->magician->faction->magiegebiet; ++m) { while (effects[end] != NULL) ++end; begin = end + 1; end = begin; } while (effects[end] != NULL) ++end; if (end == begin) return NULL; else { int index = begin + curse_geteffect_int(c) % (end - begin); return msg_message(mkname("curseinfo", effects[index]), "unit id", u, c->no); } }
int shipspeed(const ship * sh, const unit * u) { attrib *a; struct curse *c; int k, bonus; assert(sh); if (!u) u = ship_owner(sh); if (!u) return 0; assert(u->ship == sh); assert(u == ship_owner(sh)); assert(sh->type->construction); k = sh->type->range; if (sh->size != sh->type->construction->maxsize) return 0; if (sh->attribs) { if (curse_active(get_curse(sh->attribs, &ct_stormwind))) { k *= 2; } if (curse_active(get_curse(sh->attribs, &ct_nodrift))) { k += 1; } } if (u->faction->race == u_race(u)) { /* race bonus for this faction? */ if (fval(u_race(u), RCF_SHIPSPEED)) { k += 1; } } bonus = ShipSpeedBonus(u); if (bonus > 0 && sh->type->range_max > sh->type->range) { int crew = crew_skill(sh); int crew_bonus = (crew / sh->type->sumskill / 2) - 1; if (crew_bonus > 0) { int sbonus = sh->type->range_max - sh->type->range; if (bonus > sbonus) bonus = sbonus; if (bonus > crew_bonus) bonus = crew_bonus; } else { bonus = 0; } } k += bonus; a = a_find(sh->attribs, &at_speedup); while (a != NULL && a->type == &at_speedup) { k += a->data.sa[0]; a = a->next; } c = get_curse(sh->attribs, &ct_shipspeedup); while (c) { k += curse_geteffect_int(c); c = c->nexthash; } if (sh->damage > 0) { int size = sh->size * DAMAGE_SCALE; k *= (size - sh->damage); k = (k + size - 1) / size; } return k; }
int shipspeed(const ship * sh, const unit * u) { int k = sh->type->range; static const struct curse_type *stormwind_ct, *nodrift_ct; static bool init; attrib *a; struct curse *c; int bonus; assert(sh); if (!u) u = ship_owner(sh); if (!u) return 0; assert(u->ship == sh); assert(u == ship_owner(sh)); assert(sh->type->construction); assert(sh->type->construction->improvement == NULL); /* sonst ist construction::size nicht ship_type::maxsize */ if (!init) { init = true; stormwind_ct = ct_find("stormwind"); nodrift_ct = ct_find("nodrift"); } if (sh->size != sh->type->construction->maxsize) return 0; if (curse_active(get_curse(sh->attribs, stormwind_ct))) k *= 2; if (curse_active(get_curse(sh->attribs, nodrift_ct))) k += 1; if (u->faction->race == u_race(u)) { /* race bonus for this faction? */ if (fval(u_race(u), RCF_SHIPSPEED)) { k += 1; } } bonus = ShipSpeedBonus(u); if (bonus > 0 && sh->type->range_max>sh->type->range) { int crew = crew_skill(sh); int crew_bonus = (crew / sh->type->sumskill / 2) - 1; if (crew_bonus > 0) { bonus = _min(bonus, crew_bonus); bonus = _min(bonus, sh->type->range_max - sh->type->range); } else { bonus = 0; } } k += bonus; a = a_find(sh->attribs, &at_speedup); while (a != NULL && a->type == &at_speedup) { k += a->data.sa[0]; a = a->next; } c = get_curse(sh->attribs, ct_find("shipspeedup")); while (c) { k += curse_geteffect_int(c); c = c->nexthash; } if (sh->damage>0) { int size = sh->size * DAMAGE_SCALE; k *= (size - sh->damage); k = (k + size - 1) / size; } return k; }