Copy weapon in custom map

Ask questions, discuss ideas, get answers
Poow
Posts: 271
Joined: Sun Nov 01, 2009 8:00 pm
Location: Germany
Contact:

Copy weapon in custom map

Post by Poow »

Hey,

I want to use the weapon from a mod in my custom map.
I've extracted all Files from this mod & looked up wich files are used for this weapon. Standarmesh, sounds, animations projectiles etc.
So I build the same folders and copied everything into this folders in my custom map.
Which step is the next?
I want to change the soldier kit by replacing a standard weapon with the new one.
And do I need to activate the new weapon like staic objects by writing: run example_m1/example_m1 in the objects.con in my objects folder ?

eg:
run HandWeapons/Pistol/Objects


Okay, I saw it at a map with a custom weapon. I started in the objects folder:
run items/init
In Items:
run IraqKit/init
in IraqKit:
run Assault/objects
I don't know if it's a bit absurd on that way...

But anyway it's not working. There is no Weapon etc:
http://www.abload.de/img/bf19422009-12-1700-55-ifc0.jpg
http://www.abload.de/img/bf19422009-12-1700-55-1eca.jpg
€²
Okay I had forgotten to activate the pistol geometries.
But still the same more or less. No animation, nothing.
http://www.abload.de/img/bf19422009-12-1701-05-kh0k.jpg
http://www.abload.de/img/bf19422009-12-1701-06-vdsy.jpg

Any tips?
You’re entering a world of pain!
User avatar
Senshi
Posts: 697
Joined: Sun Oct 18, 2009 1:14 pm
Location: Germany
Contact:

Re: Copy weapon in custom map

Post by Senshi »

The only thing you have to take care of is that your weapons' .con files are being "run" somewhere.

It is somehow traditional establishment to do this with al these subfolders, but it suffices to add the "run" commands to your init.con of the map.

Just write
run objects\MyWeapon\objects

Of course that only applies if you have the files at that place, change as you need ;)

Best is to simply run all the con files your weapon/vehicle/item has.
Place the standardmesh files of the object in "standardmesh" of your map's root.
Place the sound files in "sounds"
Place animations in "animations" of your map root (just as if it were a regular mod archive). Also use subfolders if the mod you take the object from has them too! This way if they are called by the objects.con or geometries.con the engine can find them as the relative paths are correct, else you would need to check all the .con files so their paths point correctly to your files.

Sounds confusing, but I hope you understood, it's actually very simple. Just regard your map.rfa as a modfolder and use "run" commands to get your object loaded up and you should be fine.
Poow
Posts: 271
Joined: Sun Nov 01, 2009 8:00 pm
Location: Germany
Contact:

Re: Copy weapon in custom map

Post by Poow »

Senshi wrote:The only thing you have to take care of is that your weapons' .con files are being "run" somewhere
Good point :D
Now I can shoot with the weapon but still no sound/animation.
I will check if all con files and the run commands...

€:
Every con file is beeing activated with "run"! No animation/sound
Thanks!
You’re entering a world of pain!
Poow
Posts: 271
Joined: Sun Nov 01, 2009 8:00 pm
Location: Germany
Contact:

Re: Copy weapon in custom map

Post by Poow »

Here is the level without textures if you want to look through it a bit.
Download(1.1 MB)
You’re entering a world of pain!
User avatar
Senshi
Posts: 697
Joined: Sun Oct 18, 2009 1:14 pm
Location: Germany
Contact:

Re: Copy weapon in custom map

Post by Senshi »

1) Okay, you made this quite complicated with the run commands...you are aware you can use run-commands over multiple subfolders? Just write run objects\item\that\you\want\objects or whatever. Also you actually don't need all these hundreds of subfolders. BF42 doesn't give a crap if you make correct subfolders for your objects-files, only for all the other stuff (standardmesh, sound, animation etc.) .
2) Why does the Pistols' object.con have all the animation parts remmed out?

Code: Select all

rem ** Objects
ObjectTemplate.create AnimatedBundle PistolComplex
ObjectTemplate.createSkeleton animations/Pistol.ske
rem ObjectTemplate.geometry pistolStock
ObjectTemplate.geometry pistol

rem ObjectTemplate.addTemplate pistolTrigger
rem ObjectTemplate.bindToSkeletonPart Trigger

rem ObjectTemplate.addTemplate pistolHammer
rem ObjectTemplate.bindToSkeletonPart hane

rem ObjectTemplate.addTemplate pistolPlate
rem ObjectTemplate.bindToSkeletonPart mantel

rem ObjectTemplate.addTemplate Gunmag
rem ObjectTemplate.bindToSkeletonPart mag


ObjectTemplate.create SimpleObject pistolSimple
rem ObjectTemplate.geometry pistolStock
ObjectTemplate.geometry pistol

rem ObjectTemplate.create SimpleObject pistolTrigger
rem ObjectTemplate.geometry pistolTrigger

rem ObjectTemplate.create SimpleObject pistolHammer
rem ObjectTemplate.geometry pistolHammer

