From 1c7075573b0740cb2fc783b5e67fa1b6b4d6b5df Mon Sep 17 00:00:00 2001 From: CTD Date: Mon, 15 Sep 2014 15:51:40 +0200 Subject: [PATCH] =?UTF-8?q?Pl=C3=BCndern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Neues Kommando Plündern für die Monster (kann über XML-Option auch für Spieler freigeschaltet werden) --- res/core/de/strings.xml | 3 ++ res/core/en/strings.xml | 3 ++ res/core/messages.xml | 2 +- src/economy.c | 112 +++++++++++++++++++++++++++++++++++++++- src/economy.h | 30 +++++------ src/kernel/order.c | 3 ++ src/keyword.c | 1 + src/keyword.h | 1 + 8 files changed, 137 insertions(+), 18 deletions(-) diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index cd408f9ea..9a757c70a 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -2302,6 +2302,9 @@ SORTIEREN + + Plündere + diff --git a/res/core/en/strings.xml b/res/core/en/strings.xml index a85bb5a4f..218e287e0 100644 --- a/res/core/en/strings.xml +++ b/res/core/en/strings.xml @@ -1574,6 +1574,9 @@ GROW + + loot + diff --git a/res/core/messages.xml b/res/core/messages.xml index fd601adf0..9da26add2 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 bb24fd5e5..38b09ec77 100644 --- a/src/economy.c +++ b/src/economy.c @@ -3194,6 +3194,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 (chance(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; @@ -3281,6 +3318,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) { @@ -3344,7 +3446,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; @@ -3380,6 +3482,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) { @@ -3448,6 +3551,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; @@ -3483,6 +3590,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 23f55a609..acea0aecc 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;