Ok, here's a way to get all the dynamic lights in a level. It might be a little messy, as this is my first time using dynamic memory allocation functions (I'm a C# guy), haha...
Code:
/////////////////////////
// Includes /////////////
/////////////////////////

#include <acknex.h>
#include <default.c>
#include <stdio.h>

/////////////////////////
// Variables ////////////
/////////////////////////

DynamicLight* lights; // Array of dynamic lights.
int dynamic_light_counter = 0; // Amount of dynamic lights in our array.

/////////////////////////
// Structs //////////////
/////////////////////////

typedef struct
{
float x,y,z; 	
float red,green,blue;	
float range;	
} 
DynamicLight; // A simple struct to hold the properties of a dynamic light.

/////////////////////////
// Functions ////////////
/////////////////////////

// This function reads the internal structure of a .WMB file, and searches only for dynamic lights. It then creates a new DynamicLight struct
// with the light's properties and adds it to the global array (lights).

void GetDynamicLights(char* filename)
{
  FILE* file = fopen(level,"rb");
  fseek(file,124,SEEK_SET);

  var i = 0; int offset = 0, length = 0, num_of_objects = 0, object_type = 0;

  fread(&offset, sizeof(int), 1, file);
  fread(&length, sizeof(int), 1, file);
  fseek(file,offset,SEEK_SET);

  fread(&num_of_objects, sizeof(int), 1, file);
  
  int* offset_list = (int*)malloc (num_of_objects*sizeof(int));
  for(i = 0; i < num_of_objects; i++)
  {
		fread(&(offset_list[i]), sizeof(int), 1, file);
  }

  for(i=0; i < num_of_objects; i++)
  {
	  fseek(file,offset+offset_list[i],SEEK_SET);
	  fread(&object_type, sizeof(int), 1, file);

	  if(object_type == 2) // light
	  {
      fseek(file,offset+offset_list[i]+32,SEEK_SET);
		int flags = 0;
	
		fread(&flags, sizeof(long), 1, file);

		if(flags == 2)
		{
		fseek(file,offset+offset_list[i]+4,SEEK_SET);

		float x = 0.0, y = 0.0, z = 0.0;
		float red =0.0, blue =0.0, green = 0.0;
		float range = 0.0;
		
		fread(&x, sizeof(float), 1, file);
		fread(&y, sizeof(float), 1, file);
		fread(&z, sizeof(float), 1, file);
		fread(&red, sizeof(float), 1, file);
		fread(&green, sizeof(float), 1, file);
		fread(&blue, sizeof(float), 1, file);
		fread(&range, sizeof(float), 1, file);
		
		DynamicLight* new_light = (DynamicLight*)malloc(sizeof(DynamicLight));
		memset(new_light,0,sizeof(DynamicLight));
		new_light->x = x;
		new_light->y = y;
		new_light->z = z;
		new_light->red = (red*255)/100;
		new_light->green = (green*255)/100;
		new_light->blue = (blue*255)/100;
		new_light->range = range;
		
		lights = (DynamicLight*) realloc (lights, (dynamic_light_counter+1) * sizeof(DynamicLight));
		memcpy(&lights[dynamic_light_counter],new_light,sizeof(DynamicLight));
		dynamic_light_counter++;
		}
	  }
  }

  free (offset_list);
  fclose(file);
     
}

void main()
{
	GetDynamicLights("mylevel.wmb"); // Populate array of dynamic lights.
}



I've tested it and it works pretty well. Hope it helps.

DJB.

Last edited by DJBMASTER; 12/25/09 08:53.