I'd like some help clarifing Entities and Edicts

Werewolf

Probably not a real Werewolf
aa
Apr 12, 2011
873
309
I've had a few people in my community ask about the difference between the two, and while I *think* I have a good idea on what is and isn't and entity or edict, I'd like to clarify some points. Partly for my own curiosity sake, but also so I can actually explain this stuff to other people without getting it wrong. So what follows is what I understand the difference between them to be. Feel free to pick it apart and correct me where I am wrong, I'm here to learn!

EDIT TO CLARIFY: This isn't a guide. This is me fact checking by presenting what I know, as I understand it in the hopes that someone will correct me where I am wrong, or confirm where I am correct.

~~~~~~~

As my understanding goes, anything that has to be coordinated between players on a server is an edict, which means some entities are edicts and some are not. So for example, an env_soundscape is not an edict because it only controls what some individual players can hear in the background. A func_door is both an entity and an edict because it has to be open to everyone or closed for everyone. It can't be open for one person and closed for another person.

On a similar note, do hats and cosmetics count as entities and/or edicts? My guess is that they do as aren't most hats treated as prop_dynamics parented to players heads? Any unusual weapon or hat basically has an info_particle_system parented to the players hat or head. That would certainly make them entities, but also edicts as those props and particles have to move about the map with the player.

Which in turn leads me to wonder how many entities and edicts a basic, vanilla player is made up from? As in a totally new player with no cosmetics just spawned into a server. Wouldn't it be 1) The invisible hitbox, 2) The player model, and 3) The player's active weapon?

In comparison, what would a fancy tricked out lime scunt scout 'cost' a server? Assuming a worst case scenario, that player would also have 4) a hat, 5) a particle effect on the hat, 6) a particle effect on the active weapon, 7+8) cosmetics in the other two slots, and 9) an item in the action slot.

I should quickly add I am assuming only the players active weapon should be the only edict, because its the only one in use. But then I remembered we still have the bug where you see players holding all 3 of their weapons at the same time, so I supposed we have to a 2 more edicts. That's (theoretically) 11 in total.

Then as for anything fired by those weapons only projectiles such as rockets, stickies, arrows, balls, etc, are edicts. None of the bullet-scan weapons are/have edicts because the bullets 'travel' instantly and a value of damage is done to the target. In other words the target isn't actually 'hit' by anything, the system just pretends something did and takes of some health as if something had.

The one thing I am very certain on is the edict cap of 2048. Go over that and a server crashes. As mappers we have to be careful that our maps don't use too many edicts because once the map is loaded onto a server full of players with cosmetics, weapons, projectiles and unusual effects, the total number of edicts can creep over that hard 2048 limit and boom, crashed server.

I've seen disagreements over what the safe maximum limit we can use is, but we all seem to be in agreement that we should use as few entities as possible. Hopefully once we figure out exactly how many edicts players are made from, we can work out some scenarios with full 24 or 32 player servers.

~~~~~~~

Does what I have written sound like a fair and reasonably accurate description of the difference between the two? As I said before, feel free to pick apart what I've said and correct me where I'm wrong, I'm here to learn!
 
Last edited:

worMatty

Repacking Evangelist
aa
Jul 22, 2014
1,257
999
I think you hit the nail on the head, Werewolf. I found Snowplow's development thread to be a good example of the management of networked edicts. On a 32 player server it crashes. IIRC it has a resting number of 1800. I've always aimed to be below 1600 but even on a complex Deathrun map it turns out much lower.
 

Werewolf

Probably not a real Werewolf
aa
Apr 12, 2011
873
309
Well I'm glad I am pretty much correct, but then I did spend most of yesterday googling to try fact check bits anyway.

I think the only thing still I need to confirm is whether only the active weapon counts as an entity, or all 3? Aside from the 3 weapons at a time bug, I would suppose it is all 3 as spies would need to be able to use their pistol or sapper as well as their cloak
 

Crowbar

Spiritual preprocessor
aa
Dec 19, 2015
1,455
1,297
I think it's possible to hold up to either two (definitely at least) unusual effects or three (not sure), which makes the worst-case more of a worst-case, but of course chances that all the players will have it are close to zero, chances of many enough players even having an unusual hat not being slim only on trade servers I guess.
What I imagine it like:
The player themselves + their model + 3 hats + 3 unusual effects + action slot + weapon held + unusual effect on the weapon = 11 edicts/"worst" player.
Worth noting that projectiles and their effects are also edicts, and may end up taking up a significant part.
 

Diva Dan

hello!
aa
Mar 20, 2016
1,022
1,949
Don't forget unusual taunts with animated props (would take away the weapon edicts temporarily though)

More likely to encounter, a medic using a syringe gun- edicts get stupidly high fast!
 

Werewolf

Probably not a real Werewolf
aa
Apr 12, 2011
873
309
Don't forget unusual taunts with animated props (would take away the weapon edicts temporarily though)
Ah yes, I didn't think about those

More likely to encounter, a medic using a syringe gun- edicts get stupidly high fast!
That's not that bad actually. You can't even unload a full clip of the syringe gun before they start to disappear. I was thinking a demoman with a full Scottish Resistance clip of 14 stickies, plus a full clip of grenades (18 entities total) would cost more.
 
