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.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(data): china mines show only their blinking arming light
Olcay Seygan034cdce317d4
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 7c76596c5..d84072214 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1374,7 +1374,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same- A bright cloud no longer shows what is behind it as a line drawing. Inside a nuke's white cloud, or a falling War Factory's fireball, every tree and wreck under it used to come out as a thin grey outline, and the picture's sharpening ringed each dark piece in white. Both stop where the frame is bright.- Smoke and fire no longer end on a straight line where they meet the ground or a building. A puff that sinks into a hillside or drifts against a wall thins out over its last few metres, softly enough that a nuke's haze and a Scud's grey smoke no longer come out as stacked, stair-stepped terraces, and a toxin cloud lying low over the ground keeps its body instead of breaking into hard-edged green islands. A China mine field blinks where you can see it again: its lights hang just off the ground, and the fade had eaten all but a thirtieth of their bright middle. No effect fades over more than its own size now, so a small spark close to the ground keeps its light. This is the default renderer; Classic and the old renderer keep the hard edge they had in 2003.- Gunfire shows at the zoom you play at. A rifle's tracer was a third of a unit wide, about one pixel from the default camera, and a bullet hit nothing you could see. Tracers from rifles, Gattlings, Humvees, Technicals and Quad Cannons are now twice as wide and half again as long, the muzzle flash is half as big again, and every hit kicks up sparks and a puff of dirt where it lands. A tank shell burns a short hot streak behind it all the way to the target, where it used to be a grey sliver you could not pick out between the flash and the blast. A Crusader's, Battlemaster's, Scorpion's, Paladin's or Overlord's shot used to be a soft white glow drifting out in front of the gun, wider than the tank; it is now a short orange blast at the barrel tip, with a bigger flame and smoke puff behind it. A shell landing throws dirt and sparks around its blast. The colours are the ones the game always used, and no weapon does anything different.-- A China mine field has mines in it. EA's field had no model at all, only a white glint blinking on each of its eight spots, so your own minefield looked like a patch of fireflies. Each spot is now a round steel mine pressed into a ring of dug earth, at a random turn, with an arming LED over its fuse that flicks on for a quarter of a second every second and a half, red on standard and cluster mines and a cold blue on EMP mines. You and your allies see them a little see-through, the way you see your own stealthed units. The enemy still sees nothing until he detects the field, and then he sees the same mines. A mine going off under a tank now throws a column of dark earth twice the tank's height, scatters clods round it and leaves a low black smoke and a scorch, with a short jolt of the screen; it used to puff a pale spray of specks that looked like dust kicked up. An EMP mine throws no earth, so you can tell which kind went off: it lights a blue ring across the ground, a crackle of blue sparks and a short blue flash at the spot; EA's flash grew until it washed the whole screen white for a fifth of a second. What a mine does is unchanged.+- A China mine field tells you what kind it is. EA's field had no model at all, only a soft white glint swelling and fading on each of its eight spots, so your own minefield looked like a patch of fireflies. Each mine is now marked by a small arming light that snaps on for a quarter of a second every second and a half, red on standard and cluster mines and blue on EMP mines, with a white-hot point and a dark rim that keep it readable on grass, sand or snow. No mine body is drawn on the ground, only the light. The enemy still sees nothing until he detects the field. A mine going off under a tank now throws a column of dark earth twice the tank's height, scatters clods round it and leaves a low black smoke and a scorch, with a short jolt of the screen; it used to puff a pale spray of specks that looked like dust kicked up. An EMP mine throws no earth, so you can tell which kind went off: it lights a blue ring across the ground, a crackle of blue sparks and a short blue flash at the spot; EA's flash grew until it washed the whole screen white for a fifth of a second. What a mine does is unchanged.- A base out of power looks out of power. A building that switches off when your power runs short, or one a hacker shut down, drains to a cold grey and sags darker, and its windows and lamps go out. Every few seconds it blinks dark for an instant or its lights catch again for a moment, and blue sparks jump on its walls where something shorts. A tank or building hit by an EMP crawls with thin blue arcs for as long as it stays dead, where it used to just turn dark grey.- Your own stealthed units look cloaked instead of faded. What stands behind a Pathfinder, Colonel Burton or a stealthed GLA unit bends through its body in a slow ripple, under a cold edge you can still read the unit by. When an enemy detector has found him, that edge turns amber and flares with each sweep. On every renderer, a stealthed unit of yours no longer comes out solid whenever no building is on the screen: the game drew it a second time without its see-through. An enemy stealth unit your detector finds used to turn into a flat orange shape with no paint; now it keeps its own paint, drained of colour, under a burning red-orange outline with scan lines running up it, and all of it flares on every sweep of the detector. This is the default renderer; Classic and the old renderer keep the 2003 look for all of these.- Effects fade out instead of blinking off. The rings a nuke sends across the ground, and any spark, flash or puff whose own colours never reached nothing, used to vanish at full strength on their last frame. Each one now dims away over its last quarter of a second, or over a quarter of its life when it lives shorter than that. One that was already fading looks the way it always did.diff --git a/GeneralsMD/Code/BuildFingerprint.manifest b/GeneralsMD/Code/BuildFingerprint.manifestindex 09f0daa9d..f51c2c5a3 100644--- a/GeneralsMD/Code/BuildFingerprint.manifest+++ b/GeneralsMD/Code/BuildFingerprint.manifest@@ -10,7 +10,6 @@ Data/Art/Textures/ReforgedBarGLACenter.tgaData/Art/Textures/ReforgedBarGLALeft.tgaData/Art/Textures/ReforgedBarGLARight.tgaData/Art/Textures/ReforgedLaserPink.tga-Data/Art/Textures/ReforgedMine.tgaData/Art/Textures/ReforgedMineGlowBlue.tgaData/Art/Textures/ReforgedMineGlowRed.tgaData/Art/Textures/ReforgedMineLedBlue.tgadiff --git a/GeneralsMD/Code/Data/Art/Textures/ReforgedMine.tga b/GeneralsMD/Code/Data/Art/Textures/ReforgedMine.tgadeleted file mode 100644index 34d2174e1..000000000Binary files a/GeneralsMD/Code/Data/Art/Textures/ReforgedMine.tga and /dev/null differdiff --git a/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini b/GeneralsMD/Code/Data/INI/ParticleSystemReforged.iniindex 1e0413e97..555d970a8 100644--- a/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini+++ b/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini@@ -3400,32 +3400,28 @@ End; China's mine fields. EXAMineGroup has eight mine bones and no mesh at all, so EA's field was a; white lens flare blinking on each bone every second and a half and nothing else. MineFX and-; MineFXPurple are the mines themselves now: ReforgedMine.tga (Tools/mine_marks.py), a steel plate-; sunk in a ring of dug earth ten across, laid flat on the bone at a random turn, with an arming-; light over its cap, red on the standard and cluster mines and blue on the EMP mines. The light is-; two systems. MineFXLight is a dot two and a half across lying flat one over the plate,-; ReforgedMineLedRed.tga or ReforgedMineLedBlue.tga, a coloured lens with a near-white middle in a-; dark bezel, alpha blended so it keeps its colour on grass, sand or snow; a slave's Size scales the-; plate's, so 0.25 is a half width of 1.25. MineFXGlow hangs off the dot, a slave of a slave, which-; takes its own Size rather than a scaled one: an additive glow seven across facing the camera 2.4-; over the plate, ReforgedMineGlow*.tga, a white-hot point in a saturated glow. Each system's own-; SlavePosOffset is where its particles sit over the plate's; the one on the master is never read.-; Both are high enough that the ground behind them along the player's line of sight, which looks down-; at about 39 degrees, is further than their half width, because the soft particle fade thins a-; sprite over its half width wherever the ground is closer behind it than that; the light before-; this was a 30-across glow on the plate and came out at about a tenth of its colour. Raised that far-; straight up, the light showed about 8 px above the plate's middle from the opening camera, so each-; is also moved towards that camera (south, -Y, the opening view's yaw being 0) by its height over-; the tangent of the 37.5 degree pitch, which puts it back over the middle there. A player who turns-; the camera sees it drift off centre. The light comes on at full strength,-; holds for eight frames and is gone two frames later, then stays dark until the next plate a second-; and a half on: the lens flare it replaced was a soft blob that swelled and faded over 24 frames.+; MineFXPurple keep that: no mine is drawn, only an arming light over each bone, red on the standard+; and cluster mines and blue on the EMP mines. A steel plate under it was tried and taken out again;+; it looked laid on the ground rather than buried in it, worst on desert sand. The light is two+; systems. MineFX is a dot two and a half across lying flat, ReforgedMineLedRed.tga or+; ReforgedMineLedBlue.tga, a coloured lens with a near-white middle in a dark bezel, alpha blended so+; it keeps its colour on grass, sand or snow. Its slave MineFXGlow is an additive glow seven across+; facing the camera, ReforgedMineGlow*.tga, a white-hot point in a saturated glow; a slave's Size+; scales its master's, so 2.8 over the dot's 1.25 is 3.5, and its own SlavePosOffset places it+; against the dot. The dot sits one over the bone and the glow 2.4, high enough that the ground+; behind each along the player's line of sight, which looks down at about 39 degrees, is further+; than its half width: the soft particle fade thins a sprite over its half width wherever the ground+; is closer behind it than that, and a 30-across glow lying on the ground came out at about a tenth+; of its colour. Raised straight up the light showed about 8 px above the bone from the opening+; camera, so each is also moved towards that camera (south, -Y, the opening view's yaw being 0) by+; its height over the tangent of the 37.5 degree pitch. A player who turns the camera sees it drift+; off the spot. The dot's line volume is one point, which is how a master is offset from its bone.+; The light comes on at full strength, holds for eight frames and is gone two frames later, then+; stays dark for a second and a half, each bone starting at a random point of that: the lens flare+; it replaced was a soft blob that swelled and faded over 24 frames.;; The systems hang off the field's model, so they keep its stealth: the owner and his allies see-; them, an enemy only while the field is detected. A plate lives two seconds and the next is laid-; under it eight frames before it goes, rising while the old one fades out, and the light blinks-; with each new plate. At 95 percent opacity the steel lets the ground through only faintly; at 85-; it read as a pale translucent disc lying on grass.+; them, an enemy only while the field is detected.ParticleSystem MineFXGlowPriority = ALWAYS_RENDER@@ -3433,7 +3429,7 @@ ParticleSystem MineFXGlowShader = ADDITIVEType = PARTICLEParticleName = ReforgedMineGlowRed.tga- SlavePosOffset = X:0.00 Y:-3.10 Z:2.40+ SlavePosOffset = X:0.00 Y:-1.80 Z:1.40AngleZ = 0.00 0.00AngularRateZ = 0.00 0.00AngularDamping = 1.00 1.00@@ -3441,7 +3437,7 @@ ParticleSystem MineFXGlowGravity = 0.00Lifetime = 11.00 11.00SystemLifetime = 0- Size = 3.50 3.50+ Size = 2.80 2.80StartSizeRate = 0.00 0.00SizeRate = 0.00 0.00SizeRateDamping = 1.00 1.00@@ -3489,7 +3485,7 @@ ParticleSystem MineFXGlowPurpleShader = ADDITIVEType = PARTICLEParticleName = ReforgedMineGlowBlue.tga- SlavePosOffset = X:0.00 Y:-3.10 Z:2.40+ SlavePosOffset = X:0.00 Y:-1.80 Z:1.40AngleZ = 0.00 0.00AngularRateZ = 0.00 0.00AngularDamping = 1.00 1.00@@ -3497,7 +3493,7 @@ ParticleSystem MineFXGlowPurpleGravity = 0.00Lifetime = 11.00 11.00SystemLifetime = 0- Size = 3.50 3.50+ Size = 2.80 2.80StartSizeRate = 0.00 0.00SizeRate = 0.00 0.00SizeRateDamping = 1.00 1.00@@ -3539,14 +3535,14 @@ ParticleSystem MineFXGlowPurpleWindPingPongEndAngleMax = 6.283185End-ParticleSystem MineFXLight+ParticleSystem MineFXPriority = ALWAYS_RENDERIsOneShot = NoShader = ALPHAType = PARTICLEParticleName = ReforgedMineLedRed.tgaSlaveSystem = MineFXGlow- SlavePosOffset = X:0.00 Y:-1.30 Z:1.00+ SlavePosOffset = X:0.00 Y:0.00 Z:0.00AngleZ = 0.00 0.00AngularRateZ = 0.00 0.00AngularDamping = 1.00 1.00@@ -3554,7 +3550,7 @@ ParticleSystem MineFXLightGravity = 0.00Lifetime = 11.00 11.00SystemLifetime = 0- Size = 0.25 0.25+ Size = 1.25 1.25StartSizeRate = 0.00 0.00SizeRate = 0.00 0.00SizeRateDamping = 1.00 1.00@@ -3577,12 +3573,14 @@ ParticleSystem MineFXLightColorScale = 0.00 0.00BurstDelay = 52.00 52.00BurstCount = 1.00 1.00- InitialDelay = 0.00 0.00+ InitialDelay = 0.00 52.00DriftVelocity = X:0.00 Y:0.00 Z:0.00VelocityType = OUTWARDVelOutward = 0.00 0.00VelOutwardOther = 0.00 0.00- VolumeType = POINT+ VolumeType = LINE+ VolLineStart = X:0.00 Y:-1.30 Z:1.00+ VolLineEnd = X:0.00 Y:-1.30 Z:1.00IsHollow = NoIsGroundAligned = YesIsEmitAboveGroundOnly = No@@ -3596,14 +3594,14 @@ ParticleSystem MineFXLightWindPingPongEndAngleMax = 6.283185End-ParticleSystem MineFXLightPurple+ParticleSystem MineFXPurplePriority = ALWAYS_RENDERIsOneShot = NoShader = ALPHAType = PARTICLEParticleName = ReforgedMineLedBlue.tgaSlaveSystem = MineFXGlowPurple- SlavePosOffset = X:0.00 Y:-1.30 Z:1.00+ SlavePosOffset = X:0.00 Y:0.00 Z:0.00AngleZ = 0.00 0.00AngularRateZ = 0.00 0.00AngularDamping = 1.00 1.00@@ -3611,7 +3609,7 @@ ParticleSystem MineFXLightPurpleGravity = 0.00Lifetime = 11.00 11.00SystemLifetime = 0- Size = 0.25 0.25+ Size = 1.25 1.25StartSizeRate = 0.00 0.00SizeRate = 0.00 0.00SizeRateDamping = 1.00 1.00@@ -3634,124 +3632,14 @@ ParticleSystem MineFXLightPurpleColorScale = 0.00 0.00BurstDelay = 52.00 52.00BurstCount = 1.00 1.00- InitialDelay = 0.00 0.00- DriftVelocity = X:0.00 Y:0.00 Z:0.00- VelocityType = OUTWARD- VelOutward = 0.00 0.00- VelOutwardOther = 0.00 0.00- VolumeType = POINT- IsHollow = No- IsGroundAligned = Yes- IsEmitAboveGroundOnly = No- IsParticleUpTowardsEmitter = No- WindMotion = Unused- WindAngleChangeMin = 0.149924- WindAngleChangeMax = 0.449946- WindPingPongStartAngleMin = 0.000000- WindPingPongStartAngleMax = 0.785398- WindPingPongEndAngleMin = 5.497787- WindPingPongEndAngleMax = 6.283185-End--ParticleSystem MineFX- Priority = ALWAYS_RENDER- IsOneShot = No- Shader = ALPHA- Type = PARTICLE- ParticleName = ReforgedMine.tga- AngleZ = 0.00 6.28- AngularRateZ = 0.00 0.00- AngularDamping = 1.00 1.00- VelocityDamping = 1.00 1.00- Gravity = 0.00- Lifetime = 60.00 60.00- SystemLifetime = 0- Size = 5.00 5.00- StartSizeRate = 0.00 0.00- SizeRate = 0.00 0.00- SizeRateDamping = 1.00 1.00- Alpha1 = 0.00 0.00 0- Alpha2 = 0.95 0.95 8- Alpha3 = 0.95 0.95 60- Alpha4 = 0.00 0.00 0- Alpha5 = 0.00 0.00 0- Alpha6 = 0.00 0.00 0- Alpha7 = 0.00 0.00 0- Alpha8 = 0.00 0.00 0- Color1 = R:255 G:255 B:255 0- Color2 = R:255 G:255 B:255 60- Color3 = R:0 G:0 B:0 0- Color4 = R:0 G:0 B:0 0- Color5 = R:0 G:0 B:0 0- Color6 = R:0 G:0 B:0 0- Color7 = R:0 G:0 B:0 0- Color8 = R:0 G:0 B:0 0- ColorScale = 0.00 0.00- BurstDelay = 52.00 52.00- BurstCount = 1.00 1.00InitialDelay = 0.00 52.00DriftVelocity = X:0.00 Y:0.00 Z:0.00VelocityType = OUTWARDVelOutward = 0.00 0.00VelOutwardOther = 0.00 0.00- VolumeType = POINT- IsHollow = No- IsGroundAligned = Yes- IsEmitAboveGroundOnly = No- IsParticleUpTowardsEmitter = No- WindMotion = Unused- WindAngleChangeMin = 0.149924- WindAngleChangeMax = 0.449946- WindPingPongStartAngleMin = 0.000000- WindPingPongStartAngleMax = 0.785398- WindPingPongEndAngleMin = 5.497787- WindPingPongEndAngleMax = 6.283185- SlaveSystem = MineFXLight- SlavePosOffset = X:0.00 Y:0.00 Z:0.00-End--ParticleSystem MineFXPurple- Priority = ALWAYS_RENDER- IsOneShot = No- Shader = ALPHA- Type = PARTICLE- ParticleName = ReforgedMine.tga- AngleZ = 0.00 6.28- AngularRateZ = 0.00 0.00- AngularDamping = 1.00 1.00- VelocityDamping = 1.00 1.00- Gravity = 0.00- Lifetime = 60.00 60.00- SystemLifetime = 0- Size = 5.00 5.00- StartSizeRate = 0.00 0.00- SizeRate = 0.00 0.00- SizeRateDamping = 1.00 1.00- Alpha1 = 0.00 0.00 0- Alpha2 = 0.95 0.95 8- Alpha3 = 0.95 0.95 60- Alpha4 = 0.00 0.00 0- Alpha5 = 0.00 0.00 0- Alpha6 = 0.00 0.00 0- Alpha7 = 0.00 0.00 0- Alpha8 = 0.00 0.00 0- Color1 = R:255 G:255 B:255 0- Color2 = R:255 G:255 B:255 60- Color3 = R:0 G:0 B:0 0- Color4 = R:0 G:0 B:0 0- Color5 = R:0 G:0 B:0 0- Color6 = R:0 G:0 B:0 0- Color7 = R:0 G:0 B:0 0- Color8 = R:0 G:0 B:0 0- ColorScale = 0.00 0.00- BurstDelay = 52.00 52.00- BurstCount = 1.00 1.00- InitialDelay = 0.00 52.00- DriftVelocity = X:0.00 Y:0.00 Z:0.00- VelocityType = OUTWARD- VelOutward = 0.00 0.00- VelOutwardOther = 0.00 0.00- VolumeType = POINT+ VolumeType = LINE+ VolLineStart = X:0.00 Y:-1.30 Z:1.00+ VolLineEnd = X:0.00 Y:-1.30 Z:1.00IsHollow = NoIsGroundAligned = YesIsEmitAboveGroundOnly = No@@ -3763,8 +3651,6 @@ ParticleSystem MineFXPurpleWindPingPongStartAngleMax = 0.785398WindPingPongEndAngleMin = 5.497787WindPingPongEndAngleMax = 6.283185- SlaveSystem = MineFXLightPurple- SlavePosOffset = X:0.00 Y:0.00 Z:0.00End; A mine going off under a vehicle (WeaponFX_MineDetonation and Neutron_WeaponFX_Mine indiff --git a/GeneralsMD/Code/Tools/mine_marks.py b/GeneralsMD/Code/Tools/mine_marks.pyindex 4cfb0c2a3..fe8b8fbb9 100644--- a/GeneralsMD/Code/Tools/mine_marks.py+++ b/GeneralsMD/Code/Tools/mine_marks.py@@ -1,24 +1,16 @@-"""The picture a China mine is drawn with: a round steel pressure mine seen from above, sunk in a ring-of disturbed earth. The game lays it flat on the ground at each of a mine field's eight mine bones-(ParticleSystemReforged.ini, MineFX and MineFXPurple), so it is shaded here once, lit from the top-left, and the soil ring fades out into whatever ground it lands on.+"""The arming light that marks each China mine (ParticleSystemReforged.ini, MineFX and MineFXPurple):+red for the standard and cluster mines, a saturated blue for the EMP mines. No mine body is drawn.-The steel is smeared with soil in places and the dug ring is uneven, lumpy and reaches further on-some headings than others, darkest in the hollow against the rim, so the plate looks sunk in the-ground rather than laid on it.+It is two pictures. ReforgedMineLed*.tga is a small dot lying flat: a lens in the light's colour with+a near-white middle, inside a dark bezel, alpha blended so it keeps its colour over grass, sand or+snow. ReforgedMineGlow*.tga is the light above it, drawn additively: a white-hot point in a+saturated glow.-The arming light over each mine is two pictures. ReforgedMineLed*.tga is a small dot on the plate's-cap: a lens in the light's colour, red for the standard and cluster mines and a saturated blue for-the EMP mines, with a near-white middle, inside a dark bezel, alpha blended so it keeps its colour-over grass, sand or snow. ReforgedMineGlow*.tga is the light above it, drawn additively: a white-hot-point in a saturated glow.-- python Tools/mine_marks.py # writes Data/Art/Textures/ReforgedMine.tga and ReforgedMineLed*.tga+ python Tools/mine_marks.py # writes Data/Art/Textures/ReforgedMineLed*.tga and ReforgedMineGlow*.tgaDrawn four times too big and brought down, which is the antialiasing."""import mathimport os-import randomimport sysfrom PIL import Image@@ -26,16 +18,6 @@ from PIL import ImageDRAWN = 512SHIPPED = 128CENTRE = (DRAWN - 1) / 2.0-LIGHT = (-0.45, -0.55, 0.70) # towards the light: up and to the left in the picture, mostly overhead-STEEL = (54, 52, 40) # dull olive steel, dark and warm so it does not read as a grey coin on sand-SOIL = (26, 20, 14)-SOIL_LIT = (70, 58, 42) # dry soil smeared on the steel, before the steel's shading-DIRT = 0.45 # how much of the steel it hides where it is thickest-SOIL_ALPHA = 0.92 # the dark ring is what tells a mine from a stone on grass at the player's camera-OUTLINE = 0.035 # a near-black edge round the steel, as a share of the half width-PLATE = 0.70 # radius of the steel, as a share of the half width-SOIL_OUT = 0.98-BOLTS = 0.55LED_HOT = 0.10 # radius of the near-white hot spot, as a share of the half widthLED_LENS = 0.50 # radius of the lit lens in the light's colourLED_BEZEL_OUT = 0.74 # outer edge of the dark bezel round the lens@@ -52,78 +34,8 @@ def ramp(edge0, edge1, x):return t * t * (3.0 - 2.0 * t)-def height(x, y):- """The steel's height at a point in half widths: a bevelled rim, a flat top with a groove, a raised- pressure cap in the middle and four bolt heads."""- r = math.hypot(x, y)- h = 1.0 - ramp(PLATE - 0.08, PLATE, r) # rim bevel down to the soil- h -= 0.12 * (ramp(0.40, 0.42, r) - ramp(0.45, 0.47, r)) # groove round the top- h += 0.35 * (1.0 - ramp(0.20, 0.25, r)) # pressure cap- for k in range(4):- angle = math.radians(45 + 90 * k)- d = math.hypot(x - BOLTS * math.cos(angle), y - BOLTS * math.sin(angle))- h += 0.18 * (1.0 - ramp(0.02, 0.045, d))- return h---def waves(seed, count, frequency):- """Smooth noise in about -1..1: a few plane waves at random headings and phases."""- pick = random.Random(seed)- terms = [(pick.uniform(0, 2 * math.pi), pick.uniform(0.6, 1.4) * frequency, pick.uniform(0, 2 * math.pi))- for _ in range(count)]- scale = 1.0 / math.sqrt(count / 2.0)- return lambda x, y: scale * sum(math.sin(f * (x * math.cos(a) + y * math.sin(a)) + p) for a, f, p in terms)--def main():out_folder = sys.argv[1] if len(sys.argv) > 1 else OUT_FOLDER- length = math.sqrt(sum(c * c for c in LIGHT))- light = [c / length for c in LIGHT]- grit = random.Random(7)- clumps = waves(11, 6, 9.0) # lumps of turned earth- dirt = waves(13, 5, 6.0) # where soil has smeared over the steel- edge = waves(17, 4, 3.0) # how far the dug ring reaches, by heading- step = 2.0 / DRAWN- image = Image.new("RGBA", (DRAWN, DRAWN))- pixels = image.load()- for py in range(DRAWN):- y = (py - CENTRE) / CENTRE- for px in range(DRAWN):- x = (px - CENTRE) / CENTRE- r = math.hypot(x, y)- noise = grit.uniform(-1.0, 1.0)- heading = math.atan2(y, x)- reach = SOIL_OUT - 0.10 + 0.07 * edge(math.cos(heading), math.sin(heading))- # the soil laps over the rim in places, so the plate is sunk rather than laid on top- lip = PLATE - 0.05 * max(0.0, clumps(x * 0.7, y * 0.7) - 0.6)- if r < lip:- # slope over eight drawn pixels, scaled so a bevel tilts the normal well over- dx = (height(x + step * 4, y) - height(x - step * 4, y)) / (step * 8) * 0.06- dy = (height(x, y + step * 4) - height(x, y - step * 4)) / (step * 8) * 0.06- n = (-dx, -dy, 1.0)- nl = math.sqrt(n[0] * n[0] + n[1] * n[1] + 1.0)- lit = max(0.0, (n[0] * light[0] + n[1] * light[1] + n[2] * light[2]) / nl)- shade = 0.25 + 1.0 * lit + 0.05 * noise- if r > lip - OUTLINE:- shade *= 0.35- smear = DIRT * ramp(-0.2, 0.8, dirt(x, y))- colour = tuple(min(255, max(0, int((c * (1.0 - smear) + s * smear) * shade)))- for c, s in zip(STEEL, SOIL_LIT))- pixels[px, py] = colour + (255,)- elif r < reach:- # darkest in the hollow against the rim, fading out into the ground in clumps- fade = 1.0 - ramp(lip + 0.10, reach, r)- lump = clumps(x, y)- alpha = SOIL_ALPHA * fade * min(1.0, 0.75 + 0.35 * lump + 0.1 * noise)- hollow = 1.0 - 0.45 * (1.0 - ramp(lip, lip + 0.10, r))- shade = (1.0 + 0.25 * lump + 0.15 * noise) * hollow- colour = tuple(min(255, max(0, int(c * shade))) for c in SOIL)- pixels[px, py] = colour + (max(0, min(255, int(255 * alpha))),)- else:- pixels[px, py] = SOIL + (0,)- path = os.path.join(out_folder, "ReforgedMine.tga")- image.resize((SHIPPED, SHIPPED), Image.LANCZOS).save(path)- print(path)for name, glow, core in LEDS:path = os.path.join(out_folder, "ReforgedMineLed%s.tga" % name)led(glow, core).resize((SHIPPED, SHIPPED), Image.LANCZOS).save(path)