fireAtDead.patch (3,135 bytes)
2007-08-02 08:25
Index: rts/Lua/LuaConstGame.cpp
===================================================================
--- rts/Lua/LuaConstGame.cpp (revision 4121)
+++ rts/Lua/LuaConstGame.cpp (working copy)
@@ -68,6 +68,8 @@
LuaPushNamedNumber(L, "transportShip", modInfo->transportShip);
LuaPushNamedNumber(L, "transportHover", modInfo->transportHover);
LuaPushNamedNumber(L, "transportGround", modInfo->transportGround);
+ LuaPushNamedNumber(L, "fireAtKilled", modInfo->fireAtKilled);
+ LuaPushNamedNumber(L, "fireAtCrashing", modInfo->fireAtCrashing);
char buf[64];
SNPRINTF(buf, sizeof(buf), "0x%08X",
Index: rts/Sim/ModInfo.cpp
===================================================================
--- rts/Sim/ModInfo.cpp (revision 4121)
+++ rts/Sim/ModInfo.cpp (working copy)
@@ -43,6 +43,21 @@
// We already set the defaults so we should be able to ignore this
// Other optional mod rules MUST set their defaults...
}
+ //Get the fire-at-dead-units options
+ fireAtKilled = 0;
+ fireAtCrashing = 0;
+ //See if the mod overrides them
+ try
+ {
+ TdfParser fireAtDeadOptions("gamedata/modrules.tdf");
+ fireAtKilled = atoi(fireAtDeadOptions.SGetValueDef("0", "FIREATDEAD\\FireAtKilled").c_str());
+ fireAtCrashing = atoi(fireAtDeadOptions.SGetValueDef("0", "FIREATDEAD\\FireAtCrashing").c_str());
+ }
+ catch(content_error) // If the modrules.tdf isnt found
+ {
+ // We already set the defaults so we should be able to ignore this
+ // Other optional mod rules MUST set their defaults...
+ }
//Get the transportability options for the mod
transportGround = 1;
transportHover = 0;
Index: rts/Sim/ModInfo.h
===================================================================
--- rts/Sim/ModInfo.h (revision 4121)
+++ rts/Sim/ModInfo.h (working copy)
@@ -22,6 +22,10 @@
int transportShip; //0 = all naval units cannot be transported, 1 = all naval units can be transported (mass and size restrictions still apply). Defaults to 0.
int transportAir; //0 = all air units cannot be transported, 1 = all air units can be transported (mass and size restrictions still apply). Defaults to 0.
+ //Fire on dying units behaviour
+ int fireAtKilled; //1 = units fire at enemies running Killed() script, 0 = units ignore such enemies
+ int fireAtCrashing; //1 = units fire at crashing aircrafts, 0 = units ignore crashing aircrafts
+
};
extern CModInfo *modInfo;
Index: rts/Sim/Weapons/Weapon.cpp
===================================================================
--- rts/Sim/Weapons/Weapon.cpp (revision 4121)
+++ rts/Sim/Weapons/Weapon.cpp (working copy)
@@ -23,6 +23,7 @@
#include "Sim/Misc/LosHandler.h"
#include "Sim/Misc/GeometricObjects.h"
#include "Sim/MoveTypes/TAAirMoveType.h"
+#include "Sim/ModInfo.h"
#include "creg/STL_List.h"
#include "mmgr.h"
#include "float3.h"
@@ -544,7 +545,7 @@
if(unit && !(onlyTargetCategory&unit->category))
return false;
- if(unit && (unit->isDead || unit->crashing))
+ if(unit && ((unit->isDead && (modInfo->fireAtKilled==0)) || (unit->crashing && (modInfo->fireAtCrashing==0))))
return false;
if(weaponDef->stockpile && !numStockpiled)