Jump to content
Sign in to follow this  
kadinx

Sqs to sqf

Recommended Posts

Hello Gentlemen

I am slowly making the turn to sqf format but I have been procrastinating as much as I can due to "internal" resistance to new stuff!!

Finally, one of my favorite sqs script needs to be converted because of timing issues. It needs to be checked much more frequently and I have read that the way to go is to convert it to sqf format.

I have learned how to pre process and execute them but I still very perplexed on how to convert one.

I am not quite sure if I should post this here but after about a week of failed attempts, I think I need help. Even if just to point me in the right direction.

So the script is as follows:

---------------------------------------------

;check if the mission ended

?(forceGameOver):exit

[] exec "music.sqs"

_player = _this select 0

_killer = _this select 1

_camera = "camera" camCreate getPos _player

_camera cameraEffect ["internal","back"]

showcinemaborder False

titleText ["You have been killed!!","Plain"];titleFadeOut 5

;===

_camera camSetTarget _player

_camera camSetRelPos [1.00,-1.00,0.00]

_camera camSetFOV 0.700

_camera camCommit 0

@camCommitted _camera

? (_killer != _killer or _killer == _player) : goto "suicide"

;===

_camera camSetTarget _killer

_camera camSetRelPos [2.00,2.00,2.00]

_camera camSetFOV 1.000

_camera camCommit 5

@camCommitted _camera

;===

_camera camSetTarget _player

_camera camSetRelPos [-15.00,15.00,10.00]

_camera camSetFOV 1.000

_camera camCommit 4

@camCommitted _camera

goto "exit"

#suicide

;===

_camera camSetTarget _player

_camera camSetRelPos [4.00,-4.00,4.00]

_camera camSetFOV 1.000

_camera camCommit 3

@camCommitted _camera

;=========

_camera camSetTarget _player

_camera camSetRelPos [-15.00,15.00,10.00]

_camera camSetFOV 1.000

_camera camCommit 6

@camCommitted _camera

goto "exit"

#exit

;check if the mission ended

?(forceGameOver):exit

TitleText ["Death Penalty: 2 points!","BLACK OUT",5];titleFadeOut 1

~6

player cameraEffect ["terminate","back"]

camDestroy _camera

exit

--------------------------------------------------------------

Any help would be greatly appreciated. :o

regards

Share this post


Link to post
Share on other sites

This is good stuff. I got to learn to be more patient with my searches. Right in front of me :(

My apologies!

Many thanks kju.

Share this post


Link to post
Share on other sites

Hi :)

this is only one (sqf) example for your script:

private ["_player","_killer","_camera"];

{_x = objNull} foreach [_player,_killer,_camera];

if(!(forceGameOver)) then
{
[] exec "music.sqs";

_player = _this select 0;
_killer = _this select 1;
_camera = "camera" camCreate getPos _player;
_camera cameraEffect ["internal","back"];
showcinemaborder False;
titleText ["You have been killed!!","Plain"];titleFadeOut 5;

_camera camSetTarget _player;
_camera camSetRelPos [1.00,-1.00,0.00];
_camera camSetFOV 0.700;
_camera camCommit 0;
waituntil{camCommitted _camera};

if((_killer != _killer) || (_killer == _player)) then
{
	_camera camSetTarget _player;
	_camera camSetRelPos [4.00,-4.00,4.00];
	_camera camSetFOV 1.000;
	_camera camCommit 3;
	waituntil{camCommitted _camera};

	_camera camSetTarget _player;
	_camera camSetRelPos [-15.00,15.00,10.00];
	_camera camSetFOV 1.000;
	_camera camCommit 6;
	waituntil{camCommitted _camera};
}
else
{
	_camera camSetTarget _killer;
	_camera camSetRelPos [2.00,2.00,2.00];
	_camera camSetFOV 1.000;
	_camera camCommit 5;
	waituntil{camCommitted _camera};

	_camera camSetTarget _player;
	_camera camSetRelPos [-15.00,15.00,10.00];
	_camera camSetFOV 1.000;
	_camera camCommit 4;
	waituntil{camCommitted _camera};
};
if(!(forceGameOver)) then
{
	TitleText ["Death Penalty: 2 points!","BLACK OUT",5];titleFadeOut 1;
	sleep 6;
	player cameraEffect ["terminate","back"];
	camDestroy _camera;
};
};

Greeting

Silola

Share this post


Link to post
Share on other sites

Silola

Many thanks for you script I am going to try it right now.

Since the last post from kju I have managed another working version:

----------------------------------------------------------

//execute only on humans and game has not ended?

If (!(isServer) || !(isNull player) ||!(forceGameover) || (gameStarted)) then { call deathview;};

deathview={

private ["_player","_killer","_camera"];

_player=_this select 0;

_killer=_this select 1;

_camera="camera" camCreate getpos _player;

_camera cameraEffect ["internal","back"];

showcinemaborder False;

titleText ["You have been killed!!","Plain"];titleFadeOut 5;

0 fademusic 1;

_music = ["aa_crescendo_i","aa_death_01_south","aa_death_02_south","aa_death_10_north","aa_death_03_south","aa_death_06_rocktheme_iii","aa_death_07_rocktheme_iii"];

_final=_music call RandomSelect;

playMusic _final;

_camera camSetTarget _player;

_camera camSetRelPos [1.00,-1.00,0.00];

_camera camSetFOV 0.700;

_camera camCommit 0;

waitUntil {camCommitted _camera};

if (_killer != _killer || _killer == _player) then

{

_camera camSetTarget _player;

_camera camSetRelPos [4.00,-4.00,4.00];

_camera camSetFOV 1.000;

_camera camCommit 3;

waitUntil {camCommitted _camera};

_camera camSetTarget _player;

_camera camSetRelPos [-15.00,15.00,10.00];

_camera camSetFOV 1.000;

_camera camCommit 6;

waitUntil {camCommitted _camera};

}

else

{

_camera camSetTarget _killer;

_camera camSetRelPos [2.00,2.00,2.00];

_camera camSetFOV 1.000;

_camera camCommit 5;

waitUntil {camCommitted _camera};

_camera camSetTarget _player;

_camera camSetRelPos [-15.00,15.00,10.00];

_camera camSetFOV 1.000;

_camera camCommit 4;

waitUntil {camCommitted _camera};

};

TitleText ["Death Penalty: 2 points!","BLACK OUT",5];titleFadeOut 1;

sleep 6;

player cameraEffect ["terminate","back"];

camDestroy _camera;

};

-----------------------------------------------------

Since I was at it I incorporated the music.sqs script and another parameter for the script not to kick in when an intro is still running.

I am going to try your version and learn some more.

Thank you very much.

Share this post


Link to post
Share on other sites

Silola

After further testing, your version is better. I am adding the new consolidation changes, the startup parameter and one for the script not to run on a dedicated server and KEEPING IT :yay:.

>-------thank you-------<

Share this post


Link to post
Share on other sites

Hi,

Can anyone tell me what to put in the music.sqs mentioned above? I have no idea what code to put in it in order to play my custom track on player death.

Also, should the .sqf above be called onPlayerKilled.sqf?

Share this post


Link to post
Share on other sites

The name of the sqf could be anything you like but you need to call it somehow. I have added this line in the init.sqf

player addEventHandler ["KILLED",{_this execVM "onplayerDeath.sqf"}];

you can place this code in the music.sqs:

_music = ["aa_crescendo_i","aa_death_01_south","aa_death_02_ south","aa_death_10_north","aa_death_03_south","aa _death_06_rocktheme_iii","aa_death_07_rocktheme_ii i"]

_final=_music call bis_fnc_selectrandom

playMusic _final

When this script is executed, it will play a random ogg file from the list. All these .ogg files have to be registered properly in your description.ext file and physically exist in a subfolder (named with lower case characters) in your mission file.

