stratagus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Stratagus-CVS] stratagus/src/ai ai_rules.c


From: ludovic pollet
Subject: [Stratagus-CVS] stratagus/src/ai ai_rules.c
Date: Sat, 01 Nov 2003 11:52:19 -0500

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     ludovic pollet <address@hidden> 03/11/01 11:52:19

Modified files:
        src/ai         : ai_rules.c 

Log message:
        Bug fix in forces

Patches:
Index: stratagus/src/ai/ai_rules.c
diff -u stratagus/src/ai/ai_rules.c:1.5 stratagus/src/ai/ai_rules.c:1.6
--- stratagus/src/ai/ai_rules.c:1.5     Sat Nov  1 06:30:43 2003
+++ stratagus/src/ai/ai_rules.c Sat Nov  1 11:52:19 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: ai_rules.c,v 1.5 2003/11/01 11:30:43 pludov Exp $
+//      $Id: ai_rules.c,v 1.6 2003/11/01 16:52:19 pludov Exp $
 
 //@{
 
@@ -603,14 +603,18 @@
     AiUnitType *unittype;
     UnitType * usedtype;
 
-    AiForceCountUnits(force, count);
+    if (total) {
+       for (i = 0; i <= UnitTypeMax; i++) {
+           count[i]=0;
+       }
+    } else {
+       AiForceCountUnits(force, count);
+    }
 
     // We have everything ready
-    if (!total) {
-       if (!AiForceSubstractWant(force, count)) {
-           DebugLevel3Fn("Force ready, no cost\n");
-           return 0;
-       }
+    if (!AiForceSubstractWant(force, count)) {
+       DebugLevel3Fn("Force ready, no cost\n");
+       return 0;
     }
 
     for (i = 0; i < MaxCosts; i++) {
@@ -827,13 +831,14 @@
     // Compute force requirements.
     AiEvaluateScript(script->Action);
 
-    // TODO : move from force 0 to force script->ownForce    
-    // TODO : give some feedback on force 0 !
-
     // Launch the code.
     code = gh_eval(gh_cadr(gh_cdr(gh_car(script->Action))), NIL);
     AiScript->Script = code;
     AiScript->SleepCycles = 0;
+
+    // Don't add anymore units to this force.
+    AiPlayer->Force[AiScript->ownForce].PopulateMode = AiForceDontPopulate;
+
     snprintf(AiScript->ident, 10, "%s", ident);
 }
 
@@ -877,6 +882,7 @@
     int unitId;
     Unit *unit;
     AiActionEvaluation * action;
+
     if (!player->TotalNumUnits) {
        return NoUnitP;
     }
@@ -1084,13 +1090,13 @@
        leftCost = AiEvaluateForceCost(AiScript->ownForce, 0);
        totalCost = AiEvaluateForceCost(AiScript->ownForce, 1);
        if (leftCost > totalCost) {
-           DebugLevel3Fn("Left cost superior to totalcost ( %d > %d )\n" _C_ 
leftCost _C_ totalCost);
+           DebugLevel0Fn("Left cost superior to totalcost ( %d > %d )\n" _C_ 
leftCost _C_ totalCost);
        }
 
        if (leftCost <= ((2 * totalCost) / 10)) {
            DebugLevel3Fn("Attack script !...\n");
            AiStartScript(bestActionEvaluation->aiScriptAction, "attack");
-       } else if (leftCost <= ((8 * totalCost) /10)) {
+       } else if (leftCost <= ((9 * totalCost) /10)) {
            DebugLevel3Fn("Not ready for attack script, wait...\n");
 
            AiUpdateForce(1, AiScript->ownForce);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]