Ambrosia Garden Archive
    • Technical Information


      Has anyone got some specs for the format of the LMProject, LMScene, LMScript, LMSprite, LMFont or Spritemap files? And how much progress has been made at code-type plugins, beyond the easy class-dump type stuff?

    • @prophile, on Aug 30 2008, 03:49 PM, said in Technical Information:

      Has anyone got some specs for the format of the LMProject, LMScene, LMScript, LMSprite, LMFont or Spritemap files? And how much progress has been made at code-type plugins, beyond the easy class-dump type stuff?

      Dang, that went so far over my head (which is not an easy task given my height) that I could barely spot it while squinting. 😉
      Hopefully, prophile, someone with more knowledge than me (i.e., most anybody) will respond to this topic, as it seems interesting.

      Lamkin

    • @prophile, on Aug 30 2008, 03:49 PM, said in Technical Information:

      Has anyone got some specs for the format of the LMProject, LMScene, LMScript, LMSprite, LMFont or Spritemap files? And how much progress has been made at code-type plugins, beyond the easy class-dump type stuff?

      Yes on all of the file formats except LMFont. Spritemaps are standard .tif files- the only organization in them is determined by the LMSprite files. For the rest, see below. As for code-type plug-ins, you'll need to ask someone else- I have no idea how to do something like that.

      Edwards

      LM File Information

      Notes: Ints are 4 bytes, doubles are 8 bytes. Also, all data types are bigendian, so you will need to be careful to convert them appropriately on Intel systems.

      LMScript

      The file starts with an integer that gives the number of actions in the script. The actions start immediately thereafter, and each of them consists of the following 44 bytes (note: not all actions utilize all of these numbers, but all 44 bytes are always present in the file):

      Action Type Index (int- 4 bytes)
      Action time offset from start of script (int- 4 bytes)
      Action data integer (int- 4 bytes)
      Action data floating-point 1 (float- 8 bytes)
      Action data floating-point 2 (float- 8 bytes)
      Action data floating-point 3 (float- 8 bytes)
      Action data floating-point 4 (float- 8 bytes)

      After all the actions, there is another integer, which gives the length of the script's name. This is followed by the name itself, which runs to the end of the file.

      Action Type List  (lifted from the strings in the SketchFighter binary)
      Note: I have not done extensive testing to find out exactly how each of these actions work, or what some of the more ambiguous parameters do (i.e. "plus" in Turn Towards Target).
      
      Idx	Action
      0	Delete Self
      1	RETURN %d loops
      2	Set ID to %d
      3	Set ID relative %d
      4	Set POSITION (%d) (%f, %f) rand:(%f, %f)
      5	Set POSITION relative(%d) (%f, %f) rand:(%f, %f)
      6	Set ROTATION to (%d) %f rand:%f
      7	Set ROTATION relative (%d) %f rand:%f
      8	Set SPEED (%d) (%f, %f) rand:(%f, %f)
      9	Set SPEED relative (%d) (%f, %f) rand:(%f, %f)
      10	Set COLOR (%d) R:%f G:%f B:%f A:%f
      11	Set COLOR relative (%d) R:%f G:%f B:%f A:%f
      12	Set ROTATION SPEED (%d) %f rand:%f
      13	Set ROTATION SPEED relative (%d) %f rand:%f
      14	WAIT (%d) %f ticks rand:%f
      15	SPAWN id:%d at (%f, %f) rand:(%f, %f)
      16	Set SCALE (%d) (%f, %f) rand:(%f, %f)
      17	Set SCALE relative (%d) (%f, %f) rand:(%f, %f)
      18	Return to previous script						
      19	Turn towards target (%d) max angle %f plus:%f
      20	Set SPEED FORWARD (%d) %f rand:%f
      21	FIRE id %d speed:%f angle:%f rand:%f
      22	PROXIMITY script:%d distance:%f
      23	EXTRA1 CHECK script:%d lower than:%f
      24	Set EXTRA1 to:%d
      25	Set EXTRA2 to:%d
      26	TARGET closest of type:%d
      

      LMSprite

      This file is a simple list of values with the following meanings, in order.

      double  Spritemap section top left corner X
      double  Spritemap section top left corner Y
      double  Spritemap section width
      double  Spritemap section height
      double  Center X
      double  Center Y
      double  Collision Box Start X (within sprite)
      double  Collision Box Start Y (within sprite)
      double  Collision Box Width
      double  Collision Box Height
      int	 Imagefile Index from Project.LMProject (for the existing files, spritemap#+4)
      int	 Default AI
      int	 Solid type
      int	 Default layer
      int	 Default Extra1
      int	 Default Extra2
      int	 Name Length
      string  Name
      

      LMScene

      This file type is simply a list of sprites, with all information for each sprite that is set in the editor. Each sprite entry follows a set format, shown below, and the list starts at the first byte of the file. There is no indicator for how many sprites are in a LMScene file. The game engine simply reads through each sprite until it reaches a name string with the value "(End of File)".

      int	 Name Length
      string  Name	   (Length is Name Length bytes)
      int	 Sprite	 (1-based ID)
      int	 Script	 (1-based ID)
      double  Location X (pixels)
      double  Location Y (pixels)
      double  Size X	 (pixels)
      double  Size Y	 (pixels)
      double  Red		(0 to 1)
      double  Green	  (0 to 1)
      double  Blue	   (0 to 1)
      double  Alpha	  (0 to 1)
      double  Rotation   (degrees)
      int	 Solid Type
      int	 Layer	  (+13 for .SketchMap)
      int	 Tiled Flag
      int	 Extra1
      int	 Extra2
      

      LMProject

      This file starts with an int giving the number of spritemaps the game has. Then, for each of the spritemaps, it has information in the following format:

      int	 Description length
      string  Description (note: I don't know where this is used, apart from this file)
      int	 Filename Length
      string  Filename
      

      The file ends with two more ints. First, one giving the number of LMSprite files in the Data/Sprites folder, and second, one giving the number of LMScript files in the Data/Scripts folder. Note that if you want to add any new scripts or sprites, you will need to adjust these numbers appropriately.