Post: Limiting entity spawning
12-06-2015, 02:22 PM #1
BullyWiiPlaza
Climbing up the ladder
(adsbygoogle = window.adsbygoogle || []).push({}); How do I get the amount of entities currently spawned of one kind or in total to make sure a limit isn't exceeded? I'm having the problem of crashing the lobby with an error message when I spawn too many care packages or attack dogs. What would you suggest to make sure it doesn't happen? I'm looking for a You must login or register to view this content. and not something like "You can only call the function x times" so it's fine if older entities are deleted. Thanks Smile

    shootRealDogs()
{
self endon("disconnect");
self endon("stopShootingDogs");

while(true)
{
self waittill("weapon_fired");

dog_spawner = getEnt("dog_spawner", "targetname");
level.dog_abort = false;

// No dog spawners
if(!isDefined(dog_spawner))
{
return;
}

direction = self getPlayerAngles();
direction_vec = anglesToForward(direction);
eye = self GetEye();

scale = 8000;
direction_vec = (direction_vec[0] * scale, direction_vec[1] * scale, direction_vec[2] * scale);
trace = bulletTrace(eye, eye + direction_vec, 0, undefined);

nodes = getNodesInRadius(trace["position"], 256, 0, 128, "Path", Cool Man (aka Tustin);

// No nodes found
if (nodes.size == 0)
{
return;
}

node = getClosest(trace["position"], nodes);

maps\mp\killstreaks\_dogs::dog_manager_spawn_dog(self, self.team, node, 5);
}
}

    shootFakeCarePackages()
{
self endon("death");
level endon("game_ended");
self endon("stopFakeCarePackageBullets");

while(true)
{
self waittill ("weapon_fired");

forward = self getTagOrigin("j_head");
end = self thread vector_scal(anglestoforward(self getPlayerAngles()), 1000000);
SPLOSIONlocation = BulletTrace( forward, end, 0, self )["position"];
M = spawn("script_model",SPLOSIONlocation);
M setModel("t6_wpn_supply_drop_ally");
}
}

vector_scal(vec, scale)
{
vec = (vec[0] * scale, vec[1] * scale, vec[2] * scale);
return vec;
}


Edit:
Okay, I fixed the dog spawning issues Smile

    maximumSpawnedDogs = 30; // Do not go higher

currentlySpawnedDogs = maps\mp\killstreaks\_dogs::dog_manager_get_dogs();

if(currentlySpawnedDogs.size == maximumSpawnedDogs)
{
// Make sure we don't cause a spawning error
currentlySpawnedDogs[0] delete();
}
(adsbygoogle = window.adsbygoogle || []).push({});
12-06-2015, 03:24 PM #2
Exelo
Banned
I think it would be great actually that you wait 1 or 2 day before posting a thread in the help section in-case you find out yourself what you need.
Just like you did partially for this thread.

The following user thanked Exelo for this useful post:

Procyon
12-06-2015, 07:20 PM #3
BullyWiiPlaza
Climbing up the ladder
Exelo, I disagree. If I don't post anything, others who wonder the same will not be helped so I'm doing this as well for sharing my knowledge with the community. I could also wait and post this as a release, then nobody would complain. Besides, in programming terms, launching an additional thread (the community) besides a single thread (which is me) is more efficient. Especially since it most likely is of other people's interest as well lol.

The following 3 users say thank you to BullyWiiPlaza for this useful post:

DoraTheKiller97, Exelo, PhalaxAero
12-06-2015, 07:48 PM #4
jwm614
NextGenUpdate Elite
Originally posted by BullyWiiPlaza View Post
How do I get the amount of entities currently spawned of one kind or in total to make sure a limit isn't exceeded? I'm having the problem of crashing the lobby with an error message when I spawn too many care packages or attack dogs. What would you suggest to make sure it doesn't happen? I'm looking for a You must login or register to view this content. and not something like "You can only call the function x times" so it's fine if older entities are deleted. Thanks Smile

    shootRealDogs()
{
self endon("disconnect");
self endon("stopShootingDogs");

while(true)
{
self waittill("weapon_fired");

dog_spawner = getEnt("dog_spawner", "targetname");
level.dog_abort = false;

// No dog spawners
if(!isDefined(dog_spawner))
{
return;
}

direction = self getPlayerAngles();
direction_vec = anglesToForward(direction);
eye = self GetEye();

scale = 8000;
direction_vec = (direction_vec[0] * scale, direction_vec[1] * scale, direction_vec[2] * scale);
trace = bulletTrace(eye, eye + direction_vec, 0, undefined);

nodes = getNodesInRadius(trace["position"], 256, 0, 128, "Path", Cool Man (aka Tustin);

// No nodes found
if (nodes.size == 0)
{
return;
}

node = getClosest(trace["position"], nodes);

maps\mp\killstreaks\_dogs::dog_manager_spawn_dog(self, self.team, node, 5);
}
}

    shootFakeCarePackages()
{
self endon("death");
level endon("game_ended");
self endon("stopFakeCarePackageBullets");

while(true)
{
self waittill ("weapon_fired");

forward = self getTagOrigin("j_head");
end = self thread vector_scal(anglestoforward(self getPlayerAngles()), 1000000);
SPLOSIONlocation = BulletTrace( forward, end, 0, self )["position"];
M = spawn("script_model",SPLOSIONlocation);
M setModel("t6_wpn_supply_drop_ally");
}
}

vector_scal(vec, scale)
{
vec = (vec[0] * scale, vec[1] * scale, vec[2] * scale);
return vec;
}


Edit:
Okay, I fixed the dog spawning issues Smile

    maximumSpawnedDogs = 30; // Do not go higher

currentlySpawnedDogs = maps\mp\killstreaks\_dogs::dog_manager_get_dogs();

if(currentlySpawnedDogs.size == maximumSpawnedDogs)
{
// Make sure we don't cause a spawning error
currentlySpawnedDogs[0] delete();
}


look at my forge menu
12-06-2015, 08:45 PM #5
Procyon
Gym leader
Originally posted by BullyWiiPlaza View Post
Exelo, I disagree. If I don't post anything, others who wonder the same will not be helped so I'm doing this as well for sharing my knowledge with the community. I could also wait and post this as a release, then nobody would complain. Besides, in programming terms, launching an additional thread (the community) besides a single thread (which is me) is more efficient. Especially since it most likely is of other people's interest as well lol.


You're allowed to ask questions, but please not five every day...

The following user thanked Procyon for this useful post:

Exelo
12-06-2015, 08:50 PM #6
BullyWiiPlaza
Climbing up the ladder
Originally posted by Procyon View Post
You're allowed to ask questions, but please not five every day...

I'm fine with just 1 per day on average Winky Winky xD

By the way, You must login or register to view this content. is the guide.

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo