ID:154186
 
I created a new rare item in MLAAS... xray glasses. But since my targetting system checks whether attacker and target are within view of each other, it would allow someone to shoot through any wall they could see through.

Even if I check for sight in both directions (and I do), there is the rare case when both attacker and victim may be able to see through the wall, and thus defy intended game physics by shooting through it.

The solution was to get the attacker's and victim's turfs, and find out if they are in view of each other:
proc
get_turf(atom/where) // very useful for other things as well
while(isloc(where))
if(isturf(where))
return where
where = where.loc
return null

weapon_view(mob/attacker, mob/target)
var
from_turf = get_turf(attacker)
to_turf = get_turf(target)
if(from_turf && to_turf)
return ((from_turf in (view(to_turf))) && (to_turf in (view(from_turf))))

In case you're wondering why I check view in both directions, I have found that BYOND's sighting routines are not 100% reciprocal between given points. That is, with the right configuration of walls, person A can see person B, while the opposite is not true.
Clever.
One solution would be to make an invisible object travel to the person.
Or
have it so that you can't attack with the glasses.
Or
Quickly take off JUST the see thrrough walls not the view change and then check and then put them back on.
OR
even better just take of the SEE_MOBS part of it and not the rest.

Just one quick off topic question. How did you change the clients view?
In response to Exadv1
Exadv1 wrote:
One solution would be to make an invisible object travel to the person.
Or
have it so that you can't attack with the glasses.
Or
Quickly take off JUST the see thrrough walls not the view change and then check and then put them back on.
OR
even better just take of the SEE_MOBS part of it and not the rest.

Just one quick off topic question. How did you change the clients view?

My solution works fine, and doesn't change the nature of the play as some of yours does.