forked from github/server
Merge branch 'develop' of https://github.com/ennorehling/eressea.git
This commit is contained in:
commit
d45141255e
13 changed files with 172 additions and 120 deletions
|
@ -17,7 +17,9 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
|
#endif
|
||||||
#include <kernel/config.h>
|
#include <kernel/config.h>
|
||||||
#include "economy.h"
|
#include "economy.h"
|
||||||
|
|
||||||
|
@ -332,11 +334,12 @@ static int do_recruiting(recruitment * recruits, int available)
|
||||||
int number, dec;
|
int number, dec;
|
||||||
double multi = 2.0 * rc->recruit_multi;
|
double multi = 2.0 * rc->recruit_multi;
|
||||||
|
|
||||||
number = MIN(req->qty, (int)(get / multi));
|
number = (int)(get / multi);
|
||||||
|
if (number > req->qty) number = req->qty;
|
||||||
if (rc->recruitcost) {
|
if (rc->recruitcost) {
|
||||||
int afford = get_pooled(u, get_resourcetype(R_SILVER), GET_DEFAULT,
|
int afford = get_pooled(u, get_resourcetype(R_SILVER), GET_DEFAULT,
|
||||||
number * rc->recruitcost) / rc->recruitcost;
|
number * rc->recruitcost) / rc->recruitcost;
|
||||||
number = MIN(number, afford);
|
if (number > afford) number = afford;
|
||||||
}
|
}
|
||||||
if (u->number + number > UNIT_MAXSIZE) {
|
if (u->number + number > UNIT_MAXSIZE) {
|
||||||
ADDMSG(&u->faction->msgs, msg_feedback(u, req->ord, "error_unit_size",
|
ADDMSG(&u->faction->msgs, msg_feedback(u, req->ord, "error_unit_size",
|
||||||
|
@ -538,7 +541,8 @@ static void recruit(unit * u, struct order *ord, econ_request ** recruitorders)
|
||||||
if (recruitcost > 0) {
|
if (recruitcost > 0) {
|
||||||
int pooled =
|
int pooled =
|
||||||
get_pooled(u, get_resourcetype(R_SILVER), GET_DEFAULT, recruitcost * n);
|
get_pooled(u, get_resourcetype(R_SILVER), GET_DEFAULT, recruitcost * n);
|
||||||
n = MIN(n, pooled / recruitcost);
|
int pr = pooled / recruitcost;
|
||||||
|
if (n > pr) n = pr;
|
||||||
}
|
}
|
||||||
|
|
||||||
u->wants = n;
|
u->wants = n;
|
||||||
|
@ -1029,7 +1033,7 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want)
|
||||||
|
|
||||||
/* Schaffenstrunk: */
|
/* Schaffenstrunk: */
|
||||||
if ((dm = get_effect(u, oldpotiontype[P_DOMORE])) != 0) {
|
if ((dm = get_effect(u, oldpotiontype[P_DOMORE])) != 0) {
|
||||||
dm = MIN(dm, u->number);
|
if (dm > u->number) dm = u->number;
|
||||||
change_effect(u, oldpotiontype[P_DOMORE], -dm);
|
change_effect(u, oldpotiontype[P_DOMORE], -dm);
|
||||||
amount += dm * skill; /* dm Personen produzieren doppelt */
|
amount += dm * skill; /* dm Personen produzieren doppelt */
|
||||||
}
|
}
|
||||||
|
@ -1109,7 +1113,7 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist)
|
||||||
}
|
}
|
||||||
need = nreq;
|
need = nreq;
|
||||||
|
|
||||||
avail = MIN(avail, nreq);
|
if (avail > nreq) avail = nreq;
|
||||||
if (need > 0) {
|
if (need > 0) {
|
||||||
int use = 0;
|
int use = 0;
|
||||||
for (al = alist; al; al = al->next) {
|
for (al = alist; al; al = al->next) {
|
||||||
|
@ -1124,7 +1128,8 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist)
|
||||||
use += x;
|
use += x;
|
||||||
nreq -= want;
|
nreq -= want;
|
||||||
need -= x;
|
need -= x;
|
||||||
al->get = MIN(al->want, al->get + x * al->save.sa[1] / al->save.sa[0]);
|
al->get = al->get + x * al->save.sa[1] / al->save.sa[0];
|
||||||
|
if (al->get > al->want) al->get = al->want;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1160,7 +1165,8 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
avail = MIN(avail, nreq);
|
if (avail > nreq) avail = nreq;
|
||||||
|
|
||||||
for (al = alist; al; al = al->next) {
|
for (al = alist; al; al = al->next) {
|
||||||
if (avail > 0) {
|
if (avail > 0) {
|
||||||
int want = required(al->want, al->save);
|
int want = required(al->want, al->save);
|
||||||
|
@ -1171,7 +1177,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist)
|
||||||
avail -= x;
|
avail -= x;
|
||||||
nreq -= want;
|
nreq -= want;
|
||||||
al->get = x * al->save.sa[1] / al->save.sa[0];
|
al->get = x * al->save.sa[1] / al->save.sa[0];
|
||||||
al->get = MIN(al->want, al->get);
|
if (al->want < al->get) al->get = al->want;
|
||||||
if (!rtype->raw) {
|
if (!rtype->raw) {
|
||||||
int use = required(al->get, al->save);
|
int use = required(al->get, al->save);
|
||||||
if (use) {
|
if (use) {
|
||||||
|
@ -1622,7 +1628,7 @@ static void buy(unit * u, econ_request ** buyorders, struct order *ord)
|
||||||
k -= a->data.i;
|
k -= a->data.i;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = MIN(n, k);
|
if (n > k) n = k;
|
||||||
|
|
||||||
if (!n) {
|
if (!n) {
|
||||||
cmistake(u, ord, 102, MSG_COMMERCE);
|
cmistake(u, ord, 102, MSG_COMMERCE);
|
||||||
|
@ -1863,7 +1869,7 @@ static bool sell(unit * u, econ_request ** sellorders, struct order *ord)
|
||||||
bool unlimited = true;
|
bool unlimited = true;
|
||||||
const item_type *itype;
|
const item_type *itype;
|
||||||
const luxury_type *ltype;
|
const luxury_type *ltype;
|
||||||
int n;
|
int n, i;
|
||||||
region *r = u->region;
|
region *r = u->region;
|
||||||
const char *s;
|
const char *s;
|
||||||
keyword_t kwd;
|
keyword_t kwd;
|
||||||
|
@ -1935,7 +1941,8 @@ static bool sell(unit * u, econ_request ** sellorders, struct order *ord)
|
||||||
|
|
||||||
/* Ein H<>ndler kann nur 10 G<>ter pro Talentpunkt verkaufen. */
|
/* Ein H<>ndler kann nur 10 G<>ter pro Talentpunkt verkaufen. */
|
||||||
|
|
||||||
n = MIN(n, u->number * 10 * effskill(u, SK_TRADE, 0));
|
i = u->number * 10 * effskill(u, SK_TRADE, 0);
|
||||||
|
if (n > i) n = i;
|
||||||
|
|
||||||
if (!n) {
|
if (!n) {
|
||||||
cmistake(u, ord, 54, MSG_COMMERCE);
|
cmistake(u, ord, 54, MSG_COMMERCE);
|
||||||
|
@ -1965,11 +1972,12 @@ static bool sell(unit * u, econ_request ** sellorders, struct order *ord)
|
||||||
if (o->type.ltype == ltype && o->unit->faction == u->faction) {
|
if (o->type.ltype == ltype && o->unit->faction == u->faction) {
|
||||||
int fpool =
|
int fpool =
|
||||||
o->qty - get_pooled(o->unit, itype->rtype, GET_RESERVE, INT_MAX);
|
o->qty - get_pooled(o->unit, itype->rtype, GET_RESERVE, INT_MAX);
|
||||||
available -= MAX(0, fpool);
|
if (fpool < 0) fpool = 0;
|
||||||
|
available -= fpool;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
n = MIN(n, available);
|
if (n > available) n = available;
|
||||||
|
|
||||||
if (n <= 0) {
|
if (n <= 0) {
|
||||||
cmistake(u, ord, 264, MSG_COMMERCE);
|
cmistake(u, ord, 264, MSG_COMMERCE);
|
||||||
|
@ -1994,7 +2002,7 @@ static bool sell(unit * u, econ_request ** sellorders, struct order *ord)
|
||||||
k -= a->data.i;
|
k -= a->data.i;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = MIN(n, k);
|
if (n > k) n = k;
|
||||||
assert(n >= 0);
|
assert(n >= 0);
|
||||||
/* die Menge der verkauften G<>ter merken */
|
/* die Menge der verkauften G<>ter merken */
|
||||||
a->data.i += n;
|
a->data.i += n;
|
||||||
|
@ -2049,8 +2057,9 @@ static void plant(unit * u, int raw)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = MIN(skill * u->number, n);
|
i = skill * u->number;
|
||||||
n = MIN(raw, n);
|
if (i > raw) i = raw;
|
||||||
|
if (n > i) n = i;
|
||||||
/* F<>r jedes Kraut Talent*10% Erfolgschance. */
|
/* F<>r jedes Kraut Talent*10% Erfolgschance. */
|
||||||
for (i = n; i > 0; i--) {
|
for (i = n; i > 0; i--) {
|
||||||
if (rng_int() % 10 < skill)
|
if (rng_int() % 10 < skill)
|
||||||
|
@ -2095,14 +2104,14 @@ static void planttrees(unit * u, int raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* wenn eine Anzahl angegeben wurde, nur soviel verbrauchen */
|
/* wenn eine Anzahl angegeben wurde, nur soviel verbrauchen */
|
||||||
raw = MIN(raw, skill * u->number);
|
if (raw > skill * u->number) raw = skill * u->number;
|
||||||
n = get_pooled(u, rtype, GET_DEFAULT, raw);
|
n = get_pooled(u, rtype, GET_DEFAULT, raw);
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype));
|
msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
n = MIN(raw, n);
|
if (n > raw) n = raw;
|
||||||
|
|
||||||
/* F<>r jeden Samen Talent*10% Erfolgschance. */
|
/* F<>r jeden Samen Talent*10% Erfolgschance. */
|
||||||
for (i = n; i > 0; i--) {
|
for (i = n; i > 0; i--) {
|
||||||
|
@ -2152,7 +2161,8 @@ static void breedtrees(unit * u, int raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* wenn eine Anzahl angegeben wurde, nur soviel verbrauchen */
|
/* wenn eine Anzahl angegeben wurde, nur soviel verbrauchen */
|
||||||
raw = MIN(skill * u->number, raw);
|
i = skill * u->number;
|
||||||
|
if (raw > i) raw = i;
|
||||||
n = get_pooled(u, rtype, GET_DEFAULT, raw);
|
n = get_pooled(u, rtype, GET_DEFAULT, raw);
|
||||||
/* Samen pr<70>fen */
|
/* Samen pr<70>fen */
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
|
@ -2160,7 +2170,7 @@ static void breedtrees(unit * u, int raw)
|
||||||
msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype));
|
msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
n = MIN(raw, n);
|
if (n > raw) n = raw;
|
||||||
|
|
||||||
/* F<>r jeden Samen Talent*5% Erfolgschance. */
|
/* F<>r jeden Samen Talent*5% Erfolgschance. */
|
||||||
for (i = n; i > 0; i--) {
|
for (i = n; i > 0; i--) {
|
||||||
|
@ -2202,7 +2212,7 @@ static void breedhorses(unit * u)
|
||||||
}
|
}
|
||||||
effsk = effskill(u, SK_HORSE_TRAINING, 0);
|
effsk = effskill(u, SK_HORSE_TRAINING, 0);
|
||||||
n = u->number * effsk;
|
n = u->number * effsk;
|
||||||
n = MIN(n, horses);
|
if (n > horses) n = horses;
|
||||||
|
|
||||||
for (c = 0; c < n; c++) {
|
for (c = 0; c < n; c++) {
|
||||||
if (rng_int() % 100 < effsk) {
|
if (rng_int() % 100 < effsk) {
|
||||||
|
@ -2346,7 +2356,7 @@ static void expandentertainment(region * r)
|
||||||
entertaining -= o->qty;
|
entertaining -= o->qty;
|
||||||
|
|
||||||
/* Nur soviel PRODUCEEXP wie auch tats<74>chlich gemacht wurde */
|
/* Nur soviel PRODUCEEXP wie auch tats<74>chlich gemacht wurde */
|
||||||
produceexp(u, SK_ENTERTAINMENT, MIN(u->n, u->number));
|
produceexp(u, SK_ENTERTAINMENT, (u->n < u->number) ? u->n : u->number);
|
||||||
add_income(u, IC_ENTERTAIN, o->qty, u->n);
|
add_income(u, IC_ENTERTAIN, o->qty, u->n);
|
||||||
fset(u, UFL_LONGACTION | UFL_NOTMOVING);
|
fset(u, UFL_LONGACTION | UFL_NOTMOVING);
|
||||||
}
|
}
|
||||||
|
@ -2397,7 +2407,7 @@ void entertain_cmd(unit * u, struct order *ord)
|
||||||
|
|
||||||
max_e = getuint();
|
max_e = getuint();
|
||||||
if (max_e != 0) {
|
if (max_e != 0) {
|
||||||
u->wants = MIN(u->wants, max_e);
|
if (u->wants > max_e) u->wants = max_e;
|
||||||
}
|
}
|
||||||
o = nextentertainer++;
|
o = nextentertainer++;
|
||||||
o->unit = u;
|
o->unit = u;
|
||||||
|
@ -2608,11 +2618,12 @@ void tax_cmd(unit * u, struct order *ord, econ_request ** taxorders)
|
||||||
max = INT_MAX;
|
max = INT_MAX;
|
||||||
}
|
}
|
||||||
if (!playerrace(u_race(u))) {
|
if (!playerrace(u_race(u))) {
|
||||||
u->wants = MIN(income(u), max);
|
u->wants = income(u);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
u->wants = MIN(n * effskill(u, SK_TAXING, 0) * taxperlevel, max);
|
u->wants = n * effskill(u, SK_TAXING, 0) * taxperlevel;
|
||||||
}
|
}
|
||||||
|
if (u->wants > max) u->wants = max;
|
||||||
|
|
||||||
u2 = is_guarded(r, u);
|
u2 = is_guarded(r, u);
|
||||||
if (u2) {
|
if (u2) {
|
||||||
|
@ -2682,12 +2693,16 @@ void loot_cmd(unit * u, struct order *ord, econ_request ** lootorders)
|
||||||
max = INT_MAX;
|
max = INT_MAX;
|
||||||
}
|
}
|
||||||
if (!playerrace(u_race(u))) {
|
if (!playerrace(u_race(u))) {
|
||||||
u->wants = MIN(income(u), max);
|
u->wants = income(u);
|
||||||
|
if (u->wants > max) u->wants = max;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* For player start with 20 Silver +10 every 5 level of close combat skill*/
|
/* For player start with 20 Silver +10 every 5 level of close combat skill*/
|
||||||
int skbonus = (MAX(effskill(u, SK_MELEE, 0), effskill(u, SK_SPEAR, 0)) * 2 / 10) + 2;
|
int skm = effskill(u, SK_MELEE, 0);
|
||||||
u->wants = MIN(n * skbonus * 10, max);
|
int sks = effskill(u, SK_SPEAR, 0);
|
||||||
|
int skbonus = ((skm > sks ? skm : sks) * 2 / 10) + 2;
|
||||||
|
u->wants = n * skbonus * 10;
|
||||||
|
if (u->wants > max) u->wants = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
o = (econ_request *)calloc(1, sizeof(econ_request));
|
o = (econ_request *)calloc(1, sizeof(econ_request));
|
||||||
|
|
|
@ -495,7 +495,7 @@ static order *make_movement_order(unit * u, const region * target, int moves,
|
||||||
{
|
{
|
||||||
region *r = u->region;
|
region *r = u->region;
|
||||||
region **plan;
|
region **plan;
|
||||||
int bytes, position = 0;
|
int position = 0;
|
||||||
char zOrder[128], *bufp = zOrder;
|
char zOrder[128], *bufp = zOrder;
|
||||||
size_t size = sizeof(zOrder) - 1;
|
size_t size = sizeof(zOrder) - 1;
|
||||||
|
|
||||||
|
@ -507,6 +507,7 @@ static order *make_movement_order(unit * u, const region * target, int moves,
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
while (position != moves && plan[position + 1]) {
|
while (position != moves && plan[position + 1]) {
|
||||||
|
int bytes;
|
||||||
region *prev = plan[position];
|
region *prev = plan[position];
|
||||||
region *next = plan[++position];
|
region *next = plan[++position];
|
||||||
direction_t dir = reldirection(prev, next);
|
direction_t dir = reldirection(prev, next);
|
||||||
|
|
149
src/spells.c
149
src/spells.c
|
@ -11,7 +11,9 @@
|
||||||
* This program may not be used, modified or distributed without
|
* This program may not be used, modified or distributed without
|
||||||
* prior permission by the authors of Eressea.
|
* prior permission by the authors of Eressea.
|
||||||
*/
|
*/
|
||||||
|
#ifdef _MSC_VER
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
|
#endif
|
||||||
#include <kernel/config.h>
|
#include <kernel/config.h>
|
||||||
|
|
||||||
#include "guard.h"
|
#include "guard.h"
|
||||||
|
@ -149,7 +151,7 @@ static void magicanalyse_region(region * r, unit * mage, double force)
|
||||||
* mehr als 100% probability und damit immer ein Erfolg. */
|
* mehr als 100% probability und damit immer ein Erfolg. */
|
||||||
probability = curse_chance(c, force);
|
probability = curse_chance(c, force);
|
||||||
mon = c->duration + (rng_int() % 10) - 5;
|
mon = c->duration + (rng_int() % 10) - 5;
|
||||||
mon = MAX(1, mon);
|
if (mon < 1) mon = 1;
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
if (chance(probability)) { /* Analyse geglueckt */
|
if (chance(probability)) { /* Analyse geglueckt */
|
||||||
|
@ -190,7 +192,7 @@ static void magicanalyse_unit(unit * u, unit * mage, double force)
|
||||||
* mehr als 100% probability und damit immer ein Erfolg. */
|
* mehr als 100% probability und damit immer ein Erfolg. */
|
||||||
probability = curse_chance(c, force);
|
probability = curse_chance(c, force);
|
||||||
mon = c->duration + (rng_int() % 10) - 5;
|
mon = c->duration + (rng_int() % 10) - 5;
|
||||||
mon = MAX(1, mon);
|
if (mon < 1) mon = 1;
|
||||||
|
|
||||||
if (chance(probability)) { /* Analyse geglueckt */
|
if (chance(probability)) { /* Analyse geglueckt */
|
||||||
if (c_flags(c) & CURSE_NOAGE) {
|
if (c_flags(c) & CURSE_NOAGE) {
|
||||||
|
@ -231,7 +233,7 @@ static void magicanalyse_building(building * b, unit * mage, double force)
|
||||||
* mehr als 100% probability und damit immer ein Erfolg. */
|
* mehr als 100% probability und damit immer ein Erfolg. */
|
||||||
probability = curse_chance(c, force);
|
probability = curse_chance(c, force);
|
||||||
mon = c->duration + (rng_int() % 10) - 5;
|
mon = c->duration + (rng_int() % 10) - 5;
|
||||||
mon = MAX(1, mon);
|
if (mon < 1) mon = 1;
|
||||||
|
|
||||||
if (chance(probability)) { /* Analyse geglueckt */
|
if (chance(probability)) { /* Analyse geglueckt */
|
||||||
if (c_flags(c) & CURSE_NOAGE) {
|
if (c_flags(c) & CURSE_NOAGE) {
|
||||||
|
@ -272,7 +274,7 @@ static void magicanalyse_ship(ship * sh, unit * mage, double force)
|
||||||
* mehr als 100% probability und damit immer ein Erfolg. */
|
* mehr als 100% probability und damit immer ein Erfolg. */
|
||||||
probability = curse_chance(c, force);
|
probability = curse_chance(c, force);
|
||||||
mon = c->duration + (rng_int() % 10) - 5;
|
mon = c->duration + (rng_int() % 10) - 5;
|
||||||
mon = MAX(1, mon);
|
if (mon < 1) mon = 1;
|
||||||
|
|
||||||
if (chance(probability)) { /* Analyse geglueckt */
|
if (chance(probability)) { /* Analyse geglueckt */
|
||||||
if (c_flags(c) & CURSE_NOAGE) {
|
if (c_flags(c) & CURSE_NOAGE) {
|
||||||
|
@ -701,7 +703,8 @@ static int sp_destroy_magic(castorder * co)
|
||||||
"unit region command", mage, mage->region, co->order));
|
"unit region command", mage, mage->region, co->order));
|
||||||
}
|
}
|
||||||
|
|
||||||
return MAX(succ, 1);
|
if (succ < 1) succ = 1;
|
||||||
|
return succ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
@ -770,7 +773,9 @@ static int sp_transferaura(castorder * co)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
gain = MIN(aura, scm_src->spellpoints) / multi;
|
gain = scm_src->spellpoints;
|
||||||
|
if (gain > aura) gain = aura;
|
||||||
|
gain = gain / multi;
|
||||||
scm_src->spellpoints -= gain * multi;
|
scm_src->spellpoints -= gain * multi;
|
||||||
scm_dst->spellpoints += gain;
|
scm_dst->spellpoints += gain;
|
||||||
|
|
||||||
|
@ -901,7 +906,7 @@ static int sp_summonent(castorder * co)
|
||||||
double power = co->force;
|
double power = co->force;
|
||||||
unit *u;
|
unit *u;
|
||||||
attrib *a;
|
attrib *a;
|
||||||
int ents;
|
int ents, p2;
|
||||||
|
|
||||||
if (rtrees(r, 2) == 0) {
|
if (rtrees(r, 2) == 0) {
|
||||||
cmistake(mage, co->order, 204, MSG_EVENT);
|
cmistake(mage, co->order, 204, MSG_EVENT);
|
||||||
|
@ -909,7 +914,9 @@ static int sp_summonent(castorder * co)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ents = MIN((int)(power * power), rtrees(r, 2));
|
ents = rtrees(r, 2);
|
||||||
|
p2 = (int)(power * power);
|
||||||
|
if (ents > p2) ents = p2;
|
||||||
|
|
||||||
u = create_unit(r, mage->faction, ents, get_race(RC_TREEMAN), 0, NULL, mage);
|
u = create_unit(r, mage->faction, ents, get_race(RC_TREEMAN), 0, NULL, mage);
|
||||||
|
|
||||||
|
@ -1300,7 +1307,8 @@ static int sp_rosthauch(castorder * co)
|
||||||
for (; iweapon != NULL; iweapon = iweapon->next) {
|
for (; iweapon != NULL; iweapon = iweapon->next) {
|
||||||
item **ip = i_find(&u->items, iweapon->type);
|
item **ip = i_find(&u->items, iweapon->type);
|
||||||
if (*ip) {
|
if (*ip) {
|
||||||
float chance = (float)MIN((*ip)->number, force);
|
float chance = (*ip)->number;
|
||||||
|
if (chance > force) chance = force;
|
||||||
if (iweapon->chance < 1.0) {
|
if (iweapon->chance < 1.0) {
|
||||||
chance *= iweapon->chance;
|
chance *= iweapon->chance;
|
||||||
}
|
}
|
||||||
|
@ -1339,7 +1347,7 @@ static int sp_rosthauch(castorder * co)
|
||||||
* unguenstigsten Fall kann pro Stufe nur eine Waffe verzaubert werden,
|
* unguenstigsten Fall kann pro Stufe nur eine Waffe verzaubert werden,
|
||||||
* darum wird hier nur fuer alle Faelle in denen noch weniger Waffen
|
* darum wird hier nur fuer alle Faelle in denen noch weniger Waffen
|
||||||
* betroffen wurden ein Kostennachlass gegeben */
|
* betroffen wurden ein Kostennachlass gegeben */
|
||||||
return MIN(success, cast_level);
|
return (success < cast_level) ? success : cast_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
@ -1369,9 +1377,12 @@ static int sp_kaelteschutz(castorder * co)
|
||||||
unit *mage = co->magician.u;
|
unit *mage = co->magician.u;
|
||||||
int cast_level = co->level;
|
int cast_level = co->level;
|
||||||
double force = co->force;
|
double force = co->force;
|
||||||
int duration = MAX(cast_level, (int)force) + 1;
|
|
||||||
spellparameter *pa = co->par;
|
|
||||||
double effect;
|
double effect;
|
||||||
|
spellparameter *pa = co->par;
|
||||||
|
int duration = (int)force;
|
||||||
|
|
||||||
|
if (duration < cast_level) duration = cast_level;
|
||||||
|
++duration;
|
||||||
|
|
||||||
force *= 10; /* 10 Personen pro Force-Punkt */
|
force *= 10; /* 10 Personen pro Force-Punkt */
|
||||||
|
|
||||||
|
@ -2132,8 +2143,8 @@ static int sp_drought(castorder * co)
|
||||||
*/
|
*/
|
||||||
c = get_curse(r->attribs, &ct_drought);
|
c = get_curse(r->attribs, &ct_drought);
|
||||||
if (c) {
|
if (c) {
|
||||||
c->vigour = MAX(c->vigour, power);
|
c->vigour = fmax(c->vigour, power);
|
||||||
c->duration = MAX(c->duration, (int)power);
|
if (c->duration < (int)power) c->duration = (int)power;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
double effect = 4.0;
|
double effect = 4.0;
|
||||||
|
@ -2317,7 +2328,6 @@ static int sp_stormwinds(castorder * co)
|
||||||
*/
|
*/
|
||||||
static int sp_earthquake(castorder * co)
|
static int sp_earthquake(castorder * co)
|
||||||
{
|
{
|
||||||
int kaputt;
|
|
||||||
region *r = co_get_region(co);
|
region *r = co_get_region(co);
|
||||||
unit *mage = co->magician.u;
|
unit *mage = co->magician.u;
|
||||||
int cast_level = co->level;
|
int cast_level = co->level;
|
||||||
|
@ -2330,8 +2340,9 @@ static int sp_earthquake(castorder * co)
|
||||||
if (burg->size != 0 && !is_cursed(burg->attribs, &ct_magicwalls)) {
|
if (burg->size != 0 && !is_cursed(burg->attribs, &ct_magicwalls)) {
|
||||||
/* Magieresistenz */
|
/* Magieresistenz */
|
||||||
if (!target_resists_magic(mage, burg, TYP_BUILDING, 0)) {
|
if (!target_resists_magic(mage, burg, TYP_BUILDING, 0)) {
|
||||||
kaputt = MIN(10 * cast_level, burg->size / 4);
|
int kaputt = burg->size / 4;
|
||||||
kaputt = MAX(kaputt, 1);
|
if (kaputt > 10 * cast_level) kaputt = 10 * cast_level;
|
||||||
|
if (kaputt < 1) kaputt = 1;
|
||||||
burg->size -= kaputt;
|
burg->size -= kaputt;
|
||||||
if (burg->size == 0) {
|
if (burg->size == 0) {
|
||||||
/* TODO: sollten die Insassen nicht Schaden nehmen? */
|
/* TODO: sollten die Insassen nicht Schaden nehmen? */
|
||||||
|
@ -2507,7 +2518,6 @@ static int sp_forest_fire(castorder * co)
|
||||||
static int sp_fumblecurse(castorder * co)
|
static int sp_fumblecurse(castorder * co)
|
||||||
{
|
{
|
||||||
unit *target;
|
unit *target;
|
||||||
int rx, sx;
|
|
||||||
int duration;
|
int duration;
|
||||||
unit *mage = co->magician.u;
|
unit *mage = co->magician.u;
|
||||||
int cast_level = co->level;
|
int cast_level = co->level;
|
||||||
|
@ -2522,9 +2532,12 @@ static int sp_fumblecurse(castorder * co)
|
||||||
|
|
||||||
target = pa->param[0]->data.u;
|
target = pa->param[0]->data.u;
|
||||||
|
|
||||||
rx = rng_int() % 3;
|
duration = cast_level - effskill(target, SK_MAGIC, 0);
|
||||||
sx = cast_level - effskill(target, SK_MAGIC, 0);
|
if (duration < 2) {
|
||||||
duration = MAX(sx, rx) + 1;
|
int rx = rng_int() % 3;
|
||||||
|
if (duration < rx) duration = rx;
|
||||||
|
}
|
||||||
|
++duration;
|
||||||
|
|
||||||
effect = force / 2;
|
effect = force / 2;
|
||||||
c = create_curse(mage, &target->attribs, &ct_fumble,
|
c = create_curse(mage, &target->attribs, &ct_fumble,
|
||||||
|
@ -2690,8 +2703,9 @@ static int sp_firewall(castorder * co)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fd = (wall_data *)b->data.v;
|
fd = (wall_data *)b->data.v;
|
||||||
fd->force = (int)MAX(fd->force, force / 2 + 0.5);
|
fd->force = (int)fmax(fd->force, force / 2 + 0.5);
|
||||||
fd->countdown = MAX(fd->countdown, cast_level + 1);
|
if (fd->countdown < cast_level + 1)
|
||||||
|
fd->countdown = cast_level + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* melden, 1x pro Partei */
|
/* melden, 1x pro Partei */
|
||||||
|
@ -3271,7 +3285,7 @@ static void skill_summoned(unit * u, int level)
|
||||||
*/
|
*/
|
||||||
static int sp_summonundead(castorder * co)
|
static int sp_summonundead(castorder * co)
|
||||||
{
|
{
|
||||||
int undead;
|
int undead, dc;
|
||||||
unit *u;
|
unit *u;
|
||||||
region *r = co_get_region(co);
|
region *r = co_get_region(co);
|
||||||
unit *mage = co->magician.u;
|
unit *mage = co->magician.u;
|
||||||
|
@ -3285,7 +3299,9 @@ static int sp_summonundead(castorder * co)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
undead = MIN(deathcount(r), 2 + lovar(force));
|
undead = 2 + lovar(force);
|
||||||
|
dc = deathcount(r);
|
||||||
|
if (undead > dc) undead = dc;
|
||||||
|
|
||||||
if (cast_level <= 8) {
|
if (cast_level <= 8) {
|
||||||
race = get_race(RC_SKELETON);
|
race = get_race(RC_SKELETON);
|
||||||
|
@ -3333,7 +3349,7 @@ static int sp_auraleak(castorder * co)
|
||||||
int cast_level = co->level;
|
int cast_level = co->level;
|
||||||
message *msg;
|
message *msg;
|
||||||
|
|
||||||
lost = MIN(0.95, cast_level * 0.05);
|
lost = fmin(0.95, cast_level * 0.05);
|
||||||
|
|
||||||
for (u = r->units; u; u = u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
if (is_mage(u)) {
|
if (is_mage(u)) {
|
||||||
|
@ -3707,17 +3723,17 @@ static int sp_raisepeasantmob(castorder * co)
|
||||||
int anteil;
|
int anteil;
|
||||||
region *r = co_get_region(co);
|
region *r = co_get_region(co);
|
||||||
unit *mage = co->magician.u;
|
unit *mage = co->magician.u;
|
||||||
int cast_level = co->level;
|
int rp, cast_level = co->level;
|
||||||
double force = co->force;
|
double force = co->force;
|
||||||
int duration = (int)force + 1;
|
int duration = (int)force + 1;
|
||||||
faction *monsters = get_monsters();
|
faction *monsters = get_monsters();
|
||||||
message *msg;
|
message *msg;
|
||||||
|
|
||||||
anteil = 6 + (rng_int() % 4);
|
anteil = 6 + (rng_int() % 4);
|
||||||
|
rp = rpeasants(r);
|
||||||
n = rpeasants(r) * anteil / 10;
|
n = rp * anteil / 10;
|
||||||
n = MAX(0, n);
|
if (n < 0) n = 0;
|
||||||
n = MIN(n, rpeasants(r));
|
if (n > rp) n = rp;
|
||||||
|
|
||||||
if (n <= 0) {
|
if (n <= 0) {
|
||||||
report_failure(mage, co->order);
|
report_failure(mage, co->order);
|
||||||
|
@ -3956,13 +3972,13 @@ static int sp_recruit(castorder * co)
|
||||||
n = (pow(force, 1.6) * 100) / f->race->recruitcost;
|
n = (pow(force, 1.6) * 100) / f->race->recruitcost;
|
||||||
if (rc->recruit_multi > 0) {
|
if (rc->recruit_multi > 0) {
|
||||||
double multp = (double)maxp / rc->recruit_multi;
|
double multp = (double)maxp / rc->recruit_multi;
|
||||||
n = MIN(multp, n);
|
n = fmin(multp, n);
|
||||||
n = MAX(n, 1);
|
n = fmax(n, 1);
|
||||||
rsetpeasants(r, maxp - (int)(n * rc->recruit_multi));
|
rsetpeasants(r, maxp - (int)(n * rc->recruit_multi));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
n = MIN(maxp, n);
|
n = fmin(maxp, n);
|
||||||
n = MAX(n, 1);
|
n = fmax(n, 1);
|
||||||
rsetpeasants(r, maxp - (int)n);
|
rsetpeasants(r, maxp - (int)n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4007,18 +4023,17 @@ static int sp_bigrecruit(castorder * co)
|
||||||
|
|
||||||
n = (int)force + lovar((force * force * 1000) / (float)f->race->recruitcost);
|
n = (int)force + lovar((force * force * 1000) / (float)f->race->recruitcost);
|
||||||
if (f->race == get_race(RC_ORC)) {
|
if (f->race == get_race(RC_ORC)) {
|
||||||
n = MIN(2 * maxp, n);
|
if (n > 2 * maxp) n = 2 * maxp;
|
||||||
n = MAX(n, 1);
|
if (n < 1) n = 1;
|
||||||
rsetpeasants(r, maxp - (n + 1) / 2);
|
rsetpeasants(r, maxp - (n + 1) / 2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
n = MIN(maxp, n);
|
if (n > maxp) n = maxp;
|
||||||
n = MAX(n, 1);
|
if (n < 1) n = 1;
|
||||||
rsetpeasants(r, maxp - n);
|
rsetpeasants(r, maxp - n);
|
||||||
}
|
}
|
||||||
|
|
||||||
u =
|
u = create_unit(r, f, n, f->race, 0, LOC(f->locale,
|
||||||
create_unit(r, f, n, f->race, 0, LOC(f->locale,
|
|
||||||
(n == 1 ? "peasant" : "peasant_p")), mage);
|
(n == 1 ? "peasant" : "peasant_p")), mage);
|
||||||
set_order(&u->thisorder, default_order(f->locale));
|
set_order(&u->thisorder, default_order(f->locale));
|
||||||
|
|
||||||
|
@ -4133,9 +4148,9 @@ static int sp_seduce(castorder * co)
|
||||||
item *itm = *itmp;
|
item *itm = *itmp;
|
||||||
int loot;
|
int loot;
|
||||||
if (itm->type->rtype == rsilver) {
|
if (itm->type->rtype == rsilver) {
|
||||||
loot =
|
loot = get_money(target) - maintenance_cost(target);
|
||||||
MIN(cast_level * 1000, get_money(target) - (maintenance_cost(target)));
|
if (loot > cast_level * 1000) loot = cast_level * 1000;
|
||||||
loot = MAX(loot, 0);
|
if (loot < 0) loot = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
loot = itm->number / 2;
|
loot = itm->number / 2;
|
||||||
|
@ -4143,7 +4158,7 @@ static int sp_seduce(castorder * co)
|
||||||
loot += rng_int() % 2;
|
loot += rng_int() % 2;
|
||||||
}
|
}
|
||||||
if (loot > 0) {
|
if (loot > 0) {
|
||||||
loot = MIN(loot, (int)(force * 5));
|
if (loot > 5 * force) loot = 5 * force;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (loot > 0) {
|
if (loot > 0) {
|
||||||
|
@ -4260,7 +4275,9 @@ static int sp_headache(castorder * co)
|
||||||
}
|
}
|
||||||
if (smax != NULL) {
|
if (smax != NULL) {
|
||||||
/* wirkt auf maximal 10 Personen */
|
/* wirkt auf maximal 10 Personen */
|
||||||
unsigned int change = MIN(10, target->number) * (rng_uint() % 2 + 1) / target->number;
|
int change = target->number;
|
||||||
|
if (change > 10) change = 10;
|
||||||
|
change *= (rng_uint() % 2 + 1) / target->number;
|
||||||
reduce_skill(target, smax, change);
|
reduce_skill(target, smax, change);
|
||||||
}
|
}
|
||||||
set_order(&target->thisorder, NULL);
|
set_order(&target->thisorder, NULL);
|
||||||
|
@ -4295,17 +4312,18 @@ static int sp_raisepeasants(castorder * co)
|
||||||
attrib *a;
|
attrib *a;
|
||||||
region *r = co_get_region(co);
|
region *r = co_get_region(co);
|
||||||
unit *mage = co->magician.u;
|
unit *mage = co->magician.u;
|
||||||
int cast_level = co->level;
|
int rp = rpeasants(r), cast_level = co->level;
|
||||||
double power = co->force;
|
double power = co->force;
|
||||||
message *msg;
|
message *msg;
|
||||||
|
|
||||||
if (rpeasants(r) == 0) {
|
if (rp == 0) {
|
||||||
ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order,
|
ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order,
|
||||||
"error_nopeasants", ""));
|
"error_nopeasants", ""));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
bauern = MIN(rpeasants(r), (int)(power * 250));
|
bauern = (int)(power * 250);
|
||||||
rsetpeasants(r, rpeasants(r) - bauern);
|
if (bauern > rp) bauern = rp;
|
||||||
|
rsetpeasants(r, rp - bauern);
|
||||||
|
|
||||||
u2 =
|
u2 =
|
||||||
create_unit(r, mage->faction, bauern, get_race(RC_PEASANT), 0,
|
create_unit(r, mage->faction, bauern, get_race(RC_PEASANT), 0,
|
||||||
|
@ -4387,7 +4405,7 @@ int sp_puttorest(castorder * co)
|
||||||
message *seen = msg_message("puttorest", "mage", mage);
|
message *seen = msg_message("puttorest", "mage", mage);
|
||||||
message *unseen = msg_message("puttorest", "mage", NULL);
|
message *unseen = msg_message("puttorest", "mage", NULL);
|
||||||
|
|
||||||
laid_to_rest = MAX(laid_to_rest, dead);
|
if (laid_to_rest < dead) laid_to_rest = dead;
|
||||||
|
|
||||||
deathcounts(r, -laid_to_rest);
|
deathcounts(r, -laid_to_rest);
|
||||||
|
|
||||||
|
@ -4567,7 +4585,7 @@ static int sp_gbdreams(castorder * co, int effect)
|
||||||
|
|
||||||
/* wirkt erst in der Folgerunde, soll mindestens eine Runde wirken,
|
/* wirkt erst in der Folgerunde, soll mindestens eine Runde wirken,
|
||||||
* also duration+2 */
|
* also duration+2 */
|
||||||
duration = (int)MAX(1, power / 2); /* Stufe 1 macht sonst mist */
|
duration = (int)fmax(1, power / 2); /* Stufe 1 macht sonst mist */
|
||||||
duration = 2 + rng_int() % duration;
|
duration = 2 + rng_int() % duration;
|
||||||
|
|
||||||
/* Nichts machen als ein entsprechendes Attribut in die Region legen. */
|
/* Nichts machen als ein entsprechendes Attribut in die Region legen. */
|
||||||
|
@ -4739,7 +4757,8 @@ int sp_sweetdreams(castorder * co)
|
||||||
cmistake(mage, co->order, 40, MSG_EVENT);
|
cmistake(mage, co->order, 40, MSG_EVENT);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
men = MIN(opfer, u->number);
|
men = u->number;
|
||||||
|
if (men > opfer) men = opfer;
|
||||||
opfer -= men;
|
opfer -= men;
|
||||||
|
|
||||||
/* Nichts machen als ein entsprechendes Attribut an die Einheit legen. */
|
/* Nichts machen als ein entsprechendes Attribut an die Einheit legen. */
|
||||||
|
@ -4852,7 +4871,7 @@ int sp_itemcloak(castorder * co)
|
||||||
spellparameter *pa = co->par;
|
spellparameter *pa = co->par;
|
||||||
int cast_level = co->level;
|
int cast_level = co->level;
|
||||||
double power = co->force;
|
double power = co->force;
|
||||||
int duration = (int)MAX(2.0, power + 1); /* works in the report, and ageing this round would kill it if it's <=1 */
|
int duration = (int)fmax(2.0, power + 1); /* works in the report, and ageing this round would kill it if it's <=1 */
|
||||||
|
|
||||||
/* wenn kein Ziel gefunden, Zauber abbrechen */
|
/* wenn kein Ziel gefunden, Zauber abbrechen */
|
||||||
if (pa->param[0]->flag == TARGET_NOTFOUND)
|
if (pa->param[0]->flag == TARGET_NOTFOUND)
|
||||||
|
@ -4910,7 +4929,8 @@ int sp_resist_magic_bonus(castorder * co)
|
||||||
|
|
||||||
u = pa->param[n]->data.u;
|
u = pa->param[n]->data.u;
|
||||||
|
|
||||||
m = MIN(u->number, victims);
|
m = u->number;
|
||||||
|
if (m > victims) m = victims;
|
||||||
victims -= m;
|
victims -= m;
|
||||||
|
|
||||||
create_curse(mage, &u->attribs, &ct_magicresistance,
|
create_curse(mage, &u->attribs, &ct_magicresistance,
|
||||||
|
@ -4926,8 +4946,10 @@ int sp_resist_magic_bonus(castorder * co)
|
||||||
msg_release(msg);
|
msg_release(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
cast_level = MIN(cast_level, (int)(cast_level * (victims + 4) / maxvictims));
|
m = (int)(cast_level * (victims + 4) / maxvictims);
|
||||||
return MAX(cast_level, 1);
|
if (m > cast_level) m = cast_level;
|
||||||
|
if (m < 1) m = 1;
|
||||||
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** spell 'Astraler Weg'.
|
/** spell 'Astraler Weg'.
|
||||||
|
@ -5754,7 +5776,7 @@ static int sp_eternizewall(castorder * co)
|
||||||
*/
|
*/
|
||||||
int sp_permtransfer(castorder * co)
|
int sp_permtransfer(castorder * co)
|
||||||
{
|
{
|
||||||
int aura;
|
int aura, i;
|
||||||
unit *tu;
|
unit *tu;
|
||||||
unit *mage = co->magician.u;
|
unit *mage = co->magician.u;
|
||||||
int cast_level = co->level;
|
int cast_level = co->level;
|
||||||
|
@ -5781,7 +5803,8 @@ int sp_permtransfer(castorder * co)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
aura = MIN(get_spellpoints(mage) - spellcost(mage, sp), aura);
|
i = get_spellpoints(mage) - spellcost(mage, sp);
|
||||||
|
if (aura > i) aura = i;
|
||||||
|
|
||||||
change_maxspellpoints(mage, -aura);
|
change_maxspellpoints(mage, -aura);
|
||||||
change_spellpoints(mage, -aura);
|
change_spellpoints(mage, -aura);
|
||||||
|
@ -6090,7 +6113,8 @@ int sp_speed2(castorder * co)
|
||||||
spellparameter *pa = co->par;
|
spellparameter *pa = co->par;
|
||||||
|
|
||||||
maxmen = 2 * cast_level * cast_level;
|
maxmen = 2 * cast_level * cast_level;
|
||||||
dur = MAX(1, cast_level / 2);
|
dur = cast_level / 2;
|
||||||
|
if (dur < 1) dur = 1;
|
||||||
|
|
||||||
for (n = 0; n < pa->length; n++) {
|
for (n = 0; n < pa->length; n++) {
|
||||||
double effect;
|
double effect;
|
||||||
|
@ -6104,7 +6128,7 @@ int sp_speed2(castorder * co)
|
||||||
|
|
||||||
u = pa->param[n]->data.u;
|
u = pa->param[n]->data.u;
|
||||||
|
|
||||||
men = MIN(maxmen, u->number);
|
men = (maxmen <= u->number) ? maxmen : u->number;
|
||||||
effect = 2;
|
effect = 2;
|
||||||
create_curse(mage, &u->attribs, &ct_speed, force, dur, effect, men);
|
create_curse(mage, &u->attribs, &ct_speed, force, dur, effect, men);
|
||||||
maxmen -= men;
|
maxmen -= men;
|
||||||
|
@ -6115,7 +6139,8 @@ int sp_speed2(castorder * co)
|
||||||
"unit region amount", mage, mage->region, used));
|
"unit region amount", mage, mage->region, used));
|
||||||
/* Effektiv benoetigten cast_level (mindestens 1) zurueckgeben */
|
/* Effektiv benoetigten cast_level (mindestens 1) zurueckgeben */
|
||||||
used = (int)sqrt(used / 2);
|
used = (int)sqrt(used / 2);
|
||||||
return MAX(1, used);
|
if (used < 1) used = 1;
|
||||||
|
return used;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
|
|
@ -16,7 +16,9 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
|
#endif
|
||||||
#include "spy.h"
|
#include "spy.h"
|
||||||
#include "guard.h"
|
#include "guard.h"
|
||||||
#include "laws.h"
|
#include "laws.h"
|
||||||
|
@ -52,6 +54,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -146,7 +149,7 @@ int spy_cmd(unit * u, struct order *ord)
|
||||||
* Fuer jeden Talentpunkt, den das Spionagetalent das Tarnungstalent
|
* Fuer jeden Talentpunkt, den das Spionagetalent das Tarnungstalent
|
||||||
* des Opfers uebersteigt, erhoeht sich dieses um 5%*/
|
* des Opfers uebersteigt, erhoeht sich dieses um 5%*/
|
||||||
spy = effskill(u, SK_SPY, 0) - effskill(target, SK_STEALTH, r);
|
spy = effskill(u, SK_SPY, 0) - effskill(target, SK_STEALTH, r);
|
||||||
spychance = 0.1 + MAX(spy * 0.05, 0.0);
|
spychance = 0.1 + fmax(spy * 0.05, 0.0);
|
||||||
|
|
||||||
if (chance(spychance)) {
|
if (chance(spychance)) {
|
||||||
produceexp(u, SK_SPY, u->number);
|
produceexp(u, SK_SPY, u->number);
|
||||||
|
@ -162,7 +165,7 @@ int spy_cmd(unit * u, struct order *ord)
|
||||||
- (effskill(u, SK_STEALTH, 0) + effskill(u, SK_SPY, 0) / 2);
|
- (effskill(u, SK_STEALTH, 0) + effskill(u, SK_SPY, 0) / 2);
|
||||||
|
|
||||||
if (invisible(u, target) >= u->number) {
|
if (invisible(u, target) >= u->number) {
|
||||||
observe = MIN(observe, 0);
|
if (observe > 0) observe = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Anschliessend wird - unabhaengig vom Erfolg - gewuerfelt, ob der
|
/* Anschliessend wird - unabhaengig vom Erfolg - gewuerfelt, ob der
|
||||||
|
@ -344,7 +347,7 @@ static int top_skill(region * r, faction * f, ship * sh, skill_t sk)
|
||||||
for (u = r->units; u; u = u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
if (u->ship == sh && u->faction == f) {
|
if (u->ship == sh && u->faction == f) {
|
||||||
int s = effskill(u, sk, 0);
|
int s = effskill(u, sk, 0);
|
||||||
value = MAX(s, value);
|
if (value < s) value = s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
|
12
src/steal.c
12
src/steal.c
|
@ -17,7 +17,9 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
|
#endif
|
||||||
#include <kernel/config.h>
|
#include <kernel/config.h>
|
||||||
#include "economy.h"
|
#include "economy.h"
|
||||||
|
|
||||||
|
@ -80,7 +82,8 @@ void expandstealing(region * r, econ_request * stealorders)
|
||||||
n = 10;
|
n = 10;
|
||||||
}
|
}
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
n = MIN(n, requests[j].unit->wants);
|
int w = requests[j].unit->wants;
|
||||||
|
if (n > w) n = w;
|
||||||
use_pooled(u, rsilver, GET_ALL, n);
|
use_pooled(u, rsilver, GET_ALL, n);
|
||||||
requests[j].unit->n = n;
|
requests[j].unit->n = n;
|
||||||
change_money(requests[j].unit, n);
|
change_money(requests[j].unit, n);
|
||||||
|
@ -217,7 +220,8 @@ void steal_cmd(unit * u, struct order *ord, econ_request ** stealorders)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i = MIN(u->number, i_get(u->items, rring->itype));
|
i = i_get(u->items, rring->itype);
|
||||||
|
if (i > u->number) i = u->number;
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
n *= STEALINCOME * (u->number + i * (roqf_factor() - 1));
|
n *= STEALINCOME * (u->number + i * (roqf_factor() - 1));
|
||||||
}
|
}
|
||||||
|
@ -239,6 +243,6 @@ void steal_cmd(unit * u, struct order *ord, econ_request ** stealorders)
|
||||||
*stealorders = o;
|
*stealorders = o;
|
||||||
|
|
||||||
/* Nur soviel PRODUCEEXP wie auch tatsaechlich gemacht wurde */
|
/* Nur soviel PRODUCEEXP wie auch tatsaechlich gemacht wurde */
|
||||||
|
if (n > u->number) n = u->number;
|
||||||
produceexp(u, SK_STEALTH, MIN(n, u->number));
|
produceexp(u, SK_STEALTH, n);
|
||||||
}
|
}
|
||||||
|
|
11
src/study.c
11
src/study.c
|
@ -16,7 +16,9 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
|
#endif
|
||||||
#include <kernel/config.h>
|
#include <kernel/config.h>
|
||||||
#include "study.h"
|
#include "study.h"
|
||||||
#include "laws.h"
|
#include "laws.h"
|
||||||
|
@ -613,7 +615,8 @@ int study_cmd(unit * u, order * ord)
|
||||||
}
|
}
|
||||||
/* Akademie: */
|
/* Akademie: */
|
||||||
if (active_building(u, bt_find("academy"))) {
|
if (active_building(u, bt_find("academy"))) {
|
||||||
studycost = MAX(50, studycost * 2);
|
studycost = studycost * 2;
|
||||||
|
if (studycost < 50) studycost = 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sk == SK_MAGIC) {
|
if (sk == SK_MAGIC) {
|
||||||
|
@ -721,12 +724,14 @@ int study_cmd(unit * u, order * ord)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_effect(u, oldpotiontype[P_WISE])) {
|
if (get_effect(u, oldpotiontype[P_WISE])) {
|
||||||
l = MIN(u->number, get_effect(u, oldpotiontype[P_WISE]));
|
l = get_effect(u, oldpotiontype[P_WISE]);
|
||||||
|
if (l > u->number) l = u->number;
|
||||||
teach->days += l * EXPERIENCEDAYS;
|
teach->days += l * EXPERIENCEDAYS;
|
||||||
change_effect(u, oldpotiontype[P_WISE], -l);
|
change_effect(u, oldpotiontype[P_WISE], -l);
|
||||||
}
|
}
|
||||||
if (get_effect(u, oldpotiontype[P_FOOL])) {
|
if (get_effect(u, oldpotiontype[P_FOOL])) {
|
||||||
l = MIN(u->number, get_effect(u, oldpotiontype[P_FOOL]));
|
l = get_effect(u, oldpotiontype[P_FOOL]);
|
||||||
|
if (l > u->number) l = u->number;
|
||||||
teach->days -= l * STUDYDAYS;
|
teach->days -= l * STUDYDAYS;
|
||||||
change_effect(u, oldpotiontype[P_FOOL], -l);
|
change_effect(u, oldpotiontype[P_FOOL], -l);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* wenn platform.h nicht vor curses included wird, kompiliert es unter windows nicht */
|
#ifdef _MSC_VER
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
|
#endif
|
||||||
#include <kernel/config.h>
|
#include <kernel/config.h>
|
||||||
|
|
||||||
#include "summary.h"
|
#include "summary.h"
|
||||||
|
@ -97,8 +98,8 @@ int update_nmrs(void)
|
||||||
if (timeout>0) {
|
if (timeout>0) {
|
||||||
if (nmr < 0 || nmr > timeout) {
|
if (nmr < 0 || nmr > timeout) {
|
||||||
log_error("faction %s has %d NMR", itoa36(f->no), nmr);
|
log_error("faction %s has %d NMR", itoa36(f->no), nmr);
|
||||||
nmr = MAX(0, nmr);
|
if (nmr < 0) nmr = 0;
|
||||||
nmr = MIN(nmr, timeout);
|
if (nmr > timeout) nmr = timeout;
|
||||||
}
|
}
|
||||||
if (nmr > 0) {
|
if (nmr > 0) {
|
||||||
log_debug("faction %s has %d NMR", itoa36(f->no), nmr);
|
log_debug("faction %s has %d NMR", itoa36(f->no), nmr);
|
||||||
|
|
20
src/upkeep.c
20
src/upkeep.c
|
@ -1,4 +1,6 @@
|
||||||
|
#ifdef _MSC_VER
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
|
#endif
|
||||||
#include "upkeep.h"
|
#include "upkeep.h"
|
||||||
|
|
||||||
#include <kernel/ally.h>
|
#include <kernel/ally.h>
|
||||||
|
@ -42,7 +44,7 @@ static void help_feed(unit * donor, unit * u, int *need_p)
|
||||||
{
|
{
|
||||||
int need = *need_p;
|
int need = *need_p;
|
||||||
int give = get_money(donor) - lifestyle(donor);
|
int give = get_money(donor) - lifestyle(donor);
|
||||||
give = MIN(need, give);
|
if (give > need) give = need;
|
||||||
|
|
||||||
if (give > 0) {
|
if (give > 0) {
|
||||||
change_money(donor, -give);
|
change_money(donor, -give);
|
||||||
|
@ -167,7 +169,7 @@ void get_food(region * r)
|
||||||
* food from the peasants - should not be used with WORK */
|
* food from the peasants - should not be used with WORK */
|
||||||
if (owner != NULL && (get_alliance(owner, u->faction) & HELP_MONEY)) {
|
if (owner != NULL && (get_alliance(owner, u->faction) & HELP_MONEY)) {
|
||||||
int rm = rmoney(r);
|
int rm = rmoney(r);
|
||||||
int use = MIN(rm, need);
|
int use = (rm < need) ? rm : need;
|
||||||
rsetmoney(r, rm - use);
|
rsetmoney(r, rm - use);
|
||||||
need -= use;
|
need -= use;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +182,7 @@ void get_food(region * r)
|
||||||
for (v = r->units; need && v; v = v->next) {
|
for (v = r->units; need && v; v = v->next) {
|
||||||
if (v->faction == u->faction) {
|
if (v->faction == u->faction) {
|
||||||
int give = get_money(v) - lifestyle(v);
|
int give = get_money(v) - lifestyle(v);
|
||||||
give = MIN(need, give);
|
if (give > need) give = need;
|
||||||
if (give > 0) {
|
if (give > 0) {
|
||||||
change_money(v, -give);
|
change_money(v, -give);
|
||||||
change_money(u, give);
|
change_money(u, give);
|
||||||
|
@ -194,11 +196,11 @@ void get_food(region * r)
|
||||||
/* 2. Versorgung durch Fremde. Das Silber alliierter Einheiten wird
|
/* 2. Versorgung durch Fremde. Das Silber alliierter Einheiten wird
|
||||||
* entsprechend verteilt. */
|
* entsprechend verteilt. */
|
||||||
for (u = r->units; u; u = u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
int need = lifestyle(u);
|
int need;
|
||||||
faction *f = u->faction;
|
faction *f = u->faction;
|
||||||
|
|
||||||
assert(u->hp > 0);
|
assert(u->hp > 0);
|
||||||
need -= MAX(0, get_money(u));
|
need = lifestyle(u) - get_money(u);
|
||||||
|
|
||||||
if (need > 0) {
|
if (need > 0) {
|
||||||
unit *v;
|
unit *v;
|
||||||
|
@ -253,8 +255,8 @@ void get_food(region * r)
|
||||||
unit *donor = u;
|
unit *donor = u;
|
||||||
while (donor != NULL && hungry > 0) {
|
while (donor != NULL && hungry > 0) {
|
||||||
int blut = get_effect(donor, pt_blood);
|
int blut = get_effect(donor, pt_blood);
|
||||||
blut = MIN(blut, hungry);
|
if (hungry < blut) blut = hungry;
|
||||||
if (blut) {
|
if (blut > 0) {
|
||||||
change_effect(donor, pt_blood, -blut);
|
change_effect(donor, pt_blood, -blut);
|
||||||
hungry -= blut;
|
hungry -= blut;
|
||||||
}
|
}
|
||||||
|
@ -306,7 +308,9 @@ void get_food(region * r)
|
||||||
|
|
||||||
/* 3. Von den <20>berlebenden das Geld abziehen: */
|
/* 3. Von den <20>berlebenden das Geld abziehen: */
|
||||||
for (u = r->units; u; u = u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
int need = MIN(get_money(u), lifestyle(u));
|
int m = get_money(u);
|
||||||
|
int need = lifestyle(u);
|
||||||
|
if (need > m) need = m;
|
||||||
change_money(u, -need);
|
change_money(u, -need);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
ACTION OF CONTRACT, NEGLIGENCE OR OTH19ER TORTIOUS ACTION, ARISING OUT OF
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
typedef struct strlist {
|
typedef struct strlist {
|
||||||
struct strlist *next;
|
struct strlist *next;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
|
@ -10,10 +10,9 @@ This program may not be used, modified or distributed
|
||||||
without prior permission by the authors of Eressea.
|
without prior permission by the authors of Eressea.
|
||||||
*/
|
*/
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
#include "bsdstring.h"
|
#include "bsdstring.h"
|
||||||
#include "log.h"
|
|
||||||
#include "path.h"
|
|
||||||
#include "unicode.h"
|
#include "unicode.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <platform.h>
|
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#include <platform.h>
|
|
||||||
#include "variant.h"
|
#include "variant.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue