stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus doc/ccl/unittype.html src/action/acti...


From: address@hidden
Subject: [Stratagus-CVS] stratagus doc/ccl/unittype.html src/action/acti...
Date: 17 Jan 2004 01:40:16 +1100

CVSROOT:        /home/strat
Module name:    stratagus
Changes by:      <address@hidden>       04/01/17 01:40:15

Modified files:
        doc/ccl        : unittype.html 
        src/action     : action_still.c 
        src/include    : unittype.h 
        src/unit       : script_unittype.c unit_find.c 

Log message:
        Added Attacking from within a Transporter funcationality

Patches:
Index: stratagus/doc/ccl/unittype.html
diff -u stratagus/doc/ccl/unittype.html:1.42 
stratagus/doc/ccl/unittype.html:1.43
--- stratagus/doc/ccl/unittype.html:1.42        Sun Nov 30 15:56:21 2003
+++ stratagus/doc/ccl/unittype.html     Sat Jan 17 01:40:12 2004
@@ -533,6 +533,10 @@
 <dd>Unit is a transporter, you can place units inside. Note: you really should 
add
 an unload button for transporters.
 </dd>
+<dt>AttackFromTransporter</dt>
+<dd>Gives units with range the ability to attack from within a transporter 
such as a building.
+These can act like amoured personnel carriers or bunkers
+</dd>
 <dt>max-on-board</dt>
 <dd>This is only used for transporters, It's the maximum allowed on board. 
Curently the
 you can't have more that 6, or you won't get any buttons for the rest.
@@ -729,7 +733,7 @@
 <h4>Not Used</h4>
 
 <hr>
-Last changed: $Id: unittype.html,v 1.42 2003/11/30 04:56:21 jsalmon3 Exp $<br>
+Last changed: $Id: unittype.html,v 1.43 2004/01/16 14:40:12 wizzard Exp $<br>
 All trademarks and copyrights on this page are owned by their respective 
owners.
 <address>(c) 2002-2003 by <a href="http://stratagus.org";>
 The Stratagus Project</a></address></body></html>
Index: stratagus/src/action/action_still.c
diff -u stratagus/src/action/action_still.c:1.78 
stratagus/src/action/action_still.c:1.79
--- stratagus/src/action/action_still.c:1.78    Thu Jan 15 09:31:01 2004
+++ stratagus/src/action/action_still.c Sat Jan 17 01:40:13 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: action_still.c,v 1.78 2004/01/14 22:31:01 nobody_ Exp $
+//      $Id: action_still.c,v 1.79 2004/01/16 14:40:13 wizzard Exp $
 
 //@{
 
@@ -64,7 +64,13 @@
 
        DebugLevel3Fn(" %d\n" _C_ UnitNumber(unit));
 
-       if (unit->Removed) { // Removed units, do nothing?
+       //
+       // If unit is not bunkered and removed, wait
+       //
+       if (unit->Removed && (!unit->Container || 
+                       !unit->Container->Type->Transporter ||
+                       !unit->Container->Type->AttackFromTransporter ||
+                       unit->Type->Missile.Missile->Class == 
MissileClassNone)) {
                // If peon is in building or unit is in transporter it is 
removed.
                unit->Wait = CYCLES_PER_SECOND / 6;
                return;
@@ -167,8 +173,9 @@
        if (type->CanAttack && !type->Coward) {
                //
                // Normal units react in reaction range.
+               // Removed units can only attack in AttackRange, from bunker
                //
-               if (unit->Stats->Speed && !ground) {
+               if (unit->Stats->Speed && !unit->Removed && !ground) {
                        if ((goal = AttackUnitsInReactRange(unit))) {
                                // Weak goal, can choose other unit, come back 
after attack
                                CommandAttack(unit, goal->X, goal->Y, NULL, 
FlushCommands);
Index: stratagus/src/include/unittype.h
diff -u stratagus/src/include/unittype.h:1.139 
stratagus/src/include/unittype.h:1.140
--- stratagus/src/include/unittype.h:1.139      Fri Jan 16 21:35:33 2004
+++ stratagus/src/include/unittype.h    Sat Jan 17 01:40:14 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: unittype.h,v 1.139 2004/01/16 10:35:33 wizzard Exp $
+//      $Id: unittype.h,v 1.140 2004/01/16 14:40:14 wizzard Exp $
 
 #ifndef __UNITTYPE_H__
 #define __UNITTYPE_H__
@@ -323,6 +323,10 @@
 **
 **                             Can transport units
 **
+**  UnitType::AttackFromTransporter
+**    
+**    Units inside this transporter can attack with missiles.
+**
 **             UnitType::MaxOnBoard
 **
 **                             Maximum units on board (for transporters), and 
resources
@@ -719,6 +723,7 @@
        unsigned DetectCloak : 1;       /// Can see Cloaked units.
        unsigned Coward : 1;            /// Unit will only attack if instructed.
        unsigned Transporter : 1;       /// Can transport units
+       unsigned AttackFromTransporter : 1;  /// Can attack from transporter
        unsigned Vanishes : 1;          /// Corpes & destroyed places.
        unsigned GroundAttack : 1;      /// Can do command ground attack.
        unsigned ShoreBuilding : 1;     /// Building must be build on coast.
Index: stratagus/src/unit/script_unittype.c
diff -u stratagus/src/unit/script_unittype.c:1.130 
stratagus/src/unit/script_unittype.c:1.131
--- stratagus/src/unit/script_unittype.c:1.130  Thu Jan 15 13:11:09 2004
+++ stratagus/src/unit/script_unittype.c        Sat Jan 17 01:40:15 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: script_unittype.c,v 1.130 2004/01/15 02:11:09 jsalmon3 Exp $
+//      $Id: script_unittype.c,v 1.131 2004/01/16 14:40:15 wizzard Exp $
 
 //@{
 
@@ -523,6 +523,8 @@
                        type->DetectCloak = LuaToBoolean(l, -1);
                } else if (!strcmp(value, "Transporter")) {
                        type->Transporter = LuaToBoolean(l, -1);
+               } else if (!strcmp(value, "AttackFromTransporter")) {
+                       type->AttackFromTransporter = LuaToBoolean(l, -1);
                } else if (!strcmp(value, "Coward")) {
                        type->Coward = LuaToBoolean(l, -1);
                } else if (!strcmp(value, "CanGatherResources")) {
Index: stratagus/src/unit/unit_find.c
diff -u stratagus/src/unit/unit_find.c:1.68 stratagus/src/unit/unit_find.c:1.69
--- stratagus/src/unit/unit_find.c:1.68 Thu Jan 15 09:31:11 2004
+++ stratagus/src/unit/unit_find.c      Sat Jan 17 01:40:15 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unit_find.c,v 1.68 2004/01/14 22:31:11 nobody_ Exp $
+//     $Id: unit_find.c,v 1.69 2004/01/16 14:40:15 wizzard Exp $
 
 //@{
 
@@ -506,10 +506,21 @@
 
        DebugCheck(2 * missile_range + 1 >= 32);
 
-       x = u->X;
-       y = u->Y;
-       n = SelectUnits(x - missile_range, y - missile_range,
-               x + missile_range + 1, y + missile_range + 1, table);
+       //
+       // If unit is removed, use containers x and y
+       if (u->Removed) {
+               x = u->Container->X;
+               y = u->Container->Y;
+               n = SelectUnits(x - missile_range, y - missile_range,
+                       x + missile_range + u->Container->Type->TileWidth, 
+                       y + missile_range + u->Container->Type->TileHeight, 
table);
+       } else {
+               x = u->X;
+               y = u->Y;
+               n = SelectUnits(x - missile_range, y - missile_range,
+                       x + missile_range + u->Type->TileWidth, 
+                       y + missile_range + u->Type->TileHeight, table);
+       }
 
        if (!n) {
                return NoUnitP;
@@ -607,7 +618,15 @@
                        if (cost < 1) {
                                cost = 1;
                        }
-                               d = MapDistanceBetweenUnits(u, dest);
+
+                       //
+                       // Removed Unit's are in bunkers
+                       //
+                       if (u->Removed) {
+                               d = MapDistanceBetweenUnits(u->Container, dest);
+                       } else {
+                               d = MapDistanceBetweenUnits(u, dest);
+                       }
 
                        if (d <= attackrange || (d <= range && UnitReachable(u, 
dest, attackrange))) {
                                ++enemy_count;




reply via email to

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