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

[CSGO] Bonemerging particles on model(Position on Model Random)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nue
Junior Member
Join Date: Sep 2013
Old 03-16-2019 , 00:29   [CSGO] Bonemerging particles on model(Position on Model Random)
Reply With Quote #1

How to make particles to follow model's mesh like burnning particle from sm_ignite or dead body's dissolve effects?

I know that I have to use 'position on model random' initializer in particle system but I can't guess how to handle it in sourcemod

Last edited by Nue; 03-16-2019 at 00:29.
Nue is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 03-16-2019 , 05:53   Re: [CSGO] Bonemerging particles on model(Position on Model Random)
Reply With Quote #2

https://forums.alliedmods.net/showthread.php?p=2580534

you can check how its done in the above plugin
__________________

Last edited by 8guawong; 03-16-2019 at 05:53.
8guawong is offline
Nue
Junior Member
Join Date: Sep 2013
Old 03-16-2019 , 08:12   Re: [CSGO] Bonemerging particles on model(Position on Model Random)
Reply With Quote #3

Quote:
Originally Posted by 8guawong View Post
https://forums.alliedmods.net/showthread.php?p=2580534

you can check how its done in the above plugin
https://www.youtube.com/watch?v=EbiK...ature=youtu.be
This is the result of paranting burning_character particle using that code

Code:
#include <cstrike>
#include <sdktools>
#include <clientprefs>

int MyParticle[MAXPLAYERS+1];

public OnPluginStart()
{
	HookEvent("player_spawn", Auras_PlayerSpawn);
	HookEvent("player_death", Auras_PlayerDeath);
	HookEvent("player_team", Auras_PlayerTeam);
	RegConsoleCmd("autobuy", ParticleStart);
}

public Action:ParticleStart(id, Arguments)
{
	RemoveParticlesFromPlayer(id);
	AddParticlesToPlayer(id);
}

public OnMapStart()
{
	loringlib_PrecacheEffect ( "ParticleEffect" );
	PrecacheGeneric ( "particles/burning_fx.pcf", true );
	loringlib_PrecacheParticleName ( "burning_character" );
}

stock void loringlib_PrecacheEffect ( const char[] effPath ) {
    static int table = INVALID_STRING_TABLE;
    if ( table == INVALID_STRING_TABLE )
        table = FindStringTable ( "EffectDispatch" );
        
    bool lockTable = LockStringTables ( false );
    AddToStringTable ( table, effPath );
    LockStringTables ( lockTable );
}

stock void loringlib_PrecacheParticleName ( const char[] effPath ) {
    static int table = INVALID_STRING_TABLE;
    if ( table == INVALID_STRING_TABLE )
        table = FindStringTable ( "ParticleEffectNames" );
        
    bool lockTable = LockStringTables ( false );
    AddToStringTable ( table, effPath );
    LockStringTables ( lockTable );
}

public Action:Auras_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	if(!client || !IsClientInGame(client) || !IsPlayerAlive(client) || !(2<=GetClientTeam(client)<=3))
		return Plugin_Continue;
	
	//If they had one equipped but didn't die, kill it
	RemoveParticlesFromPlayer(client);
	
	AddParticlesToPlayer(client);
	//float nulls[3];
	//AttachParticle(client, "burning_character", nulls);
	return Plugin_Continue;
}

public Action:Auras_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	if(!client || !IsClientInGame(client))
		return Plugin_Continue;
	
	//Kill the particle system when the player dies
	RemoveParticlesFromPlayer(client);

	return Plugin_Continue;
}

public Action:Auras_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	if(!client || !IsClientInGame(client))
		return Plugin_Continue;
	
	//Kill the particle system when the player dies
	RemoveParticlesFromPlayer(client);

	return Plugin_Continue;
}

public void RemoveParticlesFromPlayer(int iClient)
{
	if(MyParticle[iClient] == INVALID_ENT_REFERENCE || !IsEntParticleSystem(MyParticle[iClient]))
		return;
	
	AcceptEntityInput(MyParticle[iClient], "Kill");
}

stock bool IsEntParticleSystem(int iEntity)
{
	if (IsValidEdict(iEntity))
	{
		char sBuffer[128];
		GetEdictClassname(iEntity, sBuffer, sizeof(sBuffer));
		if (StrEqual(sBuffer, "info_particle_system", false))
		{
			return true;
		}
	}
	return false;
}

public void AddParticlesToPlayer(int iClient)
{
	int iEntity = CreateEntityByName("info_particle_system");
	MyParticle[iClient] = iEntity;
	if (IsValidEdict(iEntity) && (iClient > 0))
	{
		if (IsPlayerAlive(iClient))
		{
			// Get players current position
			new Float:vPosition[3];
			GetEntPropVector(iClient, Prop_Send, "m_vecOrigin", vPosition);
			
			// Move particle to player
			TeleportEntity(iEntity, vPosition, NULL_VECTOR, NULL_VECTOR);
			
			// Set entity name
			DispatchKeyValue(iEntity, "targetname", "particle");
			
			// Get player entity name
			decl String:szParentName[64];
			GetEntPropString(iClient, Prop_Data, "m_iName", szParentName, sizeof(szParentName));
			
			// Set the effect name
			DispatchKeyValue(iEntity, "effect_name", "burning_character");
			
			// Spawn the particle
			DispatchSpawn(iEntity);
			
			// Target the particle
			SetVariantString("!activator");
			
			// Set particle parent name
			DispatchKeyValue(iEntity, "parentname", szParentName);
			
			// Set client to parent of particle
			AcceptEntityInput(iEntity, "SetParent", iClient, iEntity, 0);
			
			// Activate the entity (starts animation)
			ActivateEntity(iEntity);
			AcceptEntityInput(iEntity, "Start");
			
			// Attach to parent model
			SetEntPropEnt(iEntity, Prop_Send, "m_hOwnerEntity", iClient);
			
			SetFlags(iEntity);
		}
	}
}

public void SetFlags(int iEdict) 
{ 
    if (GetEdictFlags(iEdict) & FL_EDICT_ALWAYS) 
    { 
        SetEdictFlags(iEdict, (GetEdictFlags(iEdict) ^ FL_EDICT_ALWAYS)); 
    } 
}

public PrecacheParticle(const String:path[])
{
	if(!FileExists(path, true, NULL_STRING))
	{
		//PrintToServer("\nParticle file \'%s\' not found.", path);
		//return;
	}

	PrecacheGeneric(path, true);
}
Nue is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 03-16-2019 , 13:25   Re: [CSGO] Bonemerging particles on model(Position on Model Random)
Reply With Quote #4

Quote:
Originally Posted by Nue View Post
https://www.youtube.com/watch?v=EbiK...ature=youtu.be
This is the result of paranting burning_character particle using that code

Code:
#include <cstrike>
#include <sdktools>
#include <clientprefs>

int MyParticle[MAXPLAYERS+1];

public OnPluginStart()
{
	HookEvent("player_spawn", Auras_PlayerSpawn);
	HookEvent("player_death", Auras_PlayerDeath);
	HookEvent("player_team", Auras_PlayerTeam);
	RegConsoleCmd("autobuy", ParticleStart);
}

public Action:ParticleStart(id, Arguments)
{
	RemoveParticlesFromPlayer(id);
	AddParticlesToPlayer(id);
}

public OnMapStart()
{
	loringlib_PrecacheEffect ( "ParticleEffect" );
	PrecacheGeneric ( "particles/burning_fx.pcf", true );
	loringlib_PrecacheParticleName ( "burning_character" );
}

stock void loringlib_PrecacheEffect ( const char[] effPath ) {
    static int table = INVALID_STRING_TABLE;
    if ( table == INVALID_STRING_TABLE )
        table = FindStringTable ( "EffectDispatch" );
        
    bool lockTable = LockStringTables ( false );
    AddToStringTable ( table, effPath );
    LockStringTables ( lockTable );
}

stock void loringlib_PrecacheParticleName ( const char[] effPath ) {
    static int table = INVALID_STRING_TABLE;
    if ( table == INVALID_STRING_TABLE )
        table = FindStringTable ( "ParticleEffectNames" );
        
    bool lockTable = LockStringTables ( false );
    AddToStringTable ( table, effPath );
    LockStringTables ( lockTable );
}

public Action:Auras_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	if(!client || !IsClientInGame(client) || !IsPlayerAlive(client) || !(2<=GetClientTeam(client)<=3))
		return Plugin_Continue;
	
	//If they had one equipped but didn't die, kill it
	RemoveParticlesFromPlayer(client);
	
	AddParticlesToPlayer(client);
	//float nulls[3];
	//AttachParticle(client, "burning_character", nulls);
	return Plugin_Continue;
}

public Action:Auras_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	if(!client || !IsClientInGame(client))
		return Plugin_Continue;
	
	//Kill the particle system when the player dies
	RemoveParticlesFromPlayer(client);

	return Plugin_Continue;
}

public Action:Auras_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	if(!client || !IsClientInGame(client))
		return Plugin_Continue;
	
	//Kill the particle system when the player dies
	RemoveParticlesFromPlayer(client);

	return Plugin_Continue;
}

public void RemoveParticlesFromPlayer(int iClient)
{
	if(MyParticle[iClient] == INVALID_ENT_REFERENCE || !IsEntParticleSystem(MyParticle[iClient]))
		return;
	
	AcceptEntityInput(MyParticle[iClient], "Kill");
}

stock bool IsEntParticleSystem(int iEntity)
{
	if (IsValidEdict(iEntity))
	{
		char sBuffer[128];
		GetEdictClassname(iEntity, sBuffer, sizeof(sBuffer));
		if (StrEqual(sBuffer, "info_particle_system", false))
		{
			return true;
		}
	}
	return false;
}

public void AddParticlesToPlayer(int iClient)
{
	int iEntity = CreateEntityByName("info_particle_system");
	MyParticle[iClient] = iEntity;
	if (IsValidEdict(iEntity) && (iClient > 0))
	{
		if (IsPlayerAlive(iClient))
		{
			// Get players current position
			new Float:vPosition[3];
			GetEntPropVector(iClient, Prop_Send, "m_vecOrigin", vPosition);
			
			// Move particle to player
			TeleportEntity(iEntity, vPosition, NULL_VECTOR, NULL_VECTOR);
			
			// Set entity name
			DispatchKeyValue(iEntity, "targetname", "particle");
			
			// Get player entity name
			decl String:szParentName[64];
			GetEntPropString(iClient, Prop_Data, "m_iName", szParentName, sizeof(szParentName));
			
			// Set the effect name
			DispatchKeyValue(iEntity, "effect_name", "burning_character");
			
			// Spawn the particle
			DispatchSpawn(iEntity);
			
			// Target the particle
			SetVariantString("!activator");
			
			// Set particle parent name
			DispatchKeyValue(iEntity, "parentname", szParentName);
			
			// Set client to parent of particle
			AcceptEntityInput(iEntity, "SetParent", iClient, iEntity, 0);
			
			// Activate the entity (starts animation)
			ActivateEntity(iEntity);
			AcceptEntityInput(iEntity, "Start");
			
			// Attach to parent model
			SetEntPropEnt(iEntity, Prop_Send, "m_hOwnerEntity", iClient);
			
			SetFlags(iEntity);
		}
	}
}

public void SetFlags(int iEdict) 
{ 
    if (GetEdictFlags(iEdict) & FL_EDICT_ALWAYS) 
    { 
        SetEdictFlags(iEdict, (GetEdictFlags(iEdict) ^ FL_EDICT_ALWAYS)); 
    } 
}

public PrecacheParticle(const String:path[])
{
	if(!FileExists(path, true, NULL_STRING))
	{
		//PrintToServer("\nParticle file \'%s\' not found.", path);
		//return;
	}

	PrecacheGeneric(path, true);
}
and............................?
__________________
8guawong is offline
Nue
Junior Member
Join Date: Sep 2013
Old 03-16-2019 , 22:13   Re: [CSGO] Bonemerging particles on model(Position on Model Random)
Reply With Quote #5

Quote:
Originally Posted by 8guawong View Post
and............................?
As the video shows burning particle does not seems to parented to player

Other than burning particles are well sticking to player but that burning particle which uses 'position on model random' initializer does not working at all.
Nue is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 03-20-2019 , 17:19   Re: [CSGO] Bonemerging particles on model(Position on Model Random)
Reply With Quote #6

Nue, can you explain please, what is removing FL_EDICT_ALWAYS flag intended for?
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
andi67
Veteran Member
Join Date: Mar 2007
Location: Somewhere near you!!!
Old 03-21-2019 , 12:28   Re: [CSGO] Bonemerging particles on model(Position on Model Random)
Reply With Quote #7

Try merging it with an attachmentpoint ex. :

SetVariantString("facemask");

or any other ........
__________________
Waiting for HL3,Day of Defeat3 ,but will it ever come? So I'm gonna play COD WW2.>>>>SM_SKINCHOOSER<<<<
>>You need Models for DODS/CSS/CSGO , than click here!!!<<
andi67 is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 03-22-2019 , 04:01   Re: [CSGO] Bonemerging particles on model(Position on Model Random)
Reply With Quote #8

Quote:
Originally Posted by Nue View Post
As the video shows burning particle does not seems to parented to player

Other than burning particles are well sticking to player but that burning particle which uses 'position on model random' initializer does not working at all.
what do you mean by its not parented?

Quote:
Originally Posted by Dragokas View Post
Nue, can you explain please, what is removing FL_EDICT_ALWAYS flag intended for?
its done so you can use settransmit on the particle i believe
__________________
8guawong is offline
Muhlex
Junior Member
Join Date: Mar 2019
Old 04-07-2019 , 10:41   Re: [CSGO] Bonemerging particles on model(Position on Model Random)
Reply With Quote #9

Having the same problem. I spawn a particle using the "Position on Model Random" Initializer, teleport it to the player's position and use SetParent to define the player as the parent. Once activated you can see it spawning at the player and then quickly being moved to the world origin where it stays for it's whole lifespan.

I am also testing this with the burning_character particle. It has the control_point_number in it's Position on Model Random Initializer set to 1, which is described in the Valve Dev Wiki as "The control point to get an entity from."

I now tried to initialize the info_particle_system with cpoint1 ("If set, control point 1 of the effect will be at this entity's location.") set to the player via DispatchKeyValue. However I don't know how to specify the client correctly, as it requires a Targetname as the value for the entity.
Muhlex 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 07:04.


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