rem ObjectTemplate.create SimpleObject pistolPlate
rem ObjectTemplate.geometry pistolPlate
Is this intentional? I noticed there are separate standardmeshes, so it seems useful to have the animation parts not remmed out...

3) Big buggo one: Animations
Well, you failed simply here ;) . You didn't include a single animation nor animation coding. The only thing you included is the pistol.ske, which is a skeleton file and only defines how the pistol is positioned (as well as pistol components( trigger, mag, etc.) in relation to the Bip01R Hand.
So now there are two possibilites: Either your weapon doesn't even have own animations and simply uses the animation of another weapon (e.g. the regular Vanilla colt), then all you have to do is add the singleshotweapons.inc to your map.rfa/animations and edit it (it's a simple text file, despite the "inc" ending). Just add this line:

Code: Select all

AnimationStateMachine.copyState Pistol v_arg1 Colt 1.0 Pistol 1.0
However, if your weapon has unique animations, you need to copy all the .baf too, again with correct subfolders...

Basically these are all the animations every weapon has (sometimes not all of them are present, sometimes more...they are stored in tidy folders so it's rather easy to find). They are spread all over the animation subfolders (crouch, lie, standwalkrun etc.)

Code: Select all

3PCrouchBreathUpper
3PCrouchForwardUpper
3PCrouch2LieUpper
3PJump2LieUpper
3PLieBreathUpper
3PLieForwardUpper
3PLieTurnLeftUpper
3PLieTurnRightUpper
1pCrawl
1pLieAim
1pRun
1pStand
1pStandAim
3PJumpRunUpper
3PJumpStandUpper
3PRunBackUpper
3PRunRelaxUpper
3PRunUpper
3PStandAimUpper
3PStandUpper
3PWalkUpper
1pDeploy
1pFire
1pFireEnd
1pIdle1
1pIdle2
1pIdle3
1pLieDeploy
1pLieFire
1pLieFireEnd
1pLieReload
1pReload
3PDeploy
3PFire
3PFireEnd
3PLieDeploy
3PLieFire
3PLieFireEnd
3PReload
3PReloadLie
Fire
Reload
4) Sound
You included the sounds-folder. nice. But again you forgot all the subfolders. Sounds are always stored according to a certain principle. (Folder name should be "sound", not "sounds", by the way!)
Make it look like this: Sound\44khz\Pistol01mono.wav
If you want 22khz and 11khz support too, you need to put the soundfiles accordingly into sound\22khz\pistol01mono.wav etc.
You should find them in the sound.rfa of your mod.rfa too, structured the same.

Hope this helps :) .
Poow
Posts: 271
Joined: Sun Nov 01, 2009 8:00 pm
Location: Germany
Contact:

Re: Copy weapon in custom map

Post by Poow »

Hey, thanks!

Sound is working. :D
I've added all animations in the correct sub folders (I hope so^^) but in the game there is still no animation :?

In the pirates mod there is a "singleShotWeaponsMod.inc" in the animation.rfa archive with the following content:

Code: Select all

AnimationStateMachine.copyState M25Sniper v_arg1 M25 1.0 M25 1.0
AnimationStateMachine.copyState TabukSniper v_arg1 Tabuk 1.0 Tabuk 1.0
AnimationStateMachine.copyState2 Remington v_arg1

AnimationStateMachine.copyState2 Pistol v_arg1 <------------
AnimationStateMachine.copyState2 DuellerPistol v_arg1
AnimationStateMachine.copyState2 DucksFoot_Pistol v_arg1
AnimationStateMachine.copyState2 Musket v_arg1
AnimationStateMachine.copyState2 Musketoon v_arg1
AnimationStateMachine.copyState2 Blunderbuss v_arg1
rem AnimationStateMachine.copyState2 cannonBalls v_arg1
AnimationStateMachine.copyState2 throwingKnife v_arg1
AnimationStateMachine.copyState2 Stone_Axe v_arg1
AnimationStateMachine.copyState2 Belaying_Pin v_arg1
AnimationStateMachine.copyState2 Bone_Club v_arg1
AnimationStateMachine.copyState2 Tankard v_arg1
AnimationStateMachine.copyState2 PowderKeg v_arg1
AnimationStateMachine.copyState2 Rapier v_arg1
AnimationStateMachine.copyState2 Plunderbuss v_arg1
AnimationStateMachine.copyState2 SniperMusket v_arg1
AnimationStateMachine.copyState2 Cleaver v_arg1
AnimationStateMachine.copyState2 BBKnife v_arg1

