| 343 | } |
| 344 | |
| 345 | playerent *intersectclosest(const vec &from, const vec &to, const playerent *at, float &bestdistsquared, int &hitzone, bool aiming = true) |
| 346 | { |
| 347 | playerent *best = NULL; |
| 348 | bestdistsquared = 1e16f; |
| 349 | int zone; |
| 350 | if(at!=player1 && player1->state==CS_ALIVE && (zone = intersect(player1, from, to))) |
| 351 | { |
| 352 | best = player1; |
| 353 | bestdistsquared = at->o.squareddist(player1->o); |
| 354 | hitzone = zone; |
| 355 | } |
| 356 | loopv(players) |
| 357 | { |
| 358 | playerent *o = players[i]; |
| 359 | if(!o || o==at || (o->state!=CS_ALIVE && (aiming || (o->state!=CS_EDITING && o->state!=CS_LAGGED)))) continue; |
| 360 | float distsquared = at->o.squareddist(o->o); |
| 361 | if(distsquared < bestdistsquared && (zone = intersect(o, from, to))) |
| 362 | { |
| 363 | best = o; |
| 364 | bestdistsquared = distsquared; |
| 365 | hitzone = zone; |
| 366 | } |
| 367 | } |
| 368 | return best; |
| 369 | } |
| 370 | |
| 371 | playerent *playerincrosshair() |
| 372 | { |
no test coverage detected