Jump to content
Sign in to follow this  
sabot10.5mm

bullet cam script. terminate on mouse click? how?

Recommended Posts

this script by killzonekid is great and all, but it waits for the bullet to be null which can take forever if you miss your intended target. my question is how can i speed up the wait time so its not so long, like maybe a max flight timer or quit on mouse click

player addEventHandler ["Fired", {
if (!(player getVariable ["BulletCam", false])) exitWith {};
    _null = _this spawn {
        _missile = _this select 6;
        _cam = "camera" camCreate (position player);
        _cam cameraEffect ["External", "Back"];
        waitUntil {
            if (isNull _missile) exitWith {true};
            _cam camSetTarget _missile;
            _cam camSetRelPos [0,-3,0];
            _cam camCommit 0;
        };
        sleep 0.4;      
        _cam cameraEffect ["Terminate", "Back"];
        camDestroy _cam;
    };
}];

 

Share this post


Link to post
Share on other sites

You mentioned your max target range is at 2400m. Find the speed of the bullet, find the time past in the mission, find the time to travel x distance.

 

Time  = (Distance/Speed)

 

Then add the time it will take the bullet to the time past on the mission.

 

Example: For a bullet that has a speed of 800 the time to travel would be 3 sec. 3  = (2400/800)

 

So, you can take it from here. I would add .25 seconds to the time so you can see the miss. Ideally, if you can find the distance to the target you are aiming at, it would be perfect. I will see it I can dig up how to do that later.  Also, I made the adjustment for the sniper rifles too (example lynx).

//time must have started
waitUntil {time > 0};

//credits:KillZoneKId
player addEventHandler ["Fired", {
    _null = _this spawn {
        _missile = _this select 6;
        _cam = "camera" camCreate (position player); 
        _cam cameraEffect ["External", "Back"];

	//get speed, credits:sarogahtyp
	_init_speed_gun = getNumber(configfile >> "CfgWeapons" >> (currentWeapon player) >> "initSpeed");
	_init_speed_mag = getNumber(configfile >> "CfgMagazines" >> (currentMagazine player) >> "initSpeed");

	if((_init_speed_gun) == 0) then
	{
 	_init_speed_gun = _init_speed_mag;
	};
	
	//your max target is 2400m 
	 _t = round (2400 /_init_speed_gun );
	//get the time from the start of mission + the time to travel
	_maxtime = time + _t; 
        hint format ["Start time: %1\nEnd time: %2\n Bullet speed: %3",  time,_maxtime,_init_speed_gun];
        
        //add the time condition to the waituntil
        waitUntil {
            if (isNull _missile || time > _maxtime) exitWith {true};
            _cam camSetTarget _missile;
            _cam camSetRelPos [0,-3,0];
            _cam camCommit 0;
        };
        sleep 0.4;      
        _cam cameraEffect ["Terminate", "Back"];
        camDestroy _cam;
    };
}];

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  

×