Bug 2630: Drachen

1. Jungdrachen sind Drachen (RCF_DRAGON)
2. Ein Monster das nicht kämpfen kann, braucht nicht zu plündern.
3. make code more readable.
4. Wer schon bewacht, braucht keinen BEWACHE Befehl.
This commit is contained in:
Enno Rehling 2020-01-07 19:24:10 +01:00
parent ea15af879e
commit 2e054f27cc
3 changed files with 19 additions and 15 deletions

View File

@ -721,7 +721,7 @@
<attack type="4" damage="3d30"/> <attack type="4" damage="3d30"/>
<attack type="6" spell="icy_dragonbreath" level="6" /> <attack type="6" spell="icy_dragonbreath" level="6" />
</race> </race>
<race name="youngdragon" magres="50" maxaura="1.000000" regaura="1.000000" weight="20000" capacity="10000" speed="1.000000" hp="300" ac="4" damage="2d15" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="4" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes" unarmedguard="yes"> <race name="youngdragon" magres="50" maxaura="1.000000" regaura="1.000000" weight="20000" capacity="10000" speed="1.000000" hp="300" ac="4" damage="2d15" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="4" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes" unarmedguard="yes" dragon="yes">
<ai splitsize="6" killpeasants="yes" learn="yes" scarepeasants="yes"/> <ai splitsize="6" killpeasants="yes" learn="yes" scarepeasants="yes"/>
<skill name="magic" modifier="4"/> <skill name="magic" modifier="4"/>
<skill name="tactics" modifier="4"/> <skill name="tactics" modifier="4"/>

View File

@ -130,8 +130,9 @@ function process(rules, orders)
end end
turn_begin() turn_begin()
-- create orders for monsters:
-- run the turn: plan_monsters()
-- read orders for players:
if eressea.read_orders(orders) ~= 0 then if eressea.read_orders(orders) ~= 0 then
print("could not read " .. orders) print("could not read " .. orders)
return -1 return -1
@ -140,8 +141,9 @@ function process(rules, orders)
if nmr_check(config.maxnmrs or 80)~=0 then if nmr_check(config.maxnmrs or 80)~=0 then
return -1 return -1
end end
plan_monsters()
callbacks(rules, 'init') callbacks(rules, 'init')
-- run the turn:
turn_process() turn_process()
callbacks(rules, 'update') callbacks(rules, 'update')
turn_end() -- ageing, etc. turn_end() -- ageing, etc.

View File

@ -214,10 +214,10 @@ int monster_attacks(unit * monster, bool rich_only)
return result; 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; 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. */ /* falls genug geld in der region ist, treiben wir steuern ein. */
if (rmoney(r) >= wanted) { 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 /* falls der drache launisch ist, oder das regionssilber knapp, greift er alle an
* und holt sich Silber von Einheiten, vorausgesetzt er bewacht bereits */ * und holt sich Silber von Einheiten, vorausgesetzt er bewacht bereits */
money = 0; money = 0;
if (attacks && is_guard(udragon)) { if (attacks && is_guard(u)) {
int m = monster_attacks(udragon, true); int m = monster_attacks(u, true);
if (m > 0) money += m; if (m > 0) money += m;
} }
@ -623,11 +623,11 @@ static order *plan_dragon(unit * u)
rc_wyrm = get_race(RC_WYRM); rc_wyrm = get_race(RC_WYRM);
} }
if (ta == NULL) { if (!move && ta == NULL) {
move |= (rpeasants(r) == 0); /* when no peasants, move */ move = (rpeasants(r) == 0); /* when no peasants, move */
move |= (rmoney(r) == 0); /* when no money, 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) { if (rc == rc_wyrm && !move) {
unit *u2; unit *u2;
@ -739,6 +739,7 @@ void plan_monsters(faction * f)
attrib *ta; attrib *ta;
order *long_order = NULL; order *long_order = NULL;
bool can_move = true; bool can_move = true;
bool guarding;
/* Ab hier nur noch Befehle fuer NPC-Einheiten. */ /* Ab hier nur noch Befehle fuer NPC-Einheiten. */
if (u->faction != f || u->number <= 0) { if (u->faction != f || u->number <= 0) {
@ -763,8 +764,9 @@ void plan_monsters(faction * f)
/* Befehle muessen jede Runde neu gegeben werden: */ /* Befehle muessen jede Runde neu gegeben werden: */
free_orders(&u->orders); free_orders(&u->orders);
/* All monsters guard the region: */ guarding = is_guard(u);
if (u->status < ST_FLEE && !monster_is_waiting(u) && r->land) { /* 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)); unit_addorder(u, create_order(K_GUARD, u->faction->locale, NULL));
} }
@ -790,7 +792,7 @@ void plan_monsters(faction * f)
else else
a_remove(&u->attribs, ta); a_remove(&u->attribs, ta);
} }
else if (!r->land || is_guard(u)) { else if (!r->land || guarding) {
if (chance(attack_chance)) { if (chance(attack_chance)) {
int m = monster_attacks(u, false); int m = monster_attacks(u, false);
if (m >= 0) { if (m >= 0) {