Mami Tomoe: Can you screenshot both scenarios of player positions so I can test? Forum
Scripts
Check if two players are facing each other
Check if two players are facing each other
26 replies
Mami Tomoe: Can you screenshot both scenarios of player positions so I can test? Then just give him something like Medic Armour and 250 Health Points.
Also, you'd need to have the function get called on the
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.
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
hit and
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 1on the
hit hook. I have no idea what do you want to achieve, a bot to help train scanning?
https://youtu.be/zmprNKisMWQ
Mami Tomoe: It doesn't mean my algorithm is not consistent.Solving "facing each other" does not replicate shield behavior whatsoever.
Gaios: To have shield work against more than just bullets, those won't trigger the
shieldhit hook, therefore I have to use the
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).@
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. 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
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 08:36:00 am
SQ, that works well! Thank you. 


Offline