Battlefield Modding Tutorials BFMODS

Battlefield Modding Tutorials
It is currently Sun Sep 24, 2017 8:28 am

All times are UTC




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
PostPosted: Sat Oct 24, 2009 4:17 am 
Offline
User avatar

Joined: Fri Oct 03, 2008 4:37 pm
Posts: 513
Location: Levelland, Texas
Tutorial Difficulty: Moderate
Must have basic decent coding skills and must know how to change matIds of meshes and code the damage system. Locations of posted code is inferred and common sense on where to put it must be made.

Note: This is a very lengthy tutorial! Be warned! It is designed for the more coding challenged folks out there! So more experienced coders can probably skip most of my lengthy explanations

Begin Tutorial:

Ever since the 1.3 update or so (don't know exactly what version) of the game, projectiles no longer exploded on soldiers using the proximity code. So we were left out in the cold in terms of AP Mines. People have come up a simple method of making the AP Mine a PCO and adding death bubbles to soldier kit parts. But NO. That's not how I roll. :P

My way is better! And it's team specific too so AP Mines won't go off on friendlies and you can't avoid enemy mines by picking up enemy kits since the deathbubbles aren't attached to the kit parts in my method!

First off, lets make the APMine PCO:

Code:
ObjectTemplate.create PlayerControlObject APLandmineProjectilePCO
ObjectTemplate.networkableInfo APLandminePCO_Info
ObjectTemplate.geometry APLandmine_PCO_base
ObjectTemplate.saveInSeparateFile 1
ObjectTemplate.cullRadiusScale 3
ObjectTemplate.hasDynamicShadow 0
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.hasResponsePhysics 0
ObjectTemplate.speedMod 0
ObjectTemplate.hasArmor 1
ObjectTemplate.hitPoints 360
ObjectTemplate.maxHitPoints 360
ObjectTemplate.material 1035
ObjectTemplate.drag 1.0
ObjectTemplate.inertiaModifier 0/0/0
ObjectTemplate.mass 20
ObjectTemplate.damageMod 0
ObjectTemplate.criticalDamage 360
ObjectTemplate.ForceOnExplosion 7
ObjectTemplate.explosionRadius 3.6
ObjectTemplate.explosionMaterial 855
ObjectTemplate.hpLostWhileUpSideDown 0
ObjectTemplate.hpLostWhileDamageFromWater 360
ObjectTemplate.hpLostWhileCriticalDamage 1
ObjectTemplate.timeToLiveAfterDeath 0.5
ObjectTemplate.fadeAtTimeToLiveAfterDeath 0
ObjectTemplate.damageFromWater 1
ObjectTemplate.addArmorEffect 0 e_ExplGranade 0/0/0
ObjectTemplate.addArmorEffect -1 WaterWaterExplosion 0/0/0
rem ------------------------------------
ObjectTemplate.setPrimaryAmmoBar ABNone
ObjectTemplate.setCrossHairType CHTNone
ObjectTemplate.setVehicleCategory VCLand
ObjectTemplate.setVehicleType  VTScoutCar
ObjectTemplate.setVehicleIcon "Empty.dds"
ObjectTemplate.setMinimapIcon "Empty.dds"


Notice the use of the code "ObjectTemplate.explosionMaterial 855" in the PCO. This command tells the game to use that mat ID for the explosion that results from the death of this mine. DesertCombat uses 855 for APMine splash damage. If your mod doesn't use DesertCombat or uses a different mat ID, then change this accordingly. This ensures the mines does maximum damage to soldiers while not harming vehicles. Don't use explosionDamage as that code is global and isn't specific like with the damage system. You would end up with APMines doing heavy damage to vehicles like tanks and such and we don't want that!

Network Info for the PCO:

Code:
NetworkableInfo.createNewInfo APLandminePCO_Info
NetworkableInfo.setPredictionMode PMLinear


Geoemetry for the PCO: (disabled dynamic shadow as it would be pointless to have one on something this small)
Code:
GeometryTemplate.create StandardMesh APLandmine_PCO_base
GeometryTemplate.file DesertCombat/APLandmine/APLandmine
GeometryTemplate.hasDynamicShadow 0


Now we got the APMine as a PCO. Later we will code a damage system so you can make the APMine destructible when you hit it with bullets or explosions!

Next up lets set spawners to spawn these little devils. You can't fire the PCO directly because the game will force you into it like the WesserFall or SA-3 Missile and we don't want that!

We will need two spawners (one for each team). That way, the mines will be team specific! This will be important later when we set up the death bubbles that will trigger these mines!

Code:
ObjectTemplate.create ObjectSpawner APLandmineSpawnerAllied
ObjectTemplate.setObjectTemplate 2 APLandmineProjectilePCO
ObjectTemplate.minSpawnDelay 5
ObjectTemplate.maxSpawnDelay 5
ObjectTemplate.timeToLive 99999
ObjectTemplate.distance 99999
ObjectTemplate.maxNrOfObjectSpawned 1
ObjectTemplate.spawnOffset 0/0.16/0
ObjectTemplate.team 2
ObjectTemplate.teamOnVehicle 1

ObjectTemplate.create ObjectSpawner APLandmineSpawnerAxis
ObjectTemplate.setObjectTemplate 1 APLandmineProjectilePCO
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


There we go. The timeToLive and distance are set really high to ensure that mines work properly. If the spawner tries to deal damage to the mine, then the mine will no longer respond to deathbubbles and we can't have that!

So use the settings shown above and you should be fine!

That was the spawners. Now we will set up projectiles that will have the spawners attached to them. This is where the real magic happens as it is the initial projectile that spawns the APMine that will also arm the mines. The spawn offset used above ensures the mines will always be within the explosion radius of the projectile that spawned it since the mine will drop as soon as it spawns from the spawner.

The projectile will have no collision physics and will explode after 0.12 seconds. This ensures that the mines spawns in time for the projectile to damage it. This is key. Because the mine will have it's critical damage set to match its starting hitpoint level so that it will always be in critical. The hpLostWhileCriticalDamage setting also makes it so the mine lasts around 320 seconds. (roughly 5 minutes which was how long the original APMine projectiles lasted)

The game will give a kill credit to the last person to deal damage to pco while it is in the critical damage range. That's how you can get a kill credit for severely damaging a enemy tank and the enemy gets out before it explodes but then gets killed from the tank exploding. This is how it works and will work in the same way with the APMines since they are PCOs just like the tanks and vehicles.

Here's the projectiles that will spawn it. Like with the spawners, there will be two. One for each team to fire. We will make a new handfirearm for the axis team so they can fire the axis spawner projectile. We will get to that later.

Also note that we will need to setup the damage system for the custom material ID we will be using on the projectiles so they will deal very small amount of damage. That way it's enough to give you "ownership" of the mine, but not enough to significantly shorten the lifespan of the mine.

Code:
ObjectTemplate.create Projectile APLandmineAlliedSpawnerProjectile
ObjectTemplate.geometry GrenadeAllies
ObjectTemplate.createNotInGrid 1
ObjectTemplate.saveInSeparateFile 1
ObjectTemplate.addTemplate APLandmineSpawnerAllied
ObjectTemplate.setPosition 0/0.2/0
ObjectTemplate.timeToLive CRD_NONE/0.12/0/0
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 0
ObjectTemplate.hasResponsePhysics 0
ObjectTemplate.setHasPointPhysics 0
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

ObjectTemplate.create Projectile APLandmineAxisSpawnerProjectile
ObjectTemplate.geometry GrenadeAllies
ObjectTemplate.createNotInGrid 1
ObjectTemplate.saveInSeparateFile 1
ObjectTemplate.addTemplate APLandmineSpawnerAxis
ObjectTemplate.setPosition 0/0.2/0
ObjectTemplate.timeToLive CRD_NONE/0.12/0/0
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 0
ObjectTemplate.hasResponsePhysics 0
ObjectTemplate.setHasPointPhysics 0
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


These projectiles will be invisible and only serve the purpose of spawning and arming the mine. Notice that I turned off collision physics. This prevents problems when trying to lay mines near walls and such because if you do, the projectile gets blocked and won't be close enough to arm the mine. (since the projectile will have a tiny blast radius)

The custom mat ID ensures that only the APMine will take damage from it and not anything else.

Now before we move on we will need to code a damage system for the new matIDs that the PCOs and projectiles use. Without this, none of this will work. The Mine pcos I used use material 1035. Be sure that you change the material ID in the mesh the mine will use using the forceMatID.exe app or with GMAX/3DSMAX! You can't get away with just changing it in the code! If you don't know how to do this, find a tutorial on how to change material IDs on collision meshes. I won't explain how to do it in this tutorial. Don't worry about this when with creating the projectiles as projectiles don't follow this rule. So lucky you. :P

The damage system for the APMine PCO uses DesertCombat damage system in mind. So if your mod has projectiles that use a different mat ID setup then what I have, you must change it accordingly. That's if you want this mine to be destructible by shooting it and such that is!

Please remember that the geometry that your APMine PCO uses must have the matIds as defined in the collision meshes match that of the number below. (use your own number if 1035 conflicts with anything you might have setup in your mod)

Here's the damage system for the Mine PCO: (matID 1035)
Code:
rem *********** AP Mine Collision ***********
MaterialManager.material 1035
MaterialManager.materialAttGroup 1035
MaterialManager.materialDefGroup 1035
MaterialManager.materialDamage 10
MaterialManager.materialFriction 100
MaterialManager.materialElasticity 0
MaterialManager.materialResistance 0

rem *** Default Materials for AP Mine ***

rem * *** Dry Grass (yellow) ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 2
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate GranadeExplDirt

rem * *** Juicy Grass (Green) ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 3
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate GranadeExplDirt

rem * *** Dry Dirt ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 4
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate GranadeExplDirt

rem * *** Wet Dirt ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 5
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate GranadeExplDirt

rem * *** Mud ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 6
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate GranadeExplDirt

rem * *** Deep Mud ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 7
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate GranadeExplDirt

rem * *** Gravel ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 8
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate GranadeExplDirt

rem * *** Frozen ground ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 9
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate GranadeExplDirt

rem * *** Dry Sand ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 10
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate GranadeExplDirt

rem * *** Wet Sand ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 11
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate GranadeExplDirt

rem * *** Rock ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 12
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate GranadeExplDirt

rem * *** Forest Floor ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 13
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate GranadeExplDry

rem * *** Dirt Road ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 14
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate GranadeExplDirt

rem * *** Paved Road ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 15
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate GranadeExplDirt

rem * *** Solid Wood ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 80
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Wood ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 81
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Thin Wood ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 82
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Hollow Wood ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 83
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Solid Metal ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 84
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Metal ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 85
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Thin Metal ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 86
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Hollow Metal ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 87
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Solid Stone (Rock) ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 88
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Concrete ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 92
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Reinforced Concrete ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 93
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Flesh ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 94
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Exterior Stone Wall ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 100
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Interior Stone Wall ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 101
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Exterior brick Wall ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 102
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Interior brick Wall ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 103
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Exterior wooden Wall ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 104
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Interior wooden Wall ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 105
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Wooden Fence ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 106
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Sandbags ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 107
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Grate ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 108
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Wooden Fence ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 109
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Wire Fence ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 110
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Grated Fence ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 111
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Mesh Fence ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 112
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Bamboo Exterior wall ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 113
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Bamboo Interior wall ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 114
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Bamboo Fence ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 115
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Bamboo Fence ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 116
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Wooden Floor ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 117
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Stone Floor ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 118
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Glass Pane ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 119
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *************************************************
rem *      Special items
rem * *************************************************

rem * *** Wooden door ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 190
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Metal Door ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 191
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Wooden Ladder ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 192
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Metal Ladder ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 193
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal

rem * *** Switch/control panel ***
MaterialManager.attGroup 1035
MaterialManager.defGroup 194
MaterialManager.damageMod 0.0
MaterialManager.setEffectTemplate e_collision_metal


rem ********* Projectiles VS. APMine **********
MaterialManager.attGroup 200
MaterialManager.defGroup 1035
MaterialManager.damageMod 100
MaterialManager.setEffectTemplate e_ExplGranade

MaterialManager.attGroup 204
MaterialManager.defGroup 1040
MaterialManager.damageMod 100

MaterialManager.attGroup 205
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 226
MaterialManager.defGroup 1035
MaterialManager.damageMod 100
MaterialManager.setEffectTemplate e_ExplGranade

MaterialManager.attGroup 230
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 232
MaterialManager.defGroup 1040
MaterialManager.damageMod 100

MaterialManager.attGroup 501
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 505
MaterialManager.defGroup 1035
MaterialManager.damageMod 100
MaterialManager.setEffectTemplate e_RichoMetal

MaterialManager.attGroup 506
MaterialManager.defGroup 1035
MaterialManager.damageMod 100
MaterialManager.setEffectTemplate e_RichoMetal

MaterialManager.attGroup 600
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 601
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 602
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 603
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 604
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 650
MaterialManager.defGroup 1035
MaterialManager.damageMod 100
MaterialManager.setEffectTemplate e_RichoMetal

MaterialManager.attGroup 651
MaterialManager.defGroup 1035
MaterialManager.damageMod 100
MaterialManager.setEffectTemplate e_RichoMetal

MaterialManager.attGroup 652
MaterialManager.defGroup 1035
MaterialManager.damageMod 100
MaterialManager.setEffectTemplate e_RichoMetal

MaterialManager.attGroup 653
MaterialManager.defGroup 1035
MaterialManager.damageMod 100
MaterialManager.setEffectTemplate e_RichoMetal

MaterialManager.attGroup 670
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 672
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 673
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 674
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 675
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 676
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 680
MaterialManager.defGroup 1035
MaterialManager.damageMod 100
MaterialManager.setEffectTemplate e_RichoMetal

MaterialManager.attGroup 681
MaterialManager.defGroup 1035
MaterialManager.damageMod 100
MaterialManager.setEffectTemplate e_RichoMetal

MaterialManager.attGroup 682
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 683
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 684
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 689
MaterialManager.defGroup 1035
MaterialManager.damageMod 100
MaterialManager.setEffectTemplate e_RichoMetal

MaterialManager.attGroup 700
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 701
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 703
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 704
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 705
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 706
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 707
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 708
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 710
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 711
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 712
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 713
MaterialManager.defGroup 1035
MaterialManager.damageMod 100
MaterialManager.setEffectTemplate e_ExplGranade

MaterialManager.attGroup 714
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 715
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 716
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 717
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 718
MaterialManager.defGroup 1035
MaterialManager.damageMod 100
MaterialManager.setEffectTemplate e_ExplGranade

MaterialManager.attGroup 750
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 751
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 850
MaterialManager.defGroup 1035
MaterialManager.damageMod 100
MaterialManager.setEffectTemplate e_ExplGranade

MaterialManager.attGroup 851
MaterialManager.defGroup 1035
MaterialManager.damageMod 100
MaterialManager.setEffectTemplate e_ExplAni01

MaterialManager.attGroup 853
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 858
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 860
MaterialManager.defGroup 1035
MaterialManager.damageMod 100

MaterialManager.attGroup 861
MaterialManager.defGroup 1035
MaterialManager.damageMod 100


The above defines the damage that most of the projectiles in DC and BF1942 will do to the mine.

Now for the damage system for the projetile that spawns and arms the mine at the same time:

Code:
rem *********** AP Mine Arming Projectile **************
MaterialManager.material 880
MaterialManager.materialAttGroup 880
MaterialManager.materialDefGroup 880
MaterialManager.materialDamage 10

rem *** Arming Material vs AP Mine PCO. ***
MaterialManager.attGroup 880
MaterialManager.defGroup 1035
MaterialManager.damageMod 1.0


Ok once that is set up the mine should now arm correctly and also be killable by shooting it with guns and blasting them with granades. That way, the mines are destructible and won't cause any bad balance issues and produce the "noob whines about ap mines" effect. :P

If someone complains from dieing from APMines just tell them to watch where they are going and shoot them from safe distance. ;)

