[Code] HandBrake

Making or wanting help making your own asset? Check in here
Onil
Posts: 1232
Joined: 2007-08-19 09:50

[Code] HandBrake

Post by Onil »

I found this a long time ago and have been using it on PR SP for months and it is rather useful and fun. I don't know who the original creator is but you can see their names in the "modified by user" lines in the code since i didn't changed anything and don't want to take credit for something i didn't do. However i don't remember exactly where i got this from since it was a long time ago.

This would definitely be a great feature for PR.

It is very easy to use specially in vehicles that don't have any feature assigned to the right mouse button. Of course you can choose which button will activate the hand brake in case you want to use it in vehicles that already have something on the right mouse button (dropping ammo for example).

I don't advise messing around with BF2 or PR, so only do this in the PR Single Player Mod!

Let's take the American Buggy (FAAV) for example. Create the following files in notepad:

Handbrake.con
ObjectTemplate.create GenericFireArm Handbrake
ObjectTemplate.createdInEditor 1

include Handbrake.tweak
Handbrake.tweak
rem ***** Handbrake *****
rem ---------------------

ObjectTemplate.create GenericFireArm handbrake
ObjectTemplate.modifiedByUser cheese
ObjectTemplate.setNetworkableInfo BasicInfo
ObjectTemplate.saveInSeparateFile 1
ObjectTemplate.createdInEditor 1
rem ---BeginComp:WeaponHud ---
ObjectTemplate.createComponent WeaponHud
ObjectTemplate.weaponHud.guiIndex -1
ObjectTemplate.weaponHud.hasMag 0
ObjectTemplate.weaponHud.hasFireRate 0
ObjectTemplate.weaponHud.showAmmo 0
ObjectTemplate.weaponHud.showClips 0
ObjectTemplate.weaponHud.showInfo 0
rem ---EndComp ---
rem ---BeginComp:SingleFireComp ---
ObjectTemplate.createComponent SingleFireComp
ObjectTemplate.fire.fireInput PIAltFire
ObjectTemplate.fire.roundsPerMinute 900
rem ---EndComp ---
rem ---BeginComp :D efaultAmmoComp ---
ObjectTemplate.createComponent DefaultAmmoComp
ObjectTemplate.ammo.nrOfMags -1
ObjectTemplate.ammo.magSize -1
ObjectTemplate.ammo.reloadWithoutPlayer 1
rem ***** This is required to work *****
rem ------------------------------------
rem ---BeginComp:WeaponBasedRecoilComp ---
ObjectTemplate.createComponent WeaponBasedRecoilComp
ObjectTemplate.recoil.recoilForce 50
rem ---EndComp ---
ObjectTemplate.floaterMod 0
ObjectTemplate.hasMobilePhysics 1
rem -------------------------------------
ObjectTemplate.projectileTemplate Handbrake_Projectile
ObjectTemplate.keepProjectiles 5
ObjectTemplate.velocity 1


ObjectTemplate.create GenericProjectile Handbrake_Projectile
ObjectTemplate.modifiedByUser cheese
ObjectTemplate.createNotInGrid 1
ObjectTemplate.createdInEditor 1
ObjectTemplate.floaterMod 0
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.physicsType Point
ObjectTemplate.collisionGroups 8
rem -------------------------------------
ObjectTemplate.timeToLive CRD_NONE/0.01/0/0
ObjectTemplate.material -1
ObjectTemplate.hasOnTimeEffect 1
ObjectTemplate.minDamage 0.2
ObjectTemplate.damage 0
Create a Handbrake folder and put this 2 files inside it then search for the objects_server.zip inside the PR_SP_08/Objects folder. Open that zip and paste the Handbrake folder inside the Vehicles/Common folder so that it looks as below:

objects_server.zip/Vehicles/Common/Handbrake

Then go into the vehicle you want to change, for example the FAAV:

objects_server.zip/Vehicles/Land/jeep_faav folder

open the jeep_faav tweak file in the notepad

search for "car_horn"

as paste the following line in bold under the above two lines of the car_horn code:
ObjectTemplate.addTemplate Car_horn12
ObjectTemplate.setPosition 0/0.0937172/1.72664
ObjectTemplate.addTemplate jeep_faav_HandBrakeRotation
ObjectTemplate.setPosition 0/-0.25/-1.28
Add these lines to the end of the jeep_faav.tweak file:
ObjectTemplate.create RotationalBundle jeep_faav_HandbrakeRotation
ObjectTemplate.modifiedByUser "Bill"
ObjectTemplate.setNetworkableInfo BasicInfo
ObjectTemplate.createdInEditor 1
ObjectTemplate.floaterMod 0
ObjectTemplate.hasMobilePhysics 1
rem -------------------------------------
ObjectTemplate.addTemplate Handbrake
rem -------------------------------------
ObjectTemplate.setMinRotation -45/0/0
ObjectTemplate.setMaxRotation 45/0/0
ObjectTemplate.setMaxSpeed 1/0/0
ObjectTemplate.setAcceleration 150/0/0
ObjectTemplate.setInputToYaw PIYaw
ObjectTemplate.setAutomaticReset 1
ObjectTemplate.snapToZeroOnNoInput 1
Save it and load up a map that has the FAAV or replace one of the vehicles with the FAAV in the GamePlayObjects.con of the map

Drive the FAAV through the streets of Ramiel and test the handbrake first by going straight and braking and then by making a curve and braking. When going straight the handbrake will stop the vehicle immediately and slowly move backwards while when making a turn, the handbrake will make the vehicle drift to the side.

If you want to use another key instead of the right mouse button, change this line in the handbrake.tweak file:
ObjectTemplate.fire.fireInput PIAltFire
PIAltFire is the right mouse button so just replace that will the correct name of the other button you want to use.

This is both fun and useful and im sure you will enjoy it.

Have Fun !

EDIT 1: forgot about some lines of code needed, just added them.

EDIT 2: Some FAAV Examples

Video 1: Forward Braking Example - http://www.xfire.com/video/b17e8/

Video 2: Hand Brake Driving - http://www.xfire.com/video/b17f6/

EDIT 3: Some HMMWV & Stryker Examples

Forward HMMWV Hand Brake Example: http://www.xfire.com/video/b1915/

First i try to brake with the S key and Second i use the Hand Brake. As you can see the S key doesn't stop the vehicle in time because it doesn't work until the vehicle is almost stopped while the HB stops the vehicle right away.

Driving the HMMWV with the HandBrake: http://www.xfire.com/video/b193c/

Forward Stryker Hand Brake Example: http://www.xfire.com/video/b19ab/

Hope you can see from the vids a bit how the vehicle reacts with the hand brake.
Last edited by Onil on 2009-05-07 06:18, edited 8 times in total.
Image
AnRK
Posts: 2136
Joined: 2007-03-27 14:17

Re: [Code] HandBrake

Post by AnRK »

That's pretty cool, aside from apcs of course which carry ammo, none of the vehicles that really need a handbrake all that much have a spare secondary fire button.
Rhino
Retired PR Developer
Posts: 47909
Joined: 2005-12-13 20:00

Re: [Code] HandBrake

Post by Rhino »

interesting, but I dont see what in the code would make a vehicle stop?
Image
chuckduck
Posts: 227
Joined: 2009-02-22 12:08

Re: [Code] HandBrake

Post by chuckduck »

yeah, they should definateley include this into the next realease, if it isnt too buggy.
It would be a great help in those tight urban mas like. Basrah and Fallujah if all the jeeps/cars had this.
Nice one.
Currently Finishing off a PR Training Map with Pte.Paynter. Also Trying to Organise a Late Cold War Community Minimod.

Communist or Capitalist. Join the Invasion!
PR Late Cold War MiniMod Forum Link
crazy11
Retired PR Developer
Posts: 3141
Joined: 2008-02-05 00:20

Re: [Code] HandBrake

Post by crazy11 »

[R-DEV]Rhino wrote:interesting, but I dont see what in the code would make a vehicle stop?
It looks like he is trying to use a weapon back blast to stop the car.
Image
You miss 100% of the shots you don't take.- Wayne Gretzky
Onil
Posts: 1232
Joined: 2007-08-19 09:50

Re: [Code] HandBrake

Post by Onil »

[R-DEV]Rhino wrote:interesting, but I dont see what in the code would make a vehicle stop?
recoil of the weapon makes the vehicle stop :)
Image
Wilkinson
Posts: 1916
Joined: 2008-08-18 21:55

Re: [Code] HandBrake

Post by Wilkinson »

You should test it out and like make an awesome quick clip on it. But would be interesting to see.
Image
Image
Onil
Posts: 1232
Joined: 2007-08-19 09:50

Re: [Code] HandBrake

Post by Onil »

[R-CON]Wilkinson wrote:You should test it out and like make an awesome quick clip on it. But would be interesting to see.
It is tested.. as i said i have been using this since last year. So sure, i can make a small Xfire video.

will post it in a sec.
Image
Jordanb716
Posts: 186
Joined: 2008-04-10 22:58

Re: [Code] HandBrake

Post by Jordanb716 »

If it works maybe attach it to the spacebar. I cant think of anything that we use that for in the driver seat.
Colonelcool: I'd gladly pony up some tax dollars to send a JDAM over there just to kill that rooster.
OkitaMakoto: Talking squad level tactics in bed is actually a little known aphrodisiac.
Jigsaw: saying "lock please" accomplishes just about the square root of fuck all
Jedimushroom
Posts: 1130
Joined: 2006-07-18 19:03

