Merge branch 'loot' of github.com:CTD1/eressea-server-bugfixing into CTD1-loot

Conflicts:
	res/core/de/strings.xml
This commit is contained in:
Enno Rehling 2014-11-02 10:02:30 +01:00
commit bbd4e31cf9
8 changed files with 135 additions and 18 deletions

View File

@ -30,6 +30,7 @@
"maketemp": ["MACHE TEMP", "MACHETEMP"],
"move" : "NACH",
"password" : "PASSWORD",
"loot" : ["PLÜNDERE", "PLÜNDERN"],
"recruit": ["REKRUTIERE", "REKRUTIEREN"],
"reserve": ["RESERVIERE", "RESERVIEREN"],
"route": "ROUTE",

View File

@ -1571,6 +1571,9 @@
<string name="grow">
<text locale="en">GROW</text>
</string>
<string name="loot">
<text locale="en">loot</text>
</string>
</namespace>
<!-- NR generieren -->

View File

@ -2754,7 +2754,7 @@
<arg name="wanted" type="int"/>
<arg name="mode" type="int"/>
</type>
<text locale="de">"$unit($unit) verdient$if($eq($mode,4)," am Handel","") in $region($region) $int($amount)$if($eq($wanted,$amount),""," statt $int($wanted)") Silber$if($eq($mode,1)," durch Unterhaltung",$if($eq($mode,2)," durch Steuern",$if($eq($mode,3)," durch Handel",$if($eq($mode,5)," durch Diebstahl",$if($eq($mode,6)," durch Zauberei","")))))."</text>
<text locale="de">"$unit($unit) verdient$if($eq($mode,4)," am Handel","") in $region($region) $int($amount)$if($eq($wanted,$amount),""," statt $int($wanted)") Silber$if($eq($mode,1)," durch Unterhaltung",$if($eq($mode,2)," durch Steuern",$if($eq($mode,3)," durch Handel",$if($eq($mode,5)," durch Diebstahl",$if($eq($mode,6)," durch Zauberei",$if($eq($mode,7)," durch Pluendern","")))))."</text>
<text locale="fr">"$unit($unit) earns $int($amount)$if($eq($wanted,$amount),""," of $int($wanted)") in $region($region)."</text>
<text locale="en">"$unit($unit) earns $int($amount)$if($eq($wanted,$amount),""," of $int($wanted)") in $region($region)."</text>
</message>

View File