Edited by KadinX

Share this post


Link to post
Share on other sites

Ahh ok, thanks for your help!

I ended up finding and extracting the onplayerkilled.sqf from the CA.pbo as I was having some issues with the code above. This below works great coz I can get rid of the nasty red effect as well... only thing is when I change the 'playmusic' to reflect my track which is in a music folder I don't hear the track when I die, I strangle only hear it when I switch to the next playable unit. :confused: Do I still need the music.sqs? I have it listed in the description.ext

/*
File: onPlayerKilled.sqf
Author: Karel Moricky

Description:
You were killed!
*/

_player = _this select 0;
_killer = _this select 1;
if (isnull _killer) then {_killer = _player};

_soundVolume = soundvolume;
_musicvolume = musicvolume;	

_teamswitchcheck = {
_player = _this select 0;
_ppeffects = _this select 1;
_soundvolume = _this select 2;
_musicvolume = _this select 3;

//waituntil {_player != player};
waituntil {alive player};
setacctime 1;
terminate _ppeffects;
"dynamicBlur" ppEffectEnable false;
"colorCorrections" ppEffectEnable false;
0 fadesound _soundvolume;
0 fademusic _musicvolume;
};

//--- Initial postprocess effects
_ppeffects = _player spawn {
_player = _this;

//--- Light blur
"dynamicBlur" ppEffectEnable false;
"dynamicBlur" ppEffectAdjust [2];
"dynamicBlur" ppEffectCommit 0.1;  

//--- Full red
"colorCorrections" ppEffectAdjust [1, 1, 0, [0.1, 0.0, 0.0, 1], [1.0, 0.5, 0.5, 0.1], [0.199, 0.587, 0.114, 0.0]];
"colorCorrections" ppEffectCommit 0.1;
"colorCorrections" ppEffectEnable false;
sleep 0.1;

//--- Partly red
"colorCorrections" ppEffectAdjust [1, 1, 0, [0.1, 0.0, 0.0, 0.5], [1.0, 0.5, 0.5, 0.1], [0.199, 0.587, 0.114, 0.0]];
"colorCorrections" ppEffectCommit 0.3;

//--- Dialog
sleep 0.3;
enableenddialog;
_soundVolume = soundvolume;
_musicvolume = musicvolume;	
3 fadesound 0;
0 fademusic 0;
playmusic "mysong";
waituntil {velocity vehicle _player distance [0,0,0] == 0};

//--- Total blur
"dynamicBlur" ppEffectAdjust [10];
"dynamicBlur" ppEffectCommit 5;
sleep 3;

//--- Total red
"colorCorrections" ppEffectAdjust [1, 1, 0, [0.1, 0.0, 0.0, 1], [1.0, 0.5, 0.5, 0.1], [0.199, 0.587, 0.114, 0.0]];
"colorCorrections" ppEffectCommit 2;
sleep 4;
};

//--- Team switch check
_check = [_player,_ppeffects,_soundvolume,_musicvolume] spawn _teamswitchcheck;
waituntil {scriptdone _ppeffects || _player != player};
if (_player != player) exitwith {};
terminate _check;

//--- Pulsing effects
_ppeffects = _player spawn {
while {true} do {
	_delay = (2 + random 1) * acctime;
	"colorCorrections" ppEffectAdjust [1, 1, 0, [0.1, 0.0, 0.0, 0.7], [1.0, 0.5, 0.5, 0.1], [0.199, 0.587, 0.114, 0.0]];
	"colorCorrections" ppEffectCommit _delay;
	"dynamicBlur" ppEffectAdjust [.5];
	"dynamicBlur" ppEffectCommit _delay;  
	sleep _delay;

	_delay = (2 + random 1) * acctime;
	"colorCorrections" ppEffectAdjust [1, 1, 0, [0.1, 0.0, 0.0, 0.3], [1.0, 0.5, 0.5, 0.1], [0.199, 0.587, 0.114, 0.0]];
	"colorCorrections" ppEffectCommit _delay;
	"dynamicBlur" ppEffectAdjust [4];
	"dynamicBlur" ppEffectCommit _delay;   
	sleep _delay;
};
};
_check = [_player,_ppeffects,_soundvolume,_musicvolume] spawn _teamswitchcheck;


