Forum

> > CS2D > General > Weapon attack speed and range
Forums overviewCS2D overviewGeneral overviewLog in to reply

English Weapon attack speed and range

5 replies
To the start Previous 1 Next To the start

old Weapon attack speed and range

Mami Tomoe
User Off Offline

Quote
Don't really know if this fits in general or scripts so feel free to move it or smth IDK.

Hi! I'm here to ask a simple question, is it possible to modify a weapon's attack speed and or range.

That's it.

old Re: Weapon attack speed and range

Bowlinghead
User Off Offline

Quote
What about a Lua that denies every damage after x pixel travel distance?

You could see the shot though.

Here is something to play around.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
--untested

wpn_range = {
[1] = 32,
[2] = 64
}

currWpn = {}
currX = {}
curr Y = {}

addhook("attack","GetWeapon")
function GetWeapon(id)
	currWpn[id] = player(id,"weapontype")
	currX[id] = player(id,"x")
	currY[id] = player(id,"y")
end

addhook("hit","Hit")
function Hit(vic,src,wpn)
	local dX = player(vic,"x") 
	dX = dX*dX
	dX = dX + (currX[src] * currX[src])

	local dY = player(vic,"y")
	dY = dY*dY
	dY = dY + (currY[src] * currY[src])

	local dRange = math.sqrt(dx+dy)
	
	if (dRange > wpn_range[wpn]) then
		return 1
	end
end

old Re: Weapon attack speed and range

Masea
Super User Off Offline

Quote
@user Bowlinghead: That's lacking, as you're aware. But more than that, it is not even gonna work for many scenarios.

Let's just take one of the most known low-range weapons: M3 has 50 range according to http://www.cs2d.com/weapons.php?slot=-1#item10

What if I insert a value like
[10]=51
into wpn_range table? It basically won't work because the bullets of that weapon don't even go on that far. It stops at 50th pixel through the way and your hit hook doesn't come into action when the enemy is actually on the 51st pixel.

Although, your logic would work if the weapon had an unlimited (or excessive) range as default.
edited 1×, last 16.01.19 06:57:57 am
To the start Previous 1 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview