add_decloakOnFire_fbi_tag.diff (13,476 bytes)
2007-04-13 00:29
Index: rts/Lua/LuaSyncedRead.cpp
===================================================================
--- rts/Lua/LuaSyncedRead.cpp (revision 3610)
+++ rts/Lua/LuaSyncedRead.cpp (working copy)
@@ -86,7 +86,7 @@
LuaPushNamedNumber(L, "MY_UNITS", MyUnits);
LuaPushNamedNumber(L, "ALLY_UNITS", AllyUnits);
LuaPushNamedNumber(L, "ENEMY_UNITS", EnemyUnits);
-
+
#define REGISTER_LUA_CFUNC(x) \
lua_pushstring(L, #x); \
lua_pushcfunction(L, x); \
@@ -107,8 +107,8 @@
REGISTER_LUA_CFUNC(GetGameFrame);
REGISTER_LUA_CFUNC(GetGameSeconds);
- REGISTER_LUA_CFUNC(GetGameRulesParam);
- REGISTER_LUA_CFUNC(GetGameRulesParams);
+ REGISTER_LUA_CFUNC(GetGameRulesParam);
+ REGISTER_LUA_CFUNC(GetGameRulesParams);
REGISTER_LUA_CFUNC(GetWind);
@@ -127,8 +127,8 @@
REGISTER_LUA_CFUNC(GetTeamInfo);
REGISTER_LUA_CFUNC(GetTeamResources);
REGISTER_LUA_CFUNC(GetTeamUnitStats);
- REGISTER_LUA_CFUNC(GetTeamRulesParam);
- REGISTER_LUA_CFUNC(GetTeamRulesParams);
+ REGISTER_LUA_CFUNC(GetTeamRulesParam);
+ REGISTER_LUA_CFUNC(GetTeamRulesParams);
REGISTER_LUA_CFUNC(AreTeamsAllied);
REGISTER_LUA_CFUNC(ArePlayersAllied);
@@ -180,8 +180,8 @@
REGISTER_LUA_CFUNC(GetRealBuildQueue);
REGISTER_LUA_CFUNC(GetUnitCmdDescs);
- REGISTER_LUA_CFUNC(GetUnitRulesParam);
- REGISTER_LUA_CFUNC(GetUnitRulesParams);
+ REGISTER_LUA_CFUNC(GetUnitRulesParam);
+ REGISTER_LUA_CFUNC(GetUnitRulesParams);
REGISTER_LUA_CFUNC(GetFeatureList);
REGISTER_LUA_CFUNC(GetFeatureDefID);
@@ -509,7 +509,7 @@
{
CheckNoArgs(L, __FUNCTION__);
lua_pushboolean(L, gs->cheatEnabled);
- return 1;
+ return 1;
}
@@ -517,7 +517,7 @@
{
CheckNoArgs(L, __FUNCTION__);
lua_pushboolean(L, gs->editDefsEnabled);
- return 1;
+ return 1;
}
@@ -528,7 +528,7 @@
return 0;
}
lua_pushboolean(L, !gs->noHelperAIs);
- return 1;
+ return 1;
}
@@ -536,7 +536,7 @@
{
CheckNoArgs(L, __FUNCTION__);
lua_pushboolean(L, game->gameOver);
- return 1;
+ return 1;
}
@@ -659,8 +659,8 @@
lua_pushnumber(L, heading);
return 1;
}
-
-
+
+
int LuaSyncedRead::GetVectorFromHeading(lua_State* L)
{
const int args = lua_gettop(L); // number of arguments
@@ -1138,7 +1138,7 @@
map<int, vector<CUnit*> > unitDefMap;
const set<CUnit*>& units = team->units;
set<CUnit*>::const_iterator uit;
-
+
// tally for allies
if (IsAlliedTeam(teamID)) {
for (uit = units.begin(); uit != units.end(); ++uit) {
@@ -1235,7 +1235,7 @@
if (!IsUnitTyped(unit)) {
unknownCount++;
} else {
- const UnitDef* ud = EffectiveUnitDef(unit);
+ const UnitDef* ud = EffectiveUnitDef(unit);
map<const UnitDef*, int>::iterator mit = unitDefCounts.find(ud);
if (mit == unitDefCounts.end()) {
unitDefCounts[ud] = 1;
@@ -1518,7 +1518,7 @@
const int allegiance = ParseAllegiance(L, __FUNCTION__, 5);
#define RECTANGLE_TEST ; // no test, GetUnitsExact is sufficient
-
+
vector<CUnit*>::const_iterator it;
vector<CUnit*> units = qf->GetUnitsExact(mins, maxs);
@@ -1545,7 +1545,7 @@
else { // AllUnits
LOOP_UNIT_CONTAINER(VISIBLE_TEST, RECTANGLE_TEST);
}
-
+
hs_n.PushNumber(L, count);
return 1;
@@ -1578,7 +1578,7 @@
if ((y < ymin) || (y > ymax)) { \
continue; \
}
-
+
vector<CUnit*>::const_iterator it;
vector<CUnit*> units = qf->GetUnitsExact(mins, maxs);
@@ -1637,7 +1637,7 @@
if (dist > radSqr) { \
continue; \
} \
-
+
vector<CUnit*>::const_iterator it;
vector<CUnit*> units = qf->GetUnitsExact(mins, maxs);
@@ -1664,9 +1664,9 @@
else { // AllUnits
LOOP_UNIT_CONTAINER(VISIBLE_TEST, CYLINDER_TEST);
}
-
+
hs_n.PushNumber(L, count);
-
+
return 1;
}
@@ -1701,7 +1701,7 @@
if (dist > radSqr) { \
continue; \
} \
-
+
vector<CUnit*>::const_iterator it;
vector<CUnit*> units = qf->GetUnitsExact(mins, maxs);
@@ -1728,9 +1728,9 @@
else { // AllUnits
LOOP_UNIT_CONTAINER(VISIBLE_TEST, SPHERE_TEST);
}
-
+
hs_n.PushNumber(L, count);
-
+
return 1;
}
@@ -1774,7 +1774,7 @@
}
}
}
-
+
int startTeam, endTeam;
const int allegiance = ParseAllegiance(L, __FUNCTION__, 2);
@@ -1801,7 +1801,7 @@
int count = 0;
const int readTeam = CLuaHandle::GetActiveHandle()->GetReadTeam();
-
+
for (int team = startTeam; team <= endTeam; team++) {
const set<CUnit*>& units = gs->Team(team)->units;
set<CUnit*>::const_iterator it;
@@ -1865,7 +1865,7 @@
vector<CFeature*> rectFeatures = qf->GetFeaturesExact(mins, maxs);
const int rectFeatureCount = (int)rectFeatures.size();
-
+
lua_newtable(L);
int count = 0;
if (readAllyTeam < 0) {
@@ -1932,7 +1932,7 @@
}
}
}
-
+
return 1;
}
@@ -2510,7 +2510,7 @@
}
const bool noCmds = (args < 3) ? true : !lua_toboolean(L, 3);
-
+
PackFactoryCounts(L, commandQue, count, noCmds);
return 1;
@@ -2830,7 +2830,7 @@
return 3;
}
-
+
int LuaSyncedRead::GetFeaturePosition(lua_State* L)
{
CFeature* feature = ParseFeature(L, __FUNCTION__, 1);
@@ -2932,7 +2932,7 @@
const int iz = (int)(max(0.0f, min(float3::maxzpos, z)) / 16.0f);
const float metal = readmap->metalMap->getMetalAmount(ix, iz);
-
+
const int maxIndex = (gs->hmapx * gs->hmapy) - 1;
const int index = min(maxIndex, (gs->hmapx * iz) + ix);
const int typeIndex = readmap->typemap[index];
@@ -2983,7 +2983,7 @@
tz1 = (int)max(0 , min(gs->mapy - 1, (int)(fz1 / SQUARE_SIZE)));
tz2 = (int)max(0 , min(gs->mapy - 1, (int)(fz2 / SQUARE_SIZE)));
- return;
+ return;
}
@@ -2995,7 +2995,7 @@
int tx1, tx2, tz1, tz2;
ParseMapCoords(L, __FUNCTION__, tx1, tz1, tx2, tz2);
-
+
for(int z = tz1; z <= tz2; z++){
for(int x = tx1; x <= tx2; x++){
const CSolidObject* s = readmap->GroundBlocked((z * gs->mapx) + x);
@@ -3055,7 +3055,7 @@
if (dir == "n") { return 2; }
if (dir == "w") { return 3; }
luaL_error(L, "%s(): bad facing string", caller);
- }
+ }
luaL_error(L, "%s(): bad facing parameter", caller);
return 0;
}
Index: rts/Lua/LuaUnitDefs.cpp
===================================================================
--- rts/Lua/LuaUnitDefs.cpp (revision 3610)
+++ rts/Lua/LuaUnitDefs.cpp (working copy)
@@ -103,7 +103,7 @@
HSTR_PUSH(L, "__index");
lua_pushlightuserdata(L, (void*)ud);
lua_pushcclosure(L, UnitDefIndex, 1);
- lua_rawset(L, -3); // closure
+ lua_rawset(L, -3); // closure
HSTR_PUSH(L, "__newindex");
lua_pushlightuserdata(L, (void*)ud);
@@ -147,7 +147,7 @@
static int UnitDefIndex(lua_State* L)
{
- // not a default value
+ // not a default value
if (!lua_isstring(L, 2)) {
lua_rawget(L, 1);
return 1;
@@ -156,7 +156,7 @@
const char* name = lua_tostring(L, 2);
ParamMap::const_iterator it = paramMap.find(name);
- // not a default value
+ // not a default value
if (paramMap.find(name) == paramMap.end()) {
lua_rawget(L, 1);
return 1;
@@ -208,7 +208,7 @@
const char* name = lua_tostring(L, 2);
ParamMap::const_iterator it = paramMap.find(name);
-
+
// not a default value, set it
if (paramMap.find(name) == paramMap.end()) {
lua_rawset(L, 1);
@@ -254,7 +254,7 @@
luaL_error(L, "ERROR_TYPE in UnitDefs __newindex");
}
}
-
+
return 0;
}
@@ -303,7 +303,7 @@
}
// start the user parameters,
// remove the internal key and push a nil
- lua_settop(L, 1);
+ lua_settop(L, 1);
lua_pushnil(L);
}
}
@@ -458,10 +458,10 @@
lua_newtable(L);
HSTR_PUSH_STRING(L, "name", sound.name);
if (CLuaHandle::GetActiveHandle()->GetUserMode()) {
- HSTR_PUSH_NUMBER(L, "id", sound.id);
+ HSTR_PUSH_NUMBER(L, "id", sound.id);
}
HSTR_PUSH_NUMBER(L, "volume", sound.volume);
- lua_rawset(L, -3);
+ lua_rawset(L, -3);
}
@@ -511,7 +511,7 @@
}
HSTR_PUSH_NUMBER(L, "id", md->pathType);
-
+
const int Ship_Move = MoveData::Ship_Move;
const int Hover_Move = MoveData::Hover_Move;
const int Ground_Move = MoveData::Ground_Move;
@@ -520,7 +520,7 @@
case Ship_Move: { HSTR_PUSH_STRING(L, "type", "ship"); break; }
case Hover_Move: { HSTR_PUSH_STRING(L, "type", "hover"); break; }
case Ground_Move: { HSTR_PUSH_STRING(L, "type", "ground"); break; }
- default: { HSTR_PUSH_STRING(L, "type", "error"); break; }
+ default: { HSTR_PUSH_STRING(L, "type", "error"); break; }
}
switch (md->moveFamily) {
@@ -563,7 +563,7 @@
lua_pushboolean(L, type == #name); \
return 1; \
}
-
+
TYPE_STRING_FUNC(Bomber);
TYPE_STRING_FUNC(Builder);
TYPE_STRING_FUNC(Building);
@@ -580,13 +580,13 @@
static bool InitParamMap()
{
- paramMap["next"] = DataElement(READONLY_TYPE);
- paramMap["pairs"] = DataElement(READONLY_TYPE);
+ paramMap["next"] = DataElement(READONLY_TYPE);
+ paramMap["pairs"] = DataElement(READONLY_TYPE);
// dummy UnitDef for address lookups
const UnitDef ud;
const char* start = ADDRESS(ud);
-
+
// ADD_BOOL(valid, ud.valid);
// ADD_INT("weaponCount", weaponCount); // CUSTOM
@@ -595,12 +595,12 @@
ADD_BOOL("hasShield", hasShield); // CUSTOM
ADD_BOOL("canParalyze", canParalyze); // CUSTOM
ADD_BOOL("canStockpile", canStockpile); // CUSTOM
-ADD_BOOL("canAttackWater", canAttackWater); // CUSTOM
+ADD_BOOL("canAttackWater", canAttackWater); // CUSTOM
*/
// ADD_INT("buildOptionsCount", ud.buildOptions.size(")); // CUSTOM
-
+
ADD_FUNCTION("totalEnergyOut", ud, TotalEnergyOut);
-
+
ADD_FUNCTION("modCategories", ud.categoryString, CategorySetFromString);
ADD_FUNCTION("springCategories", ud.category, CategorySetFromBits);
ADD_FUNCTION("noChaseCategories", ud.noChaseCategory, CategorySetFromBits);
@@ -784,7 +784,7 @@
// MoveData* movedata;
// unsigned char* yardmapLevels[6];
// unsigned char* yardmaps[4]; //Iterations of the Ymap for building rotation
-
+
ADD_INT("xsize", ud.xsize);
ADD_INT("ysize", ud.ysize);
@@ -799,11 +799,12 @@
ADD_BOOL("isFirePlatform", ud.isfireplatform);
ADD_BOOL("holdSteady", ud.holdSteady);
ADD_BOOL("releaseHeld", ud.releaseHeld);
-
+
ADD_BOOL("startCloaked", ud.startCloaked);
ADD_FLOAT("cloakCost", ud.cloakCost);
ADD_FLOAT("cloakCostMoving", ud.cloakCostMoving);
- ADD_FLOAT("decloakDistance", ud.decloakDistance);
+ ADD_FLOAT("decloakDistance", ud.decloakDistance);
+ ADD_BOOL("decloakOnFire", ud.decloakOnFire);
ADD_BOOL("canKamikaze", ud.canKamikaze);
ADD_FLOAT("kamikazeDist", ud.kamikazeDist);
Index: rts/Sim/Units/Unit.cpp
===================================================================
--- rts/Sim/Units/Unit.cpp (revision 3610)
+++ rts/Sim/Units/Unit.cpp (working copy)
@@ -1401,8 +1401,10 @@
ChangeLos(realLosRadius,realAirLosRadius);
- if(unitDef->startCloaked)
+ if(unitDef->startCloaked) {
wantCloak=true;
+ isCloaked=true;
+ }
if(unitDef->windGenerator>0)
{
Index: rts/Sim/Units/UnitDef.h
===================================================================
--- rts/Sim/Units/UnitDef.h (revision 3610)
+++ rts/Sim/Units/UnitDef.h (working copy)
@@ -43,7 +43,7 @@
int imageSizeX;
int imageSizeY;
std::string buildpicname;
-
+
UnitDef* decoyDef;
int aihint;
@@ -94,7 +94,7 @@
float buildSpeed;
float buildDistance;
float mass;
-
+
float minCollisionSpeed;
float slideTolerance;
float maxSlope;
@@ -201,7 +201,7 @@
MoveData* movedata;
// unsigned char* yardmapLevels[6];
unsigned char* yardmaps[4]; //Iterations of the Ymap for building rotation
-
+
int xsize; //each size is 8 units
int ysize; //each size is 8 units
@@ -220,6 +220,7 @@
float cloakCost; //energy cost per second to stay cloaked when stationary
float cloakCostMoving; //energy cost per second when moving
float decloakDistance; //if enemy unit come within this range decloaking is forced
+ bool decloakOnFire; //should the unit decloak upon firing
bool canKamikaze; //self destruct if enemy come to close
float kamikazeDist;
Index: rts/Sim/Units/UnitDefHandler.cpp
===================================================================
--- rts/Sim/Units/UnitDefHandler.cpp (revision 3610)
+++ rts/Sim/Units/UnitDefHandler.cpp (working copy)
@@ -365,6 +365,7 @@
ud.canCloak=false;
ud.startCloaked=!!atoi(tdfparser.SGetValueDef("0", "UNITINFO\\init_cloaked").c_str());
ud.decloakDistance=atof(tdfparser.SGetValueDef("-1", "UNITINFO\\mincloakdistance").c_str());
+ ud.decloakOnFire=!!atoi(tdfparser.SGetValueDef("1", "UNITINFO\\decloakOnFire").c_str());
ud.highTrajectoryType=atoi(tdfparser.SGetValueDef("0", "UNITINFO\\HighTrajectory").c_str());
Index: rts/Sim/Weapons/Weapon.cpp
===================================================================
--- rts/Sim/Weapons/Weapon.cpp (revision 3610)
+++ rts/Sim/Weapons/Weapon.cpp (working copy)
@@ -314,8 +314,10 @@
// logOutput.Print("RelPosFire %f %f %f",relWeaponPos.x,relWeaponPos.y,relWeaponPos.z);
- owner->isCloaked=false;
- owner->curCloakTimeout=gs->frameNum+owner->cloakTimeout;
+ if (owner->unitDef->decloakOnFire) {
+ owner->isCloaked=false;
+ owner->curCloakTimeout=gs->frameNum+owner->cloakTimeout;
+ }
Fire();