Now we will set up th APMine handfirearm to fire the correct projectiles. There will be two firearms. One for each team. It's up to you which kits you want the APMine on and what index. So I won't explain the whole adding them to a kit procedure as you should know how to do that. If not...shame on you!

Code:
ObjectTemplate.create HandFireArms APLandmine
ObjectTemplate.networkableInfo HandFireArmsInfo
ObjectTemplate.loadSoundScript Sounds/APLandmine.ssc
ObjectTemplate.itemIndex 6
ObjectTemplate.projectileTemplate APLandmineAlliedSpawnerProjectile
ObjectTemplate.projectilePosition 0/-0.2/2.3
ObjectTemplate.hasDynamicShadow 1
ObjectTemplate.projectileVisible 0
ObjectTemplate.addRootSpeed 0
ObjectTemplate.magSize 4
ObjectTemplate.numOfMag 1
ObjectTemplate.magType 0
ObjectTemplate.setHasMag 0
ObjectTemplate.reloadtime 1
ObjectTemplate.roundOfFire 1
ObjectTemplate.fireOnce 1
ObjectTemplate.autoReload 1
ObjectTemplate.GUIIndex 10
ObjectTemplate.setHudAmmoType ATIcon
ObjectTemplate.setAmmoIcon "Ammo/Icon_APLandmine_64x32.tga"
ObjectTemplate.setCrossHairType CHTIcon
ObjectTemplate.velocity 2
ObjectTemplate.fireInCameraDof 1
ObjectTemplate.hideDuringFireTime 0.4
ObjectTemplate.fireDelay 1.0
ObjectTemplate.soldierCameraPosition 0/-0.03/0.2
ObjectTemplate.ammoType   2
ObjectTemplate.autoReload 1
ObjectTemplate.cantSelectWhenNoAmmo 1
ObjectTemplate.changeWeaponWhenNoAmmo 1
ObjectTemplate.createSkeleton animations/APLandmine.ske
ObjectTemplate.useSkeletonPartAsMain base
ObjectTemplate.addTemplate APLandmineLod
ObjectTemplate.loadSoundScript Sounds/GrenadeAllies.ssc

