Jump to content
Sign in to follow this  
Big Dawg KS

Improved Bullet Cam Script v1.1

Recommended Posts

Here is an update to this script due to a few requests.

Changes from previous version (1.0):

-Added following global variables (uses can be found in comments):

BDKS_BulletCamNoBlur, BDKS_BulletCamFOV, BDKS_BulletCamAccTime, BDKS_BulletCamNoParticleFX

-Added BDKS_ShowBulletCamToPlayer unit variable (see comments for use)

-Added particle effect (nothing too fancy, I like it but I'm open to suggestions)

-Added ability to terminate bullet cam in flight with key for ironsights/optics

-Added blackin/blackout effects for smoother transitions

-By default, player only sees bullet cam when he fires (see BDKS_ShowBulletCamToPlayer)

-Added check to abort cam script if projectile not found

Untested in Multiplayer. MP behaviour unknown.

See comments for more info.

Show spoiler for code

// Bullet Cam Script
// v1.1
// cam.sqf
// Big Dawg KS
// 7/13/09
//
// Call via Fired EH, ex:
//   this addEventHandler ["fired",{_this execVM "cam.sqf"}]
//
// To exit the camera ingame (while in flight), press the key for ironsights/optics
//
// To add supported weapons, add MUZZLE classnames to _list (note: classnames are CASE SENSITIVE)
//
// To disable bullet cam, set BDKS_DisableBulletCam = true
//
// To disable blur effects, set BDKS_BulletCamNoBlur = true
//
// To disable particle effects, set BDKS_BulletCamNoParticleFX = true
//
// To change FOV (zoom), change the value of BDKS_BulletCamFOV (default 0.05). Ex:
//   BDKS_BulletCamFOV = 0.3
//
// To change time acceleration, change the value of BDKS_BulletCamAccTime (default 0.5). Ex:
//   BDKS_BulletCamAccTime = 0.2
// (Note: AccTime only works in Singleplayer)
//
// To make another unit's (other than local player) bullet cam show for the
// local player, set unit variable BDKS_ShowBulletCamToPlayer = true, ex:
//   if(local Spotter)then{Sniper setVariable ["BDKS_ShowBulletCamToPlayer",true]}
//------------------------------------------------------------------------------------------------

_projectile = nearestObject [_this select 0,_this select 4];

if(call {if(isNil "BDKS_DisableBulletCam")then{true}else{!BDKS_DisableBulletCam}})then{

if((_this select 0) == vehicle player || call {if(isNil {(_this select 0) getVariable "BDKS_ShowBulletCamToPlayer"})then{false}else{(_this select 0) getVariable "BDKS_ShowBulletCamToPlayer"}})then{

// Add more weapons here
_list = ["M40A3","m107","M24","M4SPR","SVD","SVD_CAMO","ksvk","DMR","huntingrifle","SMAW","Javelin","SidewinderLaucher_F35","BombLauncherF35"];

_type = getText (configFile >> "CfgAmmo" >> (_this select 4) >> "simulation");
_relPos = [0,-13,0.05];
_fov = 0.05;
if(!isNil "BDKS_BulletCamFOV")then{_fov = BDKS_BulletCamFOV};
if(_type == "shotMissile" || _type == "shotRocket")then{_relPos = [0,-13,2.2]; _fov = 0.5};

_disablePP = false;
if(call {if(isNil "BDKS_BulletCamNoBlur")then{false}else{BDKS_DisableBulletCam}})then{_disablePP = true};

_accTime = 0.5;
if(!isNil "BDKS_BulletCamAccTime")then{_accTime = BDKS_BulletCamAccTime};

_enableParticles = true;
if(call {if(isNil "BDKS_BulletCamNoParticleFX")then{false}else{BDKS_BulletCamNoParticleFX}})then{_enableParticles = false};

if((_this select 2) in _list && !(isNull _projectile))then{
setAccTime _accTime;
_camera = "camera" camCreate (getPos _projectile);
_camera cameraEffect ["INTERNAL","BACK"];
showCinemaBorder false;
cutText ["","BLACK IN",0.2];
_cancel = false;

if(_enableParticles && _type == "ShotBullet")then{
	_pShape = ["\ca\Data\ParticleEffects\Universal\Universal.p3d", 16, 13, 3, 0];
	_pSize = [0.01,0.05];
	_pColor = [[1,1,1,0.08],[1,1,1,0.16],[1,1,1,0.03],[1,1,1,0]];

	_pSource = "#particlesource" createVehicleLocal (getPos _projectile);
	_pSource attachTo [_projectile,[0,0,0]];
	_pSource setParticleParams [_pShape,"","Billboard",1,0.3,[0,0,0],[0,0,0],0,1,0.79,0.18,_pSize,_pColor,[1000],100,0.01,"","",_projectile,360];
	_pSource setDropInterval 0.001;
};

while{alive _projectile && alive _camera && !_cancel}do{
	_camera camSetTarget _projectile;
	_camera camSetRelPos _relPos;
	_camera camSetFOV _fov;
	_camera camSetFocus [600,2];
	_camera camCommit 0;

	"RadialBlur" ppEffectAdjust [0.02,0.02,0.1,0.1];
	"RadialBlur" ppEffectCommit 0.01;
	if(!_disablePP)then{"RadialBlur" ppEffectEnable true};

	if(inputAction "optics" != 0)then{_cancel = true};

	sleep 0.001;
};
if(alive _camera && !_cancel)then{
	_camera camSetFocus [-(_relPos select 1),1];
	_camera camSetFOV (_fov * 1.6);
	_camera camCommit 1.5;

	"RadialBlur" ppEffectAdjust [0,0,1,1];
	"RadialBlur" ppEffectCommit 0.7;

	sleep 1.39;
};
cutText ["","BLACK OUT",0.1];
sleep 0.11;
setAccTime 1;
"RadialBlur" ppEffectEnable false;
_camera cameraEffect ["TERMINATE","BACK"];
camDestroy _camera;
if(_enableParticles)then{deleteVehicle _pSource};
cutText ["","BLACK IN",0.6];
};

};

};

Download

cam.sqf v1.1 @ dump.no (thanks kju, can't even access rapidshare here at work anyway)

Share this post


Link to post
Share on other sites

Dawg, you are the One ;-)

Great work, I'll test it today! Thanks, mate!

Will test it now, after a quick glance of the list of options (great work, am impressed) the only thing I'd like to see is camera position to the target as a variable. Get my drift? I'll update in a hour if all runs.

Grtz

---------- Post added at 01:58 PM ---------- Previous post was at 01:29 PM ----------

Dawg, I think you have outdone yourself, some suggestions:

- Bullet is shown from behind/low point camera angle. I would like to see hanging over the bullet sort to speak, say at a 30-45% angle. Because now sometimes you don't see the upper body when the bullet impacts.

- The camera focus on the target. Could you make that into a variable which is adpatable? Because now the Target is really upclose.

Small bug:

- The cancel option did not work, which overhere is the right mouse button. I can't cancel the cam.

Besides these points, it is simply amazing, very well done, sir! Appreciating your effort to make Arma 2 a better experience, two thumbs up!!!

Highly recommended for all Snipers/Pilots!

PS: Dawg, if one wants to disamble the blur effect where do you add the line :set BDKS_BulletCamNoBlur = true

Edited by p75

Share this post


Link to post
Share on other sites
The camera focus on the target. Could you make that into a variable which is adpatable? Because now the Target is really upclose.

Use BDKS_BulletCamFOV. Increase it for less zoom, decrease it for more (default is 0.05).

The cancel option did not work, which overhere is the right mouse button. I can't cancel the cam.

Like I said it can only be cancelled while the projectile is in flight, after it hits something you can't skip the 1-2 second shot of the impact. If it still doesn't work, it may be related to using the mouse (I don't use default control mapping), try using Num 0 (which is also ironsights/optics key by default IIRC).

Bullet is shown from behind/low point camera angle. I would like to see hanging over the bullet sort to speak, say at a 30-45% angle. Because now sometimes you don't see the upper body when the bullet impacts.

The problem is that the bullet does not rotate at all while in flight (its orientation remains fixed regardless of trajectory), and camera is attached relative to the direction of the round, not it's trajectory. If I were to change this, math (specifically trig, which I'm a bit rusty with) would be involved. Of course I could still add a variable to change the angle of the camera relative to the round, though this problem will still exist.

PS: Dawg, if one wants to disamble the blur effect where do you add the line :set BDKS_BulletCamNoBlur = true

Init field will work:

BDKS_BulletCamNoBlur = true

Share this post


Link to post
Share on other sites
Use BDKS_BulletCamFOV. Increase it for less zoom, decrease it for more (default is 0.05).

Like I said it can only be cancelled while the projectile is in flight, after it hits something you can't skip the 1-2 second shot of the impact. If it still doesn't work, it may be related to using the mouse (I don't use default control mapping), try using Num 0 (which is also ironsights/optics key by default IIRC).

The problem is that the bullet does not rotate at all while in flight (its orientation remains fixed regardless of trajectory), and camera is attached relative to the direction of the round, not it's trajectory. If I were to change this, math (specifically trig, which I'm a bit rusty with) would be involved. Of course I could still add a variable to change the angle of the camera relative to the round, though this problem will still exist.

Init field will work:

BDKS_BulletCamNoBlur = true

Mucho Gracias, Dawg, thank you for the input, simply superb!

I highly recommend this addon!!!

Share this post


Link to post
Share on other sites

Sounds promising. :rthumb:

If I were to change this, math (specifically trig, which I'm a bit rusty with) would be involved. Of course I could still add a variable to change the angle of the camera relative to the round, though this problem will still exist.

Instead of using the orientation of the bullet, you can use it's velocity vector to determine the angle.

Like this: (velocityvector / bulletspeed * distance) <-- rotated around 120° and used as modelcoordinate for positioning the camera. AFAIK we have an BIS_function for rotating vectors.

Edited by Tajin

Share this post


Link to post
Share on other sites
Instead of using the orientation of the bullet, you can use it's velocity vector to determine the angle.

I know, but if you look at my code I'm using camSetRelPos to save me the trouble of doing any calculations. I know I could use the velocity, I implied that in my previous post, but like I said my math is a bit rusty and it's not a serious enough problem for me to go through the effort to change it (plus then the code would become a lot more complex, and I'm trying to keep it as simple as possible).

AFAIK we have an BIS_function for rotating vectors.

That's cool, I wrote a few functions for ArmA to rotate vectors since at the time the math was fresh in my head (linear algebra is actually quite simple), but have since forgotten it all. It's been so long since I'ved used my (at one point well developed) math skills, in addition to a recent lack of interest (I used to actually enjoy this stuff... sigh), that they've completely degraded.

Edited by Big Dawg KS

Share this post


Link to post
Share on other sites

Thanks guys, but changing the fov does the trick, I set it to 0.3 instead of 0.05.

Gotta say it is awesome, really impressed by the results!!! Although, the no blur is better in my opinion. But that is a matter of preferences.

All I gotta to say is that this comes highly recommended and I appreciate your hard work, it could not be more perfect:

THANKS

Share this post


Link to post
Share on other sites
in addition to a recent lack of interest (I used to actually enjoy this stuff... sigh), that they've completely degraded.

;) I know what you mean. Got exactly the same problem sometimes.

Share this post


Link to post
Share on other sites

I find the blur to be more immersive on aircraft ordinance (ex. bombs).

I highly recommend this addon!!!

I don't want to call this an addon, but a useful tool for editors. They can modify it or take pieces from it to use for their own purposes. Anyone is free to use my code as they see fit, I'd prefer you credit me but then again there are times where I myself don't credit other people's code so I have no right to demand it of you.

I know what you mean. Got exactly the same problem sometimes.

For once, I think video games are actually to blame here... how ironic. :o

Edited by Big Dawg KS

Share this post


Link to post
Share on other sites

Thx for this very nice script, Big Dawg KS !

Put it on our scripts section at Assault Mission Studio

dlicon.gif

Improved Bullet Cam Script [1.1] by Big Dawg KS

Share this post


Link to post
Share on other sites

How do I get this script to run? I'm new to mission making and scripting.

Share this post


Link to post
Share on other sites

It says in the comments:

this addEventHandler ["fired",{_this execVM "cam.sqf"}]

Share this post


Link to post
Share on other sites
It says in the comments:

this addEventHandler ["fired",{_this execVM "cam.sqf"}]

Cool, got it to work! Thanks!

Share this post


Link to post
Share on other sites

Dawg,

Small bug:

There is an issue with the NVgoggles. When activated you don't get the bullet cam unless aimed high and then when you do get it while aiming high you get the bullet flight without NV filter. Could you please address it?

Thanks!

Share this post


Link to post
Share on other sites

Great script. I used your last version and I liked the slow-mo. I see where I can adjust the speed but It will stay at that speed if I change it. How would I make time go back to normal after impact?

Share this post


Link to post
Share on other sites
Dawg,

Small bug:

There is an issue with the NVgoggles. When activated you don't get the bullet cam unless aimed high and then when you do get it while aiming high you get the bullet flight without NV filter. Could you please address it?

Thanks!

Update on testing:

Another bug:

When your soldier is higher than the target (say on a mountain ) and you are shooting in a downwards angle the script does not work. Could you please address it.

Share this post


Link to post
Share on other sites

Update - bug:

I don't have all the rocket classnames, but none of the airplanes/helis work with the script.

Share this post


Link to post
Share on other sites

Vehicles will only work if you add the eventhandler to the vehicle itself, not just the crew.

F35 weapons are in the script already, more can be added.

Share this post


Link to post
Share on other sites
Vehicles will only work if you add the eventhandler to the vehicle itself, not just the crew.

F35 weapons are in the script already, more can be added.

Dawg, I did both, hmm, maybe I misspelled some name? You have a list with all the rocket names?

You know what the issue is with aiming at something below?

Grtz

Share this post


Link to post
Share on other sites

Here's a new (untested) version that will A. hopefully allow you to eliminate the problem where the script cannot acquire the projectile and B. allow you to define supported weapons without modifying the script (via a global variable).

Read the comments for details.

This is a beta (untested):

// Bullet Cam Script
// v1.2b
// cam.sqf
// Big Dawg KS
// 8/3/09
//
// Call via Fired EH, ex:
//   this addEventHandler ["fired",{_this execVM "cam.sqf"}]
//
// Alternatively, for higher velocity projectiles (where the script has trouble acquiring the projectile),
// call with this syntax:
//   this addEventHandler ["fired",{_this+(nearestObject [_this select 0,_this select 4]) execVM "cam.sqf"}]
//
// To exit the camera ingame (while in flight), press the key for ironsights/optics
//
// To add supported weapons, add MUZZLE classnames to _list (note: classnames are CASE SENSITIVE).
// Alternatively, declare a global array called BDKS_BulletCamList with muzzle classnames. Ex:
//   BDKS_BulletCamList = ["huntingrifle","Javelin"]
//
// To disable bullet cam, set BDKS_DisableBulletCam = true
//
// To disable blur effects, set BDKS_BulletCamNoBlur = true
//
// To disable particle effects, set BDKS_BulletCamNoParticleFX = true
//
// To change FOV (zoom), change the value of BDKS_BulletCamFOV (default 0.05). Ex:
//   BDKS_BulletCamFOV = 0.3
//
// To change time acceleration, change the value of BDKS_BulletCamAccTime (default 0.5). Ex:
//   BDKS_BulletCamAccTime = 0.2
// (Note: AccTime only works in Singleplayer)
//
// To make another unit's (other than local player) bullet cam show for the
// local player, set unit variable BDKS_ShowBulletCamToPlayer = true, ex:
//   if(local Spotter)then{Sniper setVariable ["BDKS_ShowBulletCamToPlayer",true]}
//------------------------------------------------------------------------------------------------

_projectile = nearestObject [_this select 0,_this select 4];

if(count _this > 5)then{_projectile = _this select 5};

if(call {if(isNil "BDKS_DisableBulletCam")then{true}else{!BDKS_DisableBulletCam}})then{

if((_this select 0) == vehicle player || call {if(isNil {(_this select 0) getVariable "BDKS_ShowBulletCamToPlayer"})then{false}else{(_this select 0) getVariable "BDKS_ShowBulletCamToPlayer"}})then{

// Add more weapons here
_list = ["M40A3","m107","M24","M4SPR","SVD","SVD_CAMO","ksvk","DMR","huntingrifle","SMAW","Javelin","SidewinderLaucher_F35","BombLauncherF35"];
if(!isNil "BDKS_BulletCamList")then{_list = BDKS_BulletCamList};

_type = getText (configFile >> "CfgAmmo" >> (_this select 4) >> "simulation");
_relPos = [0,-13,0.05];
_fov = 0.05;
if(!isNil "BDKS_BulletCamFOV")then{_fov = BDKS_BulletCamFOV};
if(_type == "shotMissile" || _type == "shotRocket")then{_relPos = [0,-13,2.2]; _fov = 0.5};

_disablePP = false;
if(call {if(isNil "BDKS_BulletCamNoBlur")then{false}else{BDKS_DisableBulletCam}})then{_disablePP = true};

_accTime = 0.5;
if(!isNil "BDKS_BulletCamAccTime")then{_accTime = BDKS_BulletCamAccTime};

_enableParticles = true;
if(call {if(isNil "BDKS_BulletCamNoParticleFX")then{false}else{BDKS_BulletCamNoParticleFX}})then{_enableParticles = false};

if((_this select 2) in _list && !(isNull _projectile))then{
setAccTime _accTime;
_camera = "camera" camCreate (getPos _projectile);
_camera cameraEffect ["INTERNAL","BACK"];
showCinemaBorder false;
cutText ["","BLACK IN",0.2];
_cancel = false;

if(_enableParticles && _type == "ShotBullet")then{
	_pShape = ["\ca\Data\ParticleEffects\Universal\Universal.p3d", 16, 13, 3, 0];
	_pSize = [0.01,0.05];
	_pColor = [[1,1,1,0.08],[1,1,1,0.16],[1,1,1,0.03],[1,1,1,0]];

	_pSource = "#particlesource" createVehicleLocal (getPos _projectile);
	_pSource attachTo [_projectile,[0,0,0]];
	_pSource setParticleParams [_pShape,"","Billboard",1,0.3,[0,0,0],[0,0,0],0,1,0.79,0.18,_pSize,_pColor,[1000],100,0.01,"","",_projectile,360];
	_pSource setDropInterval 0.001;
};

while{alive _projectile && alive _camera && !_cancel}do{
	_camera camSetTarget _projectile;
	_camera camSetRelPos _relPos;
	_camera camSetFOV _fov;
	_camera camSetFocus [600,2];
	_camera camCommit 0;

	"RadialBlur" ppEffectAdjust [0.02,0.02,0.1,0.1];
	"RadialBlur" ppEffectCommit 0.01;
	if(!_disablePP)then{"RadialBlur" ppEffectEnable true};

	if(inputAction "optics" != 0)then{_cancel = true};

	sleep 0.001;
};
if(alive _camera && !_cancel)then{
	_camera camSetFocus [-(_relPos select 1),1];
	_camera camSetFOV (_fov * 1.6);
	_camera camCommit 1.5;

	"RadialBlur" ppEffectAdjust [0,0,1,1];
	"RadialBlur" ppEffectCommit 0.7;

	sleep 1.39;
};
cutText ["","BLACK OUT",0.1];
sleep 0.11;
setAccTime 1;
"RadialBlur" ppEffectEnable false;
_camera cameraEffect ["TERMINATE","BACK"];
camDestroy _camera;
if(_enableParticles)then{deleteVehicle _pSource};
cutText ["","BLACK IN",0.6];
};

};

};

Share this post


Link to post
Share on other sites

Need help, i want to use this script together with "targetrange" mod -->http://www.armaholic.com/page.php?id=6505

The "targetrange" mod is installed and working. How do I use your script together with the mod so I can see where my bullets are flying to.

I made a file "cam.sqf" where i pasted your script into and put it in the "targetrange mod" folder, what then???

P.S. "targetrange mod" is not put in missions dir like other missions, its to be used in editor; so you put it in ex. C:\Users\name\Documents\ArmA 2\missions

Thanks in advance

Edited by KrUEgER

Share this post


Link to post
Share on other sites

You can just paste this in the player's init:

this addEventHandler ["fired",{_this execVM "cam.sqf"}]

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×