Raised This Month: $43 Target: $400
 10% 

[L4D2] Display custom screen effect particles to a client


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kazya3
Member
Join Date: Aug 2019
Location: CN
Old 07-17-2024 , 09:26   [L4D2] Display custom screen effect particles to a client
Reply With Quote #1

Description:

I'm trying to make a “hit effect hud-system” similar to CrossFire game. When the player shoots the enemy and causes damage, there will be some screen effects such as "headshot icon", "1000 Damage icon" .etc to increase the interactive feeling of the game. So I took the time to create some custom screen effects particles.

Here is some pictures:





Questions:

1. [solved]How can i Display my custom screen effect particles to a client i want? I checked some sp code and found use the function "StartMessageOne", but the "msgname" seems can’t custom..
2. [solved]Is it possible to display multiple screen effect particles at the same time?
3.When multiple screen particles are played at the same time, the particles played later are always covered by the earlier ones. I haven't find a way to change this.
4.When the particle stops, there will still be some particle effects left until the end of the life cycle. When I need to switch between multiple effects, I haven't find a way to quickly clear the residual effects..
__________________

Last edited by kazya3; 08-02-2024 at 09:38.
kazya3 is offline
King_OXO
Senior Member
Join Date: Dec 2020
Location: Brazil
Old 07-17-2024 , 16:38   Re: [L4D2] Display custom screen effect particles to a client
Reply With Quote #2

Take the idea from https://forums.alliedmods.net/showthread.php?p=2600832 But if a client needs to download the particles, it will not be possible, only if the client downloads an addon with particle_manifest manually. Because fastdl only works for models and sounds in L4D2, it does not work in .txt, pcf and vpk
__________________
_________________
Discord: gabrielbr007
YouTube: WhiteFire
Steam: WhiteFire

Last edited by King_OXO; 07-17-2024 at 16:41.
King_OXO is offline
King_OXO
Senior Member
Join Date: Dec 2020
Location: Brazil
Old 07-17-2024 , 16:46   Re: [L4D2] Display custom screen effect particles to a client
Reply With Quote #3

And to use custom particles, the player needs a particle_manifest, which needs to be in a vpk to replace the original. Valve does not update Source2009 for the player to automatically download the addon via fastdl when we update the same addon that is on the server. So the customer really needs to do everything manually
__________________
_________________
Discord: gabrielbr007
YouTube: WhiteFire
Steam: WhiteFire
King_OXO is offline
kazya3
Member
Join Date: Aug 2019
Location: CN
Old 07-17-2024 , 21:26   Re: [L4D2] Display custom screen effect particles to a client
Reply With Quote #4

Quote:
Originally Posted by King_OXO View Post
Take the idea from https://forums.alliedmods.net/showthread.php?p=2600832 But if a client needs to download the particles, it will not be possible, only if the client downloads an addon with particle_manifest manually. Because fastdl only works for models and sounds in L4D2, it does not work in .txt, pcf and vpk
Thank you for your reminders and suggestions. This plugin is designed for local host && sourcemod players, not for servers, so there is no need to worry about downloading. As you said, the steps for using this plugin on the server side will become too complicated and cumbersome. After I package the files into vpk, players who want to use the plugin only need to install it correctly.

I have also studied the source code of the plugin “custom_particle_screen_effect” before,but I still have some doubts.

PHP Code:
public Action:AttachParticle(targetString:particlename[], Float:timeFloat:origin)
{
    if (
target && IsValidEntity(target))
    {
           new 
particle CreateEntityByName("info_particle_system");
            if (
IsValidEntity(particle))
            {
                new 
Float:pos[3];
            
GetEntPropVector(targetProp_Send"m_vecOrigin"pos);
            
pos[2] += origin;
            
TeleportEntity(particleposNULL_VECTORNULL_VECTOR);
            
decl String:tName[64];
            
Format(tNamesizeof(tName), "Attach%d"target);
            
DispatchKeyValue(target"targetname"tName);
            
GetEntPropString(targetProp_Data"m_iName"tNamesizeof(tName));
            
DispatchKeyValue(particle"scale""");
            
DispatchKeyValue(particle"effect_name"particlename);
            
DispatchKeyValue(particle"parentname"tName);
            
DispatchKeyValue(particle"targetname""particle");
            
DispatchSpawn(particle);
            
ActivateEntity(particle);
            
SetVariantString(tName);
            
AcceptEntityInput(particle"SetParent"particleparticle);
            
AcceptEntityInput(particle"Enable");
            
AcceptEntityInput(particle"start");
            
CreateTimer(timeDeleteParticlesparticleTIMER_FLAG_NO_MAPCHANGE);
        }
    }

I noticed that the author used the AttachParticle function to play screen effect particles to the specified client. In the function, I found that the logic is to name the specified client and set it as the parent of the particle, and then play the particle. Can the particle be played by the specified client after "setting client as the parent"? I have some doubts about this.
__________________

Last edited by kazya3; 07-17-2024 at 21:45.
kazya3 is offline
kazya3
Member
Join Date: Aug 2019
Location: CN
Old 07-20-2024 , 11:02   Re: [L4D2] Display custom screen effect particles to a client
Reply With Quote #5

I tried the plugin “custom_particle_screen_effect” and the screen particles play for all players instead of the Incapped player when a player Incap.
__________________
kazya3 is offline
kazya3
Member
Join Date: Aug 2019
Location: CN
Old 07-20-2024 , 13:01   Re: [L4D2] Display custom screen effect particles to a client
Reply With Quote #6

Solved. I found a stock from "Lux" to do that.
PHP Code:
/*    "Lux" for the "TE_SetupParticleAttachment" method and code
    https://github.com/LuxLuma/Lux-Library/blob/master/scripting/include/lux_library.inc
*/

/**
 * Sets up a particle effect's attachment.
 *
 * @param iParticleIndex     Particle index.
 * @param sAttachmentName    Name of attachment.
 * @param iEntIndex        Entity index of the particle.
 * @param bFollow        True to make the particle follow attachment points, false otherwise.
 *
 * @error            Invalid effect index.
 **/
stock void TE_SetupParticleAttachment(int iParticleIndexint iAttachmentIndexint iEntIndexbool bFollow=false)
{
    static 
float vecDummy[3]={0.00.00.0};
    static 
EngineVersion IsEngine;
    if(
IsEngine == Engine_Unknown)
        
IsEngine GetEngineVersion();

    
TE_Start("EffectDispatch");

    
TE_WriteFloat(IsEngine == Engine_Left4Dead2 "m_vOrigin.x"    :"m_vOrigin[0]"vecDummy[0]);
    
TE_WriteFloat(IsEngine == Engine_Left4Dead2 "m_vOrigin.y"    :"m_vOrigin[1]"vecDummy[1]);
    
TE_WriteFloat(IsEngine == Engine_Left4Dead2 "m_vOrigin.z"    :"m_vOrigin[2]"vecDummy[2]);
    
TE_WriteFloat(IsEngine == Engine_Left4Dead2 "m_vStart.x"    :"m_vStart[0]"vecDummy[0]);
    
TE_WriteFloat(IsEngine == Engine_Left4Dead2 "m_vStart.y"    :"m_vStart[1]"vecDummy[1]);
    
TE_WriteFloat(IsEngine == Engine_Left4Dead2 "m_vStart.z"    :"m_vStart[2]"vecDummy[2]);

    static 
int iEffectIndex INVALID_STRING_INDEX;
    if(
iEffectIndex 0)
    {
        
iEffectIndex __FindStringIndex2(FindStringTable("EffectDispatch"), "ParticleEffect");
        if(
iEffectIndex == INVALID_STRING_INDEX)
            
SetFailState("Unable to find EffectDispatch/ParticleEffect indexes");
    }

    
TE_WriteNum("m_iEffectName"iEffectIndex);
    
TE_WriteNum("m_nHitBox"iParticleIndex);
    
TE_WriteNum("entindex"iEntIndex);
    
TE_WriteNum("m_nAttachmentIndex"iAttachmentIndex);
    
TE_WriteNum("m_fFlags"1);    //needed for attachments to work

    
TE_WriteVector("m_vAngles"vecDummy);
    
TE_WriteFloat("m_flMagnitude"0.0);
    
TE_WriteFloat("m_flScale"1.0);
    
TE_WriteFloat("m_flRadius"0.0);

    if(
IsEngine == Engine_Left4Dead2)
    {
        
TE_WriteNum("m_nDamageType"bFollow 4);
    }
    else
    {
        
TE_WriteNum("m_nDamageType"bFollow 3);
    }

__________________

Last edited by kazya3; 07-20-2024 at 13:03.
kazya3 is offline
kazya3
Member
Join Date: Aug 2019
Location: CN
Old 08-02-2024 , 09:29   Re: [L4D2] Display custom screen effect particles to a client
Reply With Quote #7

There are still some questions about screen effect particles.
  • When multiple screen particles are played at the same time, the particles played later are always covered by the earlier ones. I haven't find a way to change the material levels, there's a Z-Fight.
  • When the particle stops, there will still be some particle effects left until the end of the life cycle. When I need to switch between multiple effects, I haven't find a way to quickly clear the residual effects..
__________________

Last edited by kazya3; 08-02-2024 at 09:42.
kazya3 is offline
Paimon
Member
Join Date: Jul 2021
Location: Zootopia
Old 08-03-2024 , 08:26   Re: [L4D2] Display custom screen effect particles to a client
Reply With Quote #8

Quote:
Originally Posted by kazya3 View Post
There are still some questions about screen effect particles.
  • When multiple screen particles are played at the same time, the particles played later are always covered by the earlier ones. I haven't find a way to change the material levels, there's a Z-Fight.
  • When the particle stops, there will still be some particle effects left until the end of the life cycle. When I need to switch between multiple effects, I haven't find a way to quickly clear the residual effects..
No way to operate a shown TempEntity, because once you send the TE, it will become client-side. (Based on what I know. Correct me if I’m wrong.)
__________________

Last edited by Paimon; 08-03-2024 at 08:31.
Paimon 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 08:43.


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