Raised This Month: $ Target: $400
 0% 

TF2 Particles via TempEnts


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Aviram1994
Member
Join Date: Jan 2007
Old 07-30-2008 , 20:30   Re: TF2 Particles via TempEnts
Reply With Quote #1

Forgot many things as TeamNum,player which fired and more..
Edit:
Can you explain how do we spawn a "particle system entity"?
Aviram1994 is offline
L. Duke
Veteran Member
Join Date: Apr 2005
Location: Walla Walla
Old 07-31-2008 , 10:32   Re: TF2 Particles via TempEnts
Reply With Quote #2

Quote:
Originally Posted by Aviram1994 View Post
Forgot many things as TeamNum,player which fired and more..
Edit:
Can you explain how do we spawn a "particle system entity"?
Not sure what you mean about forgetting TeamNum and player which fired. These aren't weapon projectiles, just visual effects using the particle systems that come with TF2.

Spawning a particle system entity can be done like this:

Code:
public Action:DeleteParticles(Handle:timer, any:particle)
{
    if (IsValidEntity(particle))
    {
        new String:classname[STRLENGTH];
        GetEdictClassname(particle, classname, sizeof(classname));
        if (StrEqual(classname, "info_particle_system", false))
        {
            RemoveEdict(particle);
        }
        else
        {
            LogError("DeleteParticles: not removing entity - not a particle '%s'", classname);
        }
    }
}
public ShowParticle(Float:pos[3], String:particlename[], Float:time)
{
    new particle = CreateEntityByName("info_particle_system");
    if (IsValidEdict(particle))
    {
        TeleportEntity(particle, pos, NULL_VECTOR, NULL_VECTOR);
        DispatchKeyValue(particle, "effect_name", particlename);
        ActivateEntity(particle);
        AcceptEntityInput(particle, "start");
        CreateTimer(time, DeleteParticles, particle);
    }
    else
    {
        LogError("ShowParticle: could not create info_particle_system");
    }    
}
AttachParticle(ent, String:particleType[], Float:time)
{
    new particle = CreateEntityByName("info_particle_system");
    if (IsValidEdict(particle))
    {
        new Float:pos[3];
        GetEntPropVector(ent, Prop_Send, "m_vecOrigin", pos);
        TeleportEntity(particle, pos, NULL_VECTOR, NULL_VECTOR);
        GetEntPropString(ent, Prop_Data, "m_iName", tName, sizeof(tName));
        DispatchKeyValue(particle, "targetname", "tf2particle");
        DispatchKeyValue(particle, "parentname", tName);
        DispatchKeyValue(particle, "effect_name", particleType);
        DispatchSpawn(particle);
        SetVariantString(tName);
        AcceptEntityInput(particle, "SetParent", particle, particle, 0);
        ActivateEntity(particle);
        AcceptEntityInput(particle, "start");
        CreateTimer(time, DeleteParticles, particle);
    }
    else
    {
        LogError("AttachParticle: could not create info_particle_system");
    }
}
ShowParticle spawns it at a location. AttachParticle is basically the same thing but attaches it to an entity. You can also set attachement points by using SetParentAttachment (in the same way as SetParent above). For example, when I show healthgained_blu/red I attach it to the player's head.

You'll also need to set the entities targetname to something unique before calling AttachParticle (I use something like DispatchKeyValue(ent, "targetname", TargetName); where TargetName is "myentXXX" and the XXX is the entity ID or some other unique number).
__________________
"Good grammar is essential, Robin."
- Batman

Last edited by L. Duke; 07-31-2008 at 10:36.
L. Duke 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 09:21.


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