Forum

> > CS2D > Scripts > Check if a player hit the wall !
Forums overviewCS2D overview Scripts overviewLog in to reply

English Check if a player hit the wall !

5 replies
To the start Previous 1 Next To the start

old Check if a player hit the wall !

minos
User Off Offline

Quote
Hello guys i've searched a lot about how to check if a player hit wall but i didn't find nothing so i created this thread hoping that someone will help me. I want to check if a player hit the wall 2 times then the wall will open by using trigger.

old Re: Check if a player hit the wall !

Cure Pikachu
User Off Offline

Quote
Hmmm... Not sure if this is what you are looking for.
1. Place a cs2d entity 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
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

old Re: Check if a player hit the wall !

Masea
Super User Off Offline

Quote
@user 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 user 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 cs2d lua hook 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

old Re: Check if a player hit the wall !

Bowlinghead
User Off Offline

Quote
The grenades always land on the same "line" except they bounced over a wall.
So you check both angles - the moment the player throws the nade cs2d lua hook attack and the moment the moment the nade lands cs2d lua hook 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.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview