Raised This Month: $32 Target: $400
 8% 

Solved SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 05-13-2020 , 11:07   SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction
Reply With Quote #1

When trying to spawn an entity prop, setting it's owner to a client entity via...

Code:
SetEntPropEnt(iEnt, Prop_Data, "m_hOwnerEntity", client);
...causes the prop to not collide with the player as well as no damage taken from hitscan weapons (pistol, smg, ar2, etc) while non-hitscan weapons work fine (crossbow, crowbar, etc). I should note, this is occurring on HL2DM so I am not sure if behavior is similar on other games, I would suspect it is.

If I do not set an owner entity, the prop takes damage from all weapon types and collides with the player as expected.

Any ideas here?

PHP Code:
stock void SpawnEntityAtPlayer(int client) {

    
int iEnt CreateEntityByName("prop_physics_override");

    if(
IsValidEntity(iEnt)) {
        
float fSpawnLocation[3];
        
GetClientAbsOrigin(clientfSpawnLocation);
        
fSpawnLocation[0] += 64.0;
        
fSpawnLocation[1] += 64.0;

        
DispatchKeyValue(iEnt"model""models/props_citizen_tech/guillotine001a_wheel01.mdl");
        
DispatchKeyValue(iEnt"targetname"sEntName);

        
// ???
        // FOR SOME REASON, THIS MODIFIES COLLISION GROUP WITH PLAYER
        // AND INTERACTION HITSCAN-BASED WEAPONS
        
SetEntPropEnt(iEntProp_Data"m_hOwnerEntity"client);

    
        
DispatchSpawn(iEnt);
        
TeleportEntity(iEntfSpawnLocationNULL_VECTORNULL_VECTOR);

        
HookSingleEntityOutput(iEnt"OnTakeDamage"OnPropTakeDamage);
    }
}


