public static void Postfix(InventoryGui __instance)
 {
     if (__instance.m_craftRecipe == null)
     {
         RunicPower.StopCraftingAll(false);
     }
 }
        public static bool Prefix(InventoryGui __instance, Player player)
        {
            // if it's not a rune, do the normal flow
            var data = __instance.m_craftRecipe?.m_item?.m_itemData?.GetRuneData();

            if (data == null)
            {
                RunicPower.StopCraftingAll(false);
                return(true);
            }
            // if the player does not have the requeriments, do the normal flow
            var qualityLevel = 1;

            if (!player.HaveRequirements(__instance.m_craftRecipe, discover: false, qualityLevel) && !player.NoCostCheat())
            {
                RunicPower.StopCraftingAll(false);
                return(true);
            }
            // getting hte spell inventory
            var inv = SpellsBar.invBarGrid.m_inventory;

            // if there is not an 'empty' slot, do the normal flow
            if (!inv.HaveEmptySlot())
            {
                RunicPower.StopCraftingAll(false);
                return(true);
            }

            var        craftItem = __instance.m_craftRecipe.m_item;
            GameObject go        = Object.Instantiate(craftItem.gameObject);
            ItemDrop   item      = go.GetComponent <ItemDrop>();

            item.m_itemData.m_stack       = __instance.m_craftRecipe.m_amount;
            item.m_itemData.m_quality     = qualityLevel;
            item.m_itemData.m_variant     = __instance.m_craftVariant;
            item.m_itemData.m_durability  = item.m_itemData.GetMaxDurability();
            item.m_itemData.m_crafterID   = player.GetPlayerID();
            item.m_itemData.m_crafterName = player.GetPlayerName();

            var crafted = inv.AddItem(item.m_itemData);

            if (crafted)
            {
                if (!player.NoCostCheat())
                {
                    player.ConsumeResources(__instance.m_craftRecipe.m_resources, qualityLevel);
                }
                __instance.UpdateCraftingPanel();
            }
            // displaying some effects
            CraftingStation currentCraftingStation = Player.m_localPlayer.GetCurrentCraftingStation();
            var             effs = (currentCraftingStation != null) ? currentCraftingStation.m_craftItemDoneEffects : __instance.m_craftItemDoneEffects;

            effs.Create(player.transform.position, Quaternion.identity);

            Game.instance.GetPlayerProfile().m_playerStats.m_crafts++;
            Gogan.LogEvent("Game", "Crafted", __instance.m_craftRecipe.m_item.m_itemData.m_shared.m_name, qualityLevel);

            return(false);
        }
 public static void Postfix(InventoryGui __instance, Player player, float dt)
 {
     if (__instance.m_craftTimer == -1f && __instance.m_craftRecipe != null)
     {
         __instance.m_craftTimer = -0.5f;
         RunicPower.TryCraftingMore();
     }
 }
        public static void Prefix(InventoryGui __instance)
        {
            if (!RunicPower.configRanksTabEnabled.Value)
            {
                return;
            }

            RunicPower.onTabPressed(0, false);
        }
Пример #5
0
 public static void Prefix(Player __instance)
 {
     try {
         __instance.ExtendedPlayer(true).Save();
         RunicPower.Log("Spellsbar saved!");
     } catch (Exception) {
         RunicPower.Log("Failed to save Spellsbar!");
     };
 }
Пример #6
0
        private static bool Prefix(ref string __result, ItemDrop.ItemData item, int qualityLevel, bool crafting)
        {
            var data = item.GetRuneData();

            if (data == null)
            {
                return(true);
            }

            var rune = RunicPower.GetStaticRune(data);

            __result = rune.GetTooltip(item);

            return(false);
        }
        public static StatusEffect_Extended ExtendedStatusEffect(this StatusEffect __instance, bool create = false)
        {
            var key = __instance.GetInstanceID().ToString();

            if (key == null)
            {
                return(null);
            }
            var ext = mapping.ContainsKey(key) ? mapping[key] : null;

            if (ext == null && create)
            {
                mapping[key] = ext = new StatusEffect_Extended();
                RunicPower.Debug("ExtendedStatusEffect: " + mapping.Count);
            }
            return(ext);
        }
        public static void SetRuneByKey(string key, RuneData data)
        {
            if (key == null)
            {
                return;
            }
            var ext = mapping.ContainsKey(key) ? mapping[key] : null;

            if (ext == null)
            {
                mapping[key] = ext = new ItemDropData_Extended();
                if (!key.Contains("(Clone)"))
                {
                    mapping[key + "(Clone)"] = ext;
                }
                RunicPower.Debug("ExtendedItemDrop: " + mapping.Count);
            }
            ext.rune = data;
        }
Пример #9
0
        public static void AddRunicEffect(this SEMan __instance, string name, Player caster, string dsbuffs, bool resetTime)
        {
            // getting the rune data of this runic effect
            var data = RunicPower.GetRuneData(name);

            // if there is none, stop here
            if (data == null)
            {
                return;
            }
            // checking if the target already has this effect
            var currentEffect = __instance.m_statusEffects.Find(se => se.GetRune()?.data.core == data.core);

            // if it does
            if (currentEffect != null)
            {
                var currentRune = currentEffect.GetRune();
                // and its rank is greater than the one we're trying to apply
                if (currentRune.data.rank > data.rank)
                {
                    // stop here. we won't replace the buff with a worse version of it!
                    return;
                }
                else
                {
                    // if the current rune is of equal or lower rank, let's remove it so it can be reapplied
                    __instance.RemoveStatusEffect(currentEffect, true);
                }
            }
            // preparing a new effect
            var rune   = RunicPower.CreateRunicEffect(name, caster, dsbuffs);
            var effect = rune?.statusEffect;

            // and adding it to the player
            if (effect != null)
            {
                SetTempRune(effect, rune);
                __instance.AddStatusEffect(effect);
                UnsetTemp();
            }
        }
 public static void Prefix(InventoryGui __instance, int index, bool center)
 {
     RunicPower.ClearCache();
 }
 public static void Postfix(InventoryGui __instance)
 {
     SpellsBar.CreateInventoryBar(__instance);
     RunicPower.CreateCraftAllButton(__instance);
     RunicPower.CreateRankTabs(__instance);
 }
 public static void Prefix(InventoryGui __instance)
 {
     RunicPower.StopCraftingAll(false);
 }
Пример #13
0
        public void Cast()
        {
            // letting everyone knows the caster used the rune power

            RunicPower.AddCooldown(data.name, GetCooldown());

            var cfgMessage = RunicPower.configCastingMessage.Value;
            var message    = data.name + "!";

            if (cfgMessage == RunicPower.CastingMessage.GLOBAL)
            {
                Chat.instance.SendText(Talker.Type.Shout, message);
            }
            if (cfgMessage == RunicPower.CastingMessage.NORMAL)
            {
                Chat.instance.SendText(Talker.Type.Normal, message);
            }
            if (cfgMessage == RunicPower.CastingMessage.SELF)
            {
                Chat.instance.AddInworldText(caster.gameObject, caster.GetPlayerID(), caster.GetHeadPoint(), Talker.Type.Normal, caster.name, message);
            }

            // get the effects
            var custom = data.fxcustom;

            if (data.type == "Buff")
            {
                ExecFX(RuneData.genericVFX);
                ExecFX(RuneData.genericSFX);
            }
            else
            {
                ExecFX(data.vfx);
                ExecFX(data.sfx);
            }

            // casting RECALL

            // getting the archetype skill Id and adding experience to it
            if (data.archetype != "Generic")
            {
                AddExperience(data.rank);
                RunicPower.ClearCache();
            }

            // casting RECALL
            if (custom == "recall")
            {
                var prof     = Game.instance.GetPlayerProfile();
                var location = prof.GetCustomSpawnPoint();
                if (location != null)
                {
                    this.caster.TeleportTo(location, this.caster.gameObject.transform.rotation, true);
                }
                return;
            }

            if (data.effect == null)
            {
                return;
            }

            if (data.effect.target == "projectile")
            {
                var attack = new Attack();
                attack.m_character      = caster;
                attack.m_attackHeight   = 2f;
                attack.m_attackRange    = 1f;
                attack.m_attackHitNoise = 0;
                attack.m_projectileVel  = data.projectile.speed;
                attack.GetProjectileSpawnPoint(out var spawnPoint, out var aimDir);
                aimDir = GameCamera.instance.transform.forward;
                var        hitData    = new HitData();
                var        projPrefab = ZNetScene.instance.GetPrefab(data.projectile.name);
                GameObject projGo     = UnityEngine.Object.Instantiate(projPrefab, spawnPoint, Quaternion.LookRotation(aimDir));
                var        proj       = projGo.GetComponent <IProjectile>() as Projectile;
                proj.m_gravity = 0f;
                proj.m_ttl     = (float)data.projectile.duration;
                proj.SetRune(this);
                proj.Setup(attack.m_character, aimDir * attack.m_projectileVel, attack.m_attackHitNoise, hitData, null);
            }
            else
            {
                // getting the targets
                var semans = GetTargetsAroundCharacter(data.effect.target, this.caster, GetSkilledRange(data.rangeAOE));
                foreach (var seman in semans)
                {
                    ApplyEffectOnSeman(seman);
                }
            }
        }