CLEO Help How do i detect if i just got shot?

CLEO related
Status
Not open for further replies.

downloadstuff

Active member
Joined
Apr 4, 2015
Messages
82
Reaction score
0
Hey guys, how do i detect in cleo if i got shot?


Code:
{$CLEO .cs}

//-------------MAIN---------------
0662: NOP "TH3RM4L" 

:NONAME_11
wait 0 

if
PLAYERACTOR_GOT_SHOT
then

0AD1: show_formatted_text_highpriority "taking bullets" time 1500 

end
jump @NONAME_11

obviously this is not the objective of detecting when i am getting shot.

but could anyone replace PLAYERACTOR_GOT_SHOT (example) with the correct function?

( p.s i do not want to save the current health and compare with previous. i just want a function that makes it prettier
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
here's some function for it, the _weaponDrawNumber is not weaponID though, you'd have to modify it
Code:
0AB1: call_scm_func @WasPlayerHit 1 Actor handle $PLAYER_ACTOR _returned 1@ _weaponDrawNumber 3@
if 1@==1
then
//player got hit
054E: clear_actor $PLAYER_ACTOR damage 
0467: clear_actor $PLAYER_ACTOR last_weapon_damage
end

//0AB1: call_scm_func @WasPlayerHit 1 Actor handle $PLAYER_ACTOR _returned 1@ _weaponDrawNumber 3@ // 1@ = 1 means that hit, 1@ == 0 means not hit
:WasPlayerHit
2@ = 0
if
031D:   actor 0@ hit_by_weapon 22 //Colt
then 
2@ = 1
3@ = 2
else
    if
    031D:   actor 0@ hit_by_weapon 23 //Silenced
    then 
    2@ = 1
    3@ = 11
    else
        if
        031D:   actor 0@ hit_by_weapon 24 //Deagle
        then 
        2@ = 1
        3@ = 4
        else
            if
            031D:   actor 0@ hit_by_weapon 25 //Shotgun
            then 
            2@ = 1
            3@ = 10
            else
                if
                031D:   actor 0@ hit_by_weapon 26 //Sawn
                then 
                2@ = 1
                3@ = 9
                else
                    if
                    031D:   actor 0@ hit_by_weapon 27 //Combat shotgun
                    then 
                    2@ = 1
                    3@ = 3
                    else
                        if
                        031D:   actor 0@ hit_by_weapon 28 //Uzi
                        then 
                        2@ = 1
                        3@ = 14
                        else
                            if
                            031D:   actor 0@ hit_by_weapon 29 //Mp5
                            then 
                            2@ = 1
                            3@ = 7
                            else
                                if
                                031D:   actor 0@ hit_by_weapon 30 //AK47
                                then 
                                2@ = 1
                                3@ = 1
                                else
                                    if
                                    031D:   actor 0@ hit_by_weapon 31 //M4
                                    then 
                                    2@ = 1
                                    3@ = 5
                                    else
                                        if
                                        031D:   actor 0@ hit_by_weapon 32 //Tec9
                                        then
                                        2@ = 1 
                                        3@ = 13
                                        else
                                            if
                                            031D:   actor 0@ hit_by_weapon 33 //Rifle
                                            then 
                                            2@ = 1
                                            3@ = 8
                                            else
                                                if
                                                031D:   actor 0@ hit_by_weapon 34 //Sniper
                                                then 
                                                2@ = 1
                                                3@ = 12
                                                else
                                                    if
                                                    031D:   actor 0@ hit_by_weapon 38 //Minigun
                                                    then 
                                                    2@ = 1
                                                    3@ = 6
                                                    end
                                                end
                                            end
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
            end
        end
    end
end
0AB2: ret 2 2@ 3@
 

downloadstuff

Active member
Joined
Apr 4, 2015
Messages
82
Reaction score
0
monday link said:
here's some function for it, the _weaponDrawNumber is not weaponID though, you'd have to modify it
Code:
0AB1: call_scm_func @WasPlayerHit 1 Actor handle $PLAYER_ACTOR _returned 1@ _weaponDrawNumber 3@
if 1@==1
then
//player got hit
054E: clear_actor $PLAYER_ACTOR damage 
0467: clear_actor $PLAYER_ACTOR last_weapon_damage
end

//0AB1: call_scm_func @WasPlayerHit 1 Actor handle $PLAYER_ACTOR _returned 1@ _weaponDrawNumber 3@ // 1@ = 1 means that hit, 1@ == 0 means not hit
:WasPlayerHit
2@ = 0
if
031D:   actor 0@ hit_by_weapon 22 //Colt
then 
2@ = 1
3@ = 2
else
    if
    031D:   actor 0@ hit_by_weapon 23 //Silenced
    then 
    2@ = 1
    3@ = 11
    else
        if
        031D:   actor 0@ hit_by_weapon 24 //Deagle
        then 
        2@ = 1
        3@ = 4
        else
            if
            031D:   actor 0@ hit_by_weapon 25 //Shotgun
            then 
            2@ = 1
            3@ = 10
            else
                if
                031D:   actor 0@ hit_by_weapon 26 //Sawn
                then 
                2@ = 1
                3@ = 9
                else
                    if
                    031D:   actor 0@ hit_by_weapon 27 //Combat shotgun
                    then 
                    2@ = 1
                    3@ = 3
                    else
                        if
                        031D:   actor 0@ hit_by_weapon 28 //Uzi
                        then 
                        2@ = 1
                        3@ = 14
                        else
                            if
                            031D:   actor 0@ hit_by_weapon 29 //Mp5
                            then 
                            2@ = 1
                            3@ = 7
                            else
                                if
                                031D:   actor 0@ hit_by_weapon 30 //AK47
                                then 
                                2@ = 1
                                3@ = 1
                                else
                                    if
                                    031D:   actor 0@ hit_by_weapon 31 //M4
                                    then 
                                    2@ = 1
                                    3@ = 5
                                    else
                                        if
                                        031D:   actor 0@ hit_by_weapon 32 //Tec9
                                        then
                                        2@ = 1 
                                        3@ = 13
                                        else
                                            if
                                            031D:   actor 0@ hit_by_weapon 33 //Rifle
                                            then 
                                            2@ = 1
                                            3@ = 8
                                            else
                                                if
                                                031D:   actor 0@ hit_by_weapon 34 //Sniper
                                                then 
                                                2@ = 1
                                                3@ = 12
                                                else
                                                    if
                                                    031D:   actor 0@ hit_by_weapon 38 //Minigun
                                                    then 
                                                    2@ = 1
                                                    3@ = 6
                                                    end
                                                end
                                            end
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
            end
        end
    end
end
0AB2: ret 2 2@ 3@

dude listen. i love you <3 worked

EDIT: if i am invincible it doesnt detect that he got shot :C
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
you could use script setting hp/armor to some static value instead of invincibility. You could also detect it by some complex calculation of all streamed players rotation and aiming/shooting animation but I think it's just too much hassle
 
Status
Not open for further replies.
Top