Last edited:

Werewolf

Probably not a real Werewolf
aa
Apr 12, 2011
873
309
Let's do some math comparing TF2 as it would have been back in 2007 to today's current situation, just to see how many edicts each would use up.

To keep things fair as possible each scenario features 2 full teams of demomen, with every player setting the maximum number of stickybombs possible and then unloading their grenade launchers. This should make each the 'worst case scenario' for what was possible at the time.

As ever, feel free to correct me where I am wrong.
EDIT: Correcting mistakes.

TF2 2007 (Vanilla)
  • Full, 24 player server
  • Players consist of just a hitbox, model and their 3 weapons. 5 x 24 = 120
  • The default stickybomb launcher can lay a maximum of 8 stickies at a time. 8 x 24 = 192
  • The grenade launcher has 4 pills in a clip. 4 x 24 = 96
  • TOTAL: 120 + 192 + 96 = 408 edicts. That's 19.92% of the engine limit of 2048, leaving 1,640 spare edicts.
TF2 2017
  • Full, 32 player server
  • For their loadout they would have:
    • Their player model, hitbox and 3 weapons (as before)
    • Assuming they have an unusual item in all 3 cosmetic slots, that's an extra 6 edicts.
    • Add in the unusual effect on the active weapon and that adds up to 12 edicts each. 12 x 32 = 384
  • The Scottish resistance can lay a maximum of 14 stickies at a time. 14 x 32 = 448
  • The grenade launcher has 4 pills in a clip. 4 x 32 = 128
  • Lets also assume that all 32 players have an unusual taunt, each consisting of a prop_dynamic and info_particle_system. After unloading their grenade clips, they use the taunt. 2 x 32 = 64
  • TOTAL: 384 + 448 + 128 + 64 = 1,024 edicts. That 50.00% of the engine limit of 2048, leaving 1,024 spare edicts.
Comparing the two scenarios, we've gone from players 'costing' the server 408 edicts to 1,024 edicts. That's a 150.98% increase! As for the number of edicts mappers can safely use, we've gone from 1,640 to 1024, a 37.56% decrease.
 
Last edited:

Crowbar

Spiritual preprocessor
aa
Dec 19, 2015
1,455
1,297
Let's do some math comparing TF2 as it would have been back in 2007 to today's current situation, just to see how many edicts each would use up.

To keep things fair as possible each scenario features 2 full teams of demomen, with every player setting the maximum number of stickybombs possible and then unloading their grenade launchers. This should make each the 'worst case scenario' for what was possible at the time.

As ever, feel free to correct me where I am wrong

TF2 2007 (Vanilla)
  • Full, 24 player server
  • Players consist of just a hitbox, model and their 3 weapons. 5 x 24 = 120
  • The default stickybomb launcher can lay a maximum of 8 stickies at a time. 8 x 24 = 192
  • The grenade launcher has 6 pills in a clip. 6 x 24 = 144
  • TOTAL: 120 + 192 + 144 = 456 edicts. That's 22.26% of the engine limit of 2048, leaving 1,592 spare edicts.
TF2 2017
  • Full, 32 player server
  • Assuming they have an unusual item in all 3 weapon slots and all 3 cosmetic slots, that's 12 edicts. Add in the hitbox and player model and that adds up to 14 edicts each. 14 x 32 = 448
  • The Scottish resistance can lay a maximum of 14 stickies at a time. 14 x 32 = 448
  • The grenade launcher has 6 pills in a clip. 6 x 32 = 192
  • Lets also assume that all 32 players have an unusual taunt, each consisting of a prop_dynamic and info_particle_system. After unloading their grenade clips, they use the taunt. 2 x 32 = 64
  • TOTAL: 448 + 448 + 192 + 64 = 1,152 edicts. That 56.25% of the engine limit of 2048, leaving just 896 spare edicts.
Comparing the two scenarios, we've gone from players 'costing' the server 456 edicts to huge 1,152 edicts. That's a 152.63% increase! As for the number of edicts mappers can safely use, we've gone from 1,592 to 896, a 43.71% decrease.
The grenade launcher has 4 pills in a clip.
Only one weapon/unusual weapon effect per player at a time I'm pretty sure.
Other than that the worst case has become much worse.
 

Werewolf

Probably not a real Werewolf
aa
Apr 12, 2011
873
309
The grenade launcher has 4 pills in a clip.
Well that shows how often I play demoman then! I'll edit my post and re-do the maths.
Only one weapon/unusual weapon effect per player at a time I'm pretty sure.
Well I working off the assumption that if we have the bug where all 3 weapons can be visible, then all 3 particle effects could be as well. Maybe I should do bugged and bug free counts as well.
 

Werewolf

Probably not a real Werewolf
aa
Apr 12, 2011
873
309
I don't suppose anyone has an idea on how many edicts an average server can see during a normal game? So normal gamemodes like Arena, CP, CTF. No mods like Deathrun or VSH.

