Forum

> > CS2D > Scripts > Detect Wall.
Forums overviewCS2D overview Scripts overviewLog in to reply

English Detect Wall.

8 replies
To the start Previous 1 Next To the start

old Detect Wall.

Ajmin
User Off Offline

Quote
Hi again,
I am done with a custom projecttile script.
The happy news is that the bullet even moves through walls.
So how can i detect the walls and bounce back or atleast prevent the bullet from moving futher when it meets a wall.

Here is the scrap:
1
2
3
4
5
6
7
8
9
10
11
addhook("attack","bbb")
function bbb(id)
local h = player(id,"x")
local j = player(id,"y")
		   img[id]=image("gfx/blabla.png",0,0,0) 
			imagepos(img[id],h , j,90)
			tween_move(img[id],500,screenx[id],screeny[id])
			timer(700,"freeimage",img[id])
end

screenx and screeny are client data positions. (who cares anyway.. :/)
edited 1×, last 30.06.17 03:59:34 pm

old Re: Detect Wall.

Avo
User Off Offline

Quote
You have to make an updating function (with ms100 or always hook, for example) to check if image of your projectile isn't moving through a wall atm. Try cs2d lua cmd tile.
edited 1×, last 30.06.17 03:20:48 pm

old Re: Detect Wall.

Masea
Super User Off Offline

Quote
And to make you know,
object(imgid,"x")
and
object(imgid,"y")
can be used in this case.

Otherwise, you gotta specify your own parameters for coordinates.

old Re: Detect Wall.

Ajmin
User Off Offline

Quote
so it should be something like this?
1
if tile(object(img[id],"x"),object(img[id],"y"),"wall") then

old Re: Detect Wall.

Avo
User Off Offline

Quote
Oh, I forgot about something, if you're interested in a good code optimisation, read this. The post is two years old but you should check if it's still up-to-date.

old Re: Detect Wall.

_3yrus
User Off Offline

Quote
user Ajmin has written
Hi again,
I am done with a custom projecttile script.
The happy news is that the bullet even moves through walls.
So how can i detect the walls and bounce back or atleast prevent the bullet from moving futher when it meets a wall.

Here is the scrap:
1
2
3
4
5
6
7
8
9
10
11
addhook("attack","bbb")
function bbb(id)
local h = player(id,"x")
local j = player(id,"y")
		   img[id]=image("gfx/blabla.png",0,0,0) 
			imagepos(img[id],h , j,90)
			tween_move(img[id],500,screenx[id],screeny[id])
			timer(700,"freeimage",img[id])
end

screenx and screeny are client data positions. (who cares anyway.. :/)


do projecttiles spin when they are moving ?
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview