From 8362782b6bf4e14f649a2a8f7e30de582b5b4c9b Mon Sep 17 00:00:00 2001 From: ChrisLv <12737@live.com> Date: Sun, 25 Sep 2022 11:15:45 +0700 Subject: [PATCH 01/11] =?UTF-8?q?=E6=89=A9=E5=B1=95TechnoScriptable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ComponentHooks/TechnoComponent.cs | 209 ++++++++++++++++-- Projects/Extension.Script/TechnoScriptable.cs | 24 +- 2 files changed, 213 insertions(+), 20 deletions(-) diff --git a/ComponentHooks/TechnoComponent.cs b/ComponentHooks/TechnoComponent.cs index 6a97f98..5943ea5 100644 --- a/ComponentHooks/TechnoComponent.cs +++ b/ComponentHooks/TechnoComponent.cs @@ -21,15 +21,14 @@ static public unsafe UInt32 TechnoClass_Update_Components(REGISTERS* R) TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); ext.GameObject.Foreach(c => c.OnUpdate()); - - return 0; } catch (Exception e) { Logger.PrintException(e); - return 0; } + return 0; } + [Hook(HookType.AresHook, Address = 0x6FAFFD, Size = 7)] [Hook(HookType.AresHook, Address = 0x6FAF7A, Size = 7)] static public unsafe UInt32 TechnoClass_LateUpdate_Components(REGISTERS* R) @@ -40,15 +39,36 @@ static public unsafe UInt32 TechnoClass_LateUpdate_Components(REGISTERS* R) TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); ext.GameObject.Foreach(c => c.OnLateUpdate()); + } + catch (Exception e) + { + Logger.PrintException(e); + } + return 0; + } + + [Hook(HookType.AresHook, Address = 0x71A88D, Size = 0)] + public static unsafe UInt32 TemporalClass_UpdateA(REGISTERS* R) + { + try + { + Pointer pTemporal = (IntPtr)R->ESI; - return 0; + Pointer pTechno = pTemporal.Ref.Target; + TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); + ext.GameObject.Foreach(c => (c as ITechnoScriptable)?.OnTemporalUpdate(pTemporal)); } catch (Exception e) { Logger.PrintException(e); - return 0; } + if ((int)R->EAX <= (int)R->EBX) + { + return 0x71A895; + } + return 0x71AB08; } + [Hook(HookType.AresHook, Address = 0x6F6CA0, Size = 7)] static public unsafe UInt32 TechnoClass_Put_Components(REGISTERS* R) { @@ -56,19 +76,18 @@ static public unsafe UInt32 TechnoClass_Put_Components(REGISTERS* R) { Pointer pTechno = (IntPtr)R->ECX; var pCoord = R->Stack>(0x4); - var faceDir = R->Stack(0x8); + var faceDir = R->Stack(0x8); TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); ext.GameObject.Foreach(c => (c as IObjectScriptable)?.OnPut(pCoord.Data, faceDir)); - - return 0; } catch (Exception e) { Logger.PrintException(e); - return 0; } + return 0; } + // avoid hook conflict with phobos feature -- shield //[Hook(HookType.AresHook, Address = 0x6F6AC0, Size = 5)] [Hook(HookType.AresHook, Address = 0x6F6AC4, Size = 5)] @@ -80,15 +99,14 @@ static public unsafe UInt32 TechnoClass_Remove_Components(REGISTERS* R) TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); ext.GameObject.Foreach(c => (c as IObjectScriptable)?.OnRemove()); - - return 0; } catch (Exception e) { Logger.PrintException(e); - return 0; } + return 0; } + [Hook(HookType.AresHook, Address = 0x701900, Size = 6)] static public unsafe UInt32 TechnoClass_ReceiveDamage_Components(REGISTERS* R) { @@ -105,15 +123,79 @@ static public unsafe UInt32 TechnoClass_ReceiveDamage_Components(REGISTERS* R) TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); ext.GameObject.Foreach(c => (c as IObjectScriptable)?.OnReceiveDamage(pDamage, distanceFromEpicenter, pWH, pAttacker, ignoreDefenses, preventPassengerEscape, pAttackingHouse)); + } + catch (Exception e) + { + Logger.PrintException(e); + } + return 0; + } - return 0; + // if (pDamage >= 0 && pDamage < 1) pDamage = 1; // ╮(-△-)╭ + [Hook(HookType.AresHook, Address = 0x7019DD, Size = 6)] + public static unsafe UInt32 TechnoClass_ReceiveDamage_AtLeast1(REGISTERS* R) + { + // var pDamage = (Pointer)R->EBX; + // Logger.Log($"{Game.CurrentFrame} - 免疫伤害, {pDamage.Ref}"); + // Pointer pTechno = (IntPtr)R->ECX; + // TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); + // if (ext.DamageReactionState.IsActive()) + // { + return 0x7019E3; + // } + // return 0; + } + + + // after TakeDamage + [Hook(HookType.AresHook, Address = 0x701DFF, Size = 7)] + public static unsafe UInt32 TechnoClass_ReceiveDamage2(REGISTERS* R) + { + try + { + Pointer pTechno = (IntPtr)R->ESI; + Pointer pRealDamage = (IntPtr)R->EBX; + Pointer pWH = (IntPtr)R->EBP; + DamageState damageState = (DamageState)R->EDI; + + TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); + ext.GameObject.Foreach(c => (c as IObjectScriptable)?.OnReceiveDamage2(pRealDamage, pWH, damageState)); + } + catch (Exception e) + { + Logger.PrintException(e); + } + return 0; + } + + [Hook(HookType.AresHook, Address = 0x6FC339, Size = 6)] + public static unsafe UInt32 TechnoClass_CanFire_Components(REGISTERS* R) + { + try + { + Pointer pTechno = (IntPtr)R->ESI; + Pointer pWeapon = (IntPtr)R->EDI; + var pTarget = R->Stack>(0x20 - (-0x4)); + + TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); + bool ceaseFire = false; + if (!ceaseFire) + { + ext.GameObject.Foreach(c => (c as ITechnoScriptable)?.CanFire(pTarget, pWeapon, ref ceaseFire)); + } + if (ceaseFire) + { + // Logger.Log($"{Game.CurrentFrame} {pTechno} [{pTechno.Ref.Type.Ref.Base.Base.ID}] cease fire !!!"); + return 0x6FCB7E; + } } catch (Exception e) { Logger.PrintException(e); - return 0; } + return 0; } + [Hook(HookType.AresHook, Address = 0x6FDD50, Size = 6)] static public unsafe UInt32 TechnoClass_Fire_Components(REGISTERS* R) { @@ -126,13 +208,54 @@ static public unsafe UInt32 TechnoClass_Fire_Components(REGISTERS* R) TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); ext.GameObject.Foreach(c => (c as ITechnoScriptable)?.OnFire(pTarget, nWeaponIndex)); - return 0; } catch (Exception e) { Logger.PrintException(e); - return 0; } + return 0; + } + + [Hook(HookType.AresHook, Address = 0x6F65D1, Size = 6)] + public static unsafe UInt32 TechnoClass_DrawHealthBar_Building(REGISTERS* R) + { + try + { + Pointer pTechno = (IntPtr)R->ESI; + + int length = (int)R->EBX; + Pointer pLocation = R->Stack(0x4C - (-0x4)); + Pointer pBound = R->Stack(0x4C - (-0x8)); + + TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); + ext.GameObject.Foreach(c => (c as ITechnoScriptable)?.DrawHealthBar(length, pLocation, pBound, true)); + } + catch (Exception e) + { + Logger.PrintException(e); + } + return 0; + } + + [Hook(HookType.AresHook, Address = 0x6F683C, Size = 7)] + public static unsafe UInt32 TechnoClass_DrawHealthBar_Other(REGISTERS* R) + { + try + { + Pointer pTechno = (IntPtr)R->ESI; + + int length = pTechno.Ref.Base.Base.WhatAmI() == AbstractType.Infantry ? 8 : 17; + Pointer pLocation = R->Stack(0x4C - (-0x4)); + Pointer pBound = R->Stack(0x4C - (-0x8)); + + TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); + ext.GameObject.Foreach(c => (c as ITechnoScriptable)?.DrawHealthBar(length, pLocation, pBound, false)); + } + catch (Exception e) + { + Logger.PrintException(e); + } + return 0; } #region Render @@ -142,14 +265,12 @@ static public UInt32 TechnoClass_Render_Components(Pointer pTechno) { TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); ext.GameObject.Foreach(c => c.OnRender()); - - return 0; } catch (Exception e) { Logger.PrintException(e); - return 0; } + return 0; } [Hook(HookType.AresHook, Address = 0x4144B0, Size = 5)] static public unsafe UInt32 AircraftClass_Render_Components(REGISTERS* R) @@ -176,5 +297,55 @@ static public unsafe UInt32 UnitClass_Render_Components(REGISTERS* R) return TechnoClass_Render_Components(pUnit.Convert()); } #endregion + + [Hook(HookType.AresHook, Address = 0x5F45A0, Size = 5)] + public static unsafe UInt32 TechnoClass_Select(REGISTERS* R) + { + try + { + Pointer pTechno = (IntPtr)R->EDI; + // Logger.Log("{0} Select", pTechno.IsNull ? "Unknow" : pTechno.Ref.Type.Ref.Base.Base.ID); + TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); + bool selectable = true; + + ext.GameObject.Foreach(c => (c as ITechnoScriptable)?.OnSelect(ref selectable)); + if (!selectable) + { + return 0x5F45A9; + } + } + catch (Exception e) + { + Logger.PrintException(e); + } + return 0; + } + + + [Hook(HookType.AresHook, Address = 0x730E8F, Size = 6)] + public static unsafe UInt32 ObjectClass_GuardCommand(REGISTERS* R) + { + Pointer pObject = (IntPtr)R->ESI; + if (pObject.CastToTechno(out Pointer pTechno)) + { + // Logger.Log("{0} Guard Command", pTechno.IsNull ? "Unknow" : pTechno.Ref.Type.Ref.Base.Base.ID); + TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); + ext.GameObject.Foreach(c => (c as ITechnoScriptable)?.OnGuardCommand()); + } + return 0; + } + + [Hook(HookType.AresHook, Address = 0x730F1C, Size = 5)] + public static unsafe UInt32 ObjectClass_StopCommand(REGISTERS* R) + { + Pointer pObject = (IntPtr)R->ESI; + if (pObject.CastToTechno(out Pointer pTechno)) + { + // Logger.Log("{0} Stop Command", pTechno.IsNull ? "Unknow" : pTechno.Ref.Type.Ref.Base.Base.ID); + TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); + ext.GameObject.Foreach(c => (c as ITechnoScriptable)?.OnStopCommand()); + } + return 0; + } } } diff --git a/Projects/Extension.Script/TechnoScriptable.cs b/Projects/Extension.Script/TechnoScriptable.cs index 7bf99f3..9ba2f21 100644 --- a/Projects/Extension.Script/TechnoScriptable.cs +++ b/Projects/Extension.Script/TechnoScriptable.cs @@ -10,7 +10,17 @@ namespace Extension.Script { public interface ITechnoScriptable : IObjectScriptable { + + void OnTemporalUpdate(Pointer pTemporal); + + void CanFire(Pointer pTarget, Pointer pWeapon, ref bool ceaseFire); void OnFire(Pointer pTarget, int weaponIndex); + + void OnSelect(ref bool selectable); + void DrawHealthBar(int barLength, Pointer pPos, Pointer pBound, bool isBuilding); + + void OnGuardCommand(); + void OnStopCommand(); } [Serializable] @@ -20,13 +30,25 @@ public TechnoScriptable(TechnoExt owner) : base(owner) { } - public virtual void OnPut(CoordStruct coord, Direction faceDir) { } + protected Pointer pTechno => Owner.OwnerObject; + protected string section => pTechno.Ref.Type.Ref.Base.Base.ID; + + public virtual void OnTemporalUpdate(Pointer pTemporal) { } + + public virtual void OnPut(CoordStruct coord, short dirType) { } public virtual void OnRemove() { } public virtual void OnReceiveDamage(Pointer pDamage, int DistanceFromEpicenter, Pointer pWH, Pointer pAttacker, bool IgnoreDefenses, bool PreventPassengerEscape, Pointer pAttackingHouse) { } + public virtual void OnReceiveDamage2(Pointer pRealDamage, Pointer pWH, DamageState damageState) { } + public virtual void CanFire(Pointer pTarget, Pointer pWeapon, ref bool ceaseFire) { } public virtual void OnFire(Pointer pTarget, int weaponIndex) { } + + public virtual void OnSelect(ref bool selectable) { } + public virtual void DrawHealthBar(int barLength, Pointer pPos, Pointer pBound, bool isBuilding) { } + public virtual void OnGuardCommand() { } + public virtual void OnStopCommand() { } } } From 226e302b4ec90ede08ec8d22fa2ec42106a96513 Mon Sep 17 00:00:00 2001 From: ChrisLv <12737@live.com> Date: Sun, 25 Sep 2022 17:21:30 +0700 Subject: [PATCH 02/11] =?UTF-8?q?=E8=A1=A5=E5=85=85TechnoClass=5FReceiveDa?= =?UTF-8?q?mage2=E7=9A=84=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ComponentHooks/TechnoComponent.cs | 21 ++++--------------- Projects/Extension.Script/BulletScriptable.cs | 11 +++++++++- Projects/Extension.Script/IScriptable.cs | 4 +++- Projects/Extension.Script/TechnoScriptable.cs | 4 +++- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ComponentHooks/TechnoComponent.cs b/ComponentHooks/TechnoComponent.cs index 5943ea5..c801d78 100644 --- a/ComponentHooks/TechnoComponent.cs +++ b/ComponentHooks/TechnoComponent.cs @@ -131,22 +131,6 @@ static public unsafe UInt32 TechnoClass_ReceiveDamage_Components(REGISTERS* R) return 0; } - // if (pDamage >= 0 && pDamage < 1) pDamage = 1; // ╮(-△-)╭ - [Hook(HookType.AresHook, Address = 0x7019DD, Size = 6)] - public static unsafe UInt32 TechnoClass_ReceiveDamage_AtLeast1(REGISTERS* R) - { - // var pDamage = (Pointer)R->EBX; - // Logger.Log($"{Game.CurrentFrame} - 免疫伤害, {pDamage.Ref}"); - // Pointer pTechno = (IntPtr)R->ECX; - // TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); - // if (ext.DamageReactionState.IsActive()) - // { - return 0x7019E3; - // } - // return 0; - } - - // after TakeDamage [Hook(HookType.AresHook, Address = 0x701DFF, Size = 7)] public static unsafe UInt32 TechnoClass_ReceiveDamage2(REGISTERS* R) @@ -158,8 +142,11 @@ public static unsafe UInt32 TechnoClass_ReceiveDamage2(REGISTERS* R) Pointer pWH = (IntPtr)R->EBP; DamageState damageState = (DamageState)R->EDI; + Pointer pAttacker = R->Stack>(0xD4); + Pointer pAttackingHouse = R->Stack>(0xE0); + TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); - ext.GameObject.Foreach(c => (c as IObjectScriptable)?.OnReceiveDamage2(pRealDamage, pWH, damageState)); + ext.GameObject.Foreach(c => (c as IObjectScriptable)?.OnReceiveDamage2(pRealDamage, pWH, damageState, pAttacker, pAttackingHouse)); } catch (Exception e) { diff --git a/Projects/Extension.Script/BulletScriptable.cs b/Projects/Extension.Script/BulletScriptable.cs index b8bd63e..a7e1034 100644 --- a/Projects/Extension.Script/BulletScriptable.cs +++ b/Projects/Extension.Script/BulletScriptable.cs @@ -21,8 +21,11 @@ public BulletScriptable(BulletExt owner) : base(owner) { } + protected Pointer pBullet => Owner.OwnerObject; + protected string section => pBullet.Ref.Type.Ref.Base.Base.ID; + [Obsolete("not support OnPut in BulletScriptable yet", true)] - public void OnPut(CoordStruct coord, Direction faceDir) + public void OnPut(CoordStruct coord, short dirType) { throw new NotSupportedException("not support OnPut in BulletScriptable yet"); } @@ -37,6 +40,12 @@ public void OnReceiveDamage(Pointer pDamage, int DistanceFromEpicenter, Poi { throw new NotSupportedException("not support OnReceiveDamage in BulletScriptable yet"); } + [Obsolete("not support OnReceiveDamage in BulletScriptable yet", true)] + public void OnReceiveDamage2(Pointer pRealDamage, Pointer pWH, DamageState damageState, + Pointer pAttacker, Pointer pAttackingHouse) + { + throw new NotSupportedException("not support OnReceiveDamage in BulletScriptable yet"); + } public virtual void OnDetonate(Pointer pCoords) { } } diff --git a/Projects/Extension.Script/IScriptable.cs b/Projects/Extension.Script/IScriptable.cs index 0640a3e..926bcba 100644 --- a/Projects/Extension.Script/IScriptable.cs +++ b/Projects/Extension.Script/IScriptable.cs @@ -15,10 +15,12 @@ public interface IAbstractScriptable : IScriptable public interface IObjectScriptable : IAbstractScriptable { - void OnPut(CoordStruct coord, Direction faceDir); + void OnPut(CoordStruct coord, short dirType); void OnRemove(); void OnReceiveDamage(Pointer pDamage, int DistanceFromEpicenter, Pointer pWH, Pointer pAttacker, bool IgnoreDefenses, bool PreventPassengerEscape, Pointer pAttackingHouse); + void OnReceiveDamage2(Pointer pRealDamage, Pointer pWH, DamageState damageState, + Pointer pAttacker, Pointer pAttackingHouse); } diff --git a/Projects/Extension.Script/TechnoScriptable.cs b/Projects/Extension.Script/TechnoScriptable.cs index 9ba2f21..986258f 100644 --- a/Projects/Extension.Script/TechnoScriptable.cs +++ b/Projects/Extension.Script/TechnoScriptable.cs @@ -40,7 +40,9 @@ public virtual void OnRemove() { } public virtual void OnReceiveDamage(Pointer pDamage, int DistanceFromEpicenter, Pointer pWH, Pointer pAttacker, bool IgnoreDefenses, bool PreventPassengerEscape, Pointer pAttackingHouse) { } - public virtual void OnReceiveDamage2(Pointer pRealDamage, Pointer pWH, DamageState damageState) { } + public virtual void OnReceiveDamage2(Pointer pRealDamage, Pointer pWH, DamageState damageState, + Pointer pAttacker, Pointer pAttackingHouse) + { } public virtual void CanFire(Pointer pTarget, Pointer pWeapon, ref bool ceaseFire) { } public virtual void OnFire(Pointer pTarget, int weaponIndex) { } From de5fa1f24358ff08d8ad46ee3abae243e21638ed Mon Sep 17 00:00:00 2001 From: ChrisLv <12737@live.com> Date: Mon, 26 Sep 2022 11:37:49 +0700 Subject: [PATCH 03/11] =?UTF-8?q?=E8=A1=A5=E5=85=85TechnoClass=5FReceiveDa?= =?UTF-8?q?mage=5FDestroy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ComponentHooks/TechnoComponent.cs | 19 +++++++++++++++++++ Projects/Extension.Script/BulletScriptable.cs | 5 +++++ Projects/Extension.Script/IScriptable.cs | 1 + Projects/Extension.Script/TechnoScriptable.cs | 1 + 4 files changed, 26 insertions(+) diff --git a/ComponentHooks/TechnoComponent.cs b/ComponentHooks/TechnoComponent.cs index c801d78..6816ecf 100644 --- a/ComponentHooks/TechnoComponent.cs +++ b/ComponentHooks/TechnoComponent.cs @@ -155,6 +155,25 @@ public static unsafe UInt32 TechnoClass_ReceiveDamage2(REGISTERS* R) return 0; } + // TakeDamage to destroy + [Hook(HookType.AresHook, Address = 0x702050, Size = 6)] + public static unsafe UInt32 TechnoClass_ReceiveDamage_Destroy(REGISTERS* R) + { + try + { + Pointer pTechno = (IntPtr)R->ESI; + TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); + // Logger.Log($"{Game.CurrentFrame} - 单位 {pTechno} {pTechno.Ref.Type.Ref.Base.Base.ID} 受伤害死亡, 所属 {pTechno.Ref.Owner}"); + ext.GameObject.Foreach(c => (c as IObjectScriptable)?.OnReceiveDamageDestroy()); + + } + catch (Exception e) + { + Logger.PrintException(e); + } + return 0; + } + [Hook(HookType.AresHook, Address = 0x6FC339, Size = 6)] public static unsafe UInt32 TechnoClass_CanFire_Components(REGISTERS* R) { diff --git a/Projects/Extension.Script/BulletScriptable.cs b/Projects/Extension.Script/BulletScriptable.cs index a7e1034..841463a 100644 --- a/Projects/Extension.Script/BulletScriptable.cs +++ b/Projects/Extension.Script/BulletScriptable.cs @@ -46,6 +46,11 @@ public void OnReceiveDamage2(Pointer pRealDamage, Pointer { throw new NotSupportedException("not support OnReceiveDamage in BulletScriptable yet"); } + [Obsolete("not support OnReceiveDamage in BulletScriptable yet", true)] + public void OnReceiveDamageDestroy() + { + throw new NotSupportedException("not support OnReceiveDamage in BulletScriptable yet"); + } public virtual void OnDetonate(Pointer pCoords) { } } diff --git a/Projects/Extension.Script/IScriptable.cs b/Projects/Extension.Script/IScriptable.cs index 926bcba..bde0a6b 100644 --- a/Projects/Extension.Script/IScriptable.cs +++ b/Projects/Extension.Script/IScriptable.cs @@ -21,6 +21,7 @@ void OnReceiveDamage(Pointer pDamage, int DistanceFromEpicenter, Pointer pAttacker, bool IgnoreDefenses, bool PreventPassengerEscape, Pointer pAttackingHouse); void OnReceiveDamage2(Pointer pRealDamage, Pointer pWH, DamageState damageState, Pointer pAttacker, Pointer pAttackingHouse); + void OnReceiveDamageDestroy(); } diff --git a/Projects/Extension.Script/TechnoScriptable.cs b/Projects/Extension.Script/TechnoScriptable.cs index 986258f..8f3e1cc 100644 --- a/Projects/Extension.Script/TechnoScriptable.cs +++ b/Projects/Extension.Script/TechnoScriptable.cs @@ -43,6 +43,7 @@ public virtual void OnReceiveDamage(Pointer pDamage, int DistanceFromEpicen public virtual void OnReceiveDamage2(Pointer pRealDamage, Pointer pWH, DamageState damageState, Pointer pAttacker, Pointer pAttackingHouse) { } + public virtual void OnReceiveDamageDestroy() { } public virtual void CanFire(Pointer pTarget, Pointer pWeapon, ref bool ceaseFire) { } public virtual void OnFire(Pointer pTarget, int weaponIndex) { } From 8716dc66935e591862da559e18337d3e68dee5fa Mon Sep 17 00:00:00 2001 From: ChrisLv <12737@live.com> Date: Tue, 27 Sep 2022 04:12:07 +0700 Subject: [PATCH 04/11] =?UTF-8?q?=E6=9C=AA=E6=A0=87=E8=AE=B0=E4=B8=BA?= =?UTF-8?q?=E5=8F=AF=E5=BA=8F=E5=88=97=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/Extension/Components/YRTransform.cs | 1 + Projects/Extension/INI/INIConfig.cs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Projects/Extension/Components/YRTransform.cs b/Projects/Extension/Components/YRTransform.cs index 6db6b89..e07cbb1 100644 --- a/Projects/Extension/Components/YRTransform.cs +++ b/Projects/Extension/Components/YRTransform.cs @@ -11,6 +11,7 @@ namespace Extension.Components { + [Serializable] internal class YRTransform : Transform { public YRTransform(IExtension extension) diff --git a/Projects/Extension/INI/INIConfig.cs b/Projects/Extension/INI/INIConfig.cs index f57135f..908a5fd 100644 --- a/Projects/Extension/INI/INIConfig.cs +++ b/Projects/Extension/INI/INIConfig.cs @@ -37,6 +37,7 @@ public interface IConfigWrapper where T : INIConfig T Data { get; } } + [Serializable] public abstract class INIConfig { /// @@ -46,6 +47,7 @@ public abstract class INIConfig public abstract void Read(IConfigReader ini); } + [Serializable] public abstract class INIAutoConfig : INIConfig { public sealed override void Read(IConfigReader ini) From 964df980f1b630c4ae6ad7d37f2fc358662d4572 Mon Sep 17 00:00:00 2001 From: ChrisLv <12737@live.com> Date: Mon, 3 Oct 2022 22:59:41 +0700 Subject: [PATCH 05/11] =?UTF-8?q?=E5=A2=9E=E5=8A=A0TechnoClass=E7=9A=84=20?= =?UTF-8?q?RenderEnd=20=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ComponentHooks/TechnoComponent.cs | 41 ++++++++++++++++++++++ Projects/Extension/Components/Component.cs | 4 ++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/ComponentHooks/TechnoComponent.cs b/ComponentHooks/TechnoComponent.cs index 6816ecf..9acad05 100644 --- a/ComponentHooks/TechnoComponent.cs +++ b/ComponentHooks/TechnoComponent.cs @@ -304,6 +304,47 @@ static public unsafe UInt32 UnitClass_Render_Components(REGISTERS* R) } #endregion + #region After Render + public static UInt32 TechnoClass_Render2(Pointer pTechno) + { + try + { + TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); + ext.GameObject.Foreach(c => c.OnRenderEnd()); + } + catch (Exception e) + { + Logger.PrintException(e); + } + return 0; + } + [Hook(HookType.AresHook, Address = 0x4149F0, Size = 5)] + public static unsafe UInt32 AircraftClass_Render2(REGISTERS* R) + { + Pointer pAircraft = (IntPtr)R->ECX; + return TechnoClass_Render2(pAircraft.Convert()); + } + // Not supported and do not need this. + // [Hook(HookType.AresHook, Address = 0x43DA6C, Size = 7)] + // public static unsafe UInt32 BuildingClass_Render2(REGISTERS* R) + // { + // Pointer pBuilding = (IntPtr)R->ECX; + // return TechnoClass_Render2(pBuilding.Convert()); + // } + [Hook(HookType.AresHook, Address = 0x51961A, Size = 5)] + public static unsafe UInt32 InfantryClass_Render2(REGISTERS* R) + { + Pointer pInfantry = (IntPtr)R->ECX; + return TechnoClass_Render2(pInfantry.Convert()); + } + [Hook(HookType.AresHook, Address = 0x73D410, Size = 5)] + public static unsafe UInt32 UnitClass_Render2(REGISTERS* R) + { + Pointer pUnit = (IntPtr)R->ECX; + return TechnoClass_Render2(pUnit.Convert()); + } + #endregion + [Hook(HookType.AresHook, Address = 0x5F45A0, Size = 5)] public static unsafe UInt32 TechnoClass_Select(REGISTERS* R) { diff --git a/Projects/Extension/Components/Component.cs b/Projects/Extension/Components/Component.cs index 631d388..c21d81a 100644 --- a/Projects/Extension/Components/Component.cs +++ b/Projects/Extension/Components/Component.cs @@ -161,7 +161,9 @@ public virtual void OnLateUpdate() } public virtual void OnRender() { - + } + public virtual void OnRenderEnd() + { } public virtual void OnDestroy() { From cce789598abc590083b28ab40847f8617875fe6c Mon Sep 17 00:00:00 2001 From: ChrisLv <12737@live.com> Date: Mon, 3 Oct 2022 23:19:12 +0700 Subject: [PATCH 06/11] =?UTF-8?q?=E5=B0=86=20Put=20=E7=9A=84=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E7=B1=BB=E5=9E=8B=E6=94=B9=E4=B8=BA=E6=8C=87=E9=92=88?= =?UTF-8?q?=E5=92=8C=E6=9E=9A=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ComponentHooks/TechnoComponent.cs | 6 +++--- Projects/Extension.Script/BulletScriptable.cs | 2 +- Projects/Extension.Script/IScriptable.cs | 2 +- Projects/Extension.Script/TechnoScriptable.cs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ComponentHooks/TechnoComponent.cs b/ComponentHooks/TechnoComponent.cs index 9acad05..c369e04 100644 --- a/ComponentHooks/TechnoComponent.cs +++ b/ComponentHooks/TechnoComponent.cs @@ -75,11 +75,11 @@ static public unsafe UInt32 TechnoClass_Put_Components(REGISTERS* R) try { Pointer pTechno = (IntPtr)R->ECX; - var pCoord = R->Stack>(0x4); - var faceDir = R->Stack(0x8); + Pointer pCoord = R->Stack>(0x4); + DirType faceDir = R->Stack(0x8); TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); - ext.GameObject.Foreach(c => (c as IObjectScriptable)?.OnPut(pCoord.Data, faceDir)); + ext.GameObject.Foreach(c => (c as IObjectScriptable)?.OnPut(pCoord, faceDir)); } catch (Exception e) { diff --git a/Projects/Extension.Script/BulletScriptable.cs b/Projects/Extension.Script/BulletScriptable.cs index 841463a..09d3f97 100644 --- a/Projects/Extension.Script/BulletScriptable.cs +++ b/Projects/Extension.Script/BulletScriptable.cs @@ -25,7 +25,7 @@ public BulletScriptable(BulletExt owner) : base(owner) protected string section => pBullet.Ref.Type.Ref.Base.Base.ID; [Obsolete("not support OnPut in BulletScriptable yet", true)] - public void OnPut(CoordStruct coord, short dirType) + public void OnPut(Pointer pLocation, DirType dirType) { throw new NotSupportedException("not support OnPut in BulletScriptable yet"); } diff --git a/Projects/Extension.Script/IScriptable.cs b/Projects/Extension.Script/IScriptable.cs index bde0a6b..04d5979 100644 --- a/Projects/Extension.Script/IScriptable.cs +++ b/Projects/Extension.Script/IScriptable.cs @@ -15,7 +15,7 @@ public interface IAbstractScriptable : IScriptable public interface IObjectScriptable : IAbstractScriptable { - void OnPut(CoordStruct coord, short dirType); + void OnPut(Pointer pLocation, DirType dirType); void OnRemove(); void OnReceiveDamage(Pointer pDamage, int DistanceFromEpicenter, Pointer pWH, Pointer pAttacker, bool IgnoreDefenses, bool PreventPassengerEscape, Pointer pAttackingHouse); diff --git a/Projects/Extension.Script/TechnoScriptable.cs b/Projects/Extension.Script/TechnoScriptable.cs index 8f3e1cc..1a244a6 100644 --- a/Projects/Extension.Script/TechnoScriptable.cs +++ b/Projects/Extension.Script/TechnoScriptable.cs @@ -35,7 +35,7 @@ public TechnoScriptable(TechnoExt owner) : base(owner) public virtual void OnTemporalUpdate(Pointer pTemporal) { } - public virtual void OnPut(CoordStruct coord, short dirType) { } + public virtual void OnPut(Pointer pLocation, DirType dirType) { } public virtual void OnRemove() { } public virtual void OnReceiveDamage(Pointer pDamage, int DistanceFromEpicenter, Pointer pWH, Pointer pAttacker, bool IgnoreDefenses, bool PreventPassengerEscape, Pointer pAttackingHouse) From 41233d25586e39235caf364aea7957d9837d48eb Mon Sep 17 00:00:00 2001 From: ChrisLv <12737@live.com> Date: Mon, 3 Oct 2022 23:59:21 +0700 Subject: [PATCH 07/11] =?UTF-8?q?=E5=A2=9E=E5=8A=A0TechnoClass=E5=92=8CBul?= =?UTF-8?q?letClass=E7=9A=84OnInit()=20=E5=92=8C=20OnUnInit()=20=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ComponentHooks/BulletComponent.cs | 35 +++++++++++++++++++ ComponentHooks/TechnoComponent.cs | 16 +++++++++ ExtensionHooks/BulletExt.cs | 14 +++++++- ExtensionHooks/TechnoExt.cs | 14 +++++++- Projects/Extension.Script/AnimScriptable.cs | 12 ++++++- Projects/Extension.Script/BulletScriptable.cs | 10 +++--- Projects/Extension.Script/IScriptable.cs | 2 ++ .../Extension.Script/SuperWeaponScriptable.cs | 3 ++ Projects/Extension.Script/TechnoScriptable.cs | 3 ++ 9 files changed, 101 insertions(+), 8 deletions(-) diff --git a/ComponentHooks/BulletComponent.cs b/ComponentHooks/BulletComponent.cs index c483167..e7735ba 100644 --- a/ComponentHooks/BulletComponent.cs +++ b/ComponentHooks/BulletComponent.cs @@ -50,6 +50,41 @@ public static unsafe UInt32 BulletClass_LateUpdate_Components(REGISTERS* R) } } + [Hook(HookType.AresHook, Address = 0x466556, Size = 6)] + public static unsafe UInt32 BulletClass_Init(REGISTERS* R) + { + try + { + Pointer pBullet = (IntPtr)R->ECX; + BulletExt ext = BulletExt.ExtMap.Find(pBullet); + // Logger.Log("BulletExt init {0}", ext == null?"Ext is null":"is ready."); + ext.GameObject.Foreach(c => (c as IBulletScriptable)?.OnInit()); + } + catch (Exception e) + { + Logger.PrintException(e); + } + return (uint)0; + } + + [Hook(HookType.AresHook, Address = 0x468B5D, Size = 6)] + public static unsafe UInt32 BulletClass_Put(REGISTERS* R) + { + try + { + Pointer pBullet = (IntPtr)R->EBX; + BulletExt ext = BulletExt.ExtMap.Find(pBullet); + Pointer pCoord = R->Stack(-0x20); + // Logger.Log("BulletExt init {0} {1}", ext == null?"Ext is null":"is ready.", pCoord.Data); + ext.GameObject.Foreach(c => (c as IBulletScriptable)?.OnPut(pCoord, default)); + } + catch (Exception e) + { + Logger.PrintException(e); + } + return (uint)0; + } + [Hook(HookType.AresHook, Address = 0x4690B0, Size = 6)] public static unsafe UInt32 BulletClass_Detonate_Components(REGISTERS* R) { diff --git a/ComponentHooks/TechnoComponent.cs b/ComponentHooks/TechnoComponent.cs index c369e04..21044a3 100644 --- a/ComponentHooks/TechnoComponent.cs +++ b/ComponentHooks/TechnoComponent.cs @@ -12,6 +12,22 @@ namespace ComponentHooks { public class TechnoComponentHooks { + [Hook(HookType.AresHook, Address = 0x6F42ED, Size = 10)] + public static unsafe UInt32 TechnoClass_Init(REGISTERS* R) + { + try + { + Pointer pTechno = (IntPtr)R->ESI; + TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); + ext.GameObject.Foreach(c => (c as ITechnoScriptable)?.OnInit()); + } + catch (Exception e) + { + Logger.PrintException(e); + } + return 0; + } + [Hook(HookType.AresHook, Address = 0x6F9E50, Size = 5)] static public unsafe UInt32 TechnoClass_Update_Components(REGISTERS* R) { diff --git a/ExtensionHooks/BulletExt.cs b/ExtensionHooks/BulletExt.cs index 06b6e75..f9db08e 100644 --- a/ExtensionHooks/BulletExt.cs +++ b/ExtensionHooks/BulletExt.cs @@ -7,6 +7,7 @@ using PatcherYRpp; using Extension.Ext; using Extension.Script; +using Extension.Utilities; namespace ExtensionHooks { @@ -21,9 +22,20 @@ public static unsafe UInt32 BulletClass_CTOR(REGISTERS* R) [Hook(HookType.AresHook, Address = 0x4665E9, Size = 0xA)] public static unsafe UInt32 BulletClass_DTOR(REGISTERS* R) { + try + { + Pointer pBullet = (IntPtr)R->ESI; + + BulletExt ext = BulletExt.ExtMap.Find(pBullet); + ext.GameObject.Foreach(c => (c as IObjectScriptable)?.OnUnInit()); + } + catch (Exception e) + { + Logger.PrintException(e); + } return BulletExt.BulletClass_DTOR(R); } - + [Hook(HookType.AresHook, Address = 0x46AFB0, Size = 8)] [Hook(HookType.AresHook, Address = 0x46AE70, Size = 5)] public static unsafe UInt32 BulletClass_SaveLoad_Prefix(REGISTERS* R) diff --git a/ExtensionHooks/TechnoExt.cs b/ExtensionHooks/TechnoExt.cs index 904b7e6..86e5642 100644 --- a/ExtensionHooks/TechnoExt.cs +++ b/ExtensionHooks/TechnoExt.cs @@ -6,6 +6,7 @@ using DynamicPatcher; using PatcherYRpp; using Extension.Ext; +using Extension.Utilities; using Extension.Script; namespace ExtensionHooks @@ -21,9 +22,20 @@ static public unsafe UInt32 TechnoClass_CTOR(REGISTERS* R) [Hook(HookType.AresHook, Address = 0x6F4500, Size = 5)] static public unsafe UInt32 TechnoClass_DTOR(REGISTERS* R) { + try + { + Pointer pTechno = (IntPtr)R->ECX; + + TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); + ext.GameObject.Foreach(c => (c as IObjectScriptable)?.OnUnInit()); + } + catch (Exception e) + { + Logger.PrintException(e); + } return TechnoExt.TechnoClass_DTOR(R); } - + [Hook(HookType.AresHook, Address = 0x70C250, Size = 8)] [Hook(HookType.AresHook, Address = 0x70BF50, Size = 5)] static public unsafe UInt32 TechnoClass_SaveLoad_Prefix(REGISTERS* R) diff --git a/Projects/Extension.Script/AnimScriptable.cs b/Projects/Extension.Script/AnimScriptable.cs index 450e1a3..b5d2bd1 100644 --- a/Projects/Extension.Script/AnimScriptable.cs +++ b/Projects/Extension.Script/AnimScriptable.cs @@ -3,6 +3,8 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Extension.Ext; +using PatcherYRpp; namespace Extension.Script { @@ -16,10 +18,18 @@ public interface IAnimScriptable : IAbstractScriptable [Serializable] public abstract class AnimScriptable : Scriptable, IAnimScriptable { + public AnimScriptable(AnimExt owner) : base(owner) { } - + + protected Pointer pAnim => Owner.OwnerObject; + protected string section => pAnim.Ref.Type.Ref.Base.Base.ID; + + public void OnInit() { } + public void OnUnInit() { } + + [Obsolete("not support OnPut in AnimScriptable yet", true)] public void OnPut(CoordStruct coord, Direction faceDir) { diff --git a/Projects/Extension.Script/BulletScriptable.cs b/Projects/Extension.Script/BulletScriptable.cs index 09d3f97..a8b66a1 100644 --- a/Projects/Extension.Script/BulletScriptable.cs +++ b/Projects/Extension.Script/BulletScriptable.cs @@ -24,11 +24,11 @@ public BulletScriptable(BulletExt owner) : base(owner) protected Pointer pBullet => Owner.OwnerObject; protected string section => pBullet.Ref.Type.Ref.Base.Base.ID; - [Obsolete("not support OnPut in BulletScriptable yet", true)] - public void OnPut(Pointer pLocation, DirType dirType) - { - throw new NotSupportedException("not support OnPut in BulletScriptable yet"); - } + public virtual void OnInit() { } + public virtual void OnUnInit() { } + + public virtual void OnPut(Pointer pLocation, DirType dirType) { } + [Obsolete("not support OnRemove in BulletScriptable yet", true)] public void OnRemove() { diff --git a/Projects/Extension.Script/IScriptable.cs b/Projects/Extension.Script/IScriptable.cs index 04d5979..980c64d 100644 --- a/Projects/Extension.Script/IScriptable.cs +++ b/Projects/Extension.Script/IScriptable.cs @@ -10,7 +10,9 @@ namespace Extension.Script public interface IAbstractScriptable : IScriptable { + void OnInit(); void OnUpdate(); + void OnUnInit(); } public interface IObjectScriptable : IAbstractScriptable diff --git a/Projects/Extension.Script/SuperWeaponScriptable.cs b/Projects/Extension.Script/SuperWeaponScriptable.cs index 84f7482..4258bcc 100644 --- a/Projects/Extension.Script/SuperWeaponScriptable.cs +++ b/Projects/Extension.Script/SuperWeaponScriptable.cs @@ -22,6 +22,9 @@ public SuperWeaponScriptable(SuperWeaponExt owner) : base(owner) { } + public void OnInit() { } + public void OnUnInit() { } + public sealed override void OnUpdate() { throw new NotSupportedException("not support OnUpdate in SuperWeaponScriptable yet"); diff --git a/Projects/Extension.Script/TechnoScriptable.cs b/Projects/Extension.Script/TechnoScriptable.cs index 1a244a6..fa87c18 100644 --- a/Projects/Extension.Script/TechnoScriptable.cs +++ b/Projects/Extension.Script/TechnoScriptable.cs @@ -33,6 +33,9 @@ public TechnoScriptable(TechnoExt owner) : base(owner) protected Pointer pTechno => Owner.OwnerObject; protected string section => pTechno.Ref.Type.Ref.Base.Base.ID; + public virtual void OnInit() { } + public virtual void OnUnInit() { } + public virtual void OnTemporalUpdate(Pointer pTemporal) { } public virtual void OnPut(Pointer pLocation, DirType dirType) { } From 099f9d1b57c0532886ccd447bca6dbeb1587396a Mon Sep 17 00:00:00 2001 From: ChrisLv <12737@live.com> Date: Wed, 5 Oct 2022 02:43:27 +0700 Subject: [PATCH 08/11] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20TechnoClass=5FRegist?= =?UTF-8?q?erDestruction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ComponentHooks/TechnoComponent.cs | 29 +++++++++++++++++++ Projects/Extension.Script/BulletScriptable.cs | 4 +-- Projects/Extension.Script/IScriptable.cs | 4 +-- Projects/Extension.Script/TechnoScriptable.cs | 8 +++-- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/ComponentHooks/TechnoComponent.cs b/ComponentHooks/TechnoComponent.cs index 21044a3..e48f4db 100644 --- a/ComponentHooks/TechnoComponent.cs +++ b/ComponentHooks/TechnoComponent.cs @@ -190,6 +190,35 @@ public static unsafe UInt32 TechnoClass_ReceiveDamage_Destroy(REGISTERS* R) return 0; } + [Hook(HookType.AresHook, Address = 0x702E9D, Size = 6)] + public static unsafe UInt32 TechnoClass_RegisterDestruction(REGISTERS* R) + { + try + { + Pointer pTechno = (IntPtr)R->ESI; + Pointer pKiller = (IntPtr)R->EDI; + int cost = (int)R->EBP; + + TechnoExt ext = TechnoExt.ExtMap.Find(pTechno); + + bool skip = false; + if (!skip) + { + ext.GameObject.Foreach(c => (c as ITechnoScriptable)?.OnRegisterDestruction(pKiller, cost, ref skip)); + } + // skip the entire veterancy + if (skip) + { + return 0x702FF5; + } + } + catch (Exception e) + { + Logger.PrintException(e); + } + return 0; + } + [Hook(HookType.AresHook, Address = 0x6FC339, Size = 6)] public static unsafe UInt32 TechnoClass_CanFire_Components(REGISTERS* R) { diff --git a/Projects/Extension.Script/BulletScriptable.cs b/Projects/Extension.Script/BulletScriptable.cs index a8b66a1..e3a680c 100644 --- a/Projects/Extension.Script/BulletScriptable.cs +++ b/Projects/Extension.Script/BulletScriptable.cs @@ -35,8 +35,8 @@ public void OnRemove() throw new NotSupportedException("not support OnRemove in BulletScriptable yet"); } [Obsolete("not support OnReceiveDamage in BulletScriptable yet", true)] - public void OnReceiveDamage(Pointer pDamage, int DistanceFromEpicenter, Pointer pWH, - Pointer pAttacker, bool IgnoreDefenses, bool PreventPassengerEscape, Pointer pAttackingHouse) + public void OnReceiveDamage(Pointer pDamage, int distanceFromEpicenter, Pointer pWH, + Pointer pAttacker, bool ignoreDefenses, bool preventPassengerEscape, Pointer pAttackingHouse) { throw new NotSupportedException("not support OnReceiveDamage in BulletScriptable yet"); } diff --git a/Projects/Extension.Script/IScriptable.cs b/Projects/Extension.Script/IScriptable.cs index 980c64d..a385f37 100644 --- a/Projects/Extension.Script/IScriptable.cs +++ b/Projects/Extension.Script/IScriptable.cs @@ -19,8 +19,8 @@ public interface IObjectScriptable : IAbstractScriptable { void OnPut(Pointer pLocation, DirType dirType); void OnRemove(); - void OnReceiveDamage(Pointer pDamage, int DistanceFromEpicenter, Pointer pWH, - Pointer pAttacker, bool IgnoreDefenses, bool PreventPassengerEscape, Pointer pAttackingHouse); + void OnReceiveDamage(Pointer pDamage, int distanceFromEpicenter, Pointer pWH, + Pointer pAttacker, bool ignoreDefenses, bool preventPassengerEscape, Pointer pAttackingHouse); void OnReceiveDamage2(Pointer pRealDamage, Pointer pWH, DamageState damageState, Pointer pAttacker, Pointer pAttackingHouse); void OnReceiveDamageDestroy(); diff --git a/Projects/Extension.Script/TechnoScriptable.cs b/Projects/Extension.Script/TechnoScriptable.cs index fa87c18..0776280 100644 --- a/Projects/Extension.Script/TechnoScriptable.cs +++ b/Projects/Extension.Script/TechnoScriptable.cs @@ -13,6 +13,8 @@ public interface ITechnoScriptable : IObjectScriptable void OnTemporalUpdate(Pointer pTemporal); + void OnRegisterDestruction(Pointer pKiller, int cost, ref bool skip); + void CanFire(Pointer pTarget, Pointer pWeapon, ref bool ceaseFire); void OnFire(Pointer pTarget, int weaponIndex); @@ -40,14 +42,16 @@ public virtual void OnTemporalUpdate(Pointer pTemporal) { } public virtual void OnPut(Pointer pLocation, DirType dirType) { } public virtual void OnRemove() { } - public virtual void OnReceiveDamage(Pointer pDamage, int DistanceFromEpicenter, Pointer pWH, - Pointer pAttacker, bool IgnoreDefenses, bool PreventPassengerEscape, Pointer pAttackingHouse) + public virtual void OnReceiveDamage(Pointer pDamage, int distanceFromEpicenter, Pointer pWH, + Pointer pAttacker, bool ignoreDefenses, bool preventPassengerEscape, Pointer pAttackingHouse) { } public virtual void OnReceiveDamage2(Pointer pRealDamage, Pointer pWH, DamageState damageState, Pointer pAttacker, Pointer pAttackingHouse) { } public virtual void OnReceiveDamageDestroy() { } + public virtual void OnRegisterDestruction(Pointer pKiller, int cost, ref bool skip) { } + public virtual void CanFire(Pointer pTarget, Pointer pWeapon, ref bool ceaseFire) { } public virtual void OnFire(Pointer pTarget, int weaponIndex) { } From e0f828d7bc6e671ce1221ac197daa8539d2e5fb3 Mon Sep 17 00:00:00 2001 From: ChrisLv <12737@live.com> Date: Mon, 10 Oct 2022 00:25:41 +0700 Subject: [PATCH 09/11] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=94=B9=E4=BA=86rules?= =?UTF-8?q?md=E5=90=8D=E5=AD=97=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/Extension/INI/INIConstant.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Projects/Extension/INI/INIConstant.cs b/Projects/Extension/INI/INIConstant.cs index e42603c..74b7b5c 100644 --- a/Projects/Extension/INI/INIConstant.cs +++ b/Projects/Extension/INI/INIConstant.cs @@ -12,10 +12,10 @@ namespace Extension.INI { public static class INIConstant { - public static string AiName { get; set; } = "aimd.ini"; - public static string ArtName { get; set; } = "artmd.ini"; - public static string RulesName { get; set; } = "rulesmd.ini"; - public static string Ra2md { get; set; } = "ra2md.ini"; + public static string AiName => CCINIClass.INI_AI_FileName; //"aimd.ini"; + public static string ArtName => CCINIClass.INI_Art_FileName; //"artmd.ini"; + public static string RulesName => CCINIClass.INI_Ruels_FileName; //"rulesmd.ini"; + public static string Ra2md => "ra2md.ini"; public static string GameModeName => _gameModeName; public static string MapName => ScenarioClass.Instance.FileName; From cae69c610326f60477e51648d35e01ca9dd3154d Mon Sep 17 00:00:00 2001 From: ChrisLv <12737@live.com> Date: Sat, 15 Oct 2022 01:02:22 +0700 Subject: [PATCH 10/11] add FastPow from Phobos --- Projects/PatcherYRpp.Utilities/MathEx.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Projects/PatcherYRpp.Utilities/MathEx.cs b/Projects/PatcherYRpp.Utilities/MathEx.cs index efffb81..85668ac 100644 --- a/Projects/PatcherYRpp.Utilities/MathEx.cs +++ b/Projects/PatcherYRpp.Utilities/MathEx.cs @@ -158,6 +158,17 @@ public static Vector3 GetForwardVector(Pointer pTechno, bool getTur return facing.current().ToVector3(); } + // Direct multiplication pow from Phobos + public static double FastPow(this double x, double n) + { + double r = 1.0; + while (n > 0) + { + r *= x; + --n; + } + return r; + } #endregion From bba32a072a7d711da675681de8cfc871088884f1 Mon Sep 17 00:00:00 2001 From: ChrisLv <12737@live.com> Date: Sat, 15 Oct 2022 14:05:33 +0700 Subject: [PATCH 11/11] =?UTF-8?q?=E4=BF=AE=E6=AD=A3StopCmd=E5=92=8CGuardCm?= =?UTF-8?q?d=E7=9A=84=E9=94=99=E8=AF=AF=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ComponentHooks/TechnoComponent.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ComponentHooks/TechnoComponent.cs b/ComponentHooks/TechnoComponent.cs index e48f4db..c4881e6 100644 --- a/ComponentHooks/TechnoComponent.cs +++ b/ComponentHooks/TechnoComponent.cs @@ -413,8 +413,8 @@ public static unsafe UInt32 TechnoClass_Select(REGISTERS* R) return 0; } - - [Hook(HookType.AresHook, Address = 0x730E8F, Size = 6)] + [Hook(HookType.AresHook, Address = 0x730DEB, Size = 6)] //Building + [Hook(HookType.AresHook, Address = 0x730E56, Size = 6)] public static unsafe UInt32 ObjectClass_GuardCommand(REGISTERS* R) { Pointer pObject = (IntPtr)R->ESI; @@ -427,7 +427,7 @@ public static unsafe UInt32 ObjectClass_GuardCommand(REGISTERS* R) return 0; } - [Hook(HookType.AresHook, Address = 0x730F1C, Size = 5)] + [Hook(HookType.AresHook, Address = 0x730EEB, Size = 6)] public static unsafe UInt32 ObjectClass_StopCommand(REGISTERS* R) { Pointer pObject = (IntPtr)R->ESI;