diff --git a/conf/keywords.json b/conf/keywords.json
index bc5538810..4f16be9bf 100644
--- a/conf/keywords.json
+++ b/conf/keywords.json
@@ -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",
diff --git a/res/core/en/strings.xml b/res/core/en/strings.xml
index 98bfaf310..71681ec44 100644
--- a/res/core/en/strings.xml
+++ b/res/core/en/strings.xml
@@ -1571,6 +1571,9 @@
GROW
+
+ loot
+
diff --git a/res/core/messages.xml b/res/core/messages.xml
index 52951dc88..932276078 100644
--- a/res/core/messages.xml
+++ b/res/core/messages.xml
@@ -2754,7 +2754,7 @@
- "$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","")))))."
+ "$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","")))))."
"$unit($unit) earns $int($amount)$if($eq($wanted,$amount),""," of $int($wanted)") in $region($region)."
"$unit($unit) earns $int($amount)$if($eq($wanted,$amount),""," of $int($wanted)") in $region($region)."
diff --git a/src/economy.c b/src/economy.c
index 4e132d8f8..862780e09 100644
--- a/src/economy.c
+++ b/src/economy.c
@@ -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. */
diff --git a/src/economy.h b/src/economy.h
index 4ee69ea4b..58891f188 100644
--- a/src/economy.h
+++ b/src/economy.h
@@ -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
}
diff --git a/src/kernel/order.c b/src/kernel/order.c
index f7e94a2aa..5d2ab53da 100644
--- a/src/kernel/order.c
+++ b/src/kernel/order.c
@@ -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:
diff --git a/src/keyword.c b/src/keyword.c
index 25ace155b..b4b181797 100644
--- a/src/keyword.c
+++ b/src/keyword.c
@@ -143,5 +143,6 @@ const char *keywords[MAXKEYWORDS] = {
"claim",
"promote",
"pay",
+ "loot",
};
diff --git a/src/keyword.h b/src/keyword.h
index 8577d682e..24e47da51 100644
--- a/src/keyword.h
+++ b/src/keyword.h
@@ -69,6 +69,7 @@ typedef enum {
K_CLAIM,
K_PROMOTION,
K_PAY,
+ K_LOOT,
MAXKEYWORDS,
NOKEYWORD = -1
} keyword_t;