max entities exceeded???

Posted By: heinekenbottle

max entities exceeded??? - 11/20/08 18:46

Does max_entities count more than models, sprites and map entities?

I just got a max_entites exceeded error, but the F11 debug panel shows that I only have 350 entities, most of them smoke sprites that rise from a tank if it is wounded (I didn't use a particle effect because I maxed out doing the effect on the rockets the tanks fire, and that effect is actually commented out right now anyways)



Here you can see the error in the game. The entity count is 358. The error says 1000.

The error only came after I changed some code, which merely consisted of moving some vector instructions out of an if-branch and should not have increased the number of entities or functions at all (the ent_create function that those vectors concern remained in that if-branch.

Code:
//This is how the code looked before I was getting a max_entity error.

//FUNCTION cannonFire()
//fires a missile from the turret when the LMB is clicked
function cannonFire()
{
	var reload =0;					//a counter that keeps the player from machine-gunning missiles
	VECTOR muzzle;					//a vector for the vertex where the missile originates (tip of the cannon)
	VECTOR muzzle2;
	while(player.health > 0)		//while the player is alive
	{	
		if(reload <= 0)				//if reload is 0 or less
		{
			if(mouse_left)				//and LMB is pressed
			{
				
                                vec_for_vertex(muzzle,turret,58);			//find the vector for vertex #58				ent_create("rocket2.mdl",muzzle,missile);	//create a rocket with the missile action
				ent_playsound(turret,shoot,1000);			//play the gun fire sound
				reload = 1;											//set reload to 1
			}
		}
		else
		{
			reload -= 0.0625 * time_step;				//reduce reload (this is a frequency for 1 shot per second)
		}
		wait(1);			//avoid endless loops
	}
}

//This is the current code.  After making this change, the max entities error popped up.

//FUNCTION cannonFire()
//fires a missile from the turret when the LMB is clicked
function cannonFire()
{
	var reload =0;					//a counter that keeps the player from machine-gunning missiles
	VECTOR muzzle;					//a vector for the vertex where the missile originates (tip of the cannon)
	VECTOR muzzle2;
	while(player.health > 0)		//while the player is alive
	{	
		vec_for_vertex(muzzle,turret,58);			//find the vector for vertex #58
		vec_set(muzzle2,muzzle);
		muzzle2.x = muzzle.x + 3000;
		vec_to_screen(muzzle2,camera);
		crosshairPan.pos_x = muzzle2.x;
		crosshairPan.pos_y = muzzle2.y;
		if(reload <= 0)				//if reload is 0 or less
		{
			if(mouse_left)				//and LMB is pressed
			{
				
				ent_create("rocket2.mdl",muzzle,missile);	//create a rocket with the missile action
				ent_playsound(turret,shoot,1000);			//play the gun fire sound
				reload = 1;											//set reload to 1
			}
		}
		else
		{
			reload -= 0.0625 * time_step;				//reduce reload (this is a frequency for 1 shot per second)
		}
		wait(1);			//avoid endless loops
	}
}



I'm not even sure if thats the code, but I do know that I have tested the game several times last night with particles and a smoking tank, possibly two smoking tanks, and no max entities error.

The rest of the code was written with maximum entities and framerate in mind, the track the tank lays as it moves is only created once a second (rather than once a frame) while it moves. The rockets are designed so only one can be fired per second.

I tried to fix it by increasing nexus to 300, and I got "Not enough entities reserved(7500)."

I set max entities to 3000, and after reducing the total number of sprites the smoke function can produce, it still crashed with the "not enough entities reserved (3000)" error.

And this was at 200 something entities.

I even had it freeze without the smoke function running.

Is there something else to this error besides the number of entities? Or does that 1000 mean something else.

None of these models are animated, and they all have very small and simple skins (as you can see).
Posted By: heinekenbottle

Re: max entities exceeded??? - 11/20/08 19:10

Crashing after I increased max_entities to 10,000 (a bit extreme but I'm trying to figure out why its doing this) and nexus to 300, and recompiled:



I ran it again without it crashing (did not change ANYTHING) and here is the screen shot (and this is after shooting up the enemy tank so it spews smoke):



I noticed a huge difference in memory consumption in both screen shots even though I didn't change anything.

But maybe the memory consumption is different because the screen grab didn't take until I was trying to recover (note the alt-tab panel)

EDIT #2:

I think the crash that occured after the max_entities number was bumped to 10,000 had to do with an entity being spawned when the missile hits level geometry; the my.event wasn't being set to NULL (I fixed that just a few seconds ago) but this doesn't explain the max entities exceeded error.

And in case it helps, here's a screen shot of the smoke coming from the enemy tank (there was no crash when I ran it this time).



EDIT#3: Now it freezes without giving me any error message and this time the memory consumption isn't giving me a crazy number like 300,000
Posted By: testDummy

Re: max entities exceeded??? - 11/20/08 19:28

Are all fired rockets (or other projectiles) eventually destroyed, including those which might fly into the sky and miss all collision contacts?
Posted By: heinekenbottle

Re: max entities exceeded??? - 11/20/08 19:33

Originally Posted By: testDummy
Are all fired rockets (or other projectiles) eventually destroyed, including those which might fly into the sky and miss all collision contacts?


The missile action runs a while loop that is true only if it has more than zero health AND is less than 5000 units from the player. Once that condition is broken, the missile is removed via ent_remove(me).

Also, the level the models are in are surrounded by walls and right now the missiles only go straight, so they hit the walls before they exceed that range anyways.

The tracks laid by the tank remove themselves after their alpha hits 0. Same goes for the smoke.
Posted By: testDummy

Re: max entities exceeded??? - 11/20/08 19:39

value of nexus (-nx)?
Posted By: heinekenbottle

Re: max entities exceeded??? - 11/20/08 19:50

Originally Posted By: testDummy
value of nexus (-nx)?


300, which according to the manual, gives me 3000 entities. And according to the statistics, I'm only using 100-200.

I've also updated my script a bit more. Now the tank only spews smoke if its in view of the camera and the sprites remove themselves if out of view. This has lowered the number of entities drastically, around 100 if I look at a wounded tank, and 5 if not.
Posted By: EvilSOB

Re: max entities exceeded??? - 11/21/08 03:19

Couple of thing to try.

Make sure any nexus or max_entity commands are before the load_level command.

Run the level with max_entities set to 1000 and tank-tracks disabled.
If it runs clean, re-enable the tracks and put in a text-panel showing
a counter of how many are active. [xxx = proc_status(Tack_Track_Action)]
Just to tr and see what entities are going nuts.

What is probably happening, everything runs smooth, then one function somewhere
goes nuts, creating hundreds of entities (during the same frame)until the engine crashes
so your debug-entity counter doesnt get updated with the actual count.
Posted By: heinekenbottle

Re: max entities exceeded??? - 11/21/08 16:06

I just did that.

The smoke appears to cap out at around 70 instance of the function, the tracks cap out at around 160 instances of the function (I could probably reduce that further without ruining the effect) and the number of missiles that both myself and the enemy tank fires is around 5-7 at max.

I'm not getting the crash anymore, but then again, I did drastically increase max_entities.

What I was wondering though was why there was such a deficiency between the number of entities the debugger said I had and what the error message kept saying
Posted By: EvilSOB

Re: max entities exceeded??? - 11/22/08 00:22

Drop the max_entities resize for this test, and go through ALL your code
and add the following line DIRECTLY after EVERY ent_create.
Code:
diag_var("Ents=%.0f\n",num_entities);
Then run it till you get the "not enough entities reserved" error.
Then look in the acklog.txt file in your script folder and see how high
the entities count actually got at the crash
Posted By: heinekenbottle

Re: max entities exceeded??? - 11/22/08 15:56

I just did that. The game did not crash.

However, I have two guesses on what caused it:

1. When the missile hits an object, it makes an explosion. It is possible that several explosions were made at once. I did get a e1513 crash earlier with that function. This was fixed by setting the missile's events to NULL after an event.

2. There may have been too much smoke. This was fixed in three ways, the number of particles is limited to 150, the smoke effect does not occur if the spawn vector is off the camera and the sprites themselves remove themselves if they float off the camera.

Acklog was giving me 160 entities top, I could not push it any further (two smoking tanks, both shooting as fast as possible)
Posted By: testDummy

Re: max entities exceeded??? - 11/22/08 19:50

Perhaps, with some configurations, in terms of the error type, under certain conditions, shadow, decal and other elements might count against max entities?

Technique tq is used to generate n tank tracks on screen per frame...

Is a shader being used on tank smoke elements?

© 2023 lite-C Forums