forked from github/server
Bug 2584: gray mages can regenerate aura.
This commit is contained in:
parent
3434bbe67d
commit
a461bff6f0
35
src/magic.c
35
src/magic.c
|
@ -117,6 +117,11 @@ typedef struct sc_mage {
|
|||
struct spellbook *spellbook;
|
||||
} sc_mage;
|
||||
|
||||
void mage_set_spellpoints(sc_mage *m, int aura)
|
||||
{
|
||||
m->spellpoints = aura;
|
||||
}
|
||||
|
||||
int mage_get_spellpoints(const sc_mage *m)
|
||||
{
|
||||
return m ? m->spellpoints : 0;
|
||||
|
@ -603,7 +608,7 @@ void set_spellpoints(unit * u, int sp)
|
|||
{
|
||||
sc_mage *m = get_mage(u);
|
||||
if (m) {
|
||||
m->spellpoints = sp;
|
||||
mage_set_spellpoints(m, sp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -615,18 +620,6 @@ int change_spellpoints(unit * u, int mp)
|
|||
return mage_change_spellpoints(get_mage(u), mp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bietet die Moeglichkeit, die maximale Anzahl der Magiepunkte mit
|
||||
* Regionszaubern oder Attributen zu beinflussen
|
||||
*/
|
||||
static int get_spchange(const unit * u)
|
||||
{
|
||||
sc_mage *m;
|
||||
|
||||
m = get_mage(u);
|
||||
return m ? m->spchange : 0;
|
||||
}
|
||||
|
||||
/* ein Magier kann normalerweise maximal Stufe^2.1/1.2+1 Magiepunkte
|
||||
* haben.
|
||||
* Manche Rassen haben einen zusaetzlichen Multiplikator
|
||||
|
@ -655,12 +648,15 @@ int max_spellpoints(const struct unit *u, const region * r)
|
|||
double potenz = 2.1;
|
||||
double divisor = 1.2;
|
||||
const struct resource_type *rtype;
|
||||
const sc_mage *m;
|
||||
|
||||
assert(u);
|
||||
if (!r) r = u->region;
|
||||
|
||||
sk = effskill(u, SK_MAGIC, r);
|
||||
msp = rc_maxaura(u_race(u)) * (pow(sk, potenz) / divisor + 1) + get_spchange(u);
|
||||
msp = rc_maxaura(u_race(u)) * (pow(sk, potenz) / divisor + 1);
|
||||
m = get_mage(u);
|
||||
if (m) msp += m->spchange;
|
||||
|
||||
rtype = rt_find("aurafocus");
|
||||
if (rtype && i_get(u->items, rtype->itype) > 0) {
|
||||
|
@ -1464,9 +1460,11 @@ void regenerate_aura(void)
|
|||
|
||||
for (r = regions; r; r = r->next) {
|
||||
for (u = r->units; u; u = u->next) {
|
||||
if (u->number && is_mage(u)) {
|
||||
aura = get_spellpoints(u);
|
||||
auramax = max_spellpoints_depr(r, u);
|
||||
if (u->number && u->attribs) {
|
||||
sc_mage *m = get_mage(u);
|
||||
if (m) {
|
||||
aura = mage_get_spellpoints(m);
|
||||
auramax = max_spellpoints(u, r);
|
||||
if (aura < auramax) {
|
||||
struct building *b = inside_building(u);
|
||||
const struct building_type *btype = building_is_active(b) ? b->type : NULL;
|
||||
|
@ -1501,7 +1499,8 @@ void regenerate_aura(void)
|
|||
"unit region amount", u, r, regen));
|
||||
}
|
||||
if (aura > auramax) aura = auramax;
|
||||
set_spellpoints(u, aura);
|
||||
mage_set_spellpoints(m, aura);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,6 +210,7 @@ extern "C" {
|
|||
const struct spell *mage_get_combatspell(const struct sc_mage *mage, int nr, int *level);
|
||||
struct spellbook * mage_get_spellbook(const struct sc_mage * mage);
|
||||
int mage_get_spellpoints(const struct sc_mage *m);
|
||||
void mage_set_spellpoints(struct sc_mage *m, int aura);
|
||||
int mage_change_spellpoints(struct sc_mage *m, int delta);
|
||||
|
||||
enum magic_t unit_get_magic(const struct unit *u);
|
||||
|
|
Loading…
Reference in New Issue