ObjectTemplate.create HandFireArms APLandmineAxis
ObjectTemplate.networkableInfo HandFireArmsInfo
ObjectTemplate.loadSoundScript Sounds/APLandmine.ssc
ObjectTemplate.itemIndex 6
ObjectTemplate.projectileTemplate APLandmineAxisSpawnerProjectile
ObjectTemplate.projectilePosition 0/0/2.3
ObjectTemplate.hasDynamicShadow 1
ObjectTemplate.projectileVisible 0
ObjectTemplate.addRootSpeed 0
ObjectTemplate.magSize 4
ObjectTemplate.numOfMag 1
ObjectTemplate.magType 0
ObjectTemplate.setHasMag 0
ObjectTemplate.reloadtime 1
ObjectTemplate.roundOfFire 1
ObjectTemplate.fireOnce 1
ObjectTemplate.autoReload 1
ObjectTemplate.GUIIndex 10
ObjectTemplate.setHudAmmoType ATIcon
ObjectTemplate.setAmmoIcon "Ammo/Icon_APLandmine_64x32.tga"
ObjectTemplate.setCrossHairType CHTIcon
ObjectTemplate.velocity 2
ObjectTemplate.fireInCameraDof 1
ObjectTemplate.hideDuringFireTime 0.4
ObjectTemplate.fireDelay 1.0
ObjectTemplate.soldierCameraPosition 0/-0.03/0.2
ObjectTemplate.ammoType   2
ObjectTemplate.autoReload 1
ObjectTemplate.cantSelectWhenNoAmmo 1
ObjectTemplate.changeWeaponWhenNoAmmo 1
ObjectTemplate.createSkeleton animations/APLandmine.ske
ObjectTemplate.useSkeletonPartAsMain base
ObjectTemplate.addTemplate APLandmineLod
ObjectTemplate.loadSoundScript Sounds/GrenadeAllies.ssc

