Raised This Month: $ Target: $400
 0% 

Solved Shield entitiy detection doesn't work while player is using it?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GasmoN
Member
Join Date: Jul 2014
Old 05-28-2022 , 08:37   Re: Shield entitiy detection doesn't work while player is using it?
Reply With Quote #1

SOLUTION:

It's maybe not the best solution out there, but it does works.
So, instead of detecting the shield, I thought about detecting if entity is touching player from behind, sides, or front. Since player is fully covered in front when using shield, this way of detecting is helping me achive what I wanted. (If entity is touching player in front, it means it's touching the shield too).

And that's where I remembered about this plugin that prevents players from back stabbing.
https://forums.alliedmods.net/showpo...66&postcount=4 So after some small changes I made it work.

The code I am using in FM_Touch forward after checking if entity is touching player and all other checks:
PHP Code:
        if(is_using_shield(id))
        {    
            static 
Float:fOrigin[3];
            
pev(idpev_originfOrigin);
            
            static 
Float:fViewAngles[3]
            static 
Float:fTViewAngles[3];
            
pev(bulletpev_v_anglefTViewAngles);
            
            static 
Float:fMinAngleFloat:fMaxAngle;
            
fMinAngle fViewAngles[1] - CHECK_ANGLE;
            
fMaxAngle fViewAngles[1] + CHECK_ANGLE;
            
            if(
fMinAngle <= fTViewAngles[1] <= fMaxAngle)
            {
                
// Entity is touching player's back
            
}
            else
            {
                
// Entity is touching player's front (shield)
            
}
        } 
Define and stock used
PHP Code:
#define CHECK_ANGLE 100.0

bool:is_using_shield(id)
{
    if(
entity_get_int(id EV_INT_sequence) == 98)
    return 
true;

    return 
false;

If there is a better way of doing this, I am always up for suggestions.

Last edited by GasmoN; 05-28-2022 at 08:48.
GasmoN is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:25.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode