-- Runs inside a private scope after the existing read-only UE reflection helpers. local movementID,animationID=1337142257,1337142258 local function identity(a) if not ptr(a)then return end local cl=q(a+0x10);local name=q(a+0x18);local index=readInteger(a+0xC) if not ptr(cl)or not name or not index then return end return {address=a,class=cl,name=name,index=index} end local function valid(id) return id and state.pid==getOpenedProcessID()and q(id.address+0x10)==id.class and q(id.address+0x18)==id.name and readInteger(id.address+0xC)==id.index end local function context() if not state.worldSlot or not state.namePool then local wr=uniqueScan(signatures.world);local worldSlot=wr+7+assert(readInteger(wr+3,true)) local nr=uniqueScan(signatures.names)+0x1C;local namePool=nr+7+assert(readInteger(nr+3,true)) state.worldSlot=worldSlot;state.namePool=namePool end if state.pid~=getOpenedProcessID()then return end local world=q(state.worldSlot);if not ptr(world)then return end local gi=q(world+offset(classOf(world),'OwningGameInstance'));if not ptr(gi)then return end local list,n=array(gi+offset(classOf(gi),'LocalPlayers'),8);if not list or not n or n<1 then return end local lp=q(list);if not ptr(lp)then return end local pc=q(lp+offset(classOf(lp),'PlayerController'));if not ptr(pc)then return end local pawn=q(pc+offset(classOf(pc),'Pawn'));local id=identity(pawn);if not id then return end local dying=field(id.class,'bActorIsBeingDestroyed');if dying and flag(pawn,dying)then return end return {pawn=pawn,id=id} end local function factorValue(value) assert(finite(value)and value>=1 and value<=5,'速度倍率必须在 1 到 5 之间');return value end local function quantize(value)return (string.unpack('=0 and current<=maximum,'速度当前值异常') if l.lastWritten==nil or current~=l.lastWritten then l.base=current end local target=quantize(l.base*factor) assert(finite(target)and target<=maximum,'速度目标值异常') if target~=current then assert(writeFloat(address,target),'速度写入失败')end l.lastWritten=target;return true end function RestorePlayerSpeedLease(l) if l and valid(l.object)and q(l.object.address+0x20)==l.owner then local address=l.object.address+l.offset;local current=readFloat(address) if l.lastWritten~=nil and current==l.lastWritten then assert(writeFloat(address,l.base),'速度恢复失败')end end end ApplyPlayerAnimationLease=ApplyPlayerSpeedLease RestorePlayerAnimationLease=RestorePlayerSpeedLease function ReleaseChangedPlayerAnimationLease(s,owner) if s.binding and s.binding.owner~=owner then RestorePlayerAnimationLease(s.binding);s.binding=nil end end local function restoreMovement(s) local errors={} for _,l in ipairs(s.leases or {})do local ok,e=pcall(RestorePlayerSpeedLease,l);if not ok then errors[#errors+1]=tostring(e)end end assert(#errors==0,table.concat(errors,'; ')) s.leases=nil;s.pawn=nil;s.attributes=nil end local speedFields={'WalkSpeed','JogSpeed','SprintSpeed','CrouchSpeed'} function PlayerMovementAttributeLease(id,outer,at) local base=assert(readFloat(id.address+at+8),'移动属性基值不可读') local current=assert(readFloat(id.address+at+12),'移动属性当前值不可读') assert(finite(base)and base>=0 and base<=20000 and finite(current)and current>=0 and current<=20000,'移动属性原值异常') -- Keep GAS BaseValue untouched. Re-aggregating CurrentValue from a scaled -- BaseValue would feed our own multiplier back into the next refresh. return {object=id,owner=outer,offset=at+12,maximum=100000} end local function movementLeases(c) local attrs=q(c.pawn+offset(c.id.class,'AttributeSetBase'));local id=identity(attrs) assert(id and fname(id.class+0x18)=='BasicAttributeSet','玩家移动属性不可用') local outer=q(attrs+0x20);assert(ptr(outer),'移动属性归属不可用') local leases={} for _,name in ipairs(speedFields)do local p=field(id.class,name,true) assert(p.size==16 and fname(p.type+0x18)=='GameplayAttributeData','移动属性结构已改变:'..name) -- Only scale the four source attributes. FinalWalkSpeed/MaxWalkSpeed are game -- outputs; scaling those as well could apply the multiplier twice. leases[#leases+1]=PlayerMovementAttributeLease(id,outer,p.offset) end return attrs,leases end function EnablePlayerMovementSpeed() assert(not PBZ_PlayerMovementSpeed,'移动速度已经开启') local s={pid=state.pid,factor=1} s.refresh=function() local c=context() if not c then restoreMovement(s);return end local attrs=q(c.pawn+offset(c.id.class,'AttributeSetBase')) if s.pawn~=c.pawn or s.attributes~=attrs or not s.leases or not valid(s.leases[1].object)then restoreMovement(s) local address,leases=movementLeases(c);s.attributes=address;s.leases=leases;s.pawn=c.pawn end for _,l in ipairs(s.leases)do assert(ApplyPlayerSpeedLease(l,s.factor),'玩家移动属性身份发生变化')end s.lastError=nil end s.stop=function()restoreMovement(s);if s.timer then s.timer.destroy();s.timer=nil end;PBZ_PlayerMovementSpeed=nil end s.refresh();s.timer=createTimer(nil,false);s.timer.Interval=100 s.timer.OnTimer=function() local ok,e=pcall(s.refresh) if not ok then local restored,why=pcall(restoreMovement,s);s.lastError=tostring(e)..(restored and ''or '; '..tostring(why))end end PBZ_PlayerMovementSpeed=s;s.timer.Enabled=true end local function enableAnimation() local s={pid=state.pid,factor=1} s.refresh=function() local c=context() if not c then RestorePlayerAnimationLease(s.binding);s.binding=nil;return end ReleaseChangedPlayerAnimationLease(s,c.pawn) local mesh=q(c.pawn+offset(c.id.class,'Mesh'));local id=identity(mesh) if s.binding and s.binding.object.address~=mesh then RestorePlayerAnimationLease(s.binding);s.binding=nil end assert(id and q(mesh+0x20)==c.pawn,'玩家角色模型不可用') if not s.binding or not valid(s.binding.object)then RestorePlayerAnimationLease(s.binding) local p=field(id.class,'GlobalAnimRateScale',true);assert(p.size==4,'角色动作速度字段发生变化') s.binding={object=id,owner=c.pawn,offset=p.offset} end assert(ApplyPlayerAnimationLease(s.binding,s.factor),'玩家模型身份发生变化') s.lastError=nil end s.stop=function() RestorePlayerAnimationLease(s.binding);if s.timer then s.timer.destroy();s.timer=nil end PBZ_PlayerAnimationSpeed=nil end s.refresh();s.timer=createTimer(nil,false);s.timer.Interval=100 s.timer.OnTimer=function() local ok,e=pcall(s.refresh) if not ok then local restored,why=pcall(RestorePlayerAnimationLease,s.binding);s.lastError=tostring(e)..(restored and ''or '; '..tostring(why))end end PBZ_PlayerAnimationSpeed=s s.timer.Enabled=true end function EnablePlayerAnimationSpeed() assert(not PBZ_PlayerAnimationSpeed,'行走动画速度已经开启');enableAnimation() end local function manager(id) if id==movementID then return PBZ_PlayerMovementSpeed end if id==animationID then return PBZ_PlayerAnimationSpeed end end function PlayerSpeedFactor(id) local s=manager(id);return ('%.2f'):format(s and s.factor or 1) end function SetPlayerSpeedFactor(id,value) value=factorValue(value) local s=manager(id);assert(s and s.pid==getOpenedProcessID(),'请先开启对应速度功能') local previous=s.factor;s.factor=value;local ok,e=pcall(s.refresh) if not ok then s.factor=previous local restored,why=pcall(function()if id==movementID then restoreMovement(s)else RestorePlayerAnimationLease(s.binding)end end) s.lastError=tostring(e)..(restored and ''or '; '..tostring(why));error(s.lastError) end return true end function PlayerSpeedPreflight() local c=assert(context(),'请先进入可操作的场景');local attrs,leases=movementLeases(c) local mesh=q(c.pawn+offset(c.id.class,'Mesh'));local id=identity(mesh) assert(id and q(mesh+0x20)==c.pawn,'玩家模型校验失败') local p=field(id.class,'GlobalAnimRateScale',true);assert(p.size==4,'动作速度字段类型已改变') return ('READ_ONLY_OK pid=%d attributes=%X source_fields=%d animation_offset=%X animation_scale=%s'):format(state.pid,attrs,#leases,p.offset,tostring(readFloat(mesh+p.offset))) end