Add Player Spawn Point to a vehicle

Add Player Spawn Point to a vehicle

By Dnamro

This tutorial will explain how to add a player spawn to a vehicle. This is useful when you have vehicles that are difficult for players to get to, such as in the air.

Note: For this tutorial, I am using the Hovercraft (LCAC) from Point of existence mod for BFV for my example. The code will be the same for Vietnam or BF42 mods.

* First of all add the spawners to the PCO object::

ObjectTemplate.create PlayerControlObject LCAC
ObjectTemplate.NetworkableInfo LCACBodyInfo.
.
.
.
rem soldier spawns
ObjectTemplate.addTemplate LCAC\_SoldierSpawn
ObjectTemplate.setPosition -2.82/2/-6.96
ObjectTemplate.addTemplate LCAC\_SoldierSpawn
ObjectTemplate.setPosition -2.35/1.8/7.7
ObjectTemplate.addTemplate LCAC\_SoldierSpawn
ObjectTemplate.setPosition 2.35/1.8/7.7
rem ------------------------------------------
rem vehicle LAV spawner
ObjectTemplate.addTemplate LCAC\_LAV-25Spawner
ObjectTemplate.setPosition 0/3.3/0

Note: - The LCAC soldier spawns are set to just ride in the vehicle and not for a particular vehicle postion. However, most of the time you want to spawn a soldier into vehicle positions.

* Next you want to create a vehicle group for the soldier spawner. The group number can't be much higher then 150. Numbers between 100 -120 should be safe to use. Just make sure to use a unique number for ever new group you use an object for. You could also reuse this for another object if you wanted the same settings. If you have multiple vehicles with the same group number, you will only get one shared spawn selection that will be centered between the vehicles. Its best to use a different group for each vehicle, unless the spawner will be only used for bots.

.Examples with notes after '--':

>
>
>
>
> **rem spawn group for only players by US/Allies**
>
> spawnPointManager.group 76 -- unique group number
>
> spawnPointManager.groupTeam 2 -- this sets 2 for US use
>
> spawnPointManager.groupIcon test1.tga -- standard icon
>
> spawnPointManager.onlyForHuman 1 -- sets for use only by players
>
>
>
>
>
> **rem spawn group for players and bots by US/Allies**
>
> spawnPointManager.group 77 -- unique group number
>
> spawnPointManager.groupTeam 2 -- this sets 2 for US use
>
> spawnPointManager.groupIcon test1.tga -- standard icon
>
>
>
> **rem spawn group for only bots by US/Allies**
>
> spawnPointManager.group 78 -- unique group number
>
> spawnPointManager.groupTeam 2 -- this sets 2 for US use
>
> spawnPointManager.groupIcon test1.tga -- standard icon
>
>
>
>
> spawnPointManager.onlyForAI 1 -- set to 1 for only bot use
>
>

> rem \*\*\* LCAC\_SoldierSpawn1 \*\*\*
>
>
>
> ObjectTemplate.create SpawnPoint LCAC\_SoldierSpawn
>
> ObjectTemplate.setSpawnRotation 0/0/0
>
> ObjectTemplate.setSpawnPositionOffset 0/0/0
>
> ObjectTemplate.setSpawnPreventionDelay 0
>
> ObjectTemplate.setSpawnId 0 -- This should be unique to this object
>
> ObjectTemplate.setGroup 76 -- this number ties to the group above
>
> ObjectTemplate.setEnterOnSpawn 0 -- Controls player
>
> ObjectTemplate.setAIEnterOnSpawn 1 -- Controls bot
>
>
>
>
> ObjectTemplate.setSpawnAsParaTroper 0 -- This would auto deploy a chute
>
>

Now this does not make any since to have setAIEnterOnSpawn 1 when the group for this spawner is for Human only. Usually you don't want to force players to spawn into vehicles, by setting setEnterOnSpawn 1 unless you are using this code:

>
>
>
>
>
>
> rem \*\*\* LCAC\_SoldierSpawn2 \*\*\*
>
> ObjectTemplate.create SpawnPoint LCAC\_SoldierSpawn2
>
> ObjectTemplate.setSpawnRotation 0/0/0
>
> ObjectTemplate.setSpawnPositionOffset 0/0/0
>
> ObjectTemplate.setSpawnPreventionDelay 0
>
> ObjectTemplate.setSpawnId 1 -- This should be unique to this object
>
> ObjectTemplate.setGroup 76 -- this number ties to the group above
>
>
>
>
> ObjectTemplate.setEnterOnSpawn 1
>
>

Note: the LCAC\_SoldierSpawn2 spawner is not used but I created it to show how an additional player spawn would be created that spawns players into the vehicle for a mobile spawner. Note that if all vehicle positions become full, that the spawner will automatically disappear until a vehicle position is available.

