CLEO Help detect if someone is looking in my direction

CLEO related
Status
Not open for further replies.

downloadstuff

Active member
Joined
Apr 4, 2015
Messages
82
Reaction score
0
Hello. I have created this thread because it is something a bit different and i should keep posting on the other topic.

Okay basically i want to print a message whenever someone i am targetting is looking at me.

Opcode.exe gave me this code but its not working, whenever i aim to a target, doesnt matter if i aim at him from behind or not.. i want that when i aim at a target that is looking in my direction (his camera position angle) to print a message, that simple.

code not working

Code:
{$CLEO .cs}
{$INCLUDE SF}
0000: NOP

:randomshit
wait 0
IF
0AD2: 0@ = player $PLAYER_CHAR targeted_actor //IF and SET
THEN
    Actor.StorePos($PLAYER_CHAR, 1@, 2@, 3@)
    Actor.StorePos(0@, 4@, 5@, 6@)
    0AB1: @getZAngleBetweenPoints 4 from_XY 4@ 5@ and_XY 1@ 2@ store_to 7@
//    7@ *= -1.0 
    8@ = Actor.Angle(0@)
    0063: 8@ -= 7@  // (float)
    IF or
    8@ < 40.0
    8@ > -40.0
    then
    
    end





END
jump @randomshit

:getYAngleBetweenPoints
{
  Parameters:
    Passed:
      0@ - origin X
      1@ - origin Y
      2@ - origin Z
      3@ - destination X
      4@ - destination Y
      5@ - destination Z
    Result:
      7@ - absolute Y angle

  Example:
    0AB1: call_scm_func @getYAngleBetweenPoints 6 from_XYZ 0.0 0.0 0.0 and_XYZ 1.0 0.0 0.0 store_to 1@ 
}
0509: 6@ = distance_between_XY 0@ 1@ and_XY 3@ 4@ 
0063: 2@ -= 5@ 
0604: get_Z_angle_for_point 6@ 2@ store_to 7@ 
0AB2: ret 1 7@ 

:getZAngleBetweenPoints
{
  Parameters:
    Passed:
      0@ - origin X
      1@ - origin Y
      2@ - destination X
      3@ - destination Y
    Result:
      4@ - absolute Z angle

  Example:
    0AB1: call_scm_func @getZAngleBetweenPoints 4 from_XY 0.0 0.0 and_XY 1.0 0.0 store_to 1@ 
}
0063: 0@ -= 2@ 
0063: 1@ -= 3@ 
0604: get_Z_angle_for_point 0@ 1@ store_to 4@ 
0AB2: ret 1 4@

this is the code as is, i have edited it but didnt work so i posted the code that opcode originally gave me.

this code  when i aim at someone, always prints that he is looking at me.. even if he isnt
 

downloadstuff

Active member
Joined
Apr 4, 2015
Messages
82
Reaction score
0
LeHidend link said:
I don't see the snippet :S

https://ugbase.eu/snippets/get-zy-angle-between-points/

yeah i forgot to add it. but yeah its not working.. always says that he is looking at me when i aim at him from every angle
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
You right now: 
:bawww: pls help no work fix ples i has no idea how to do this pls spoon feed mehh :bawww:

Code:
{$CLEO .cs}
0000:

WHILE TRUE
    WAIT 0
    IF
    0AD2: 0@ = player $PLAYER_CHAR targeted_actor
    THEN
        04C4: store_coords_to 1@ 2@ 3@ from_actor 0@ with_offset -3.0 0.0 0.0 
        04C4: store_coords_to 4@ 5@ 6@ from_actor 0@ with_offset 3.0 100.0 0.0
        IF
        00A3:   actor $PLAYER_ACTOR sphere 0 in_rectangle_cornerA 1@ 2@ cornerB 4@ 5@
        THEN
            0AD1: "TARGET_PLAYER IS LOOKING AT YOU!" 100 

    
        END
    END
END

That is one of the easiest way. It took longer to write this post than to make that...
:looky: now bye
 

downloadstuff

Active member
Joined
Apr 4, 2015
Messages
82
Reaction score
0
Opcode.eXe link said:
You right now: 
:bawww: pls help no work fix ples i has no idea how to do this pls spoon feed mehh :bawww:

Code:
{$CLEO .cs}
0000:

WHILE TRUE
    WAIT 0
    IF
    0AD2: 0@ = player $PLAYER_CHAR targeted_actor
    THEN
        04C4: store_coords_to 1@ 2@ 3@ from_actor 0@ with_offset -3.0 0.0 0.0 
        04C4: store_coords_to 4@ 5@ 6@ from_actor 0@ with_offset 3.0 100.0 0.0
        IF
        00A3:   actor $PLAYER_ACTOR sphere 0 in_rectangle_cornerA 1@ 2@ cornerB 4@ 5@
        THEN
            0AD1: "TARGET_PLAYER IS LOOKING AT YOU!" 100 

    
        END
    END
END

That is one of the easiest way. It took longer to write this post than to make that...
:looky: now bye

it works good thanks, but what i want is using the camera position, because if the player is for example using a sawnoff and aiming by the  side, it wont trigger
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
Code:
04C4: store_coords_to 1@ 2@ 3@ from_actor 0@ with_offset -3.0 0.0 0.0 
04C4: store_coords_to 4@ 5@ 6@ from_actor 0@ with_offset 3.0 100.0 0.0
        IF
        00A3:   actor $PLAYER_ACTOR sphere 0 in_rectangle_cornerA 1@ 2@ cornerB 4@ 5@
        THEN

but isn't it neccessary to take account of desired players rotation and the angle between you and him? I never used 04C4 but i bet that the code above would cause "TARGET PLAYER IS LOOKING AT YOU" message not when his looking at you but when you're in rectangle (z-3, z+3, y0, y+100)
 

downloadstuff

Active member
Joined
Apr 4, 2015
Messages
82
Reaction score
0
monday link said:
Code:
04C4: store_coords_to 1@ 2@ 3@ from_actor 0@ with_offset -3.0 0.0 0.0 
04C4: store_coords_to 4@ 5@ 6@ from_actor 0@ with_offset 3.0 100.0 0.0
        IF
        00A3:   actor $PLAYER_ACTOR sphere 0 in_rectangle_cornerA 1@ 2@ cornerB 4@ 5@
        THEN

but isn't it neccessary to take account of desired players rotation and the angle between you and him? I never used 04C4 but i bet that the code above would cause "TARGET PLAYER IS LOOKING AT YOU" message not when his looking at you but when you're in rectangle (z-3, z+3, y0, y+100)

i think the recticle is created in front of the player, but i sort of want to create it attached to the "head bone" so that when he looks from the side, with a sawnoff of uzi for example,it would still detected. That or getting the cameraposition and creating the recticle in that direction.

i found this code and edited a bit but idk how to create the offset -3 +3 +100 etc.. and i dont even know if it would work

Code:
       19@ = SAMP.GetSAMPPlayerIDByActorHandle(0@)
        
        0BBE: samp store_player 19@ aim_data 1@
0AC8: 1@ = 32 //not sure if its 32 or 31
0C0C: 2@ = struct 1@ offset 13 size 4
0C0C: 3@ = struct 1@ offset 17 size 4
0C0C: 4@ = struct 1@ offset 21 size 4
0AC9: 1@

(code not implemented, just an idea)
 
Status
Not open for further replies.
Top