Page 1 of 2

Modified tank destruction

Posted: Sat Jan 11, 2014 10:01 pm
by Vilespring
I have attempted to make the Tiger tank in the game just have its turret fly off when it dies, instead of what it currently does. Mocking some code I found in the AA allies, I made these modifications

Code: Select all

rem *** Tiger ***
ObjectTemplate.create PlayerControlObject Tiger
ObjectTemplate.setNetworkableInfo TigerBodyInfo
ObjectTemplate.saveInSeparateFile 1

(bla bla bla, stuff I didn't change)

ObjectTemplate.addArmorEffect 12 e_PanzFire 0/1/-1.4
ObjectTemplate.addArmorEffect 0 e_ExplGas 0/0/0
ObjectTemplate.addArmorEffect 0 e_scrapmetal 0/0/0
ObjectTemplate.addArmorEffect 0 e_Tigerexplosion
ObjectTemplate.addArmorEffect -1 WaterWaterExplosion 0/0/0
ObjectTemplate.damageFromWater 1
ObjectTemplate.aiTemplate Tiger
rem -------------------------------------
ObjectTemplate.addTemplate lodTiger
rem -------------------------------------
ObjectTemplate.setSoldierExitLocation -2.3/0.5/0 0/0/0
ObjectTemplate.GUIIndex 75

(bla bla bla, stuff I didn't change)

rem *** TigerWreck ***
ObjectTemplate.create bundle TigerWreck
ObjectTemplate.geometry Tiger_Hull_M1
ObjectTemplate.addTemplate TigerHullHatch
ObjectTemplate.setPosition -1.199/0.65/1.8


rem *** TigerLodSelector ***
LodSelectorTemplate.create DistCompareSelector2 TigerLodSelector
LodSelectorTemplate.hasDestroyedLod 1
LodSelectorTemplate.addLodDistance 100

rem -----------------------------------------------------------------------
rem -------------------boom effects----------------------------------------
rem -----------------------------------------------------------------------


rem *** e_Tigerexplosion***
ObjectTemplate.create EffectBundle e_Tigerexplosion
ObjectTemplate.saveInSeparateFile 1
rem -------------------------------------
ObjectTemplate.addTemplate Em_TigerTurret
ObjectTemplate.setPosition 0/1/0
ObjectTemplate.timeToLive CRD_NONE/1.8/0/0
rem -------------------------------------


rem *** Em_TigerTurret ***
ObjectTemplate.create Emitter Em_TigerTurret
ObjectTemplate.template TigerDestroyedTurret
addTemplate e_CorsairFire
ObjectTemplate.addEmitterSpeed 1
ObjectTemplate.emitterSpeedScale 1
ObjectTemplate.lodDistance 375
ObjectTemplate.timeToLive CRD_NONE/1/0/0
ObjectTemplate.intensity CRD_NONE/1/0/0
ObjectTemplate.relativePositionInDof CRD_NONE/0.1/0/0
ObjectTemplate.positionalSpeedInDof CRD_UNIFORM/10/0/1
ObjectTemplate.positionalSpeedInUp CRD_UNIFORM/20/15/0
ObjectTemplate.positionalSpeedInRight CRD_UNIFORM/10/0/1
ObjectTemplate.startRotation CRD_UNIFORM/1/100/0


rem *** TigerDestroyedTurret ***
ObjectTemplate.create Bundle TigerDestroyedTurret
ObjectTemplate.addTemplate e_FireSmallYellow
ObjectTemplate.geometry Tiger_Tow_M1
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasResponsePhysics 1
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.destroyed 1
ObjectTemplate.sinkInToLandAfterDeathSpeed 1
ObjectTemplate.addTemplate TigerGunBase
ObjectTemplate.setPosition 0/0.325/1.295
ObjectTemplate.addTemplate TigerTowerHatch
ObjectTemplate.setPosition -0.792/0.95/-0.232
The problem is, when the tank is destroyed, it changes to the destroyed, black junk it does, which confuses my in why, and no turret flying in the air. what did I do wrong?

Re: Modified tank destruction

Posted: Sun Jan 12, 2014 6:53 am
by Swaffy
You still have "scrapmetal" on the list and you didn't add coordinates to "Tigerexplosion".

Re: Modified tank destruction

Posted: Sun Jan 12, 2014 8:05 am
by Apache Thunder
You need to have the turret wreck mesh be it's own object. Then have it spawn from an effect emitter tied to one of your scrap metal effects.

As for the turret object you have coded. You may need to remove the sink into land code:

Code: Select all

ObjectTemplate.create Bundle TigerDestroyedTurret
ObjectTemplate.geometry Tiger_Tow_M1
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasResponsePhysics 1
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.mass 100
ObjectTemplate.destroyed 1
rem ObjectTemplate.sinkInToLandAfterDeathSpeed 1
ObjectTemplate.timeToLiveAfterDeath 20
rem --------------------------------------------------
ObjectTemplate.addTemplate e_FireSmallYellow
ObjectTemplate.addTemplate TigerGunBase
ObjectTemplate.setPosition 0/0.325/1.295
ObjectTemplate.addTemplate TigerTowerHatch
ObjectTemplate.setPosition -0.792/0.95/-0.232
I also added mass and defined the timeToLiveAfterDeath property.

Also make sure the turrent isn't being emitted inside the vehicles collision mesh. This may interfere with the upward movement it's supposed to have. So have it spawn above the tank at a distance that would ensure it isn't spawning side the vehicle's collision mesh.

Also, you didn't specify the required vector3 after the armor effect:

Code: Select all

ObjectTemplate.addArmorEffect 0 e_Tigerexplosion
It needs to have a position defined:

Code: Select all

ObjectTemplate.addArmorEffect 0 e_Tigerexplosion 0/0/0
If you don't specify the minimum required arguments for a command, the game will ignore the entire command. So pay close attention to that! ;)

Re: Modified tank destruction

Posted: Sun Jan 12, 2014 5:53 pm
by Vilespring
I did all the modifying, adding a coordinate, copying and pasting the new turret, and no new results. The tanks still launches scrap metal, even though e_srapmetal was remmed out. Also, even though I changed the destroyed geometry to the normal hull, it still turns into the destroyed form. I though I was running the wrong mod, so I put a pole on top of the tank, and it was there. Either I'm doing something really stupid, or it's just ignoring me! :| (bets on I'm stupid! :lol: )

Re: Modified tank destruction

Posted: Tue Jan 14, 2014 7:29 am
by Vilespring
It was me being stupid. When I did all the editing but the pole adding I packed to the FHR RFA. :lol:
I knew it was me being a retard.

the only problem is the turret acts funny on the ground. It rocks all over the place, and it phases through vehicles and buildings. any solutions? other than that, it works great!

Re: Modified tank destruction

Posted: Tue Jan 14, 2014 8:13 am
by Swaffy
Vilespring wrote:the only problem is the turret acts funny on the ground. It rocks all over the place, and it phases through vehicles and buildings. any solutions? other than that, it works great!
Perhaps there's a way to make it collide with objects but make it go through the heightmap?

Re: Modified tank destruction

Posted: Tue Jan 14, 2014 8:39 pm
by Vilespring
I could just turn off collision all together, making it just cosmetic.
I kinda wanted the turret to be usable as cover, but whatever.

could I put a box inside of it? would that work? :lol:

Re: Modified tank destruction

Posted: Wed Jan 15, 2014 4:47 am
by Apache Thunder
The mass for the tank turret isn't high enough. Try increasing it's mass. You can also add springs to it as that will help stabalize it.


If you don't want it to collide with the terrain use this command:

Code: Select all

ObjectTemplate.addToCollisionGroup c_CGLandsape

Re: Modified tank destruction

Posted: Wed Jan 15, 2014 6:23 am
by BotHunter
Take a look at the code for my Hoverjeep

http://bfmods.com/viewtopic.php?f=45&t=1630&start=10

Re: Modified tank destruction

Posted: Wed Jan 15, 2014 6:24 am
by Swaffy
Apache Thunder wrote:

Code: Select all

ObjectTemplate.addToCollisionGroup c_CGLandsape
Precisely this! That way planes and other objects can collide with it but it will fall through the ground! (I think)