Re: [Code] HandBrake

Post by Jedimushroom »

Uhh horn is spacebar.
Image

"God will strike him down when he checks his email and sees young Fighter has turd burgling tendancies. Could you imagine going to church knowing your son takes it up the wrong 'un?" - [R-Dev]Gaz on 'Fighter137'
Jordanb716
Posts: 186
Joined: 2008-04-10 22:58

Re: [Code] HandBrake

Post by Jordanb716 »

Jedimushroom wrote:Uhh horn is spacebar.
Oh right I forget. :) There's my idea out the window. edit: Hang on can't you just use left click? For the horn I mean.
Last edited by Jordanb716 on 2009-05-03 18:07, edited 2 times in total.
Colonelcool: I'd gladly pony up some tax dollars to send a JDAM over there just to kill that rooster.
OkitaMakoto: Talking squad level tactics in bed is actually a little known aphrodisiac.
Jigsaw: saying "lock please" accomplishes just about the square root of fuck all
Onil
Posts: 1232
Joined: 2007-08-19 09:50

Re: [Code] HandBrake

Post by Onil »

Jedimushroom wrote:Uhh horn is spacebar.
I thought the horn was on the left mouse button :o
Image
Onil
Posts: 1232
Joined: 2007-08-19 09:50

Re: [Code] HandBrake

Post by Onil »

Here are the videos, it's hard to show how the hand brake works in a video but i hope you can see the vehicle stopping right away and the effects it has on the vehicle. When im turning if i click once on the hand brake it drifts a lot so i just click and release twice to stop completely plus correcting direction with the wheels.

Video 1: Forward Braking Example - Hand Brake Example - Xfire Video

Video 2: Hand Brake Driving - Hand Brake Driving - Xfire Video
Image
BroCop
Posts: 4155
Joined: 2008-03-08 12:28

Re: [Code] HandBrake

Post by BroCop »

Is it possible to code the middle button?...AFAIK it isnt being used for anything


EDIT- btw just saw the vid's...must have in-game
Onil
Posts: 1232
Joined: 2007-08-19 09:50

Re: [Code] HandBrake

Post by Onil »

CroCop_PR wrote:Is it possible to code the middle button?...AFAIK it isnt being used for anything


EDIT- btw just saw the vid's...must have in-game
I suppose that would be possible yes.

I will try and make some vid's with other vehicles using it.
Image
Brummy
Posts: 7479
Joined: 2007-06-03 18:54

Re: [Code] HandBrake

Post by Brummy »

Please no :p .. This would only lead to random people trying to be a leet tokio driftah1!!11oen
chuckduck
Posts: 227
Joined: 2009-02-22 12:08

Re: [Code] HandBrake

Post by chuckduck »

Nice vids, i definatley support ths function. But i think the horn and the handbrake should be switched.

Mouse button L or R = Horn
Spacebar = Handbrake

Leet driftas, will just get shot to peices....they will over skid and then be shot to pieces like swiss cheese.
:p
Currently Finishing off a PR Training Map with Pte.Paynter. Also Trying to Organise a Late Cold War Community Minimod.

Communist or Capitalist. Join the Invasion!
PR Late Cold War MiniMod Forum Link
Brummy
Posts: 7479
Joined: 2007-06-03 18:54

Re: [Code] HandBrake

Post by Brummy »

chuckduck wrote:Nice vids, i definatley support ths function. But i think the horn and the handbrake should be switched.

Mouse button L or R = Horn
Spacebar = Handbrake

Leet driftas, will just get shot to peices....they will over skid and then be shot to pieces like swiss cheese.
:p
Spacebar = LMB

It's the 2nd Fire button.
Jordanb716
Posts: 186
Joined: 2008-04-10 22:58

Re: [Code] HandBrake

Post by Jordanb716 »

Some people use middle mouse for voip and iirc and you can just use left click for the horn I support spacebar for handbrake. If it's implemented of course. edit: I don't think they are connected together. Spacebar and lmb are just assigned to the same function in the key editor. You can change them separately.
Colonelcool: I'd gladly pony up some tax dollars to send a JDAM over there just to kill that rooster.
OkitaMakoto: Talking squad level tactics in bed is actually a little known aphrodisiac.
Jigsaw: saying "lock please" accomplishes just about the square root of fuck all
Onil
Posts: 1232
Joined: 2007-08-19 09:50

Re: [Code] HandBrake

Post by Onil »

Brummy wrote:Please no :p .. This would only lead to random people trying to be a leet tokio driftah1!!11oen
Don't worry, you can tweak it to lower the drift. But what's the fun in that? :D
Image
Post Reply

Return to “PR:BF2 Community Modding”