AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction (https://forums.alliedmods.net/showthread.php?t=324345)

scorpius2k1 05-13-2020 11:07

SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction
 
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!");



Bacardi 05-13-2020 11:25

Re: SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction
 
Try set properties, after entity spawn.
CreateTimer with 0.0 seconds.

Franc1sco 05-13-2020 11:25

Re: SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction
 
That occur since always, and I used that for make my noblock in props plugin -> https://forums.alliedmods.net/showthread.php?p=2561383

scorpius2k1 05-13-2020 11:44

Re: SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction
 
Quote:

Originally Posted by Bacardi (Post 2699928)
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. :grrr:

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!");



Bacardi 05-13-2020 11:59

Re: SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction
 
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

scorpius2k1 05-13-2020 12:10

Re: SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction
 
Quote:

Originally Posted by Bacardi (Post 2699936)
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. :cry:


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. :grrr:

safetymoose 05-13-2020 15:41

Re: SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction
 
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.

scorpius2k1 05-13-2020 16:16

Re: SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction
 
Quote:

Originally Posted by safetymoose (Post 2699958)
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 :wink: 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?

safetymoose 05-14-2020 03:16

Re: SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction
 
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.

scorpius2k1 05-20-2020 16:13

Re: SetEntPropEnt "m_hOwnerEntity" Changes Collision Group & Weapon Interaction
 
Quote:

Originally Posted by safetymoose (Post 2700046)
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! :)

:bacon!::bacon!::bacon!:

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);
    }




All times are GMT -4. The time now is 09:35.

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