Forum

> > CS2D > Scripts > Detect Wall.
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Detect Wall.

8 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Detect Wall.

Ajmin
User Off Offline

Zitieren
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.. :/)
1× editiert, zuletzt 30.06.17 15:59:34

alt Re: Detect Wall.

Avo
User Off Offline

Zitieren
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.
1× editiert, zuletzt 30.06.17 15:20:48

alt Re: Detect Wall.

Masea
Super User Off Offline

Zitieren
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.

alt Re: Detect Wall.

Ajmin
User Off Offline

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

alt Re: Detect Wall.

Avo
User Off Offline

Zitieren
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.

alt Re: Detect Wall.

_3yrus
User Off Offline

Zitieren
user Ajmin hat geschrieben
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 ?
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht