Ejemplo n.º 1
0
 /// <summary>
 /// Load an npcgen.data file
 /// </summary>
 /// <param name="NPCGenFile">Path to the npcgen.data file</param>
 /// <returns>True on successful load</returns>
 public Boolean Load(String NPCGenFile)
 {
     try
     {
         MemoryStream ms = new MemoryStream();
         FileStream   fs = new FileStream(NPCGenFile, FileMode.Open);
         //Clone the FileStream into memory release and reset Position on MemoryStream
         fs.CopyTo(ms); fs.Close(); ms.Position = 0;
         BinaryReader br = new BinaryReader(ms);
         creatureSets       = new List <CreatureSet>();
         resourceSets       = new List <ResourceSet>();
         dynamics           = new List <DynamicObj>();
         triggers           = new List <Trigger>();
         version            = br.ReadInt32();
         _creatureSetsCount = br.ReadInt32();
         _resourceSetsCount = br.ReadInt32();
         _dynamicsCount     = br.ReadInt32();
         _triggersCount     = br.ReadInt32();
         Int32         i;
         Int32         x;
         CreatureSet   creatureFillHolder;
         CreatureGroup creatureGFillHolder;
         for (i = 0; i < _creatureSetsCount; i++)
         {
             creatureFillHolder                     = new CreatureSet();
             creatureFillHolder.spawnMode           = br.ReadInt32();
             creatureFillHolder._creatureGroupCount = br.ReadInt32();
             creatureFillHolder.spawnX              = br.ReadSingle();
             creatureFillHolder.spawnY              = br.ReadSingle();
             creatureFillHolder.spawnZ              = br.ReadSingle();
             creatureFillHolder.rot1                = br.ReadSingle();
             creatureFillHolder.rot2                = br.ReadSingle();
             creatureFillHolder.rot3                = br.ReadSingle();
             creatureFillHolder.spreadX             = br.ReadSingle();
             creatureFillHolder.spreadY             = br.ReadSingle();
             creatureFillHolder.spreadZ             = br.ReadSingle();
             creatureFillHolder.unknown1            = br.ReadInt32();
             creatureFillHolder.unknown2            = br.ReadInt32();
             creatureFillHolder.unknown3            = br.ReadBoolean();
             creatureFillHolder.unknown4            = br.ReadBoolean();
             creatureFillHolder.unknown5            = br.ReadBoolean();
             creatureFillHolder.unknown6            = br.ReadInt32();
             creatureFillHolder.trigger             = br.ReadInt32();
             creatureFillHolder.unknown7            = br.ReadInt32();
             creatureFillHolder.unknown8            = br.ReadInt32();
             creatureFillHolder.creatureGroups      = new List <CreatureGroup>();
             for (x = 0; x < creatureFillHolder._creatureGroupCount; x++)
             {
                 creatureGFillHolder              = new CreatureGroup();
                 creatureGFillHolder.id           = br.ReadInt32();
                 creatureGFillHolder.amount       = br.ReadInt32();
                 creatureGFillHolder.respawn      = br.ReadInt32();
                 creatureGFillHolder.diedTimes    = br.ReadInt32();
                 creatureGFillHolder.agressive    = br.ReadInt32();
                 creatureGFillHolder.offsetWater  = br.ReadInt32();
                 creatureGFillHolder.offsetTrn    = br.ReadInt32();
                 creatureGFillHolder.faction      = br.ReadInt32();
                 creatureGFillHolder.facHelper    = br.ReadInt32();
                 creatureGFillHolder.facAccept    = br.ReadInt32();
                 creatureGFillHolder.needHelp     = br.ReadBoolean();
                 creatureGFillHolder.defFaction   = br.ReadBoolean();
                 creatureGFillHolder.defFacHelper = br.ReadBoolean();
                 creatureGFillHolder.defFacAccept = br.ReadBoolean();
                 creatureGFillHolder.pathID       = br.ReadInt32();
                 creatureGFillHolder.loopType     = br.ReadInt32();
                 creatureGFillHolder.speedFlag    = br.ReadInt32();
                 creatureGFillHolder.deadTime     = br.ReadInt32();
                 creatureFillHolder.creatureGroups.Add(creatureGFillHolder);
             }
             creatureSets.Add(creatureFillHolder);
         }
         ResourceSet   resourceFillHolder;
         ResourceGroup resourceGFillHolder;
         for (i = 0; i < _resourceSetsCount; i++)
         {
             resourceFillHolder                     = new ResourceSet();
             resourceFillHolder.spawnX              = br.ReadSingle();
             resourceFillHolder.spawnY              = br.ReadSingle();
             resourceFillHolder.spawnZ              = br.ReadSingle();
             resourceFillHolder.spreadX             = br.ReadSingle();
             resourceFillHolder.spreadZ             = br.ReadSingle();
             resourceFillHolder._resourceGroupCount = br.ReadInt32();
             resourceFillHolder.unknown1            = br.ReadBoolean();
             resourceFillHolder.unknown2            = br.ReadBoolean();
             resourceFillHolder.unknown3            = br.ReadBoolean();
             resourceFillHolder.unknown4            = br.ReadInt32();
             resourceFillHolder.rot1                = br.ReadByte();
             resourceFillHolder.rot2                = br.ReadByte();
             resourceFillHolder.rot3                = br.ReadByte();
             resourceFillHolder.unknownTrigger      = br.ReadInt32();
             resourceFillHolder.unknown6            = br.ReadByte();
             resourceFillHolder.unknown7            = br.ReadBoolean();
             resourceFillHolder.unknown8            = br.ReadBoolean();
             resourceFillHolder.unknown9            = br.ReadBoolean();
             resourceFillHolder.resourceGroups      = new List <ResourceGroup>();
             for (x = 0; x < resourceFillHolder._resourceGroupCount; x++)
             {
                 resourceGFillHolder             = new ResourceGroup();
                 resourceGFillHolder.type        = br.ReadInt32();
                 resourceGFillHolder.id          = br.ReadInt32();
                 resourceGFillHolder.respawn     = br.ReadInt32();
                 resourceGFillHolder.amount      = br.ReadInt32();
                 resourceGFillHolder.hmap_offset = br.ReadInt32();
                 resourceFillHolder.resourceGroups.Add(resourceGFillHolder);
             }
             resourceSets.Add(resourceFillHolder);
         }
         DynamicObj dynamicObjFillHolder;
         for (i = 0; i < _dynamicsCount; i++)
         {
             dynamicObjFillHolder           = new DynamicObj();
             dynamicObjFillHolder.id        = br.ReadInt32();
             dynamicObjFillHolder.spawnX    = br.ReadSingle();
             dynamicObjFillHolder.spawnY    = br.ReadSingle();
             dynamicObjFillHolder.spawnZ    = br.ReadSingle();
             dynamicObjFillHolder.dir1      = br.ReadByte();
             dynamicObjFillHolder.dir2      = br.ReadByte();
             dynamicObjFillHolder.rad       = br.ReadByte();
             dynamicObjFillHolder.triggerID = br.ReadInt32();
             dynamicObjFillHolder.scale     = br.ReadByte();
             dynamics.Add(dynamicObjFillHolder);
         }
         Trigger triggerFillHolder;
         for (i = 0; i < _triggersCount; i++)
         {
             triggerFillHolder      = new Trigger();
             triggerFillHolder.id   = br.ReadInt32();
             triggerFillHolder.gmID = br.ReadInt32();
             //name is ALWAYS 128 bytes long
             triggerFillHolder.realname       = br.ReadBytes(128);
             triggerFillHolder.autostart      = br.ReadBoolean();
             triggerFillHolder.autostartDelay = br.ReadInt32();
             triggerFillHolder.autostopDelay  = br.ReadInt32();
             triggerFillHolder.dontStartOnSch = br.ReadBoolean();
             triggerFillHolder.dontStoponSch  = br.ReadBoolean();
             triggerFillHolder.year1          = br.ReadInt32();
             triggerFillHolder.month1         = br.ReadInt32();
             triggerFillHolder.weekDay1       = br.ReadInt32();
             triggerFillHolder.day1           = br.ReadInt32();
             //no idea why they didn't use byte here...
             //not like there are 256 hours in a day...
             //and for month/weekday/day
             triggerFillHolder.hour1 = br.ReadInt32();
             //same for this
             triggerFillHolder.minute1  = br.ReadInt32();
             triggerFillHolder.year2    = br.ReadInt32();
             triggerFillHolder.month2   = br.ReadInt32();
             triggerFillHolder.weekDay2 = br.ReadInt32();
             triggerFillHolder.day2     = br.ReadInt32();
             triggerFillHolder.hour2    = br.ReadInt32();
             triggerFillHolder.minute2  = br.ReadInt32();
             triggerFillHolder.duration = br.ReadInt32();
             triggers.Add(triggerFillHolder);
         }
         return(true);
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
         return(false);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Load an npcgen.data file
 /// </summary>
 /// <param name="NPCGenFile">Path to the npcgen.data file</param>
 /// <returns>True on successful load</returns>
 public Boolean Load(String NPCGenFile)
 {
     try
     {
         MemoryStream ms = new MemoryStream();
         FileStream fs = new FileStream(NPCGenFile, FileMode.Open);
         //Clone the FileStream into memory release and reset Position on MemoryStream
         fs.CopyTo(ms); fs.Close(); ms.Position = 0;
         BinaryReader br = new BinaryReader(ms);
         creatureSets = new List<CreatureSet>();
         resourceSets = new List<ResourceSet>();
         dynamics = new List<DynamicObj>();
         triggers = new List<Trigger>();
         version = br.ReadInt32();
         _creatureSetsCount = br.ReadInt32();
         _resourceSetsCount = br.ReadInt32();
         _dynamicsCount = br.ReadInt32();
         _triggersCount = br.ReadInt32();
         Int32 i;
         Int32 x;
         CreatureSet creatureFillHolder;
         CreatureGroup creatureGFillHolder;
         for (i = 0; i < _creatureSetsCount; i++)
         {
             creatureFillHolder = new CreatureSet();
             creatureFillHolder.spawnMode = br.ReadInt32();
             creatureFillHolder._creatureGroupCount = br.ReadInt32();
             creatureFillHolder.spawnX = br.ReadSingle();
             creatureFillHolder.spawnY = br.ReadSingle();
             creatureFillHolder.spawnZ = br.ReadSingle();
             creatureFillHolder.rot1 = br.ReadSingle();
             creatureFillHolder.rot2 = br.ReadSingle();
             creatureFillHolder.rot3 = br.ReadSingle();
             creatureFillHolder.spreadX = br.ReadSingle();
             creatureFillHolder.spreadY = br.ReadSingle();
             creatureFillHolder.spreadZ = br.ReadSingle();
             creatureFillHolder.unknown1 = br.ReadInt32();
             creatureFillHolder.unknown2 = br.ReadInt32();
             creatureFillHolder.unknown3 = br.ReadBoolean();
             creatureFillHolder.unknown4 = br.ReadBoolean();
             creatureFillHolder.unknown5 = br.ReadBoolean();
             creatureFillHolder.unknown6 = br.ReadInt32();
             creatureFillHolder.trigger = br.ReadInt32();
             creatureFillHolder.unknown7 = br.ReadInt32();
             creatureFillHolder.unknown8 = br.ReadInt32();
             creatureFillHolder.creatureGroups = new List<CreatureGroup>();
             for (x = 0; x < creatureFillHolder._creatureGroupCount; x++)
             {
                 creatureGFillHolder = new CreatureGroup();
                 creatureGFillHolder.id = br.ReadInt32();
                 creatureGFillHolder.amount = br.ReadInt32();
                 creatureGFillHolder.respawn = br.ReadInt32();
                 creatureGFillHolder.diedTimes = br.ReadInt32();
                 creatureGFillHolder.agressive = br.ReadInt32();
                 creatureGFillHolder.offsetWater = br.ReadInt32();
                 creatureGFillHolder.offsetTrn = br.ReadInt32();
                 creatureGFillHolder.faction = br.ReadInt32();
                 creatureGFillHolder.facHelper = br.ReadInt32();
                 creatureGFillHolder.facAccept = br.ReadInt32();
                 creatureGFillHolder.needHelp = br.ReadBoolean();
                 creatureGFillHolder.defFaction = br.ReadBoolean();
                 creatureGFillHolder.defFacHelper = br.ReadBoolean();
                 creatureGFillHolder.defFacAccept = br.ReadBoolean();
                 creatureGFillHolder.pathID = br.ReadInt32();
                 creatureGFillHolder.loopType = br.ReadInt32();
                 creatureGFillHolder.speedFlag = br.ReadInt32();
                 creatureGFillHolder.deadTime = br.ReadInt32();
                 creatureFillHolder.creatureGroups.Add(creatureGFillHolder);
             }
             creatureSets.Add(creatureFillHolder);
         }
         ResourceSet resourceFillHolder;
         ResourceGroup resourceGFillHolder;
         for (i = 0; i < _resourceSetsCount; i++)
         {
             resourceFillHolder = new ResourceSet();
             resourceFillHolder.spawnX = br.ReadSingle();
             resourceFillHolder.spawnY = br.ReadSingle();
             resourceFillHolder.spawnZ = br.ReadSingle();
             resourceFillHolder.spreadX = br.ReadSingle();
             resourceFillHolder.spreadZ = br.ReadSingle();
             resourceFillHolder._resourceGroupCount = br.ReadInt32();
             resourceFillHolder.unknown1 = br.ReadBoolean();
             resourceFillHolder.unknown2 = br.ReadBoolean();
             resourceFillHolder.unknown3 = br.ReadBoolean();
             resourceFillHolder.unknown4 = br.ReadInt32();
             resourceFillHolder.rot1 = br.ReadByte();
             resourceFillHolder.rot2 = br.ReadByte();
             resourceFillHolder.rot3 = br.ReadByte();
             resourceFillHolder.unknownTrigger = br.ReadInt32();
             resourceFillHolder.unknown6 = br.ReadByte();
             resourceFillHolder.unknown7 = br.ReadBoolean();
             resourceFillHolder.unknown8 = br.ReadBoolean();
             resourceFillHolder.unknown9 = br.ReadBoolean();
             resourceFillHolder.resourceGroups = new List<ResourceGroup>();
             for (x = 0; x < resourceFillHolder._resourceGroupCount; x++)
             {
                 resourceGFillHolder = new ResourceGroup();
                 resourceGFillHolder.type = br.ReadInt32();
                 resourceGFillHolder.id = br.ReadInt32();
                 resourceGFillHolder.respawn = br.ReadInt32();
                 resourceGFillHolder.amount = br.ReadInt32();
                 resourceGFillHolder.hmap_offset = br.ReadInt32();
                 resourceFillHolder.resourceGroups.Add(resourceGFillHolder);
             }
             resourceSets.Add(resourceFillHolder);
         }
         DynamicObj dynamicObjFillHolder;
         for (i = 0; i < _dynamicsCount; i++)
         {
             dynamicObjFillHolder = new DynamicObj();
             dynamicObjFillHolder.id = br.ReadInt32();
             dynamicObjFillHolder.spawnX = br.ReadSingle();
             dynamicObjFillHolder.spawnY = br.ReadSingle();
             dynamicObjFillHolder.spawnZ = br.ReadSingle();
             dynamicObjFillHolder.dir1 = br.ReadByte();
             dynamicObjFillHolder.dir2 = br.ReadByte();
             dynamicObjFillHolder.rad = br.ReadByte();
             dynamicObjFillHolder.triggerID = br.ReadInt32();
             dynamicObjFillHolder.scale = br.ReadByte();
             dynamics.Add(dynamicObjFillHolder);
         }
         Trigger triggerFillHolder;
         for (i = 0; i < _triggersCount; i++)
         {
             triggerFillHolder = new Trigger();
             triggerFillHolder.id = br.ReadInt32();
             triggerFillHolder.gmID = br.ReadInt32();
             //name is ALWAYS 128 bytes long
             triggerFillHolder.realname = br.ReadBytes(128);
             triggerFillHolder.autostart = br.ReadBoolean();
             triggerFillHolder.autostartDelay = br.ReadInt32();
             triggerFillHolder.autostopDelay = br.ReadInt32();
             triggerFillHolder.dontStartOnSch = br.ReadBoolean();
             triggerFillHolder.dontStoponSch = br.ReadBoolean();
             triggerFillHolder.year1 = br.ReadInt32();
             triggerFillHolder.month1 = br.ReadInt32();
             triggerFillHolder.weekDay1 = br.ReadInt32();
             triggerFillHolder.day1 = br.ReadInt32();
             //no idea why they didn't use byte here...
             //not like there are 256 hours in a day...
             //and for month/weekday/day
             triggerFillHolder.hour1 = br.ReadInt32();
             //same for this
             triggerFillHolder.minute1 = br.ReadInt32();
             triggerFillHolder.year2 = br.ReadInt32();
             triggerFillHolder.month2 = br.ReadInt32();
             triggerFillHolder.weekDay2 = br.ReadInt32();
             triggerFillHolder.day2 = br.ReadInt32();
             triggerFillHolder.hour2 = br.ReadInt32();
             triggerFillHolder.minute2 = br.ReadInt32();
             triggerFillHolder.duration = br.ReadInt32();
             triggers.Add(triggerFillHolder);
         }
             return true;
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
         return false;
     }
 }