--sniper2 script by smallg local fire_range = {} local shot_delay = {} local damage = {} local chance_to_hit = {} local timer2 = {} local fired = {} function sniper3_init(e) damage[e] = 45 fire_range[e] = 4000 shot_delay[e] = 4000 --1000 = 1 second chance_to_hit[e] = 50 --100 = certain hit fired[e] = 0 CharacterControlManual(e) CharacterControlArmed(e) end --sound1 = normal sniper gun shot function sniper3_main(e) RotateToPlayer(e) if timer2[e] == nil then timer2[e] = g_Time+(GetPlayerDistance(e)*0.25) end if g_Entity[e]['animating'] == 0 then SetAnimation(0) PlayAnimation(e) g_Entity[e]['animating'] = 1 end if fired[e] == 0 then if GetTimer(e) > shot_delay[e] then StartTimer(e) if GetPlayerDistance(e) < fire_range[e] then x1 = GetEntityPositionX(e) y1 = GetEntityPositionY(e)+80 --above origin so we can see over cover z1 = GetEntityPositionZ(e) y2 = g_PlayerPosY x2 = g_PlayerPosX z2 = g_PlayerPosZ obstructionhit = IntersectAll(x2,y2,z2,x1,y1,z1,g_Entity[e]['obj']) if obstructionhit == nil then obstructionhit = 0 end if obstructionhit ~= 0 then --Prompt ("obstructed") else thit = RayTerrain(x1,y1,z1,x2,y2+10,z2) if thit ~= 1 then fired[e] = 1 PlaySound(e,1) --shot fired timer2[e] = g_Time+(GetPlayerDistance(e)/5) end end end end else if g_Time > timer2[e] then if math.random(1,100) >= chance_to_hit[e] then PlaySound(e,2) --hit flesh HurtPlayer(e,damage[e]) else PlaySound(e,3) --bullet ricochets end fired[e] = 0 end end --SetGamePlayerStateSlowMotion(1) --Prompt(GetGamePlayerStateGunRecoilCorrectAngleX().." "..GetGamePlayerStateGunRecoilCorrectAngleY()) end