Zoom in tanks

Making or wanting help making your own asset? Check in here
czesiek77
Posts: 26
Joined: 2014-04-20 18:56

Zoom in tanks

Post by czesiek77 »

Hi I am trying to make my own mod.
I played Project Reality and I saw that tanks sights have zoom.
How is it done? In weapons it is simple by adding ObjectTemplate.zoom.addZoomFactor.
In tanks it can be done with this command but I want zoom which activate when X is pressed, not PPM.
User avatar
Mats391
PR:BF2 Lead Developer
Posts: 7643
Joined: 2010-08-06 18:06

Re: Zoom in tanks

Post by Mats391 »

The zoom on PR tanks is done with the smoke-launcher or the coax mg.
For example the us_tnk_m1a2 uses CoaxialBrowning, which you can find in weapon/armament/coaxial_browning and in there you have:

Code: Select all

rem ---BeginComp :D efaultZoomComp ---
ObjectTemplate.createComponent DefaultZoomComp
ObjectTemplate.zoom.zoomInput PIFlareFire
ObjectTemplate.zoom.zoomDelay 0
ObjectTemplate.zoom.addZoomFactor 0
ObjectTemplate.zoom.addZoomFactor 0.33
ObjectTemplate.zoom.addZoomFactor 0.1
rem ---EndComp ---
Similar components you will find for any land vehicle that has zoom. Choppers use a different system with cemaras.

Edit:
When you use this way of making zoom make sure the weapon with the zoom comp never gets deselected like the coax mg. Otherwise you will unzoom when switching weapons.
czesiek77
Posts: 26
Joined: 2014-04-20 18:56

Re: Zoom in tanks

Post by czesiek77 »

Thank you very much! It is that what I have been triying to do for last week. :)
czesiek77
Posts: 26
Joined: 2014-04-20 18:56

Re: Zoom in tanks

Post by czesiek77 »

I was wondering about one more thing. How do I move camera in tanks to other side of the barrel?
User avatar
Mats391
PR:BF2 Lead Developer
Posts: 7643
Joined: 2010-08-06 18:06

Re: Zoom in tanks

Post by Mats391 »

You have to change the position of the gunners camera then. To stick with the m1a2 example it would be called "us_tnk_m1a2_Gunner_Camera" it will have similar name to that always and is usually located on the turret somewhere. Best is to check its position in the bf2editor and adjust it to the position you like. However i do not recommend to save it from the editor, just use it as preview and make your changes with notepad directly in the tweak files.
czesiek77
Posts: 26
Joined: 2014-04-20 18:56

Re: Zoom in tanks

Post by czesiek77 »

Thank you again for helping. :grin:
czesiek77
Posts: 26
Joined: 2014-04-20 18:56

Re: Zoom in tanks

Post by czesiek77 »

Sorry for bothering but I have problem with adding zoom to LAV25. It has problem meybe becouse of guidence?
User avatar
Mats391
PR:BF2 Lead Developer
Posts: 7643
Joined: 2010-08-06 18:06

Re: Zoom in tanks

Post by Mats391 »

I doubt it is a problem with the guidance, other weapons have it and zoom fine (for example most AT vehicles in PR).
Can you post the code you added to zoom? And also are you working on bf2 LAV or PR one?
czesiek77
Posts: 26
Joined: 2014-04-20 18:56

Re: Zoom in tanks

Post by czesiek77 »

I am working on LAV from other mod, Here is the code :

Code: Select all

ObjectTemplate.create GenericFireArm lav_ad_bf3_TowLauncher
ObjectTemplate.createdInEditor 1
rem ---BeginComp:WeaponHud ---
ObjectTemplate.createComponent WeaponHud
ObjectTemplate.weaponHud.weaponIcon Ingame\Weapons\Icons\Hud\bomb.tga
ObjectTemplate.weaponHud.hudName "M220 TOW"
ObjectTemplate.weaponHud.hasFireRate 0
rem ---EndComp ---
rem ---BeginComp:MultiFireComp ---
ObjectTemplate.createComponent MultiFireComp
ObjectTemplate.fire.fireInput PIAltFire
ObjectTemplate.fire.fireInCameraDof 1
ObjectTemplate.fire.addBarrelName lav_ad_bf3_towbarrel
rem ---EndComp ---
rem ---BeginComp :D efaultAmmoComp ---
ObjectTemplate.createComponent DefaultAmmoComp
ObjectTemplate.ammo.nrOfMags -1
ObjectTemplate.ammo.magSize 1
ObjectTemplate.ammo.minimumTimeUntilReload 10
ObjectTemplate.ammo.autoReload 1
ObjectTemplate.ammo.reloadWithoutPlayer 1
rem ---EndComp ---
rem ---BeginComp:WeaponBasedRecoilComp ---
ObjectTemplate.createComponent WeaponBasedRecoilComp
ObjectTemplate.recoil.cameraRecoilSpeed 13
ObjectTemplate.recoil.cameraRecoilSize 1.5
rem ---EndComp ---
rem ---BeginComp:SimpleDeviationComp ---
ObjectTemplate.createComponent SimpleDeviationComp
ObjectTemplate.deviation.minDev 0.25
rem ---EndComp ---
rem ---BeginComp :D efaultSoundComp ---
ObjectTemplate.createComponent DefaultSoundComp
rem ---EndComp ---
rem ---BeginComp :D efaultAnimationComp ---
ObjectTemplate.createComponent DefaultAnimationComp
rem ---EndComp ---
rem ---BeginComp :D efaultZoomComp ---
[b]ObjectTemplate.createComponent DefaultZoomComp
ObjectTemplate.createComponent DefaultZoomComp
ObjectTemplate.zoom.zoomInput PIFlareFire
ObjectTemplate.zoom.addZoomFactor 0
ObjectTemplate.zoom.addZoomFactor 0.25[/b]
rem ---EndComp ---
rem ---BeginComp:LPTargetComp ---
ObjectTemplate.createComponent LPTargetComp
ObjectTemplate.target.maxDistance 9999
ObjectTemplate.target.setTargetAtMaxDistance 1
ObjectTemplate.target.targetSystem TSWireGuided
ObjectTemplate.target.targetObjectTemplate UniqueTarget
ObjectTemplate.target.disableGuidanceOnReload 0
ObjectTemplate.target.disableGuidanceOnReload 0
This LAV has normal cannon and TOW as alt fire just like in vanilla one.
User avatar
Mats391
PR:BF2 Lead Developer
Posts: 7643
Joined: 2010-08-06 18:06

