stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus/src clone/unit.c include/minimap.h in...


From: ludovic pollet
Subject: [Stratagus-CVS] stratagus/src clone/unit.c include/minimap.h in...
Date: Sat, 01 Nov 2003 06:33:11 -0500

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

Modified files:
        src/clone      : unit.c 
        src/include    : minimap.h unit.h 
        src/map        : minimap.c 
        src/unit       : ccl_unit.c 
        src/ai         : ai_resource.c 

Log message:
        made AI wait until attack ends, before repairing buildings

Patches:
Index: stratagus/src/ai/ai_resource.c
diff -u stratagus/src/ai/ai_resource.c:1.76 stratagus/src/ai/ai_resource.c:1.77
--- stratagus/src/ai/ai_resource.c:1.76 Fri Oct 31 04:14:45 2003
+++ stratagus/src/ai/ai_resource.c      Sat Nov  1 06:33:10 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: ai_resource.c,v 1.76 2003/10/31 09:14:45 pludov Exp $
+//      $Id: ai_resource.c,v 1.77 2003/11/01 11:33:10 pludov Exp $
 
 //@{
 
@@ -1241,10 +1241,12 @@
        unit = AiPlayer->Player->Units[i];
        repair_flag = 1;
        // Unit damaged?
+       // Don't repair attacked unit ( wait 5 sec before repairing )
        if (unit->Type->Building
            && unit->Orders[0].Action != UnitActionBuilded
            && unit->Orders[0].Action != UnitActionUpgradeTo
-           && unit->HP < unit->Stats->HitPoints) {
+           && unit->HP < unit->Stats->HitPoints
+           && unit->Attacked + 5 * CYCLES_PER_SECOND < GameCycle) {
 
            DebugLevel3Fn("Have building to repair %d(%s)\n" _C_
                UnitNumber(unit) _C_ unit->Type->Ident);
Index: stratagus/src/clone/unit.c
diff -u stratagus/src/clone/unit.c:1.325 stratagus/src/clone/unit.c:1.326
--- stratagus/src/clone/unit.c:1.325    Thu Oct 30 15:22:49 2003
+++ stratagus/src/clone/unit.c  Sat Nov  1 06:33:07 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unit.c,v 1.325 2003/10/30 20:22:49 n0body Exp $
+//     $Id: unit.c,v 1.326 2003/11/01 11:33:07 pludov Exp $
 
 //@{
 
@@ -2925,6 +2925,7 @@
 {
     UnitType* type;
     Unit* goal;
+    unsigned long lastattack;
 
     if (!damage) {                     // Can now happen by splash damage
        DebugLevel0Fn("Warning no damage, try to fix by caller?\n");
@@ -2953,7 +2954,11 @@
     }
 
     type = target->Type;
-    if (!target->Attacked) {
+    lastattack = target->Attacked;
+    target->Attacked = GameCycle ? GameCycle : 1;
+
+
+    if (!lastattack || lastattack + 2 * CYCLES_PER_SECOND < GameCycle) {
        // NOTE: perhaps this should also be moved into the notify?
        if (target->Player == ThisPlayer) {
            // FIXME: Problem with load+save.
@@ -2982,7 +2987,6 @@
            AiHelpMe(attacker, target);
        }
     }
-    target->Attacked = 7;
 
     if (target->HP <= damage) {        // unit is killed or destroyed
        //  increase scores of the attacker, but not if attacking it's own 
units.
@@ -3535,7 +3539,7 @@
        CLprintf(file, "'not-seen ");
     }
     CLprintf(file, "'direction %d\n  ", unit->Direction);
-    CLprintf(file, "'attacked %d\n ", unit->Attacked);
+    CLprintf(file, "'attacked %lu\n ", unit->Attacked);
     CLprintf(file, " 'current-sight-range %d", unit->CurrentSightRange);
     if (unit->Burning) {
        CLprintf(file, " 'burning");
@@ -3743,7 +3747,7 @@
     int RunStart;
 
     CLprintf(file, "\n;;; -----------------------------------------\n");
-    CLprintf(file, ";;; MODULE: units $Id: unit.c,v 1.325 2003/10/30 20:22:49 
n0body Exp $\n\n");
+    CLprintf(file, ";;; MODULE: units $Id: unit.c,v 1.326 2003/11/01 11:33:07 
pludov Exp $\n\n");
 
     //
     // Local variables
Index: stratagus/src/include/minimap.h
diff -u stratagus/src/include/minimap.h:1.21 
stratagus/src/include/minimap.h:1.22
--- stratagus/src/include/minimap.h:1.21        Tue Oct  7 12:05:05 2003
+++ stratagus/src/include/minimap.h     Sat Nov  1 06:33:09 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: minimap.h,v 1.21 2003/10/07 16:05:05 jsalmon3 Exp $
+//     $Id: minimap.h,v 1.22 2003/11/01 11:33:09 pludov Exp $
 
 #ifndef __MINIMAP_H__
 #define __MINIMAP_H__
@@ -38,6 +38,11 @@
 ----------------------------------------------------------------------------*/
 
 #define MINIMAP_FAC    (16*3)          /// integer scale factor
+
+    /// unit attacked are shown red for at least this amount of cycles
+#define ATTACK_RED_DURATION    (1*CYCLES_PER_SECOND)
+    /// unit attacked are shown blinking for this amount of cycles
+#define ATTACK_BLINK_DURATION  (7*CYCLES_PER_SECOND)
 
     /// Update seen tile change in minimap
 #define UpdateMinimapSeenXY(tx,ty)
Index: stratagus/src/include/unit.h
diff -u stratagus/src/include/unit.h:1.225 stratagus/src/include/unit.h:1.226
--- stratagus/src/include/unit.h:1.225  Fri Oct 31 01:18:56 2003
+++ stratagus/src/include/unit.h        Sat Nov  1 06:33:09 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unit.h,v 1.225 2003/10/31 06:18:56 jsalmon3 Exp $
+//     $Id: unit.h,v 1.226 2003/11/01 11:33:09 pludov Exp $
 
 #ifndef __UNIT_H__
 #define __UNIT_H__
@@ -194,8 +194,7 @@
 **
 **     Unit::Attacked
 **
-**             If Attacked is non-zero, the unit is attacked. This member is
-**             counted down.
+**             Last cycle the unit was attacked. 0 means never.
 **
 **     Unit::Burning
 **
@@ -520,7 +519,7 @@
 
     unsigned   Direction : 8;          /// angle (0-255) unit looking
 
-    unsigned   Attacked : 4;           /// unit is attacked
+    unsigned long Attacked;            /// gamecycle unit was last attacked
 
     unsigned   Burning : 1;            /// unit is burning
     unsigned   Destroyed : 1;          /// unit is destroyed pending reference
Index: stratagus/src/map/minimap.c
diff -u stratagus/src/map/minimap.c:1.72 stratagus/src/map/minimap.c:1.73
--- stratagus/src/map/minimap.c:1.72    Fri Oct 24 00:40:49 2003
+++ stratagus/src/map/minimap.c Sat Nov  1 06:33:09 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: minimap.c,v 1.72 2003/10/24 04:40:49 mr-russ Exp $
+//     $Id: minimap.c,v 1.73 2003/11/01 11:33:09 pludov Exp $
 
 //@{
 
@@ -388,7 +388,8 @@
                (*table)->Type->NeutralMinimapColorRGB.D24.b,
                (*table)->Type->NeutralMinimapColorRGB.D24.c);
        } else if (unit->Player == ThisPlayer) {
-           if (unit->Attacked && red_phase) {
+           if (unit->Attacked && unit->Attacked + ATTACK_BLINK_DURATION > 
GameCycle &&
+                   (red_phase || unit->Attacked + ATTACK_RED_DURATION > 
GameCycle)) {
                color = ColorRed;
            } else if (MinimapShowSelected && unit->Selected) {
                color = ColorWhite;
@@ -416,10 +417,6 @@
            }
        }
 
-       // FIXME: bad place, but must be done for all units
-       if (red_phase_changed && unit->Attacked) {
-           unit->Attacked--;
-       }
     }
 }
 
Index: stratagus/src/unit/ccl_unit.c
diff -u stratagus/src/unit/ccl_unit.c:1.71 stratagus/src/unit/ccl_unit.c:1.72
--- stratagus/src/unit/ccl_unit.c:1.71  Sat Oct 25 19:10:44 2003
+++ stratagus/src/unit/ccl_unit.c       Sat Nov  1 06:33:10 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_unit.c,v 1.71 2003/10/25 23:10:44 n0body Exp $
+//     $Id: ccl_unit.c,v 1.72 2003/11/01 11:33:10 pludov Exp $
 
 //@{
 
@@ -612,6 +612,7 @@
            unit->Direction = gh_scm2int(gh_car(list));
            list = gh_cdr(list);
        } else if (gh_eq_p(value, gh_symbol2scm("attacked"))) {
+           // FIXME : unsigned long should be better handled
            unit->Attacked = gh_scm2int(gh_car(list));
            list = gh_cdr(list);
        } else if (gh_eq_p(value, gh_symbol2scm("burning"))) {
@@ -663,6 +664,7 @@
            unit->Kills = gh_scm2int(gh_car(list));
            list = gh_cdr(list);
        } else if (gh_eq_p(value, gh_symbol2scm("ttl"))) {
+           // FIXME : unsigned long should be better handled
            unit->TTL = gh_scm2int(gh_car(list));
            list = gh_cdr(list);
        } else if (gh_eq_p(value, gh_symbol2scm("bloodlust"))) {




reply via email to

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