//--- Break if killer is alive - show his internal view
if (alive _killer && (_player distance _killer < 150) && random 1 > 0.5) then {
_killer switchcamera "internal";
setacctime 0.5;

//--- Killer is dead or time expired
_sleep = [] spawn {sleep (30 + random 30)};
waituntil {!alive _killer || scriptdone _sleep};
setacctime 1;
_killer = _player;

//--- Light blur
"dynamicBlur" ppEffectEnable true;
"dynamicBlur" ppEffectAdjust [2];
"dynamicBlur" ppEffectCommit 0.1;  

//--- Full red
"colorCorrections" ppEffectAdjust [1, 1, 0, [0.1, 0.0, 0.0, 1], [1.0, 0.5, 0.5, 0.1], [0.199, 0.587, 0.114, 0.0]];
"colorCorrections" ppEffectCommit 0.1;
"colorCorrections" ppEffectEnable false;
sleep 0.1;
};

//--- Random constants for player
_pos = position vehicle _player;
_flying = if ((_pos select 2) > 50) then {true} else {false};
_size = sizeof typeof vehicle _player;
_dir = random 360;
_dx = sin _dir * _size;
_dy = cos _dir * _size;
_dz = if (_flying) then {_size * 2} else {_size};

//--- Random constants for killer
_ksize = sizeof typeof vehicle _killer;
_kdir = random 360;
_kdx = sin _dir * _size;
_kdy = cos _dir * _size;
_kdz = _size;

//--- Create camera
_camera = "camera" camcreate position vehicle _player;
_camera cameraeffect ["internal","back"];
showcinemaborder false;
_camera campreparetarget _pos;
_camera campreparepos [(_pos select 0) + _dx,(_pos select 1) + _dy,(_pos select 2) + _dz];
_camera campreparefov 0.7;
_camera camcommitprepared 0;

//--- Track player
while {velocity vehicle _player distance [0,0,0] > 0 || _flying} do {
_pos = position vehicle _player;

if (!_flying || (_flying && (position vehicle _player select 2) > 50)) then {
	_camera campreparepos [(_pos select 0) + _dx,(_pos select 1) + _dy,(_pos select 2) + _dz];
};
_camera campreparetarget _pos;
_camera camcommitprepared 0;
sleep 0.01;
};

//--- Zoom out from player
_delay = 5 + random 5;
_distancecoef = 1.2;
if (_player == _killer) then {_delay = 100 + random 100; _distancecoef = 5 + random 3};
_pos = position vehicle _player;
_camera campreparepos [(_pos select 0) + _dx * _distancecoef,(_pos select 1) + _dy * _distancecoef,(_pos select 2) + _dz * _distancecoef];
_camera camcommitprepared _delay;
waituntil {camcommitted _camera};

if (_player == _killer) exitwith {};

//--- Show killer
_pos = position vehicle _killer;
_camera campreparetarget vehicle _killer;
_camera campreparepos [(_pos select 0) + _kdx,(_pos select 1) + _kdy,(_pos select 2) + _kdz];
_camera camcommitprepared (5 + random 5);
waituntil {camcommitted _camera};

while {true} do {
_pos = position vehicle _killer;
_camera campreparepos [(_pos select 0) + _kdx,(_pos select 1) + _kdy,(_pos select 2) + _kdz];
_camera campreparetarget _pos;
_camera camcommitprepared 0;
sleep 0.01;
};

Edited by 11_HARLEY_11

Share this post


Link to post
Share on other sites

I am not familiar with the function of this sqf but your are looking for the following command

# fademusic 1

#=number of seconds to put up or bring down the volume

fademusic=command that alters the music sound

1=Full volume

0=No volume

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  

×