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