local owner='esp_projection' local function geometryBytes(b) if not b or #b<56 then return end local g={string.unpack('0 then local g=geometry(sw+0xD0) if g and u.q(a+offset)==sw and u.q(a+offset+8)==ctrl and readInteger(ctrl+8)>0 then return g end end end end end s.geometry=cached local function stringAt(a,name) local f=u.field(u.classOf(a),name,true);local data,n=u.array(a+f.offset,1024) return data and n>1 and u.exactString(data,n-1,true)or '' end local function nameID(text) local key=text:lower();if s.names[key]~=nil then return s.names[key]or nil end local current=readInteger(u.namePool+8);local cursor=readInteger(u.namePool+12) assert(current and current<8192 and cursor and cursor<=0x20000,'地图名称池不可读') for block=0,current do local address=u.q(u.namePool+0x10+block*8) local data=address and H('read',address,block==current and cursor or 0x20000) if data then local at=1 while at+1<=#data do local header=string.unpack('>6 if n==0 then break end local bytes=n*((header&1)==0 and 1 or 2) if n>1023 or at+1+bytes>#data then break end if header&1==0 and n==#text and data:sub(at+2,at+1+bytes):lower()==key then local id=(block<<16)|((at-1)//2);s.names[key]=id;return id end at=at+2+bytes;if at%2==0 then at=at+1 end end end end s.names[key]=false end local function refresh(c) if s.searchWorld~=c.world then s.searchWorld=c.world;s.lastSearch=-10000;s.roots={};s.system=nil end if getTickCount()-s.lastSearch<2000 then return end local found=H('espObjects',chunks,count,classes.WB_MapNew_C,classes.MapSubsystem) s.lastSearch=getTickCount();s.roots={};s.system=nil for _,a in ipairs(found)do local cl=u.classOf(a) if cl==classes.MapSubsystem then if u.q(a+0x20)==c.gi or u.q(a+0x20)==c.world then assert(not s.system,'地图子系统不唯一');s.system=u.identity(a)end elseif u.field(cl,'Gadget')then s.roots[#s.roots+1]={address=a,weak=weak(a)}end end end local function mapState(c) refresh(c) local selected for _,root in ipairs(s.roots)do local a=root.address if root.weak and weak(a)==root.weak and visible(a)then local cl=u.classOf(a);local canvas=u.q(a+u.offset(cl,'Gadget')) local cg=cached(canvas) if cg then assert(not selected,'多个地图同时可见,请关闭后重新打开地图') local mode=readBytes(a+u.offset(cl,'BigMapMode'),1) local name=stringAt(a,'CurrentDisplayMapID');local layerID=readInteger(a+u.offset(cl,'CurrentLayer'),true) local clip=u.q(a+u.offset(cl,'MapClickSurface')) selected={root=a,canvas=canvas,geometry=cg,clip=cached(clip),id=nameID(name),name=name,layer=layerID,overview=mode~=0} end end end return selected end local d,assembly=u.acquireDispatch(owner);assert(d.nativeEspProjectionVersion==1,'缺少ESP批量查询接口') ProtectDamageNumberDispatcher(d,u.worldSlot);s.dispatcher=d local function stamp(p)return ('%s:%s:%.6f:%.6f:%.6f'):format(p.address,p.weak,p.position[1],p.position[2],p.position[3])end s.project=function(points,w,h) if s.stopping then return {},'正在关闭ESP'end local c=u.context();if not c then s.results={};return {},'等待本地角色'end local map=mapState(c);s.map=map local key=('%s:%s:%s:%s'):format(c.world,c.pc,map and map.root or 0,map and((map.id or 0)..':'..tostring(map.layer))or 'screen') if key~=s.key then s.key=key;s.results={};s.screenQueries={};s.viewport=nil;s.generation=s.generation+1 end if map and(map.overview or not map.id or not map.clip or not s.system or not u.valid(s.system))then return {},'请选择已加载区域的分区地图'end for _,p in ipairs(points)do p.tag=stamp(p)end if not s.pending and getAddressSafe('PBZ_ESP_QueryBuffer')then local batch={} for i,p in ipairs(points)do if not map or not s.results[p.tag] then batch[#batch+1]=p if map and #batch==300 then break end p.projectionOrder=s.screenQueries[p.weak] or 0 p.pointOrder=i end end if #batch>300 then -- Let unqueried and least recently queried points take the next screen batch. table.sort(batch,function(a,b) if a.projectionOrder==b.projectionOrder then return a.pointOrder0 then assert(H('write',buffer+64,EspSupport.packPoints(batch),false))end local writes={{0,buffer},{8,#batch},{16,map and 1 or 2},{24,map and map.id or 0},{32,layer.address},{40,map and map.layer or 0},{48,viewportCDO.address},{56,viewport.address}} local ids={u.identity(c.pc),screen,project,mapID,layer,viewport,viewportCDO,map and s.system or u.identity(c.pc)} local weakIDs={};for i,id in ipairs(ids)do weakIDs[i]=u.weakReference(id)end local generation=s.generation local r={nativeEspProjection=true,owner=owner,world=c.world,pcID=ids[1],receiver=map and s.system or ids[1],fn=map and project or screen,extra=map and mapID or ids[1],resultKind='object',resultOffset=0,writes=writes} r.validate=function()for i,id in ipairs(ids)do if not weakIDs[i]or u.weakReference(id)~=weakIDs[i]then return false end end;return true end r.capture=function() local raw=assert(H('read',buffer,64+#batch*48),'ESP查询结果不可读') local result={viewport=map and geometryBytes(raw)or nil,points={}} for i,p in ipairs(batch)do local at=65+(i-1)*48 local x,y,flag=string.unpack('=0 and y>=0 and x<=w and y<=h then out[#out+1]={x=x,y=y,caption=p.caption,distance=p.distance,metres=p.metres,color=p.color}end end end return out,s.error or(map and('大地图 · '..#out..' 个标记(当前已加载对象)')or('场景 · '..#out..' 个标记')) end s.prepareStop=function() s.stopping=true local ok,e=pcall(d.drain,owner) if not ok then s.stopping=false;error(e,0) end if s.pending then s.stopping=false;error('ESP原生查询仍在执行,请重试关闭',0) end end s.stop=function()assert(not s.pending,'请先完成ESP查询');local restore=d.release(owner);if PBZ_EspProjection==s then PBZ_EspProjection=nil end;return restore..'\nunregistersymbol(PBZ_ESP_QueryBuffer)\ndealloc(PBZ_ESP_QueryBuffer)'end PBZ_EspProjection=s return assembly..'\nalloc(PBZ_ESP_QueryBuffer,$4000)\nregistersymbol(PBZ_ESP_QueryBuffer)' end function PrepareEspProjectionDisable() local s=PBZ_EspProjection;if s then s.prepareStop()end end function StopEspProjection() local s=PBZ_EspProjection;return s and s.stop()or '' end