sttosin 67 Posted December 19, 2014 I found half of this code on a topic explaining Event handlers and started playing with it while adding a bit more. What I want is essentially a script that will zoom in and show enemy after the fatal shot hits as they fall down. I do not want this for every bullet or non fatal hits(So not using HitPart EH). The code currently includes the bullet camera because without it, it will complain about "No owner" in the RPT and "Generating ST on the fly is very slow" errors. I left that in at this point so you guys can at least test this and see the effect I was going for. Just Run it with a trigger. Any help is appreciated. See code: setDate [1943, 6, 25, 12, 30]; // [] spawn { while {true} do { { if (_x distance player >50 ) then { _x addeventhandler ["killed",{ hint format ["Kill Shot! \n%1 is K.I.A \nKill Distance: %2 meters \nTime of kill: %3/%4/%5 %6:%7",name (_this select 0),player distance (_this select 0),(date select 1),(date select 2),(date select 0),(date select 3),(date select 4)]; //hintSilent ["Hit!"]; _shooter = _this select 1; _victim = _this select 0; if (_shooter == _missile) then { //player removeEventHandler ["Fired",0]; //_TimeOfDeath = time; //_CameraTime = time+3; //hint format ["His name was %1", name (_this select 0)]; _null = _this spawn { _cam = "camera" camCreate (position _victim); _cam cameraEffect ["External", "Back"]; waitUntil { if (isNull _victim) exitWith {true}; _cam camSetTarget _victim; _cam camSetRelPos [0,-3,0]; _cam camCommit 0; }; sleep 1; //_cam cameraEffect ["Terminate", "Back"]; camDestroy _cam; //setAccTime 1; }; }; }]; }; } foreach allunits; sleep 1; //setAccTime 1; }; }; player addEventHandler ["Fired", { //setAccTime 1; _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 [2,-3,2]; _cam camCommit 0; }; sleep 2; _cam cameraEffect ["Terminate", "Back"]; camDestroy _cam; //setAccTime 1; }; }]; Share this post Link to post Share on other sites
cosmic10r 2331 Posted December 19, 2014 Hey buddy... sorry I've been so busy... will try to have a look this weekend Share this post Link to post Share on other sites
dreadedentity 278 Posted December 19, 2014 If you use a "killed" event handler, it will only activate when the unit it is assigned to dies. The problem with that is that there's no bullet to attach a camera to, however. Using a "fired" event handler like you have will work, but to me it seems like a lot of work because you're going to have to predict the bullet path and time. Just to be clear for everyone else, are you trying to do a sniper elite-esque bullet camera? This could be pretty difficult for the reason I explained above, but what you could try doing is using the "killed" event handler and then inside the code you have a "replay" kinda thing Share this post Link to post Share on other sites
sttosin 67 Posted December 19, 2014 Hey buddy... sorry I've been so busy... will try to have a look this weekend No worries CosmiC10R. Let me know what you find. Share this post Link to post Share on other sites
sttosin 67 Posted December 19, 2014 (edited) If you use a "killed" event handler, it will only activate when the unit it is assigned to dies. The problem with that is that there's no bullet to attach a camera to, however. Using a "fired" event handler like you have will work, but to me it seems like a lot of work because you're going to have to predict the bullet path and time.Just to be clear for everyone else, are you trying to do a sniper elite-esque bullet camera? This could be pretty difficult for the reason I explained above, but what you could try doing is using the "killed" event handler and then inside the code you have a "replay" kinda thing Not really a sniper type cam. More like how movies are shot where the camera shows the view through the scope but cuts to third person view of the enemy when he is hit. Sometimes showing multiple hits to the enemy as he goes down. So when the unit dies I don't attach to bullet, I attach to unit but it spams RPT with warnings, "unit....is dead". I also don't want bullet cam 100% of the time or even at all. Edited December 19, 2014 by sttosin Share this post Link to post Share on other sites
dreadedentity 278 Posted December 19, 2014 Not really a sniper type cam. More like how movies are shot where the camera shows the view through the scope but cuts to third person view of the enemy when he is hit. Sometimes showing multiple hits to the enemy as he goes down.So when the unit dies I don't attach to bullet, I attach to unit but it spams RPT with warnings, "unit....is dead". I also don't want bullet cam 100% of the time or even at all. Excellent, now that you've explained what you want, we can help Share this post Link to post Share on other sites
sttosin 67 Posted December 21, 2014 I can still use some help with this one guys. Share this post Link to post Share on other sites
groshnak 1 Posted December 21, 2014 You could setpos a game logic or such to the unit when the killed EH fires and then point the camera at the game logic? Share this post Link to post Share on other sites
Jigsor 176 Posted December 21, 2014 Try this. //init.sqf if (!isdedicated && hasInterface) then { [] spawn { waitUntil {!isNull player && player == player}; player addEventHandler ["killed", {handle = [(_this select 0),(_this select 1)] execVM "Killed.sqf"}]; }; }; // Killed.sqf // player addEventHandler ["killed", {handle = [(_this select 0),(_this select 1)] execVM "scripts\Killed.sqf"}]; // Generates deathcam/killercam _player = _this select 0; _killer = _this select 1; _rnumbArr = [-2,2]; _rnumb = _rnumbArr select (floor random (count _rnumbArr)); _pos = [(getPosAsl _player select 0) + _rnumb, (getPosAsl _player select 1) + _rnumb,(getPosAsl _player select 2) + 0.5]; _camera = "camera" camCreate _pos; waitUntil {preloadCamera _pos;}; _camera cameraEffect ["internal","back"]; _camera camSetFOV 1; // Look at player _camera camSetTarget vehicle _player; if(vehicle player != player) then {_camera camSetRelPos [0,10,1]}else{_camera camSetRelPos [0,2,1]}; _camera camCommit 0; waitUntil {camCommitted _camera}; _camera camCommand "inertia on"; sleep 2.0; if (not isNull vehicle _killer) then {// Look at killer _rnumbArr = [-5,5]; _rnumb = _rnumbArr select (floor random (count _rnumbArr)); _camera camSetTarget vehicle _killer; _camera camPreparePos [ getPosAtl vehicle _killer select 0, (getPosAtl vehicle _killer select 1) + _rnumb, (getPosAtl vehicle _killer select 2) + 1]; _camera camCommitPrepared 4; }else{// Look at player _camera camSetTarget vehicle _player; _camera camCommit 4; }; waitUntil {camCommitted _camera}; Sleep 3.0; titleCut["", "BLACK out",2]; _player cameraEffect ["terminate","back"]; camDestroy _camera; titleCut["", "BLACK in",1]; Share this post Link to post Share on other sites
sttosin 67 Posted December 21, 2014 Try this. Thanks Jigsor. Looks like you completely rewrote the code :) I still get the "no owner" when player kills opfor and nothing happens. It works a bit when player dies. No addons except cba_a3 RPT: 8:45:07 Starting mission: 8:45:07 Mission file: TestKillShot 8:45:07 Mission world: Stratis 8:45:07 Mission directory: C:\Users\Tosin\Documents\Arma 3 - Other Profiles\StTosin\missions\TestKillShot.Stratis\ 8:45:10 Attempt to override final function - bis_functions_list 8:45:10 Attempt to override final function - bis_functions_listpreinit 8:45:10 Attempt to override final function - bis_functions_listpostinit 8:45:10 Attempt to override final function - bis_functions_listrecompile 8:45:11 [79078,2547.02,0,"XEH: PreInit Started. v1.0.9.140907. MISSINIT: missionName=TestKillShot, worldName=Stratis, isMultiplayer=false, isServer=true, isDedicated=false"] 8:45:11 [79078,2547.11,0,"XEH: PreInit Finished. CACHE DISABLED? (Disable caching with cba_cache_disable.pbo): SLX_XEH_RECOMPILE=false, CBA_COMPILE_RECOMPILE=false, CBA_FUNC_RECOMPILE=false"] 8:45:11 Attempt to override final function - bis_fnc_missiontaskslocal 8:45:11 Attempt to override final function - bis_fnc_missionconversationslocal 8:45:11 Attempt to override final function - bis_fnc_missionflow 8:45:11 soldier[O_Soldier_SL_F]:Some of magazines weren't stored in soldier Vest or Uniform? 8:45:11 soldier[O_Soldier_TL_F]:Some of magazines weren't stored in soldier Vest or Uniform? 8:45:11 soldier[O_Soldier_AR_F]:Some of magazines weren't stored in soldier Vest or Uniform? 8:45:11 soldier[O_Soldier_AR_F]:Some of magazines weren't stored in soldier Vest or Uniform? 8:45:11 soldier[O_Soldier_LAT_F]:Some of magazines weren't stored in soldier Vest or Uniform? 8:45:11 soldier[O_Soldier_LAT_F]:Some of magazines weren't stored in soldier Vest or Uniform? 8:45:12 [79099,2548.2,0,"XEH: PostInit Started"] 8:45:12 [79099,2548.21,0,"CBA_VERSIONING: cba=1.0.9.140907, "] 8:45:12 [79099,2548.22,0,"XEH: PostInit Finished. State: _isClient=true, _isJip=false, _isDedClient=false, _isServer=true, _isDedServer=false, _playerCheckDone=true, _sp=true, _startInitDone=true, _postInitDone=true, _mpRespawn=false, _machineType=1, _sessionId=9, _level=0, _timeOut=false, _game=3, BIS_functions=L Modules:1, group=L Modules, player=B Alpha 1-1:1 (StTosin), _playerType=B_soldier_M_F", _playerGroup=B Alpha 1-1] 8:45:12 No owner 8:45:13 No owner 8:45:15 No owner 8:45:52 WARNING: Function 'name' - StTosin is dead 8:45:52 WARNING: Function 'name' - StTosin is dead Thanks for your help on this. Share this post Link to post Share on other sites
Jigsor 176 Posted December 21, 2014 With this code when player kill AI nothing should happen. This killed eventhandler I posted will not work on and should not be used on AI. Only the player would be viewing through cam the instant he is killed in my code. Did you want the player to switch to camera when he is shooting at/kills an AI? Not sure how you generated that error. Share this post Link to post Share on other sites
sttosin 67 Posted December 21, 2014 With this code when player kill AI nothing should happen. This killed eventhandler I posted will not work on and should not be used on AI. Only the player would be viewing through cam the instant he is killed in my code. Did you want the player to switch to camera when he is shooting at/kills an AI?Not sure how you generated that error. Ah OK. I need to better explain my goal. I don't want the camera on the player at all. I want the camera on the AI the player kills. Share this post Link to post Share on other sites
cosmic10r 2331 Posted December 23, 2014 I had a go at this the other day sttosin and I can get the cam to flip to a view of the player but not the victim... I'll keep trying it.. Share this post Link to post Share on other sites
sttosin 67 Posted December 23, 2014 I had a go at this the other day sttosin and I can get the cam to flip to a view of the player but not the victim... I'll keep trying it.. Thanks CosmiC10R. Share this post Link to post Share on other sites
sttosin 67 Posted December 28, 2014 (edited) UPDATE: I am getting closer to what I want. See the script below. [] spawn { while {true} do { { if (_x distance player >5 ) then { _x addeventhandler ["killed",{ //hint format ["Kill Shot! \n%1 is K.I.A \nKill Distance: %2 meters ",name (_this select 0),player distance (_this select 0)]; _shooter = _this select 1; _victim = _this select 0; if (_shooter == player) then { setAcctime 0.1; sleep 0.5; _veh = createVehicle ["Land_HelipadEmpty_F", getPos _victim vectorAdd [0,-3,1.2], [], 0, "CAN_COLLIDE"]; _cam = "camera" camCreate (getPos _veh); _veh cameraEffect ["External", "Back"]; waitUntil { if (isNull _victim) exitWith {true}; _cam camSetTarget getPos _veh; _cam camSetRelPos [0,0,0]; _cam camCommit 0; }; sleep 1; camDestroy _cam; setAcctime 1; }; }]; }; } foreach allunits; sleep 1; }; }; It actually works now but....throws a lot of RPT errors still. Also slow mo not working but check it out: and more: PS: I can still use some help. I am learning this way also but don't let that stop you from lending a hand. :) Edited December 28, 2014 by sttosin Share this post Link to post Share on other sites
sttosin 67 Posted December 28, 2014 CosmiC10R and Mikey74 came through on this one with the slow motion and getting rid of the errors in RPT. Testing the updated code and will share when satisfied. Thanks guys! Share this post Link to post Share on other sites
sttosin 67 Posted December 28, 2014 Stable version looking splendid: Also see video from CosmiC10R: Share this post Link to post Share on other sites