Exemplo n.º 1
0
        public override void SetStaticDefaults()
        {
            base.SetStaticDefaults();
            DisplayName.SetDefault("Witch Clicker");

            ClickEffect.WildMagic = ClickerSystem.RegisterClickEffect(mod, "WildMagic", "Wild Magic", "Randomly acts as any possible click effect", 6, new Color(175, 75, 255, 0), delegate(Player player, Vector2 position, int type, int damage, float knockBack)
            {
                List <string> excluded = new List <string>
                {
                    ClickEffect.WildMagic,
                    ClickEffect.Conqueror
                };

                List <string> allowed = new List <string>();

                foreach (var name in ClickerSystem.GetAllEffectNames())
                {
                    if (!excluded.Contains(name))
                    {
                        allowed.Add(name);
                    }
                }

                if (allowed.Count == 0)
                {
                    return;
                }

                string random = Main.rand.Next(allowed);
                if (ClickerSystem.IsClickEffect(random, out ClickEffect effect))
                {
                    effect.Action?.Invoke(player, position, type, damage, knockBack);
                }
            });
        }
Exemplo n.º 2
0
 /// <summary>
 /// Call in <see cref="ModItem.SetDefaults"/> for a clicker weapon to add effects to it
 /// </summary>
 /// <param name="item">The clicker weapon</param>
 /// <param name="effects">the effect names</param>
 public static void AddEffect(Item item, IEnumerable <string> effects)
 {
     if (ClickerSystem.IsClickerWeapon(item, out ClickerItemCore clickerItem))
     {
         //Check against already added effects
         List <string> list = clickerItem.itemClickEffects;
         foreach (var name in effects)
         {
             if (!string.IsNullOrEmpty(name) && !list.Contains(name))
             {
                 if (ClickerSystem.IsClickEffect(name, out _))
                 {
                     list.Add(name);
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
        public override void SafeSetStaticDefaults()
        {
            DisplayName.SetDefault("sus cicker [sic]");

            ClickerCompatibilityCalls.RegisterClickEffect(mod, "Impostor", "Impostor", "Can mimic any other effect", 3, Color.Red, DoSuspiciousActivitiesEpic);

            foreach (string effect in ClickerCompatibilityCalls.GetAllEffectNames().Where(effect => effect != $"{mod.Name}:Impostor"))
            {
                AvailableEffects.Add(effect);
            }

            void DoSuspiciousActivitiesEpic(Player player, Vector2 position, int type, int damage, float knockBack)
            {
                if (ClickerSystem.IsClickEffect(AvailableEffects[EffectIndex], out ClickEffect effect))
                {
                    effect.Action?.Invoke(player, position, type, damage, knockBack);
                }
            }
        }
Exemplo n.º 4
0
        public override bool AltFunctionUse(Player player)
        {
            if (!(Main.mouseRight && Main.mouseRightRelease))
            {
                return(false);
            }

            EffectIndex++;

            if (EffectIndex >= AvailableEffects.Count)
            {
                EffectIndex = 0;
            }

            if (ClickerSystem.IsClickEffect(AvailableEffects[EffectIndex], out ClickEffect effect))
            {
                CombatText.NewText(player.getRect(), new Color(Main.rand.Next(0, 256), Main.rand.Next(0, 256), Main.rand.Next(0, 256)), $"Selected: {effect.DisplayName}");
            }

            return(true);
        }
Exemplo n.º 5
0
        public override void SetStaticDefaults()
        {
            base.SetStaticDefaults();

            ClickEffect.WildMagic = ClickerSystem.RegisterClickEffect(Mod, "WildMagic", null, null, 6, new Color(175, 75, 255), delegate(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, int type, int damage, float knockBack)
            {
                List <string> excluded = new List <string>
                {
                    ClickEffect.WildMagic,
                    ClickEffect.Conqueror,
                    ClickEffect.AutoClick,
                    ClickEffect.PhaseReach
                };

                List <string> allowed = new List <string>();

                foreach (var name in ClickerSystem.GetAllEffectNames())
                {
                    if (!excluded.Contains(name))
                    {
                        allowed.Add(name);
                    }
                }

                if (allowed.Count == 0)
                {
                    return;
                }

                string random = Main.rand.Next(allowed);
                if (ClickerSystem.IsClickEffect(random, out ClickEffect effect))
                {
                    effect.Action?.Invoke(player, source, position, type, damage, knockBack);
                }
            });
        }
Exemplo n.º 6
0
        public override void ModifyTooltips(Item item, List <TooltipLine> tooltips)
        {
            if (ClickerSystem.IsClickerItem(item))
            {
                Player player        = Main.LocalPlayer;
                var    clickerPlayer = player.GetModPlayer <ClickerPlayer>();
                int    index;

                float alpha = Main.mouseTextColor / 255f;

                if (ClickerConfigClient.Instance.ShowClassTags)
                {
                    index = tooltips.FindIndex(tt => tt.mod.Equals("Terraria") && tt.Name.Equals("ItemName"));
                    if (index != -1)
                    {
                        tooltips.Insert(index + 1, new TooltipLine(mod, "ClickerTag", $"-{LangHelper.GetText("Tooltip.ClickerTag")}-")
                        {
                            overrideColor = Main.DiscoColor
                        });
                    }
                }

                if (isClickerDisplayTotal)
                {
                    index = tooltips.FindIndex(tt => tt.mod.Equals("Terraria") && tt.Name.Equals("Tooltip0"));

                    if (index != -1)
                    {
                        string color = (new Color(252, 210, 44) * alpha).Hex3();
                        tooltips.Add(new TooltipLine(mod, "TransformationText", $"{LangHelper.GetText("Tooltip.TotalClicks")}: [c/{color}:{clickerPlayer.clickerTotal}]"));
                    }
                }

                if (ClickerSystem.IsClickerWeapon(item))
                {
                    TooltipLine tooltip = tooltips.Find(tt => tt.mod.Equals("Terraria") && tt.Name.Equals("Damage"));
                    if (tooltip != null)
                    {
                        string number = tooltip.text.Split(' ')[0];
                        tooltip.text = LangHelper.GetText("Tooltip.ClickDamage", number);
                    }

                    //Show the clicker's effects
                    //Then show ones missing through the players enabled effects (respecting overlap, ignoring the currently held clickers effect if its not the same type)
                    List <string> effects = new List <string>(itemClickEffects);
                    foreach (var name in ClickerSystem.GetAllEffectNames())
                    {
                        if (clickerPlayer.HasClickEffect(name, out ClickEffect effect) && !effects.Contains(name))
                        {
                            if (!(player.HeldItem.type != item.type && player.HeldItem.type != ItemID.None && player.HeldItem.GetGlobalItem <ClickerItemCore>().itemClickEffects.Contains(name)))
                            {
                                effects.Add(name);
                            }
                        }
                    }

                    if (effects.Count > 0)
                    {
                        index = tooltips.FindIndex(tt => tt.mod.Equals("Terraria") && tt.Name.Equals("Knockback"));

                        if (index != -1)
                        {
                            //"Auto Select" key: player.controlTorch

                            var    keys = PlayerInput.CurrentProfile.InputModes[InputMode.Keyboard].KeyStatus[TriggerNames.SmartSelect];
                            string key  = keys.Count == 0 ? null : keys[0];

                            //If has a key, but not pressing it, show the ForMoreInfo text
                            //Otherwise, list all effects

                            bool showDesc = key == null || player.controlTorch;

                            foreach (var name in effects)
                            {
                                if (ClickerSystem.IsClickEffect(name, out ClickEffect effect))
                                {
                                    tooltips.Insert(++index, effect.ToTooltip(clickerPlayer.GetClickAmountTotal(this, name), alpha, showDesc));
                                }
                            }

                            if (!showDesc && ClickerConfigClient.Instance.ShowEffectSuggestion)
                            {
                                //Add ForMoreInfo as the last line
                                index = tooltips.FindLastIndex(tt => tt.mod.Equals("Terraria") && tt.Name.StartsWith("Tooltip"));
                                var ttl = new TooltipLine(mod, "ForMoreInfo", LangHelper.GetText("Tooltip.ForMoreInfo", key))
                                {
                                    overrideColor = Color.Gray
                                };

                                if (index != -1)
                                {
                                    tooltips.Insert(++index, ttl);
                                }
                                else
                                {
                                    tooltips.Add(ttl);
                                }
                            }
                        }
                    }
                }


                if (item.prefix < PrefixID.Count || !ClickerPrefix.ClickerPrefixes.Contains(item.prefix))
                {
                    return;
                }

                int ttindex = tooltips.FindLastIndex(t => (t.mod == "Terraria" || t.mod == mod.Name) && (t.isModifier || t.Name.StartsWith("Tooltip") || t.Name.Equals("Material")));
                if (ttindex != -1)
                {
                    if (radiusBoostPrefix != 0)
                    {
                        TooltipLine tt = new TooltipLine(mod, "PrefixClickerRadius", (radiusBoostPrefix > 0 ? "+" : "") + LangHelper.GetText("Prefix.PrefixClickerRadius.Tooltip", (int)((radiusBoostPrefix / 2) * 100)))
                        {
                            isModifier    = true,
                            isModifierBad = radiusBoostPrefix < 0
                        };
                        tooltips.Insert(++ttindex, tt);
                    }
                    if (radiusBoostPrefix != 0)
                    {
                        TooltipLine tt = new TooltipLine(mod, "PrefixClickBoost", (clickBoostPrefix < 0 ? "" : "+") + LangHelper.GetText("Prefix.PrefixClickBoost.Tooltip", clickBoostPrefix))
                        {
                            isModifier    = true,
                            isModifierBad = clickBoostPrefix > 0
                        };
                        tooltips.Insert(++ttindex, tt);
                    }
                }
            }
        }