Author Topic: Smart Spawn  (Read 1501 times)

0 Members and 1 Guest are viewing this topic.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Smart Spawn
« on: August 08, 2013, 08:19:11 am »
Script Name: Smart Spawn
Author: Curt
Server/Core Version: 2.7.5 SC3
Version: 0.1

Are you sick of being a lonely player in a server running around trying to find your team mates since you respawned far away? Are you tired of being bullied around by your enemies because you spawned right on top of them? Good news everyone who answered yes to either of these questions! Now there is the Smart Spawn script for Soldat! It is designed such that you respawn close to your friendly team mates, and away from those mean enemies. Let's take a look at what this means.

In the images below, the height of the blue curve is the probability that you will spawn there, if there is a spawn point there. The green dots are your team mates, and the red does are your enemies.



You can see here you will more likely spawn near your nice and happy team mates on the left or the right, and less likely to spawn in the middle of those nasty enemies in the middle are at.



Oh no! They went ahead and attacked the our right party! While the battle is taking place, we are less likely to spawn in that area. We wouldn't want to disturb their fun, now would we? It wouldn't be very fair for you if enemies just spawned on you in the middle of a battle; and similarly, it wouldn't be very fair if you spawned in the middle of that battle.

So let us take a look of this in action! Everybody loves videos, right?!

https://www.youtube.com/watch?v=z8E36_K7PeA

Here on ctf_Kampf, you can clearly see how usually the teams spawn away from each other typically on opposite sides. The silly bots like that bottom right corner.

https://www.youtube.com/watch?v=H-2pBKXE-eM

Some more action on Arena2! A nice small map where I can record most of the action without moving the camera :D. Be sure to watch where the bots spawn.

This script comes with another sub-script called the Spawn Merger that makes Smart Spawn a little better and more useful. What this does is it creates new spawn points on top of existing spawn points for the other teams. Many maps are designed such that teams spawn purposefully in certain locations, where different 'corners' of the map are for different teams. This behavior is not desired for use of the Smart Spawn because it is limiting where players can spawn. Thus why I came up with the Smart Spawn script. It can be clearly seen in action in the first video above of ctf_Kampf where both alpha and bravo teams are spawning on both sides of the map.

Quote from: README.txt
##### What is Smart Spawn:

Smart Spawn modifies spawn points on the server throughout the game such that players are more likely to spawn close to their allies, and less likely to spawn close to their enemies.


##### What is Spawn Merger:

Spawn Merger modifies the spawn points once at the beginning of a new map such that the team spawn points are merged. What this means is, with the exception of the first respawn, will be capable of respawning whereever anybody else was able to respawn at.

This script comes with Spawn Merger built in, and is enabled by default.


##### Configuring the script:

It is possible to configure the script by modifying config.ini. Under the [Defines] category, adding any of the following text will change the bahaviour by the description provided:

SPAWNMERGER
Enable Spawn Merger. If this is not set, Spawn Merger will not be in use, and all the other related configurations will be ignored.

SPAWNMERGERDM
Include team 0 in the list of teams to merge spawns with.

SPAWNMERGER2
Include only teams 1 and 2 (and 0 if SPAWNMERGERDM is set) in the list of teams to merge spawns with, independant of the gamemode. This is particularly useful if the gamemode it a team deathmatch, but only teams 1 and 2 are in use.

SP_WELCOMEMESSAGE
Welcomes players into the server. This will inform joining players simply how Smart Spawn changes the server.

SP_UPDATEONKILL
Updates the spawn points right after somebody is killed.

SP_UPDATEONAFTERRESPAWN
Updates the spawn points right after a player respawns. This is used to make it less likely for enemies to spawn at the same spawn point as you or near you right after you spawn. Similarly, this makes allies more likely to spawn at the same spawn point as you or near you.
Warning: When developing this script, errors were encountered when using this. It is advised not to use this.

SP_HIDEWARNINGS
It is possible that the number of spawn points allowed in the server at a given time reaches its maximum. When this happens, the script writes to the console a warning message saying that so more spawn points are available. Enabling this will remove this warning from appearing.

SP_DEBUG1
Used for debugging purposes. Every time the spawn points are updated, this will write to the console showing how many spawn points there are for each team. This compares how many spawn points the script expects and compares that to the actual number of spawn points. If they do not match, an error is shown.

