Jump to content
Sign in to follow this  
Big Dawg KS

Improved Bullet Cam Script

Recommended Posts

Apparently this random code I wrote up one day for ArmA without testing became quite popular, so I've given it an update for ArmA2.

Update: I made a small fix to give rockets same camera properties as missiles.

Improvements over original:

Added radial blur post processing effects

Added decreased camera FOV (increased zoom)

Different camera relPos & FOV for bullets and missiles (camera angle is higher on missiles so you can see above smoke trail)

Removed black borders

Added ability to disable the script with a global variable

Implemented a fix from Maddmatt (that he made to the original)

Known Problems:

Can't exit bullet cam until round hits something or self-destructs (so don't fire it into the air unless you're prepared for a lengthy wait)

Read comments for more info, otherwise it's pretty self-explanitory.

Show spoiler for code.

// Bullet Cam Script
// cam.sqf
// Big Dawg KS
// 7/9/09
//
// Call via Fired EH, ex:
// this addEventHandler ["fired",{_this execVM "cam.sqf"}]
//
// To add supported weapons, add MUZZLE classnames to _list (note: classnames are CASE SENSITIVE)
//
// To disable, set BDKS_DisableBulletCam = true

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

_projectile = nearestObject [_this select 0,_this select 4];
_list = ["M40A3","m107","M24","M4SPR","SVD","SVD_CAMO","ksvk","SMAW","Javelin","M1014","DMR","SidewinderLaucher_F35","BombLauncherF35"];
_type = getText (configFile >> "CfgAmmo" >> (_this select 4) >> "simulation");
_relPos = [0,-13,0.05];
_fov = 0.05;
if(_type == "shotMissile" || _type == "shotRocket")then{_relPos = [0,-13,2.2]; _fov = 0.5};
if((_this select 2) in _list)then{
setAccTime 0.5;
_camera = "camera" camCreate (getPos _projectile);
_camera cameraEffect ["INTERNAL","BACK"];
showCinemaBorder false;
while{alive _projectile && alive _camera}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;
	"RadialBlur" ppEffectEnable true;
	sleep 0.001;
};
if(alive _camera)then{
	_camera camSetFocus [50,1];
	_camera camSetFOV (_fov * 1.6);
	_camera camCommit 1.5;
	"RadialBlur" ppEffectAdjust [0,0,1,1];
	"RadialBlur" ppEffectCommit 0.7;
	sleep 1.5;
};
_camera cameraEffect ["TERMINATE","BACK"];
camDestroy _camera;
setAccTime 1;
"RadialBlur" ppEffectEnable false;
};

};

I used muzzle classnames to determine which weapons bullet cam should activate on. If you want to find muzzle names of weapons to add them to the list, here are a few hints. First, if the weapon only has one muzzle (like most weapons), it's usually the same as the weapon classname. Otherwise, to find it try adding this eventhandler to the player and firing:

player addEventHandler ["fired",{hint format ["Muzzle Classname: %1",_this select 2]}]

Also, please note that the muzzle classnames you put in the list are case sensitive, so they must appear exactly as they do in the weapon's config.

Download link (rapidshare) for file:

cam.sqf @ rapidshare.com

Edited by Big Dawg KS

Share this post


Link to post
Share on other sites

Great job! I'll test it!

Update:

Missing the CZ550 and Mk12SPR. (don't know the exact spelling). I'll update more with a review later.

---------- Post added at 06:53 AM ---------- Previous post was at 05:50 AM ----------

Ok, I did a quick test, let me start by asking if you could explain the code as to what does what?

Remarks/Improvement notes:

- Bullet sometimes bounces when hitting the ground at a certain angle

- Close up is alittle too close, camera should be removed back

- Option with and without Blur

Positive notes:

- Better feeling of immersion

- Really useful for learning how to aim correctly on moving targets

- plain awesomeness when you hit your target from 1500 meters away and see the impact :-)

---------- Post added at 06:59 AM ---------- Previous post was at 06:53 AM ----------

Dawg, could you alter the script so it shows the bullet with a short trace as in this movie:

Edited by p75

Share this post


Link to post
Share on other sites
- Bullet sometimes bounces when hitting the ground at a certain angle
ArmA does that, not the script. And yes, it's meant to be that way.

Nice script Dawg.

Just a few suggestions from the bulletcam-code I've done so far.

Check either the distance from bullet to player or have a timeout, to avoid those extremely long shots. Or maybe we should add an simple option to cancel it in the first place. ;)

An drop-particleeffect is a good thing for regular bullets, so they become visible.

The one p75 posted in that video looks neat, mine is not as pretty right now. (more like a glowing dot, but thats because i want to see the exact position of the bullet, not a stream)

Another gimmick would be to check if the game is in single or multiplayer and use setAcctime if it's singleplayer.

Share this post


Link to post
Share on other sites
ArmA does that, not the script. And yes, it's meant to be that way.

Nice script Dawg.

Just a few suggestions from the bulletcam-code I've done so far.

Check either the distance from bullet to player or have a timeout, to avoid those extremely long shots. Or maybe we should add an simple option to cancel it in the first place. ;)

An drop-particleeffect is a good thing for regular bullets, so they become visible.

The one p75 posted in that video looks neat, mine is not as pretty right now. (more like a glowing dot, but thats because i want to see the exact position of the bullet, not a stream)

Another gimmick would be to check if the game is in single or multiplayer and use setAcctime if it's singleplayer.

Thanks for your input, Tajin, yes, that movie shows great promise, it shows the actual bullet, I hope Dawg can make it the same.

I would be interested in how these scripts are working so I can help tuning them for community use.

Cheers

Share this post


Link to post
Share on other sites

Very Cool Dawg. Makes for great sniper missions.

I cant test this so ill ask. If you play MP coop would the spotter see the bullet cam too if it was a player?

Share this post


Link to post
Share on other sites
If you play MP coop would the spotter see the bullet cam too if it was a player?

No. The way it, is the bulletcam only activates for the person firing.

Although it would be possible to change that.

Share this post


Link to post
Share on other sites
Check either the distance from bullet to player or have a timeout, to avoid those extremely long shots. Or maybe we should add an simple option to cancel it in the first place.

What I wanted to do is let the player cancel it, but have yet to decide on a way to implement this (partly because most user input is disabled while the camera is on).

I was thinking about adding a particle effect, but these things take some time to do (at least for people like me who want them to be perfect), so it will come at a later time.

Missing the CZ550 and Mk12SPR

