Ejemplo n.º 1
0
        public bool PurchasedTreasureMap(int interval, Heightmap.Biome biome, Vector3 position, Vector3 circleOffset)
        {
            if (!DebugMode)
            {
                if (HasPurchasedTreasureMap(interval, biome))
                {
                    EpicLoot.LogError($"Player has already purchased treasure map! (interval={interval} biome={biome})");
                    return(false);
                }
            }
            else if (IntervalOverride != 0)
            {
                interval = IntervalOverride;
            }

            TreasureMaps.Add(new TreasureMapChestInfo()
            {
                Interval            = interval,
                Biome               = biome,
                State               = TreasureMapState.Purchased,
                Position            = position,
                MinimapCircleOffset = circleOffset,
            });

            NumberOfTreasureMapsOrBountiesStarted++;

            return(true);
        }
Ejemplo n.º 2
0
        protected virtual void ActivateStatusEffectAction()
        {
            if (AbilityDef.Action != AbilityAction.StatusEffect)
            {
                EpicLoot.LogError($"Tried to activate a status effect ability ({AbilityDef.ID}) that was not marked as Action=StatusEffect!");
                return;
            }

            var statusEffectName = AbilityDef.ActionParams.FirstOrDefault();

            if (string.IsNullOrEmpty(statusEffectName))
            {
                EpicLoot.LogError($"Tried to activate a status effect ability ({AbilityDef.ID}) but the status effect name param was missing!");
                return;
            }

            var statusEffect = EpicLoot.LoadAsset <StatusEffect>(statusEffectName);

            if (statusEffect == null)
            {
                EpicLoot.LogError($"Tried to activate a status effect ability ({AbilityDef.ID}) but the status effect asset could not be found ({statusEffectName})!");
                return;
            }

            _player.GetSEMan().AddStatusEffect(statusEffect);
        }
Ejemplo n.º 3
0
        private void AddSlainBountyTargetToLedger(BountyInfo bounty, string monsterID, bool isAdd)
        {
            if (!Common.Utils.IsServer())
            {
                return;
            }

            if (BountyLedger == null)
            {
                EpicLoot.LogError("[BountyLedger] Server tried to add kill log to bounty ledger but BountyLedger was null");
                return;
            }

            if (Player.m_localPlayer != null && Player.m_localPlayer.GetPlayerID() == bounty.PlayerID)
            {
                EpicLoot.Log($"[BountyLedger] This player ({bounty.PlayerID}) is the local player");
                return;
            }

            var characterZdos  = ZNet.instance.GetAllCharacterZDOS();
            var playerIsOnline = characterZdos.Select(zdo => zdo.GetLong("playerID")).Any(playerID => playerID == bounty.PlayerID);

            if (playerIsOnline)
            {
                EpicLoot.Log($"[BountyLedger] This player ({bounty.PlayerID}) is connected to server, don't log the kill, they'll get the RPC");
                return;
            }

            BountyLedger.AddKillLog(bounty.PlayerID, bounty.ID, monsterID, isAdd);
            SaveBountyLedger();
        }
Ejemplo n.º 4
0
        public void Setup(Player player, Heightmap.Biome biome, int treasureMapInterval)
        {
            Reinitialize(biome, treasureMapInterval, false, player.GetPlayerID());

            var container = GetComponent <Container>();
            var zdo       = container?.m_nview.GetZDO();

            if (container != null && zdo != null && zdo.IsValid())
            {
                container.GetInventory().RemoveAll();

                zdo.Set("TreasureMapChest.Interval", Interval);
                zdo.Set("TreasureMapChest.Biome", Biome.ToString());
                zdo.Set("creator", player.GetPlayerID());

                var items = LootRoller.RollLootTable(LootTableName, 1, LootTableName, transform.position);
                items.ForEach(item => container.m_inventory.AddItem(item));

                var biomeConfig = AdventureDataManager.Config.TreasureMap.BiomeInfo.Find(x => x.Biome == biome);
                if (biomeConfig?.ForestTokens > 0)
                {
                    container.m_inventory.AddItem("ForestToken", biomeConfig.ForestTokens, 1, 0, 0, "");
                }

                container.Save();
            }
            else
            {
                EpicLoot.LogError($"Trying to set up TreasureMapChest ({biome} {treasureMapInterval}) but there was no Container component!");
            }
        }
Ejemplo n.º 5
0
        public static void CheckAndDoLifeSteal(HitData hit)
        {
            try
            {
                if (!hit.HaveAttacker())
                {
                    return;
                }

                var attacker = hit.GetAttacker() as Humanoid;
                if (attacker == null)
                {
                    return;
                }

                // TODO track actual weapon which made a hit for better life-steal calculation
                var weapon = attacker.GetCurrentWeapon();

                // in case weapon's durability is destroyed after hit?
                // OR in case damage is delayed and player hides weapon - see to-do above
                if (weapon == null || !weapon.IsMagic() || !(attacker is Player player))
                {
                    return;
                }

                var lifeStealMultiplier = 0f;
                ModifyWithLowHealth.Apply(player, MagicEffectType.LifeSteal, effect => lifeStealMultiplier += player.GetTotalActiveMagicEffectValue(effect, 0.01f));

                if (lifeStealMultiplier == 0)
                {
                    return;
                }

                var healOn = hit.m_damage.GetTotalDamage() * lifeStealMultiplier;

                EpicLoot.Log("lifesteal " + healOn);
                var healFromQueue = false;
                if (attacker.IsPlayer())
                {
                    var healingQueue = attacker.GetComponent <HealingQueueMono>();
                    if (healingQueue)
                    {
                        healFromQueue = true;
                        healingQueue.HealRequests.Add(healOn);
                    }
                }

                if (!healFromQueue)
                {
                    // mostly for NPC with lifeSteal weapon
                    attacker.Heal(healOn);
                }
            }
            catch (Exception e)
            {
                EpicLoot.LogError(e.Message);
            }
        }
Ejemplo n.º 6
0
        public static string GetGatedItemID(string itemID, GatedItemTypeMode mode)
        {
            if (string.IsNullOrEmpty(itemID))
            {
                EpicLoot.LogError($"Tried to get gated itemID with null or empty itemID!");
                return(null);
            }

            if (mode == GatedItemTypeMode.Unlimited)
            {
                return(itemID);
            }

            if (!EpicLoot.IsObjectDBReady())
            {
                EpicLoot.LogError($"Tried to get gated itemID ({itemID}) but ObjectDB is not initialized!");
                return(null);
            }

            if (!ItemInfoByID.TryGetValue(itemID, out var info))
            {
                return(itemID);
            }

            var itemName = GetItemName(itemID);

            if (string.IsNullOrEmpty(itemName))
            {
                return(null);
            }

            while (CheckIfItemNeedsGate(mode, itemName))
            {
                //EpicLoot.Log("Yes...");
                var index = info.Items.IndexOf(itemID);
                if (index < 0)
                {
                    // Items list is empty, no need to gate any items from of this type
                    return(itemID);
                }
                if (index == 0)
                {
                    //EpicLoot.Log($"Reached end of gated list. Fallback is ({info.Fallback}), returning ({(string.IsNullOrEmpty(info.Fallback) ? itemID : info.Fallback)}){(string.IsNullOrEmpty(info.Fallback) ? "" : " (fallback)")}");
                    return(string.IsNullOrEmpty(info.Fallback) ? itemID : info.Fallback);
                }

                itemID   = info.Items[index - 1];
                itemName = GetItemName(itemID);
                //EpicLoot.Log($"Next lower tier item is ({itemID})");
            }

            //EpicLoot.Log($"No, return ({itemID})");
            return(itemID);
        }
Ejemplo n.º 7
0
 public static BountyInfo FromBountyID(string ID)
 {
     try
     {
         return(Player.m_localPlayer.GetAdventureSaveData().Bounties.Where(b => b.ID == ID).Single());
     }
     catch
     {
         EpicLoot.LogError($"Bounty {ID} not found");
         return(null);
     }
 }
Ejemplo n.º 8
0
        public static void OnDamaged(Character __instance, HitData hit)
        {
            var attacker = hit.GetAttacker() as Humanoid;

            if (attacker == null)
            {
                return;
            }

            var weapon = attacker.GetCurrentWeapon();

            if (weapon != null && weapon.IsMagic() && weapon.HasMagicEffect(MagicEffectType.Paralyze))
            {
                if (hit.GetTotalDamage() <= 0.0)
                {
                    return;
                }

                var seParalyze = __instance.m_seman.GetStatusEffect("Paralyze") as SE_Paralyzed;
                if (seParalyze == null)
                {
                    seParalyze = __instance.m_seman.AddStatusEffect("Paralyze") as SE_Paralyzed;
                    if (seParalyze == null)
                    {
                        EpicLoot.LogError("Could not add paralyze effect");
                        return;
                    }
                }

                // TODO: this does not work
                var fx = __instance.transform.Find("fx_Lightning(Clone)/Sparcs");
                if (fx != null)
                {
                    var ps   = fx.GetComponent <ParticleSystem>();
                    var main = ps.main;
                    main.startColor = Color.yellow;
                }

                var totalParalyzeTime = weapon.GetMagicItem().GetTotalEffectValue(MagicEffectType.Paralyze);
                seParalyze.Setup(totalParalyzeTime);
            }
        }