ObjectTemplate.create SimpleObject APLandmineSimple
ObjectTemplate.geometry Shad_APLandmine

ObjectTemplate.create AnimatedBundle APLandmineComplex
ObjectTemplate.createSkeleton animations/APLandmine.ske
ObjectTemplate.geometry Shad_APLandmine

ObjectTemplate.create LodObject APLandmineLod
ObjectTemplate.lodselector HandWeaponLodSelector
ObjectTemplate.addTemplate APLandmineComplex
ObjectTemplate.addTemplate APLandmineSimple


Ok before we continue we must do some changes in the animation system so that the new Axis hand fire arm will have the correct 1p and 3p soldier animations when using this hand weapon. If you not doing this in a mod that uses DC code. You will need to define the Blue team one as well. So I will include both strings just in case.

The following goes in the singleshotweaponsmod.inc file found in the animations.rfa. If your mod doesn't have one, copy the one from the mod your mod depends on. If it doesn't have any mod dependencies, then it's the vanilla BF1942 mod that you will get this from!

Add these lines to the file: (doesn't matter where, but just be tidy and remember where you put it)
Code:
AnimationStateMachine.copyState APLandmine v_arg1 GrenadeAllies 1.0 GrenadeAllies 1.0
AnimationStateMachine.copyState APLandmineAxis v_arg1 GrenadeAllies 1.0 GrenadeAllies 1.0


If your mod runs off of DesertCombat, then the first line you can leave out as it is already definied in the file. Otherwise both will be needed. This tells the game to use the granade animations when holding the APMine. Please note that if you plan on using a different AP Mine mesh, be sure to use a different animation or make your own for the new geometry if it differs from the granade. Otherwise use the mesh that DC uses and the above will work fine.

Ok now that we got the handweapons, projectiles, APMine PCO, damages system, and animation system set up, now for the triggering system! The most important part of the whole process. Without this, the apmines will not go off when a soldier gets near the mines. So pay close attention!

We will now create health depots with negative health settings. These are commonely reffered to as death bubbles. These death bubbles will be attached directly to the soldiers and NOT to the kit parts as was the case in older APMine systems. We will get to that in just a bit, but first we need to create the death bubbles:

Code:
ObjectTemplate.create SupplyDepot APMine_Det_Allied
ObjectTemplate.radius 3.6
ObjectTemplate.team 1
ObjectTemplate.addVehicleType APLandmineProjectilePCO -1 -365 0
ObjectTemplate.workOnVehicles 1
ObjectTemplate.workOnSoldiers 0

ObjectTemplate.create SupplyDepot APMine_Det_Axis
ObjectTemplate.radius 3.6
ObjectTemplate.team 2
ObjectTemplate.addVehicleType APLandmineProjectilePCO -1 -365 0
ObjectTemplate.workOnVehicles 1
ObjectTemplate.workOnSoldiers 0


Be sure you put these on the right soldiers! Mess this up and you could end up with players blowing themselves up from their own mines because of incorrect death bubble settings!

As you can see the allied death bubble is set to team 1 and kills any team 1 apmines. Visa versa for Red team death bubble.

Now to add them to the soldiers! We are almost done! This code has been shrunk down and leaves out some code to save space.

Blue Team:
Code:
ObjectTemplate.create BFSoldier USSOldier


rem [SNIPPED]


rem /////////////////////////////////////////
ObjectTemplate.addTemplate APMine_Det_Allied
rem /////////////////////////////////////////


Red Team:
Code:
ObjectTemplate.create BFSoldier IraqSoldier


rem [SNIPPED]


rem /////////////////////////////////////////
ObjectTemplate.addTemplate APMine_Det_Axis
rem /////////////////////////////////////////


If your mod uses more and/or different soldiers, be sure to add the death bubbles to those too! Axis deathbubble goes on any soldier that will be on team 1 and the allied death bubble will go on any soldier on team 2.

Do NOT put the death bubbles in the commonsoldierdata.inc file! That file is common code used by all soldiers!

Also important that the death bubbles be the LAST child object addTemplated to the soldier! Scroll down through the code till you see the addTemplate entry for the parachute. That is normally the last thing on the soldier. AddTemplate the deathbubble after that. If you put this anywhere else, you risk it not working or screwing up the other lod parts of the soldier!

Also note that with this method, dead bodies and soldiers who are in vehicles will not set off the ap mines. Which means your safe to drop a mine ontop of a dead body or drive over enemy apmines in a vehicle with seats.

Now all you have to do is set up your kits to use the APMines. In my mod the heavy assault and sniper kits have them. But it's your choice as to which ones. Just make sure the index setting for the handweapons don't conflict with anything else on the kit. Also make a kit icon or use the one DC used. You can use the one I made if you wish. The Axis handweapon goes on team 1 kits and the other on team 2 kits!

That's it! Now you got APMines for your mod. Now use your new weapon on the battlefield and win the war soldier!

_________________
ImageImage
I have cameras in your head!


Top
 Profile Send private message E-mail  
 
PostPosted: Thu Oct 29, 2009 1:24 pm 
Offline

Joined: Sun Jan 27, 2008 8:46 pm
Posts: 173
thats alot of codes xD i might try to understand it, sometime. Nice tutorial

_________________
Image


Top
 Profile Send private message E-mail  
 
PostPosted: Sun Jan 10, 2010 7:48 pm 
Offline

Joined: Mon Jan 26, 2009 2:01 am
Posts: 98
very nice guide 10/10 :D just kinda hard to understand where each code goes

_________________
http://www.rockwitch.com/blog/media/hax0r.gif
Image
Image
Stop "1337-speak"!


Top
 Profile Send private message E-mail  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Group