(hap_req): New.
(nati, populace): Use it. (populace, nati): Change hap, pct from float to double, because they are used as double. (nati): Print happiness needed with just two decimals, like the other levels.
This commit is contained in:
parent
222847bb75
commit
97be5018e2
4 changed files with 15 additions and 13 deletions
|
@ -290,6 +290,7 @@ extern int blksize(int);
|
||||||
extern time_t fdate(int);
|
extern time_t fdate(int);
|
||||||
/* hap_fact.c */
|
/* hap_fact.c */
|
||||||
extern double hap_fact(struct natstr *, struct natstr *);
|
extern double hap_fact(struct natstr *, struct natstr *);
|
||||||
|
extern double hap_req(struct natstr *np);
|
||||||
/* hours.c */
|
/* hours.c */
|
||||||
extern int is_wday_allowed(int, char *);
|
extern int is_wday_allowed(int, char *);
|
||||||
extern int is_daytime_allowed(int, char *);
|
extern int is_daytime_allowed(int, char *);
|
||||||
|
|
|
@ -47,7 +47,7 @@ nati(void)
|
||||||
{
|
{
|
||||||
struct natstr *natp;
|
struct natstr *natp;
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
float hap;
|
double hap;
|
||||||
int mil;
|
int mil;
|
||||||
int civ;
|
int civ;
|
||||||
int cnum;
|
int cnum;
|
||||||
|
@ -122,11 +122,9 @@ nati(void)
|
||||||
|
|
||||||
pr("Max safe population for civs/uws: %d/%d\n", safepop, uwpop);
|
pr("Max safe population for civs/uws: %d/%d\n", safepop, uwpop);
|
||||||
|
|
||||||
hap = ((natp->nat_level[NAT_TLEV] - 40) / 40.0 +
|
hap = hap_req(natp);
|
||||||
natp->nat_level[NAT_ELEV] / 3.0);
|
|
||||||
|
|
||||||
if (hap > 0.0)
|
if (hap > 0.0)
|
||||||
pr("Happiness needed is %f\n", hap);
|
pr("Happiness needed is %.2f\n", hap);
|
||||||
else
|
else
|
||||||
pr("No happiness needed\n");
|
pr("No happiness needed\n");
|
||||||
|
|
||||||
|
|
|
@ -62,3 +62,11 @@ hap_fact(struct natstr *tnat, struct natstr *vnat)
|
||||||
hap_fact = 0.8;
|
hap_fact = 0.8;
|
||||||
return hap_fact;
|
return hap_fact;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return happiness required to keep NP's citizens happy. */
|
||||||
|
double
|
||||||
|
hap_req(struct natstr *np)
|
||||||
|
{
|
||||||
|
return (np->nat_level[NAT_TLEV] - 40.0) / 40.0
|
||||||
|
+ np->nat_level[NAT_ELEV] / 3.0;
|
||||||
|
}
|
||||||
|
|
|
@ -49,10 +49,7 @@
|
||||||
void
|
void
|
||||||
populace(struct natstr *np, struct sctstr *sp, int etu)
|
populace(struct natstr *np, struct sctstr *sp, int etu)
|
||||||
{
|
{
|
||||||
float hap;
|
double hap, pct;
|
||||||
float tech;
|
|
||||||
float edu;
|
|
||||||
float pct;
|
|
||||||
int n;
|
int n;
|
||||||
int civ = sp->sct_item[I_CIVIL];
|
int civ = sp->sct_item[I_CIVIL];
|
||||||
int mil = sp->sct_item[I_MILIT];
|
int mil = sp->sct_item[I_MILIT];
|
||||||
|
@ -74,11 +71,9 @@ populace(struct natstr *np, struct sctstr *sp, int etu)
|
||||||
}
|
}
|
||||||
|
|
||||||
hap = np->nat_level[NAT_HLEV];
|
hap = np->nat_level[NAT_HLEV];
|
||||||
edu = np->nat_level[NAT_ELEV];
|
pct = hap_req(np);
|
||||||
tech = np->nat_level[NAT_TLEV];
|
|
||||||
pct = (double)((tech - 40) / 40.0 + edu / 3.0);
|
|
||||||
if (sp->sct_own == sp->sct_oldown && hap < pct &&
|
if (sp->sct_own == sp->sct_oldown && hap < pct &&
|
||||||
chance(((double)pct - (double)hap) / (double)5.0)) {
|
chance((pct - hap) / 5.0)) {
|
||||||
/*
|
/*
|
||||||
* zap the loyalty of unhappy civilians.
|
* zap the loyalty of unhappy civilians.
|
||||||
* there is a 20% chance per hap point below the
|
* there is a 20% chance per hap point below the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue