Jump to content
Sign in to follow this  
LtShadow

Help with Sonic Boom script?

Recommended Posts

Moderators, this is not a double post, nor cross post. I am simply moving this topic to this area due to another member advising me asking for help here!

Hello!

I am trying to get a 'Sonic Boom' to play when a plane I am working on hits a certain (called for) speed. I have already tried lots of methods that have gotten me somewhere, but not to the working point.

Please have a look at these codes;

Common_Init

Code:

_plane = _this select 0

#Skip
[_plane] execVM "\mig29\scr\AircraftEffects.sqf"
[_plane] execVM "\mig29\scr\AircraftBoom.sqf"
exit

AircraftBoom.sqf

Code:

//SonicBoom script by LtShadow
//Do not re-distribute unless you ask permission!
//

_veh = _this select 0;		//the vehicle
_spd = 500 select 0;		//the speed at which the sonic boom occurs
_boomed = false;


class CfgSounds
{
sounds[]= {sonicboom};

class sonicboom
{
	name = "sonicboom";
	sound[] = {\mig29\tornado_gr4boom.wss, 200, 1.1,};
	titles[] = {};
};
};


while {alive _veh} do {

_vel = velocity _veh;

_speed = 3.6*sqrt((_vel select 0)^2 + (_vel select 1)^2 + (_vel select 2)^2);

hint format ["Speed: %1",_speed];

if (_speed > _spd and not _boomed) then {

	_veh say3D "sonicboom";

	_boomed = true;

};

sleep 0.5;

};

ArmA 2 script I am trying to base this off of;

Code:

/*

*/


_veh = _this select 0;		//the vehicle
_spd = _this select 1;		//the speed at which the sonic boom occurs

_boomed = false;

while {alive _veh} do {

_vel = velocity _veh;

_speed = 3.6*sqrt((_vel select 0)^2 + (_vel select 1)^2 + (_vel select 2)^2);

hint format ["Speed: %1",_speed];

if (_speed > _spd and not _boomed) then {

	_veh say3D "sonicboom";

	_boomed = true;

};

sleep 1;

};

Init line of unit in mission (arma 2)

nul = [this,70] execVM "monitor.sqf";

Monitor.sqf is the 'SonicBoom' script I had put above this.

ArmA 3 .RPT file errors;

Code:

Error in expression <00 select 0;		
_boomed = false;


