| 662 | VARP(bulletairsounddestrad, 0, 8, 1000); |
| 663 | |
| 664 | void addshotline(dynent *pl, const vec &from, const vec &to) |
| 665 | { |
| 666 | if(pl == player1 || !shotlinettl || !shotline) return; |
| 667 | bool fx = shotlinettl > 0 && (player1->isspectating() || !multiplayer(NULL)); // allow fx only in spect mode and locally |
| 668 | if(rnd(3) && !fx) return; // show all shotlines when fx enabled |
| 669 | |
| 670 | int start = (camera1->o.dist(to) <= 10.0f) ? 8 : 5; |
| 671 | vec unitv; |
| 672 | float dist = to.dist(from, unitv); |
| 673 | if(dist < 1) return; |
| 674 | unitv.div(dist); |
| 675 | |
| 676 | // shotline visuals |
| 677 | vec o = unitv; |
| 678 | o.mul(dist/10+start).add(from); |
| 679 | vec d = unitv; |
| 680 | d.mul(dist/10*-(10-start-2)).add(to); |
| 681 | newparticle(o, d, fx ? shotlinettl : min(75, shotlinettl), 6); |
| 682 | |
| 683 | // shotline sound fx |
| 684 | if(!bulletairsoundrad) return; |
| 685 | vec fromuv, touv; |
| 686 | float fd = camera1->o.dist(from, fromuv); |
| 687 | float td = camera1->o.dist(to, touv); |
| 688 | if(fd <= (float)bulletairsoundsourcerad || td <= (float)bulletairsounddestrad) return; // ignore nearly fired/detonated shots |
| 689 | vec soundpos(unitv); |
| 690 | soundpos.mul(fd/(fd+td)*dist); |
| 691 | soundpos.add(from); |
| 692 | if(!bulletairsound || soundpos.dist(camera1->o) > bulletairsoundrad) return; // outside player radius |
| 693 | audiomgr.playsound(rnd(2) ? S_BULLETAIR1 : S_BULLETAIR2, &soundpos, SP_LOW); |
| 694 | } |
| 695 |
no test coverage detected