stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus/src ai/ai_force.c unit/unit.c


From: address@hidden
Subject: [Stratagus-CVS] stratagus/src ai/ai_force.c unit/unit.c
Date: 9 Feb 2004 13:40:48 +1100

CVSROOT:        /home/strat
Module name:    stratagus
Changes by:      <address@hidden>       04/02/09 13:40:48

Modified files:
        src/ai         : ai_force.c 
        src/unit       : unit.c 

Log message:
        Better way for ai to attack, attack even if under fog(DUH)
        Fix divide by 0 run away code.

Patches:
Index: stratagus/src/ai/ai_force.c
diff -u stratagus/src/ai/ai_force.c:1.48 stratagus/src/ai/ai_force.c:1.49
--- stratagus/src/ai/ai_force.c:1.48    Mon Jan 19 09:36:23 2004
+++ stratagus/src/ai/ai_force.c Mon Feb  9 13:40:46 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: ai_force.c,v 1.48 2004/01/18 22:36:23 nobody_ Exp $
+//      $Id: ai_force.c,v 1.49 2004/02/09 02:40:46 nobody_ Exp $
 
 //@{
 
@@ -496,11 +496,11 @@
                DebugLevel3Fn("FORCE %d started (AiAttackWithForce)\n" _C_ 
force);
 
                enemy = NoUnitP;
-               while (aiunit && !enemy) {  // Use a unit that can attack
-                       if (aiunit->Unit->Type->CanAttack) {
-                               enemy = AttackUnitsInDistance(aiunit->Unit, 
MaxMapWidth);
+               for (x = 0; x < NumUnits; ++x) {
+                       if (IsEnemy(AiPlayer->Player, Units[x]) && 
Units[x]->HP) {
+                               enemy = Units[x];
+                               break;
                        }
-                       aiunit = aiunit->Next;
                }
 
                if (!enemy) {
Index: stratagus/src/unit/unit.c
diff -u stratagus/src/unit/unit.c:1.391 stratagus/src/unit/unit.c:1.392
--- stratagus/src/unit/unit.c:1.391     Mon Feb  9 05:10:08 2004
+++ stratagus/src/unit/unit.c   Mon Feb  9 13:40:47 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: unit.c,v 1.391 2004/02/08 18:10:08 nobody_ Exp $
+//      $Id: unit.c,v 1.392 2004/02/09 02:40:47 nobody_ Exp $
 
 //@{
 
@@ -3132,6 +3132,9 @@
                x = target->X - attacker->X;
                y = target->Y - attacker->Y;
                d = isqrt(x * x + y * y);
+               if (!d) {
+                       d = 1;
+               }
                x = target->X + (x * 5) / d;
                y = target->Y + (y * 5) / d;
                CommandStopUnit(target);
@@ -3744,7 +3747,7 @@
        int j;
 
        CLprintf(file, "\n--- -----------------------------------------\n");
-       CLprintf(file, "--- MODULE: units $Id: unit.c,v 1.391 2004/02/08 
18:10:08 nobody_ Exp $\n\n");
+       CLprintf(file, "--- MODULE: units $Id: unit.c,v 1.392 2004/02/09 
02:40:47 nobody_ Exp $\n\n");
 
 #if 0
        //




reply via email to

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