Forum
Scripts
Check if a player hit the wall !
Check if a player hit the wall !
5 replies
1

1. Place a
func_dynwall entity at the location you want the wall. Get the tile coordinates for later.2. Make a map script like so:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
hit_counter = 0
wall_image = 0
wall_x = 1 -- Tile X coordinates of the wall
wall_y = 1 -- Tile Y coordinates of the wall
addhook("startround_prespawn","s")
function s()
	hit_counter = 0
	wall_image = image("<tile:"..tile(wall_x,wall_y,"frame")..">",wall_x*32,wall_y*32,3)
	imagehitzone(wall_image,102,0,0,32,32)
	-- imagehitzone(wall_image,102,-1,-1,34,34) -- if the previous imagehitzone function doesn't quite work
end
addhook("hitzone","h")
function h(iid)
	if iid == wall_image then
		hit_counter = hit_counter + 1
		if hit_counter == 2 then
			parse("triggerposition "..wall_x.." "..wall_y)
			freeimage(wall_image)
			wall_image = 0
		end
	end
end
edited 2×, last 09.05.18 12:02:43 am
Cure Pikachu: thanks but it didn't work :s . also i want to know which kind of walls will works with ?
minos: Well, he made only for a single wall you'll specify the coordinates of but I see you want it for every single wall stands on the map. And that'll be laggy (depends on how large the map is and actually how many walls in there) if we use the way of
Cure Pikachu's since it is going to spawn an image onto the walls in the map. I don't even know if the maps are going to load for huge ones.Although, I got a distinct idea. We'll be about using
attack and checking the range of the weapon player is holding. Whenever the player will shot, we will create an invisible line that will check if there is a wall until the range of the weapon could reach. But here comes another question after that, which is every weapon in CS2D does have a range value? Well, the guns and rifles probably should have but I have no idea about the rest which are grenades, melee things, etc. Hence we also need to bring the grenades that could hit more than one wall at the same time (since they are hitting to things in an area of the circle) into the idea. So good luck you who is going to deal with it
So you check both angles - the moment the player throws the nade
attack and the moment the moment the nade lands
projectile.The problem is that the damage to the wall will be applied when the nade lands; not when it hits the wall!
So its not possible practicaly.
You do know the player´s cursor position while he throws the nade theoreticly and then... good luck with that
Do you need a script for every wall? I dont think so.
Masea yes that was my idea thank you for explanation , @
Bowlinghead i want it working on melee weapons :v
1

Offline