From 24113c5e9aa35132f5de10983e96be47116c4ee8 Mon Sep 17 00:00:00 2001 From: bellapatricia Date: Sun, 17 Aug 2014 15:23:09 +0200 Subject: [PATCH] Finished adding Hatch- morphing and such (CC, Overseer) --- AnotherSc2Hack/Classes/BackEnds/GameInfo.cs | 114 ++++++++- .../Classes/BackEnds/HelpFunctions.cs | 73 +++++- .../Classes/BackEnds/InteropCalls.cs | 23 ++ .../FrontEnds/Rendering/BaseRenderer.cs | 238 ++++++++++++++---- .../FrontEnds/Rendering/ProductionRenderer.cs | 4 +- .../FrontEnds/Rendering/UnitRenderer.cs | 25 +- AnotherSc2Hack/Properties/AssemblyInfo.cs | 4 +- PredefinedTypes/PredefinedTypes.cs | 12 + PredefinedTypes/Properties/AssemblyInfo.cs | 4 +- 9 files changed, 421 insertions(+), 76 deletions(-) diff --git a/AnotherSc2Hack/Classes/BackEnds/GameInfo.cs b/AnotherSc2Hack/Classes/BackEnds/GameInfo.cs index 7edf78d4..b1511c24 100644 --- a/AnotherSc2Hack/Classes/BackEnds/GameInfo.cs +++ b/AnotherSc2Hack/Classes/BackEnds/GameInfo.cs @@ -703,7 +703,9 @@ private void AssignUnitCommands(ref PredefinedTypes.Unit u, int i) u.Id.Equals(PredefinedTypes.UnitId.ZbLiar) || u.Id.Equals(PredefinedTypes.UnitId.ZbHive) || u.Id.Equals(PredefinedTypes.UnitId.ZuBanelingCocoon) || + u.Id.Equals(PredefinedTypes.UnitId.ZuBroodlordCocoon) || u.Id.Equals(PredefinedTypes.UnitId.ZuEgg) || + u.Id.Equals(PredefinedTypes.UnitId.ZuOverseerCocoon) || u.Id.Equals(PredefinedTypes.UnitId.TbEbay) || u.Id.Equals(PredefinedTypes.UnitId.TbTechlabFactory) || u.Id.Equals(PredefinedTypes.UnitId.TbTechlabRax) || @@ -717,6 +719,7 @@ private void AssignUnitCommands(ref PredefinedTypes.Unit u, int i) u.Id.Equals(PredefinedTypes.UnitId.PbTemplararchives) || u.Id.Equals(PredefinedTypes.UnitId.PbTwilightcouncil) || u.Id.Equals(PredefinedTypes.UnitId.PbRoboticssupportbay) || + u.Id.Equals(PredefinedTypes.UnitId.PuMothershipCore) || u.Id.Equals(PredefinedTypes.UnitId.ZbEvolutionChamber) || u.Id.Equals(PredefinedTypes.UnitId.ZbSpire) || u.Id.Equals(PredefinedTypes.UnitId.ZbSpawningPool) || @@ -981,10 +984,14 @@ private Int32 GetGUnitReadUnitCount() var lUnitIds = new List(); - /* Content of Abilities */ + /* Content of Abilities (pAbilities) */ var iUnitAbilitiesPointer = BitConverter.ToUInt32(InteropCalls.Help_ReadProcessMemory(HStarcraft, Of.UnitStruct + 0xDC + Of.UnitStructSize * iUnitNum, 4), 0); + + + + /* Bitwise AND */ iUnitAbilitiesPointer = iUnitAbilitiesPointer & 0xFFFFFFFC; @@ -997,7 +1004,7 @@ private Int32 GetGUnitReadUnitCount() /* Reading the Bytearray */ - /* Read the result of iUnitAbilitiesPointer */ + /* Read the result of iUnitAbilitiesPointer (p1) */ var iUnitAbilitiesPointerResult = BitConverter.ToInt32(InteropCalls.Help_ReadProcessMemory(HStarcraft, (int)iUnitAbilitiesPointer, 4), 0); @@ -1010,6 +1017,8 @@ private Int32 GetGUnitReadUnitCount() for (var i = 0; i < byteBuffer.Length; i++) { +#if !DEBUG + if (byteBuffer[i].Equals(0x19)) { iIndexToLookAt = i; @@ -1018,9 +1027,10 @@ private Int32 GetGUnitReadUnitCount() break; } +#else #region Debug/ Tests - /* var _iContentOfPointer = + var _iContentOfPointer = BitConverter.ToUInt32( InteropCalls.Help_ReadProcessMemory(HStarcraft, (Int32)iUnitAbilitiesPointer + 0x18 + 4 * i, 4), 0); @@ -1034,6 +1044,27 @@ private Int32 GetGUnitReadUnitCount() ? true : false; + var result2 = + BitConverter.ToUInt32( + InteropCalls.Help_ReadProcessMemory(HStarcraft, iUnitAbilitiesPointerResult - 3 + 0xA4 + (i * 4), 4), 0); + + /* var result3 = + BitConverter.ToInt32( + InteropCalls.Help_ReadProcessMemory(HStarcraft, iUnitAbilitiesPointerResult - 3, 4), 0);*/ + + var resultOfResult2 = + BitConverter.ToUInt32( + InteropCalls.Help_ReadProcessMemory(HStarcraft, (UInt32)(result2 + 4), 4), 0); + + /* var resultOfResult3 = + BitConverter.ToInt32( + InteropCalls.Help_ReadProcessMemory(HStarcraft, result3, 4), 0);*/ + + var strAbilityName = + Encoding.UTF8.GetString(InteropCalls.Help_ReadProcessMemory(HStarcraft, resultOfResult2, + 16)); + + var _iArrayOfBytes = BitConverter.ToInt32( InteropCalls.Help_ReadProcessMemory(HStarcraft, (Int32)_iContentOfPointer + 0x34, 4), 0); @@ -1041,6 +1072,7 @@ private Int32 GetGUnitReadUnitCount() var _iTempPtr = BitConverter.ToInt32( InteropCalls.Help_ReadProcessMemory(HStarcraft, (Int32)_iArrayOfBytes, 4), 0); + var _productionChunk = InteropCalls.Help_ReadProcessMemory(HStarcraft, _iTempPtr, 0x80); var _iType = BitConverter.ToInt32(_productionChunk, 0x44); @@ -1050,19 +1082,34 @@ private Int32 GetGUnitReadUnitCount() var _iMineralCost = BitConverter.ToInt32(_productionChunk, 0x74); var _iVespineCost = BitConverter.ToInt32(_productionChunk, 0x78); + var _iSomething = + BitConverter.ToInt32( + InteropCalls.Help_ReadProcessMemory(HStarcraft, (Int32) _iContentOfPointer + 0x4, 4), 0); + Debug.WriteLine("\n"); Debug.WriteLine("i: " + i); - Debug.WriteLine("NumberOfQueuedUnits: " + _iNumberOfQueuedUnits); - Debug.WriteLine("Bytebuffer Item: " + byteBuffer[i].ToString("X2") + "(" + byteBuffer[i] + ")"); - Debug.WriteLine("Minerals: " + _iMineralCost); - Debug.WriteLine("Reactor Attached: " + _bReactorAttached); - Debug.WriteLine("iType: " + _iType); - Debug.WriteLine("Time Left: " + _iTimeLeft);*/ + Debug.WriteLine("iPointerResult - 3: 0x" + (iUnitAbilitiesPointerResult - 3).ToString("X8")); + Debug.WriteLine("Result2 (0xA4): 0x" + result2.ToString("X8")); + Debug.WriteLine("Result of Result2: 0x" + result2.ToString("X8")); + Debug.WriteLine("Ability Name: " + strAbilityName); + //Debug.WriteLine("NumberOfQueuedUnits: " + _iNumberOfQueuedUnits); + //Debug.WriteLine("Bytebuffer Item: 0x" + byteBuffer[i].ToString("X2") + " - " + byteBuffer[i]); + //Debug.WriteLine("Minerals: " + _iMineralCost); + //Debug.WriteLine("Reactor Attached: " + _bReactorAttached); + //Debug.WriteLine("iType: " + _iType); + //Debug.WriteLine("Time Left: " + _iTimeLeft); + //Debug.WriteLine("iContent of pointer: 0x" + _iContentOfPointer.ToString("X8")); + //Debug.WriteLine("Temp ptr: 0x" + _iTempPtr.ToString("X8")); + //Debug.WriteLine("iSometzhing: 0x" + _iSomething.ToString("X8")); + #endregion +#endif } + + /* Read the DATA Pointer (that leads to our result) */ var iContentOfPointer = BitConverter.ToUInt32( @@ -1115,6 +1162,55 @@ private Int32 GetGUnitReadUnitCount() lUnitIds.Add(prd2); } + //That will happen if there is no unit to be build or something is morphing like a Hatch => Lair + //Thus: Check if the sourcebuilding is a hatch or something.. + else if (iNumberOfQueuedUnits <= 0) + { + if (structureId.Equals(PredefinedTypes.UnitId.ZbHatchery) || + structureId.Equals(PredefinedTypes.UnitId.ZbLiar) || + structureId.Equals(PredefinedTypes.UnitId.ZbSpire) || + structureId.Equals(PredefinedTypes.UnitId.ZuBroodlordCocoon) || + structureId.Equals(PredefinedTypes.UnitId.ZuOverseerCocoon) || + structureId.Equals(PredefinedTypes.UnitId.TbCcGround) || + structureId.Equals(PredefinedTypes.UnitId.PuMothershipCore) || + structureId.Equals(PredefinedTypes.UnitId.PuArchon)) + { + var iUnitCommandQueuePointer = InteropCalls.ReadUInt32(HStarcraft, + Of.UnitStruct + 0xD4 + Of.UnitStructSize * iUnitNum); + + if (iUnitCommandQueuePointer > 0) + { + var iUnitCommandQueueChunk = InteropCalls.Help_ReadProcessMemory(HStarcraft, + iUnitCommandQueuePointer + 0x98, + 0xCC); + + var iType2 = -1; //BitConverter.ToInt32(iUnitCommandQueueChunk, 0x44); + var iTimeMax2 = BitConverter.ToUInt32(iUnitCommandQueueChunk, 0x1C); + var iTimeLeft2 = (float)BitConverter.ToUInt32(iUnitCommandQueueChunk, 0); + var iMineralCost2 = BitConverter.ToInt32(iUnitCommandQueueChunk, 0xC4); + var iVespineCost2 = BitConverter.ToInt32(iUnitCommandQueueChunk, 0xC8); + + var prd2 = new PredefinedTypes.UnitProduction + { + Id = + HelpFunctions.GetUnitIdFromLogicalId(structureId, iType2, (Int32) iTimeMax2, + iMineralCost2, iVespineCost2), + MineralCost = iMineralCost2, + ProductionStatus = 100 - (iTimeLeft2/iTimeMax2)*100, + ProductionTimeLeft = iTimeLeft2/65536, + ReactorAttached = false, + Supply = 0, + SupplyRaw = 0, + UnitsInProduction = 0, + VespineCost = iVespineCost2 + }; + + lUnitIds.Add(prd2); + + } + } + } + var productionChunk = InteropCalls.Help_ReadProcessMemory(HStarcraft, iTempPtr, 0x80); #region Debug and Tests diff --git a/AnotherSc2Hack/Classes/BackEnds/HelpFunctions.cs b/AnotherSc2Hack/Classes/BackEnds/HelpFunctions.cs index 460338bf..8971b1ae 100644 --- a/AnotherSc2Hack/Classes/BackEnds/HelpFunctions.cs +++ b/AnotherSc2Hack/Classes/BackEnds/HelpFunctions.cs @@ -919,20 +919,35 @@ public static PredefinedTypes.UnitId GetUnitIdFromLogicalId(PredefinedTypes.Unit if (logicalId.Equals(0)) return PredefinedTypes.UnitId.NbXelNagaTower; - var strStuff = Convert.ToString(logicalId, 16); - strStuff = "1" + strStuff.Substring(1); + if (!logicalId.Equals(-1)) + { - var inumber = int.Parse(strStuff, NumberStyles.HexNumber); + var strStuff = Convert.ToString(logicalId, 16); + strStuff = "1" + strStuff.Substring(1); - logicalId = inumber; + var inumber = int.Parse(strStuff, NumberStyles.HexNumber); + logicalId = inumber; + } #region Terran #region CC - Orbital - PF if (structureBuildFrom.Equals(PredefinedTypes.UnitId.TbCcGround)) + { + //E.G. Upgrade to Lair/ Hive + if (logicalId == -1) + { + if (mineralCost == 150 && vespineCost == 0) + return PredefinedTypes.UnitId.TupUpgradeToOrbital; + + if (mineralCost == 150 && vespineCost == 150) + return PredefinedTypes.UnitId.TupUpgradeToPlanetary; + } + return PredefinedTypes.UnitId.TuScv; + } if (structureBuildFrom.Equals(PredefinedTypes.UnitId.TbPlanetary)) return PredefinedTypes.UnitId.TuScv; @@ -1235,6 +1250,16 @@ public static PredefinedTypes.UnitId GetUnitIdFromLogicalId(PredefinedTypes.Unit #region Protoss + if (structureBuildFrom.Equals(PredefinedTypes.UnitId.PuMothershipCore)) + { + //E.G. Upgrade to Lair/ Hive + if (logicalId == -1) + { + if (mineralCost == 300 && vespineCost == 300) + return PredefinedTypes.UnitId.PupUpgradeToMothership; + } + } + #region Units #region Nexus @@ -1494,9 +1519,29 @@ public static PredefinedTypes.UnitId GetUnitIdFromLogicalId(PredefinedTypes.Unit if (logicalId.Equals(0x10003)) return PredefinedTypes.UnitId.ZupBurrow; + //E.G. Upgrade to Lair/ Hive + if (logicalId == -1) + { + if (mineralCost == 150 && vespineCost == 100) + return PredefinedTypes.UnitId.ZupUpgradeToLair; + + if (mineralCost == 200 && vespineCost == 150) + return PredefinedTypes.UnitId.ZupUpgradeToHive; + } + return PredefinedTypes.UnitId.ZuQueen; } + if (structureBuildFrom.Equals(PredefinedTypes.UnitId.ZbSpire)) + { + //E.G. Upgrade to Lair/ Hive + if (logicalId == -1) + { + if (mineralCost == 100 && vespineCost == 150) + return PredefinedTypes.UnitId.ZupUpgradeToGreaterSpire; + } + } + #region Units if (structureBuildFrom.Equals(PredefinedTypes.UnitId.ZuBanelingCocoon)) @@ -1505,6 +1550,26 @@ public static PredefinedTypes.UnitId GetUnitIdFromLogicalId(PredefinedTypes.Unit return PredefinedTypes.UnitId.ZuBaneling; } + if (structureBuildFrom.Equals(PredefinedTypes.UnitId.ZuBroodlordCocoon)) + { + //E.G. Upgrade to Lair/ Hive + if (logicalId == -1) + { + if (mineralCost == 150 && vespineCost == 150) + return PredefinedTypes.UnitId.ZupUpgradeToBroodlord; + } + } + + if (structureBuildFrom.Equals(PredefinedTypes.UnitId.ZuOverseerCocoon)) + { + //E.G. Upgrade to Lair/ Hive + if (logicalId == -1) + { + if (mineralCost == 50 && vespineCost == 50) + return PredefinedTypes.UnitId.ZupUpgradeToOverseer; + } + } + /* For the eggs, we have to cchack using other values.. Player 2 has the Type waay different. */ if (structureBuildFrom.Equals(PredefinedTypes.UnitId.ZuEgg)) diff --git a/AnotherSc2Hack/Classes/BackEnds/InteropCalls.cs b/AnotherSc2Hack/Classes/BackEnds/InteropCalls.cs index 9d40f39a..4a4ccc91 100644 --- a/AnotherSc2Hack/Classes/BackEnds/InteropCalls.cs +++ b/AnotherSc2Hack/Classes/BackEnds/InteropCalls.cs @@ -328,6 +328,16 @@ public enum DwmEc : uint EnableComposition = 1, } + public static Int32 ReadInt32(IntPtr handle, uint address) + { + return BitConverter.ToInt32(Help_ReadProcessMemory(handle, address, sizeof(Int32)), 0); + } + + public static UInt32 ReadUInt32(IntPtr handle, int address) + { + return BitConverter.ToUInt32(Help_ReadProcessMemory(handle, address, sizeof(UInt32)), 0); + } + public static byte[] Help_ReadProcessMemory(IntPtr handle, int address, int size) { if (size < 0) @@ -336,6 +346,19 @@ public static byte[] Help_ReadProcessMemory(IntPtr handle, int address, int size IntPtr bytesRead; var buffer = new byte[size]; + ReadProcessMemory(handle, (IntPtr)address, buffer, size, out bytesRead); + + return buffer; + } + + public static byte[] Help_ReadProcessMemory(IntPtr handle, uint address, int size) + { + if (size < 0) + return new byte[0]; + + IntPtr bytesRead; + var buffer = new byte[size]; + ReadProcessMemory(handle, (IntPtr) address, buffer, size, out bytesRead); return buffer; diff --git a/AnotherSc2Hack/Classes/FrontEnds/Rendering/BaseRenderer.cs b/AnotherSc2Hack/Classes/FrontEnds/Rendering/BaseRenderer.cs index 790e74e1..2b6107d9 100644 --- a/AnotherSc2Hack/Classes/FrontEnds/Rendering/BaseRenderer.cs +++ b/AnotherSc2Hack/Classes/FrontEnds/Rendering/BaseRenderer.cs @@ -2013,7 +2013,7 @@ protected void CountUnits() { _lTuMule[tmpUnit.Owner].UnitAmount += 1; _lTuMule[tmpUnit.Owner].Id = PredefinedData.UnitId.TuMule; - _lTuMule[tmpUnit.Owner].AliveSince.Add(1 - (tmpUnit.AliveSince / 387328.0f)); + _lTuMule[tmpUnit.Owner].AliveSince.Add(1 - (tmpUnit.AliveSince/387328.0f)); } else if (tmpUnit.Id == @@ -2086,11 +2086,11 @@ protected void CountUnits() PredefinedData.UnitId.TuVikingGround) _lTuViking[tmpUnit.Owner].UnitAmount += 1; - #endregion + #endregion - #region Buildings + #region Buildings - #region Command Center (Air/ Ground/ Unit Production) + #region Command Center (Air/ Ground/ Unit Production) else if (tmpUnit.Id == PredefinedData.UnitId.TbCcGround || @@ -2106,11 +2106,35 @@ protected void CountUnits() _lTuScv[tmpUnit.Owner].ConstructionState.Add(tmpUnit.ProdProcess[k]); } } + + else + { + + for (var k = 0; k < tmpUnit.ProdMineralCost.Count; k++) + { + if ( + tmpUnit.ProdUnitProductionId[k].Equals( + PredefinedData.UnitId.TupUpgradeToOrbital)) + { + _lTbOrbitalCommand[tmpUnit.Owner].UnitUnderConstruction += 1; + _lTbOrbitalCommand[tmpUnit.Owner].ConstructionState.Add(tmpUnit.ProdProcess[k]); + } + + else if ( + tmpUnit.ProdUnitProductionId[k].Equals( + PredefinedData.UnitId.TupUpgradeToPlanetary)) + { + _lTbPlanetaryFortress[tmpUnit.Owner].UnitUnderConstruction += 1; + _lTbPlanetaryFortress[tmpUnit.Owner].ConstructionState.Add(tmpUnit.ProdProcess[k]); + } + } + + } } - #endregion + #endregion - #region Orbital Command (Air/ Ground/ Unit Production) + #region Orbital Command (Air/ Ground/ Unit Production) else if (tmpUnit.Id == PredefinedData.UnitId.TbOrbitalAir || @@ -2131,9 +2155,9 @@ protected void CountUnits() } } - #endregion + #endregion - #region Barracks (Air/ Ground/ Unit Production) + #region Barracks (Air/ Ground/ Unit Production) else if (tmpUnit.Id == PredefinedData.UnitId.TbRaxAir || @@ -2182,41 +2206,41 @@ protected void CountUnits() } } - #endregion + #endregion - #region Bunker + #region Bunker else if (tmpUnit.Id == PredefinedData.UnitId.TbBunker) _lTbBunker[tmpUnit.Owner].UnitAmount += 1; - #endregion + #endregion - #region Turret + #region Turret else if (tmpUnit.Id == PredefinedData.UnitId.TbTurret) _lTbTurrent[tmpUnit.Owner].UnitAmount += 1; - #endregion + #endregion - #region Refinery + #region Refinery else if (tmpUnit.Id == PredefinedData.UnitId.TbRefinery) _lTbRefinery[tmpUnit.Owner].UnitAmount += 1; - #endregion + #endregion - #region Sensor Tower + #region Sensor Tower else if (tmpUnit.Id == PredefinedData.UnitId.TbSensortower) _lTbSensorTower[tmpUnit.Owner].UnitAmount += 1; - #endregion + #endregion - #region Planetary (Unit Production) + #region Planetary (Unit Production) else if (tmpUnit.Id == PredefinedData.UnitId.TbPlanetary) @@ -2233,9 +2257,9 @@ protected void CountUnits() } } - #endregion + #endregion - #region Engineering Bay (Upgrade Production) + #region Engineering Bay (Upgrade Production) else if (tmpUnit.Id == PredefinedData.UnitId.TbEbay) { @@ -2321,9 +2345,9 @@ protected void CountUnits() } } - #endregion + #endregion - #region Factory (Air/ Ground/ Unit Production) + #region Factory (Air/ Ground/ Unit Production) else if (tmpUnit.Id == PredefinedData.UnitId.TbFactoryAir || @@ -2381,9 +2405,9 @@ protected void CountUnits() } } - #endregion + #endregion - #region Starport (Air/ Ground/ Unit Production) + #region Starport (Air/ Ground/ Unit Production) else if (tmpUnit.Id == PredefinedData.UnitId.TbStarportAir || @@ -2441,9 +2465,9 @@ protected void CountUnits() } } - #endregion + #endregion - #region Supply (Hidden/ Normal) + #region Supply (Hidden/ Normal) else if (tmpUnit.Id == PredefinedData.UnitId.TbSupplyGround || @@ -2451,9 +2475,9 @@ protected void CountUnits() PredefinedData.UnitId.TbSupplyHidden) _lTbSupply[tmpUnit.Owner].UnitAmount += 1; - #endregion + #endregion - #region Ghost Academy (Upgrade Production) + #region Ghost Academy (Upgrade Production) else if (tmpUnit.Id == PredefinedData.UnitId.TbGhostacademy) @@ -2491,9 +2515,9 @@ protected void CountUnits() } } - #endregion + #endregion - #region Fucion Core (Upgrade Production) + #region Fucion Core (Upgrade Production) else if (tmpUnit.Id == PredefinedData.UnitId.TbFusioncore) @@ -2523,9 +2547,9 @@ protected void CountUnits() } } - #endregion + #endregion - #region Armory (Upgrade Production) + #region Armory (Upgrade Production) else if (tmpUnit.Id == PredefinedData.UnitId.TbArmory) @@ -2614,17 +2638,17 @@ protected void CountUnits() } } - #endregion + #endregion - #region AutoTurret + #region AutoTurret else if (tmpUnit.Id == PredefinedData.UnitId.TbAutoTurret) _lTbAutoTurret[tmpUnit.Owner].UnitAmount += 1; - #endregion + #endregion - #region Techlab Barracks (Upgrade Production) + #region Techlab Barracks (Upgrade Production) else if (tmpUnit.Id == PredefinedData.UnitId.TbTechlabRax) @@ -2664,9 +2688,9 @@ protected void CountUnits() } } - #endregion + #endregion - #region Techlab Factory (Upgrade Production) + #region Techlab Factory (Upgrade Production) else if (tmpUnit.Id == PredefinedData.UnitId.TbTechlabFactory) @@ -2705,9 +2729,9 @@ protected void CountUnits() } } - #endregion + #endregion - #region Techlab Starport (Upgrade Production) + #region Techlab Starport (Upgrade Production) else if (tmpUnit.Id == PredefinedData.UnitId.TbTechlabStarport) @@ -2754,9 +2778,9 @@ protected void CountUnits() } } - #endregion + #endregion - #region Reactor (Normal, Starport, Factory, Barracks COMBINED) + #region Reactor (Normal, Starport, Factory, Barracks COMBINED) else if (tmpUnit.Id == PredefinedData.UnitId.TbReactor || @@ -2768,16 +2792,16 @@ protected void CountUnits() PredefinedData.UnitId.TbReactorStarport) _lTbReactor[tmpUnit.Owner].UnitAmount += 1; - #endregion + #endregion - #endregion + #endregion - #endregion + #endregion - #region Protoss + #region Protoss - #region Units + #region Units else if (tmpUnit.Id == PredefinedData.UnitId.PuForceField) @@ -2786,13 +2810,26 @@ protected void CountUnits() _lPuForcefield[HMainHandler.GInformation.Player.Count].Id = PredefinedData.UnitId.PuForceField; _lPuForcefield[HMainHandler.GInformation.Player.Count].AliveSince.Add(1 - - (tmpUnit.AliveSince / - 62208.0f)); + (tmpUnit.AliveSince/ + 62208.0f)); } else if (tmpUnit.Id == PredefinedData.UnitId.PuArchon) + { _lPuArchon[tmpUnit.Owner].UnitAmount += 1; + + //Archons take 12 seconds to finish morphing + //12 secs = 49152 SC2 ticks (* 4096) + //Thus AliveSince > 49152 = Ready to roll + + if (tmpUnit.AliveSince < 49152) + { + _lPuArchon[tmpUnit.Owner].UnitUnderConstruction += 1; + _lPuArchon[tmpUnit.Owner].ConstructionState.Add((tmpUnit.AliveSince/49152f) * 100); + } + + } else if (tmpUnit.Id == PredefinedData.UnitId.PuCarrier) @@ -2820,7 +2857,11 @@ protected void CountUnits() else if (tmpUnit.Id == PredefinedData.UnitId.PuMothership) + { _lPuMothership[tmpUnit.Owner].UnitAmount += 1; + _lPuMothership[tmpUnit.Owner].Id = PredefinedData.UnitId.PuMothership; + _lPuMothership[tmpUnit.Owner].Energy.Add(tmpUnit.Energy); + } else if (tmpUnit.Id == PredefinedData.UnitId.PuMothershipCore) @@ -2828,6 +2869,24 @@ protected void CountUnits() _lPuMothershipcore[tmpUnit.Owner].UnitAmount += 1; _lPuMothershipcore[tmpUnit.Owner].Id = PredefinedData.UnitId.PuMothershipCore; _lPuMothershipcore[tmpUnit.Owner].Energy.Add(tmpUnit.Energy); + + if (tmpUnit.ProdNumberOfQueuedUnits == 0) + { + + for (var k = 0; k < tmpUnit.ProdMineralCost.Count; k++) + { + if ( + tmpUnit.ProdUnitProductionId[k].Equals( + PredefinedData.UnitId.PupUpgradeToMothership)) + { + _lPuMothership[tmpUnit.Owner].UnitUnderConstruction += 1; + _lPuMothership[tmpUnit.Owner].ConstructionState.Add(tmpUnit.ProdProcess[k]); + } + + + } + + } } else if (tmpUnit.Id == @@ -3577,8 +3636,24 @@ protected void CountUnits() else if (tmpUnit.Id == PredefinedData.UnitId.ZuBroodlordCocoon) + { _lZuBroodlordCocoon[tmpUnit.Owner].UnitAmount += 1; + if (tmpUnit.ProdNumberOfQueuedUnits == 0) + { + for (var k = 0; k < tmpUnit.ProdMineralCost.Count; k++) + { + if ( + tmpUnit.ProdUnitProductionId[k].Equals( + PredefinedData.UnitId.ZupUpgradeToBroodlord)) + { + _lZuBroodlord[tmpUnit.Owner].UnitUnderConstruction += 1; + _lZuBroodlord[tmpUnit.Owner].ConstructionState.Add(tmpUnit.ProdProcess[k]); + } + } + } + } + else if (tmpUnit.Id == PredefinedData.UnitId.ZuCorruptor) _lZuCorruptor[tmpUnit.Owner].UnitAmount += 1; @@ -3621,8 +3696,24 @@ protected void CountUnits() else if (tmpUnit.Id == PredefinedData.UnitId.ZuOverseerCocoon) + { _lZuOverseerCocoon[tmpUnit.Owner].UnitAmount += 1; + if (tmpUnit.ProdNumberOfQueuedUnits == 0) + { + for (var k = 0; k < tmpUnit.ProdMineralCost.Count; k++) + { + if ( + tmpUnit.ProdUnitProductionId[k].Equals( + PredefinedData.UnitId.ZupUpgradeToOverseer)) + { + _lZuOverseer[tmpUnit.Owner].UnitUnderConstruction += 1; + _lZuOverseer[tmpUnit.Owner].ConstructionState.Add(tmpUnit.ProdProcess[k]); + } + } + } + } + else if (tmpUnit.Id == PredefinedData.UnitId.ZuQueen || tmpUnit.Id == PredefinedData.UnitId.ZuQueenBurrow) @@ -3907,6 +3998,21 @@ protected void CountUnits() } } } + + //Upgrade To Lair + else + { + for (var k = 0; k < tmpUnit.ProdMineralCost.Count; k++) + { + if ( + tmpUnit.ProdUnitProductionId[k].Equals( + PredefinedData.UnitId.ZupUpgradeToLair)) + { + _lZbLair[tmpUnit.Owner].UnitUnderConstruction += 1; + _lZbLair[tmpUnit.Owner].ConstructionState.Add(tmpUnit.ProdProcess[k]); + } + } + } } #endregion @@ -4070,6 +4176,21 @@ protected void CountUnits() } } } + + //Upgrade To Hive + else + { + for (var k = 0; k < tmpUnit.ProdMineralCost.Count; k++) + { + if ( + tmpUnit.ProdUnitProductionId[k].Equals( + PredefinedData.UnitId.ZupUpgradeToHive)) + { + _lZbHive[tmpUnit.Owner].UnitUnderConstruction += 1; + _lZbHive[tmpUnit.Owner].ConstructionState.Add(tmpUnit.ProdProcess[k]); + } + } + } } #endregion @@ -4222,6 +4343,21 @@ protected void CountUnits() } } } + + //Upgrade To Greater Spire + else + { + for (var k = 0; k < tmpUnit.ProdMineralCost.Count; k++) + { + if ( + tmpUnit.ProdUnitProductionId[k].Equals( + PredefinedData.UnitId.ZupUpgradeToGreaterSpire)) + { + _lZbGreaterspire[tmpUnit.Owner].UnitUnderConstruction += 1; + _lZbGreaterspire[tmpUnit.Owner].ConstructionState.Add(tmpUnit.ProdProcess[k]); + } + } + } } #endregion @@ -4839,9 +4975,9 @@ protected void CountUnits() #region Units - else if (tmpUnit.Id == + /*else if (tmpUnit.Id == PredefinedData.UnitId.PuArchon) - _lPuArchon[tmpUnit.Owner].UnitUnderConstruction += 1; + _lPuArchon[tmpUnit.Owner].UnitUnderConstruction += 1;*/ else if (tmpUnit.Id == PredefinedData.UnitId.PuCarrier) diff --git a/AnotherSc2Hack/Classes/FrontEnds/Rendering/ProductionRenderer.cs b/AnotherSc2Hack/Classes/FrontEnds/Rendering/ProductionRenderer.cs index 57ecdc65..5ef47fed 100644 --- a/AnotherSc2Hack/Classes/FrontEnds/Rendering/ProductionRenderer.cs +++ b/AnotherSc2Hack/Classes/FrontEnds/Rendering/ProductionRenderer.cs @@ -378,10 +378,10 @@ protected override void Draw(BufferedGraphics g) clPlayercolor, fStringFont, true); Helper_DrawUnitsProduction(_lTbOrbitalCommand[i], ref iPosX, iPosY, iSize, _imgTbOc, g, - clPlayercolor, fStringFont, true); + clPlayercolor, fStringFont, false); Helper_DrawUnitsProduction(_lTbPlanetaryFortress[i], ref iPosX, iPosY, iSize, _imgTbPf, g, - clPlayercolor, fStringFont, true); + clPlayercolor, fStringFont, false); Helper_DrawUnitsProduction(_lTbSupply[i], ref iPosX, iPosY, iSize, _imgTbSupply, g, clPlayercolor, fStringFont, true); Helper_DrawUnitsProduction(_lTbRefinery[i], ref iPosX, iPosY, diff --git a/AnotherSc2Hack/Classes/FrontEnds/Rendering/UnitRenderer.cs b/AnotherSc2Hack/Classes/FrontEnds/Rendering/UnitRenderer.cs index fe5e8f09..8b124795 100644 --- a/AnotherSc2Hack/Classes/FrontEnds/Rendering/UnitRenderer.cs +++ b/AnotherSc2Hack/Classes/FrontEnds/Rendering/UnitRenderer.cs @@ -396,10 +396,10 @@ protected override void Draw(BufferedGraphics g) clPlayercolor, fStringFont, true); Helper_DrawUnits(_lTbOrbitalCommand[i], ref iPosX, iPosY, iSize, _imgTbOc, g, - clPlayercolor, fStringFont, true); + clPlayercolor, fStringFont, false); Helper_DrawUnits(_lTbPlanetaryFortress[i], ref iPosX, iPosY, iSize, _imgTbPf, g, - clPlayercolor, fStringFont, true); + clPlayercolor, fStringFont, false); Helper_DrawUnits(_lTbSupply[i], ref iPosX, iPosY, iSize, _imgTbSupply, g, clPlayercolor, fStringFont, true); Helper_DrawUnits(_lTbRefinery[i], ref iPosX, iPosY, @@ -475,10 +475,12 @@ protected override void Draw(BufferedGraphics g) clPlayercolor, fStringFont, true); Helper_DrawUnits(_lZbHatchery[i], ref iPosX, iPosY, iSize, _imgZbHatchery, g, clPlayercolor, fStringFont, true); + //Note: Since Lairs/ Hives can not be placed plainly on the ground, we have to hack here + //We'll pretend them to be units so we don't subtract the units in procution from the unitamount Helper_DrawUnits(_lZbLair[i], ref iPosX, iPosY, iSize, _imgZbLair, g, clPlayercolor, - fStringFont, true); + fStringFont, false); Helper_DrawUnits(_lZbHive[i], ref iPosX, iPosY, iSize, _imgZbHive, g, clPlayercolor, - fStringFont, true); + fStringFont, false); Helper_DrawUnits(_lZbSpawningpool[i], ref iPosX, iPosY, iSize, _imgZbSpawningpool, g, clPlayercolor, fStringFont, true); Helper_DrawUnits(_lZbEvochamber[i], ref iPosX, iPosY, iSize, _imgZbEvochamber, g, @@ -496,7 +498,7 @@ protected override void Draw(BufferedGraphics g) Helper_DrawUnits(_lZbSpire[i], ref iPosX, iPosY, iSize, _imgZbSpire, g, clPlayercolor, fStringFont, true); Helper_DrawUnits(_lZbGreaterspire[i], ref iPosX, iPosY, iSize, _imgZbGreaterspire, g, - clPlayercolor, fStringFont, true); + clPlayercolor, fStringFont, false); Helper_DrawUnits(_lZbUltracavern[i], ref iPosX, iPosY, iSize, _imgZbUltracavern, g, clPlayercolor, fStringFont, true); Helper_DrawUnits(_lZbInfestationpit[i], ref iPosX, iPosY, iSize, _imgZbInfestationpit, g, @@ -783,7 +785,7 @@ private void Helper_DrawUnits(PredefinedData.UnitCount unit, ref Int32 posX, Int Int32 result = 0; float fWidthSize = 0f; - /* Unitamount defines all buildings*/ + //Unitamount defines all buildings (applied to buildings actually placed on the map, not Upgrade To Lair and such.. if (isStructure) unit.UnitAmount -= unit.UnitUnderConstruction; @@ -870,6 +872,17 @@ private void Helper_DrawUnits(PredefinedData.UnitCount unit, ref Int32 posX, Int } } + else if (unit.Id.Equals(PredefinedData.UnitId.PuMothership)) + { + foreach (var energy in unit.Energy) + { + var tmp = energy / 4096; + var tmpRes = tmp / 100; + if (tmpRes >= 1) + result += tmpRes; + } + } + #endregion #region Terran diff --git a/AnotherSc2Hack/Properties/AssemblyInfo.cs b/AnotherSc2Hack/Properties/AssemblyInfo.cs index bcefd9b2..3316e203 100644 --- a/AnotherSc2Hack/Properties/AssemblyInfo.cs +++ b/AnotherSc2Hack/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.6.5.2")] -[assembly: AssemblyFileVersion("0.6.5.2")] +[assembly: AssemblyVersion("0.6.6.0")] +[assembly: AssemblyFileVersion("0.6.6.0")] diff --git a/PredefinedTypes/PredefinedTypes.cs b/PredefinedTypes/PredefinedTypes.cs index f92aceb9..4a8297de 100644 --- a/PredefinedTypes/PredefinedTypes.cs +++ b/PredefinedTypes/PredefinedTypes.cs @@ -11,6 +11,9 @@ * Those classes allow you to save codelines and work. * In addition, you can manipulate the elements of a class without any nasty structhacking, making the code more readable. * + * + * + * NOTE: To use this, you have to recompile in Release mode so it get's refreshed (The assembly is pointed to the release version, not debug)! */ using System; @@ -220,6 +223,8 @@ public enum UnitId TupCaduceusReactor, TupDurableMeterials, TupCorvidReactor, + TupUpgradeToOrbital, + TupUpgradeToPlanetary, /* Protoss */ PupAirW1, @@ -246,6 +251,8 @@ public enum UnitId PupWarpGate, PupAnionPulseCrystals, PupGravitonCatapult, + PupUpgradeToMothership, + PupUpgradeToArchon, /* Zerg */ ZupAirA1, @@ -277,6 +284,11 @@ public enum UnitId ZupPneumatizedCarapace, ZupTunnelingClaws, ZupVentralSacs, + ZupUpgradeToLair, + ZupUpgradeToHive, + ZupUpgradeToGreaterSpire, + ZupUpgradeToBroodlord, + ZupUpgradeToOverseer, }; diff --git a/PredefinedTypes/Properties/AssemblyInfo.cs b/PredefinedTypes/Properties/AssemblyInfo.cs index b7973c4f..06b399e0 100644 --- a/PredefinedTypes/Properties/AssemblyInfo.cs +++ b/PredefinedTypes/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.2.2")] -[assembly: AssemblyFileVersion("1.0.2.2")] +[assembly: AssemblyVersion("1.0.3.0")] +[assembly: AssemblyFileVersion("1.0.3.0")]