>
>
>
>
> >> vehicle spawner
>
> rem \*\*\* LCAC\_LAV-25Spawner \*\*\*
>
> ObjectTemplate.create ObjectSpawner LCAC\_LAV-25Spawner
>
> ObjectTemplate.setObjectTemplate 1 LAV-25 >>spawn LAV-25 for Team 1
>
> ObjectTemplate.setObjectTemplate 2 LAV-25 >>spawn LAV-25 for Team 2
>
> ObjectTemplate.holdObject 1 >>Holds the object in its spawn position
>
> ObjectTemplate.minSpawnDelay 20 >> time in seconds
>
> ObjectTemplate.maxSpawnDelay 20 >>time in seconds
>
> ObjectTemplate.TimeToLive 30 >> time in seconds
>
> ObjectTemplate.Distance 20
>
> ObjectTemplate.spawnOffset 0/0/0
>
> ObjectTemplate.team 2 - team that owns vehicle
>
> ObjectTemplate.MaxNrOfObjectSpawned 1 >> Number of vehicles to spawn
>
>
>
>
> ObjectTemplate.damageWhenLost 10
>
>

**Special Code Notes:**

holdObject 1 -- keeps the spawned object in its place relative to what spawned it. This is how landing craft stay on the sides of ships and how you can spawn a plane in midair. It will stay in its place until someone gets in it and starts moving it. In this case it spawns an vehicle on the Hovercraft that travels with it.

MaxNrofObjectsSpawned 1 -- Is the number of vehicles that can be spawned and live at the same time from this spawner. If left out, it defaults to 1. If set higher, multiple vehicles will appear at the spawndelay intervals, up to the max. Its very useful on a carrier to allow multiple planes to be launched quickly.

ObjectTemplate.teamOnVehicle 0 -- If you want to restrict enemy bots from stealing a vehicle, use this code in the spawner with a 1 for Vietnam/Axis, 2 for US/Allies, 0 is neutral/default setting.

**Conflict Between group and spawner settings:**

If there is a conflict between the group setting and the spawner setting, I found that the group setting takes over. So, in the case of the LCAC, since the group setting is for Human only, the spawner setting for AIEnterOnEntry is apparently useless since bots don't spawn with this group setting.

So, what would happen if you used both in the group settings like so:

> >> spawn group for only players by US/Allies
>
>
>
> spawnPointManager.group 76 -- unique group number
>
> spawnPointManager.groupTeam 2 -- this sets 2 for US use
>
> spawnPointManager.groupIcon test1.tga -- standard icon
>
> spawnPointManager.onlyForHuman 1 -- sets for use only by players
>
>
>
>
> spawnPointManager.onlyForAI 1 -- set to 1 for only bot use
>
>

It appears that the last setting will take priority.

**Spawner for AI and Player**

You can use bot settings for the spawner if the group does not have any restrictions. So if the group is unrestricted, then both AI and players can be set to enter the vehicle when spawning:

>
>
>
>
>
>
> rem unrestricted group
>
> spawnPointManager.group 76 -- unique group number
>
> spawnPointManager.groupTeam 2 -- this sets 2 for US use
>
> spawnPointManager.groupIcon test1.tga -- standard icon
>
>
>
> rem \*\*\* LCAC\_SoldierSpawn1 \*\*\*
>
> ObjectTemplate.create SpawnPoint LCAC\_SoldierSpawn
>
> ObjectTemplate.setSpawnRotation 0/0/0
>
> ObjectTemplate.setSpawnPositionOffset 0/0/0
>
> ObjectTemplate.setSpawnPreventionDelay 0
>
> ObjectTemplate.setSpawnId 0 -- This should be unique to this object
>
> ObjectTemplate.setGroup 76 -- this number ties to the group above
>
> ObjectTemplate.setEnterOnSpawn 1 -- Controls player
>
>
>
>
> ObjectTemplate.setAIEnterOnSpawn 1 -- Controls bot
>
>

**Using a Map Player Spawn to get a player into a vehicle**

Now these same settings will work just as well for the map player spawner code instead of the vehicle code. The code is the same. The difference is that a map player spawn will only work if the vehicle is present at the start location, while a vehicle player spawn will allow the vehicle to be entered while on-the-move, and will follow the vehicle around the map. If you have more than one vehicle like this, only one spawn point will be show and which will be centered between the vehicles.

Note: It is possible to have several of the same type of vehicle on the map, each with it's own player spawn point. Each vehicle will need to be cloned with a unique name and each one will need to have it's own spawn group number. This only pertains to player spawns. If the spawn is for only AI, then it's not an issue because AI only spawners don't show up on the spawn selection screen.