1 (edited by MetaTee 2016-01-27 13:42:53)

Topic: [Coding] Check for collision between to points on map?

Hey guys,

I'm trying to check if there is a wall(or some other collision) between to points on the map.
My problem is, that >Hit< stays false in the following code, even if there is a collision between the two points.

My code:

            float Dist = pos2distance;
            bool Hit;
            Hit = false;
            for (int i = 1; i < Dist; i += 32)
            {
                vec2 TestPos = pos1 + normalize(pos2 - pos1 ) * i;

                if (Collision()->GetCollisionAt(TestPos.x, TestPos.y)&CCollision::COLFLAG_SOLID)
                {
                    Hit = true;
                }
            }

Would be great, if somebody can help me with that! Thanks!

2

Re: [Coding] Check for collision between to points on map?

Try using

int CCollision::IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision)
Real programmers don't comment their code - it was hard to write, it should be hard to understand.
Proudly verkeckt since 2010.

3

Re: [Coding] Check for collision between to points on map?

Thanks, but it does output an error at compiling:

src/game/client/components/aimbot.cpp(143): error C2664: "int CCollision::Inters
ectLine(vec2,vec2,vec2 *,vec2 *,bool)" : Konvertierung von Argument 3 von "const
 float" in "vec2 *" nicht möglich

Free translated:

src/game/client/components/aimbot.cpp(143): error C2664: "int CCollision::Inters
ectLine(vec2,vec2,vec2 *,vec2 *,bool)" : converting of Argument 3 from "const
 float" to "vec2 *" not possible

My code:

            vec2 pOutBeforeCollision;
            vec2 pOutCollision;
            Hit = Collision()->IntersectLine(OwnPosition, AimPosition, *pOutCollision, *pOutBeforeCollision, false);

4 (edited by Sushi Tee 2016-01-27 15:19:36)

Re: [Coding] Check for collision between to points on map?

should we really help someone who is trying to write a client sided aimbot?

aimbot.cpp(143)

Well I don't care. Learn how to work with pointers.

Hit = Collision()->IntersectLine(OwnPosition, AimPosition, &pOutCollision, &pOutBeforeCollision, false);

If you don't need the two positions just do:

Hit = Collision()->IntersectLine(OwnPosition, AimPosition, 0, 0, false);

If I saw this correctly you still have to check "Hit" against "Collision::COLFLAG_SOLID" after that line as it only returns "GetCollisionAt(...)".

uptee - a simple web interface for hosting and maintaining teeworlds servers
teerace - a website gathering results of trusted Race-mod servers providing global ranking and statistics
*gV* rox ^^

5 (edited by MetaTee 2016-01-27 15:40:38)

Re: [Coding] Check for collision between to points on map?

Dude thats what I expected. I'm not working on an aimbot, trust me. Just look my previous posts! Im creating a POI system. I'm work ing on a base of a aimbot, thats true. I just have not got the knowledge to create such a file by myself.
Aimposition is btw the position where you're aiming.

In the end it should not be possible to move the POIs(small flags) thought walls.

6

Re: [Coding] Check for collision between to points on map?

That's still developing into some sort of tutorial (or tips at least) on how to make a cheat, and that's not tolerated here. Closed.

Not Luck, Just Magic.