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
95
src/magic.c
95
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,44 +1460,47 @@ 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) {
|
||||||
if (aura < auramax) {
|
aura = mage_get_spellpoints(m);
|
||||||
struct building *b = inside_building(u);
|
auramax = max_spellpoints(u, r);
|
||||||
const struct building_type *btype = building_is_active(b) ? b->type : NULL;
|
if (aura < auramax) {
|
||||||
reg_aura = regeneration(u);
|
struct building *b = inside_building(u);
|
||||||
|
const struct building_type *btype = building_is_active(b) ? b->type : NULL;
|
||||||
|
reg_aura = regeneration(u);
|
||||||
|
|
||||||
/* Magierturm erhoeht die Regeneration um 75% */
|
/* Magierturm erhoeht die Regeneration um 75% */
|
||||||
/* Steinkreis erhoeht die Regeneration um 50% */
|
/* Steinkreis erhoeht die Regeneration um 50% */
|
||||||
if (btype)
|
if (btype)
|
||||||
reg_aura *= btype->auraregen;
|
reg_aura *= btype->auraregen;
|
||||||
|
|
||||||
/* Bonus/Malus durch Zauber */
|
/* Bonus/Malus durch Zauber */
|
||||||
mod = get_curseeffect(u->attribs, &ct_auraboost);
|
mod = get_curseeffect(u->attribs, &ct_auraboost);
|
||||||
if (mod > 0) {
|
if (mod > 0) {
|
||||||
reg_aura = (reg_aura * mod) / 100.0;
|
reg_aura = (reg_aura * mod) / 100.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Einfluss von Artefakten */
|
||||||
|
/* TODO (noch gibs keine) */
|
||||||
|
|
||||||
|
/* maximal Differenz bis Maximale-Aura regenerieren
|
||||||
|
* mindestens 1 Aura pro Monat */
|
||||||
|
regen = (int)reg_aura;
|
||||||
|
reg_aura -= regen;
|
||||||
|
if (chance(reg_aura)) {
|
||||||
|
++regen;
|
||||||
|
}
|
||||||
|
if (regen < 1) regen = 1;
|
||||||
|
if (regen > auramax - aura) regen = auramax - aura;
|
||||||
|
|
||||||
|
aura += regen;
|
||||||
|
ADDMSG(&u->faction->msgs, msg_message("regenaura",
|
||||||
|
"unit region amount", u, r, regen));
|
||||||
}
|
}
|
||||||
|
if (aura > auramax) aura = auramax;
|
||||||
/* Einfluss von Artefakten */
|
mage_set_spellpoints(m, aura);
|
||||||
/* TODO (noch gibs keine) */
|
|
||||||
|
|
||||||
/* maximal Differenz bis Maximale-Aura regenerieren
|
|
||||||
* mindestens 1 Aura pro Monat */
|
|
||||||
regen = (int)reg_aura;
|
|
||||||
reg_aura -= regen;
|
|
||||||
if (chance(reg_aura)) {
|
|
||||||
++regen;
|
|
||||||
}
|
|
||||||
if (regen < 1) regen = 1;
|
|
||||||
if (regen > auramax - aura) regen = auramax - aura;
|
|
||||||
|
|
||||||
aura += regen;
|
|
||||||
ADDMSG(&u->faction->msgs, msg_message("regenaura",
|
|
||||||
"unit region amount", u, r, regen));
|
|
||||||
}
|
}
|
||||||
if (aura > auramax) aura = auramax;
|
|
||||||
set_spellpoints(u, 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