[Question] How does one add a new gun to a mod?

Making or wanting help making your own asset? Check in here
Post Reply
Superior Mind
Posts: 161
Joined: 2007-02-15 01:55

[Question] How does one add a new gun to a mod?

Post by Superior Mind »

If I wanted to add a new weapon to a little mini mod I am working on, how would I go about doing it? Which files exactly need to be placed where? I know it is more than just making a new folder in the Object_Server and Client folders. I have a lot of experience in tweaking weapon and map files, but nothing to the extent of adding new models/weapons/vehicles. So anyone know? Thank you.
Image
NaZar3TH
Posts: 33
Joined: 2007-05-08 06:12

Post by NaZar3TH »

For weapons:
1.) go to your objects_server/weapons/handheld and copy the weapon folder from there into your mod's objects_server/weapons/handheld.

2.) then do the same for objects_client/weapons/handheld

3.) then go to menu_client/hud/texture/ingame/weapons/hud/ then find your 2 files pertaining to that weapon, then go to the folder called selection inside the hud folder and find your selection icon from there. copy those 3 files into your own menu_client.

4.)
then go to objects_server/kits/(insertarmyofchoicehere)/(whateverkityouwant) and erase the weapon that is listed there and replace it with your own.

5.)test your game in windowed mode to make sure theres no problems.

for vehicles:
pretty much the same as your weapons except they are in a different directory and need to have a hud, which can be found in the menu_client and menu_server files.

textures for things are located in the objects_client file.

itll take a lil while to figure it out but once you got the hang of it its easy as shit to add stuff in.
Image

Fast N Low, Ready to Go
Superior Mind
Posts: 161
Joined: 2007-02-15 01:55

Post by Superior Mind »

Ah, cool. Thanks so much man.
Image
Snake_doctor
Posts: 289
Joined: 2007-01-13 13:22

Post by Snake_doctor »

dunno if this will hellp of bf2 editor furums
http://bfeditor.org/forums/index.php?showtopic=6769
Custom Kits for your map, Learn how to mod your map. Add the TANK KILLER kit smile.gif

Custom kits are easy, the hard part is not stuffing it up by adding the 2 or more weapons with the same item index.

People whom are familiar with the custom skins tutorial I wrote will find this pretty similar.

First of all were going to set up your map with some custom zips that will contain the modified kit and or weapon information. Then I will ensure that the zipped content is loaded by adding a ServerArchives.con to my levels server.zip

(For these sort of map customizations its best to work from the zips rather than an unpacked map, these sort of customizations would be added once the map is final as the Editor doesnt take to well to custom content like this.)

So lets begin, open your_level folder, right click and select New, WinRAR ZIP archive, I'll call mine Custom_kits_server.zip also do the same again but call the zip Custom_weapons_server.zip, I wont bother creating a client as we dont need it for custom kits or weapon tweaks.
Now we will add the ServerArchives.con to our maps server.zip but first we will modify it mount our custom.zips.

Open mods/BF2 copy the ServerArchives.con then open /Levels/your_map/server.zip and Ctrl V to paste it into the zip, once pasted double click the ServerArchives.con to edit in notepad. Now we need mount the custom zips by adding their path to the .con like this:

fileManager.mountArchive Levels/your_map/Custom_kits_server.zip Objects
fileManager.mountArchive Levels/your_map/Custom_weapons_server.zip Objects
fileManager.mountArchive Objects_server.zip Objects
fileManager.mountArchive Menu_server.zip Menu
fileManager.mountArchive Common_server.zip Common

Save the file and click yes to update the archive. Now lets get some BF2 kits to tweak, to keep things simple we will modify one kit from one team. Lets modify the US Anti Tank Kit, we will call it TANK KILLER. (now that got your attention didn't it.)

Open mods/bf2/Objects_server.zip and drag the Kits folder to /Levels/your level/ open Kits folder and delete everything except the US folder, now open the US folder and delete everything except the US_AT.con, then right click it, properties and un-check read only.

Time to edit the kit con, open US_AT.con, change the first line to read ObjectTemplate.create Kit TANK_KILLER

So what should we give this guy the TANK KILLER, how about:

Mines - at_mines
C4 - c4_explosives
Eryx - CHAT_ERYX
Predator - USATP_predator
Grenades - ushgr_m67
Pistol - USPIS_92FS

That will do otherwise writting this tutorial may take alot longer. As is we will need to modify most of those weapon tweaks so that we don't double up on item index's. So first of all lets look at the tweak files for those weapons to determine their item index's (btw item index's are the weapon slots 1-0 on the keyboard)

So open up mods/bf2/Objects_server.zip then open weapons/Handheld/ and the above mentioned weapons folders, then open up their tweaks and look for ObjectTemplate.itemIndex and record the corresponding number for each kit (if you play enough BF2 you will probably allready know the index numbers). You will find that it will end up like this.

at_mines (index 5)
c4_explosives (index 5)
CHAT_ERYX (index 4)
USATP_predator (index 4)
ushgr_m67 (index 4)
USPIS_92FS (index 2)

So by looking at that what does that tell you? It tells you that you will need to modify at least 3 ot the kits, we will leave c4, CHAT_ERYX, USPIS_92FS alone and we will modify at_mines, USATP_predator and the ushgr_m67, and we will issue them with item #'s 1,3 and 6.
Note that we will have to completely rename the weapons of which items index's we are going to change otherwise it will crash as it will clash with other kits.

So lets modify these 3 weapons, open mods/bf2/Objects_server.zip/ and drag the weapons folder into Levels/your level/ (there are alot of files but we will be deleting 99% of them, I do it this way because it keeps the file structure without manually creating the folders)

Open the new weapons folder and delete everything except Handheld, then open the Handheld folder and delete everything except at_mines, USATP_predator and the ushgr_m67 folders.
Now lets rename, real simple lets just loose the underscore_ and whats left of it. So our weapons will be:

mine
predator
m67

Start by renaming the folders, after renaming them open the mine folder and delete everything except at_mine.con, at_mine.tweak and the Weapon.desc, now you can rename the con and tweak to mine. (remember to always uncheck read only when editing BF2 files)

Lets edit the con, I'll just post the code as its nice and short, but essentially what we are doing is renaming the object or bundle to mine, however we want to keep all ObjectTemplate references to geometry or col mesh as this needs to be loaded from bf2.
mine.con

CODE
GeometryTemplate.create BundledMesh mine
CollisionManager.createTemplate mine

ObjectTemplate.create GenericFireArm mine
ObjectTemplate.saveInSeparateFile 1
ObjectTemplate.creator JSA-1:jsa
ObjectTemplate.collisionMesh at_mine
ObjectTemplate.mapMaterial 0 lambert1 0
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.physicsType 3
ObjectTemplate.geometry at_mine

include mine.tweak


For the mine.tweak we also want to leave the geom and colmesh templates alone, we only need to change a few lines which I have highlighted in green: (GenericFireArm, projectileTemplate, itemIndex and GenericProjectile)
[codebox]
rem *** Generated with Bf2Editor.exe [created: 2005/3/23 15:53]
GeometryTemplate.compressVertexData 1
GeometryTemplate.maxTextureRepeat 16
ObjectTemplate.activeSafe GenericFireArm mine
ObjectTemplate.creator MBA-1:mba
ObjectTemplate.modifiedByUser nfe
ObjectTemplate.saveInSeparateFile 1
ObjectTemplate.castsDynamicShadow 1
rem ---BeginComp:WeaponHud ---
ObjectTemplate.createComponent WeaponHud
ObjectTemplate.weaponHud.weaponIcon Ingame\Weapons\Icons\Hud\icon_M16m203.tga
ObjectTemplate.weaponHud.selectIcon Ingame\Weapons\Icons\Hud\Selection\AT_mine.tga
ObjectTemplate.weaponHud.specialAbilityIcon Ingame\Weapons\Icons\Hud\SpecialKitIcons\mine.tga
ObjectTemplate.weaponHud.hudName "ANTI TANK MINE"
ObjectTemplate.weaponHud.guiIndex 0
ObjectTemplate.weaponHud.altGuiIndex 0
ObjectTemplate.weaponHud.hasFireRate 0
ObjectTemplate.weaponHud.disableOnSprint 1
rem ---EndComp ---
rem ---BeginComp:ThrownFireComp ---
ObjectTemplate.createComponent ThrownFireComp
ObjectTemplate.fire.addFireRate 0
ObjectTemplate.fire.projectileStartPosition 0/-0.1/0
ObjectTemplate.fire.maxProjectilesInWorld 5
ObjectTemplate.fire.pullBackTime 0
ObjectTemplate.fire.projectileStartRotation 0/-8/0
rem ---EndComp ---
rem ---BeginComp :D efaultAmmoComp ---
ObjectTemplate.createComponent DefaultAmmoComp
ObjectTemplate.ammo.magSize 1
ObjectTemplate.ammo.changeMagAt 0.8
ObjectTemplate.ammo.reloadTime 1.1
ObjectTemplate.ammo.minimumTimeUntilReload 0.3
ObjectTemplate.ammo.autoReload 1
ObjectTemplate.ammo.instantReloadOnEnable 1
ObjectTemplate.ammo.toggleWhenNoAmmo 1
rem ---EndComp ---
rem ---BeginComp:HelpHud ---
ObjectTemplate.createComponent HelpHud
ObjectTemplate.HelpHud.helpStringKey "HUD_HELP_WEAPON_HANDHELD_ATMINE_vehicles"
ObjectTemplate.HelpHud.helpSoundKey "HUD_HELP_WEAPON_HANDHELD_ATMINE_vehicles"
rem ---EndComp ---
rem ---BeginComp :D efaultSoundComp ---
ObjectTemplate.createComponent DefaultSoundComp
ObjectTemplate.sound.noisy 0
rem ---EndComp ---
rem ---BeginComp:ThrownAnimationComp ---
ObjectTemplate.createComponent ThrownAnimationComp
rem ---EndComp ---
rem ---BeginComp :D efaultZoomComp ---
ObjectTemplate.createComponent DefaultZoomComp
ObjectTemplate.zoom.addZoomFactor 0
rem ---EndComp ---
ObjectTemplate.geometry at_mine
ObjectTemplate.setCollisionMesh at_mine
ObjectTemplate.mapMaterial 0 lambert1 90
ObjectTemplate.hasMobilePhysics 0
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.physicsType Mesh
ObjectTemplate.material 90
rem -------------------------------------
ObjectTemplate.addTemplate S_at_mine_Fire1P
ObjectTemplate.addTemplate S_at_mine_Fire1P_Outdoor
ObjectTemplate.addTemplate S_at_mine_Fire3P
ObjectTemplate.addTemplate S_at_mine_BoltClick
ObjectTemplate.addTemplate S_at_mine_TriggerClick
ObjectTemplate.addTemplate S_at_mine_SwitchFireRate
ObjectTemplate.addTemplate S_at_mine_Reload1P
ObjectTemplate.addTemplate S_at_mine_Reload3P
ObjectTemplate.addTemplate S_at_mine_Deploy1P
ObjectTemplate.addTemplate S_at_mine_Deploy3P
ObjectTemplate.addTemplate S_at_mine_Zoom
rem -------------------------------------
ObjectTemplate.animationSystem1P Objects/Weapons/Handheld/AT_mine/AnimationSystem1p.inc
ObjectTemplate.animationSystem3P Objects/Weapons/Handheld/AT_mine/AnimationSystem3p.inc
ObjectTemplate.projectileTemplate mine_Projectile
ObjectTemplate.keepProjectiles 30
ObjectTemplate.velocity 5
ObjectTemplate.itemIndex 1
ObjectTemplate.delayToUse 1.1

GeometryTemplate.compressVertexData 1
GeometryTemplate.maxTextureRepeat 16
ObjectTemplate.create GenericProjectile mine_Projectile
ObjectTemplate.modifiedByUser nfe
ObjectTemplate.setNetworkableInfo BasicInfo
ObjectTemplate.createNotInGrid 1
ObjectTemplate.createdInEditor 1
rem ---BeginComp:Armor ---
ObjectTemplate.createComponent Armor
ObjectTemplate.armor.maxHitPoints 1000
ObjectTemplate.armor.defaultMaterial 90
ObjectTemplate.armor.waterLevel -0.3
rem ---EndComp ---
rem ---BeginComp :D efaultCollisionComp ---
ObjectTemplate.createComponent DefaultCollisionComp
ObjectTemplate.collision.bouncing 1
rem ---EndComp ---
rem ---BeginComp :D efaultDetonationComp ---
ObjectTemplate.createComponent DefaultDetonationComp
ObjectTemplate.detonation.explosionMaterial 49
ObjectTemplate.detonation.explosionRadius 7
ObjectTemplate.detonation.explosionForce 10
ObjectTemplate.detonation.explosionDamage 2500
ObjectTemplate.detonation.endEffectTemplate e_exp_MineExp
ObjectTemplate.detonation.useMMOnEndEffect 1
ObjectTemplate.detonation.triggerRadius 1
ObjectTemplate.detonation.triggerType MTYVehicle
ObjectTemplate.detonation.triggerVictimMinSpeed 1
ObjectTemplate.detonation.detectionRadius 25
ObjectTemplate.detonation.showMineIndicationIcon 1
ObjectTemplate.detonation.allowFriendlyFireDetonation 1
rem ---EndComp ---
rem ---BeginComp :D efaultProjSoundComp ---
ObjectTemplate.createComponent DefaultProjSoundComp
rem ---EndComp ---
rem ---BeginComp :D efaultPenetrateComp ---
ObjectTemplate.createComponent DefaultPenetrateComp
ObjectTemplate.penetrate.allowSolidPenetration 0
rem ---EndComp ---
ObjectTemplate.geometry at_mine
ObjectTemplate.setCollisionMesh at_mine
ObjectTemplate.mass 25
ObjectTemplate.floaterMod 0
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.physicsType Mesh
ObjectTemplate.collisionGroups 8
ObjectTemplate.material 90
rem -------------------------------------
ObjectTemplate.addTemplate S_at_mine_Projectile_Looping
rem -------------------------------------
ObjectTemplate.timeToLive CRD_NONE/9999/0/0
ObjectTemplate.material 90
ObjectTemplate.hasOnTimeEffect 1
ObjectTemplate.armingDelay 3
ObjectTemplate.localPredictOnClient 1
ObjectTemplate.damage 0
ObjectTemplate.visibleOn3dMap 1
ObjectTemplate.3dMapIcon 9
ObjectTemplate.canPickup 1

ObjectTemplate.activeSafe Sound S_at_mine_Fire1P
ObjectTemplate.modifiedByUser nfe
ObjectTemplate.soundFilename "objects/weapons/handheld/medikit/sounds/throw.wav"
ObjectTemplate.loopCount 0
ObjectTemplate.is3dSound 0
ObjectTemplate.stopType 1
ObjectTemplate.volume 0.5
ObjectTemplate.pitch 1
ObjectTemplate.pan 0.5
ObjectTemplate.reverbLevel 1
ObjectTemplate.pitchEnvelope 0/1/0.9/1.1/1/1/0/0.97/1.03/
ObjectTemplate.volumeEnvelope 0/1/0/1/1/1/0/0.9/1/

ObjectTemplate.activeSafe Sound S_at_mine_Fire1P_Outdoor
ObjectTemplate.modifiedByUser nfe

ObjectTemplate.activeSafe Sound S_at_mine_Fire3P
ObjectTemplate.modifiedByUser nfe
ObjectTemplate.soundFilename "objects/weapons/handheld/medikit/sounds/throw.wav"
ObjectTemplate.loopCount 0
ObjectTemplate.is3dSound 1
ObjectTemplate.stopType 1
ObjectTemplate.volume 0.5
ObjectTemplate.pitch 1
ObjectTemplate.reverbLevel 1
ObjectTemplate.pitchEnvelope 0/1/0.9/1.1/1/1/0/0.97/1.03/
ObjectTemplate.volumeEnvelope 0/1/0/1/1/1/0/0.9/1/
ObjectTemplate.minDistance 2
ObjectTemplate.halfVolumeDistance 4

ObjectTemplate.activeSafe Sound S_at_mine_BoltClick
ObjectTemplate.modifiedByUser nfe

ObjectTemplate.activeSafe Sound S_at_mine_TriggerClick
ObjectTemplate.modifiedByUser nfe

ObjectTemplate.activeSafe Sound S_at_mine_SwitchFireRate
ObjectTemplate.modifiedByUser nfe

ObjectTemplate.activeSafe Sound S_at_mine_Reload1P
ObjectTemplate.modifiedByUser nfe
ObjectTemplate.soundFilename "objects/weapons/handheld/at_mine/sounds/atmine_deploy_1p.wav"
ObjectTemplate.loopCount 1
ObjectTemplate.is3dSound 0
ObjectTemplate.stopType 1
ObjectTemplate.volume 0.5
ObjectTemplate.pitch 1
ObjectTemplate.pan 0.5
ObjectTemplate.reverbLevel 1

ObjectTemplate.activeSafe Sound S_at_mine_Reload3P
ObjectTemplate.modifiedByUser nfe
ObjectTemplate.soundFilename "objects/weapons/handheld/at_mine/sounds/atmine_deploy_3p.wav"
ObjectTemplate.loopCount 1
ObjectTemplate.is3dSound 1
ObjectTemplate.stopType 1
ObjectTemplate.volume 0.5
ObjectTemplate.pitch 1
ObjectTemplate.reverbLevel 1
ObjectTemplate.minDistance 0.5
ObjectTemplate.halfVolumeDistance 1

ObjectTemplate.activeSafe Sound S_at_mine_Deploy1P
ObjectTemplate.modifiedByUser nfe
ObjectTemplate.soundFilename "objects/weapons/handheld/at_mine/sounds/atmine_deploy_1p.wav"
ObjectTemplate.loopCount 1
ObjectTemplate.is3dSound 0
ObjectTemplate.stopType 1
ObjectTemplate.volume 0.5
ObjectTemplate.pitch 1
ObjectTemplate.pan 0.5
ObjectTemplate.reverbLevel 1

ObjectTemplate.activeSafe Sound S_at_mine_Deploy3P
ObjectTemplate.modifiedByUser nfe
ObjectTemplate.soundFilename "objects/weapons/handheld/at_mine/sounds/atmine_deploy_3p.wav"
ObjectTemplate.loopCount 1
ObjectTemplate.is3dSound 1
ObjectTemplate.stopType 1
ObjectTemplate.volume 0.5
ObjectTemplate.pitch 1
ObjectTemplate.reverbLevel 1
ObjectTemplate.minDistance 0.5
ObjectTemplate.halfVolumeDistance 1

ObjectTemplate.activeSafe Sound S_at_mine_Zoom
ObjectTemplate.modifiedByUser nfe

ObjectTemplate.activeSafe Sound S_at_mine_Projectile_Looping
ObjectTemplate.modifiedByUser nfe[/codebox]


Repeat the renaming process for the predator and m67.
Important: When renaming the predator DO NOT rename the projectile template leave it as ObjectTemplate.projectileTemplate at_predator unlike the mine the projectile template is seperate from the tweak and if renamed screws things up.

Once you have them setup it is time to return to the Kit, open TANK_KILLER.con, all we originally did was define the kit name, low lets add the modded weapons.

So we allready changed the kit name, next we want to delete the weapons were not using which will be the USATP_Predator, kni_knife and the USRIF_MP5_A3, then we want to add the weapons we want, the renamed loaded from our map and some from stock files.
So lets add CHAT_ERYX, c4_explosives, Predator, mine and m67. We will leave UnlockUSAT and UnlockUSAT2 in there.

