Forum

> > CS2D > Scripts > Knockback Script?
Forums overviewCS2D overview Scripts overviewLog in to reply

English Knockback Script?

5 replies
To the start Previous 1 Next To the start

old Knockback Script?

N13-SHADOW
User Off Offline

Quote
i finally thinked about something cool

can any body make a script that can push players on hit?

i know we have it already but its for zambie mod
i want a sample script that we can paste it in "autorun"folder
[to use it]

did we have?
here.. eat some cookies! (LOL)

Admin/mod comment

"is it going to create?" isn't a title which makes any sense at all. fixed. /DC

old Re: Knockback Script?

Dousea
User Off Offline

Quote
Here it is:
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
35
addhook("hit", "hithook")
function hithook (id, source, weapon, hpdmg)
	if (weapon < 50 or weapon > 69) then
		knockback(source, id, weapon)
	end
end

function knockcheck (x, y, rotation, knock)
	local breaks, op1, op2
	for distance = 5, math.ceil(knock), 2 do
		op1 = x + math.cos(rotation) * distance
		op2 = y + math.sin(rotation) * distance
		if (not tile(math.ceil(op1 / 32) - 1, math.ceil(op2 / 32) - 1, "walkable")) then
			breaks = true
			break
		end
	end
	return breaks
end

function knockback (id, source, weapon)
	if (weapon < 99) then
		local knock = itemtype(weapon, "dmg") / 2
		local rotation = player(id, "rot")
		if (rotation < -90) then
			rotation = rotation + 360
		end
		local angle = math.rad(math.abs(rotation + 90)) - math.pi
		x = player(source, "x") + math.cos(angle) * knock
		y = player(source, "y") + math.sin(angle) * knock
		if (not knockcheck(player(source, "x"), player(source, "y"), angle, knock)) then
			parse("setpos " .. source .. " " .. x .. " " .. y)
		end
	end
end
It is fresh from Zombie Plague. It works perfectly fine. Edited the necessary component to make it compatible without Zombie Plague data.

old Re: Knockback Script?

Yates
Reviewer Off Offline

Quote
The Zombie Plague knock back script is bugged hard. Good luck with that.

Also note that turrets and barbed wire do not knock back.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview