lastcheck = 0 function occlusion_new_init(e) weapon_name[e] = "occlusion" end function occlusion_new_main(e) if g_Time > lastcheck then hiding = 0 showing = 0 ents = 0 lastcheck = g_Time+15 for a = 1,g_EntityElementMax do hide = 0 if g_Entity[a] ~= nil then if ai_soldier_state[a] == nil then if weapon_name[a] == nil then if g_Entity[a]['health'] == 25 then ents = ents+1 x2 = g_Entity[a]['x'] y2 = g_Entity[a]['y']+80 z2 = g_Entity[a]['z'] x1 = g_PlayerPosX y1 = g_PlayerPosY+20 z1 = g_PlayerPosZ terrainhit = RayTerrain(x2,y2,z2,x1,y1,z1) if terrainhit == nil then terrainhit = 0 end if terrainhit == 0 then showing = showing + 1 Show(a) else hiding = hiding + 1 Hide(a) end end end end end end end TextCenterOnX(50,90,5,"total entities = "..ents.."/"..g_EntityElementMax.." , hidden = "..hiding..", shown = "..showing) end --main function occlusion_new_exit(e) end function PlayerLooking(e,dis,v) if g_Entity[e] ~= nil then if dis == nil then dis = 3000 end if v == nil then v = 0.5 end if GetPlayerDistance(e) <= dis then local destx = g_Entity[e]['x'] - g_PlayerPosX local destz = g_Entity[e]['z'] - g_PlayerPosZ local angle = math.atan2(destx,destz) angle = angle * (180.0 / math.pi) if angle <= 0 then angle = 360 + angle elseif angle > 360 then angle = angle - 360 end while g_PlayerAngY < 0 or g_PlayerAngY > 360 do if g_PlayerAngY <= 0 then g_PlayerAngY = 360 + g_PlayerAngY elseif g_PlayerAngY > 360 then g_PlayerAngY = g_PlayerAngY - 360 end end local L = angle - v local R = angle + v if L <= 0 then L = 360 + L elseif L > 360 then L = L - 360 end if R <= 0 then R = 360 + R elseif R > 360 then R = R - 360 end if (L < R and math.abs(g_PlayerAngY) > L and math.abs(g_PlayerAngY) < R) then return 1 elseif (L > R and (math.abs(g_PlayerAngY) > L or math.abs(g_PlayerAngY) < R)) then return 1 else return 0 end else return 0 end end end