Jump to content
Sign in to follow this  
arno

conditional *.fx effect -- how?

Recommended Posts

Greetings!After figuring out how to switch lights on and off with the COM1 frequency, I wanted to do the same with an effect of the *.fx type (i.e. not gmax animation or anything).With FSEffects, I created an API macro containing the effect (a torch) set up to be ON at all times.Then I modified the macro by wrapping the usual switch logic (shown in red below) around the Dbx statement which calls the effect.Thus: (using braces {} for parentheses () to chase off the Smilies :-))

;macrodesc Effect: fx_myEffect {Created with FS Effects} . . .Area{ B %1 %2 22 }  PerspectiveCall{ :Go }  Jump{ : } :Go  mif{ %11  }	RefPoint{  2  :End  %4 %1 %2 v1=  %10 E=  %11 }  melse	RefPoint{  7  :End  %4 %1 %2 v1=  %10 }  mifend  Call{ :Begin } :End  Return :Begin[font color="red"]; activate fire by COM1 123.45 = DCBAIfVarAnd{ :fire_on 7BE DCBA }  Jump{ :skip_on }:fire_on[/font]; following Dbx statement coming from FSeffects again, ; contains name and timing {always ON} for the effect    Dbx{ A0 00 84 ... }[font color="red"]:skip_on[/font]ReturnEndA

[p class=dcmessage]This macro compiles OK but does not work as intended: the effect never shows up in FS9, no matter what the COM1 freq is.The same approach works fine for Dot() or Light() statements.Why not for the Dbx{} here?Perhaps because it is loaded only once (when called from the scenery macro), and then never checked again?What is a better way of controlling *.fx effects via COM1 ?(I did read Arno's various tutorials over at SceneryDesign.org about "Conditional Diplays" etc., but they refer to either scenery objects or gmax animations and effects, but not *.fx type effects.)Thanks for any tips!Cheers,Martin

Share this post


Link to post
Share on other sites

Hi MArtin.I have not tried this:It may be possible to use Arno's CAT tool ( latest version ) on an FS9 MDL-object. That object could be an attachment for an effect. If it works, the object ( an attachment ) will be switched on and off, and the effect should be switched with it.Dick

Share this post


Link to post
Share on other sites

Thanks for the fast reply, Dick!I'll certainly look into CAT (good timing -- new version just came out). I think, though, that it deals with animation of objects created in gmax, not the "classical" MS *.fx type effects. Then again, gmax is probably the way to go for effects, too, so this tool will be interesting in any case. Also, I am associating MDL always with aircraft modelling, not scenery objects, but that's perhaps a misconception -- I still have a lot of catching up to do, with the FS9 world...So, something new to learn, always a good prospect! Thanks for the directions!Cheers,Martin

Share this post


Link to post
Share on other sites

Hi Martin.I tried Arno's MDLTweaker, but effects show no matter the condition. Perhaps an ASM hack can yet be found to control the display... Arno's tool tweaks the MDL directly... not the ASM code.Dick

Share this post


Link to post
Share on other sites

Sorry, bad news, as far as I know it is not possible to add conditions to effects file (only with the effect file parameters as described in the effects SDK).This is because the effect attachment is not done in the normal BGL RIFF section, but in the ATTA and ATTO sections. I have tried to put the condition in there, but it does not work.For the FsEffect/API approach discussed before, I came to the same conclusion. No matter what condition you put in the API, the effect does not repond to it.I think this is just something we need to accept.


Arno

If the world should blow itself up, the last audible voice would be that of an expert saying it can't be done.

FSDeveloper.com | Former Microsoft FS MVP | Blog

Share this post


Link to post
Share on other sites

Thanks for the confirmation, Arno. Even if it's a "negative" one -- I'm always glad to learn it isn't just me... :-)On to learn more about gmax effects, then...Cheers,Martin

Share this post


Link to post
Share on other sites
Guest gorchi

Hello!Let's come back to the API. You certainly are one step away from the working API :)Try something like this:;-----------------------------------------------------------------;VODDATA Latitude Longitude Range Scale Rotation Not_used Not_used Not_used Not_used Visibility Altitude Scenery_complexity(0-5) Not_used Not_usedArea( 5 %1 %2 %3 )IfVarRange( :Exit 0346 %12 5 )PerspectiveCall( :_PCall )Jump32( :Exit ):_PCallPerspective:_PC02mif( %11 )RefPoint( 2 :Skip %4 %1 %2 E= %11 v1= %10 V2= 20 )melseRefPoint( 7 :Skip %4 %1 %2 v1= %10 v2= 20 )mifendIfVarRange( :Skip 7C0 0x2345 0x2345 )GObj( EFFECT "myeffect.fx" "" ):SkipReturn:ExitEndA ;-----------------------------------------------------------------But first don't forget to test the API with the IfVarRange() condition omitted just to test if API works anyhow! When You have established that API works, the effect shows, then uncomment IfVarRange.Hope it helps and best regards,Goran BrumenFS Slovenija 2002 teamhttp://slovenia.avsim.netP.S: If possible, please omit dbx()/dba()/dwx() instructions in SCASM. My experience is quite bad with those commands and could lead to FS crash too...

Share this post


Link to post
Share on other sites

The code suggested by Goran is indeed better, but I don't think it will work either. If I remember correct from my tests the conditions are just ignored by the effect.>P.S: If possible, please omit dbx()/dba()/dwx() instructions>in SCASM. My experience is quite bad with those commands and>could lead to FS crash too...It's never the Dbx, Dba or Dwx command to blame :). These commands just write the given value to the BGL file (directly in hex mode thus). But if you are using this code without knowing what you are doing, it is indeed very easy to make FS crash, because it will not understand the BGL file in that case.


Arno

If the world should blow itself up, the last audible voice would be that of an expert saying it can't be done.

FSDeveloper.com | Former Microsoft FS MVP | Blog

Share this post


Link to post
Share on other sites

Hello,sorry for the delayed response; got side-tracked again by Real Life :-). Thanks for your further suggestions and comments.Just for the record: I have now tried Goran's code, and can confirm Arno's suspicion that it does not work. I tried both versions, Goran's:

IfVarRange( :Skip 7C0 0x2345 0x2345 )  GObj( EFFECT "fx_myEffect.fx" "" ):Skip

[p class=dcmessage]...and my own (complete code above in the thread):

IfVarAnd( :fire_on 7BE DCBF )  Jump( :Skip ):fire_on	  GObj( EFFECT "fx_myEffect.fx" "" ):Skip

[p class=dcmessage]...but no luck. Like Arno says, it seems we'll have to live with that.Incidentally, I am confused about the variables tested:According to the FSUIPC doc.s "07C0" is "Autopilot Wing Leveller", not COM1 frequency. Whereas I found 7BE for COM1, but can't remember where; it's not in the FSUIPC doc. (but works anyway).And I read (SCASM doc.) that the "2345" of 123.45 needs to be coded as "DCBF", which is certainly different from 0x2345.Do I have outdated info? What is the current authoritative document about these variables and their use?(But this question is not related to the original problem with the effects: no permutation I tried can switch the effect on and off.)>It's never the Dbx, Dba or Dwx command to blame :)Well, I wouldn't use it directly -- in my case, it just was generated by FSeffects (and I then proceeded to manually translate it to ASCII to see if it was correct, which it was :-))Cheers,Martin

Share this post


Link to post
Share on other sites

Hi Martin,>Incidentally, I am confused about the variables tested:>According to the FSUIPC doc.s "07C0" is "Autopilot Wing>Leveller", not COM1 frequency. >Whereas I found 7BE for COM1, but can't remember where; it's >not in the FSUIPC doc. (but works anyway).The variables listed in the FSUIPC SDK are for use by FSUIPC only, when accessing the variables from the scenery they have different addresses, these are listed in the scenery SDK (Fs98 and Fs2000 SDK are the best sources).>And I read (SCASM doc.) that the "2345" of 123.45 needs to be>coded as "DCBF", which is certainly different from 0x2345.I don't really see the connection here as well, but normally you can write the value in both decimal and hecadecimal format. So the 2345h can also be written as 9029 in decimal format. I guess it is something like this that is causing the confusion.>Do I have outdated info? What is the current authoritative>document about these variables and their use?>(But this question is not related to the original problem with>the effects: no permutation I tried can switch the>effect on and off.)As I wrote before the old Fs98 and Fs2000 SDK are the best sources. But I do have plans for some time already to make a list of the variables that are there and what kind of values they take. Hopefully I can find some time soon to work on that.


Arno

If the world should blow itself up, the last audible voice would be that of an expert saying it can't be done.

FSDeveloper.com | Former Microsoft FS MVP | Blog

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...