SP_DEBUG2
Used for debugging purposes. Every time the spawn points are updated, this will write to the console stating whether new spawn points are needed to be made, or existing spawn points are needed to be removed.

SP_DEBUG
Enables SP_DEBUG1.

DEBUG
Enables SP_DEBUG1.


##### More advanced configuration:

It is possible to modify or replace the default spawn probability calculation formula. The calculation is a two-step process:

1) Calculate weights for each spawn point, later normalized. The default method is:

The current method for calculating weights (1) is:
Weight = FoeFactor / FriendlyFactor, where
FriendlyFactor = (sum(Distance^2) + SP_Smoothing^2) / FriendlyCounter, where Distance is the distance between the spawn point and each friendly player, and FriendlyCounter is the total number of allied players
FoeFactor = (sum(Distance^2) + SP_Smoothing^2) / FoeCounter, where Distance is the distance between the spawn point and each enemy player, and FoeCounter is the total number of enemy players

2) Calculate the number of server spawn points per spawn point. The default method is:

Floor(SP_Offset + SP_Gain * Weight)

The constants SP_Smoothing, SP_Offset, SP_Gain, SP_VDistGain, SP_HDistGain can be found in smartspawn.pas. The default values are with a description:

SP_Smoothing = 25.0;
Used in calculating weight. Smooths out the distance formula such that not only spawns that you are on top of but ones that you are near are also more likely.

SP_HDistGain = 1.0;
Used in calculating weight. The gain for horizontal (x) distances. Typically this is a value near one.

SP_VDistGain = 0.6;
Used in calculating weight. The gain for vertical (y) distances. Typically this is a value near one. Lower values are better for maps with a lot of horizontal spread and multiple paths on top of each other, such as Arena2. An example value of 0.4 means vertical distances are treated 2.5 (1/0.4) times larger than they appear. Imagine stretching the map vertically by that much.

SP_Gain = 5.7;
Used in calculating server spawn points. The multiplier for the weight (a number between 0 and 1).

SP_Offset = 0.8;
Used in calculating server spawn points. The offset number of spawn points. When this is 1, all spawn points will have at least one server spawn point, making the weight a little less effective.

To replace the method for calculating the weight, store a function pointer in SP_CalculateWeight. Similarly, to replace the method for calculating the number of server spawns, store a function pointer in SP_CalculateSpawnCount. The following types are defined for each variable, respectively:
SP_TCalculateWeight = function(const Team, Index: byte): double;
SP_TCalculateSpawnCount = function(const Team, Index: byte; const Weight: double): byte;


#### Special notes:

This script was made in Script Core 3 in server versions 2.6.4 and 2.6.5.

The formula used for calculating the weights and server spawn points are not ideal for gamemodes with no teams on large maps. The reason this is the case is because the formula is designed purely to make it so you will spawn near allies and far from enemies. In a deathmatch game, there are only ememies. On large maps, this means it may take a while before you find an enemy. A better formula might be for higher weights for medium distances, and lower weights for close and far distances. If you plan on using this script on large maps for a gamemode without teams, consider modifying the formulas; refer to section `More advanced configuration` for further information on how to do so.
« Last Edit: August 08, 2013, 08:26:26 am by DorkeyDear »

Offline iAmBullet

  • Soldat Beta Team
  • Major
  • ******
  • Posts: 64
  • War doesn't determine who's right, but who's left
Re: Smart Spawn
« Reply #1 on: August 08, 2013, 11:55:37 am »
So does this script disregard the spawnpoints pertaining to a certain team (alpha or bravo) and treat all spawnpoints as the same? On the Kampf video the bravo team spawned on alpha side a lot so that's where my assumption comes from.

I really love this idea but wouldn't it create problems in gamemodes like CTF? I think it would be a perfect fit for DM, but what gamemodes would you recommend this work best on?

Thanks

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Smart Spawn
« Reply #2 on: August 08, 2013, 12:37:14 pm »
There is a 'sub-script' called Spawn Merger which is what caused alphas to be able to spawn in bravo spawns, and bravos to spawn in alpha spawns. This is disableable by removing the line in config.ini that says `SPAWNMERGER`. With Spawn Merger disabled, CTF can be played normally using the default spawn points. Using Smart Spawn with Spawn Merger enabled would generally be for non-CTF games, like team match.