| 776 | } |
| 777 | |
| 778 | void raydamage(vec &from, vec &to, playerent *d) |
| 779 | { |
| 780 | int dam = d->weaponsel->info.damage; |
| 781 | int hitzone = -1; |
| 782 | playerent *o = NULL; |
| 783 | float distsquared, hitdistsquared = 0.0f; |
| 784 | bool hit = false; |
| 785 | int rayscount = 0, hitscount = 0; |
| 786 | if(d->weaponsel->type==GUN_SHOTGUN) |
| 787 | { |
| 788 | playerent *hits[3*SGRAYS]; |
| 789 | loopk(3) |
| 790 | loopi(SGRAYS) |
| 791 | { |
| 792 | rayscount++; |
| 793 | int h = k*SGRAYS + i; |
| 794 | if((hits[h] = intersectclosest(from, sgr[h].rv, d, distsquared, hitzone))) |
| 795 | shorten(from, sgr[h].rv, (hitdistsquared = distsquared)); |
| 796 | } |
| 797 | loopk(3) |
| 798 | loopi(SGRAYS) |
| 799 | { |
| 800 | int h = k*SGRAYS + i; |
| 801 | if(hits[h]) |
| 802 | { |
| 803 | o = hits[h]; |
| 804 | hits[h] = NULL; |
| 805 | int numhits_o, numhits_m, numhits_c; |
| 806 | numhits_o = numhits_m = numhits_c = 0; |
| 807 | switch(sgr[h].ds) |
| 808 | { |
| 809 | case 0: numhits_o++; break; |
| 810 | case 1: numhits_m++; break; |
| 811 | case 2: numhits_c++; break; |
| 812 | default: break; |
| 813 | } |
| 814 | for(int j = i+1; j < 3*SGRAYS; j++) if(hits[j] == o) |
| 815 | { |
| 816 | hits[j] = NULL; |
| 817 | switch(sgr[j].ds) |
| 818 | { |
| 819 | case 0: numhits_o++; break; |
| 820 | case 1: numhits_m++; break; |
| 821 | case 2: numhits_c++; break; |
| 822 | default: break; |
| 823 | } |
| 824 | } |
| 825 | int numhits = numhits_o + numhits_m + numhits_c; |
| 826 | int dmgreal = 0; |
| 827 | float dmg4r = 0.0f; |
| 828 | bool withBONUS = false; |
| 829 | if(SGDMGBONUS) |
| 830 | { |
| 831 | float d2o = SGDMGDISTB; |
| 832 | if(o) d2o = vec(from).sub(o->o).magnitude(); |
| 833 | if(d2o <= (SGDMGDISTB/10.0f) && numhits) |
| 834 | { |
| 835 | dmg4r += SGDMGBONUS; |
no test coverage detected