Example #1
0
        public bool IsValid(CharacterDrop.Drop drop, CharacterDropItemConfiguration config, Character character)
        {
            if (config.ConditionKilledWithStatus.Value.Length > 0)
            {
                var statuses = config.ConditionKilledWithStatus.Value.SplitByComma();

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

                var lastStatusRecord = RecordLastStatus.GetLastStatus(character);

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

#if DEBUG
                Log.LogTrace($"Looking for statuses '{config.ConditionKilledWithStatus}' among '{lastStatusRecord.Statuses.Join()}'");
#endif

                if (statuses.Any(x => lastStatusRecord.HasStatus(x)))
                {
                    return(true);
                }

                Log.LogTrace($"{nameof(ConditionKilledWithStatus)}: Disabling drop {drop.m_prefab.name} due to not finding any of the required statuses in last hit.");
                return(false);
            }

            return(true);
        }
        public bool ShouldFilter(CharacterDrop.Drop drop, DropExtended dropExtended, CharacterDrop characterDrop)
        {
            if (!string.IsNullOrEmpty(dropExtended.Config.ConditionGlobalKeys.Value))
            {
                var requiredKeys = dropExtended.Config.ConditionGlobalKeys.Value.SplitByComma();

                if (requiredKeys.Count > 0)
                {
                    bool foundRequiredKey = false;

                    foreach (var key in requiredKeys)
                    {
                        foundRequiredKey = ZoneSystem.instance.GetGlobalKey(key);

                        if (foundRequiredKey)
                        {
                            break;
                        }
                    }

                    if (!foundRequiredKey)
                    {
                        Log.LogTrace($"{nameof(dropExtended.Config.ConditionGlobalKeys)}: Disabling drop {drop.m_prefab.name} due to not finding any of the requires global keys '{dropExtended.Config.ConditionGlobalKeys.Value}'.");

                        return(true);
                    }
                }
            }

            return(false);
        }
Example #3
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);
        }
