According to this

video tests your default damage falloff distance is wrong.

I calculated with

**32 cs2d pixels = 64 csgo units**.

If the players has a distance of 64 pixels (=128 csgo units) then your tazer doesnt do any damage.

dmg = TaserBaseDamage * (1 - distance / TaserRange) -- pasted out of your code

dmg = 500 * ( 1 - 64/64)

dmg = 500 * ( 1 - 1)

dmg = 500 * 0

dmg = 0

While the video says it does a damage of 163 on 128 csgo units (= 64 cs2d pixels).

The video gives us 5 points.

P1: 285; 64

P2: 163; 128

P3: 100; 183

P4: 99; 184

P5: 0; 232

Edit: It even provides a 6th point and more information like hitting someone in the back makes less damage.

So you can create a function like this:

y = ax^4 + bx^3 + cx^2 + dx + e

I tried to insert the 5 points to get a linear equation system to calculate each variable a,b,c,d,e but when I try to insert the value my values never fit.

I use an

online calculator* for this.

This website uses the

Gaussian Elimination Process
*Below you can see "Allgemeine Lösung: x = {}" which is in theory a (above most), b, c, d and e (lowest most) so you know how the function looks like. *

But when I test the values I dont get the right y-values whatsoever.
If you are able to calculate the correct values you can make an almost real CSGO like tazer by using something like:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

-- vars_table = { e, d, c, b, a }
function GetFunctionValue(x,vars_table)
local e = 0
for _, i in pairs(vars_table) do
e = e + vars_table[i]*(x^i)
end
return e
end
function GetDamage(distance)
damage_function = {
[5] = -15567449/100109763138000,
[4] = 3756718573/37541161176750,
[3] = -6140740444829/300329289414000,
[2] = 1775646281917/2502744078450,
[1] = 232
}
return GetFunctionValue(distance,damage_function)/2
end

I hope this was at least a little bit useful.