int get_resource(const unit * u, const resource_type * rtype) { assert(rtype); if (rtype->uget) { /* this resource is probably special */ int i = rtype->uget(u, rtype); if (i >= 0) return i; } else if (rtype->uchange) { /* this resource is probably special */ int i = rtype->uchange((unit *)u, rtype, 0); if (i >= 0) return i; } if (rtype->itype) { return i_get(u->items, rtype->itype); } if (rtype == get_resourcetype(R_AURA)) { return get_spellpoints(u); } if (rtype == get_resourcetype(R_PERMAURA)) { return max_spellpoints(u->region, u); } log_error("trying to get unknown resource '%s'.\n", rtype->_name); return 0; }
static void do_shock(unit * u, const char *reason) { int i; if (u->number > 0) { /* HP - Verlust */ u->hp = (unit_max_hp(u) * u->number) / 10; u->hp = _max(1, u->hp); } /* Aura - Verlust */ if (is_mage(u)) { set_spellpoints(u, max_spellpoints(u->region, u) / 10); } /* Evt. Talenttageverlust */ for (i = 0; i != u->skill_size; ++i) if (rng_int() % 5 == 0) { skill *sv = u->skills + i; int weeks = (sv->level * sv->level - sv->level) / 2; int change = (weeks + 9) / 10; reduce_skill(u, sv, change); } /* Dies ist ein Hack, um das skillmod und familiar-Attribut beim Mage * zu löschen wenn der Familiar getötet wird. Da sollten wir über eine * saubere Implementation nachdenken. */ if (strcmp(reason, "trigger") == 0) { remove_familiar(u); } if (u->faction != NULL) { ADDMSG(&u->faction->msgs, msg_message("shock", "mage reason", u, _strdup(reason))); } }