If you are able to bypass the los check function, would you be able to bypass the range check function ? The 'is my target close enough to start casting that spell' check ?
Since when the server is laggin you can cast on someone you see while he is in fact too far away or not in sight, this check looks to be client-sided.