| 389 | } |
| 390 | |
| 391 | void checkitems(playerent *d) |
| 392 | { |
| 393 | if(editmode || d->state!=CS_ALIVE) return; |
| 394 | d->onladder = false; |
| 395 | float eyeheight = d->eyeheight; |
| 396 | loopv(ents) |
| 397 | { |
| 398 | entity &e = ents[i]; |
| 399 | if(e.type==NOTUSED) continue; |
| 400 | if(e.type==LADDER) |
| 401 | { |
| 402 | if(OUTBORD(e.x, e.y)) continue; |
| 403 | vec v(e.x, e.y, d->o.z); |
| 404 | float dist1 = d->o.dist(v); |
| 405 | float dist2 = d->o.z - (S(e.x, e.y)->floor+eyeheight); |
| 406 | if(dist1<1.5f && dist2<e.attr1) trypickup(i, d); |
| 407 | continue; |
| 408 | } |
| 409 | |
| 410 | if(!e.spawned) continue; |
| 411 | if(OUTBORD(e.x, e.y)) continue; |
| 412 | |
| 413 | if(e.type==CTF_FLAG) continue; |
| 414 | // simple 2d collision |
| 415 | vec v(e.x, e.y, S(e.x, e.y)->floor+eyeheight); |
| 416 | if(isitem(e.type)) v.z += float(e.attr1) / ENTSCALE10; |
| 417 | if(d->o.dist(v)<2.5f) trypickup(i, d); |
| 418 | } |
| 419 | if(m_flags_) loopi(2) |
| 420 | { |
| 421 | flaginfo &f = flaginfos[i]; |
| 422 | entity &e = *f.flagent; |
| 423 | if(!e.spawned || !f.ack || (f.state == CTFF_INBASE && !clentstats.flags[i])) continue; |
| 424 | if(OUTBORD(f.pos.x, f.pos.y)) continue; |
| 425 | if(f.state==CTFF_DROPPED) // 3d collision for dropped ctf flags |
| 426 | { |
| 427 | if(objcollide(d, f.pos, 2.5f, 8.0f)) trypickupflag(i, d); |
| 428 | } |
| 429 | else // simple 2d collision |
| 430 | { |
| 431 | vec v = f.pos; |
| 432 | v.z = S(int(v.x), int(v.y))->floor + eyeheight; |
| 433 | if(d->o.dist(v)<2.5f) trypickupflag(i, d); |
| 434 | } |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | void resetpickups(int type) |
| 439 | { |
no test coverage detected