forked from github/server
less rounding error in aura regen
This commit is contained in:
parent
eac7f5ee91
commit
de4604fdcc
|
@ -1481,10 +1481,11 @@ do_fumble(castorder *co)
|
|||
/* Ein Magier regeneriert pro Woche W(Stufe^1.5/2+1), mindestens 1
|
||||
* Zwerge nur die Hälfte
|
||||
*/
|
||||
static int
|
||||
static double
|
||||
regeneration(unit * u)
|
||||
{
|
||||
int sk, aura, d;
|
||||
int sk;
|
||||
double aura, d;
|
||||
double potenz = 1.5;
|
||||
double divisor = 2.0;
|
||||
|
||||
|
@ -1494,16 +1495,16 @@ regeneration(unit * u)
|
|||
|
||||
sk = effskill(u, SK_MAGIC);
|
||||
/* Rassenbonus/-malus */
|
||||
d = (int)(pow(sk, potenz) * u->race->regaura / divisor);
|
||||
d = pow(sk, potenz) * u->race->regaura / divisor;
|
||||
d++;
|
||||
|
||||
/* Einfluss von Artefakten */
|
||||
/* TODO (noch gibs keine)*/
|
||||
|
||||
/* Würfeln */
|
||||
aura = (rng_int() % d + rng_int() % d)/2 + 1;
|
||||
aura = (rng_double() * d + rng_double() * d)/2 + 1;
|
||||
|
||||
aura = (int)(aura * MagicRegeneration());
|
||||
aura *= MagicRegeneration();
|
||||
|
||||
return aura;
|
||||
}
|
||||
|
@ -1515,6 +1516,7 @@ regeneration_magiepunkte(void)
|
|||
unit *u;
|
||||
int aura, auramax;
|
||||
double reg_aura;
|
||||
int regen;
|
||||
int n;
|
||||
|
||||
for (r = regions; r; r = r->next) {
|
||||
|
@ -1525,7 +1527,7 @@ regeneration_magiepunkte(void)
|
|||
if (aura < auramax) {
|
||||
struct building * b = inside_building(u);
|
||||
const struct building_type * btype = b?b->type:NULL;
|
||||
reg_aura = (double)regeneration(u);
|
||||
reg_aura = regeneration(u);
|
||||
|
||||
/* Magierturm erhöht die Regeneration um 75% */
|
||||
/* Steinkreis erhöht die Regeneration um 50% */
|
||||
|
@ -1542,13 +1544,16 @@ regeneration_magiepunkte(void)
|
|||
|
||||
/* maximal Differenz bis Maximale-Aura regenerieren
|
||||
* mindestens 1 Aura pro Monat */
|
||||
reg_aura = MAX(1,reg_aura);
|
||||
reg_aura = MIN((auramax - aura), reg_aura);
|
||||
regen = (int)reg_aura;
|
||||
reg_aura -= regen;
|
||||
if (chance(reg_aura)) ++regen;
|
||||
regen = MAX(1, regen);
|
||||
regen = MIN((auramax - aura), regen);
|
||||
|
||||
aura += (int)reg_aura;
|
||||
aura += regen;
|
||||
ADDMSG(&u->faction->msgs, msg_message(
|
||||
"regenaura", "unit region amount",
|
||||
u, r, (int)reg_aura));
|
||||
u, r, regen));
|
||||
}
|
||||
set_spellpoints(u, MIN(aura, auramax));
|
||||
|
||||
|
|
Loading…
Reference in New Issue