You can add the hunting rifle yourself (ya I forgot about it, and it's my favorite rifle too, doh), but the SPR (classname is M4SPR) is already in there. Will add CZ550 in next release.

Another gimmick would be to check if the game is in single or multiplayer and use setAcctime if it's singleplayer.

I wasn't really considering MP when I wrote it but it should still work (setAccTime will simply be ignored in MP), I'll just have to check locality of the firer/player. Problem is though that without slowing time down it's a bit too fast.

If you play MP coop would the spotter see the bullet cam too if it was a player?

I could implement this if people desire it, but I currently don't have anybody to help me do MP testing (any volunteers?).

- Close up is alittle too close, camera should be removed back

Since it's a script you can easily modify it to suit your needs. Just change the FOV value. I'll probably add a gobal variable to allow you to change it ingame though.

- Option with and without Blur

Right, I'll add more global variables to disable/configure stuff.

Share this post


Link to post
Share on other sites
What I wanted to do is let the player cancel it, but have yet to decide on a way to implement this (partly because most user input is disabled while the camera is on).

I was thinking about adding a particle effect, but these things take some time to do (at least for people like me who want them to be perfect), so it will come at a later time.

You can add the hunting rifle yourself (ya I forgot about it, and it's my favorite rifle too, doh), but the SPR (classname is M4SPR) is already in there. Will add CZ550 in next release.

I wasn't really considering MP when I wrote it but it should still work (setAccTime will simply be ignored in MP), I'll just have to check locality of the firer/player. Problem is though that without slowing time down it's a bit too fast.

I could implement this if people desire it, but I currently don't have anybody to help me do MP testing (any volunteers?).

Since it's a script you can easily modify it to suit your needs. Just change the FOV value. I'll probably add a gobal variable to allow you to change it ingame though.

Right, I'll add more global variables to disable/configure stuff.

Thanks mate,

the particle effect is the bullet, right? Dawg, where can I find the script commands as I'm all new to this. I'd like to get into it. PS: could you check your pm for the other question I had?

Is there any way to prevent the bouncing, I've tested some more, but it is quite irragular. Also, many time when I start a mission the first shot seems to be fired below the actual ground.

Awaiting your input, appreciating your effort, thanks!

Share this post


Link to post
Share on other sites
I wasn't really considering MP when I wrote it but it should still work (setAccTime will simply be ignored in MP), I'll just have to check locality of the firer/player. Problem is though that without slowing time down it's a bit too fast.

Even though setAccTime is ignored in MP you'll have to check it, because the "sleep" has to be changed when using setAccTime. *hmmm* oh simply scale the sleep commands using accTime.

sleep 5 * accTime

Oh it can be so easy sometimes, why didn't I think of this earlier ?

*wanders off to change some scripts*

Share this post


Link to post
Share on other sites

Nice script, Big Dawg KS. Thx a lot. Put it on our scripts section!

Share this post


Link to post
Share on other sites
Even though setAccTime is ignored in MP you'll have to check it, because the "sleep" has to be changed when using setAccTime. *hmmm* oh simply scale the sleep commands using accTime.

sleep 5 * accTime

Oh it can be so easy sometimes, why didn't I think of this earlier ?

*wanders off to change some scripts*

The sleeps don't need to be scaled for this IMO (only the sleep at the end would be noticably shorter).

Is there any way to prevent the bouncing, I've tested some more, but it is quite irragular.

I'm not sure there's any practical scripting solution to disabling ricochets, but if there were I'm not sure it's even something worth looking into.

Edited by Big Dawg KS

Share this post


Link to post
Share on other sites

Hmm right, just noticed you use camcommit 0 no need for scaled sleep then.

Mine uses a longer delay in the loop and a camcommit of the same length, which makes it very smooth without using a fast loop.

Like this:

while {(alive _shot) && (player distance _shot) < 1000} do {
bcam camSetRelPos [0,0,0];
bcam camSetTarget _shot;
bcam camCommit _delay * 1.01;
sleep _delay;
};

Share this post


Link to post
Share on other sites

When I tried using a delay for camCommit (synced with sleep delay) it was actually quite jerky when the round was traveling at slower speeds (lower speeds means less straight trajectory, ex. ricochets, or GBUs). Then again I didn't try making the delay longer. Either way it's already pretty smooth and this way it's more precise.

Edited by Big Dawg KS

Share this post


Link to post
Share on other sites

Download limit reached. Try dump.no.

Share this post


Link to post
Share on other sites

Put it on our scripts section at Assault Mission Studio

dlicon.gif

Improved Bullet Cam Script by Big Dawg KS

Share this post


Link to post
Share on other sites

Anyway to "slow" the bullet down? I mean. The camera is nice. However you see the bullet hit before the camera gets to the hit object.

Share this post


Link to post
Share on other sites
Anyway to "slow" the bullet down? I mean. The camera is nice. However you see the bullet hit before the camera gets to the hit object.

Dawg said he would have a look at it, the "particle part", .......but he is a perfectionist and said it will take some time.

Dawg are you able to do it?

Share this post


Link to post
Share on other sites

Dawg, I receive alot of below sea shots on Cheranus (or whatever it is called). Utes is working correctly. Any idea how to fix this?

Need to add that this is with the CHEYTACsniper addon, added as "CHEYTAC".

Edited by p75

Share this post


Link to post
Share on other sites

It happens when the script isn't able to locate the bullet you've fired. In general it works better on weapons with slower muzzlespeeds.

Maybe add an check, so that in this case the bulletcam simply won't activate.

Share this post


Link to post
Share on other sites
It happens when the script isn't able to locate the bullet you've fired. In general it works better on weapons with slower muzzlespeeds.

Maybe add an check, so that in this case the bulletcam simply won't activate.

Thanks, Tajin, could please suggest the line of code?

Grtz

Share this post


Link to post
Share on other sites

Tutorial == save the above text via any text editor, to a filename ending in .sqf (e.g. bulletcam.sqf)

place that file in the same directory as the saved mission file (i believe these are always called mission.sqm)

this is normally under /[your user profile]/missions/[missionname].[mapname]/

finally, in the init field of the player character put:

this addeventhandler ["fired",{_this execVM "bulletcam.sqf"}];

(with the name you have chosen in-place of 'bulletcam.sqf')

great script Big... but it is MASSIVELY unreliable with high powered rifles... like, it only works for about 1 in 6 shots... and given that pretty much the only use i can see for this script is for long range sniping... kinda ruins everything.

any chance you could work out a mod to allow it to catch the bullet better?... maybe displace the 'get' coordinates by a value along the muzzle bore, if its possible to get the muzzle velocity that will give that value, right?... otherwise, we can just enter it ourselves?

(i dont know arma scripting at all, but that seems fairly logical, right?)

---------- Post added at 15:20 ---------- Previous post was at 15:18 ----------

oh, and it seems to NEVER work for the first round... any way to force it to init without firing off a test round?

(im trying to setup a sniper mission where the player should in theory only fire one bullet... so... ya know 'eek' :/)

Share this post


Link to post
Share on other sites

oh, cool... i missed that

thanks :)

Edited by OOPz

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  

×