English Detect Wall.

8 replies
Goto Page
To the start Previous 1 Next To the start
30.06.17 01:30:27 pm
Up
JeeewNazi
User
Offline Off
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:
Code:
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
30.06.17 03:08:35 pm
Up
Avo
User
Offline Off
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
30.06.17 03:22:06 pm
Up
Masea
Super User
Offline Off
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.
Create your UI easy and fast: UI Framework | Go deeper into the darkness and test your bravery: file cs2d Outlast II Modification (27)
30.06.17 03:52:14 pm
Up
JeeewNazi
User
Offline Off
so it should be something like this?
Code:
1
if tile(object(img[id],"x"),object(img[id],"y"),"wall") then
30.06.17 04:02:23 pm
Up
Masea
Super User
Offline Off
@user JeeewNazi: Yep.
Create your UI easy and fast: UI Framework | Go deeper into the darkness and test your bravery: file cs2d Outlast II Modification (27)
03.07.17 01:04:56 pm
Up
Avo
User
Offline Off
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.
03.07.17 03:39:37 pm
Up
_3yrus
User
Offline Off
user JeeewNazi 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:
Code:
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 ?
here we go !
03.07.17 05:31:26 pm
Up
JeeewNazi
User
Offline Off
@user _3yrus: They dont.

@user Avo: I will count it avo. Anyway engi itself have helped me
doing it. I am off.
04.07.17 12:51:53 am
Up
gotya2
GAME BANNED
Offline Off
you could use something like
https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
to pre-compute the path
To the start Previous 1 Next To the start