PDA

View Full Version : [TF2] Attach particle to player1 - player2


Arkarr
03-21-2015, 13:39
I would like to repreduce the effect when a medic heal a player. When the medic use is medigun, between the weapon and the player, there is a red/blue (depend of the team) "link", particles going from the weapon output to the player body. Is there anyway to recreate this ? I actually never tried to attach particle between two players, I don't even know if it's possible.

Chdata
03-21-2015, 13:40
It is, look at stuff like repair node.

Arkarr
03-21-2015, 14:35
It is, look at stuff like repair node.
Thanks, I will give a shot and see what I can do with that.

EDIT:
wait, this won't work ! I need something to link particles to two player, not a entity <->player

Chdata
03-21-2015, 14:52
players are an entity.

stock SetParent(iParent, iChild, const String:szAttachment[] = "", Float:vOffsets[3] = {0.0,0.0,0.0})
{
SetVariantString("!activator");
AcceptEntityInput(iChild, "SetParent", iParent, iChild);

if (szAttachment[0] != '\0') // Use at least a 0.01 second delay between SetParent and SetParentAttachment inputs.
{
SetVariantString(szAttachment); // "head"

if (!AreVectorsEqual(vOffsets, Float:{0.0,0.0,0.0})) // NULL_VECTOR
{
decl Float:vPos[3];
GetEntPropVector(iParent, Prop_Send, "m_vecOrigin", vPos);
AddVectors(vPos, vOffsets, vPos);
TeleportEntity(iChild, vPos, NULL_VECTOR, NULL_VECTOR);
AcceptEntityInput(iChild, "SetParentAttachmentMaintainOffset", iParent, iChild);
}
else
{
AcceptEntityInput(iChild, "SetParentAttachment", iParent, iChild);
}
}
}

// "medicgun_beam_blue"
stock AttachParticle2(iEnt, String:szParticleType[], iCtrl)
{
new iParti = CreateEntityByName("info_particle_system");
new iPart2 = CreateEntityByName("info_particle_system");

if (IsValidEntity(iParti) && IsValidEntity(iPart2))
{
//--------------------------------------

decl String:szCtrlParti[MAX_TARGETNAME];
Format(szCtrlParti, sizeof(szCtrlParti), "tf2ctrlpart%i", iCtrl);
DispatchKeyValue(iPart2, "targetname", szCtrlParti);
SetParent(iCtrl, iPart2, "flag"); // Set one end to follow the "control" point

//--------------------------------------

DispatchKeyValue(iParti, "effect_name", szParticleType);
DispatchKeyValue(iParti, "cpoint1", szCtrlParti);

DispatchSpawn(iParti);

SetParent(iEnt, iParti, "flag"); // Set the main end to emit from the entity

ActivateEntity(iParti);
AcceptEntityInput(iParti, "Start");

return iParti; // iPart2 can be found via "m_hControlPointEnts" probably

//--------------------------------------
}

return -1;
}

I've never tested this before, but I rewrote it from either that or another similar stock in a thread I googled for.

Arkarr
03-21-2015, 17:34
YOU ROCK ! Thanks so much !

:bacon!: SOMETHING FOR YOU (https://www.google.ch/search?q=bacon&tbm=isch) :bacon!:

Chdata
03-22-2015, 08:35
so it worked

Arkarr
03-22-2015, 08:40
so it worked
Yep.

Chdata
03-22-2015, 08:46
I wonder how many particles have multiple attachment points anyway. Doesn't merasmus's fire spell have many? Or is it just multiple particle entities?

Arkarr
03-22-2015, 09:42
No idea, totally new to this particles thing...