static int att_modification(const unit * u, skill_t sk) { double result = 0; static bool init = false; static const curse_type *skillmod_ct, *gbdream_ct, *worse_ct; curse *c; if (!init) { init = true; skillmod_ct = ct_find("skillmod"); gbdream_ct = ct_find("gbdream"); worse_ct = ct_find("worse"); } c = get_curse(u->attribs, worse_ct); if (c != NULL) result += curse_geteffect(c); if (skillmod_ct) { attrib *a = a_find(u->attribs, &at_curse); while (a && a->type == &at_curse) { curse *c = (curse *) a->data.v; if (c->type == skillmod_ct && c->data.i == sk) { result += curse_geteffect(c); break; } a = a->next; } } /* TODO hier kann nicht mit get/iscursed gearbeitet werden, da nur der * jeweils erste vom Typ C_GBDREAM zurückgegen wird, wir aber alle * durchsuchen und aufaddieren müssen */ if (u->region) { double bonus = 0, malus = 0; attrib *a = a_find(u->region->attribs, &at_curse); while (a && a->type == &at_curse) { curse *c = (curse *) a->data.v; if (curse_active(c) && c->type == gbdream_ct) { double mod = curse_geteffect(c); unit *mage = c->magician; /* wir suchen jeweils den größten Bonus und den größten Malus */ if (mod > bonus) { if (mage == NULL || mage->number == 0 || alliedunit(mage, u->faction, HELP_GUARD)) { bonus = mod; } } else if (mod < malus) { if (mage == NULL || !alliedunit(mage, u->faction, HELP_GUARD)) { malus = mod; } } } a = a->next; } result = result + bonus + malus; } return (int)result; }
int unit_max_hp(const unit * u) { static int rules_stamina = -1; int h; double p; static const curse_type *heal_ct = NULL; if (rules_stamina < 0) { rules_stamina = get_param_int(global.parameters, "rules.stamina", STAMINA_AFFECTS_HP); } h = u_race(u)->hitpoints; if (heal_ct == NULL) heal_ct = ct_find("healingzone"); if (rules_stamina & 1) { p = pow(effskill(u, SK_STAMINA) / 2.0, 1.5) * 0.2; h += (int)(h * p + 0.5); } /* der healing curse verändert die maximalen hp */ if (heal_ct) { curse *c = get_curse(u->region->attribs, heal_ct); if (c) { h = (int)(h * (1.0 + (curse_geteffect(c) / 100))); } } return h; }
int curse_geteffect_int(const curse * c) { float effect = curse_geteffect(c); if (effect - (int)effect != 0) { log_error("curse has an integer attribute with float value: '%s' = %lf", c->type->cname, effect); } return (int)effect; }
/* erhöht/senkt regeneration und maxaura um effect% */ static message *cinfo_auraboost(const void *obj, objtype_t typ, const curse * c, int self) { struct unit *u = (struct unit *)obj; unused_arg(typ); assert(typ == TYP_UNIT); if (self != 0) { if (curse_geteffect(c) > 100) { return msg_message("curseinfo::auraboost_0", "unit id", u, c->no); } else { return msg_message("curseinfo::auraboost_1", "unit id", u, c->no); } } return NULL; }
/** handles the "orcish" curse that makes units grow like old orks * This would probably be better handled in an age-function for the curse, * but it's now being called by randomevents() */ static void orc_growth(void) { region *r; for (r = regions; r; r = r->next) { unit *u; for (u = r->units; u; u = u->next) { static bool init = false; static const curse_type *ct_orcish = 0; curse *c = 0; if (!init) { init = true; ct_orcish = ct_find("orcish"); } if (ct_orcish) c = get_curse(u->attribs, ct_orcish); if (c && !has_skill(u, SK_MAGIC) && !has_skill(u, SK_ALCHEMY) && !fval(u, UFL_HERO)) { int n; int increase = 0; int num = get_cursedmen(u, c); double prob = curse_geteffect(c); const item_type * it_chastity = it_find("ao_chastity"); if (it_chastity) { num -= i_get(u->items, it_chastity); } for (n = num; n > 0; n--) { if (chance(prob)) { ++increase; } } if (increase) { unit *u2 = create_unit(r, u->faction, increase, u_race(u), 0, NULL, u); transfermen(u2, u, u2->number); ADDMSG(&u->faction->msgs, msg_message("orcgrowth", "unit amount race", u, increase, u_race(u))); } } } } }