private static void _mod(TESObjectWEAP weap, Actor attacker, ref int count) { if (count <= 0) { return; } if (settings.OnlyPlayer.Value) { if (attacker == null || !attacker.IsPlayer) { return; } } long mult; if (settings.ArrowCountGlobal.Value != null) { mult = (long)Math.Round(settings.ArrowCountGlobal.Value.FloatValue); } else { mult = settings.ArrowCount.Value; } if (mult <= 1) { return; } mult *= count; if (mult > int.MaxValue) { count = int.MaxValue; } else { count = (int)mult; } }
internal override void Apply() { this.NiNode_ctor = NetScriptFramework.Main.GameInfo.GetAddressOf(68936); _cachedOffsets = new int[256]; ulong vid = 17693; int baseOffset = 0x5430; Events.OnMainMenu.Register(e => { if (this._curPlaceNode == null) { var alloc = MemoryManager.Allocate(0x130, 0); Memory.InvokeCdecl(this.NiNode_ctor, alloc, 0); this._curPlaceNode = MemoryObject.FromAddress <NiNode>(alloc); this._curPlaceNode.IncRef(); alloc = MemoryManager.Allocate(0x10, 0); this._curPlacePos = MemoryObject.FromAddress <NiPoint3>(alloc); Memory.WriteZero(this._curPlacePos.Address, 0xC); } }, 0, 1); Memory.WriteHook(new HookParameters() { Address = NetScriptFramework.Main.GameInfo.GetAddressOf(vid, 0x5CF2 - baseOffset, 0, "0F B6 D9 0F BE C2"), IncludeLength = 6, ReplaceLength = 6, Before = ctx => { TESObjectWEAP weap = null; Actor actor = null; int count = ctx.CX.ToUInt8(); try { weap = MemoryObject.FromAddress <TESObjectWEAP>(ctx.R12); } catch { } try { actor = MemoryObject.FromAddress <Actor>(ctx.R15); } catch { } int now = count; _mod(weap, actor, ref now); if (now > 255) { now = 255; } if (now != count) { ctx.CX = new IntPtr(now); } }, }); Memory.WriteHook(new HookParameters() { Address = NetScriptFramework.Main.GameInfo.GetAddressOf(vid, 0x603D - baseOffset, 0, "E8"), IncludeLength = 5, ReplaceLength = 5, After = ctx => { TESObjectWEAP weap = null; Actor actor = null; int count = ctx.AX.ToUInt8(); try { weap = MemoryObject.FromAddress <TESObjectWEAP>(ctx.R12); } catch { } try { actor = MemoryObject.FromAddress <Actor>(ctx.R15); } catch { } int now = count; _mod(weap, actor, ref now); if (now > 255) { now = 255; } if (now != count) { ctx.AX = new IntPtr(now); } }, }); Memory.WriteHook(new HookParameters() { Address = NetScriptFramework.Main.GameInfo.GetAddressOf(42928, 0xB91B - 0xB360, 0, "E8"), IncludeLength = 5, ReplaceLength = 5, After = ctx => { if (settings.ForceDrawTime.Value >= 0.0) { ctx.XMM0f = (float)settings.ForceDrawTime.Value; } else { int track = _projTrack; if (track > 0) { track--; _projTrack = track; if (_projStrength.HasValue) { ctx.XMM0f = _projStrength.Value; if (track == 0) { _projStrength = null; } } else { _projStrength = ctx.XMM0f; } } } }, }); Memory.WriteHook(new HookParameters() { Address = NetScriptFramework.Main.GameInfo.GetAddressOf(vid, 0x621C - baseOffset, 0, "F3 0F 10 44 24 48"), IncludeLength = 0, //0x3D - 0x1C, ReplaceLength = 0x3D - 0x1C, Before = ctx => { var pos = MemoryObject.FromAddress <NiPoint3>(ctx.BP + 0x68); int index = ctx.SI.ToUInt8(); if (index <= 1) { pos.X = Memory.ReadFloat(ctx.SP + 0x48); pos.Y = Memory.ReadFloat(ctx.SP + 0x4C); pos.Z = Memory.ReadFloat(ctx.SP + 0x50); return; } var plr = PlayerCharacter.Instance; bool isPlayer = plr != null && plr.Cast <PlayerCharacter>() == ctx.R15; if (isPlayer) { _projTrack = index; } else { _projTrack = 0; } float x = 0.0f; float y = 0.0f; _calculate_projectile_offset(index - 1, ref x, ref y); if (this._curPlaceHadNode) { var npos = this._curPlaceNode.WorldTransform.Position; npos.X = Memory.ReadFloat(ctx.SP + 0x48); npos.Y = Memory.ReadFloat(ctx.SP + 0x4C); npos.Z = Memory.ReadFloat(ctx.SP + 0x50); this._curPlacePos.X = x; this._curPlacePos.Y = 0.0f; this._curPlacePos.Z = y; this._curPlaceNode.WorldTransform.Translate(this._curPlacePos, npos); pos.X = npos.X; pos.Y = npos.Y; pos.Z = npos.Z; } else { bool didGet = false; if (isPlayer) { var pcam = PlayerCamera.Instance; if (pcam != null) { var pnode = pcam.Node; if (pnode != null) { byte[] buf = Memory.ReadBytes(pnode.WorldTransform.Address, 0x34); Memory.WriteBytes(this._curPlaceNode.WorldTransform.Address, buf); var tpos = this._curPlaceNode.WorldTransform.Position; tpos.X = Memory.ReadFloat(ctx.SP + 0x48); tpos.Y = Memory.ReadFloat(ctx.SP + 0x4C); tpos.Z = Memory.ReadFloat(ctx.SP + 0x50); this._curPlacePos.X = x; this._curPlacePos.Y = 0.0f; this._curPlacePos.Z = y; this._curPlaceNode.WorldTransform.Translate(this._curPlacePos, pos); didGet = true; } } } if (!didGet) { pos.X = Memory.ReadFloat(ctx.SP + 0x48) + x; pos.Y = Memory.ReadFloat(ctx.SP + 0x4C); pos.Z = Memory.ReadFloat(ctx.SP + 0x50) + y; } } } }); Events.OnWeaponFireProjectilePosition.Register(e => { if (e.Node != null) { byte[] buf = Memory.ReadBytes(e.Node.WorldTransform.Address, 0x34); Memory.WriteBytes(this._curPlaceNode.WorldTransform.Address, buf); this._curPlaceHadNode = true; } else { this._curPlaceHadNode = false; } }, 50); }