rem AnimationStateMachine.copyState cannonBalls v_arg1 ExpPack 1.0 ExpPack 1.0
AnimationStateMachine.copyState Musket v_arg1 Tabuk 1.0 Tabuk 1.0
I tried to use this file just with the marked line + the .baf files. Then totally without the "singleShotWeaponsMod.inc" + the .baf files.
Then I removed all animations an tried your "singleShotWeaponsMod.inc" file. Also nothing in the game. :(
And yes; all the "remmed" lines are also "remmed" in the original file.

New Version(1,8 MB)
You’re entering a world of pain!
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: Copy weapon in custom map

Post by Apache Thunder »

I have the same issue with the animations with Dalian Plant as well. The dam thing just won't load the animations for the new weapons I made. :(
ImageImageImage
I have cameras in your head!
User avatar
Senshi
Posts: 697
Joined: Sun Oct 18, 2009 1:14 pm
Location: Germany
Contact:

Re: Copy weapon in custom map

Post by Senshi »

Well as it's a separate weapon, you'll also have to take the animation coding over (yeah, working with animation is probably the most confusing part with BF42 ;) ). I think the problem is the ".inc" file is - as the name suggests - included (->"loaded") in all the animation coding files, but this "include" stuff is something that doesn't work as good as every other filehandling and can be glitchy as hell too. E.g. I think it's unable to trace relative paths very well, it usually only points to a file that is already in the very same folder. Now you could try to add all the animation code of your weapon separatly, that should work too...You'd need to find all the "AnimationStatexxx.con" of Vanilla and copy&change code from them...of course only the relevant parts.
Exmaple: AnimationStatesShoot.con

Code: Select all

AnimationStateMachine.createState Ub_FireBazooka
AnimationStateMachine.addAnimation Animations/WeaponHandling/3p/Bazooka/3PFireBazooka.baf 1.0 c_AsmPlayOnce
AnimationStateMachine.addAnimation Animations/WeaponHandling/1p/Bazooka/1PFireBazooka.baf 1.0 c_AsmPlayOnce
AnimationStateMachine.setOtherState c_AsmWeaponState WeaponFireBazooka
AnimationStateMachine.addTransitionWhenDone _POSE_
AnimationStateMachine.setMorphFactor 10000.0
AnimationStateMachine.setFlag c_AsmIsCrouching
include singleShotWeapons.inc Bazooka

AnimationStateMachine.setActiveState Ub_FireColt
AnimationStateMachine.addTransitionOne c_PIFire 0.5 1 Ub_FireColt
That is the part that is relevant for you. Now, this is getting a little bit into an animations tutorial for explaining ;) . This code describes the ASM (AnimationStateMachine) for when the Bazooka gets fired. As this is only very basic, it is almost universal for all single shot weapons (it actually only tells to load the animations described in "addanimation" (there are most often 2 of them, 1p and 3p) and some other not so important stuff.
In order to avoid having to write this for every weapon avaible, DICE played smart and used the line "include singleshotweapons.inc Bazooka" . This tells to load the singleshotweapons and defines "Bazooka" as a variable (v_arg1). Now the singleshotweapons is loaded and for every weapon code that is found there (Pistol v_arg1) this code gets duplicated and the variable changed so the animation is defined too.
You can see this works around several corners and somewhat at the brink of what BF can handle. e.g. this "include" stuff doesn't work as it should for knifes and grenades...another topic.

I'd suggest you test this by using the code above (of course replace Bazooka with your Pistol), check that the "addanimations" point to the right files and remove the "include" line. The "activestate" in the end should be changed too, that's only to make a smooth transition if you fire the pistol again while the first "fire"-animation is not yet finished. With this code, you should see animations ingame when you fire your pistol. If it does work, you would have to do this for all the other ASM definitions too.
Test it before you do all the work, I never did animations mapside too, so I'm not sure either where the problem actually lies.
Poow
Posts: 271
Joined: Sun Nov 01, 2009 8:00 pm
Location: Germany
Contact:

Re: Copy weapon in custom map

Post by Poow »

Hey

I tried this AnimationStatesShoot.con:

Code: Select all

        AnimationStateMachine.createState Ub_FirePistol
    AnimationStateMachine.addAnimation Animations/WeaponHandling/3p/Pistol/3PFirePistol.baf 1.0 c_AsmPlayOnce
    AnimationStateMachine.addAnimation Animations/WeaponHandling/1p/Pistol/1pFirePistol.baf 1.0 c_AsmPlayOnce
  AnimationStateMachine.setOtherState c_AsmWeaponState WeaponFireBazooka
    AnimationStateMachine.addTransitionWhenDone _POSE_
    AnimationStateMachine.setMorphFactor 10000.0
    AnimationStateMachine.setFlag c_AsmIsCrouching



    AnimationStateMachine.addTransitionOne c_PIFire 0.5 1 Ub_FireColt
in: /animations without any results.

But I don't know if I have understood everything correctly..
You’re entering a world of pain!
User avatar
Senshi
Posts: 697
Joined: Sun Oct 18, 2009 1:14 pm
Location: Germany
Contact:

Re: Copy weapon in custom map

Post by Senshi »

Do you have the .baf files in the correct subfolders too?

Also you have to change "Bazooka" in this line too ;) :
AnimationStateMachine.setOtherState c_AsmWeaponState WeaponFireBazooka

But again, I myself am not sure if this stuff is possible mapside at all. But if it is, this would be the way to do it.
Post Reply