Custom spawns for tdm, domination, king of the hill gamemode. Need help with optimization!

I"m creating mods with gamemodes that have set bases only for the first spawn and on following spawns there are custom spawns which avaibility is determined by teamates and enemy positions.

How it works group activator enables first group (grazone and spawn bases) and after 50s there are group switch timers that (first one disables first group) activate our custom spawns.
Those spawns are being activated every x secounds one at the time. At my last test there were 22 spawns activated every 400milsecounds. Those spawns are modded spawns on capture point with disable enemy radius set to 20 and they are modded to have gun game respawn property teamate radius 40

I will show the whole process to visualize it easier.
First i created first spawn bases and grayzones activated by group activator (g25) at the start of the game then in entities.blk i modded spawn on capture point so i don’t have to add postfix to them later in scene.blk

respawnBaseOnCapturePoint{
  _override:b=yes
"gun_game__respawnFriendlyRadius:r"{
    value:r=40.0
    _tags:t="server"
  }
}

Than i placed spawns for each team in 11 difrent places on the map so i ended up with 22 spawns
those spawns will have diferent groups from g1 to g22 and disable enemy radius set to 20, also check interval for each of them is diferent for example 2.11 , 2.17 , 2.23 here is their code in scene.blk

entity{
  _template:t="respawnBaseOnCapturePoint"
  transform:m=[[0.387678, 0, 0.921795] [0, 1, 0] [-0.921795, 0, 0.387678] [278.267, 16.5117, 338.391]]
  gun_game__respawnFriendlyRadius:r=40
  disableEnemyRadius:r=20
  groupName:t="g1"
  team:i=1
  enemyCheckInterval:r=1.73
}

entity{
  _template:t="respawnBaseOnCapturePoint"
  transform:m=[[0.387678, 0, 0.921795] [0, 1, 0] [-0.921795, 0, 0.387678] [278.361, 16.5117, 338.613]]
  gun_game__respawnFriendlyRadius:r=40
  disableEnemyRadius:r=20
  groupName:t="g2"
  team:i=2
  enemyCheckInterval:r=1.79
}
...

Becouse our respawns will be disabled forever by enemy proximity (it’s just how they work) i needed to reactivate them from time to time during the match. I used group switch timer for that. First group switch timer will deactivate first group (g25) so first spawns are disabled and activate (g1) our first custom spawn also it will activate grazone conected to (g1)
This is the code but remember this code repeats untill group_switch_timer__time:r=800 so the match time can’t be longer then about 12minutes (adding right amount of score was neseserry)
in scene.blk

entity{
  _template:t="group_switch_timer"
  group_switch_timer__time:r=50
  group_switch_timer__deactivateGroup:t="g25"
  group_switch_timer__activateGroup:t="g1"
}

entity{
  _template:t="group_switch_timer"
  group_switch_timer__time:r=50.4
  group_switch_timer__deactivateGroup:t=""
  group_switch_timer__activateGroup:t="g2"
}

entity{
  _template:t="group_switch_timer"
  group_switch_timer__time:r=50.8
  group_switch_timer__deactivateGroup:t=""
  group_switch_timer__activateGroup:t="g3"
}

entity{
  _template:t="group_switch_timer"
  group_switch_timer__time:r=51.2
  group_switch_timer__deactivateGroup:t=""
  group_switch_timer__activateGroup:t="g4"
}

Now the accual problem :smiley:
Becouse servers are really bad those spawns would lagg the server a lot, it’s not a constant lag but from time to time game would freeze for coulpe secounds. What i did to optimise them was to activate them one at the time throuout the game and also set diferent checks intervals using primary numbers. But with current servers it’s just not enough. My ideas to optimize it even more are:

  1. reducing number of spawns to 8 per team (16 total).

  2. make grazone stay forever instead of being activated every 8s (somehow deactivation delay doesn’t work as expected when you use group switch timers so i still have to figure that out).

  3. remove modded respawns and replace them with normal spawns on capture point so they no longer check for teammate proximity.

Do you have any other ideas for optimization? I really wan"t to make those spawns work i will apreciate any piece of advice :hearts:

A solution is to increase the cooldown of the spawn form 400 milisecond to 700 milisecond so there would be less lag after each respawn