Esempio n. 1
0
        public bool ValidConditionKilledBySkillType(CharacterDrop.Drop drop, CharacterDropItemConfiguration config, Character character)
        {
            if (config.ConditionKilledBySkillType.Value.Length > 0)
            {
                var skillTypes = config.ConditionKilledBySkillType.Value.SplitByComma();

                if (skillTypes.Count == 0)
                {
                    //Skip if we have no states to check. This indicates all are allowed.
                    return(true);
                }

                var lastHit = RecordLastHit.GetLastHit(character);

                if (lastHit is null)
                {
                    Log.LogTrace($"{nameof(ConditionKilledBySkillType)}: Disabling drop {drop.m_prefab.name} due to not finding any last hit data.");
                    return(false);
                }

                var convertedSkills = ConvertToSkillType(skillTypes);

#if DEBUG
                Log.LogTrace($"Searching for skill type '{lastHit.SkillType}' among required types '{config.ConditionKilledBySkillType.Value}'");
#endif

                if (!convertedSkills.Any(x => x == lastHit.SkillType))
                {
                    Log.LogTrace($"{nameof(ConditionKilledBySkillType)}: Disabling drop {drop.m_prefab.name} due to not finding any of the required skill types in last hit.");
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 2
0
        public bool ValidConditionKilledByDamageType(CharacterDrop.Drop drop, CharacterDropItemConfiguration config, Character character)
        {
            if (config.ConditionKilledByDamageType.Value.Length > 0)
            {
                var causes = config.ConditionKilledByDamageType.Value.SplitByComma();

                if (causes.Count == 0)
                {
                    //Skip if we have no states to check. This indicates all are allowed.
                    return(true);
                }

                var lastHit = RecordLastHit.GetLastHit(character);

                if (lastHit is null)
                {
                    Log.LogTrace($"{nameof(config.ConditionKilledByDamageType)}: Disabling drop {drop.m_prefab.name} due to not finding any last hit data.");
                    return(false);
                }

                var causesDamageType = ConvertToBitmask(causes);

#if DEBUG
                Log.LogTrace($"Searching for damage types '{causes}' as {causesDamageType} among '{lastHit.DamageType}' with result '{causesDamageType & lastHit.DamageType}'");
#endif

                if ((causesDamageType & lastHit.DamageType) == 0)
                {
                    Log.LogTrace($"{nameof(config.ConditionKilledByDamageType)}: Disabling drop {drop.m_prefab.name} due to not finding any of the required damage types in last hit.");
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 3
0
        public bool IsValid(Character character, CharacterDropItemConfiguration config)
        {
            if (character is null)
            {
#if DEBUG
                Log.LogTrace("[ConditionKilledByEntityType] No character found.");
#endif
                return(true);
            }

            if (string.IsNullOrWhiteSpace(config.ConditionKilledByEntityType.Value))
            {
                return(true);
            }

            var requiredEntityTypes = ConvertToEnum(config.ConditionKilledByEntityType.Value.SplitByComma());

            if (requiredEntityTypes.Count == 0)
            {
#if DEBUG
                Log.LogTrace("[ConditionKilledByEntityType] No valid requirements found.");
#endif

                return(true);
            }

            var lastHit = RecordLastHit.GetLastHit(character);

            if (lastHit is null)
            {
#if DEBUG
                Log.LogTrace($"{nameof(config.ConditionKilledByDamageType)}: Disabling drop {config.SectionKey} due to not finding any last hit data.");
#endif
                return(false);
            }

            EntityType killedBy = EntityType.Other;

            if (lastHit.Hit.HaveAttacker())
            {
                GameObject attacker = ZNetScene.instance.FindInstance(lastHit.Hit.m_attacker);

                var attackerCharacter = ComponentCache.GetComponent <Character>(attacker);

                if (attackerCharacter is not null)
                {
                    if (attackerCharacter.IsPlayer())
                    {
                        killedBy = EntityType.Player;
                    }
                    else
                    {
                        killedBy = EntityType.Creature;
                    }
                }
            }

#if DEBUG
            Log.LogTrace($"[ConditionKilledByEntityType] Killed by '{killedBy}'");
#endif


            return(requiredEntityTypes.Any(x => x == killedBy));
        }