Ejemplo n.º 9
0
        public static void OnDamaged(Character __instance, HitData hit)
        {
            if (hit.GetAttacker()?.IsPlayer() != true)
            {
                return;
            }

            var player = (Player)hit.GetAttacker();

            if (player.HasActiveMagicEffect(MagicEffectType.Paralyze))
            {
                if (hit.GetTotalDamage() <= 0.0)
                {
                    return;
                }

                var seParalyze = __instance.m_seman.GetStatusEffect("Paralyze") as SE_Paralyzed;
                if (seParalyze == null)
                {
                    seParalyze = __instance.m_seman.AddStatusEffect("Paralyze") as SE_Paralyzed;
                    if (seParalyze == null)
                    {
                        EpicLoot.LogError("Could not add paralyze effect");
                        return;
                    }
                }

                // TODO: this does not work

                /*var fx = __instance.transform.Find("fx_Lightning(Clone)/Sparcs");
                 * if (fx != null)
                 * {
                 *  var ps = fx.GetComponent<ParticleSystem>();
                 *  var main = ps.main;
                 *  main.startColor = Color.yellow;
                 * }*/

                var totalParalyzeTime = player.GetTotalActiveMagicEffectValue(MagicEffectType.Paralyze);
                seParalyze.Setup(totalParalyzeTime);
            }
        }
Ejemplo n.º 10
0
        public bool AcceptedBounty(BountyInfo bounty, Vector3 spawnPoint, Vector3 offset)
        {
            if (HasAcceptedBounty(bounty.Interval, bounty.ID))
            {
                EpicLoot.LogError($"Player has already accepted bounty! (interval={bounty.Interval} bountyID={bounty.ID})");
                return(false);
            }

            if (bounty.State != BountyState.Available)
            {
                EpicLoot.LogError($"Can only accept available bounties! (interval={bounty.Interval} bountyID={bounty.ID})");
                return(false);
            }

            bounty.State               = BountyState.InProgress;
            bounty.Position            = spawnPoint;
            bounty.MinimapCircleOffset = offset;
            Bounties.Add(bounty);

            return(true);
        }
Ejemplo n.º 11
0
        private static string GetItemName(string itemID)
        {
            var itemPrefab = ObjectDB.instance.GetItemPrefab(itemID);

            if (itemPrefab == null)
            {
                EpicLoot.LogError($"Tried to get gated itemID ({itemID}) but there is no prefab with that ID!");
                return(null);
            }

            var itemDrop = itemPrefab.GetComponent <ItemDrop>();

            if (itemDrop == null)
            {
                EpicLoot.LogError($"Tried to get gated itemID ({itemID}) but its prefab has no ItemDrop component!");
                return(null);
            }

            var item = itemDrop.m_itemData;

            return(item.m_shared.m_name);
        }
Ejemplo n.º 12
0
        public static void Postfix(Container __instance)
        {
            var zdo = __instance.m_nview.GetZDO();

            if (zdo != null)
            {
                var biomeString = zdo.GetString($"{nameof(TreasureMapChest)}.{nameof(TreasureMapChest.Biome)}");
                if (!string.IsNullOrEmpty(biomeString))
                {
                    if (Enum.TryParse(biomeString, out Heightmap.Biome biome))
                    {
                        var interval         = zdo.GetInt("TreasureMapChest.Interval");
                        var hasBeenFound     = zdo.GetBool("TreasureMapChest.HasBeenFound");
                        var owner            = zdo.GetLong("creator");
                        var treasureMapChest = __instance.gameObject.AddComponent <TreasureMapChest>();
                        treasureMapChest.Reinitialize(biome, interval, hasBeenFound, owner);
                    }
                    else
                    {
                        EpicLoot.LogError($"[EpicLoot.Adventure.Container_Awake] Unknown biome: {biomeString}");
                    }
                }
            }
        }