Example #4
0
        public bool ShouldFilter(CharacterDrop.Drop drop, DropExtended dropExtended, CharacterDrop characterDrop)
        {
            var character = CharacterCache.GetCharacter(characterDrop);

            int minLevel = dropExtended.Config.ConditionMinLevel.Value;

            if (minLevel >= 0 && character is not null)
            {
                if (character.GetLevel() < minLevel)
                {
                    Log.LogTrace($"{nameof(dropExtended.Config.ConditionMinLevel)}: Disabling drop {drop.m_prefab.name} due to level {character.GetLevel()} being below limit {minLevel}.");

                    return(true);
                }
            }

            int maxLevel = dropExtended.Config.ConditionMaxLevel.Value;

            if (maxLevel >= 0 && character is not null)
            {
                if (character.GetLevel() > maxLevel)
                {
                    Log.LogTrace($"{nameof(dropExtended.Config.ConditionMaxLevel)}: Disabling drop {drop.m_prefab.name} due to level {character.GetLevel()} being above limit {maxLevel}.");

                    return(true);
                }
            }

            return(false);
        }
        public bool ShouldFilter(CharacterDrop.Drop drop, DropExtended dropExtended, CharacterDrop characterDrop)
        {
            var envMan = EnvMan.instance;

            if (dropExtended.Config.ConditionNotDay.Value && envMan.IsDay())
            {
                Log.LogTrace($"{nameof(dropExtended.Config.ConditionNotDay)}: Disabling drop {drop.m_prefab.name} due to time of day.");

                return(true);
            }

            if (dropExtended.Config.ConditionNotAfternoon.Value && envMan.IsAfternoon())
            {
                Log.LogTrace($"{nameof(dropExtended.Config.ConditionNotAfternoon)}: Disabling drop {drop.m_prefab.name} due to time of day.");

                return(true);
            }

            if (dropExtended.Config.ConditionNotNight.Value && envMan.IsNight())
            {
                Log.LogTrace($"{nameof(dropExtended.Config.ConditionNotNight)}: Disabling drop {drop.m_prefab.name} due to time of day.");

                return(true);
            }

            return(false);
        }
        public static bool ValidConditionNotCreatureStates(CharacterDrop.Drop drop, DropExtended extended, Character character)
        {
            if (extended.Config.ConditionNotCreatureStates.Value.Length > 0)
            {
                var states = extended.Config.ConditionNotCreatureStates.Value.SplitByComma();

                if (states.Count == 0)
                {
#if DEBUG
                    Log.LogDebug("No conditions for not having a creature state were found.");
#endif

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

                if (states.Any(x => HasState(character, x)))
                {
                    Log.LogTrace($"{nameof(extended.Config.ConditionNotCreatureStates)}: Disabling drop {drop.m_prefab.name} due to forbidden creature state.");
                    return(false);
                }
            }

            return(true);
        }
        public bool ShouldFilter(CharacterDrop.Drop drop, DropExtended dropExtended, CharacterDrop characterDrop)
        {
            if (!string.IsNullOrEmpty(dropExtended.Config.ConditionBiomes.Value))
            {
                var character = CharacterCache.GetCharacter(characterDrop);

                var biomes = dropExtended.Config.ConditionBiomes.Value.Split(new[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries);

                var currentBiome        = WorldGenerator.instance.GetBiome(character.GetCenterPoint()).ToString().ToUpperInvariant();
                var currentBiomeCleaned = currentBiome.ToUpperInvariant();

                if (biomes.Length > 0)
                {
                    bool foundBiome = biomes.Any(x => x.Trim().ToUpperInvariant() == currentBiome);

                    if (!foundBiome)
                    {
                        Log.LogTrace($"{nameof(dropExtended.Config.ConditionBiomes)}: Disabling drop {drop.m_prefab.name} due to biome {currentBiome} not being in required list.");

                        return(true);
                    }
                }
            }

            return(false);
        }
Example #8
0
        public bool ShouldFilter(CharacterDrop.Drop drop, DropExtended extended, CharacterDrop characterDrop)
        {
            if (extended?.Config?.Subsections is null)
            {
                return(false);
            }

            var character = CharacterCache.GetCharacter(characterDrop);

            if (!character.IsBoss())
            {
                return(false);
            }

            if (extended.Config.Subsections.TryGetValue(CharacterDropModConfigCLLC.ModName, out Config config) && config is CharacterDropModConfigCLLC cllcConfig)
            {
                if (!ValidConditionBossAffix(drop, cllcConfig, character))
                {
                    return(true);
                }

                if (!ValidConditionNotBossAffix(drop, cllcConfig, character))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #9
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);
        }
        public static DropExtended GetExtension(CharacterDrop.Drop drop)
        {
            if (DropTable.TryGetValue(drop, out DropExtended dropExtended))
            {
                return(dropExtended);
            }

            return(null);
        }
Example #11
0
        public bool ShouldFilter(CharacterDrop.Drop drop, DropExtended extended, CharacterDrop characterDrop)
        {
            if (IsValid(extended?.Config))
            {
                return(false);
            }

            Log.LogTrace($"Filtered drop '{drop}' due to not being within required CLLC world level.");
            return(true);
        }
Example #12
0
    public bool ShouldFilter(CharacterDrop.Drop drop, DropExtended extended, CharacterDrop characterDrop)
    {
        if (drop is null ||
            characterDrop.IsNull() ||
            extended?.Config is null)
        {
            return(false);
        }

        var character = CharacterCache.GetCharacter(characterDrop);

        // Ignore if no character is associated with drop.
        if (character.IsNull())
        {
            return(false);
        }

#if DEBUG && VERBOSE
        Log.LogTrace($"[{character.name}] Checking ConditionHitByEntityTypeRecently=" + extended.Config.ConditionHitByEntityTypeRecently.Value);
#endif

        var configTypes = extended.Config.ConditionHitByEntityTypeRecently.Value.SplitByComma();

        List <EntityType> entities;

        if (configTypes.Count == 0)
        {
            // Ignore if there are no entity types for condition to check.
            return(false);
        }
        else if (!configTypes.TryConvertToEnum(out entities))
        {
#if DEBUG
            Log.LogWarning($"[{character.name}] Failed to convert EntityType to enum: " + configTypes.Join());
#endif
            return(false);
        }

        var recentHits = RecordRecentHits.GetRecentHits(character);

#if DEBUG && VERBOSE
        Log.LogTrace($"[{character.name}] Checking recent hits: " + recentHits.Select(x => GetHitterType(x)).Join());
        Log.LogTrace($"[{character.name}] Searching for hits by: " + entities.Join());
#endif

        var match = recentHits.Any(x => entities.Contains(GetHitterType(x)));

        if (!match)
        {
            Log.LogTrace($"Filtered drop '{drop.m_prefab.name}' due not being hit recently by required entity type.");
        }

        return(!match);
    }
Example #13
0
        /// <summary>
        ///     Converts the <see cref="DropConfig">DropConfigs</see> to Valheim style <see cref="CharacterDrop.Drop"/> array.
        /// </summary>
        /// <returns>The Valheim <see cref="CharacterDrop.Drop"/> array</returns>
        public CharacterDrop.Drop[] GetDrops()
        {
            CharacterDrop.Drop[] drops = new CharacterDrop.Drop[DropConfigs.Length];

            for (int i = 0; i < drops.Length; i++)
            {
                drops[i] = DropConfigs[i].GetDrop();
            }

            return(drops);
        }
Example #14
0
        public void CreateDrop()
        {
            var d = new CharacterDrop.Drop();

            d.m_chance          = 1;
            d.m_amountMax       = Level + Key;
            d.m_amountMin       = d.m_amountMax;
            d.m_levelMultiplier = false;
            d.m_prefab          = ZNetScene.instance.GetPrefab("OdinLegacy");
            m_cDrop.m_drops     = new List <CharacterDrop.Drop>();
            Traverse.Create(m_cDrop).Field <bool>("m_dropsEnabled").Value = true;
            m_cDrop.m_drops.Add(d);
        }
        private static void InsertDrops(CharacterDrop instance, CharacterDropItemConfiguration dropConfig)
        {
            //Sanity checks
            if (!dropConfig.IsValid())
            {
#if DEBUG
                Log.LogDebug($"Drop config {dropConfig.SectionKey} is not valid or enabled.");
#endif
                return;
            }

            GameObject item = ObjectDB.instance.GetItemPrefab(dropConfig.PrefabName?.Value);

            if (item.IsNull())
            {
                item = ZNetScene.instance.GetPrefab(dropConfig.PrefabName.Value);
            }

            if (item.IsNull())
            {
                Log.LogWarning($"[{dropConfig.SectionKey}]: No item '{dropConfig.PrefabName}' exists");
                return;
            }

            CharacterDrop.Drop newDrop = new CharacterDrop.Drop
            {
                m_prefab          = item,
                m_amountMax       = dropConfig.SetAmountMax.Value,
                m_amountMin       = dropConfig.SetAmountMin.Value,
                m_chance          = dropConfig.SetChanceToDrop.Value / 100,
                m_levelMultiplier = dropConfig.SetScaleByLevel.Value,
                m_onePerPlayer    = dropConfig.SetDropOnePerPlayer.Value,
            };

            DropExtended.Set(newDrop, dropConfig);

            if (!GeneralConfig.AlwaysAppendCharacterDrops.Value)
            {
                int index = dropConfig.Index;

                if (instance.m_drops.Count > index)
                {
                    Log.LogDebug($"[{dropConfig.SectionKey}]: Removing overriden item '{instance.m_drops[index].m_prefab.name}' at index '{index}'.");

                    instance.m_drops.RemoveAt(index);
                }
            }

            Insert(instance, dropConfig, newDrop);
        }
Example #16
0
        public bool ShouldFilter(CharacterDrop.Drop drop, DropExtended extended, CharacterDrop characterDrop)
        {
            if (!characterDrop || characterDrop is null || extended?.Config is null)
            {
                return(false);
            }

            if (IsValid(characterDrop.transform.position, extended.Config))
            {
                return(false);
            }

            Log.LogTrace($"Filtered drop '{drop.m_prefab.name}' due not being within required distance to center of map.");
            return(true);
        }
        public bool ShouldFilter(CharacterDrop.Drop drop, DropExtended extended, CharacterDrop characterDrop)
        {
            var character = CharacterCache.GetCharacter(characterDrop);

            if (!ValidConditionCreatureStates(drop, extended, character))
            {
                return(true);
            }

            if (!ValidConditionNotCreatureStates(drop, extended, character))
            {
                return(true);
            }

            return(false);
        }
Example #18
0
        public bool ShouldFilter(CharacterDrop.Drop drop, DropExtended extended, CharacterDrop characterDrop)
        {
            if (!characterDrop || characterDrop is null || extended?.Config is null)
            {
                return(false);
            }

            var character = CharacterCache.GetCharacter(characterDrop);

            if (IsValid(character, extended.Config))
            {
                return(false);
            }

            Log.LogTrace($"Filtered drop '{drop.m_prefab.name}' due not being killed by required entity type.");
            return(true);
        }
Example #19
0
        public bool ShouldFilter(CharacterDrop.Drop drop, DropExtended dropExtended, CharacterDrop characterDrop)
        {
            if (!characterDrop || characterDrop is null || dropExtended?.Config?.ConditionLocation is null)
            {
                return(false);
            }

            if (string.IsNullOrEmpty(dropExtended.Config.ConditionLocation.Value))
            {
                return(false);
            }

            var character = CharacterCache.GetCharacter(characterDrop);

            var locations = dropExtended.Config.ConditionLocation.Value.SplitByComma(toUpper: true);

            var currentLocation = LocationHelper.FindLocation(character.GetCenterPoint());

            if (locations.Count > 0)
            {
                if (currentLocation is null)
                {
                    Log.LogTrace($"{nameof(dropExtended.Config.ConditionLocation)}: Disabling drop {drop.m_prefab.name} due to not being in required location.");
                    return(true);
                }

                var currentLocationName = currentLocation.LocationName.Trim().ToUpperInvariant();

                if (locations.Any(x => x == currentLocationName))
                {
                    return(false);
                }
                else
                {
                    Log.LogTrace($"{nameof(dropExtended.Config.ConditionLocation)}: Disabling drop {drop.m_prefab.name} due to not being in required location.");
                    return(true);
                }
            }

            return(false);
        }
Example #20
0
        public bool ShouldFilter(CharacterDrop.Drop drop, DropExtended dropExtended, CharacterDrop characterDrop)
        {
            if (!characterDrop || characterDrop is null || dropExtended?.Config is null)
            {
                return(false);
            }

            if (string.IsNullOrEmpty(dropExtended.Config.ConditionKilledByDamageType?.Value))
            {
                return(false);
            }

            var character = CharacterCache.GetCharacter(characterDrop);

            if (ValidConditionKilledByDamageType(drop, dropExtended.Config, character))
            {
                return(false);
            }

            return(true);
        }
Example #21
0
        public bool ShouldFilter(CharacterDrop.Drop drop, DropExtended extended, CharacterDrop characterDrop)
        {
            if (!characterDrop || characterDrop is null || extended?.Config is null)
            {
                return(false);
            }

            if (string.IsNullOrEmpty(extended.Config.ConditionKilledWithStatus?.Value))
            {
                return(false);
            }

            var character = CharacterCache.GetCharacter(characterDrop);

            if (IsValid(drop, extended.Config, character))
            {
                return(false);
            }

            return(true);
        }
        public bool ShouldFilter(CharacterDrop.Drop drop, DropExtended extended, CharacterDrop characterDrop)
        {
            if (!extended.Config.Subsections.TryGetValue(CharacterDropModConfigSpawnThat.ModName, out Config modConfig))
            {
                return(false);
            }

            var config = modConfig as CharacterDropModConfigSpawnThat;

            if (config is null || string.IsNullOrWhiteSpace(config.ConditionTemplateId.Value))
            {
                return(false);
            }

            var character = CharacterCache.GetCharacter(characterDrop);

            if (!character || character is null)
            {
                return(false);
            }

            var zdo = ZdoCache.GetZDO(character.gameObject);

            if (zdo is null)
            {
                return(false);
            }

            var templateId = zdo.GetString(SpawnModifierSetTemplateId.ZdoFeature, null);

            var configTemplateIds = config.ConditionTemplateId.Value.SplitByComma();

            if (!configTemplateIds.Any(x => x == templateId))
            {
                Log.LogTrace($"{nameof(config.ConditionTemplateId)}: Disabling drop {drop.m_prefab.name} due to not having required spawn template id {config.ConditionTemplateId.Value}.");
                return(true);
            }

            return(false);
        }
        public bool ShouldFilter(CharacterDrop.Drop drop, DropExtended extended, CharacterDrop characterDrop)
        {
            if (drop is null || extended is null || !characterDrop || characterDrop is null)
            {
                return(false);
            }

            if (string.IsNullOrEmpty(extended.Config.ConditionFaction.Value))
            {
                return(false);
            }

            var character = CharacterCache.GetCharacter(characterDrop);

            if (!character || character is null)
            {
                return(false);
            }

            var characterFaction = character.GetFaction();

            var requiredFactions = extended.Config.ConditionFaction.Value.SplitByComma();

            foreach (var requiredFaction in requiredFactions)
            {
                if (Enum.TryParse(requiredFaction, true, out Character.Faction faction))
                {
                    if (characterFaction == faction)
                    {
                        return(false);
                    }
                }
            }

            Log.LogTrace($"{nameof(extended.Config.ConditionFaction)}: Disabling drop {drop.m_prefab.name} due to {characterFaction} not being in required list.");
            return(true);
        }
Example #24
0
        public bool ShouldFilter(CharacterDrop.Drop drop, DropExtended dropExtended, CharacterDrop characterDrop)
        {
            if (!string.IsNullOrEmpty(dropExtended.Config.ConditionEnvironments.Value))
            {
                var envMan     = EnvMan.instance;
                var currentEnv = envMan.GetCurrentEnvironment();

                var environments = dropExtended.Config.ConditionEnvironments.Value.SplitByComma(true);

                if (environments.Count > 0)
                {
                    var requiredSet = new HashSet <string>(environments);

                    if (!requiredSet.Contains(currentEnv.m_name.Trim().ToUpperInvariant()))
                    {
                        Log.LogTrace($"{nameof(dropExtended.Config.ConditionEnvironments)}: Disabling drop {drop.m_prefab.name} due to environment {currentEnv.m_name} not being in required list.");

                        return(true);
                    }
                }
            }

            return(false);
        }
Example #25
0
        public static bool ValidConditionNotInfusion(CharacterDrop.Drop drop, CharacterDropModConfigCLLC config, Character character)
        {
            if (config.ConditionNotInfusion.Value.Length > 0)
            {
                var states = config.ConditionNotInfusion.Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                if ((states?.Length ?? 0) == 0)
                {
#if DEBUG
                    Log.LogDebug("No conditions for CLLC infusions were found.");
#endif
                    //Skip if we have no states to check. This indicates all are allowed.
                    return(true);
                }

                if (states.Any(x => HasState(character, x)))
                {
                    Log.LogTrace($"{nameof(config.ConditionNotInfusion)}: Disabling drop {drop.m_prefab.name} due finding one of the disabled infusions '{config.ConditionNotInfusion.Value}'.");
                    return(false);
                }
            }

            return(true);
        }
Example #26
0
        internal static void LateLoadDwarf(GameObject clone)
        {
            for (int index = 0; index < clone.transform.childCount; ++index)
            {
                GameObject.Destroy(clone.transform.GetChild(index).gameObject);
            }
            GameObject prefab = ZNetScene.instance.GetPrefab("Haldor");
            GameObject eyePos = (GameObject)null;

            for (int index = 0; index < prefab.transform.childCount; ++index)
            {
                GameObject gameObject = GameObject.Instantiate <GameObject>(prefab.transform.GetChild(index).gameObject, clone.transform);
                gameObject.name = gameObject.name.TrimCloneTag();
                if (gameObject.name == "EyePos")
                {
                    eyePos = gameObject;
                }
                if (gameObject.name == "Pipe")
                {
                    GameObject.Destroy(gameObject);
                }
            }

            VisEquipment component1 = clone.GetComponent <VisEquipment>();

            component1.m_bodyModel          = clone.transform.Find("Haldor/HaldorTheTrader/Haldor").GetComponent <SkinnedMeshRenderer>();
            component1.m_leftHand           = clone.transform.Find("Haldor/HaldorTheTrader/Armature/Root/Hip/Spine0/Spine1/Spine2/Shoulder.l/Upperarm.l/Underarm.l/Wrist.l/Shoulder.l.016/Shoulder.l.017/Shoulder.l.018").GetComponent <Transform>();
            component1.m_rightHand          = clone.transform.Find("Haldor/HaldorTheTrader/Armature/Root/Hip/Spine0/Spine1/Spine2/Shoulder.r/Upperarm.r/Underarm.r/Wrist.r/Middle1.r").GetComponent <Transform>();
            component1.m_helmet             = clone.transform.Find("Haldor/HaldorTheTrader/Armature/Root/Hip/Spine0/Spine1/Spine2/Head/Jaw").GetComponent <Transform>();
            component1.m_backShield         = clone.transform.Find("Haldor/HaldorTheTrader/Armature/Root/Hip/Spine0/Spine1/Spine2/Shoulder.r/Upperarm.r/Underarm.r/Wrist.r/Pipe.001").GetComponent <Transform>();
            component1.m_backMelee          = clone.transform.Find("Haldor/HaldorTheTrader/Armature/Root/Hip/Spine0/Spine1/Spine2/Shoulder.r/Upperarm.r/Underarm.r/Wrist.r/Pipe.001").GetComponent <Transform>();
            component1.m_backTwohandedMelee = clone.transform.Find("Haldor/HaldorTheTrader/Armature/Root/Hip/Spine0/Spine1/Spine2/Shoulder.r/Upperarm.r/Underarm.r/Wrist.r/Pipe.001").GetComponent <Transform>();
            component1.m_backBow            = clone.transform.Find("Haldor/HaldorTheTrader/Armature/Root/Hip/Spine0/Spine1/Spine2/Shoulder.r/Upperarm.r/Underarm.r/Wrist.r/Pipe.001").GetComponent <Transform>();
            component1.m_backTool           = clone.transform.Find("Haldor/HaldorTheTrader/Armature/Root/Hip/Spine0/Spine1/Spine2/Shoulder.r/Upperarm.r/Underarm.r/Wrist.r/Pipe.001").GetComponent <Transform>();
            component1.m_backAtgeir         = clone.transform.Find("Haldor/HaldorTheTrader/Armature/Root/Hip/Spine0/Spine1/Spine2/Shoulder.r/Upperarm.r/Underarm.r/Wrist.r/Pipe.001").GetComponent <Transform>();

            /*
             * component1.m_clothColliders = new CapsuleCollider[5]
             * {
             *   clone.transform.Find("Visual/Armature/Hips/ClothCollider").GetComponent<CapsuleCollider>(),
             *   clone.transform.Find("Visual/Armature/Hips/LeftUpLeg/ClothCollider").GetComponent<CapsuleCollider>(),
             *   clone.transform.Find("Visual/Armature/Hips/RightUpLeg/ClothCollider").GetComponent<CapsuleCollider>(),
             *   clone.transform.Find("Visual/Armature/Hips/Spine/Spine1/ClothCollider (3)").GetComponent<CapsuleCollider>(),
             *   clone.transform.Find("Visual/Armature/Hips/Spine/Spine1/Spine2/ClothCollider (4)").GetComponent<CapsuleCollider>()
             * };
             */

            component1.m_models   = prefab.GetComponent <VisEquipment>().m_models;
            component1.m_isPlayer = true;

            /*
             * CapsuleCollider component2 = clone.GetComponent<CapsuleCollider>();
             * component2.center = prefab.GetComponent<CapsuleCollider>().center;
             * component2.radius = prefab.GetComponent<CapsuleCollider>().radius;
             * component2.height = prefab.GetComponent<CapsuleCollider>().height;
             */
            //clone.GetComponent<Rigidbody>().interpolation = prefab.GetComponent<Rigidbody>().interpolation;
            ZSyncAnimation component3 = clone.GetComponent <ZSyncAnimation>();
            ZSyncAnimation component4 = prefab.GetComponent <ZSyncAnimation>();

            component3.m_syncBools  = new List <string>((IEnumerable <string>)component4.m_syncBools);
            component3.m_syncFloats = new List <string>((IEnumerable <string>)component4.m_syncFloats);
            component3.m_syncInts   = new List <string>((IEnumerable <string>)component4.m_syncInts);
            FootStep component5 = clone.GetComponent <FootStep>();
            FootStep component6 = prefab.GetComponent <FootStep>();

            component5.m_footstepCullDistance = component6.m_footstepCullDistance;
            component5.m_effects.Clear();
            foreach (FootStep.StepEffect effect in component6.m_effects)
            {
                component5.m_effects.Add(effect);
            }
            component5.m_feet[0] = clone.transform.Find("Haldor/HaldorTheTrader/Armature/Root/Hip/UpperLeg.l/LowerLeg.l/Foot.l/Foot2.l");
            component5.m_feet[1] = clone.transform.Find("Haldor/HaldorTheTrader/Armature/Root/Hip/UpperLeg.r/LowerLeg.r/Foot.r/Foot2.r");

            GameObject playerPrefab = RRRLateLoadPrefabs.Clone("Player", "newPlays", true, true);
            Humanoid   component11  = clone.GetComponent <Humanoid>();
            Humanoid   component21  = playerPrefab.GetComponent <Humanoid>();

            component11.m_eye              = eyePos.transform;
            component11.m_crouchSpeed      = component21.m_crouchSpeed;
            component11.m_walkSpeed        = component21.m_walkSpeed;
            component11.m_speed            = component21.m_speed;
            component11.m_turnSpeed        = component21.m_turnSpeed;
            component11.m_runSpeed         = component21.m_runSpeed;
            component11.m_runTurnSpeed     = component21.m_runTurnSpeed;
            component11.m_acceleration     = component21.m_acceleration;
            component11.m_jumpForce        = component21.m_jumpForce;
            component11.m_jumpForceForward = component21.m_jumpForceForward;
            component11.m_swimDepth        = component21.m_swimDepth;
            component11.m_swimSpeed        = component21.m_swimSpeed;

            /*
             * component11.m_damageModifiers = component21.m_damageModifiers.Clone();
             * component11.m_defaultItems = new GameObject[0];
             * component11.m_randomWeapon = new GameObject[0];
             * component11.m_randomArmor = new GameObject[0];
             * component11.m_randomShield = new GameObject[0];
             * component11.m_randomSets = new Humanoid.ItemSet[0];
             */

            Character component  = (Character)clone.GetComponent <Character>();
            BaseAI    component2 = (BaseAI)clone.GetComponent <BaseAI>();

            component.m_name = "Dwarf";
            Character character1 = component;

            character1.m_health = 100;

            /*
             * Character character2 = component;
             * character2.m_acceleration = (float)(character2.m_acceleration * 0.8);
             * Character character3 = component;
             * character3.m_speed = (float)(character3.m_speed * 0.8);
             * Character character4 = component;
             * character4.m_walkSpeed = (float)(character4.m_walkSpeed * 0.8);
             * Character character5 = component;
             * character5.m_runSpeed = (float)(character5.m_runSpeed * 0.7);
             */
            Humanoid humanoid = (Humanoid)component;

            humanoid.m_defaultItems = (GameObject[])new GameObject[1]
            {
                RRRLateLoadPrefabs.Clone("SwordIron", "SwordIron2", true, true)
                //Dwarf.DesignAxeAttack(),
                //Dwarf.DesignAxeAttack2()
            };
            Character.Faction nFaction = Character.Faction.Players;
            humanoid.m_faction    = nFaction;
            humanoid.m_randomSets = null;

            MonsterAI monsterAI = clone.GetComponent <MonsterAI>();

            monsterAI.m_viewRange        = (int)25;
            monsterAI.m_spawnMessage     = "Dwarf, ready!";
            monsterAI.m_deathMessage     = "Oww!";
            monsterAI.m_enableHuntPlayer = false;

            Tameable   tameable   = (Tameable)clone.AddComponent <Tameable>();
            GameObject wolfObject = (GameObject)RRRLateLoadPrefabs.Clone("Wolf", "wolfClone9000", true, true);
            Tameable   wolfTame   = (Tameable)wolfObject.GetComponent <Tameable>();

            tameable.m_fedDuration = wolfTame.m_fedDuration;
            tameable.m_tamingTime  = wolfTame.m_tamingTime;
            tameable.m_commandable = true;

            FootStep   footStep   = (FootStep)clone.AddComponent <FootStep>();
            GameObject greyObject = (GameObject)RRRLateLoadPrefabs.Clone("Player", "playClone", true, true);
            FootStep   greyStep   = (FootStep)greyObject.GetComponent <FootStep>();

            footStep = greyStep;

            CharacterDrop characterDrop = (CharacterDrop)clone.AddComponent <CharacterDrop>();

            characterDrop.m_drops.Clear();
            CharacterDrop.Drop drop = new CharacterDrop.Drop()
            {
                m_prefab = ZNetScene.instance.GetPrefab("Coins")
            };
            characterDrop.m_drops.Add(drop);

            //Dwarf.DesignAppearance(clone);
        }
 public static void Set(CharacterDrop.Drop drop, CharacterDropItemConfiguration config)
 {
     DropTable.GetOrCreateValue(drop).Config = config;
 }
Example #28
0
        internal static void LateLoadGroot(GameObject clone)
        {
            Character component  = (Character)clone.GetComponent <Character>();
            BaseAI    component2 = (BaseAI)clone.GetComponent <BaseAI>();

            component.m_name = "Groot";
            Character character1 = component;

            character1.m_health = 400;
            Character character2 = component;

            character2.m_acceleration = (float)(character2.m_acceleration * 0.8);
            Character character3 = component;

            character3.m_speed = (float)(character3.m_speed * 0.8);
            Character character4 = component;

            character4.m_walkSpeed = (float)(character4.m_walkSpeed * 0.8);
            Character character5 = component;

            character5.m_runSpeed = (float)(character5.m_runSpeed * 0.7);

            Rigidbody rigidbody = clone.GetComponent <Rigidbody>();

            rigidbody.mass = 50;

            Humanoid humanoid = (Humanoid)component;

            humanoid.m_defaultItems = (GameObject[])new GameObject[2]
            {
                Groot.DesignThornAttack(),
                    Groot.DesignPunch(component)
            };
            Character.Faction nFaction = Character.Faction.Players;
            humanoid.m_faction            = nFaction;
            humanoid.m_randomSets         = null;
            humanoid.m_boss               = false;
            humanoid.m_bossEvent          = null;
            humanoid.m_defeatSetGlobalKey = null;

            MonsterAI monsterAI = (MonsterAI)clone.GetComponent <BaseAI>();

            Pathfinding.AgentType npath = Pathfinding.AgentType.HorseSize;
            monsterAI.m_pathAgentType    = npath;
            monsterAI.m_viewRange        = (int)30;
            monsterAI.m_spawnMessage     = "I am Groot";
            monsterAI.m_deathMessage     = "Groot sad";
            monsterAI.m_enableHuntPlayer = false;

            Tameable   tameable   = (Tameable)clone.AddComponent <Tameable>();
            GameObject wolfObject = (GameObject)RRRLateLoadPrefabs.Clone("Wolf", "wolfClone", true, true);
            Tameable   wolfTame   = (Tameable)wolfObject.GetComponent <Tameable>();

            tameable.m_fedDuration = wolfTame.m_fedDuration;
            tameable.m_tamingTime  = wolfTame.m_tamingTime;
            tameable.m_commandable = true;
            tameable.m_tamedEffect = new EffectList();

            FootStep   footStep   = (FootStep)clone.GetComponent <FootStep>();
            GameObject greyObject = (GameObject)RRRLateLoadPrefabs.Clone("Greydwarf_Elite", "grayClone", true, true);
            FootStep   greyStep   = (FootStep)greyObject.GetComponent <FootStep>();

            footStep.m_effects = greyStep.m_effects;

            CharacterDrop characterDrop = (CharacterDrop)clone.GetComponent <CharacterDrop>();

            characterDrop.m_drops.Clear();
            CharacterDrop.Drop drop = new CharacterDrop.Drop()
            {
                m_prefab = ZNetScene.instance.GetPrefab("Wood")
            };
            characterDrop.m_drops.Add(drop);

            GameObject bruteDeath = RRRLateLoadPrefabs.Clone("sfx_greydwarf_elite_death", "vfx_" + clone.name + "_death", true, false);

            humanoid.m_deathEffects.m_effectPrefabs[0].m_prefab = bruteDeath;

            GameObject clone1 = RRRLateLoadPrefabs.Clone("Greydwarf_elite_ragdoll", clone.name + "_ragdoll", true, false);

            ((EffectList.EffectData)((EffectList)component.m_deathEffects).m_effectPrefabs[1]).m_prefab = (GameObject)clone1;

            Groot.DesignAppearance(clone);
        }
        public bool ShouldFilter(CharacterDrop.Drop drop, DropExtended extended, CharacterDrop characterDrop)
        {
            var character = CharacterCache.GetCharacter(characterDrop);
            var inventory = CharacterCache.GetInventory(character);

            if (inventory is null)
            {
#if DEBUG
                Log.LogDebug("No inventory for creature were found.");
#endif

                //No inventory to compare against. Assume that all is allowed.
                return(false);
            }

            var items = extended.Config.ConditionHasItem.Value.SplitByComma(true);

            if (items.Count == 0)
            {
                return(false);
            }

            HashSet <string> inventoryItems;

            if (InstallationManager.RRRInstalled && character.name.StartsWith("RRR"))
            {
                // This is an RRR creature, item names will have been set with a specific pattern.
                inventoryItems = new();

                foreach (var item in inventory.GetAllItems())
                {
                    var firstSection = item.m_dropPrefab.name.IndexOf('@');

                    if (firstSection < 0)
                    {
                        // Unformatted item, add as is
                        inventoryItems.Add(PrepareName(item.m_dropPrefab));
                        continue;
                    }

                    var endSection = item.m_dropPrefab.name.IndexOf('@', firstSection + 1);

                    if (endSection < 0)
                    {
                        inventoryItems.Add(CleanName(item.m_dropPrefab.name.Substring(firstSection + 1)));
                    }
                    else
                    {
                        inventoryItems.Add(CleanName(item.m_dropPrefab.name.Substring(firstSection + 1, endSection - firstSection - 1)));
                    }
                }
            }
            else
            {
                inventoryItems = inventory
                                 .GetAllItems()
                                 .Select(x => x.m_dropPrefab.name.Trim().ToUpperInvariant())
                                 .ToHashSet();
            }

#if DEBUG
            Log.LogTrace("Inventory: " + inventoryItems.Join());
#endif
            if (!items.Any(x => inventoryItems.Contains(x)))
            {
                //No inventory items matched an item in condition list.
                Log.LogTrace($"{nameof(CharacterDropItemConfiguration.ConditionHasItem)}: Found none of the required items '{items.Join()}' in inventory.");

                return(true);
            }

            return(false);
        }
        private static void CarryExtended(List <KeyValuePair <GameObject, int> > dropItems, CharacterDrop.Drop drop, CharacterDrop characterDrop)
        {
            try
            {
                if (dropItems is null)
                {
#if DEBUG
                    Log.LogWarning("Unable to carry drop due to dropitems being null.");
#endif
                }

                if (drop is null)
                {
#if DEBUG
                    Log.LogWarning($"Unable to carry drop due to being null for {characterDrop}.");
#endif
                    return;
                }

                var extended = DropExtended.GetExtension(drop);

                if (extended is not null && dropItems is not null)
                {
#if DEBUG
                    Log.LogDebug($"Carrying configs for drop {extended.Config.SectionKey}:{characterDrop.GetHashCode()}");
                    Log.LogDebug($"Carrying configs for drop {drop.m_prefab.name}");
#endif
                    TempDropListCache.SetDrop(characterDrop, dropItems.Count - 1, extended);
                }

#if DEBUG
                else if (dropItems is null)
                {
                    Log.LogDebug("Disregard. No items to carry");
                    //Log.LogDebug($"Carrying configs for drop {drop.m_prefab.name}");
                }
                else if (extended is null)
                {
                    Log.LogDebug($"Disregard. No config to carry for item {drop}:{(drop.m_prefab.IsNull() ? "" : drop.m_prefab.name)}");
                }
#endif
            }