Raised This Month: $51 Target: $400
 12% 

Solved Spawn prop_physics


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
3ipKa
Member
Join Date: Jul 2013
Old 07-14-2022 , 07:43   Spawn prop_physics
Reply With Quote #1

Hi guys! What's the propper way to spawn prop_physics(override/multiplayer)? Now my goal is just spawn prop_physics with model i interested in. Model has .phy file but it doesn't spawn at all... I've already tried numerous methods. prop_dynamic works, but without physics and that's not what i need.
Game - l4d2, model - pipebomb, if it's important.

Last edited by 3ipKa; 08-18-2022 at 14:52. Reason: fond solution ) post #11
3ipKa is offline
3ipKa
Member
Join Date: Jul 2013
Old 07-16-2022 , 13:03   Re: Spawn prop_physics
Reply With Quote #2

Ok, I've tried code given in link, but nothing, model doesn't spawn.

Code:
#define PIPE_MODEL	"models/w_models/weapons/w_eq_pipebomb.mdl"

public void OnPluginStart()
{
	RegConsoleCmd("sm_spawnphy", spanwCMD);
}

public void OnMapStart()
{
	PrecacheModel( "models/w_models/weapons/w_eq_pipebomb.mdl", true );
}

public Action spanwCMD(int client,int args)
{
	float SpawnPosition[3], SpawnAngle[3];
	GetClientAbsOrigin( client, SpawnPosition );
	SpawnPosition[2] += 20; SpawnAngle[0] = 90.0;
	int phymdl = CreateEntityByName("prop_physics");//prop_physics_multiplayer - no effect too
	if(IsValidEdict(phymdl))
	{		
		PrintToChatAll("phymdl is valid");// fired well
		DispatchKeyValue(phymdl, "model", PIPE_MODEL);
    
		TeleportEntity(phymdl, SpawnPosition, SpawnAngle, NULL_VECTOR);
		DispatchSpawn(phymdl);
			
		DispatchKeyValue(phymdl, "StartDisabled", "false");
		DispatchKeyValue(phymdl, "Solid", "6");
			
		// DispatchKeyValue(phymdl, "spawnflags", "8"); 
		// SetEntProp(phymdl, Prop_Data, "m_CollisionGroup", 5);
		AcceptEntityInput(phymdl, "EnableCollision"); 
		AcceptEntityInput(phymdl, "TurnOn", phymdl, phymdl, 0);
			
		SetEntityMoveType(phymdl, MOVETYPE_VPHYSICS);
		SetEntProp(phymdl, Prop_Data, "m_nSolidType", 6);
		SetEntProp(phymdl, Prop_Data, "m_CollisionGroup", 2);
		SetEntProp(phymdl, Prop_Data, "m_takedamage", 0);  
	}
	return Plugin_Handled;
}
I've tried different properties. I mean DispatchKeyValue and SetEntProp with solid type, collision group properties, tried MOVETYPE_VPHYSICS, different spawnflags, tried swapping keys (teleport first than DispatchSpawn).
My goal is to spawn model with physics, I could use another one, but pipebomb fits my needs excellent. It shouldn't be pickable.

Last edited by 3ipKa; 07-16-2022 at 13:06.
3ipKa is offline
Sreaper
髪を用心
Join Date: Nov 2009
Old 07-16-2022 , 15:54   Re: Spawn prop_physics
Reply With Quote #3

Quote:
Originally Posted by 3ipKa View Post
Ok, I've tried code given in link, but nothing, model doesn't spawn.

Spoiler


I've tried different properties. I mean DispatchKeyValue and SetEntProp with solid type, collision group properties, tried MOVETYPE_VPHYSICS, different spawnflags, tried swapping keys (teleport first than DispatchSpawn).
My goal is to spawn model with physics, I could use another one, but pipebomb fits my needs excellent. It shouldn't be pickable.

Code:
#include <sdktools>

#define PIPE_MODEL	"models/props_c17/oildrum001_explosive.mdl"

public void OnPluginStart()
{
	RegConsoleCmd("sm_spawnphy", spanwCMD);
}

public void OnMapStart()
{
	PrecacheModel( "models/props_c17/oildrum001_explosive.mdl", true );
}

public Action spanwCMD(int client,int args)
{
	float SpawnPosition[3], SpawnAngle[3];
	GetClientAbsOrigin( client, SpawnPosition );
	SpawnPosition[2] += 20; SpawnAngle[0] = 90.0;
	int phymdl = CreateEntityByName("prop_physics");
	if(IsValidEdict(phymdl))
	{		
		PrintToChatAll("phymdl is valid");// fired well
		DispatchKeyValue(phymdl, "model", PIPE_MODEL);
    
		TeleportEntity(phymdl, SpawnPosition, SpawnAngle, NULL_VECTOR);
		DispatchSpawn(phymdl);
        
		DispatchKeyValue(phymdl, "StartDisabled", "false");
		DispatchKeyValue(phymdl, "Solid", "6");
			
		AcceptEntityInput(phymdl, "EnableCollision"); 
		AcceptEntityInput(phymdl, "TurnOn", phymdl, phymdl, 0);
			
		SetEntityMoveType(phymdl, MOVETYPE_VPHYSICS);
		SetEntProp(phymdl, Prop_Data, "m_nSolidType", 6);
		SetEntProp(phymdl, Prop_Data, "m_CollisionGroup", 0);
		SetEntProp(phymdl, Prop_Data, "m_takedamage", 2);

	}
	return Plugin_Handled;
}
This seems to work as intended.

Last edited by Sreaper; 07-16-2022 at 15:55.
Sreaper is offline
3ipKa
Member
Join Date: Jul 2013
Old 07-16-2022 , 16:49   Re: Spawn prop_physics
Reply With Quote #4

Unfortunately but it doesn't work. Maybe on my end only...? Tried different models...
3ipKa is offline
Sreaper
髪を用心
Join Date: Nov 2009
Old 07-16-2022 , 17:37   Re: Spawn prop_physics
Reply With Quote #5

Quote:
Originally Posted by 3ipKa View Post
Unfortunately but it doesn't work. Maybe on my end only...? Tried different models...
I used the command and spawned an explosive barrel on TF2 using it. I was able to walk into the barrel to move it as well as shoot the barrel causing it to explode. If you have Silvers dev cmds plugin check the default values of a regular prop physics in L4d to see if any values are different. Especially the m_CollisionGroup

Last edited by Sreaper; 07-16-2022 at 18:55.
Sreaper is offline
3ipKa
Member
Join Date: Jul 2013
Old 07-17-2022 , 10:45   Re: Spawn prop_physics
Reply With Quote #6

I managed to spawn oildrum001.mdl, but not w_eq_pipebomb.mdl...
I don't understant why, it has also .phy file and others... Tried some other models - dont work too.
For burrel i used m_CollisionGroup 1 and m_nSolidType 6 just for test, works fine. IDK is the reason in properties.
3ipKa is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 07-17-2022 , 11:18   Re: Spawn prop_physics
Reply With Quote #7

Try prop_physics_override
__________________
Silvers is offline
3ipKa
Member
Join Date: Jul 2013
Old 07-17-2022 , 11:48   Re: Spawn prop_physics
Reply With Quote #8

Quote:
Originally Posted by Silvers View Post
Try prop_physics_override
It didn't help
3ipKa is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 07-17-2022 , 12:22   Re: Spawn prop_physics
Reply With Quote #9

PHP Code:
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>

#define MODEL_PIPE    "models/w_models/weapons/w_eq_pipebomb.mdl"

bool g_bLeft4Dead2;

public 
APLRes AskPluginLoad2(Handle myselfbool latechar[] errorint err_max)
{
    
EngineVersion test GetEngineVersion();
    if( 
test == Engine_Left4Dead g_bLeft4Dead2 false;
    else if( 
test == Engine_Left4Dead2 g_bLeft4Dead2 true;
    else
    {
        
strcopy(errorerr_max"Plugin only supports Left 4 Dead 1 & 2.");
        return 
APLRes_SilentFailure;
    }
    return 
APLRes_Success;
}

public 
void OnPluginStart()
{
    
RegAdminCmd("sm_pipe"CmdPipeADMFLAG_ROOT);
}

public 
void OnMapStart()
{
    
PrecacheModel(MODEL_PIPE);
}

Action CmdPipe(int clientint args)
{
    
float vPos[3], vAng[3];
    if( 
SetTeleportEndPoint(clientvPos) )
    {
        
int entity CreateEntityByName("weapon_pipe_bomb");

        
vAng[0] = 90.0;
        
vPos[2] += 10;
        
TeleportEntity(entityvPosNULL_VECTORNULL_VECTOR);
        
DispatchSpawn(entity);

        
// Block +USE
        
SDKHook(entitySDKHook_UseOnUse);

        
// Remove glow
        
if( g_bLeft4Dead2 )
        {
            
SetEntProp(entityProp_Send"m_iGlowType"3);
            
SetEntProp(entityProp_Send"m_glowColorOverride"1);
            
SetEntProp(entityProp_Send"m_nGlowRange"0);
        }
    }

    return 
Plugin_Handled;
}

Action OnUse(int entity)
{
    return 
Plugin_Handled;
}

bool SetTeleportEndPoint(int clientfloat vPos[3])
{
    
GetClientEyePosition(clientvPos);
    
float vAng[3];
    
GetClientEyeAngles(clientvAng);

    
Handle trace TR_TraceRayFilterEx(vPosvAngMASK_SHOTRayType_InfiniteExcludeSelf_Filterclient);

    if( 
TR_DidHit(trace) )
    {
        
TR_GetEndPosition(vPostrace);
    }
    else
    {
        
delete trace;
        return 
false;
    }

    
delete trace;
    return 
true;
}

bool ExcludeSelf_Filter(int entityint contentsMaskany client)
{
    if( 
entity == client )
        return 
false;
    return 
true;

__________________
Silvers is offline
3ipKa
Member
Join Date: Jul 2013
Old 07-19-2022 , 08:07   Re: Spawn prop_physics
Reply With Quote #10

Thank you Silver! It's a bit hackish in my view, but it does the trick and gives some advantages Thank you guys! You're all awesome )
3ipKa is offline
Reply



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 21:26.


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