public 
void OnPropTakeDamage(const char [] outputint callerint activatorfloat delay) {
    
PrintToChatAll("Prop Damaged!");

__________________
{__ PIRATES COVE __} ● HIGH-KILL Community | Stats ●
Half-Life 2: Deathmatch
66.151.244.149:27016 => CONNECT

Last edited by scorpius2k1; 05-20-2020 at 16:34.
scorpius2k1 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 05-13-2020 , 11:25   Re: SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction
Reply With Quote #2

Try set properties, after entity spawn.
CreateTimer with 0.0 seconds.
Bacardi is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 05-13-2020 , 11:25   Re: SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction
Reply With Quote #3

That occur since always, and I used that for make my noblock in props plugin -> https://forums.alliedmods.net/showthread.php?p=2561383
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.

Franc1sco is offline
Send a message via MSN to Franc1sco
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 05-13-2020 , 11:44   Re: SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction
Reply With Quote #4

Quote:
Originally Posted by Bacardi View Post
Try set properties, after entity spawn.
CreateTimer with 0.0 seconds.
Great idea, I was hopeful and had not tried that but no luck, still have the issue unfortunately.

PHP Code:
stock void SpawnEntityAtPlayer(int client) {

    
int iEnt CreateEntityByName("prop_physics_override");

    if(
IsValidEntity(iEnt)) {
        
float fSpawnLocation[3];
        
GetClientAbsOrigin(clientfSpawnLocation);
        
fSpawnLocation[0] += 64.0;
        
fSpawnLocation[1] += 64.0;

        
DispatchKeyValue(iEnt"model""models/props_citizen_tech/guillotine001a_wheel01.mdl");
        
DispatchKeyValue(iEnt"targetname"sEntName);

        
DispatchSpawn(iEnt);
        
TeleportEntity(iEntfSpawnLocationNULL_VECTORNULL_VECTOR);

        
DataPack dp;
        
CreateDataTimer(0.1tSetPropOwnerdp);
        
dp.WriteCell(client);
        
dp.WriteCell(iEnt);
    }
}

public 
Action tSetPropOwner(Handle timerHandle dp) {
    
ResetPack(dp);
    
int client ReadPackCell(dp);
    
int iEnt ReadPackCell(dp);

    if(
IsValidEntity(iEnt)) {
        
// ???
        // FOR SOME REASON, THIS MODIFIES COLLISION GROUP WITH PLAYER
        // AND INTERACTION HITSCAN-BASED WEAPONS
        
SetEntPropEnt(iEntProp_Data"m_hOwnerEntity"client);
    }
}

public 
void OnPropTakeDamage(const char [] outputint callerint activatorfloat delay) {
    
PrintToChatAll("Prop Damaged!");

__________________
{__ PIRATES COVE __} ● HIGH-KILL Community | Stats ●
Half-Life 2: Deathmatch
66.151.244.149:27016 => CONNECT
scorpius2k1 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 05-13-2020 , 11:59   Re: SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction
Reply With Quote #5

Not sure does it make any change but, I think you need use Prop_Send for m_hOwnerEntity.
I haven't tested.

But look what Franc1sco offered
__________________
Do not Private Message @me
Bacardi is offline
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 05-13-2020 , 12:10   Re: SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction
Reply With Quote #6

Quote:
Originally Posted by Bacardi View Post
Not sure does it make any change but, I think you need use Prop_Send for m_hOwnerEntity.
I haven't tested.

But look what Franc1sco offered
Thanks again for your reply Bacardi. I had tried Prop_Send as well.
Code:
SetEntPropEnt(iEnt, Prop_Send, "m_hOwnerEntity", client);
The prop owner is set correctly as it was before, but the same issue is still occurring.


I believe Franc1sco had mentioned he had made use this particular "bug" to intentionally change the collision groups of props as a mention, not as a solution.

I am not sure what else to try as this definitely shouldn't be expected behavior just by changing an entity owner. Very strange.
__________________
{__ PIRATES COVE __} ● HIGH-KILL Community | Stats ●
Half-Life 2: Deathmatch
66.151.244.149:27016 => CONNECT
scorpius2k1 is offline
safetymoose
Senior Member
Join Date: Feb 2015
Old 05-13-2020 , 15:41   Re: SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction
Reply With Quote #7

It's not a bug, that is how the engine works. Same applies to goldsource games. There is no collision between an entity and it's owner.
safetymoose is offline
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 05-13-2020 , 16:16   Re: SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction
Reply With Quote #8

Quote:
Originally Posted by safetymoose View Post
It's not a bug, that is how the engine works. Same applies to goldsource games. There is no collision between an entity and it's owner.
Thanks for the reply. I had wondered if that was possibly the case and the reason I put the word "bug" in quotes It still seems odd to me why this was implemented that way. Do you by chance have any links that you have verified that is how the engine works? Not saying you're wrong, but I would like to research this a bit further as it might lead to a solution for the other side of this issue which I am more interested in -- weapons.

Prop ownership still doesn't explain what is happening to certain weapons being able to interact with the prop while some don't. One solid proof for this here is with HL2DM. A player can set SLAMS (which are also props after they are set in the world). Even with the player being the prop owner, they are still be able to interact/damage them with any weapon.

What is the difference going on here?
__________________
{__ PIRATES COVE __} ● HIGH-KILL Community | Stats ●
Half-Life 2: Deathmatch
66.151.244.149:27016 => CONNECT
scorpius2k1 is offline
safetymoose
Senior Member
Join Date: Feb 2015
Old 05-14-2020 , 03:16   Re: SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction
Reply With Quote #9

I believe owner is used for projectiles, projectiles are given the owner info so they dont collide or interact with the owner. Here are some links from HL1's engine, i assume HL2 behaves similarly.

https://github.com/dreamstalker/rehl...pp#L1246-L1247
https://github.com/dreamstalker/rehl....cpp#L524-L525
https://github.com/dreamstalker/rehl...ty_state.h#L79
https://github.com/dreamstalker/rehl...n/const.h#L514


Not sure how damage is handled tho.

Edit: Usually when i set owner to an entity, i manually block damage from the owner because i dont want the owner to damage the entity.

Last edited by safetymoose; 05-14-2020 at 03:22.
safetymoose is offline
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 05-20-2020 , 16:13   Re: SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction
Reply With Quote #10

Quote:
Originally Posted by safetymoose View Post
I believe owner is used for projectiles, projectiles are given the owner info so they dont collide or interact with the owner. Here are some links from HL1's engine, i assume HL2 behaves similarly.

https://github.com/dreamstalker/rehl...pp#L1246-L1247
https://github.com/dreamstalker/rehl....cpp#L524-L525
https://github.com/dreamstalker/rehl...ty_state.h#L79
https://github.com/dreamstalker/rehl...n/const.h#L514


Not sure how damage is handled tho.

Edit: Usually when i set owner to an entity, i manually block damage from the owner because i dont want the owner to damage the entity.
Thanks for the reply, those links really explain a lot. With that said and the engine setup the way it is I came up with another solution. It's a bit outside of the box and doesn't "technically" set the prop to an owner, but provides the same result and works perfectly for the intended use --- without blocking any weapon interaction.

Solution below if anyone may find it useful. Appreciate all the help!



PHP Code:
stock void SpawnEntityAtPlayer(int client) {

    
int iEnt CreateEntityByName("prop_physics_override");

    if(
IsValidEntity(iEnt)) {
        
float fSpawnLocation[3];
        
char sEntName[255];

        
GetClientAbsOrigin(clientfSpawnLocation);
        
fSpawnLocation[0] += 64.0;
        
fSpawnLocation[1] += 64.0;

        
Format(sEntNamesizeof(sEntName), "prop_physics_override:%i"client);

        
DispatchKeyValue(iEnt"model""models/props_c17/oildrum001.mdl");
        
DispatchKeyValue(iEnt"targetname"sEntName);

        
DispatchSpawn(iEnt);
        
TeleportEntity(iEntfSpawnLocationNULL_VECTORNULL_VECTOR);
    }
}

stock int GetClientOfPropTargetName(int iEntchar [] sTargetName) {
    if(!
IsValidEntity(iEnt)) { return -1; }

    
char sEntityTargetName[255];
    
char sBuffer[2][128];
    
int client;

    
GetEntPropString(iEntProp_Data"m_iName"sEntityTargetNamesizeof(sEntityTargetName));

    if(
StrContains(sEntityTargetNamesTargetNamefalse) != -1) {
        
ExplodeString(sEntityTargetName":"sBuffersizeof(sBuffer), sizeof(sBuffer[]), true);
        if(!
StrEqual(sBuffer[1], "")) {
            
client StringToInt(sBuffer[1]);
        }
    }

    return 
client;
}

public 
void OnPropTakeDamage(const char [] outputint callerint activatorfloat delay) {
    
int client GetClientOfPropTargetName(caller"prop_physics_override");

    if(
client && client <= MaxClients) {
        
PrintToChatAll("%N is the prop owner!"client);
    }

__________________
{__ PIRATES COVE __} ● HIGH-KILL Community | Stats ●
Half-Life 2: Deathmatch
66.151.244.149:27016 => CONNECT

Last edited by scorpius2k1; 05-20-2020 at 16:14.
scorpius2k1 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 14:02.


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