forked from github/server
Bug 2584: gray mages can regenerate aura.
This commit is contained in:
parent
3434bbe67d
commit
a461bff6f0
2 changed files with 48 additions and 48 deletions
35
src/magic.c
35
src/magic.c
|
@ -117,6 +117,11 @@ typedef struct sc_mage {
|
||||||
struct spellbook *spellbook;
|
struct spellbook *spellbook;
|
||||||
} sc_mage;
|
} sc_mage;
|
||||||
|
|
||||||
|
void mage_set_spellpoints(sc_mage *m, int aura)
|
||||||
|
{
|
||||||
|
m->spellpoints = aura;
|
||||||
|
}
|
||||||
|
|
||||||
int mage_get_spellpoints(const sc_mage *m)
|
int mage_get_spellpoints(const sc_mage *m)
|
||||||
{
|
{
|
||||||
return m ? m->spellpoints : 0;
|
return m ? m->spellpoints : 0;
|
||||||
|
@ -603,7 +608,7 @@ void set_spellpoints(unit * u, int sp)
|
||||||
{
|
{
|
||||||
sc_mage *m = get_mage(u);
|
sc_mage *m = get_mage(u);
|
||||||
if (m) {
|
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);
|
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
|
/* ein Magier kann normalerweise maximal Stufe^2.1/1.2+1 Magiepunkte
|
||||||
* haben.
|
* haben.
|
||||||
* Manche Rassen haben einen zusaetzlichen Multiplikator
|
* 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 potenz = 2.1;
|
||||||
double divisor = 1.2;
|
double divisor = 1.2;
|
||||||
const struct resource_type *rtype;
|
const struct resource_type *rtype;
|
||||||
|
const sc_mage *m;
|
||||||
|
|
||||||
assert(u);
|
assert(u);
|
||||||
if (!r) r = u->region;
|
if (!r) r = u->region;
|
||||||
|
|
||||||
sk = effskill(u, SK_MAGIC, r);
|
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");
|
rtype = rt_find("aurafocus");
|
||||||
if (rtype && i_get(u->items, rtype->itype) > 0) {
|
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 (r = regions; r; r = r->next) {
|
||||||
for (u = r->units; u; u = u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
if (u->number && is_mage(u)) {
|
if (u->number && u->attribs) {
|
||||||
aura = get_spellpoints(u);
|
sc_mage *m = get_mage(u);
|
||||||
auramax = max_spellpoints_depr(r, u);
|
if (m) {
|
||||||
|
aura = mage_get_spellpoints(m);
|
||||||
|
auramax = max_spellpoints(u, r);
|
||||||
if (aura < auramax) {
|
if (aura < auramax) {
|
||||||
struct building *b = inside_building(u);
|
struct building *b = inside_building(u);
|
||||||
const struct building_type *btype = building_is_active(b) ? b->type : NULL;
|
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));
|
"unit region amount", u, r, regen));
|
||||||
}
|
}
|
||||||
if (aura > auramax) aura = auramax;
|
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);
|
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);
|
struct spellbook * mage_get_spellbook(const struct sc_mage * mage);
|
||||||
int mage_get_spellpoints(const struct sc_mage *m);
|
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);
|
int mage_change_spellpoints(struct sc_mage *m, int delta);
|
||||||
|
|
||||||
enum magic_t unit_get_magic(const struct unit *u);
|
enum magic_t unit_get_magic(const struct unit *u);
|
||||||
|
|
Loading…
Reference in a new issue