Re: Zoom in tanks

Post by Mats391 »

Code: Select all

rem ---BeginComp :D efaultZoomComp ---
ObjectTemplate.createComponent DefaultZoomComp
[color=Red]ObjectTemplate.createComponent DefaultZoomComp[/color]
ObjectTemplate.zoom.zoomInput PIFlareFire
ObjectTemplate.zoom.addZoomFactor 0
ObjectTemplate.zoom.addZoomFactor 0.25
rem ---EndComp ---
You are createing the component twice in there. I also would add "ObjectTemplate.zoom.zoomDelay 0" as i dont know what the default zoom delay is.
What is the "delayToUse"? You wont be able to zoom during that delay or reloading the weapon
czesiek77
Posts: 26
Joined: 2014-04-20 18:56

Re: Zoom in tanks

Post by czesiek77 »

Ok I will try deleting it and adding zoomdelay.
czesiek77
Posts: 26
Joined: 2014-04-20 18:56

Re: Zoom in tanks

Post by czesiek77 »

It worked! Thanks!
czesiek77
Posts: 26
Joined: 2014-04-20 18:56

Re: Zoom in tanks

Post by czesiek77 »

One more thing. Is there anyway to do zoom like in BF3/4? I mean that some parts of hud are magnified?
User avatar
Mats391
PR:BF2 Lead Developer
Posts: 7643
Joined: 2010-08-06 18:06

Re: Zoom in tanks

Post by Mats391 »

Yes and no. There is no thing to check the zoom level, the only way is having a button node that activates when pressing the zoom key. You then cant have a lot of zoom delay or time between changing zoom levels otherwise the HUD wont synch with the zooming.
Easiest way to do that is if you have right mouse as zoom key. For any non mouse button you would likely need some hack like PR did with the C for changing to backup sights.
czesiek77
Posts: 26
Joined: 2014-04-20 18:56

Re: Zoom in tanks

Post by czesiek77 »

I am not sure if you understand me. I mean zoom in tanks. In BF3 when you zoom in tanks the main cross magnify. Example :
http://img2.wikia.nocookie.net/__cb2012 ... om_HUD.png

In want to achive similiar effect in BF2. I ve tried with altguiindex of main cannon but nothing works.
czesiek77
Posts: 26
Joined: 2014-04-20 18:56

Re: Zoom in tanks

Post by czesiek77 »

When I add altguiindex to main cannon it work but after shot it goes back to normal guiindex.
User avatar
Mats391
PR:BF2 Lead Developer
Posts: 7643
Joined: 2010-08-06 18:06

Re: Zoom in tanks

Post by Mats391 »

czesiek77 wrote:I am not sure if you understand me. I mean zoom in tanks. In BF3 when you zoom in tanks the main cross magnify. Example :
http://img2.wikia.nocookie.net/__cb2012 ... om_HUD.png

In want to achive similiar effect in BF2. I ve tried with altguiindex of main cannon but nothing works.
Yes i understand what you are trying and the way i described it was how i did it previously for handheld weapons
Example:

As you can see the indicator on the top switches from WFOV to NFOV when zooming in. I did this with a button node that reacts on right click, but i guess this is no option for vehicles :)
czesiek77 wrote:When I add altguiindex to main cannon it work but after shot it goes back to normal guiindex.
This seems like a way easier way to do it :D
I guess the reason it switches back after firing is because your main cannon is reloading then and "unzooms" (view is still zoomed because you have the zoom comp on other weapon). To fix this you can either add the zoom comp to the main cannon and then have the view zoom out after firing. Or you add the guiIndexes to the weapon with zoom comp (e.g. coax) and get the HUD based on that. The second approach might require you to make a lot of unique coax guns.
czesiek77
Posts: 26
Joined: 2014-04-20 18:56

Re: Zoom in tanks

Post by czesiek77 »

I need only 3 HUDs like that so I have too add Guiindex and altGuiindex to 3 coax guns, am I correct?
User avatar
Mats391
PR:BF2 Lead Developer
Posts: 7643
Joined: 2010-08-06 18:06

Re: Zoom in tanks

Post by Mats391 »

czesiek77 wrote:I need only 3 HUDs like that so I have too add Guiindex and altGuiindex to 3 coax guns, am I correct?
Yes and make sure the main cannon has no guiIndex then or it could give troubles. Best is to set it to -1 i think at least that is how its done on jets with the cannon.
czesiek77
Posts: 26
Joined: 2014-04-20 18:56

Re: Zoom in tanks

Post by czesiek77 »

It worked :) Thank you very much :-P
Post Reply

Return to “PR:BF2 Community Modding”