Jump to content
Sign in to follow this  
magnus28

create a custom script/trigger?

Recommended Posts

first of all I have next to no experience with .sqf or .sqs

Me and my mates play I44 CO mod,

and there is a plane (JU-87 "Stuka") That I want to add the Jericho Siren too.

The author of the plane was kind enough to provide me with the .pbo for another project I am working on (modelling) and I noticed that the sound file for the dive siren is already in there. I checked another config file and it was assigned a class name and such, but seems like it was never implemented.

I would like to create a custom script or trigger that would turn on the siren when the plane goes into a steep dive (60 degrees or more) and turn off when the dive breaks out past 60 degree angle.

I want something more than just an option to turn on in the mouse wheel, it should be triggered by the dive.

although I have inexperience with scripting, I would be willing to learn and research at least how to do this.. just looking for some suggestions to try or in what area I should be looking into...

If I had a more specific question to ask I would - this is not a "make this work post", i'm just clueless how to even begin this task.

ty in advance

Share this post


Link to post
Share on other sites

sorry if there is a better sub forum to post this in, I figured editing/scripting would be the appropriate place.

the vectordir doesn't seem relevant to what i am asking if it could be done.

I was thinking for now maybe something that could simulate a steep dive, and trigger the siren would be if two criteria are met:

for example,

-if throttle is set to zero + altitude decreases 100m then activate siren.

a dive bomber would apply the dive brakes to slow the decent, seeing on how Arma doesn't have dive brakes, setting the throttle to zero would slow the dive.

so essentially once those two parameters have been met, the siren would activate.

and of course once the two parameters were reversed, the siren would turn off.

again, I don't know scripting, but i'm thinking a code could be constructed to simulate this.

Share this post


Link to post
Share on other sites

There is a function for returning the pitch and bank of a vehicle

Just place this in the planes init and it will return the picth of the aircraft

null=[] spawn {while {true} do { pitchbank = plane call BIS_fnc_getPitchBank;  pitch     = pitchbank select 0;  bank      = pitchbank select 1;hint format ["%1",pitch];sleep 0.1}}

Share this post


Link to post
Share on other sites

this helps a bit, as the Ju-87 had an automated system that would recover the plane from a dive in case the pilot blacked out.

But it doesn't answer the question of adding a trigger in a dive that would activate the Jericho siren..

Share this post


Link to post
Share on other sites

Something like this maybe....the sound is broken into two parts... the dive and the pullout. Demo mission here!

This is not an ideal solution and there will be problems with the play length of the sounds.... but is here to give you some ideas. Because of the limitations of playing sound... I'm not sure if an ideal solution is possible!

The first sound plays in a dive of over 20 degrees and the second sound plays when the aircraft has been in a dive of >20 and is now <10 degrees.

Also instead of using playsound which is non-directional... you can use _plane say3D "sound".... which is directional.

For the description.ext (which you must create). The sounds are in a folder called sounds.

description.ext:-

//************************************************************
// === Sounds ===============================================>
//************************************************************

class CfgSounds
{
sounds[]= {stuka_01,stuka_02,nofear,topgun_s};

class stuka_01
{
	name = "stuka_01";
	sound[] = {\sounds\stuka_01.ogg, 1, 1.0};
	titles[] = {};
};

class stuka_02
{
	name = "stuka_02";
	sound[] = {\sounds\stuka_02.ogg, 1, 1.0};
	titles[] = {};
};

class nofear
{
	name = "nofear";
	sound[] = {\sounds\nofear.ogg, db-0, 1.0};
	titles[] = {};
};

class topgun_s
{
	name = "topgun_s";
	sound[] = {\sounds\topgun_s.ogg, db-6, 1.0};
	titles[] = {};
};
};

....and for the loop to monitor the planes inclination. Call with nul = [plane] execVM "siren.sqf";

siren.sqf:-

_plane = _this select 0;

_indive = false;

while {canmove _plane} do {

_pitchbank = _plane call BIS_fnc_getPitchBank;
_pitch = _pitchbank select 0;

hint format ["pitch: %1",_pitch];

if (_pitch < (-20) and not _indive) then {playsound "stuka_01";_indive = true};
if (_pitch >= (-10) and _indive) then {playsound "stuka_02";_indive = false};

sleep 1;

};

You can use Audacity to make your .oog sounds from .wavs! There's a couple extra sounds in the folder just for the hell of it!

Share this post


Link to post
Share on other sites

Hello Magnus,

if I understand your question correctly, then you want a way how to automatically observe the planes angles at all times. The answer to that was given above. You need to start a script (e.g. as soon as a aircraft is airborne) which is running in a loop and constantly checking the conditions to either turn on or turn off your sound. You could use a simple trigger object, place it on the map and name it checkSiren, for example. In the condition field, remove the "this" and replace it with your starting condition. For example *getPos myStuka select 2 > 100;* just as a simple starter now. So this will fire the trigger once your aircraft myStuka has reached 100 meters above ground. In the onAct field you have to start your control script sqf. From now on the loop is running and constantly checking the planes angles and, if required, turn on the sound.

Maybe this in combination with the above posts help you understand the mechanics ?

Good Luck !

Benbone

Share this post


Link to post
Share on other sites

Alternatively you could start the above siren script right int the init statement of the stuka unit or even in the init.sqf.

Greetings

Benbone

Share this post


Link to post
Share on other sites

twirly and ben ty so much. I'll have to consult my friend who is a scripting guru and get him to explain a few things to me.

What is the command that will monitor the angle of the plane? Can you show me the line in the script?

And also where did you get that Jericho siren sound? Youtube? I would like to contact the owner for permission to use/alter the file ;-)

thx again!

Share this post


Link to post
Share on other sites
What is the command that will monitor the angle of the plane?

Once you have the Functions Module on the map...these lines will return the dive angle (pitch) of the _plane.

_pitchbank = _plane call BIS_fnc_getPitchBank;
_pitch = _pitchbank select 0;

_pitchbank will be an array containing two things... pitch and bank... like this... [pitch, bank]

You then need to select the first element of the array to get _pitch... so... _pitch = _pitchbank select 0

And also where did you get that Jericho siren sound? Youtube?

Yes downloaded a video from YouTube.

Used flv2avi to convert to an .avi

Used VirtualDub to extract the sound to a .wav

Used Audacity to manipulate the .wav.... in this case split in into two parts... and make the .oogs.

I wouldn't worry too much about asking permission to use the sound from an old archive video on YouTube....it's probably public record and in the public domain anyway.

Hope that helps.

Edited by twirly

Share this post


Link to post
Share on other sites

outstanding twirly, really appreciate it.

if I have any more questions i'll ask ;)

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  

×