Author: esr
Date: Thu Oct 23 09:09:24 2008
New Revision: 30332

URL: http://svn.gna.org/viewcvs/wesnoth?rev=30332&view=rev
Log:
Prevent units damaged units from moving to villages where they are
likely to get whacked on the next turn (because the village
vulnerability exceeds their remaining hitpoints).  Make leaders
twice as cautious this way.

Idea from one of suokko's patches, but the implementation of the
leader-caution effect was wrong.

Modified:
    trunk/src/ai.cpp

Modified: trunk/src/ai.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai.cpp?rev=30332&r1=30331&r2=30332&view=diff
==============================================================================
--- trunk/src/ai.cpp (original)
+++ trunk/src/ai.cpp Thu Oct 23 09:09:24 2008
@@ -1359,6 +1359,8 @@
                        typedef 
std::multimap<location,location>::const_iterator Itor;
                        std::pair<Itor,Itor> it = 
srcdst.equal_range(u_it->first);
                        double best_vulnerability = 100000.0;
+                       // Make leader units more unlikely to move to 
vulnerable villages 
+                       const double leader_penalty = (u.can_recruit()?2.0:1.0);
                        Itor best_loc = it.second;
                        while(it.first != it.second) {
                                const location& dst = it.first->second;
@@ -1375,8 +1377,9 @@
                                ++it.first;
                        }
 
-                       // If we have found an eligible village:
-                       if(best_loc != it.second) {
+                       // If we have found an eligible village,
+                       // and we can move there without expecting to get 
whacked next turn:
+                       if(best_loc != it.second && 
best_vulnerability*leader_penalty < u.hitpoints()) {
                                const location& src = best_loc->first;
                                const location& dst = best_loc->second;
 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to