@ -3192,6 +3192,43 @@ static int do_work(unit * u, order * ord, request * o)
return -1;
}
static void expandloot(region * r, request * lootorders)
{
unit *u;
int i;
int looted = 0;
int startmoney = rmoney(r);
expandorders(r, lootorders);
if (!norders)
return;
for (i = 0; i != norders && rmoney(r) > TAXFRACTION * 2; i++) {
change_money(oa[i].unit, TAXFRACTION);
oa[i].unit->n += TAXFRACTION;
/*Looting destroys double the money*/
rsetmoney(r, rmoney(r) - TAXFRACTION * 2);
looted = looted + TAXFRACTION * 2;
}
free(oa);
/* Lowering morale by 1 depending on the looted money (+20%) */
if (rng_int() % 100 < ((looted / startmoney) + 0.2)) {
int m = region_get_morale(r);
if (m) {
/*Nur Moral -1, turns is not changed, so the first time nothing happens if the morale is good*/
region_set_morale(r, m-1, -1);
}
}
for (u = r->units; u; u = u->next) {
if (u->n >= 0) {
add_income(u, IC_LOOT, u->wants, u->n);
fset(u, UFL_LONGACTION | UFL_NOTMOVING);
}
}
}
static void expandtax(region * r, request * taxorders)
{
unit *u;
@ -3279,6 +3316,71 @@ void tax_cmd(unit * u, struct order *ord, request ** taxorders)
return;
}
void loot_cmd(unit * u, struct order *ord, request ** lootorders)
{
region *r = u->region;
unit *u2;
int n;
int max;
request *o;
keyword_t kwd;
kwd = init_order(ord);
assert(kwd == K_LOOT);
if (get_param_int(global.parameters, "rules.enable_loot", 0) == 0 && !is_monsters(u->faction)) {
return;
}
if (!humanoidrace(u_race(u)) && !is_monsters(u->faction)) {
cmistake(u, ord, 228, MSG_INCOME);
return;
}
if (fval(u, UFL_WERE)) {
cmistake(u, ord, 228, MSG_INCOME);
return;
}
if (besieged(u)) {
cmistake(u, ord, 60, MSG_INCOME);
return;
}
n = armedmen(u, false);
if (!n) {
cmistake(u, ord, 48, MSG_INCOME);
return;
}
u2 = is_guarded(r, u, GUARD_TAX);
if (u2) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, ord, "region_guarded", "guard", u2));
return;
}
max = getuint();
if (max == 0)
max = INT_MAX;
if (!playerrace(u_race(u))) {
u->wants = _min(income(u), max);
}
else {
/* For player start with 20 Silver +10 every 5 level of close combat skill*/
int skbonus = (_max(eff_skill(u, SK_MELEE, r), eff_skill(u, SK_SPEAR, r)) * 2 / 10) + 2;
u->wants = _min(n * skbonus * 10, max);
}
o = (request *)calloc(1, sizeof(request));
o->qty = u->wants / TAXFRACTION;
o->unit = u;
addlist(lootorders, o);
return;
}
#define MAX_WORKERS 2048
void auto_work(region * r)
{
@ -3342,7 +3444,7 @@ static void peasant_taxes(region * r)
void produce(struct region *r)
{
request workers[MAX_WORKERS];
request *taxorders, *sellorders, *stealorders, *buyorders;
request *taxorders, *lootorders, *sellorders, *stealorders, *buyorders;
unit *u;
int todo;
static int rule_autowork = -1;
@ -3378,6 +3480,7 @@ void produce(struct region *r)
nextentertainer = &entertainers[0];
entertaining = 0;
taxorders = 0;
lootorders = 0;
stealorders = 0;
for (u = r->units; u; u = u->next) {
@ -3446,6 +3549,10 @@ void produce(struct region *r)
tax_cmd(u, u->thisorder, &taxorders);
break;
case K_LOOT:
loot_cmd(u, u->thisorder, &lootorders);
break;
case K_STEAL:
steal_cmd(u, u->thisorder, &stealorders);
break;
@ -3481,6 +3588,9 @@ void produce(struct region *r)
if (taxorders)
expandtax(r, taxorders);
if (lootorders)
expandloot(r, lootorders);
/* An erster Stelle Kaufen (expandbuying), die Bauern so Geld bekommen, um
* nachher zu beim Verkaufen (expandselling) den Spielern abkaufen zu
* können. */

View File

@ -37,28 +37,26 @@ extern "C" {
#define TRADE_FRACTION 100
extern int income(const struct unit *u);
extern int income(const struct unit *u);
/* Wieviel Fremde eine Partei pro Woche aufnehmen kann */
#define MAXNEWBIES 5
void economics(struct region *r);
void produce(struct region *r);
void auto_work(struct region *r);
void economics(struct region *r);
void produce(struct region *r);
void auto_work(struct region *r);
enum { IC_WORK, IC_ENTERTAIN, IC_TAX, IC_TRADE, IC_TRADETAX, IC_STEAL,
IC_MAGIC };
void maintain_buildings(struct region *r, bool crash);
extern void add_spende(struct faction *f1, struct faction *f2, int betrag,
struct region *r);
extern int make_cmd(struct unit *u, struct order *ord);
extern void split_allocations(struct region *r);
extern int recruit_archetypes(void);
extern int give_control_cmd(struct unit *u, struct order *ord);
extern void give_control(struct unit * u, struct unit * u2);
enum { IC_WORK, IC_ENTERTAIN, IC_TAX, IC_TRADE, IC_TRADETAX, IC_STEAL, IC_MAGIC, IC_LOOT };
void maintain_buildings(struct region *r, bool crash);
extern void add_spende(struct faction *f1, struct faction *f2, int betrag, struct region *r);
extern int make_cmd(struct unit *u, struct order *ord);
extern void split_allocations(struct region *r);
extern int recruit_archetypes(void);
extern int give_control_cmd(struct unit *u, struct order *ord);
extern void give_control(struct unit * u, struct unit * u2);
struct message * check_steal(const struct unit * u, struct order *ord);
struct message * check_give(const struct unit * u, const struct unit * u2, struct order *ord);
struct message * check_steal(const struct unit * u, struct order *ord);
struct message * check_give(const struct unit * u, const struct unit * u2, struct order *ord);
#ifdef __cplusplus
}

View File

@ -416,6 +416,7 @@ bool is_repeated(const order * ord)
case K_PIRACY:
case K_PLANT:
case K_MAKE:
case K_LOOT:
result = 1;
break;
@ -456,6 +457,7 @@ bool is_exclusive(const order * ord)
case K_PIRACY:
case K_PLANT:
case K_MAKE:
case K_LOOT:
result = 1;
break;
@ -499,6 +501,7 @@ bool is_long(const order * ord)
case K_PIRACY:
case K_PLANT:
case K_MAKE:
case K_LOOT:
return true;
default:

View File

@ -143,5 +143,6 @@ const char *keywords[MAXKEYWORDS] = {
"claim",
"promote",
"pay",
"loot",
};

View File

@ -69,6 +69,7 @@ typedef enum {
K_CLAIM,
K_PROMOTION,
K_PAY,
K_LOOT,
MAXKEYWORDS,
NOKEYWORD = -1
} keyword_t;