class CfgSounds
{
sounds[]= {sonicboom};

clas>
 Error position: <CfgSounds
{
sounds[]= {sonicboom};

clas>
 Error Missing ;
File mig29\scr\AircraftBoom.sqf, line 11
Error in expression <00 select 0;		
_boomed = false;


class CfgSounds
{
sounds[]= {sonicboom};

clas>
 Error position: <CfgSounds
{
sounds[]= {sonicboom};

clas>
 Error Missing ;
File mig29\scr\AircraftBoom.sqf, line 11
Error in expression <00 select 0;		
_boomed = false;


class CfgSounds
{
sounds[]= {sonicboom};

clas>
 Error position: <CfgSounds
{
sounds[]= {sonicboom};

clas>
 Error Missing ;
File mig29\scr\AircraftBoom.sqf, line 11
Error in expression <00 select 0;		
_boomed = false;


class CfgSounds
{
sounds[]= {sonicboom};

clas>
 Error position: <CfgSounds
{
sounds[]= {sonicboom};

clas>
 Error Missing ;
File mig29\scr\AircraftBoom.sqf, line 11
Error in expression <00 select 0;		
_boomed = false;


class CfgSounds
{
sounds[]= {sonicboom};

clas>
 Error position: <CfgSounds
{
sounds[]= {sonicboom};

clas>
 Error Missing ;
File mig29\scr\AircraftBoom.sqf, line 11
Error in expression <00 select 0;		
_boomed = false;


class CfgSounds
{
sounds[]= {sonicboom};

clas>
 Error position: <CfgSounds
{
sounds[]= {sonicboom};

clas>
 Error Missing ;
File mig29\scr\AircraftBoom.sqf, line 11
Error in expression <00 select 0;		
_boomed = false;


class CfgSounds
{
sounds[]= {sonicboom};

clas>
 Error position: <CfgSounds
{
sounds[]= {sonicboom};

clas>
 Error Missing ;
File mig29\scr\AircraftBoom.sqf, line 11
Error in expression <00 select 0;		
_boomed = false;


class CfgSounds
{
sounds[]= {sonicboom};

clas>
 Error position: <CfgSounds
{
sounds[]= {sonicboom};

clas>
 Error Missing ;
File mig29\scr\AircraftBoom.sqf, line 11
Error in expression <00 select 0;		
_boomed = false;


class CfgSounds
{
sounds[]= {sonicboom};

clas>
 Error position: <CfgSounds
{
sounds[]= {sonicboom};

clas>
 Error Missing ;
File mig29\scr\AircraftBoom.sqf, line 11
Error in expression <



_veh = _this select 0;		
_spd = 500 select 0;		
_boomed = false;


class Cfg>
 Error position: <select 0;		
_boomed = false;


class Cfg>
 Error select: Type Number, expected Array,Config entry
File mig29\scr\AircraftBoom.sqf, line 7
Error in expression <00 select 0;		
_boomed = false;


class CfgSounds
{
sounds[]= {sonicboom};

clas>
 Error position: <CfgSounds
{
sounds[]= {sonicboom};

clas>
 Error Missing ;
File mig29\scr\AircraftBoom.sqf, line 11
Error in expression <speed > 850) and (_nowspeed < 860) and (_lastspeed < _nowspeed)) then {
_emitter>
 Error position: <_lastspeed < _nowspeed)) then {
_emitter>
 Error Undefined variable in expression: _lastspeed
File mig29\scr\FX_SonicBoom.sqf, line 14

Original ArmA 2/OA Mission file

Elaboration;

That would have to be added to the plane's addOn config. Not sure how exactly to do that though, the guys over on Configs and Black Magic would know more. :) Then however you're running into a situation where you, the server and everyone playing needs to have the proper version of that addOn for it to work.

Is this for your F-14 port? You'd wanna add the sound to the addOn and the config to the cfgSounds in your config for the plane. I'm not sure how to get the monitor script to work with an addOn though.

Yes, I am trying to make this work ALL IN ONE, so that I do not have to call any scripts with a mission/trigger in the editor (all pre-set variables in the config).

Thank You!

(Moderators, could you please delete the other thread, as this is the proper area for this question)

Original Thread

Share this post


Link to post
Share on other sites
Guest

Ok, here is the deal.

- you do not start a new thread (at your own discretion) about the same in a different section, that is crossposting.

- you do not instruct the moderators what to do with your old thread in the new thread

What you do is:

- contact a moderator by PM or report your post

- ask a moderator to move the thread to the correct section

- ask a moderator to remove the posts which do not belong in the discussion

Maybe read the forum rules again?

http://forums.bistudio.com/misc.php?do=vsarules

Old thread deleted..............................

Share this post


Link to post
Share on other sites
Ok, here is the deal.

- you do not start a new thread (at your own discretion) about the same in a different section, that is crossposting.

- you do not instruct the moderators what to do with your old thread in the new thread

What you do is:

- contact a moderator by PM or report your post

- ask a moderator to move the thread to the correct section

- ask a moderator to remove the posts which do not belong in the discussion

Maybe read the forum rules again?

http://forums.bistudio.com/misc.php?do=vsarules

Old thread deleted..............................

I read them, didn't think about messaging you, and I did not INSTRUCT you.. I asked politely, there is a massive difference. At least I had the audacity to explain why I did things the way I did.

Back on Topic, anyone who can shed light on this?

Thank You!

-LtShadow

Share this post


Link to post
Share on other sites

Okay, I tried to implement the say3D command, again, with no joy. Anyone out there know how to activate a sound (In the pbo) at a certain speed without having to make a separate mission file?

Share this post


Link to post
Share on other sites

Actually, I am nearly completed with this, but am getting a Error - Generic Error in Expression ; Sleep 1 in this code -

//SonicBoom script by LtShadow
//Do not re-distribute unless you ask permission!
//

_veh = _this;		//the vehicle
_spd = 500;		//the speed at which the sonic boom occurs
_boomed = false;


while {alive _veh} do {

_vel = velocity _veh;

_speed = 3.6*sqrt((_vel select 0)^2 + (_vel select 1)^2 + (_vel select 2)^2);

if (_speed > _spd and not _boomed) then {

	_veh say3D "mig29\snd\tornado_gr4boom.wss";

	_boomed = true;

	Sleep 1;
};
};

Then, when I just set a init in a vehicles code 'this exec "AircraftBoom.sqf";' it gives me an error saying Error - }; must have {

Weird.

Hope someone can help me, thanks.

Share this post


Link to post
Share on other sites

_veh say3D "mig29\snd\tornado_gr4boom.wss";

say3d - must use a sound! Sound is defined in CfgSound of the Description.ext.

dont think it .wss format is allowed - (http://ofp.toadlife.net/downloads/tutorials/tutorial_sound/tutorial_sound.html)

Description.ext.

class CfgSounds
    {
    sounds[] = { sonicboom};

    class sonicboom
    {
         name = "sonicboom";
         sound[] = {""mig29\snd\tornado_gr4boom.[color="#FF0000"]ogg[/color]", db-40, 1.0};
         titles[] = {};

    };
};

therefore should be

_veh say3D "sonicboom";

'this exec "AircraftBoom.sqf";

when calling and .sqf file you use ExecVM "filename.sqf"

Share this post


Link to post
Share on other sites
_veh say3D "mig29\snd\tornado_gr4boom.wss";

say3d - must use a sound! Sound is defined in CfgSound of the Description.ext.

dont think it .wss format is allowed - (http://ofp.toadlife.net/downloads/tutorials/tutorial_sound/tutorial_sound.html)

Description.ext.

class CfgSounds
    {
    sounds[] = { sonicboom};

    class sonicboom
    {
         name = "sonicboom";
         sound[] = {""mig29\snd\tornado_gr4boom.[color="#FF0000"]ogg[/color]", db-40, 1.0};
         titles[] = {};

    };
};

therefore should be

_veh say3D "sonicboom";

'this exec "AircraftBoom.sqf";

when calling and .sqf file you use ExecVM "filename.sqf"

I realize this, but again, I do not want to create a mission file! lol, I want this all to be inside of the configuration of the .pbo . .. :P

And, again . . . I want to use this as an ADDED configuration of the vehicle, and not use a mission to set the script up.

Share this post


Link to post
Share on other sites

Something like this in the cpp

class CfgSounds
{
class bBoom {
	name = "bBoom";
	sound[] = {"\mig29\snd\tornado_gr4boom.ogg", db-40, 1.0};
	titles[] = {};
};
};

Share this post


Link to post
Share on other sites
Gnat;2463648']Something like this in the cpp

class CfgSounds
{
class bBoom {
	name = "bBoom";
	sound[] = {"\mig29\snd\tornado_gr4boom.ogg", db-40, 1.0};
	titles[] = {};
};
};

Okay, thank you. :)

How would I call the sound in my script exactly? I am having enough troubles figuring out the logic of ArmA. ;)

Here is my updated script as of 8/9/2013 09:33AM;

_veh = _this;	
_spd = 500;	
_boomed = false;


while {!alive _this} then {

_vel = (velocity _veh select 1);

_speed = 3.6*sqrt((_vel select 0)^2 + (_vel select 1)^2 + (_vel select 2)^2);

if (_speed > _spd and not _boomed) then {

	_veh say3D "mig29\snd\tornado_gr4boom.wss";

	_boomed = true;

};

sleep 0.5;

};

Also, getting an error at Line 7 according to the arma3.rpt file.

Error in expression <_boomed = false;


while {!alive _this} then {

_vel = (velocity _veh select 1);>
 Error position: <then {

_vel = (velocity _veh select 1);>
 Error then: Type while, expected if
File mig29\scr\AircraftBoom.sqf, line 7

Thanks Gnat. :)

Edited by LtShadow

Share this post


Link to post
Share on other sites

Hey there, LtShadow.

Unfortunately, you fell victim to common misconception :) There's no sonic boom when an aircraft "passes" certain velocity.

Rather, there's a cone of high pressure (shock wave) which is moved with the plane itself.

The "boom" itself happens when this cone is dragged over the observer - i.e. effectively the observer is hit by the shockwave.

See:

http://en.wikipedia.org/wiki/Sonic_boom#Perception_and_noise

However, as those who have witnessed landings of space shuttles have heard, when the aircraft is nearby the sonic boom is a sharper "bang" or "crack". The sound is much like the "aerial bombs" used at firework displays. It is a common misconception that only "one" boom is generated during the subsonic to supersonic transition, rather, the boom is continuous along the boom carpet for the entire supersonic flight. As a former Concorde pilot puts it, "You don't actually hear anything on board. All we see is the pressure wave moving down the aeroplane - it gives an indication on the instruments. And that's what we see around Mach 1. But we don't hear the sonic boom or anything like that. That's rather like the wake of a ship - it's behind us.".

That's not an attack on the work itself, I'm just pointing out that it may be worth changing the direction a little.

As for your script, you should write

while {!alive _this} do {

instead of

while {!alive _this} then {
Edited by DarkWanderer

Share this post


Link to post
Share on other sites
Hey there, LtShadow.

Unfortunately, you fell victim to common misconception :) There's no sonic boom when an aircraft "passes" certain velocity.

Rather, there's a cone of high pressure (shock wave) which is moved with the plane itself.

The "boom" itself happens when this cone is dragged over the observer - i.e. effectively the observer is hit by the shockwave.

See:

http://en.wikipedia.org/wiki/Sonic_boom#Perception_and_noise

Actually, yes there is! :)

When the plane reaches the point of sound, a very high pressure shock wave starts to cone around the aircraft, once the aircraft passes this point is when the 'Boom' occurs.

haha, even though it may not be realistic, I just want to figure this darn thing out!

Tired of nonsense answers. The only useful one here is Gnat (and Foxhound because he is le* Moderatorr).

Thank You.

I updated my script post as of 0953 8/9/13

Edit*

Thank You, will try that right now.

Do you have steam, maybe you could be of assistance if I get another error. ;)

---------- Post added at 10:09 ---------- Previous post was at 09:55 ----------

Update:

New error:

Fixed

while {!alive _this} then {

to

while {!alive _this} do {

And getting this error:

Error in expression <_spd = 500;	
_boomed = false;


while {!alive _this} do {

_vel = (velocity _veh>
 Error position: <alive _this} do {

_vel = (velocity _veh>
 Error alive: Type Array, expected Object
File mig29\scr\AircraftBoom.sqf, line 7

Thank you.

Edited by LtShadow

Share this post


Link to post
Share on other sites
When the plane reaches the point of sound, a very high pressure shock wave starts to cone around the aircraft, once the aircraft passes this point is when the 'Boom' occurs.

Nope, still wrong ;)

But it would be a nice start, nevertheless.

Error in expression <_spd = 500;

_boomed = false;

while {!alive _this} do {

_vel = (velocity _veh>

Error position: <alive _this} do {

_vel = (velocity _veh>

Error alive: Type Array, expected Object

File mig29\scr\AircraftBoom.sqf, line 7

How are you calling your script? Something like this?

[this,500] call "somescript.sdf"

Share this post


Link to post
Share on other sites
Nope, still wrong ;)

But it would be a nice start, nevertheless.

How are you calling your script? Something like this?

I am not calling the script. Period.

Actually, I am using this .sqs file in the planes script folder:

_plane = _this select 0

#Skip
[_plane] execVM "\mig29\scr\AircraftEffects.sqf"
[_plane] execVM "\mig29\scr\AircraftBoom.sqf"
exit

This is where it inits all the scripts. :)

Share this post


Link to post
Share on other sites

You're using velocity and say3D wrong.

[color="#FF0000"][b]_vel = (velocity _veh select 1);[/b] //You are selecting the 2nd element of the velocity array; ex: [0,[b][u]5[/u][/b],2][/color]

[color="#FF0000"]	[b]_speed = 3.6*sqrt((_vel select 0)^2 + (_vel select 1)^2 + (_vel select 2)^2);[/b] //Now you are choosing different elements of the velocity, but the _vel var is a number and not an array, so select won't do anything.[/color]

if (_speed > _spd and not _boomed) then {

[color="#FF0000"]		[b]_veh say3D "mig29\snd\tornado_gr4boom.wss";[/b] //You must configure the sound under CfgSounds to use it - say3D does not use file paths.[/color]

	_boomed = true;

};

Share this post


Link to post
Share on other sites
You're using velocity and say3D wrong.

[color="#FF0000"][b]_vel = (velocity _veh select 1);[/b] //You are selecting the 2nd element of the velocity array; ex: [0,[b][u]5[/u][/b],2][/color]

[color="#FF0000"]	[b]_speed = 3.6*sqrt((_vel select 0)^2 + (_vel select 1)^2 + (_vel select 2)^2);[/b] //Now you are choosing different elements of the velocity, but the _vel var is a number and not an array, so select won't do anything.[/color]

if (_speed > _spd and not _boomed) then {

[color="#FF0000"]		[b]_veh say3D "mig29\snd\tornado_gr4boom.wss";[/b] //You must configure the sound under CfgSounds to use it - say3D does not use file paths.[/color]

	_boomed = true;

};

Okay, so how would you go about doing this?

:)

Share this post


Link to post
Share on other sites

Okay guys, have collaborated with another scripter and he can't figure it out (No, it wasn't ZooLoo because he is busy with other stuff).

I am so close, I can taste it!

This has to do with the if !alive _This statement; please read!

(As you can tell, me and my buddy totally re-vamped this code , I did most of the work anyways)

_boomed = false;
_veh = _this;


if (!alive _this) then
{

       if (speed _this >= 760 and not _boomed) then {

               _veh say3D "bBoom";

               _boomed = true;

       };

       sleep 1;

};

The Say3D is already set up, as well as the speed _this function (as it is a standard .sqf function and No MISSION NEEDED!)

This is the error I get when I start up my game with the MIG;

Error in expression <"
_boomed = false;
_veh = _this;


if (!alive _this) then
{

if (speed _this >= >
 Error position: <alive _this) then
{

if (speed _this >= >
 Error alive: Type Array, expected Object
File mig29\scr\AircraftBoom.sqf, line 5

If ANYONE knows what the problem is, please let me know ASAP (Tired of working on this).

Thank YOU!!!

Share this post


Link to post
Share on other sites

What is _this equal to?

_this needs to be an object - it looks like you are sending an array.

If you are putting this in an init line then do...

_sonicBoom = this execVM "SONICBOOMSCRIPTNAME.sqf";

I'm assuming you did this...

_sonicBoom = [this] execVM "SCRIPT.sqf";

-----

Now for some logic. Why would the sonic boom only occur when the vehicle is "dead"?

You'd also want to put the script into a loop so it will continuously check for that condition. Right now you have it check only once (as soon as the mission starts) which means you'll never see the sonic boom.

Share this post


Link to post
Share on other sites

Moderators, this script was completed, edited and finalized by zooloo! :)

He is a truly gifted scripter, thank you for your help man.

-Shadow-

Edited by LtShadow

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  

×