Gamestudio Links
Zorro Links
Newest Posts
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (EternallyCurious, AndrewAMD, TipmyPip, Quad), 902 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
max entities exceeded??? #237566
11/20/08 18:46
11/20/08 18:46
Joined: Oct 2008
Posts: 218
Nashua NH
heinekenbottle Offline OP
Member
heinekenbottle  Offline OP
Member

Joined: Oct 2008
Posts: 218
Nashua NH
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).


I was once Anonymous_Alcoholic.

Code Breakpoint;
Re: max entities exceeded??? [Re: heinekenbottle] #237571
11/20/08 19:10
11/20/08 19:10
Joined: Oct 2008
Posts: 218
Nashua NH
heinekenbottle Offline OP
Member
heinekenbottle  Offline OP
Member

Joined: Oct 2008
Posts: 218
Nashua NH
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

Last edited by heinekenbottle; 11/20/08 19:51.

I was once Anonymous_Alcoholic.

Code Breakpoint;
Re: max entities exceeded??? [Re: heinekenbottle] #237576
11/20/08 19:28
11/20/08 19:28
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
Are all fired rockets (or other projectiles) eventually destroyed, including those which might fly into the sky and miss all collision contacts?

Re: max entities exceeded??? [Re: testDummy] #237578
11/20/08 19:33
11/20/08 19:33
Joined: Oct 2008
Posts: 218
Nashua NH
heinekenbottle Offline OP
Member
heinekenbottle  Offline OP
Member

Joined: Oct 2008
Posts: 218
Nashua NH
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.


I was once Anonymous_Alcoholic.

Code Breakpoint;
Re: max entities exceeded??? [Re: heinekenbottle] #237580
11/20/08 19:39
11/20/08 19:39
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
value of nexus (-nx)?

Re: max entities exceeded??? [Re: testDummy] #237582
11/20/08 19:50
11/20/08 19:50
Joined: Oct 2008
Posts: 218
Nashua NH
heinekenbottle Offline OP
Member
heinekenbottle  Offline OP
Member

Joined: Oct 2008
Posts: 218
Nashua NH
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.

Last edited by heinekenbottle; 11/20/08 19:58.

I was once Anonymous_Alcoholic.

Code Breakpoint;
Re: max entities exceeded??? [Re: heinekenbottle] #237630
11/21/08 03:19
11/21/08 03:19
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
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.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: max entities exceeded??? [Re: EvilSOB] #237691
11/21/08 16:06
11/21/08 16:06
Joined: Oct 2008
Posts: 218
Nashua NH
heinekenbottle Offline OP
Member
heinekenbottle  Offline OP
Member

Joined: Oct 2008
Posts: 218
Nashua NH
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

Last edited by heinekenbottle; 11/21/08 16:06.

I was once Anonymous_Alcoholic.

Code Breakpoint;
Re: max entities exceeded??? [Re: heinekenbottle] #237755
11/22/08 00:22
11/22/08 00:22
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
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


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: max entities exceeded??? [Re: EvilSOB] #237815
11/22/08 15:56
11/22/08 15:56
Joined: Oct 2008
Posts: 218
Nashua NH
heinekenbottle Offline OP
Member
heinekenbottle  Offline OP
Member

Joined: Oct 2008
Posts: 218
Nashua NH
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)


I was once Anonymous_Alcoholic.

Code Breakpoint;
Page 1 of 2 1 2

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1