Could use some insight on spawning random vehicles

Ask questions, discuss ideas, get answers
Post Reply
tanelorn
Posts: 42
Joined: Thu Oct 14, 2010 6:19 pm

Could use some insight on spawning random vehicles

Post by tanelorn »

Hi all. Let me first describe the big picture for my efforts on spawning random vehicles. This works to a degree but has some annoying issues that I'm trying to fix.

What I did was use the RandomLOD command in BF to make an object select from a variety of spawners attached to it. The RandomLOD command lets you have multiple versions of an object, each labeled with the same name but a different number at the end of it. In my example: gazelle_randomspawner_1, gazelle_randomspawner_2, etc. So what happens is:
1. The map spawns my randomspawner root object, that has multiple vehicle spawnpoints attached to it, using the randomLOD command. This object uses the smokegrenade geometry so is fairly undetectable and causes no collision conflicts.
2. The randomspawner, upon being created, chooses one of many vehicle spawnpoints out of its list.
3. That spawner operates normally, and spawns the vehicle.
4. The randomspawner is set to self destruct (using the criticaldamage and damagepersecond settings) in about 10 seconds with no damage or fanfare.
5. The vehicle sits there like any other vehicle that has spawned. However, as it's spawnpoint is now gone (as the randomspawner object is gone), it is considered 'abandoned' because it is too far (infinitely far) from its spawnpoint. The spawnpoint settings for abandoned vehicles kicks in, and the vehicle will eventually self destruct.
6. When the timer for the map's randomspawner spawn is at the appropriate time, a new randomspawner object appears and the process starts over.

To the outsider, the only real issue with this whole setup is that it is possible for multiple vehicles to spawn on top of eachother, since it is the randomspawner object, not the map, that spawns these vehicles. So the map won't hold off on another vehicle spawning, because it is only checking if there's still a randomspawner on the spot, which there is not as they self destruct in 10 seconds.

To me, who knows what is going on, there are a variety of issues that I can't figure out, even after hours and hours of tweaking and playtesting:
1. Obviously, it would seem a good idea to get these vehicles to time-out and self destruct before the next one will appear. That's what I've been trying to do. But issue #2 is preventing me from doing this...

2. This is the rediculous, illogical part that I can't figure out. These randomspawners have the following behaviors:
2a. Upon first appearing at the beginning of the game, the randomspawner does everything appropriately, choosing a random vehicle from it's list with true randomness. Also, the vehicle inherits all the settings from its spawner attached to the randomspawn object. I have set these spawners to give the vehicle a short lifetime for testing purposes. Ultimately I will give them a lifetime just short of the map's randomspawner respawn timer.
2b. For every following appearance of the randomspawn, the same vehicle is always chosen. In the case of the Gazelle, it is the third choice. Additionally, the vehicle has a default timeout that takes a long time.

Obviously this is very frustrating. My system works perfectly for the first instance of the randomspawner appearing on the map. But for every other appearance, it loses its ability to select a random vehicle, and that vehicle gets a default timeout. This makes it impossible for me to clear out a vehicle before the next one will appear, and of course takes away the functionality of the random spawner.

I was thinking that, perhaps, there's some other spawner that is interfering with this. But I've done a 'find in files' text search for anything that shares the name of my randomspawner or the vehicle spawners and there is no overlap.

Any insight you may have on this odd behavior would be appreciated. I'll attach the code for one of my random spawners below.

Randomspawner object

Code: Select all

ObjectTemplate.create PlayerControlObject randomAirSpawn_gazelle
ObjectTemplate.setNetworkableInfo randomAirSpawnBodyInfo
rem -------------------------------------
ObjectTemplate.geometry SmokeGrenade
objectTemplate.cullRadiusScale 1.5
ObjectTemplate.hasMobilePhysics 0
ObjectTemplate.explosionRadius 0
ObjectTemplate.explosionDamage 0
ObjectTemplate.drag 2
ObjectTemplate.dragOffset 0/0/0
ObjectTemplate.mass 4500
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.hasResponsePhysics 1
ObjectTemplate.hasArmor 1
ObjectTemplate.speedMod 2
ObjectTemplate.hitpoints 10000
ObjectTemplate.maxhitpoints 10000
ObjectTemplate.timeToLiveAfterDeath 1
ObjectTemplate.material 54
ObjectTemplate.criticalDamage 10000
ObjectTemplate.explosionForceMod 1
ObjectTemplate.hpLostWhileCriticalDamage 10000
ObjectTemplate.hpLostWhileUpSideDown 5
ObjectTemplate.hpLostWhileDamageFromWater 5
ObjectTemplate.damageFromWater 0
rem -------------------------------------
ObjectTemplate.addTemplate gazelle_randomspawner
ObjectTemplate.setRandomGeometries 4
ObjectTemplate.setPosition 0/0.5/0
rem -------------------------------------
ObjectTemplate.setPcoId 0
ObjectTemplate.GUIIndex 30
ObjectTemplate.setVehicleIcon "Vehicle/Icon_Browning.tga"
ObjectTemplate.setSoldierExitLocation 6/12/-7 180/0/0
ObjectTemplate.setVehicleIconPos 40/60
ObjectTemplate.setNumberOfWeaponIcons 0
ObjectTemplate.setVehicleCategory VCLand
ObjectTemplate.setVehicleType  VTArtillery
ObjectTemplate.setToolTipType  TTArtillery
ObjectTemplate.setMinimapIcon "Minimap/minimap_icon_none.tga"
ObjectTemplate.hasRestrictedExit 1
Code for the spawns themselves

Code: Select all

ObjectTemplate.create ObjectSpawner gazelle_randomspawner1
rem ObjectTemplate.setObjectTemplate 1 SA-342G
ObjectTemplate.setObjectTemplate 1 SA-342L
ObjectTemplate.MinSpawnDelay 15
ObjectTemplate.MaxSpawnDelay 15
ObjectTemplate.SpawnDelayAtStart 0
beginrem
ObjectTemplate.TimeToLive 45
ObjectTemplate.Distance 40
ObjectTemplate.DamageWhenLost 10
endrem
ObjectTemplate.TimeToLive 15
ObjectTemplate.Distance 0
ObjectTemplate.DamageWhenLost 100
ObjectTemplate.team 1
ObjectTemplate.MaxNrOfObjectSpawned 1
ObjectTemplate.TeamOnVehicle 1

ObjectTemplate.create ObjectSpawner gazelle_randomspawner2
ObjectTemplate.setObjectTemplate 1 SA-342H
ObjectTemplate.MinSpawnDelay 15
ObjectTemplate.MaxSpawnDelay 15
ObjectTemplate.SpawnDelayAtStart 0
beginrem
ObjectTemplate.TimeToLive 45
ObjectTemplate.Distance 40
ObjectTemplate.DamageWhenLost 10
endrem
ObjectTemplate.TimeToLive 15
ObjectTemplate.Distance 0
ObjectTemplate.DamageWhenLost 100
ObjectTemplate.team 1
ObjectTemplate.MaxNrOfObjectSpawned 1
ObjectTemplate.TeamOnVehicle 1

ObjectTemplate.create ObjectSpawner gazelle_randomspawner3
rem ObjectTemplate.setObjectTemplate 1 SA-342L
ObjectTemplate.setObjectTemplate 1 SA-342G
ObjectTemplate.MinSpawnDelay 15
ObjectTemplate.MaxSpawnDelay 15
ObjectTemplate.SpawnDelayAtStart 0
beginrem
ObjectTemplate.TimeToLive 45
ObjectTemplate.Distance 40
ObjectTemplate.DamageWhenLost 10
endrem
ObjectTemplate.TimeToLive 15
ObjectTemplate.Distance 0
ObjectTemplate.DamageWhenLost 100
ObjectTemplate.team 1
ObjectTemplate.MaxNrOfObjectSpawned 1
ObjectTemplate.TeamOnVehicle 1

ObjectTemplate.create ObjectSpawner gazelle_randomspawner4
ObjectTemplate.setObjectTemplate 1 SA-342M
ObjectTemplate.MinSpawnDelay 15
ObjectTemplate.MaxSpawnDelay 15
ObjectTemplate.SpawnDelayAtStart 0
beginrem
ObjectTemplate.TimeToLive 45
ObjectTemplate.Distance 40
ObjectTemplate.DamageWhenLost 10
endrem
ObjectTemplate.TimeToLive 15
ObjectTemplate.Distance 0
ObjectTemplate.DamageWhenLost 100
ObjectTemplate.team 1
ObjectTemplate.MaxNrOfObjectSpawned 1
ObjectTemplate.TeamOnVehicle 1
Tanelorn-Desert Combat Realism mod lead
DCR Website: http://www.tanelorn.us/dcr/pages/index.htm
DCR AI development: http://www.battlefieldsingleplayer.com/ ... opic=15529
DCR new features: http://bfmods.com/viewtopic.php?f=6&t=727
Post Reply