public override bool FromStream(Stream mstream, short ParsingRule, ThingDb.Thing thing) { NoxBinaryReader br = new NoxBinaryReader(mstream); // collisionbox SizeX = br.ReadInt32(); SizeY = br.ReadInt32(); if (SizeX > 60) { SizeX = 60; } if (SizeY > 60) { SizeY = 60; } // цвета заливки и граней для PressurePlate EdgeColor = br.ReadColor(); BackColor = br.ReadColor(); UnkInt1 = br.ReadInt32(); // обработчики событий ScriptOnPressed = br.ReadScriptEventString(); ScriptOnReleased = br.ReadScriptEventString(); ScriptOnCollided = br.ReadScriptEventString(); // кто может активировать AllowedObjClass = br.ReadInt32(); IgnoredObjClass = br.ReadInt32(); AllowedTeamID = br.ReadByte(); IgnoredTeamID = br.ReadByte(); if (ParsingRule >= 61) { TriggerState = br.ReadByte(); Unk7 = br.ReadByte(); UnkInt2 = br.ReadInt32(); } return(true); }
public override bool FromStream(Stream mstream, short ParsingRule, ThingDb.Thing thing) { NoxBinaryReader br = new NoxBinaryReader(mstream); if (ParsingRule < 42) { throw new NotSupportedException("Where did you find this map?"); } ScriptActivated = br.ReadInt32(); // какой-то скриптовый обработчик UnknownScriptHandler = br.ReadScriptEventString(); // координаты места падения FallX = br.ReadInt32(); FallY = br.ReadInt32(); // таймаут вызова скрипта ScriptTime1 = br.ReadInt32(); ScriptTimeout = br.ReadInt16(); return(true); }
public override bool FromStream(Stream mstream, short ParsingRule, ThingDb.Thing thing) { NoxBinaryReader br = new NoxBinaryReader(mstream); DirectionId = (byte)Array.IndexOf(MonsterXfer.NOX_DIRECT_LONG, br.ReadUInt64()); ScriptEvents = new string[10]; // Fix for some old maps (null) NPCVoiceSet = ""; BuffList = new MonsterXfer.BuffEntry[0]; // Читаем имена обработчиков скриптовых событий for (int i = 0; i < 10; i++) { if (i == 2) { DetectEventTimeout = br.ReadUInt16(); } ScriptEvents[i] = br.ReadScriptEventString(); } // Пропуск (0) br.ReadInt32(); // цвета NPCColors = new Color[6]; byte R, G, B; for (int i = 0; i < 6; i++) { R = br.ReadByte(); G = br.ReadByte(); B = br.ReadByte(); NPCColors[i] = Color.FromArgb(R, G, B); } // основной блок инфы if (ParsingRule >= 32) { ActionRoamPathFlag = br.ReadByte(); if (ParsingRule < 49) { StatusFlags = (NoxEnums.MonsterStatus)br.ReadUInt16(); } else { StatusFlags = (NoxEnums.MonsterStatus)br.ReadUInt32(); } HealthMultiplier = br.ReadSingle(); RetreatRatio = br.ReadSingle(); ResumeRatio = br.ReadSingle(); SightRange = br.ReadSingle(); Health = br.ReadInt16(); Aggressiveness = br.ReadSingle(); if (ParsingRule < 35) { DefaultAction = br.ReadInt32(); } EscortObjName = br.ReadString(); if (ParsingRule >= 34) { int spells = br.ReadInt32(); 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.Spells.Keys.Contains(spellName)) { KnownSpells.Add(new MonsterXfer.SpellEntry(spellName, spellFlags)); } } } else { br.BaseStream.Seek(0x224, SeekOrigin.Current); } // Задержки между заклинаниями if (ParsingRule < 47) { ReactionCastingDelayMin = (ushort)br.ReadByte(); ReactionCastingDelayMax = (ushort)br.ReadByte(); if (ParsingRule <= 32) { br.ReadInt32(); } BuffCastingDelayMin = (ushort)br.ReadByte(); BuffCastingDelayMax = (ushort)br.ReadByte(); if (ParsingRule <= 32) { br.ReadInt32(); } DebuffCastingDelayMin = (ushort)br.ReadByte(); DebuffCastingDelayMax = (ushort)br.ReadByte(); if (ParsingRule <= 32) { br.ReadInt32(); } OffensiveCastingDelayMin = (ushort)br.ReadByte(); OffensiveCastingDelayMax = (ushort)br.ReadByte(); if (ParsingRule <= 32) { br.ReadInt32(); } BlinkCastingDelayMin = (ushort)br.ReadByte(); BlinkCastingDelayMax = (ushort)br.ReadByte(); if (ParsingRule <= 32) { br.ReadInt32(); } } else { ReactionCastingDelayMin = br.ReadUInt16(); ReactionCastingDelayMax = br.ReadUInt16(); BuffCastingDelayMin = br.ReadUInt16(); BuffCastingDelayMax = br.ReadUInt16(); DebuffCastingDelayMin = br.ReadUInt16(); DebuffCastingDelayMax = br.ReadUInt16(); OffensiveCastingDelayMin = br.ReadUInt16(); OffensiveCastingDelayMax = br.ReadUInt16(); BlinkCastingDelayMin = br.ReadUInt16(); BlinkCastingDelayMax = br.ReadUInt16(); } if (ParsingRule < 34) { MagicNumber = br.ReadUInt32(); } if (ParsingRule >= 33) { LockPathDistance = br.ReadSingle(); } if (ParsingRule >= 34) { SpellPowerLevel = br.ReadInt32(); NPCStrength = br.ReadByte(); NPCSpeed = br.ReadSingle(); AimSkillLevel = br.ReadSingle(); if (ParsingRule < 42) { if (br.ReadInt16() == 0) { Immortal = true; } } TrapSpell1 = br.ReadString(); TrapSpell2 = br.ReadString(); TrapSpell3 = br.ReadString(); } if (ParsingRule >= 35) { string action = br.ReadString(); DefaultAction = Array.IndexOf(NoxEnums.AIActionStrings, action); } if (ParsingRule >= 41) { // here you have to read just a huge amount of information // however it is used very rarely, usually 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(false); // TODO для ПОЛНОЙ совместимости, придётся } } } if (ParsingRule >= 42) { Immortal = br.ReadBoolean(); } if (ParsingRule >= 44) { MagicNumber = br.ReadUInt32(); } if (ParsingRule >= 45) { MaxHealth = (short)br.ReadInt32(); } if (ParsingRule >= 46) { AddedSubclass = br.ReadUInt32(); } if (ParsingRule >= 48) { Health = br.ReadInt16(); } if (ParsingRule >= 51) { Experience = br.ReadSingle(); } if (ParsingRule >= 52) { NPCVoiceSet = br.ReadString(); } if (ParsingRule < 61) { return(true); } // энчанты short buffsType = br.ReadInt16(); if (buffsType > 2 || buffsType <= 0) { return(false); } byte count = br.ReadByte(); 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(); } BuffList[count - 1] = be; count--; } Array.Reverse(BuffList); if (ParsingRule >= 62) { PoisonLevel = br.ReadByte(); } } return(true); }
public override bool FromStream(Stream mstream, short ParsingRule, ThingDb.Thing thing) { NoxBinaryReader br = new NoxBinaryReader(mstream); // частота появления монстров int spawnRateNum = (int)br.ReadByte(); MonsterSpawnRate = new byte[spawnRateNum]; for (int i = 0; i < spawnRateNum; i++) { MonsterSpawnRate[i] = br.ReadByte(); } // число уже созданных монстров SpawnedMonsters = br.ReadByte(); // заменяется при загрузке на MonsterSpawnLimit SavedSpawnLimit = br.ReadByte(); // должно быть 0 если карта не была сохранена игрой LastSpawnFrame = br.ReadUInt32(); // скриптовые обработчики ScriptOnDamage = br.ReadScriptEventString(); ScriptOnDestroy = br.ReadScriptEventString(); ScriptOnCollide = br.ReadScriptEventString(); ScriptOnSpawn = br.ReadScriptEventString(); // монстры int monsters = (int)br.ReadByte(); byte spawnLimitNum = 0; List <string> monsterNames = new List <string>(monsters); MonsterData = new byte[monsters][]; for (int i = 0; i < monsters; i++) { // именно так if (!br.ReadBoolean()) { monsterNames.Add(null); continue; } string monsterName = br.ReadString(); short unknown = br.ReadInt16(); // увеличивается для следующего монстра // SkipToNextQword br.SkipToNextBoundary(); long entryLenMB = br.ReadInt64(); MonsterData[i] = br.ReadBytes((int)entryLenMB); /* * MonsterData - типичная инфа об обьекте * short parsingRule1 = br.ReadInt16(); * short parsingRule2 = br.ReadInt16(); * br.ReadInt32(); // extent * br.ReadInt32(); // globalID * br.ReadSingle(); // X * br.ReadSingle(); // Y * byte term = br.ReadByte(); * result.MonsterData[i] = MonsterXfer.FromStream(br.BaseStream, ThingDb.Things[monsterName], parsingRule1); */ monsterNames.Add(monsterName); } spawnLimitNum = br.ReadByte(); MonsterNames = monsterNames.ToArray(); // максимальное число создаваемых монстров, берется из gamedata.bin MonsterSpawnLimit = new byte[spawnLimitNum]; for (int i = 0; i < spawnLimitNum; i++) { MonsterSpawnLimit[i] = br.ReadByte(); } // настройки спавна: 0 - отключен, 1 - рандом позиция, 2 - зависит от игрока if (ParsingRule >= 63) { GenerationFlags = br.ReadInt32(); } return(true); }
public static MonsterGeneratorXfer FromStream(Stream mstream, short ParsingRule) { MonsterGeneratorXfer result = new MonsterGeneratorXfer(); NoxBinaryReader br = new NoxBinaryReader(mstream); // частота появления монстров int spawnRateNum = (int) br.ReadByte(); result.MonsterSpawnRate = new byte[spawnRateNum]; for (int i = 0; i < spawnRateNum; i++) result.MonsterSpawnRate[i] = br.ReadByte(); // число уже созданных монстров result.SpawnedMonsters = br.ReadByte(); // заменяется при загрузке на MonsterSpawnLimit result.SavedSpawnLimit = br.ReadByte(); // должно быть 0 если карта не была сохранена игрой result.LastSpawnFrame = br.ReadUInt32(); // скриптовые обработчики result.ScriptOnDamage = br.ReadScriptEventString(); result.ScriptOnDestroy = br.ReadScriptEventString(); result.ScriptOnCollide = br.ReadScriptEventString(); result.ScriptOnSpawn = br.ReadScriptEventString(); // монстры int monsters = (int) br.ReadByte(); byte spawnLimitNum = 0; List<string> monsterNames = new List<string>(monsters); result.MonsterData = new byte[monsters][]; for (int i = 0; i < monsters; i++) { // именно так if (!br.ReadBoolean()) { monsterNames.Add(null); continue; } string monsterName = br.ReadString(); short unknown = br.ReadInt16(); // увеличивается для следующего монстра // SkipToNextQword br.SkipToNextBoundary(); long entryLenMB = br.ReadInt64(); result.MonsterData[i] = br.ReadBytes((int) entryLenMB); /* MonsterData - типичная инфа об обьекте short parsingRule1 = br.ReadInt16(); short parsingRule2 = br.ReadInt16(); br.ReadInt32(); // extent br.ReadInt32(); // globalID br.ReadSingle(); // X br.ReadSingle(); // Y byte term = br.ReadByte(); result.MonsterData[i] = MonsterXfer.FromStream(br.BaseStream, ThingDb.Things[monsterName], parsingRule1); */ monsterNames.Add(monsterName); } spawnLimitNum = br.ReadByte(); result.MonsterNames = monsterNames.ToArray(); // максимальное число создаваемых монстров, берется из gamedata.bin result.MonsterSpawnLimit = new byte[spawnLimitNum]; for (int i = 0; i < spawnLimitNum; i++) result.MonsterSpawnLimit[i] = br.ReadByte(); // настройки спавна: 0 - отключен, 1 - рандом позиция, 2 - зависит от игрока if (ParsingRule >= 63) result.GenerationFlags = br.ReadInt32(); return result; }
public override bool FromStream(Stream mstream, short ParsingRule, ThingDb.Thing thing) { NoxBinaryReader br = new NoxBinaryReader(mstream); DirectionId = (byte)Array.IndexOf(NOX_DIRECT_LONG, br.ReadUInt64()); ScriptEvents = new string[10]; // Read script event handler names for (int i = 0; i < 10; i++) { if (i == 2) { DetectEventTimeout = br.ReadUInt16(); } ScriptEvents[i] = br.ReadScriptEventString(); } // Skip (0) if (ParsingRule >= 11) { br.ReadInt32(); } if (ParsingRule >= 31) { ActionRoamPathFlag = br.ReadByte(); if (ParsingRule < 51) { StatusFlags = (NoxEnums.MonsterStatus)br.ReadUInt16(); } else { StatusFlags = (NoxEnums.MonsterStatus)br.ReadUInt32(); } HealthMultiplier = br.ReadSingle(); RetreatRatio = br.ReadSingle(); ResumeRatio = br.ReadSingle(); SightRange = br.ReadSingle(); if (ParsingRule < 33) { br.BaseStream.Seek(2, SeekOrigin.Current); } Aggressiveness = br.ReadSingle(); if (ParsingRule < 34) { DefaultAction = br.ReadInt32(); } EscortObjName = br.ReadString(); if (ParsingRule >= 34) { int spells = br.ReadInt32(); 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.Spells.Keys.Contains(spellName)) { KnownSpells.Add(new SpellEntry(spellName, spellFlags)); } } } else { br.BaseStream.Seek(0x224, SeekOrigin.Current); } // Spell usage delay values if (ParsingRule < 46) { ReactionCastingDelayMin = (ushort)br.ReadByte(); ReactionCastingDelayMax = (ushort)br.ReadByte(); if (ParsingRule <= 32) { br.ReadInt32(); } BuffCastingDelayMin = (ushort)br.ReadByte(); BuffCastingDelayMax = (ushort)br.ReadByte(); if (ParsingRule <= 32) { br.ReadInt32(); } DebuffCastingDelayMin = (ushort)br.ReadByte(); DebuffCastingDelayMax = (ushort)br.ReadByte(); if (ParsingRule <= 32) { br.ReadInt32(); } OffensiveCastingDelayMin = (ushort)br.ReadByte(); OffensiveCastingDelayMax = (ushort)br.ReadByte(); if (ParsingRule <= 32) { br.ReadInt32(); } BlinkCastingDelayMin = (ushort)br.ReadByte(); BlinkCastingDelayMax = (ushort)br.ReadByte(); if (ParsingRule <= 32) { br.ReadInt32(); } } else { ReactionCastingDelayMin = br.ReadUInt16(); ReactionCastingDelayMax = br.ReadUInt16(); BuffCastingDelayMin = br.ReadUInt16(); BuffCastingDelayMax = br.ReadUInt16(); DebuffCastingDelayMin = br.ReadUInt16(); DebuffCastingDelayMax = br.ReadUInt16(); OffensiveCastingDelayMin = br.ReadUInt16(); OffensiveCastingDelayMax = br.ReadUInt16(); BlinkCastingDelayMin = br.ReadUInt16(); BlinkCastingDelayMax = br.ReadUInt16(); } if (ParsingRule > 32) { LockPathDistance = br.ReadSingle(); } if (ParsingRule >= 33) { SpellPowerLevel = br.ReadInt32(); AimSkillLevel = br.ReadSingle(); if (ParsingRule < 42) { if (br.ReadInt16() == 0) { Immortal = true; } } if (ParsingRule < 53) { int spellIndex = br.ReadInt32(); TrapSpell1 = ThingDb.Spells.Values[spellIndex].Name; spellIndex = br.ReadInt32(); TrapSpell2 = ThingDb.Spells.Values[spellIndex].Name; spellIndex = br.ReadInt32(); TrapSpell3 = ThingDb.Spells.Values[spellIndex].Name; } else { TrapSpell1 = br.ReadString(); TrapSpell2 = br.ReadString(); TrapSpell3 = br.ReadString(); } } if (ParsingRule >= 34) { string action = br.ReadString(); DefaultAction = Array.IndexOf(NoxEnums.AIActionStrings, action); } if (ParsingRule >= 41) { // large, complex structure dealing with AI-specific data // it is only used on saved games, normally 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(false); // TODO implement for full compatibility } } } if (ParsingRule >= 42) { Immortal = br.ReadBoolean(); } if (ParsingRule >= 43 && thing.Subclass[(int)ThingDb.Thing.SubclassBitIndex.SHOPKEEPER]) { // Shop contents 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; } ShopkeeperInfo = si; } if (ParsingRule >= 44) { MagicNumber = br.ReadUInt32(); } if (ParsingRule >= 45) { AddedSubclass = br.ReadUInt32(); } if (ParsingRule >= 49) { Health = br.ReadInt16(); } if (ParsingRule >= 51) { SetDefaultResumeRatio = br.ReadBoolean(); SetDefaultRetreatRatio = br.ReadBoolean(); SetDefaultMonsterStatus = br.ReadBoolean(); LearnDefaultSpells = br.ReadBoolean(); } if (ParsingRule >= 54 && thing.Subclass[(int)ThingDb.Thing.SubclassBitIndex.FEMALE_NPC]) { MaidenBodyColors = new Color[6]; byte R, G, B; for (int i = 0; i < 6; i++) { R = br.ReadByte(); G = br.ReadByte(); B = br.ReadByte(); MaidenBodyColors[i] = Color.FromArgb(R, G, B); } if (ParsingRule >= 55) { MaidenVoiceSet = br.ReadString(); } } if (ParsingRule >= 62) { short entryType = br.ReadInt16(); if (entryType > 2 || entryType <= 0) { return(false); } byte count = br.ReadByte(); 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(); } BuffList[count] = be; count--; } Array.Reverse(BuffList); } if (ParsingRule >= 63 && thing.Subclass[(int)ThingDb.Thing.SubclassBitIndex.WOUNDED_NPC]) { WoundedNPCVoiceSet = br.ReadString(); } if (ParsingRule >= 64) { PoisonLevel = br.ReadByte(); } } return(true); }