Airstrike handweapon problem

Ask questions, discuss ideas, get answers
Post Reply
hipnox
Posts: 68
Joined: Tue Aug 09, 2011 10:34 pm

Airstrike handweapon problem

Post by hipnox »

Hello,

I'm making an airstrike weapon based on the original landmine. By attaching a spawner on it, i was able to make it spawn downward pointing V2 rockets at 500 units above it. It works well. Te rocket (which is a PCO) comes crashing down and explodes. The mine disappears 5 seconds after being tossed.

The problem is that though the mine's time to live is set to CRD_NONE/5/0/0, it keeps spawning rockets even after exploding, and doesn't seem to stop. I dont know why really. It appears the mine simply vanishes but still exists somehow.


[ i tried setting the maximum number of objects to spawn to 1, but that makes the airstrike usable only once per match, as any following landmines will not spawn anything. pretty lame. ]

Here's the projectile

Code: Select all

rem *** AirstrikeDeployProjectile ***
ObjectTemplate.create Projectile AirstrikeDeployProjectile
ObjectTemplate.networkableInfo ProjectileInfo
ObjectTemplate.geometry Landmine
ObjectTemplate.hasDynamicShadow 1
ObjectTemplate.setHasMobilePhysics 1
ObjectTemplate.setHasCollisionPhysics 1
ObjectTemplate.setHasResponsePhysics 0
ObjectTemplate.setHasPointPhysics 0
ObjectTemplate.hasCollisionEffect 0
ObjectTemplate.invisibleAtEndEffect 0
ObjectTemplate.timeToLive CRD_NONE/5/0/0
ObjectTemplate.addTemplate AirstrikeSpawner
ObjectTemplate.setPosition 0/200/0
ObjectTemplate.setRotation 0/90/0
ObjectTemplate.dieAfterColl 0
rem ObjectTemplate.radius 0
rem ObjectTemplate.ForceOnExplosion 0
rem ObjectTemplate.explodeNearEnemyDistance 3
rem ObjectTemplate.hasOnTimeEffect 1
ObjectTemplate.mass 130
ObjectTemplate.material 230
ObjectTemplate.material2 232
ObjectTemplate.damageType 4
rem ObjectTemplate.endEffectTemplate e_ExplGranade
ObjectTemplate.noFFSound 1
rem ObjectTemplate.addToProjectileList 1
rem ObjectTemplate.projectileType 1
Here's the spawner

Code: Select all

rem *** AirstrikeSpawner *** 
ObjectTemplate.create ObjectSpawner AirstrikeSpawner
ObjectTemplate.setObjectTemplate 1 v2
ObjectTemplate.setObjectTemplate 2 v2
ObjectTemplate.holdObject 0
ObjectTemplate.minSpawnDelay 10
ObjectTemplate.maxSpawnDelay 10
ObjectTemplate.SpawnDelayAtStart 1
ObjectTemplate.TimeToLive 9999
ObjectTemplate.Distance 9999
ObjectTemplate.spawnOffset 0/.17/0
ObjectTemplate.team 2
ObjectTemplate.MaxNrOfObjectSpawned 1
ObjectTemplate.damageWhenLost 1
any ideas?
User avatar
Swaffy
Posts: 1715
Joined: Sun Aug 29, 2010 9:25 pm
Location: Cibolo, Texas

Re: Airstrike handweapon problem

Post by Swaffy »

You set the TimeToLive on the spawner to 9999. Try setting it to ... 5 or 10.

ObjectTemplate.TimeToLive 9999
to:
ObjectTemplate.TimeToLive 5
(Forum Thread|Download) Swaffy'sMod v0.34 | Download link to come Soon™
hipnox
Posts: 68
Joined: Tue Aug 09, 2011 10:34 pm

Re: Airstrike handweapon problem

Post by hipnox »

Isn't that for controling how much a vehicle can live when far away from the spawnpoint? either way i tried with that and did not work

What did work however was adding the spawnpoint not to the projectile itself but to the explosion effect when it dies. When the landmine dies, it creates a red explosion with bright red targeting fume. Its the effect bundle that has the spawnpoint. when the effect is done, the spawnpoint disappears.


Image
User avatar
Apache Thunder
Posts: 1213
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: Airstrike handweapon problem

Post by Apache Thunder »

Carefull now. Tying PCO spawners to effects that are in turn activated by the damage system results in CTDs in multiplayer. (Yes even if it's just the effect for the endEffect setting on the projectile) I have tried multiple variations of systems involving this like a spotting system that spawns a PCO when a projectile hit certain materials to trying to spawn a ball PCO via the effect/damage system and it worked great in singleplayer/empty server. But once other clients connect and start using it...boom client side CTDs. I can't recall if it was the server that crashes or the clients that do. I think it caused client side CTDs.

First thing I noticed is that your landmine has network info....remove it. I found that spawners behave differently on projectiles when network info is present. Network info is only needed if you are coding C4 or want to limit the amount of C4/Landmines the player can place on the map at one time. (hence them disappearing one at a time once the player goes past the limit). Network info is also responsible for removing the projectile from the map after the player dies in a vehicle or dies on foot and his kit disappears. My troop traps and vehicle/supply drops in my other mods make use of spawners on projectiles similar to what your doing. So there wasn't anything wrong with the 9999 setting on the timetoLive setting on the spawner or the distance settings. I only used the maxNrOfObjectSpawned setting to keep my AP Mine coding from spawning more then 1 mine per fire attempt. :P

Since your landmine has too short of a timeToLive for this to be an issue, the network info is not needed. ;)

Example coding on how my BFH Troop Trap APMines spawn when fired:

Code: Select all

ObjectTemplate.create Projectile TTSpawnerProjectileGER
ObjectTemplate.geometry GrenadeAllies
ObjectTemplate.createNotInGrid 1
ObjectTemplate.saveInSeparateFile 1 
ObjectTemplate.timeToLive CRD_NONE/0.12/0/0
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 0
ObjectTemplate.hasResponsePhysics 0
ObjectTemplate.hasPointPhysics 1
ObjectTemplate.hasCollisionEffect 0
ObjectTemplate.hasOnTimeEffect 1
ObjectTemplate.invisibleAtEndEffect 1
ObjectTemplate.invisible 1
ObjectTemplate.damageType 1
ObjectTemplate.ForceOnExplosion 0
ObjectTemplate.radius 1
ObjectTemplate.material 880
ObjectTemplate.material2 880
ObjectTemplate.minDamage 0.25
rem -----------------------------------------------
ObjectTemplate.addTemplate TTSpawnerNationals
ObjectTemplate.setPosition 0/0.2/0

ObjectTemplate.create ObjectSpawner TTSpawnerNationals
ObjectTemplate.setObjectTemplate 1 TroopTrap_Nationals
ObjectTemplate.minSpawnDelay 5
ObjectTemplate.maxSpawnDelay 5
ObjectTemplate.timeToLive 99999
ObjectTemplate.distance 99999
ObjectTemplate.maxNrOfObjectSpawned 1
ObjectTemplate.spawnOffset 0/0.16/0
ObjectTemplate.team 1
ObjectTemplate.teamOnVehicle 1
That one has an even shorter time to live setting. Yours needs to be longer to allow the spawner to spawn more then one. Child objects on projectiles usually disappear along with the projectile so once the spawner is removed from the map after the landmine dies, then it should stop spawning the rockets. The only thing I see wrong with your coding right now is the network info on the projectile that has the spawner addTemplated to it.

If that fails you can try adding this to your spawner:

Code: Select all

ObjectTemplate.maxNrOfObjectsToSpawn 10
ObjectTemplate.resetWhenRemoved 1
The maxNrOfObjectsToSpawn command is a unused command in BF42. It should give a total limit of vehicles the spawner will ever spawn when it's on the map. I used 10 as an example. You can increase it or decrease it to fit your needs. The restWhenRemoved command should reset the spawner after it's removed from the map after the landmine host dies.

To make it spawn vehicles faster simply set the Distance to something low like 0 so that the spawner will always respawn the vehicle during it's time on the map and the timeToLive will give it the speed it will respawn it. The maxNrOfObjectsToSpawn should then give it the total amount it is allowed to spawn during it's lifetime.
ImageImageImage
I have cameras in your head!
Post Reply