Forum

> > CS2D > Scripts > Check if two players are facing each other
Forums overviewCS2D overview Scripts overviewLog in to reply

English Check if two players are facing each other

26 replies
Page
To the start Previous 1 2 Next To the start

old Re: Check if two players are facing each other

Mami Tomoe
User Off Offline

Quote
I don't know if that's totally required, all you need to do is have a bot (with A.I. disabled, of course) standing while holding a Tactical Shield.

Then just give him something like Medic Armour and 250 Health Points.

Also, you'd need to have the function get called on the cs2d lua hook hit hook, and have it print the output.

Once you've done that, just try and hit the bot from different places, and you'd notice that the function will sometimes print true when it's not supposed to, or vice-versa.

But if you urgently need images, I can try and get some, perhaps even a video.

old Re: Check if two players are facing each other

Gaios
Reviewer Off Offline

Quote
@user Mami Tomoe: Dude, we just wasted the time to help you writting an algorithm to detect if players are facing each other. And now you're trying to solve totally another problem. Just do use cs2d lua hook hit and cs2d lua hook shieldhit to detect if you hit the bot. But just don't need any shield or whatsoever, because you can deny all hits to the bots by returing
return 1
on the cs2d lua hook hit hook. I have no idea what do you want to achieve, a bot to help train scanning?
> https://youtu.be/zmprNKisMWQ

old Re: Check if two players are facing each other

Mami Tomoe
User Off Offline

Quote
@user Gaios: To have shield work against more than just bullets, those won't trigger the cs2d lua hook shieldhit hook, therefore I have to use the cs2d lua hook hit, and I have to use a check (that I don't know how to make) to know if the hit was in front of the player (where the shield is held).

@user SQ: Well yeah, but originally on the first post, I said that I want to have my own Tactical Shield logic... I thought that was easy to understand, my bad.

old Re: Check if two players are facing each other

SQ
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
-- pid1 - source
-- pid2 - victim
-- works only after bullet hit check
function ShieldHit(pid1, pid2)
    if (player(pid1, "exists") == false or player(pid2, "exists") == false) then
        return(false)
    end

    if (player(pid1, "health") < 1 or player(pid2, "health") < 1) then
        return(false)
    end

    local p1, p2 = {}, {}

    p1.x = player(pid1, "x")  -- + weapon offset
    p1.y = player(pid1, "y")  -- + weapon offset

    p2.x = player(pid2, "x") 
    p2.y = player(pid2, "y")
    p2.rot = player(pid2, "rot")

    local rot = math.deg(math.atan2(p1.x - p2.x, p2.y - p1.y))

    local angleDif = ((p2.rot - rot + 180) % 360) - 180

    return(math.abs(angleDif) < 55)
end

function always() 
    
    if ShieldHit(1, 2) then
        parse("msg shieldhit *"..os.clock())
    end
   
end

addhook("always", "always")
edited 5×, last 02.06.21 10:36:00 am
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview