Teppo Mäenpää has proposed merging
lp:~kxq/widelands/feature-1656664-scout-improvement into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1656664 in widelands: "Scouts are a sore point of this game."
https://bugs.launchpad.net/widelands/+bug/1656664
For more details, see:
https://code.launchpad.net/~kxq/widelands/feature-1656664-scout-improvement/+merge/335284
This is a lightweight fix to the issue described verbosely in
https://wl.widelands.org/forum/topic/2792 and briefly below:
If player can only build small military huts, and the enemy has a large one,
the large may be unattackable as a result of small vision range and long
distance. The only way is to use scout to temporarily bring the enemy MS to
vision. However, that requires a lot of patience because of reasons discussed
in the forum.
With this modification, the switches between random walking and doing an
excursion to enemy military sites.
The scout is still in the worker class.
--
Your team Widelands Developers is requested to review the proposed merge of
lp:~kxq/widelands/feature-1656664-scout-improvement into lp:widelands.
=== modified file 'data/tribes/workers/atlanteans/scout/init.lua'
--- data/tribes/workers/atlanteans/scout/init.lua 2017-02-12 09:10:57 +
+++ data/tribes/workers/atlanteans/scout/init.lua 2017-12-16 17:12:13 +
@@ -15,7 +15,7 @@
descname = pgettext("atlanteans_worker", "Scout"),
helptext_script = dirname .. "helptexts.lua",
icon = dirname .. "menu.png",
- vision_range = 2,
+ vision_range = 3,
buildcost = {
atlanteans_carrier = 1
=== modified file 'data/tribes/workers/barbarians/scout/init.lua'
--- data/tribes/workers/barbarians/scout/init.lua 2017-02-12 09:10:57 +
+++ data/tribes/workers/barbarians/scout/init.lua 2017-12-16 17:12:13 +
@@ -17,7 +17,7 @@
descname = pgettext("barbarians_worker", "Scout"),
helptext_script = dirname .. "helptexts.lua",
icon = dirname .. "menu.png",
- vision_range = 2,
+ vision_range = 3,
buildcost = {
barbarians_carrier = 1
=== modified file 'data/tribes/workers/empire/scout/init.lua'
--- data/tribes/workers/empire/scout/init.lua 2017-02-12 09:10:57 +
+++ data/tribes/workers/empire/scout/init.lua 2017-12-16 17:12:13 +
@@ -17,7 +17,7 @@
descname = pgettext("empire_worker", "Scout"),
helptext_script = dirname .. "helptexts.lua",
icon = dirname .. "menu.png",
- vision_range = 2,
+ vision_range = 3,
buildcost = {
empire_carrier = 1
=== modified file 'src/logic/findimmovable.cc'
--- src/logic/findimmovable.cc 2017-05-20 22:42:49 +
+++ src/logic/findimmovable.cc 2017-12-16 17:12:13 +
@@ -21,6 +21,7 @@
#include "base/macros.h"
#include "economy/flag.h"
+#include "logic/map.h"
#include "logic/map_objects/immovable.h"
#include "logic/map_objects/tribes/militarysite.h"
@@ -66,6 +67,14 @@
}
return false;
}
+// Enemy military sites that cannot be attacked (for scout)
+bool FindForeignMsite::accept(const BaseImmovable& imm) const {
+ if (upcast(MilitarySite const, ms, ))
+ {
+ return >owner() !=
+ }
+ return false;
+}
bool FindImmovableByDescr::accept(const BaseImmovable& baseimm) const {
if (upcast(const Immovable, imm, )) {
=== modified file 'src/logic/findimmovable.h'
--- src/logic/findimmovable.h 2017-08-18 16:29:43 +
+++ src/logic/findimmovable.h 2017-12-16 17:12:13 +
@@ -138,6 +138,13 @@
bool accept(const BaseImmovable&) const;
};
+struct FindForeignMsite {
+ explicit FindForeignMsite(const Player& init_player) : player(init_player) {
+ }
+ bool accept(const BaseImmovable&) const;
+ const Player& player;
+};
+
struct FindImmovableByDescr {
explicit FindImmovableByDescr(const ImmovableDescr& init_descr) : descr(init_descr) {
}
=== modified file 'src/logic/map_objects/tribes/worker.cc'
--- src/logic/map_objects/tribes/worker.cc 2017-11-12 08:59:45 +
+++ src/logic/map_objects/tribes/worker.cc 2017-12-16 17:12:13 +
@@ -2551,6 +2551,141 @@
state.ivar1 = radius;
state.ivar2 = game.get_gametime() + time;
+ // Enemy military sites cannot be attacked, if those are not visible.
+ // However, Widelands workers are still somewhat aware of their presence. For example,
+ // Player does not acquire ownership of land, even if a militarysite blocking it is
+ // invisible. Therefore, it is IMO okay for the scout to be aware of those as well.
+ // Scout occasionally pays special attention to enemy military sites, to give the player
+ // an opportunity to attack. This is important, if the player can only build small huts
+ // and the enemy has one of the bigggest ones: without scout, the player has no way of attacking.
+ // The following block switches between two modes of operation:
+ // - Random walk
+ // - Lurking near an enemy military site.
+ // The code keeps track if interesting military sites, so that they all are visited.
+ // When the list of unvisited potential attack