Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

feat(w3ddevice): pink death lasers for the supw particle uplink

Olcay Seygan1641ecb7eb8d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2b05af52d..a9e6e5daf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -512,7 +512,7 @@ A third pass went through the generals' powers, promotions and unit abilities.
- Tooltips that named the wrong countdown: the Air Force Spectre Gunship (3:00, said 4:00), the Air Force Carpet Bomb (4:00, said China's 2:30), the Leaflet Drop (5:00, said 6:00), the Stealth GPS Scrambler (3:00, said 4:00). The Spectre's third promotion keeps the gunship up 20 seconds, and now says so.
- Air Force, Laser and Superweapon: the Pathfinder and Stealth Fighter promotions stop asking for a plain American Barracks or Airfield these generals never build.
- Voices and sounds that were recorded and never played: EVA's lines for the MOAB, the Sentry Drone Gun and Neutron Shells, the Super Hacker's own building-hack line, the Hacker's line when you arm the hack, the Artillery Barrage's own explosion (it borrowed the carpet bomb's, two at a time), and Jarmen Kell's charge-planting sound, where he said his attack line twice.
-- The Superweapon general's Particle Cannon glows and dies in the pink of its beam, not in the plain cannon's blue. The laser beams it throws when destroyed are still blue; there is no pink model for them.
+- The Superweapon general's Particle Cannon glows and dies in the pink of its beam, not in the plain cannon's blue. The laser beams it throws when destroyed go up pink as well. EA never made a pink model for them, so the same beams are drawn with a pink strip in place of the blue one, and the other generals' uplinks still die in blue.
- The Particle Uplink's dish holds still while the building goes up instead of cycling its deploy animation.
- A Sneak Attack tunnel coming out of the ground shows its own portrait, and the Demolitions Bomb Truck stops showing the Demolitions upgrade icon.
diff --git a/GeneralsMD/Code/CMakeLists.txt b/GeneralsMD/Code/CMakeLists.txt
index 7ae597095..8b015f0ef 100644
--- a/GeneralsMD/Code/CMakeLists.txt
+++ b/GeneralsMD/Code/CMakeLists.txt
@@ -665,7 +665,8 @@ add_custom_command(TARGET generals POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/Data/Install_Final.bmp
${CMAKE_CURRENT_SOURCE_DIR}/../Run/
- # The three command bar plates per side and the smoke signals' ground marks. A loose
+ # The three command bar plates per side, the smoke signals' ground marks and the
+ # SupW uplink's pink laser strip (Tools/pink_laser.py). A loose
# texture beats every .big, so these land in Run/Art/Textures where the W3D file
# system looks first.
COMMAND ${CMAKE_COMMAND} -E copy_directory
diff --git a/GeneralsMD/Code/Data/Art/Textures/ReforgedLaserPink.tga b/GeneralsMD/Code/Data/Art/Textures/ReforgedLaserPink.tga
new file mode 100644
index 000000000..ef28f4253
Binary files /dev/null and b/GeneralsMD/Code/Data/Art/Textures/ReforgedLaserPink.tga differ
diff --git a/GeneralsMD/Code/Data/INI/FixesReforged.ini b/GeneralsMD/Code/Data/INI/FixesReforged.ini
index abc39bf52..fc045f1a6 100644
--- a/GeneralsMD/Code/Data/INI/FixesReforged.ini
+++ b/GeneralsMD/Code/Data/INI/FixesReforged.ini
@@ -2214,13 +2214,28 @@ Object SupW_AmericaParticleCannonUplink
ExemptStatus = UNDER_CONSTRUCTION
DestructionDelay = 2000
FX = INITIAL SupW_FX_ParticleUplinkDeathInitial
- OCL = INITIAL OCL_SDILinkLasers
+ OCL = INITIAL SupW_OCL_SDILinkLasers
FX = FINAL FX_StructureMediumDeath
OCL = FINAL SupW_OCL_ParticleUplinkDeathFinal
End
End
End
+; The lasers the dying SupW uplink throws, pink like its beam. EA's model names one texture,
+; EXLaser2.tga, and ReforgedLaserPink.tga is the same gradient with the blue turned magenta.
+; A reskin keeps the lifetime, body and death of SDILasers and swaps only the draw module.
+ObjectReskin SupW_SDILasers SDILasers
+ Draw = W3DModelDraw ModuleTag_01_Pink
+ OkToChangeModelColor = Yes
+ ReplaceTexture = EXLaser2.tga ReforgedLaserPink.tga
+ ConditionState = NONE
+ Model = ABSDILink_L
+ Animation = ABSDILink_L.ABSDILink_L
+ AnimationMode = ONCE
+ End
+ End
+End
+
; ==== Alpha Aurora bomb ===========================================================================
; The fuel-air bomb died 15 above the ground or above any roof it passed, and a 12 radius let it
diff --git a/GeneralsMD/Code/Data/INI/ObjectCreationListReforged.ini b/GeneralsMD/Code/Data/INI/ObjectCreationListReforged.ini
index fb0881468..5ec639aec 100644
--- a/GeneralsMD/Code/Data/INI/ObjectCreationListReforged.ini
+++ b/GeneralsMD/Code/Data/INI/ObjectCreationListReforged.ini
@@ -472,6 +472,22 @@ ObjectCreationList SupW_SUPERWEAPON_Paradrop3
End
End
+; ==== Particle Uplink death lasers ================================================================
+
+; The Superweapon General's cannon fires a pink beam, and its dying uplink still threw the blue
+; lasers of the plain one. SupW_SDILasers is the same model drawn with a pink texture.
+
+ObjectCreationList SupW_OCL_SDILinkLasers
+ CreateObject
+ ObjectNames = SupW_SDILasers
+ Disposition = LIKE_EXISTING
+ Count = 1
+ MinLifetime = 3000
+ MaxLifetime = 3000
+ Offset = X:30 Y:0 Z:0
+ End
+End
+
; ==== Particle Uplink rubble ======================================================================
; A destroyed Particle Cannon Uplink lets six plain USA Rangers out of the rubble, where every
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingFactory.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingFactory.cpp
index bb867e4b8..6bde17995 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingFactory.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingFactory.cpp
@@ -388,10 +388,11 @@ AsciiString TheThingTemplateBeingParsedName;
// find existing item if present
ThingTemplate *thingTemplate = TheThingFactory->findTemplateInternal( name, FALSE );
- if( !thingTemplate && ini->getLoadType() == INI_LOAD_MULTIFILE )
+ if( !thingTemplate && ini->getLoadType() == INI_LOAD_MULTIFILE && reskinFrom.isEmpty() )
{
// a patch names an object EA's files built; a name that finds nothing is a typo, and a new
- // template made from it would change no unit and still land in the INI CRC
+ // template made from it would change no unit and still land in the INI CRC. An ObjectReskin
+ // is the exception: it is new by design and names its original, which has to exist.
DEBUG_CRASH(( "[LINE: %d in '%s'] %s patches an object that does not exist", ini->getLineNum(), ini->getFilename().str(), name.str() ));
throw INI_INVALID_DATA;
}
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DModelDraw.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DModelDraw.h
index f559817ee..681350921 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DModelDraw.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DModelDraw.h
@@ -289,6 +289,8 @@ public:
std::vector<AsciiString> m_extraPublicBones;
AsciiString m_trackFile; ///< if present, leaves tracks using this texture
AsciiString m_attachToDrawableBone;
+ AsciiString m_replaceTextureOld; ///< with m_replaceTextureNew, one texture this module draws in place of another on every model
+ AsciiString m_replaceTextureNew;
#ifdef CACHE_ATTACH_BONE
mutable Vector3 m_attachToDrawableBoneOffset;
#endif
@@ -329,6 +331,7 @@ public:
private:
static void parseConditionState( INI* ini, void *instance, void * /*store*/, const void* /*userData*/ );
+ static void parseReplaceTexture( INI* ini, void *instance, void * /*store*/, const void* /*userData*/ );
public:
virtual void crc( Xfer *xfer );
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp
index 928fd813e..4138e24e4 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp
@@ -1201,7 +1201,16 @@ static void parseAsciiStringLC( INI* ini, void * /*instance*/, void *store, cons
}
//-------------------------------------------------------------------------------------------------
-void W3DModelDrawModuleData::buildFieldParse(MultiIniFieldParse& p)
+/** ReplaceTexture = <old> <new>: draw every model of this module with <new> wherever it names <old>. */
+void W3DModelDrawModuleData::parseReplaceTexture( INI* ini, void *instance, void * /*store*/, const void* /*userData*/ )
+{
+ W3DModelDrawModuleData* self = (W3DModelDrawModuleData*)instance;
+ self->m_replaceTextureOld = ini->getNextAsciiString();
+ self->m_replaceTextureNew = ini->getNextAsciiString();
+}
+
+//-------------------------------------------------------------------------------------------------
+void W3DModelDrawModuleData::buildFieldParse(MultiIniFieldParse& p)
{
ModuleData::buildFieldParse(p);
@@ -1225,6 +1234,7 @@ void W3DModelDrawModuleData::buildFieldParse(MultiIniFieldParse& p)
{ "AttachToBoneInAnotherModule", parseAsciiStringLC, NULL, offsetof(W3DModelDrawModuleData, m_attachToDrawableBone) },
{ "IgnoreConditionStates", ModelConditionFlags::parseFromINI, NULL, offsetof(W3DModelDrawModuleData, m_ignoreConditionStates) },
{ "ReceivesDynamicLights", INI::parseBool, NULL, offsetof(W3DModelDrawModuleData, m_receivesDynamicLights) },
+ { "ReplaceTexture", W3DModelDrawModuleData::parseReplaceTexture, NULL, 0 },
{ 0, 0, 0, 0 }
};
p.add(dataFieldParse);
@@ -3302,7 +3312,10 @@ void W3DModelDraw::setModelState(const ModelConditionInfo* newState)
}
else
{
- m_renderObject = W3DDisplay::m_assetManager->Create_Render_Obj(newState->m_modelName.str(), draw->getScale(), m_hexColor);
+ const W3DModelDrawModuleData* data = getW3DModelDrawModuleData();
+ Bool swapsTexture = !data->m_replaceTextureOld.isEmpty();
+ m_renderObject = W3DDisplay::m_assetManager->Create_Render_Obj(newState->m_modelName.str(), draw->getScale(), m_hexColor,
+ swapsTexture ? data->m_replaceTextureOld.str() : NULL, swapsTexture ? data->m_replaceTextureNew.str() : NULL);
DEBUG_ASSERTCRASH(m_renderObject, ("*** ASSET ERROR: Model %s not found!\n",newState->m_modelName.str()));
}
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DAssetManager.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DAssetManager.cpp
index 43f032adc..6bd6e65da 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DAssetManager.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DAssetManager.cpp
@@ -285,7 +285,7 @@ RenderObjClass * W3DAssetManager::Create_Render_Obj(const char* name)
// write straight into it, so the number lives in one place rather than six.
enum { MUNGED_NAME_SIZE = 512 };
-static inline void Munge_Render_Obj_Name(char *newname, const char *oldname, float scale, const int color, const char *textureName)
+static inline void Munge_Render_Obj_Name(char *newname, const char *oldname, float scale, const int color, const char *oldTextureName, const char *textureName)
{
char lower_case_name[255];
strlcpy(lower_case_name, oldname, ARRAY_SIZE(lower_case_name));
@@ -293,8 +293,10 @@ static inline void Munge_Render_Obj_Name(char *newname, const char *oldname, flo
if (!textureName)
textureName = "";
+ if (!oldTextureName)
+ oldTextureName = "";
- snprintf(newname, MUNGED_NAME_SIZE, "#%d!%g!%s#%s",color,scale,textureName,lower_case_name);
+ snprintf(newname, MUNGED_NAME_SIZE, "#%d!%g!%s>%s#%s",color,scale,oldTextureName,textureName,lower_case_name);
}
//---------------------------------------------------------------------
@@ -337,33 +339,35 @@ Int W3DAssetManager::replaceHLODTexture(RenderObjClass *robj, TextureClass *oldT
//---------------------------------------------------------------------
Int W3DAssetManager::replaceMeshTexture(RenderObjClass *robj, TextureClass *oldTex, TextureClass *newTex)
{
- int i;
- int didReplace=0;
-
- MeshClass *mesh=(MeshClass*) robj;
- MeshModelClass * model = mesh->Get_Model();
+ MeshClass *mesh=(MeshClass*) robj;
MaterialInfoClass *material = mesh->Get_Material_Info();
-
- for (i=0; i<material->Texture_Count(); i++)
+ Bool usesOld = FALSE;
+ for (int i=0; i<material->Texture_Count(); i++)
+ usesOld |= (material->Peek_Texture(i) == oldTex);
+ REF_PTR_RELEASE(material);
+ if (!usesOld)
+ return 0;
+
+ // The model is shared with every other copy of this asset; swap on a copy of our own.
+ mesh->Make_Unique();
+ MeshModelClass * model = mesh->Get_Model();
+ material = mesh->Get_Material_Info();
+ for (int i=0; i<material->Texture_Count(); i++)
{
if (material->Peek_Texture(i) == oldTex)
- {
- model->Replace_Texture(oldTex,newTex);
material->Replace_Texture(i,newTex);
- didReplace=1;
- }
}
+ model->Replace_Texture(oldTex,newTex);
- REF_PTR_RELEASE(material);
+ REF_PTR_RELEASE(material);
REF_PTR_RELEASE(model);
- return didReplace;
+ return 1;
}
//---------------------------------------------------------------------
-/** Replaces all references to old texture with new texture. Operation is performed on
- asset prototype so it will affect most instances of this object. Objects which have
- been customized with house color will not be affected unless they are created after
- this function is called.
+/** Replaces all references to old texture with new texture on robj alone. Each mesh that
+ names the old texture gets a model of its own first, so the prototype and every other
+ instance keep drawing the old one.
*/
int W3DAssetManager::replacePrototypeTexture(RenderObjClass *robj, const char * oldname, const char * newname)
{
@@ -762,7 +766,7 @@ RenderObjClass * W3DAssetManager::Create_Render_Obj(
}
char newname[MUNGED_NAME_SIZE];
- Munge_Render_Obj_Name(newname, name, scale, color, newTexture);
+ Munge_Render_Obj_Name(newname, name, scale, color, oldTexture, newTexture);
// see if we got a cached version
RenderObjClass *rendobj = NULL;
diff --git a/GeneralsMD/Code/Tools/pink_laser.py b/GeneralsMD/Code/Tools/pink_laser.py
new file mode 100644
index 000000000..a08fdab88
--- /dev/null
+++ b/GeneralsMD/Code/Tools/pink_laser.py
@@ -0,0 +1,48 @@
+"""The pink the Superweapon General's dying Particle Uplink throws its lasers in. EA's lasers are one
+model, ABSDILink_L, textured with a 16 pixel strip that runs dark, blue, white at the middle, blue,
+dark across the beam; the SupW_SDILasers reskin draws that model with this strip in its place. Red
+follows the blue, so the glow turns magenta like the SupW cannon's beam and the core stays white.
+
+ python Tools/pink_laser.py # writes Data/Art/Textures/ReforgedLaserPink.tga"""
+import os
+import sys
+
+from PIL import Image
+
+SIZE = 16
+MIDDLE = SIZE // 2
+GLOW_WIDTH = 4.63 # columns from the edge before the magenta is at full strength
+CORE_FALLOFF = 1.6 # how fast the white core gives way to the glow
+FULL = 255
+OUT_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "Data", "Art", "Textures", "ReforgedLaserPink.tga")
+
+
+def column_colour(column):
+ distance = abs(column - MIDDLE)
+ glow = round(FULL * min(1.0, (MIDDLE - distance) / GLOW_WIDTH))
+ core = round(FULL * (1.0 - distance / MIDDLE) ** CORE_FALLOFF)
+ return (glow, core, glow)
+
+
+def strip():
+ image = Image.new("RGB", (SIZE, SIZE))
+ image.putdata([column_colour(column) for row in range(SIZE) for column in range(SIZE)])
+ return image
+
+
+def selfcheck():
+ assert column_colour(MIDDLE) == (FULL, FULL, FULL), column_colour(MIDDLE)
+ assert column_colour(0) == (0, 0, 0), column_colour(0)
+ red, green, blue = column_colour(MIDDLE - 3)
+ assert red == blue == FULL and green < FULL, (red, green, blue)
+
+
+def main():
+ selfcheck()
+ out_path = sys.argv[1] if len(sys.argv) > 1 else OUT_PATH
+ strip().save(out_path)
+ print(out_path)
+
+
+if __name__ == "__main__":
+ main()