Advertisement
Prawy

Untitled

Mar 4th, 2022
23
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None
  1. getSpawnpoint_NearTeam(spawnpoints)
  2. {
  3. // level endon("intermission");
  4.  
  5. // There are no valid spawnpoints in the map
  6. if(!isdefined(spawnpoints))
  7. return undefined;
  8.  
  9. // Make a list of fully connected, non-spectating, alive players
  10. players = getentarray("player", "classname");
  11. for(i = 0; i < players.size; i++)
  12. {
  13. player = players[i];
  14.  
  15. if(player.sessionstate == "spectator" || player.sessionstate == "dead" || player == self)
  16. {
  17. // println("### ", player.name, " not considered:");
  18. //
  19. // println(" player.sessionstate == ", player.sessionstate);
  20. //
  21. // if(player == self)
  22. // println(" player == self");
  23.  
  24. continue;
  25. }
  26.  
  27. aliveplayers = add_to_array(aliveplayers, player);
  28. // println("*** ", player.name, " on team ", player.pers["team"], " added to consider list");
  29. }
  30.  
  31. // Spawn away from players if they exist, otherwise spawn at a random spawnpoint
  32. if(isdefined(aliveplayers))
  33. {
  34. // println("*** SPAWNING FARTHEST: ", self.name);
  35.  
  36. distlargest = -33554432;
  37.  
  38. for(i = 0; i < spawnpoints.size; i++)
  39. {
  40. if(wouldtelefrag(spawnpoint.origin))
  41. continue;
  42.  
  43. dist = 0;
  44.  
  45. for(j = 0; j < aliveplayers.size; j++)
  46. {
  47. if(aliveplayers[j].pers["team"] == self.pers["team"])
  48. dist = dist - (distance(spawnpoints[i].origin, aliveplayers[j].origin) * 2);
  49. else
  50. dist = dist + distance(spawnpoints[i].origin, aliveplayers[j].origin);
  51. }
  52.  
  53. if(dist > distlargest)
  54. {
  55. distlargest = dist;
  56. bestposition = spawnpoints[i];
  57. }
  58. }
  59.  
  60. spawnpoint = bestposition;
  61. }
  62. else
  63. {
  64. // println("*** SPAWNING RANDOM: ", self.name);
  65. spawnpoint = getSpawnpoint_Random(spawnpoints);
  66. }
  67.  
  68. return spawnpoint;
  69. }
Advertisement
RAW Paste Data Copied
Advertisement