I've been doing some research into how other plugins handle sprays, and how the Source engine handles sprays itself.
Most plugins use this block of code to spray a player's spray (taken from
here):
Code:
TE_Start("Player Decal");
TE_WriteVector("m_vecOrigin", fClientEyeViewPoint);
TE_WriteNum("m_nPlayer", iClient);
TE_SendToAll();
where
fClientEyeViewPoint is the origin point and
iClient is the client index. However, I don't see a way to manipulate how the spray is displayed from here.
In the
Source 2013 multiplayer code, when a player uses
impulse 201, the engine does the following steps:
- Find who's placing a spray
- See if they have a spray set up
- Generate a hashed filename (some sort of hex value) based on the filename and player
- Get the logo based on this hashed filename (either in materials/temp or download/user_custom)
- Apply a VMT material to it (materials/decals/playerlogoXX.vmt)
- Display it in the world
However, VMT files don't determine how large a decal is; based on the info_overlay entity in Hammer, each overlay has four vectors (uv0, uv1, uv2, uv3) that determine how the spray is projected onto the brush/displacement based on its origin point.
The
C_TEPlayerDecal class only seems to expose 3 values: the player ID, the spray's origin point, and the entity ID, m_nEntity.
With this information, I can see two ways of achieving my goals:
- Use m_nEntity to manipulate the uv points of the spray before it's placed, increasing its size. This would probably be the best solution, but how would I get the entity ID of the spray before it's placed? Is it even possible to change the decal's properties given its entity index?
- Use a generic BSP decal with the player's spray based on the hashed filename. I can check the client's value of cl_logofile, get the filename, generate the hash myself, then use that to display the logo in the world. Is this a feasible approach? Is it possible?
Am I on to something, or am I misunderstanding how Source handles player sprays? Any advice would be appreciated.