Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Building crash code in SCASM macros

Featured Replies

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

  • Commercial Member

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.

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

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

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

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

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.