Page 1 of 4

[Code] HandBrake

Posted: 2009-05-03 16:46
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.

Re: [Code] HandBrake

Posted: 2009-05-03 16:54
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.

Re: [Code] HandBrake

Posted: 2009-05-03 17:05
by Rhino
interesting, but I dont see what in the code would make a vehicle stop?

Re: [Code] HandBrake

Posted: 2009-05-03 17:09
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.

Re: [Code] HandBrake

Posted: 2009-05-03 17:23
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.

Re: [Code] HandBrake

Posted: 2009-05-03 17:24
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 :)

Re: [Code] HandBrake

Posted: 2009-05-03 17:29
by Wilkinson
You should test it out and like make an awesome quick clip on it. But would be interesting to see.

Re: [Code] HandBrake

Posted: 2009-05-03 17:41
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.

Re: [Code] HandBrake

Posted: 2009-05-03 17:53
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.

Re: [Code] HandBrake

Posted: 2009-05-03 17:56
by Jedimushroom
Uhh horn is spacebar.

Re: [Code] HandBrake

Posted: 2009-05-03 18:01
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.

Re: [Code] HandBrake

Posted: 2009-05-03 18:31
by Onil
Jedimushroom wrote:Uhh horn is spacebar.
I thought the horn was on the left mouse button :o

Re: [Code] HandBrake

Posted: 2009-05-03 18:42
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

Re: [Code] HandBrake

Posted: 2009-05-03 18:42
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

Re: [Code] HandBrake

Posted: 2009-05-03 18:53
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.

Re: [Code] HandBrake

Posted: 2009-05-03 18:58
by Brummy
Please no :p .. This would only lead to random people trying to be a leet tokio driftah1!!11oen

Re: [Code] HandBrake

Posted: 2009-05-03 18:58
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

Re: [Code] HandBrake

Posted: 2009-05-03 19:00
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.

Re: [Code] HandBrake

Posted: 2009-05-03 19:00
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.

Re: [Code] HandBrake

Posted: 2009-05-03 19:02
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