/// <summary> /// Gets monster data. /// </summary> /// <param name="monster">Monster index.</param> /// <returns>DFMonster.</returns> public DFMonster GetMonster(int monster) { // Load the record DFMonster dfMonster = new DFMonster(); if (!LoadMonster(monster, out dfMonster)) { return(dfMonster); } return(dfMonster); }
/// <summary> /// Load monster record into memory and decompose it for use. /// </summary> /// <param name="monster">Monster index.</param> /// <returns>True if successful.</returns> public bool LoadMonster(int monster, out DFMonster dfMonster) { dfMonster = new DFMonster(); // Generate name from index string name = string.Format("ENEMY{0:000}.CFG", monster); // Attempt to load record int index = bsaFile.GetRecordIndex(name); if (index == -1) { return(false); } // Read monster CFG data MonsterCFG cfg = ReadMonsterCFG(index); dfMonster.MonsterCFG = cfg; // Copy name, resists, etc. dfMonster.Name = cfg.Name; dfMonster.ResistanceFlags = cfg.ResistanceFlags; dfMonster.ImmunityFlags = cfg.ImmunityFlags; dfMonster.LowToleranceFlags = cfg.LowToleranceFlags; dfMonster.CriticalWeaknessFlags = cfg.CriticalWeaknessFlags; // Expand special abilities, spell points, etc. int value = cfg.AbilityFlagsAndSpellPointsBitfield; dfMonster.AcuteHearing = ((value & 1) == 1); dfMonster.Athleticism = ((value & 2) == 2); dfMonster.AdrenalineRush = ((value & 4) == 4); dfMonster.NoRegenSpellPoints = ((value & 8) == 8); dfMonster.SunDamage = ((value & 16) == 16); dfMonster.HolyDamage = ((value & 32) == 32); dfMonster.SpellPointsInDark = ((value & 0x00c0) >> 8); dfMonster.SpellPointsInLight = ((value & 0x0300) >> 10); dfMonster.SpellPointMultiplier = ((value & 0x1c00) >> 12); return(true); }
/// <summary> /// Load monster record into memory and decompose it for use. /// </summary> /// <param name="monster">Monster index.</param> /// <returns>True if successful.</returns> public bool LoadMonster(int monster, out DFMonster dfMonster) { dfMonster = new DFMonster(); // Generate name from index string name = string.Format("ENEMY{0:000}.CFG", monster); // Attempt to load file int index = bsaFile.GetRecordIndex(name); if (index == -1) { return(false); } // Setup reader, go right to name as that is all we are reading for now FileProxy memoryFile = bsaFile.GetRecordProxy(index); dfMonster.Name = memoryFile.ReadCString(28, 16); return(true); }
/// <summary> /// Load monster record into memory and decompose it for use. /// </summary> /// <param name="monster">Monster index.</param> /// <returns>True if successful.</returns> public bool LoadMonster(int monster, out DFMonster dfMonster) { dfMonster = new DFMonster(); // Generate name from index string name = string.Format("ENEMY{0:000}.CFG", monster); // Attempt to load record int index = bsaFile.GetRecordIndex(name); if (index == -1) return false; // Read monster CFG data MonsterCFG cfg = ReadMonsterCFG(index); dfMonster.MonsterCFG = cfg; // Copy name, resists, etc. dfMonster.Name = cfg.Name; dfMonster.ResistanceFlags = cfg.ResistanceFlags; dfMonster.ImmunityFlags = cfg.ImmunityFlags; dfMonster.LowToleranceFlags = cfg.LowToleranceFlags; dfMonster.CriticalWeaknessFlags = cfg.CriticalWeaknessFlags; // Expand special abilities, spell points, etc. int value = cfg.AbilityFlagsAndSpellPointsBitfield; dfMonster.AcuteHearing = ((value & 1) == 1); dfMonster.Athleticism = ((value & 2) == 2); dfMonster.AdrenalineRush = ((value & 4) == 4); dfMonster.NoRegenSpellPoints = ((value & 8) == 8); dfMonster.SunDamage = ((value & 16) == 16); dfMonster.HolyDamage = ((value & 32) == 32); dfMonster.SpellPointsInDark = ((value & 0x00c0) >> 8); dfMonster.SpellPointsInLight = ((value & 0x0300) >> 10); dfMonster.SpellPointMultiplier = ((value & 0x1c00) >> 12); return true; }
/// <summary> /// Gets monster data. /// </summary> /// <param name="monster">Monster index.</param> /// <returns>DFMonster.</returns> public DFMonster GetMonster(int monster) { // Load the record DFMonster dfMonster = new DFMonster(); if (!LoadMonster(monster, out dfMonster)) return dfMonster; return dfMonster; }