CFS Exploding Objects
Campaigns
  • Aircraft
  • Scenery
  • Links


  • CFS Exploding Objects



    Creating CFS Exploding Objects from API files

    I found two ways of creating an exploding object. The first was to hex edit an existing CFS library file and insert your own objects. Then Scasm 2.5 came along and made the process much easier.

    First convert your macro file (.api) to scasm (.sca) format. This can be done using Airport or DDay then decompiling with BGL Analyse 1.2 available on FlightSim.com.
    Using a text editor insert the .sca file into library format .sca:

    Header( 1 S85:38:40.82 S94:21:19.18 W000:00:00.00 W000:00:00.00 )
    LatRange( S94:21:19.18 S85:38:40.82 )

    mif( [$Version < 250] )
    Error( You need at least SCASM version 2.50 to compile this code )
    mifend

    ; Library section
    ; Library Object #1
    ObjID( 00112233 44556677 8899AABB CCDDEEFF )
    LibObj(
    PWR 0
    SIZE 1000
    SCALE 0.500
    TYPE 769
    NAME "12345678" )
    CrashStart( :all_ok 150 )
    CrashBox ( :no_crash 0 0 0 80 60 350 0 0 0 )
    SetCrashCode( 14 )
    :no_crash
    Call( :all_ok )
    Return
    :all_ok


    ;insert .sca file here from transform call or rotated call (DDay) command.


    EndObj
    ; ----------------------------------------
    ; Library Object #2
    ; ----------------------------------------
    etc


    ObjID : This is a 32bit identifier unique to each object in the library.
    PWR 0 : Not used this.
    SIZE 1000 : It maybe sets the scale - don't think it worked with some objects ?
    SCALE 0.50 : Sets the scale dividing factor. Doesn't work with scale commands.
    TYPE 769 : Not used this.
    NAME :I stick to eight character names, but any number can work.
    CRASHSTART : The base radius of the crash box.
    CRASHBOX :
    x0 z0 y0 : The first three vary the box offset in relation to the object - use these if you know the drawing origin was not central to the object you created in dday etc. or you are using more than one crashbox.
    x z y : The next three define the dimensions of the crash box - z is height.
    p b h : p-pitch b-bank h-heading as in mission files.
    The crashbox will take up a lot of time in trial and error - you can define more than one:
    CrashStart( :all_ok 150 )
    CrashBox ( :box1 x0 z0 y0 x z y p b h )
    SetCrashCode( 14 )
    :box1
    CrashBox ( :box2 x0 z0 y0 x z y p b h )
    SetCrashCode( 14 )
    Return
    :box2
    CrashBox ( :no_crash x0 z0 y0 x z y p b h )
    SetCrashCode( 14 )
    Return
    :no_crash
    Call( :all_ok )
    Return
    :all_ok
    The SetCrashCode( 14 ) sets a crash into a solid object (building).

    Using a text editor edit an existing .dp file to suit your needs. They need to have exactly the same name as defined in your .sca file. I've been told that CFS2 .dp files will allow use of the objects in CFS2, but as I don't have CFS2 I cannot confirm this.
    Put the compiled .bgl file into /scenery folder and .dp file into the /objects_dp folder, then write a mission file to test the object.

    Hex Editing

    This is far more involved, uses hexedecimal maths and is a waste of time now that scasm 2.5 does the job for you. Fine tune the crashbox instead ! I did find that some api files would not appear - martin wright's fire and smoke objects. Others with transform call (46 00) were difficult to scale down, but all files generated by dday seem to use rotatedcall (33 0C) and work fine.