private static void ApplySkillBonus(SkillBonuses attrs, int min, int max, int index, int low, int high) { SkillName[] possibleSkills = (attrs.Owner is Spellbook ? m_PossibleSpellbookSkills : m_PossibleBonusSkills); int count = possibleSkills.Length; SkillName sk, check; double bonus; bool found; do { found = false; sk = possibleSkills[Utility.Random(count)]; for (int i = 0; !found && i < 5; ++i) { found = (attrs.GetValues(i, out check, out bonus) && check == sk); } } while (found); attrs.SetValues((short)index, sk, (short)Scale(min, max, low, high)); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); if (version < 2) { SkillName old; double val; SkillBonuses.GetValues(0, out old, out val); for (int i = 0; i < m_PossibleBonusSkills.Length; i++) { if (old == m_PossibleBonusSkills[i]) { return; } } SkillBonuses.SetValues(0, m_PossibleBonusSkills[Utility.Random(m_PossibleBonusSkills.Length)], (Utility.Random(4) == 0 ? 10.0 : 5.0)); } }
private static void ApplySkillBonus( SkillBonuses attrs, int min, int max, int index, int low, int high ) { SkillName[] possibleSkills = ( attrs.Owner is Spellbook ? m_PossibleSpellbookSkills : m_PossibleBonusSkills ); int count = possibleSkills.Length; SkillName sk, check; double bonus; bool found; do { found = false; sk = possibleSkills[Utility.Random( count )]; for ( int i = 0; !found && i < 5; ++i ) found = ( attrs.GetValues( i, out check, out bonus ) && check == sk ); } while ( found ); attrs.SetValues( (short) index, sk, (short) Scale( min, max, low, high ) ); }