-- LUA Script - precede every function and global member with lowercase name of script + '_main' local U = require "scriptbank\\utillib" local Q = require "scriptbank\\quatlib" local rad = math.rad local deg = math.deg local tan = math.tan local atan = math.atan local abs = math.abs local mouse_spr = mouse_spr or CreateSprite( LoadImage( "scriptbank\\images\\mouse_cursor.png" )) function activate_mouse_init(e) SetSpriteSize( mouse_spr, 2.5 ) SetSpriteOffset( mouse_spr, 1.25, 2.1 ) SetSpritePosition( mouse_spr, 200, 200 ) SetPlayerFOV( 33 ) Hide( e ) end local aspect = GetDeviceWidth() / GetDeviceHeight() local mousePress = false local freezeScreen = false local EkeyPressed = false function activate_mouse_main( e ) if g_KeyPressE == 1 then if not EkeyPressed then EkeyPressed = true if not freezeScreen then ActivateMouse() freezeScreen = true else freezeScreen = false DeactivateMouse() SetSpritePosition( mouse_spr, 200, 200 ) end end else EkeyPressed = false end if not freezeScreen then return end local mx, my = g_MouseX, g_MouseY local hfov = g_PlayerFOV / 50 * 90 + 20 local hfov = hfov / 100 * 90 + 20 local hfov = rad( hfov / aspect / 2) * 1.405 local vfov = hfov / aspect * 1.1 local ax = 1 / tan( hfov ) local ay = 1 / tan( vfov ) SetSpritePosition( mouse_spr, mx, my ) local px, py, pz = g_PlayerPosX, g_PlayerPosY + 28, g_PlayerPosZ local paX, paY, paZ = rad( g_PlayerAngX ), rad( g_PlayerAngY ), rad( g_PlayerAngZ ) local omx, omy = ( mx - 50 ) / 50, ( my - 50 ) / 50 local quat = Q.FromEuler( paX, paY, paZ ) local xAng = atan( omx / ax ) local yAng = atan( omy / ay ) if omx ~= 0 then fact = 1 - ( 0.18 * omx * omx ) yAng = yAng * fact end local qoff = Q.FromEuler( yAng, xAng, 0 ) quat = Q.Mul( quat, qoff ) paX, paY, paZ = Q.ToEuler( quat ) local rayX, rayY, rayZ = U.Rotate3D ( 0, 0, 4000, paX, paY, paZ ) rayX, rayY, rayZ = px + rayX, py + rayY, pz + rayZ local obj = IntersectAll( px, py, pz, rayX, rayY, rayZ, 0 ) if obj ~= 0 then rayX = GetIntersectCollisionX() rayY = GetIntersectCollisionY() rayZ = GetIntersectCollisionZ() if g_MouseClick == 1 and not mousePress then mousePress = true for k, v in pairs( g_Entity ) do if v.obj == obj then if v.health > 0 then SetEntityHealth( k, 0 ) end break end end end elseif RayTerrain( px, py, pz, rayX, rayY, rayZ ) == 1 then rayX = GetRayCollisionX() rayY = GetRayCollisionY() rayZ = GetRayCollisionZ() end if g_MouseClick == 0 then mousePress = false end end