Working out the average number of cosmetics isn't that bas, as not everyone has a full set of unusual cosmetics or weapons, and even those who do don't make the majority of a server. The only way I figure to get a good average is to use a 24 player server, assuming:
  • 1 third of those players (8 people) are new players with no cosmetics at all. 5 x 8 = 40
  • Another third have 2 non-unusual cosmetics. 7 x 8 = 56
  • The final 3rd are our 'worst case' players with as much as possible in each slot. 12 x 8 = 96
  • Total 40 + 56 + 96 = 192
What's harder to work out is the number of projectiles, gibs, dropped weapons or other edicts that aren't part of the map or part of an alive player.

I don't suppose someone has some idea of what that might be or at least a way of working it out?
 

Izotope

Sourcerer
aa
May 13, 2013
699
763
Dr. Face and I hosted a big map test of dr_playstation yesterday with 32 players total.
The server crashed almost every new round.
The map itself has a huge load of entities and edicts + all player stuff that was attempted to be spawned every round was ultimately too much.
 

worMatty

Repacking Evangelist
aa
Jul 22, 2014
1,257
999
You can of course type 'status' in console and it'll tell you how many networked edicts the server is currently hosting.

Bear in mind that not all things may be represented by an individual edict. Some things may be aspects or properties of an edict, such as player health, or weapon skin.
 

ics

http://ics-base.net
aa
Jun 17, 2010
835
537
I don't suppose anyone has an idea on how many edicts an average server can see during a normal game? So normal gamemodes like Arena, CP, CTF. No mods like Deathrun or VSH.

Average count on live gameplay with all things considered adds to 250-400 edicts with 24-32 players on full server. Depending on the map. Levels with small areas where everything happens closely, there is more shooting and more havoc, so it's easily more close to 300 than lets say 200 on average server.

In theory, if everyone picks demoman with scottish resistance, lays stickies, have all cosmetic slots in use with 3 unusuals, has unusual taunt and keeps shooting 4 pipebombs, it would be a disaster. Each demoman creates like 25-29 edicts and x 24 is... 600-696! Well over the safe limits.

Rarely when you create a map, edicts goes overboard though so you generally do not need to worry about this. Only if your map turns out to be payload and if it's especially multistage one, there is high risk of going overboard with the edicts or as i call them, dynamic entities aka things that get created and removed on the fly as game progresses. Hats, ammo from weapons like stickybombs, payload itself, control points, point_spotlights (see full list with loading a map and type in console sv_dump_edicts). Also cl_showents works on your pc. Of course you CAN go overboard by stuffing everything in it but usually, you dont.

I've ran a lot of custom maps in game servers in the past and had full server crash due to them. Sometimes it's some thing in map done wrong but most cases are the incredible count of edicts. When you design a map, it is good to keep edicts under 1400 so the map doesn't crash in high player count servers (32). Otherwise there is a risk of crashing the game.

Koth, Arena and CP maps in general usually are in no danger going overboard with edicts. Granary has only 706, Gravelpit 516 and Viaduct has only 333 in use.

Payload maps are different thing. Thundermountain which is a 3 stage payload dances on the edge with 1357 edicts but does not go over with those yet, not even on 32 slot servers. As comparison, Badwater has 1050 edicts.

Tc_hydro goes overboard (1476) and i guess snowplow that was already mentioned is the winner with 1557 edicts in use.
 

Werewolf

Probably not a real Werewolf
aa
Apr 12, 2011
873
309
Quick follow up question about giant MvM bots - Do giant robots have more entities, or are they simply scaled up in size? And do scaled up bots cost more edicts somehow?
 

Werewolf

Probably not a real Werewolf
aa
Apr 12, 2011
873
309
Also 2nd follow up I've just noticed in testing - different commands seem to generate different numbers. In this case, I loaded up cp_gravelpit and joined spectate. No bots and on a local server.

Using 'status' in the console gave me this:
Code:
tags  : cp
players : 1 humans, 0 bots (24 max)
edicts  : 509 used of 2048 max
Using 'sv_dump_edicts' on the other hand gives me this:
Code:
NumEdicts: 516
FreeEdicts: 7
Question is, which of these is this is correct? I did noticed that 516 - 7 = 509, so I'm guessing the 'status' command is the more accurate is it calculates the actual number rather than 'sv_dump_edicts' just giving the pure info? Is this reasoning correct?
 

Crowbar

Spiritual preprocessor
aa
Dec 19, 2015
1,455
1,297
I'm guessing free edicts are those that exist but don't need to be calculated or something? Is that possible?
 

Werewolf

Probably not a real Werewolf
aa
Apr 12, 2011
873
309
I'm guessing free edicts are those that exist but don't need to be calculated or something? Is that possible?
My guess is that those 7 free edicts are put aside for me. I was sat in spectate so they weren't in use, but being held aside for when I joined a team?

If that is the case, then why 7 edicts? My understanding was that a basic player cost the server 5 edicts (hitbox, model, and 3 weapons), and as I hadn't selected a team or class it would have no idea what my loadout would be, so it can't put aside for any extra edicts I might take up in the form of unusual.

Assuming my theory is true, what could the other 2 edicts be?