Exemple #1
0
            public override TalentEntry ConvertTo(byte[] rawData, ref int id)
            {
                var talent = new TalentEntry();

                id = (int)(talent.Id = (TalentId)GetUInt32(rawData, 0));

                var treeId = (TalentTreeId)GetUInt32(rawData, 1);

                talent.Tree = TalentTrees.Get((uint)treeId);

                if (talent.Tree == null)
                {
                    return(null);
                }

                talent.Row = GetUInt32(rawData, 2);
                talent.Col = GetUInt32(rawData, 3);

                var  abilities = new List <Spell>(5);
                uint spellId;

                for (int i = 0; i < 9; i++)
                {
                    spellId = GetUInt32(rawData, i + 4);

                    // There are talents linking to invalid spells, eg Dirty Tricks, Rank 3
                    Spell spell;
                    if (spellId == 0 || (spell = SpellHandler.Get(spellId)) == null)
                    {
                        break;
                    }
                    if (spell.IsTeachSpell)
                    {
                        spell = spell.GetEffectsWhere(effect => effect.TriggerSpell != null)[0].TriggerSpell;
                    }

                    if (spell != null)
                    {
                        abilities.Add(spell);
                    }
                    else
                    {
                        log.Warn("Talent has invalid Spell: {0} ({1})", talent.Id, spellId);
                    }
                }
                talent.Spells = abilities.ToArray();

                talent.RequiredId   = (TalentId)GetUInt32(rawData, 13);
                talent.RequiredRank = GetUInt32(rawData, 16);

                return(talent);
            }
Exemple #2
0
            public override TalentEntry ConvertTo(byte[] rawData, ref int id)
            {
                TalentEntry talentEntry = new TalentEntry();

                id = (int)(talentEntry.Id = (TalentId)GetUInt32(rawData, 0));
                TalentTreeId uint32_1 = (TalentTreeId)GetUInt32(rawData, 1);

                talentEntry.Tree = TalentTrees.Get((uint)uint32_1);
                if (talentEntry.Tree == null)
                {
                    return(null);
                }
                talentEntry.Row = GetUInt32(rawData, 2);
                talentEntry.Col = GetUInt32(rawData, 3);
                List <Spell> spellList = new List <Spell>(5);

                for (int index = 0; index < 9; ++index)
                {
                    uint  uint32_2 = GetUInt32(rawData, index + 4);
                    Spell triggerSpell;
                    if (uint32_2 != 0U && (triggerSpell = SpellHandler.Get(uint32_2)) != null)
                    {
                        if (triggerSpell.IsTeachSpell)
                        {
                            triggerSpell =
                                triggerSpell.GetEffectsWhere(
                                    effect => effect.TriggerSpell != null)[0].TriggerSpell;
                        }
                        if (triggerSpell != null)
                        {
                            spellList.Add(triggerSpell);
                        }
                        else
                        {
                            log.Warn("Talent has invalid Spell: {0} ({1})", talentEntry.Id,
                                     uint32_2);
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                talentEntry.Spells       = spellList.ToArray();
                talentEntry.RequiredId   = (TalentId)GetUInt32(rawData, 13);
                talentEntry.RequiredRank = GetUInt32(rawData, 16);
                return(talentEntry);
            }