public static FieldGuideXfer FromMapObject(Map.Object obj) { FieldGuideXfer result = new FieldGuideXfer(); using (NoxBinaryReader br = new NoxBinaryReader(new MemoryStream(obj.modbuf))) { result.MonsterSID = br.ReadString(); } return result; }
public static SpellRewardXfer FromMapObject(Map.Object obj) { SpellRewardXfer result = new SpellRewardXfer(); using (NoxBinaryReader br = new NoxBinaryReader(new MemoryStream(obj.modbuf))) { result.SpellName = br.ReadString(); } return result; }
protected void ReadCharacterInfo(NoxBinaryReader rdr) { long finish = rdr.ReadInt64() + rdr.BaseStream.Position; rdr.ReadBytes(6); //UNKNOWN header seems to always = 0c 00 02 00 00 00 SavePath = rdr.ReadString(System.Type.GetType("System.Int16")); rdr.ReadByte(); //terminating null not included in length //the time this file was written FileTime = new DateTime( rdr.ReadInt16(), //year rdr.ReadInt32() & 0xFFFF, //month --skip the next 16bytes //rdr.ReadInt16(),//day of the week (not needed) rdr.ReadInt16(), //day rdr.ReadInt16(), //hour rdr.ReadInt16(), //minute rdr.ReadInt16(), //seconds rdr.ReadInt16() //milliseconds ); //these colors are RGB HairColor = rdr.ReadColor(); SkinColor = rdr.ReadColor(); MustacheColor = rdr.ReadColor(); BeardColor = rdr.ReadColor(); SideburnsColor = rdr.ReadColor(); PantsColor = rdr.ReadUserColor(); ShirtColor = rdr.ReadUserColor(); ShirtTrimColor = rdr.ReadUserColor(); ShoesColor = rdr.ReadUserColor(); ShoesTrimColor = rdr.ReadUserColor(); Name = rdr.ReadUnicodeString(); Class = (CharacterClass)rdr.ReadByte(); rdr.ReadBytes(2); //UNKNOWN: always 00 0A? LastMapPlayed = rdr.ReadString(); rdr.ReadByte(); //null terminator not included in string length System.Diagnostics.Debug.Assert(rdr.BaseStream.Position == finish, "Bad CharacterInfo length"); }
public static GlyphXfer FromStream(Stream stream, short ParsingRule) { GlyphXfer result = new GlyphXfer(); NoxBinaryReader br = new NoxBinaryReader(stream); if (ParsingRule < 41) br.ReadInt32(); result.Angle = br.ReadByte(); result.TargX = br.ReadSingle(); result.TargY = br.ReadSingle(); byte spells = br.ReadByte(); while (spells > 0) { result.Spells.Add(br.ReadString()); spells--; } return result; }
public static NPCXfer FromStream(Stream mstream, ThingDb.Thing tt, short ParsingRule) { NPCXfer result = new NPCXfer(); NoxBinaryReader br = new NoxBinaryReader(mstream); result.Direction = (MonsterXfer.DirectionEncoded) br.ReadUInt64(); result.ScriptEvents = new string[10]; // Читаем имена обработчиков скриптовых событий for (int i = 0; i < 10; i++) { if (i == 2) result.DetectEventTimeout = br.ReadUInt16(); result.ScriptEvents[i] = br.ReadScriptEventString(); } // Пропуск (0) br.ReadInt32(); // цвета result.NPCColors = new Color[6]; byte R, G, B; for (int i = 0; i < 6; i++) { R = br.ReadByte(); G = br.ReadByte(); B = br.ReadByte(); result.NPCColors[i] = Color.FromArgb(R, G, B); } // основной блок инфы if (ParsingRule >= 32) { result.ActionRoamPathFlag = br.ReadByte(); if (ParsingRule < 49) result.StatusFlags = (NoxEnums.MonsterStatus) br.ReadUInt16(); else result.StatusFlags = (NoxEnums.MonsterStatus) br.ReadUInt32(); result.HealthMultiplier = br.ReadSingle(); result.RetreatRatio = br.ReadSingle(); result.ResumeRatio = br.ReadSingle(); result.SightRange = br.ReadSingle(); result.Health = br.ReadInt16(); result.Aggressiveness = br.ReadSingle(); if (ParsingRule < 35) result.DefaultAction = br.ReadInt32(); result.EscortObjName = br.ReadString(); if (ParsingRule >= 34) { int spells = br.ReadInt32(); result.KnownSpells = new List<MonsterXfer.SpellEntry>(); string spellName = null; uint spellFlags = 0; for (int i = 0; i < spells; i++) { spellName = br.ReadString(); spellFlags = br.ReadUInt32(); if (ThingDb.thingdb.Spells.Keys.Contains(spellName)) result.KnownSpells.Add(new MonsterXfer.SpellEntry(spellName, spellFlags)); } } else br.BaseStream.Seek(0x224, SeekOrigin.Current); // Задержки между заклинаниями if (ParsingRule < 47) { result.ReactionCastingDelayMin = (ushort) br.ReadByte(); result.ReactionCastingDelayMax = (ushort) br.ReadByte(); if (ParsingRule <= 32) br.ReadInt32(); result.BuffCastingDelayMin = (ushort) br.ReadByte(); result.BuffCastingDelayMax = (ushort) br.ReadByte(); if (ParsingRule <= 32) br.ReadInt32(); result.DebuffCastingDelayMin = (ushort) br.ReadByte(); result.DebuffCastingDelayMax = (ushort) br.ReadByte(); if (ParsingRule <= 32) br.ReadInt32(); result.OffensiveCastingDelayMin = (ushort) br.ReadByte(); result.OffensiveCastingDelayMax = (ushort) br.ReadByte(); if (ParsingRule <= 32) br.ReadInt32(); result.BlinkCastingDelayMin = (ushort) br.ReadByte(); result.BlinkCastingDelayMax = (ushort) br.ReadByte(); if (ParsingRule <= 32) br.ReadInt32(); } else { result.ReactionCastingDelayMin = br.ReadUInt16(); result.ReactionCastingDelayMax = br.ReadUInt16(); result.BuffCastingDelayMin = br.ReadUInt16(); result.BuffCastingDelayMax = br.ReadUInt16(); result.DebuffCastingDelayMin = br.ReadUInt16(); result.DebuffCastingDelayMax = br.ReadUInt16(); result.OffensiveCastingDelayMin = br.ReadUInt16(); result.OffensiveCastingDelayMax = br.ReadUInt16(); result.BlinkCastingDelayMin = br.ReadUInt16(); result.BlinkCastingDelayMax = br.ReadUInt16(); } if (ParsingRule < 34) result.MagicNumber = br.ReadUInt32(); if (ParsingRule >= 33) result.LockPathDistance = br.ReadSingle(); if (ParsingRule >= 34) { result.SpellPowerLevel = br.ReadInt32(); result.NPCStrength = br.ReadByte(); result.NPCSpeed = br.ReadSingle(); result.AimSkillLevel = br.ReadSingle(); if (ParsingRule < 42) { if (br.ReadInt16() == 0) result.Immortal = true; } result.TrapSpell1 = br.ReadString(); result.TrapSpell2 = br.ReadString(); result.TrapSpell3 = br.ReadString(); } if (ParsingRule >= 35) { string action = br.ReadString(); result.DefaultAction = Array.IndexOf(NoxEnums.AIActionStrings, action); } if (ParsingRule >= 41) { // здесь придётся читать просто огромное кол-во инфы // однако она используется очень редко, обычно entryType = 4; forced = 0 short entryType = br.ReadInt16(); if (entryType <= 4) { byte forced = 1; if (entryType >= 2) forced = br.ReadByte(); if (forced == 1 || entryType < 2) { return result; // TODO для ПОЛНОЙ совместимости, придётся } } } if (ParsingRule >= 42) result.Immortal = br.ReadBoolean(); if (ParsingRule >= 44) result.MagicNumber = br.ReadUInt32(); if (ParsingRule >= 45) result.MaxHealth = (short) br.ReadInt32(); if (ParsingRule >= 46) result.AddedSubclass = br.ReadUInt32(); if (ParsingRule >= 48) result.Health = br.ReadInt16(); if (ParsingRule >= 51) result.Experience = br.ReadSingle(); if (ParsingRule >= 52) result.NPCVoiceSet = br.ReadString(); if (ParsingRule < 61) return result; // энчанты short buffsType = br.ReadInt16(); if (buffsType > 2 || buffsType <= 0) return result; byte count = br.ReadByte(); result.BuffList = new MonsterXfer.BuffEntry[count]; while (count > 0) { MonsterXfer.BuffEntry be = new MonsterXfer.BuffEntry(); be.Name = br.ReadString(); be.Power = br.ReadByte(); be.Duration = br.ReadInt32(); if (be.Name == ENCHANT_SHIELD && buffsType >= 2) be.ShieldHealth = br.ReadInt32(); result.BuffList[count] = be; count--; } Array.Reverse(result.BuffList); if (ParsingRule >= 62) result.PoisonLevel = br.ReadByte(); } return result; }
protected void ReadCharacterInfo(NoxBinaryReader rdr) { long finish = rdr.ReadInt64() + rdr.BaseStream.Position; rdr.ReadBytes(6);//UNKNOWN header seems to always = 0c 00 02 00 00 00 SavePath = rdr.ReadString(System.Type.GetType("System.Int16")); rdr.ReadByte();//terminating null not included in length //the time this file was written FileTime = new DateTime( rdr.ReadInt16(),//year rdr.ReadInt32() & 0xFFFF,//month --skip the next 16bytes //rdr.ReadInt16(),//day of the week (not needed) rdr.ReadInt16(),//day rdr.ReadInt16(),//hour rdr.ReadInt16(),//minute rdr.ReadInt16(),//seconds rdr.ReadInt16()//milliseconds ); //these colors are RGB HairColor = rdr.ReadColor(); SkinColor = rdr.ReadColor(); MustacheColor = rdr.ReadColor(); BeardColor = rdr.ReadColor(); SideburnsColor = rdr.ReadColor(); PantsColor = rdr.ReadUserColor(); ShirtColor = rdr.ReadUserColor(); ShirtTrimColor = rdr.ReadUserColor(); ShoesColor = rdr.ReadUserColor(); ShoesTrimColor = rdr.ReadUserColor(); Name = rdr.ReadUnicodeString(); Class = (CharacterClass) rdr.ReadByte(); rdr.ReadBytes(2);//UNKNOWN: always 00 0A? LastMapPlayed = rdr.ReadString(); rdr.ReadByte();//null terminator not included in string length System.Diagnostics.Debug.Assert(rdr.BaseStream.Position == finish, "Bad CharacterInfo length"); }
public static MonsterXfer FromStream(Stream mstream, ThingDb.Thing tt, short ParsingRule) { MonsterXfer result = new MonsterXfer(); NoxBinaryReader br = new NoxBinaryReader(mstream); result.Direction = (DirectionEncoded) br.ReadUInt64(); result.ScriptEvents = new string[10]; // Читаем имена обработчиков скриптовых событий for (int i = 0; i < 10; i++) { if (i == 2) result.DetectEventTimeout = br.ReadUInt16(); result.ScriptEvents[i] = br.ReadScriptEventString(); } // Пропуск (0) if (ParsingRule >= 11) br.ReadInt32(); if (ParsingRule >= 31) { result.ActionRoamPathFlag = br.ReadByte(); if (ParsingRule < 51) result.StatusFlags = (NoxEnums.MonsterStatus) br.ReadUInt16(); else result.StatusFlags = (NoxEnums.MonsterStatus) br.ReadUInt32(); result.HealthMultiplier = br.ReadSingle(); result.RetreatRatio = br.ReadSingle(); result.ResumeRatio = br.ReadSingle(); result.SightRange = br.ReadSingle(); if (ParsingRule < 33) br.BaseStream.Seek(2, SeekOrigin.Current); result.Aggressiveness = br.ReadSingle(); if (ParsingRule < 34) result.DefaultAction = br.ReadInt32(); result.EscortObjName = br.ReadString(); if (ParsingRule >= 34) { int spells = br.ReadInt32(); result.KnownSpells = new List<SpellEntry>(); string spellName = null; uint spellFlags = 0; for (int i = 0; i < spells; i++) { spellName = br.ReadString(); spellFlags = br.ReadUInt32(); if (ThingDb.thingdb.Spells.Keys.Contains(spellName)) result.KnownSpells.Add(new SpellEntry(spellName, spellFlags)); } } else br.BaseStream.Seek(0x224, SeekOrigin.Current); // Задержки между заклинаниями if (ParsingRule < 46) { result.ReactionCastingDelayMin = (ushort) br.ReadByte(); result.ReactionCastingDelayMax = (ushort) br.ReadByte(); if (ParsingRule <= 32) br.ReadInt32(); result.BuffCastingDelayMin = (ushort) br.ReadByte(); result.BuffCastingDelayMax = (ushort) br.ReadByte(); if (ParsingRule <= 32) br.ReadInt32(); result.DebuffCastingDelayMin = (ushort) br.ReadByte(); result.DebuffCastingDelayMax = (ushort) br.ReadByte(); if (ParsingRule <= 32) br.ReadInt32(); result.OffensiveCastingDelayMin = (ushort) br.ReadByte(); result.OffensiveCastingDelayMax = (ushort) br.ReadByte(); if (ParsingRule <= 32) br.ReadInt32(); result.BlinkCastingDelayMin = (ushort) br.ReadByte(); result.BlinkCastingDelayMax = (ushort) br.ReadByte(); if (ParsingRule <= 32) br.ReadInt32(); } else { result.ReactionCastingDelayMin = br.ReadUInt16(); result.ReactionCastingDelayMax = br.ReadUInt16(); result.BuffCastingDelayMin = br.ReadUInt16(); result.BuffCastingDelayMax = br.ReadUInt16(); result.DebuffCastingDelayMin = br.ReadUInt16(); result.DebuffCastingDelayMax = br.ReadUInt16(); result.OffensiveCastingDelayMin = br.ReadUInt16(); result.OffensiveCastingDelayMax = br.ReadUInt16(); result.BlinkCastingDelayMin = br.ReadUInt16(); result.BlinkCastingDelayMax = br.ReadUInt16(); } if (ParsingRule > 32) result.LockPathDistance = br.ReadSingle(); if (ParsingRule >= 33) { result.SpellPowerLevel = br.ReadInt32(); result.AimSkillLevel = br.ReadSingle(); if (ParsingRule < 42) { if (br.ReadInt16() == 0) result.Immortal = true; } if (ParsingRule < 53) { int spellIndex = br.ReadInt32(); result.TrapSpell1 = ThingDb.thingdb.Spells.Values[spellIndex].Name; spellIndex = br.ReadInt32(); result.TrapSpell2 = ThingDb.thingdb.Spells.Values[spellIndex].Name; spellIndex = br.ReadInt32(); result.TrapSpell3 = ThingDb.thingdb.Spells.Values[spellIndex].Name; } else { result.TrapSpell1 = br.ReadString(); result.TrapSpell2 = br.ReadString(); result.TrapSpell3 = br.ReadString(); } } if (ParsingRule >= 34) { string action = br.ReadString(); result.DefaultAction = Array.IndexOf(NoxEnums.AIActionStrings, action); } if (ParsingRule >= 41) { // здесь придётся читать просто огромное кол-во инфы // однако она используется очень редко, обычно entryType = 4; forced = 0 short entryType = br.ReadInt16(); if (entryType <= 4) { byte forced = 1; if (entryType >= 2) forced = br.ReadByte(); if (forced == 1 || entryType < 2) { return result; // TODO для ПОЛНОЙ совместимости, придётся } } } if (ParsingRule >= 42) { result.Immortal = br.ReadBoolean(); } if (ParsingRule >= 43 && tt.Subclass[(int) ThingDb.Thing.SubclassBitIndex.SHOPKEEPER]) { // Информация о содержании магазина ShopkeeperInfoStruct si = new ShopkeeperInfoStruct(); if (ParsingRule >= 50) si.BuyValueMultiplier = br.ReadSingle(); if (ParsingRule >= 61) si.SellValueMultiplier = br.ReadSingle(); if (ParsingRule >= 48) si.ShopkeeperGreetingText = br.ReadString(); byte items = br.ReadByte(); si.ShopItems = new ShopItemInfo[items]; for (int i = 0; i < items; i++) { ShopItemInfo item = new ShopItemInfo(); if (ParsingRule < 50) br.ReadInt32(); item.Count = br.ReadByte(); item.Name = br.ReadString(); if (ParsingRule >= 47) { item.SpellID = br.ReadString(); item.Ench1 = br.ReadString(); item.Ench2 = br.ReadString(); item.Ench3 = br.ReadString(); item.Ench4 = br.ReadString(); } si.ShopItems[i] = item; } result.ShopkeeperInfo = si; } if (ParsingRule >= 44) result.MagicNumber = br.ReadUInt32(); if (ParsingRule >= 45) result.AddedSubclass = br.ReadUInt32(); if (ParsingRule >= 49) result.Health = br.ReadInt16(); if (ParsingRule >= 51) { result.SetDefaultResumeRatio = br.ReadBoolean(); result.SetDefaultRetreatRatio = br.ReadBoolean(); result.SetDefaultMonsterStatus = br.ReadBoolean(); result.LearnDefaultSpells = br.ReadBoolean(); } if (ParsingRule >= 54 && tt.Subclass[(int) ThingDb.Thing.SubclassBitIndex.FEMALE_NPC]) { result.MaidenBodyColors = new Color[6]; byte R, G, B; for (int i = 0; i < 6; i++) { R = br.ReadByte(); G = br.ReadByte(); B = br.ReadByte(); result.MaidenBodyColors[i] = Color.FromArgb(R, G, B); } if (ParsingRule >= 55) result.MaidenVoiceSet = br.ReadString(); } if (ParsingRule >= 62) { short entryType = br.ReadInt16(); if (entryType > 2 || entryType <= 0) return result; byte count = br.ReadByte(); result.BuffList = new BuffEntry[count]; while (count > 0) { BuffEntry be = new BuffEntry(); be.Name = br.ReadString(); be.Power = br.ReadByte(); be.Duration = br.ReadInt32(); if (be.Name == ENCHANT_SHIELD && entryType >= 2) be.ShieldHealth = br.ReadInt32(); result.BuffList[count] = be; count--; } Array.Reverse(result.BuffList); } if (ParsingRule >= 63 && tt.Subclass[(int) ThingDb.Thing.SubclassBitIndex.WOUNDED_NPC]) result.WoundedNPCVoiceSet = br.ReadString(); if (ParsingRule >= 64) result.PoisonLevel = br.ReadByte(); } return result; }
public static RewardMarkerXfer FromStream(Stream stream, short ParsingRule) { RewardMarkerXfer result = new RewardMarkerXfer(); NoxBinaryReader br = new NoxBinaryReader(stream); result.RewardType = (RewardFlags) br.ReadUInt32(); result.Unknown1 = br.ReadInt32(); // spells short count = br.ReadInt16(); result.Spells = new List<string>(count); while (count > 0) { result.Spells.Add(br.ReadString()); count--; } // abilities count = br.ReadInt16(); result.Abilities = new List<string>(count); while (count > 0) { result.Abilities.Add(br.ReadString()); count--; } // monster scrolls count = br.ReadInt16(); result.Monsters = new List<string>(count); while (count > 0) { result.Monsters.Add(br.ReadString()); count--; } result.Unknown2 = br.ReadInt32(); result.Unknown3 = br.ReadInt32(); result.Unknown4 = br.ReadInt32(); result.Unknown5 = br.ReadInt32(); result.Unknown6 = br.ReadInt32(); if (ParsingRule >= 62) result.ActivateChance = br.ReadInt32(); if (ParsingRule >= 63) result.RareOrSpecial = br.ReadBoolean(); return result; }