Sign in to follow this  
Guest bjornhall

Building crash code in SCASM macros

Recommended Posts

Hi folks,Hope you don't mind too much my beating up this dead ol' mare again ... ;-) I am speaking of the issue with a great many SCASM macros triggering builing crashes from 'viewpoint' rather than 'aircraft location'. When looking at the crash detection code in those macros, both the code and the issue look amazingly simple, don't they? I mean, look:; CRASH DetectionIfVarRange3( :NoCrash 37E -312 312 382 0 993 386 -501 501 )ReturnSetVar( 0284 14 ):NoCrash(The extra Return is my work-around in those cases when I'm not absolutely certain I won't screw something up by removing the code entirely... I don't speak SCASM too well I'm afraid!)Well, "obviously", 37E is the variable for the viewpoint position, and if one replaced it with the proper variable for the aircraft position, it would all work again, wouldn't it? So, the crucial questions here ... 1) Did I get that right, or am I completely missing something?2) What is the magic variable to put in instead of 37E; does any of you guys happen to know?Thanks, and all the best,/Bj

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Hi Bjorn,Ah, this is a famous problem :). This way of crash detection (used by FSDS) does not really work. It checks if the distance from the viewpoint to the scenery object is between certain values for the x, y and z direction. Three varaibles are used for this 37E, 382 and 386.I think there is no better variable then this. Maybe 33B gives the correct distance, but not sure. Also that variable has no x, y and z distance, but it is the shortest distance.I think the best way to get a correct crash detection is to completely remove this way of crash detection and use the SCASM command that are specially made for crash detection. I have never written such commands manual, so can't give real tips now.

Share this post


Link to post
Share on other sites

Hi Arno,Thanks, now it makes a lot more sense ... :) I should have noticed there were three variables there of course ... Ok, I will dig up my SCASM manuals then ... Best,/Bj

Share this post


Link to post
Share on other sites

Hi guysThe appropriate code to replace the faulty crash detection in FDSD-generated macros, using the latest crash detection techniques, isReplace; CRASH DetectionIfVarRange3( :NoCrash 37E -312 312 382 0 993 386 -501 501 )ReturnSetVar( 0284 14 ):NoCrashwith; CRASH DetectionCrashStart( :NoCrash 1250 ) ; see Note 1CrashOctTree( 0x14 ; crash type code, 14 = building -312 0 -501 ; crash box origin relative to RefPoint 614 993 1002 ; crash box size 1 1 1 1 1 1 1 1 ; offsets to crash nodes 255 255 255 255 255 255 255 255 ; node 1 ):NoCrashNote 1: The CrashStart command does a quick check as to whether any crash detection is necessary by checking if the aircraft is within the immediate vicinity of the object. It uses a sphere centered on the RefPoint with a given radius - I have used a radius of 1250 here to be on the safe side to enclose the whole of the crash box created by the FSDS macro. Making this sphere too big is better than making it too small. This command could probably be left out - it is only present to save time by avoiding unnecessary crash detection, and is always present in MS default code, but in this particular case the following crash detection command is so simple that including CrashStart probably doesn't save any time at all! In many of the default scenery objects (and those created by gMax), however, the CrashOctTree command is very complex in order to model much more detailed 'crash box' shapes, and then the inclusion of the CrashStart command is definitely worthwhile because it avoids lots of detailed checking when the aircraft is not in the immediate vicinity of the object.Note 2: CrashOctTree does the actual crash detection, using the true aircraft position, NOT the viewpoint position! Very complex crash 'box' shapes can be created with this command, but the simple version given here creates a straightforward rectangular box exactly copying the box created by the original FSDS code.Of course, the other even simpler solution is to remove the crash detection code altogether - crash detection is often a pretty superfluous waste of time unless the object either(a) stands on, or very close to, an airfieldor (:( stands out in a flat open space well away from other objects that would provoke a crash before an aircraft ever reached your new object anyway.CheersGerrish

Share this post


Link to post
Share on other sites

Thanks Gerrish! Most helpful indeed! I saved it to my personal knowledge-log of course ... And yeah, I sure agree that crash detection is usually rather superfluous; hence the added 'Return' in my example to bypass it! I realize now that I could as well just delete it, in those particular types of macro ... Live and learn, gotta love it! :+ Best,/Bj

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