Exemple #1
0
        public static Reaction GetReaction(uint localFaction, uint mobFaction)
        {
            try
            {
                if (mobFaction == 0 && (localFaction == 1 || localFaction == 2))
                {
                    return(Reaction.Neutral);
                }
                WoWFactionTemplate t1 = WoWFactionTemplate.FromId(mobFaction);
                WoWFactionTemplate t2 = WoWFactionTemplate.FromId(localFaction);


                if (t1 == null || t2 == null)
                {
                    return(Reaction.Unknown);
                }
                return(t1.GetReactionTowards(t2));
            }
            catch (Exception exception)
            {
                Logging.WriteError("GetReaction(uint localFaction, uint mobFaction): " + exception);
            }
            return(Reaction.Unknown);
        }
        public Reaction GetReactionTowards(WoWFactionTemplate otherFaction)
        {
            FactionTemplateDbcRecord record  = Record;
            FactionTemplateDbcRecord record2 = otherFaction.Record;

            if ((record2.FightSupport & record.HostileMask) != 0)
            {
                return(Reaction.Hostile);
            }
            if (record.EnemyFactions != null)
            {
                for (int i = 0; i < 4; i++)
                {
                    if (record.EnemyFactions[i] == 0)
                    {
                        break;
                    }
                    if (record.EnemyFactions[i] == record2.FactionId)
                    {
                        return(Reaction.Hostile);
                    }
                }
            }
            if ((record2.FightSupport & record.FriendlyMask) != 0)
            {
                return(Reaction.Friendly);
            }
            if (record.FriendlyFactions != null)
            {
                for (int j = 0; j < 4; j++)
                {
                    if (record.FriendlyFactions[j] == 0)
                    {
                        break;
                    }
                    if (record.FriendlyFactions[j] == record2.FactionId)
                    {
                        return(Reaction.Friendly);
                    }
                }
            }
            if ((record.FightSupport & record2.FriendlyMask) != 0)
            {
                return(Reaction.Friendly);
            }
            if (record2.FriendlyFactions != null)
            {
                for (int k = 0; k < 4; k++)
                {
                    if (record2.FriendlyFactions[k] == 0)
                    {
                        break;
                    }
                    if (record2.FriendlyFactions[k] == record.FactionId)
                    {
                        return(Reaction.Friendly);
                    }
                }
            }
            uint num4 = (uint)((~(record.FactionFlags >> 12) & 2) | 1);

            return((Reaction)num4);
        }