Raised This Month: $51 Target: $400
 12% 

Solved How to recache spawn points?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 02-06-2024 , 14:52   How to recache spawn points?
Reply With Quote #1

In my FFA plugin I created a set of virtual spawn points, I mean they do not have an entity assigned to. In player spawn event I teleport the player to random virtual spawn point. It works but I am curious if it can be done using real spawn points.

My plugin is hot swappable and therefore default entities should be replaced with FFA ones, with the ability to revert these changes multiple times. I can easily remove default spawn points, but I cannot add new ones.

I did several tests and I found out that such entities should be created in early timing only, like in plugin_precache. It looks like there is some caching mechanism to create a tree of entities, with "info_player_deathmatch" and "info_player_start" classes, to store their indexes.

But if I have to remove entities, they will no longer work once I restore them back. Is there a function I can call to "cache" those entities like the engine does after plugin_precache? Or is there only teleport option? Maybe I can somehow disable spawn entities by assigning a player to it so that engine would not consider it for spawn?

Last edited by damage220; 02-09-2024 at 23:00.
damage220 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-06-2024 , 23:06   Re: How to recache spawn points?
Reply With Quote #2

The engine doesn't "cache" entities (I don't think it actually caches anything) but the client does cache files (models, sounds, etc.). Even if you were able to enable and disable spawn points, are you sure that they would even be random? In the game I play, Day of Defeat, they are definitely not random so certain spawn points would only get used if all of the others are already taken (have a player that spawned but hasn't moved yet).
__________________

Last edited by fysiks; 02-06-2024 at 23:13.
fysiks is offline
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 02-07-2024 , 13:53   Re: How to recache spawn points?
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
The engine doesn't "cache" entities (I don't think it actually caches anything) but the client does cache files (models, sounds, etc.).
I think of it because I I see no reason why the engine does not utilize spawn points created in plugin_init or later. I think it is not reasonable to iterate all entities and check whether their classes are "info_player_deathmatch" or "info_player_start" on each player spawn. I would load a map, go through all these entities and create a tree of structures.
PHP Code:
struct sp {
  
int ent_index;
  
float origin[3];
  
float angles[3];
  
struct sp *next;
}; 
While this is only my assumption, it may explain why the engine does not recognize spawn points created after plugin_precache.

Quote:
Originally Posted by fysiks View Post
Even if you were able to enable and disable spawn points, are you sure that they would even be random? In the game I play, Day of Defeat, they are definitely not random so certain spawn points would only get used if all of the others are already taken (have a player that spawned but hasn't moved yet).
Oh, yes, default spawn points are not random. The game spawns first player in first spawn point, second player in second spawn point and so on. So it basically iterates from the first to last spawn point, but it is not a big deal for me.

Last edited by damage220; 02-07-2024 at 21:59.
damage220 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-07-2024 , 22:36   Re: How to recache spawn points?
Reply With Quote #4

Ah, so I guess I was thinking of caching in the context of files. When I save pointers or other references in a variable, I don't think of it, instinctually, as "caching" (even though it can be described that way).

In Day of Defeat, we have properties of our spawn point entities that enable or disable them depending on an assigned control point master. Not sure if Counter-Strike 1.6 has something like that.
__________________

Last edited by fysiks; 02-07-2024 at 22:54.
fysiks is offline
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 02-07-2024 , 22:58   Re: How to recache spawn points?
Reply With Quote #5

You can both remove and add player spawns at any time (not only in plugin_precache), and they will work correctly.
When a player respawns, the game goes through all the info_player_deathmatch entities. If there are no spawns at all, the player spawns at 0, 0, 0 (XYZ) coordinates.
Important note: I'm talking about Half-Life, but I don't think they changed anything in this algorithm for CS.

Ты можешь как удалять, так и добавлять спауны игроков в любой момент времени (не только в plugin_precache) и они будут работать корректно.
При респауне игрока, игра проходится по всем info_player_deathmatch ентитям. Если спаунов нет вообще, то игрок появляется в 0, 0, 0 (XYZ) координатах.
Важное замечение: говорю про Half-Life, но не думаю, что в CS поменяли что-то в этом алгоритме.
Phant is offline
Send a message via ICQ to Phant
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 02-08-2024 , 13:02   Re: How to recache spawn points?
Reply With Quote #6

Quote:
Originally Posted by Phant View Post
You can both remove and add player spawns at any time (not only in plugin_precache), and they will work correctly.
When a player respawns, the game goes through all the info_player_deathmatch entities. If there are no spawns at all, the player spawns at 0, 0, 0 (XYZ) coordinates.
Important note: I'm talking about Half-Life, but I don't think they changed anything in this algorithm for CS.

Ты можешь как удалять, так и добавлять спауны игроков в любой момент времени (не только в plugin_precache) и они будут работать корректно.
При респауне игрока, игра проходится по всем info_player_deathmatch ентитям. Если спаунов нет вообще, то игрок появляется в 0, 0, 0 (XYZ) координатах.
Важное замечение: говорю про Half-Life, но не думаю, что в CS поменяли что-то в этом алгоритме.
Unfortunately, no it does not work in 1.6, at least I do not know how to make it to work. If I remove all spawn points and add my own, I cannot even choose a team. If I were in a team the moment I deleted all spawn points and created new ones, after round end I spawn at 0, 0, 0 coordinates.
damage220 is offline
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 02-08-2024 , 13:13   Re: How to recache spawn points?
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
Ah, so I guess I was thinking of caching in the context of files. When I save pointers or other references in a variable, I don't think of it, instinctually, as "caching" (even though it can be described that way).

In Day of Defeat, we have properties of our spawn point entities that enable or disable them depending on an assigned control point master. Not sure if Counter-Strike 1.6 has something like that.
If there are more players than spawn points, it is not possible to join a team. So the engine either checks the number of spawn points for a team or set a property for an entity to assign a player to it. If the latter I wish I would have known the offset. That way I can assign a fake client to a spawn point to disable it. It seems I have to get the offset experimentally if there is any.
damage220 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-08-2024 , 22:29   Re: How to recache spawn points?
Reply With Quote #8

Is there any reason you need to disable a spawn point that you created? Could you maybe just put it near the normal spawn points so that it blends in with the map then when you move them dynamically, it'll be practically like they are new?
__________________
fysiks is offline
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 02-09-2024 , 22:27   Re: How to recache spawn points?
Reply With Quote #9

Quote:
Originally Posted by fysiks View Post
Is there any reason you need to disable a spawn point that you created? Could you maybe just put it near the normal spawn points so that it blends in with the map then when you move them dynamically, it'll be practically like they are new?
Great thought, I can even use default spawn points only and change their origins based on the current mode. I do not know why I never thought of it. Thank you.
damage220 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:43.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode