From 2e054f27ccab812bb0e1d28512d36f6b3a21bae0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 7 Jan 2020 19:24:10 +0100 Subject: [PATCH] =?UTF-8?q?Bug=202630:=20Drachen=201.=20Jungdrachen=20sind?= =?UTF-8?q?=20Drachen=20(RCF=5FDRAGON)=202.=20Ein=20Monster=20das=20nicht?= =?UTF-8?q?=20k=C3=A4mpfen=20kann,=20braucht=20nicht=20zu=20pl=C3=BCndern.?= =?UTF-8?q?=203.=20make=20code=20more=20readable.=204.=20Wer=20schon=20bew?= =?UTF-8?q?acht,=20braucht=20keinen=20BEWACHE=20Befehl.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- res/eressea/races.xml | 2 +- scripts/run-turn.lua | 8 +++++--- src/monsters.c | 24 +++++++++++++----------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/res/eressea/races.xml b/res/eressea/races.xml index 82b642ba2..8c3822110 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -721,7 +721,7 @@ - + diff --git a/scripts/run-turn.lua b/scripts/run-turn.lua index e5c90a7be..7ef29b00d 100644 --- a/scripts/run-turn.lua +++ b/scripts/run-turn.lua @@ -130,8 +130,9 @@ function process(rules, orders) end turn_begin() - - -- run the turn: + -- create orders for monsters: + plan_monsters() + -- read orders for players: if eressea.read_orders(orders) ~= 0 then print("could not read " .. orders) return -1 @@ -140,8 +141,9 @@ function process(rules, orders) if nmr_check(config.maxnmrs or 80)~=0 then return -1 end - plan_monsters() callbacks(rules, 'init') + + -- run the turn: turn_process() callbacks(rules, 'update') turn_end() -- ageing, etc. diff --git a/src/monsters.c b/src/monsters.c index 6f20a8c8b..b1ff0feba 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -214,10 +214,10 @@ int monster_attacks(unit * monster, bool rich_only) return result; } -static order *get_money_for_dragon(region * r, unit * udragon, int wanted) +static order *get_money_for_dragon(region * r, unit * u, int wanted) { int money; - bool attacks = attack_chance > 0.0; + bool attacks = (attack_chance > 0.0) && armedmen(u); /* falls genug geld in der region ist, treiben wir steuern ein. */ if (rmoney(r) >= wanted) { @@ -231,8 +231,8 @@ static order *get_money_for_dragon(region * r, unit * udragon, int wanted) /* falls der drache launisch ist, oder das regionssilber knapp, greift er alle an * und holt sich Silber von Einheiten, vorausgesetzt er bewacht bereits */ money = 0; - if (attacks && is_guard(udragon)) { - int m = monster_attacks(udragon, true); + if (attacks && is_guard(u)) { + int m = monster_attacks(u, true); if (m > 0) money += m; } @@ -623,11 +623,11 @@ static order *plan_dragon(unit * u) rc_wyrm = get_race(RC_WYRM); } - if (ta == NULL) { - move |= (rpeasants(r) == 0); /* when no peasants, move */ - move |= (rmoney(r) == 0); /* when no money, move */ + if (!move && ta == NULL) { + move = (rpeasants(r) == 0); /* when no peasants, move */ + move = move || (rmoney(r) == 0); /* when no money, move */ } - move |= chance(0.04); /* 4% chance to change your mind */ + move = move || chance(0.04); /* 4% chance to change your mind */ if (rc == rc_wyrm && !move) { unit *u2; @@ -739,6 +739,7 @@ void plan_monsters(faction * f) attrib *ta; order *long_order = NULL; bool can_move = true; + bool guarding; /* Ab hier nur noch Befehle fuer NPC-Einheiten. */ if (u->faction != f || u->number <= 0) { @@ -763,8 +764,9 @@ void plan_monsters(faction * f) /* Befehle muessen jede Runde neu gegeben werden: */ free_orders(&u->orders); - /* All monsters guard the region: */ - if (u->status < ST_FLEE && !monster_is_waiting(u) && r->land) { + guarding = is_guard(u); + /* All monsters want to guard the region: */ + if (!guarding && u->status < ST_FLEE && !monster_is_waiting(u) && r->land) { unit_addorder(u, create_order(K_GUARD, u->faction->locale, NULL)); } @@ -790,7 +792,7 @@ void plan_monsters(faction * f) else a_remove(&u->attribs, ta); } - else if (!r->land || is_guard(u)) { + else if (!r->land || guarding) { if (chance(attack_chance)) { int m = monster_attacks(u, false); if (m >= 0) {