Now lets edit the hud name: ObjectTemplate.vehicleHud.hudName "TANK KILLER" Save the file and the kit is done, it should look like this:
[codebox]ObjectTemplate.create Kit TANK_KILLER
ObjectTemplate.saveInSeparateFile 1
ObjectTemplate.kitType AT
ObjectTemplate.aiTemplate AT
ObjectTemplate.geometry US_Kits
ObjectTemplate.geometry.kit 3
ObjectTemplate.geometry.dropGeom 13
ObjectTemplate.networkableInfo KitInfo
ObjectTemplate.setHasCollisionPhysics 1
ObjectTemplate.unlockIndex 0
ObjectTemplate.cullRadiusScale 2.4

rem -------------------------------------
ObjectTemplate.addTemplate CHAT_ERYX
ObjectTemplate.addTemplate c4_explosives
ObjectTemplate.addTemplate Predator
ObjectTemplate.addTemplate USPIS_92FS
ObjectTemplate.addTemplate mine
ObjectTemplate.addTemplate UnlockUSAT
ObjectTemplate.addTemplate UnlockUSAT2
ObjectTemplate.addTemplate m67
ObjectTemplate.addTemplate ParachuteLauncher
rem -------------------------------------

ObjectTemplate.createComponent AbilityHud
ObjectTemplate.abilityHud.ammoSound S_Resupply
ObjectTemplate.abilityHud.healingSound S_Heal
ObjectTemplate.abilityHud.repairingSound S_Repair

ObjectTemplate.createComponent VehicleHud
ObjectTemplate.vehicleHud.hudName "TANK KILLER"
ObjectTemplate.vehicleHud.miniMapIcon "Ingame\Kits\Icons\kit_ATAA_outline.tga"
ObjectTemplate.vehicleHud.vehicleIcon "Ingame\Kits\Icons\kit_ATAA.tga"
ObjectTemplate.vehicleHud.spottedIcon "Ingame\Player\Icons\Minimap\mini_Soldier.dds"
ObjectTemplate.vehicleHud.abilityIcon "Ingame\Weapons\Icons\Hud\SpecialKitIcons\kevlarVest.tga"
ObjectTemplate.vehicleHud.pantingSound S_SprintBreath
ObjectTemplate.vehicleHud.injurySound S_Injury
ObjectTemplate.vehicleHud.vehicleType 7

ObjectTemplate.sprintStaminaDissipationFactor 0.6

rem ---BeginComp:Radio ---
ObjectTemplate.createComponent Radio
ObjectTemplate.Radio.spottedMessage "infantry_spotted"
rem ---EndComp ---

ObjectTemplate.create ItemContainer UnlockUSAT
ObjectTemplate.addTemplate chsht_protecta
ObjectTemplate.unlockLevel 1

ObjectTemplate.create ItemContainer UnlockUSAT2
ObjectTemplate.addTemplate eurif_fnp90
ObjectTemplate.replaceItem USRIF_MP5_A3
ObjectTemplate.replaceItem chsht_protecta
ObjectTemplate.unlockLevel 2[/codebox]

Now before we forget lets add our modifed kit and weapons to our custom zips, drag the kits folder into Custom_kits_server.zip and drag the weapons folder into Custom_weapons_server.zip

Ok we are almost ready to test it out, first we need to assign our new kit to the LevelSettings in your maps Init.con. Im testing on a map that has US and MEC, Im going to swap the US_AT with TANK_KILLER but you could swap it with whatever one you want.

gameLogic.setKit 1 6 "MEC_AT" "mec_heavy_soldier"
gameLogic.setKit 2 6 "TANK_KILLER" "us_heavy_soldier"

Thats it you have completed the tutorial, now with this knowledge you should be able to pretty much mod anything into your map, effects, soldiers, statics, vehicles, weapons, kits, vegitation, water, you name it
Superior Mind
Posts: 161
Joined: 2007-02-15 01:55

Post by Superior Mind »

Lol bro, you went way OD with that post. I know how to make custom kits and everything, I've been modding for at least a year now. I just didn't know how to make a new weapon. But thanks anyway lol.
Image
Post Reply

Return to “PR:BF2 Community Modding”