Jump to content
Official BF Editor Forums
Sign in to follow this  
[BF:A] Croupier

How to: Spawning Destructable Barrels

Recommended Posts

Tutorial taken from my reply to covertmercenary question regarding spawning destructable barrels.

http://bfeditor.org/forums/index.php?showtopic=6087

Maybe this could work: Make object spawner and choose any vechile, then in tweaker bar where is defined which vechiles will spawn, just write one of destroyable objects name to that textfield and see if it works.

On the right track but I'm afraid it's not quite that simple. The 2 problems with what would seem to be the most obvious approach as Freor stated is:

1. You can't type into into the VehicleTeam field

2. Even just assigning the destructable barrel as the object spawned wont work (it throws up a network code error, looks like objectspawners dont like destructable barrels, strange because the destructable bridges work? diff = mesh type.)

Luckily there is a workaround but it involves a bit of basic modding.

How to spawn Destructable Barrels.

Navigate to your level folder, bf2/levels/your_map/ if contents are zipped then unzip.

Inside your_map folder create a new folder named customobjects, open the customobjects folder and create a new folder barrel_red, open barrel_red.

Open mods/bf2/Objects_server.zip/staticobjects/common/destroyableobjects/barrel/barrel_yellow/

Copy barrel_yellow.con and barrel_yellow.tweak and paste them in your_map/customobjects/barrel_red/ then marque select, right click and properties and uncheck read only.

Rename the con and tweak to barrel_red.con and barrel_red.tweak, open the con and rename it like this:

GeometryTemplate.create BundledMesh barrel_red
CollisionManager.createTemplate barrel_red

ObjectTemplate.create PlayerControlObject barrel_red
ObjectTemplate.saveInSeparateFile 1
ObjectTemplate.creator FUL-1:ful
ObjectTemplate.collisionMesh barrel_yellow
ObjectTemplate.mapMaterial 0 metal_thin 0
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.physicsType 3
ObjectTemplate.geometry barrel_yellow

include barrel_red.tweak

Note I leave the col mesh and Geom names alone. Also very important I change the Object template type to PlayerControlObject reasons as I noted in point 2.

Do the same for the tweak:

rem *** Generated with Bf2Editor.exe [created: 2005/5/2 17:30]
GeometryTemplate.compressVertexData 1
GeometryTemplate.maxTextureRepeat 16
ObjectTemplate.activeSafe PlayerControlObject barrel_red
ObjectTemplate.creator DPA-1:dpa
ObjectTemplate.modifiedByUser ful
ObjectTemplate.setNetworkableInfo BasicInfo
ObjectTemplate.saveInSeparateFile 1
rem ---BeginComp:Armor ---
ObjectTemplate.createComponent Armor
ObjectTemplate.armor.maxHitPoints 50
ObjectTemplate.armor.hitPoints 50
ObjectTemplate.armor.defaultMaterial 97
ObjectTemplate.armor.waterLevel -0.3
ObjectTemplate.armor.explosionForce 12
ObjectTemplate.armor.explosionDamage 150
ObjectTemplate.armor.explosionRadius 9
ObjectTemplate.armor.explosionMaterial 70
ObjectTemplate.armor.wreckHitPoints 0
ObjectTemplate.armor.addArmorEffect 0 e_barrelyello_exp1 0/0/0 0/0/0
rem ---EndComp ---
ObjectTemplate.geometry barrel_yellow
ObjectTemplate.setCollisionMesh barrel_yellow
ObjectTemplate.mapMaterial 0 metal_thin 111
ObjectTemplate.treeCollisionDiameter 0.7
ObjectTemplate.hasMobilePhysics 0
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.physicsType Mesh

Now before we open the editor we will create a new .con file in levels/your_map/ called tmp.con and in that con file we will type run customobjects\barrel_red\barrel_red.con and then save.

We will also type that same line run customobjects\barrel_red\barrel_red.con in levels/your_map/Init.con right at the bottom like this:

rem -----------------------------------------------------------------------------

renderer.globalStaticMeshLodDistanceScale 1
renderer.globalBundleMeshLodDistanceScale 1
renderer.globalSkinnedMeshLodDistanceScale 1

run customobjects\barrel_red\barrel_red.con

The reason why I am dupilicating that line is simple, when I save in the editor the line in Init.con that I added will be erased, fortunately the init.con contains a line that points to the tmp.con that does'nt get erased. I need the line in the Init.con when working in the editor otherwise the barrel_red is not available in the VehicleTeam selector.

OK time to fire up the Editor.

Load up your unzipped map with the custom barrel_red. Right click near a control point, create ObjectSpawner, click cancel, name it CP_your_flag_barrel_red1

Go to the tweakerbar and click in the VehicleTeam1 selection box, if all went well you should have barrel_red as selectable, to quickly select it press B on your keyboard.

If you are experiencing problems I suggest re-doing the tutorial.

Cheer's,

Croupier..... dice2.png

Share this post


Link to post
Share on other sites

Using the above method you can create an object spawner that will spawn barrels like it would a vehicle in game.

I havent tested this over a network but it works fine locally.

Share this post


Link to post
Share on other sites
Croupier' date='Jun 17 2006, 02:08 PM' post='41721']

The reason why I am dupilicating that line is simple, when I save in the editor the line in Init.con that I added will be erased, fortunately the init.con contains a line that points to the tmp.con that does'nt get erased. I need the line in the Init.con when working in the editor otherwise the barrel_red is not available in the VehicleTeam selector.

Init.con referring to tmp.con is not in your example. Do we just add

run tmp.con

to our init.con?

Cheers

Shade

Share this post


Link to post
Share on other sites

This is does not work for me. I did this tutorial like 4 times. I even copied and pasted all the text, straight from this forum. I get up to the part where I select it as a vehicle spawn.

Go to the tweakerbar and click in the VehicleTeam1 selection box, if all went well you should have barrel_red as selectable, to quickly select it press B on your keyboard.

Red barrel is in the list. When I select it for team1, bf editor crashes. I even tried it for team2. It still crashes. Can someone please test this? This is the only tutorial I found for spawning barrels.

Share this post


Link to post
Share on other sites

okay. I did figure this out. It does work. What I did was edit gulf of oman. and renamed it. When I try to add regular static yellow barrels, they were no where to be found. it wasnt in the editor list of objects. but i noticed there was a folder called "level" and inside it had my barrel_red. So i added those red barrels as static objects into my map. Then I tried adding a spawnable red barrel and the editor didnt crash YAY

I tested my map and it works!! barrels come back.

now my problem is, when i opened my map to edit it again, i look at the spawnable red barrels and all i see is a blue sqaure. there no red barrel to be found. I look in the init.con and the "run" command line is not there. but the command line is in the tmp.con file. so i boot my map back up in bf2 and everything seems to be fine. the red barrel is still there. it just doesnt show it in the editor. im thinking because the init.con deltes the run command

EDIT*

Editor crashed again :( When I opened the editor the 2nd time and tried adding a third barrel as spawn, it crashed. i tihnk its because the run command isnt it in the init.,con

Edited by Abort

Share this post


Link to post
Share on other sites

The tmp.con is not run when launching the map in the editor (why ? because the 'run tmp.con' command is in the section 'if v_arg1 is not editor' ) Either add the 'run tmp.con' command to the other section as well or live without the barrels in the editor.

Share this post


Link to post
Share on other sites

i see. but why am i the only person having a problem with this tutorial? It makes perfect sense to use the yellow barrel as a template and then create a red barrel. But why does it crash in the editor with out doing extra stuff (adding static red barrel)? I'm editing gulf of oman btw.

Share this post


Link to post
Share on other sites

The editor doesn't find the object when its loading your map, because the 'run tmp.con' is not included in the editor section of your init.con. But there's help. You can copy the red_barrel object folder to the /objects folder in your mod. Make sure to have the same path as in the map's object folder then the editor can load the barrel from your mod while the game loads it from your map :P

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×