public static void ShootBonusProjectiles(Player player, Vector2 position, bool dummy)
        {
            OrchidModPlayer modPlayer = player.GetModPlayer <OrchidModPlayer>();

            if (modPlayer.gamblerSlimyLollipop)
            {
                OrchidModGlobalItem orchidItem = modPlayer.gamblerCardCurrent.GetGlobalItem <OrchidModGlobalItem>();
                if (orchidItem.gamblerCardSets.Contains("Slime") && Main.rand.Next(180) == 0)
                {
                    float scale    = 1f - (Main.rand.NextFloat() * .3f);
                    int   rand     = Main.rand.Next(3) + 1;
                    int   projType = ProjectileType <Gambler.Projectiles.SlimeRainCardProj2>();
                    for (int i = 0; i < rand; i++)
                    {
                        int newProjectile = OrchidModGamblerHelper.DummyProjectile(Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 5f, projType, 15, 0f, player.whoAmI), dummy);
                        Main.projectile[newProjectile].ai[1]     = 1f;
                        Main.projectile[newProjectile].netUpdate = true;
                    }
                }
            }

            for (int l = 0; l < Main.projectile.Length; l++)
            {
                Projectile projectile = Main.projectile[l];
                if (projectile.active && projectile.owner == player.whoAmI)
                {
                    OrchidModGlobalProjectile modProjectile = projectile.GetGlobalProjectile <OrchidModGlobalProjectile>();
                    if (modProjectile.gamblerDummyProj == dummy && modProjectile.gamblerBonusTrigger)
                    {
                        modProjectile.gamblerBonusProjectilesDelegate(player, modPlayer, projectile, modProjectile, dummy);
                    }
                }
            }
        }
Esempio n. 2
0
        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            OrchidModPlayer modPlayer   = player.GetModPlayer <OrchidModPlayer>();
            Item            currentCard = modPlayer.gamblerCardDummy;

            if (OrchidModGamblerHelper.getNbGamblerCards(player, modPlayer) > 0)
            {
                if (player.altFunctionUse == 2 || modPlayer.gamblerCardDummy.type == 0)
                {
                    Main.PlaySound(SoundID.Item64, player.position);
                    OrchidModGamblerHelper.drawDummyCard(player, modPlayer);
                    currentCard = modPlayer.gamblerCardDummy;
                    this.checkStats(currentCard, player, modPlayer);
                    Color floatingTextColor = new Color(255, 200, 0);
                    CombatText.NewText(player.Hitbox, floatingTextColor, modPlayer.gamblerCardDummy.Name);
                    return(false);
                }
            }
            else
            {
                return(false);
            }

            currentCard = modPlayer.gamblerCardDummy;
            this.checkStats(currentCard, player, modPlayer);
            currentCard.GetGlobalItem <OrchidModGlobalItem>().gamblerShootDelegate(player, position, speedX, speedY, type, item.damage, item.knockBack, true);
            return(false);
        }
        public override bool UseItem(Player player)
        {
            OrchidModPlayer modPlayer = player.GetModPlayer <OrchidModPlayer>();

            OrchidModGamblerHelper.removeGamblerChip(100, this.diceCost, player, modPlayer, mod);
            OrchidModGamblerHelper.rollGamblerDice(this.diceID, this.diceDuration, player, modPlayer, mod);
            return(true);
        }
Esempio n. 4
0
 public static void onRespawnGambler(Player player, OrchidModPlayer modPlayer)
 {
     modPlayer.gamblerShuffleCooldown = 0;
     modPlayer.gamblerChips           = 0;
     modPlayer.gamblerRedraws         = 0;
     modPlayer.gamblerUIDisplayTimer  = 0;
     OrchidModGamblerHelper.clearGamblerCardCurrent(player, modPlayer);
     OrchidModGamblerHelper.clearGamblerCardsNext(player, modPlayer);
 }
 public override bool CanUseItem(Player player)
 {
     if (player == Main.player[Main.myPlayer])
     {
         OrchidModPlayer modPlayer = player.GetModPlayer <OrchidModPlayer>();
         Item[]          cards     = modPlayer.gamblerCardsItem;
         int             count     = OrchidModGamblerHelper.getNbGamblerCards(player, modPlayer);
         if (OrchidModGamblerHelper.containsGamblerCard(item, player, modPlayer) || player.altFunctionUse == 2 || count < this.cardRequirement || count >= 20)
         {
             return(false);
         }
         else
         {
             if (OrchidModGamblerHelper.getNbGamblerCards(player, modPlayer) <= 0)
             {
                 bool found = false;
                 for (int i = 0; i < Main.maxInventory; i++)
                 {
                     Item item = Main.LocalPlayer.inventory[i];
                     if (item.type != 0)
                     {
                         OrchidModGlobalItem orchidItem = item.GetGlobalItem <OrchidModGlobalItem>();
                         if (orchidItem.gamblerDeck)
                         {
                             found = true;
                             break;
                         }
                     }
                 }
                 if (!found)
                 {
                     int gamblerDeck = ItemType <Gambler.Decks.GamblerAttack>();
                     player.QuickSpawnItem(gamblerDeck, 1);
                 }
             }
             item.useAnimation = 20;
             item.useTime      = 20;
             for (int i = 0; i < 20; i++)
             {
                 if (cards[i].type == 0)
                 {
                     cards[i] = new Item();
                     cards[i].SetDefaults(item.type, true);
                     OrchidModGamblerHelper.clearGamblerCardCurrent(player, modPlayer);
                     OrchidModGamblerHelper.clearGamblerCardsNext(player, modPlayer);
                     modPlayer.gamblerShuffleCooldown = 0;
                     modPlayer.gamblerRedraws         = 0;
                     OrchidModGamblerHelper.drawGamblerCard(player, modPlayer);
                     return(true);
                 }
             }
             //item.TurnToAir();
         }
     }
     return(base.CanUseItem(player));
 }
Esempio n. 6
0
        public override void HoldItem(Player player)
        {
            OrchidModPlayer modPlayer = player.GetModPlayer <OrchidModPlayer>();

            modPlayer.GamblerDeckInHand = true;
            if (Main.mouseLeft)
            {
                OrchidModGamblerHelper.ShootBonusProjectiles(player, player.Center, true);
            }
        }
Esempio n. 7
0
        public override void HoldItem(Player player)
        {
            OrchidModPlayer modPlayer = player.GetModPlayer <OrchidModPlayer>();

            modPlayer.GamblerDeckInHand     = true;
            modPlayer.gamblerUIFightDisplay = true;
            if (Main.mouseLeft)
            {
                this.checkStats(modPlayer.gamblerCardCurrent, player, modPlayer);
                OrchidModGamblerHelper.ShootBonusProjectiles(player, player.Center, false);
            }
        }
        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            Player             player    = Main.player[projectile.owner];
            OrchidModPlayer    modPlayer = player.GetModPlayer <OrchidModPlayer>();
            OrchidModGlobalNPC modTarget = target.GetGlobalNPC <OrchidModGlobalNPC>();

            if (target.type != NPCID.TargetDummy && this.gamblingChipChance > 0)
            {
                OrchidModGamblerHelper.addGamblerChip(this.gamblingChipChance, player, modPlayer);
            }
            modTarget.gamblerHit = true;
            SafeOnHitNPC(target, damage, knockback, crit, player, modPlayer);
        }
        public override bool CanUseItem(Player player)
        {
            OrchidModPlayer modPlayer = player.GetModPlayer <OrchidModPlayer>();

            if (modPlayer.gamblerChips < this.chipCost || modPlayer.gamblerCardCurrent.type == 0)
            {
                return(false);
            }
            else
            {
                OrchidModGamblerHelper.removeGamblerChip(this.consumeChance, this.chipCost, player, modPlayer, mod);
            }
            return(base.CanUseItem(player));
        }
Esempio n. 10
0
        public override bool CanUseItem(Player player)
        {
            OrchidModPlayer modPlayer = player.GetModPlayer <OrchidModPlayer>();

            if (player.altFunctionUse == 2)
            {
                return(false);
            }
            else
            {
                OrchidModGamblerHelper.clearGamblerCards(player, modPlayer);
                OrchidModGamblerHelper.onRespawnGambler(player, modPlayer);
            }
            return(base.CanUseItem(player));
        }
Esempio n. 11
0
 public static void removeGamblerCard(Item card, Player player, OrchidModPlayer modPlayer)
 {
     if (OrchidModGamblerHelper.containsGamblerCard(card, player, modPlayer))
     {
         bool found = false;
         for (int i = 0; i < 20; i++)
         {
             if (modPlayer.gamblerCardsItem[i].type == card.type)
             {
                 found = true;
             }
             if (found)
             {
                 modPlayer.gamblerCardsItem[i] = new Item();
                 modPlayer.gamblerCardsItem[i].SetDefaults(i == 19 ? 0 : modPlayer.gamblerCardsItem[i + 1].type, true);
             }
         }
     }
 }
Esempio n. 12
0
        public static int getNbGamblerCards(Player player, OrchidModPlayer modPlayer)
        {
            if (modPlayer.gamblerCardsItem.Count() != 20)
            {
                OrchidModGamblerHelper.clearGamblerCards(player, modPlayer);
            }
            int val = 0;

            for (int i = 0; i < 20; i++)
            {
                if (modPlayer.gamblerCardsItem[i].type != 0)
                {
                    val++;
                }
                else
                {
                    return(val);
                }
            }
            return(val);
        }
Esempio n. 13
0
        public static void ShootBonusProjectiles(Player player, Vector2 position, bool dummy)
        {
            OrchidModPlayer modPlayer = player.GetModPlayer <OrchidModPlayer>();

            if (modPlayer.gamblerSlimyLollipop)
            {
                OrchidModGlobalItem orchidItem = modPlayer.gamblerCardCurrent.GetGlobalItem <OrchidModGlobalItem>();
                if (orchidItem.gamblerCardSets.Contains("Slime") && Main.rand.Next(180) == 0)
                {
                    float scale    = 1f - (Main.rand.NextFloat() * .3f);
                    int   rand     = Main.rand.Next(3) + 1;
                    int   projType = ProjectileType <Gambler.Projectiles.SlimeRainCardProj2>();
                    for (int i = 0; i < rand; i++)
                    {
                        Vector2 target  = Main.MouseWorld;
                        Vector2 heading = target - player.position;
                        heading.Normalize();
                        heading *= new Vector2(0f, 5f).Length();
                        Vector2 vel = heading.RotatedByRandom(MathHelper.ToRadians(30));
                        vel = vel * scale;
                        int newProjectile = OrchidModGamblerHelper.DummyProjectile(Projectile.NewProjectile(player.Center.X, player.Center.Y, vel.X, vel.Y, projType, 15, 0f, player.whoAmI), dummy);
                        Main.projectile[newProjectile].ai[1]     = 1f;
                        Main.projectile[newProjectile].netUpdate = true;
                    }
                }
            }

            for (int l = 0; l < Main.projectile.Length; l++)
            {
                Projectile projectile = Main.projectile[l];
                if (projectile.active && projectile.owner == player.whoAmI)
                {
                    OrchidModGlobalProjectile modProjectile = projectile.GetGlobalProjectile <OrchidModGlobalProjectile>();
                    if (modProjectile.gamblerDummyProj == dummy && modProjectile.gamblerBonusTrigger)
                    {
                        modProjectile.gamblerBonusProjectilesDelegate(player, modPlayer, projectile, modProjectile, dummy);
                    }
                }
            }
        }
Esempio n. 14
0
 public override bool CanUseItem(Player player)
 {
     if (player == Main.LocalPlayer)
     {
         OrchidModPlayer modPlayer   = player.GetModPlayer <OrchidModPlayer>();
         Item            currentCard = modPlayer.gamblerCardCurrent;
         if (OrchidModGamblerHelper.getNbGamblerCards(player, modPlayer) > 0)
         {
             if (player.altFunctionUse == 2)
             {
                 if (modPlayer.gamblerRedraws > 0 && modPlayer.gamblerRedrawCooldownUse <= 0)
                 {
                     modPlayer.gamblerRedraws--;
                     modPlayer.gamblerRedrawCooldownUse = 30;
                     Main.PlaySound(SoundID.Item64, player.position);
                     OrchidModGamblerHelper.drawGamblerCard(player, modPlayer);
                     currentCard = modPlayer.gamblerCardCurrent;
                     this.checkStats(currentCard, player, modPlayer);
                 }
                 return(false);
             }
             else
             {
                 if (modPlayer.gamblerShuffleCooldown <= 0)
                 {
                     OrchidModGamblerHelper.drawGamblerCard(player, modPlayer);
                     Main.PlaySound(SoundID.Item64, player.position);
                     currentCard = modPlayer.gamblerCardCurrent;
                     this.checkStats(currentCard, player, modPlayer);
                 }
             }
         }
         else
         {
             return(false);
         }
     }
     return(base.CanUseItem(player));
 }
Esempio n. 15
0
        public static void drawGamblerCard(Player player, OrchidModPlayer modPlayer)
        {
            modPlayer.gamblerJustSwitched = true;

            if (modPlayer.gamblerCardNext.Count() != 3)
            {
                OrchidModGamblerHelper.clearGamblerCardsNext(player, modPlayer);
            }

            for (int i = 0; i < 3; i++)
            {
                if (modPlayer.gamblerCardNext[i].type == 0)
                {
                    int rand = Main.rand.Next(OrchidModGamblerHelper.getNbGamblerCards(player, modPlayer));
                    modPlayer.gamblerCardNext[i] = new Item();
                    modPlayer.gamblerCardNext[i].SetDefaults(modPlayer.gamblerCardsItem[rand].type, true);
                }
            }

            modPlayer.gamblerCardCurrent = new Item();
            modPlayer.gamblerCardCurrent.SetDefaults(modPlayer.gamblerCardNext[0].type, true);

            for (int i = 0; i < 2; i++)
            {
                modPlayer.gamblerCardNext[i] = new Item();
                modPlayer.gamblerCardNext[i].SetDefaults(modPlayer.gamblerCardNext[i + 1].type, true);
            }

            modPlayer.gamblerCardNext[2] = new Item();
            modPlayer.gamblerCardNext[2].SetDefaults(0, true);

            for (int i = 0; i < 3; i++)
            {
                if (modPlayer.gamblerCardNext[i].type == 0)
                {
                    int rand = Main.rand.Next(OrchidModGamblerHelper.getNbGamblerCards(player, modPlayer));
                    modPlayer.gamblerCardNext[i] = new Item();
                    modPlayer.gamblerCardNext[i].SetDefaults(modPlayer.gamblerCardsItem[rand].type, true);
                }
            }

            if (OrchidModGamblerHelper.getNbGamblerCards(player, modPlayer) > 3)
            {
                for (int i = 2; i > -1; i--)
                {
                    for (int j = 2; j > -1; j--)
                    {
                        int currentType = modPlayer.gamblerCardNext[i].type;
                        if ((currentType == modPlayer.gamblerCardNext[j].type || currentType == modPlayer.gamblerCardCurrent.type) && i != j)
                        {
                            int k = 0;
                            while (k < 5 && (currentType == modPlayer.gamblerCardNext[j].type || currentType == modPlayer.gamblerCardCurrent.type))
                            {
                                k++;
                                int rand = Main.rand.Next(OrchidModGamblerHelper.getNbGamblerCards(player, modPlayer));
                                modPlayer.gamblerCardNext[i] = new Item();
                                modPlayer.gamblerCardNext[i].SetDefaults(modPlayer.gamblerCardsItem[rand].type, true);
                                currentType = modPlayer.gamblerCardNext[i].type;
                            }
                        }
                    }
                }
            }

            modPlayer.gamblerShuffleCooldown = modPlayer.gamblerShuffleCooldownMax;

            if (modPlayer.gamblerDungeon)
            {
                int rand = Main.rand.Next(3);
                for (int i = 0; i < rand; i++)
                {
                    OrchidModGamblerHelper.addGamblerChip(100, player, modPlayer);
                }
            }

            if (modPlayer.gamblerPennant)
            {
                OrchidModGlobalItem orchidItem = modPlayer.gamblerCardCurrent.GetGlobalItem <OrchidModGlobalItem>();
                if (orchidItem.gamblerCardSets.Contains("Boss"))
                {
                    player.AddBuff(BuffType <Gambler.Buffs.ConquerorsPennantBuff>(), 60 * 10);
                }
            }

            if (modPlayer.gamblerVulture)
            {
                int rand     = Main.rand.Next(3) + 1;
                int projType = ProjectileType <Gambler.Projectiles.Equipment.VultureCharmProj>();
                for (int i = 0; i < rand; i++)
                {
                    float   scale   = 1f - (Main.rand.NextFloat() * .3f);
                    Vector2 target  = Main.MouseWorld;
                    Vector2 heading = target - player.Center;
                    heading.Normalize();
                    heading *= new Vector2(0f, 10f).Length();
                    Vector2 vel = heading.RotatedByRandom(MathHelper.ToRadians(20));
                    vel = vel * scale;
                    Projectile.NewProjectile(player.Center.X, player.Center.Y, vel.X, vel.Y, projType, 12, 0f, player.whoAmI);
                    if (i == 0)
                    {
                        OrchidModProjectile.spawnDustCircle(player.Center, 31, 10, 10, true, 1.5f, 1f, 5f, true, true, false, 0, 0, true);
                    }
                }
            }

            modPlayer.gamblerSeedCount = 0;
        }
Esempio n. 16
0
        public static void gamblerPostUpdateEquips(Player player, OrchidModPlayer modPlayer, Mod mod)
        {
            if (player.whoAmI == Main.myPlayer)
            {
                //Since this is a variable that is synced through SendClientChanges, it has to only be assigned on the client aswell
                modPlayer.gamblerHasCardInDeck = modPlayer.gamblerCardsItem[0].type != 0;
            }

            if (modPlayer.gamblerRedrawsMax > 0)
            {
                modPlayer.gamblerRedrawCooldown = modPlayer.gamblerRedraws >= modPlayer.gamblerRedrawsMax ? modPlayer.gamblerRedrawCooldownMax : modPlayer.gamblerRedrawCooldown;
                modPlayer.gamblerRedrawCooldown = modPlayer.gamblerRedrawCooldown > modPlayer.gamblerRedrawCooldownMax ? modPlayer.gamblerRedrawCooldownMax : modPlayer.gamblerRedrawCooldown;
                modPlayer.gamblerRedrawCooldown = modPlayer.gamblerRedrawCooldown <= 0 ? modPlayer.gamblerRedrawCooldownMax : modPlayer.gamblerRedrawCooldown - 1;
                if (modPlayer.gamblerRedrawCooldown <= 0 && modPlayer.gamblerRedraws < modPlayer.gamblerRedrawsMax)
                {
                    modPlayer.gamblerRedraws++;
                }
            }
            else
            {
                modPlayer.gamblerRedrawCooldown = -1;
            }

            modPlayer.gamblerRedrawCooldownUse -= modPlayer.gamblerRedrawCooldownUse > 0 ? 1 : 0;
            modPlayer.gamblerShuffleCooldown   -= modPlayer.gamblerShuffleCooldown > 0 ? 1 : 0;
            modPlayer.gamblerUIDisplayTimer     = modPlayer.gamblerShuffleCooldown <= 0 && modPlayer.gamblerDiceDuration <= 0 ? modPlayer.gamblerUIDisplayTimer > 0 ? modPlayer.gamblerUIDisplayTimer - 1 : modPlayer.gamblerUIDisplayTimer : 300;
            if (modPlayer.gamblerChips > 0 && modPlayer.gamblerUIDisplayTimer <= 0 && modPlayer.timer120 % 60 == 0)
            {
                modPlayer.gamblerChips--;
                modPlayer.gamblerUIDisplayTimer = modPlayer.gamblerChips == 0 ? 60 : 0;
            }

            if (modPlayer.gamblerUIDisplayTimer == 0 && modPlayer.gamblerChips == 0 && modPlayer.gamblerCardCurrent.type == 0)
            {
                OrchidModGamblerHelper.clearGamblerCardCurrent(player, modPlayer);
                modPlayer.gamblerRedraws = 0;
                OrchidModGamblerHelper.clearGamblerCardsNext(player, modPlayer);
            }

            if (modPlayer.gamblerRedraws > modPlayer.gamblerRedrawsMax)
            {
                modPlayer.gamblerRedraws = modPlayer.gamblerRedrawsMax;
            }
            if (modPlayer.gamblerChips > modPlayer.gamblerChipsMax)
            {
                modPlayer.gamblerChips = modPlayer.gamblerChipsMax;
            }

            if (modPlayer.gamblerDiceDuration <= 0)
            {
                modPlayer.gamblerDiceID    = -1;
                modPlayer.gamblerDiceValue = 0;
            }
            else
            {
                modPlayer.gamblerDiceDuration--;
                switch (modPlayer.gamblerDiceID)
                {
                case 0:
                    modPlayer.gamblerDamage += (0.03f * modPlayer.gamblerDiceValue);
                    break;

                case 1:
                    modPlayer.gamblerChipsConsume += 4 * modPlayer.gamblerDiceValue;
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 17
0
        public override void ModifyTooltips(List <TooltipLine> tooltips)
        {
            TooltipLine tt = tooltips.FirstOrDefault(x => x.Name == "Damage" && x.mod == "Terraria");

            if (tt != null)
            {
                string[] splitText   = tt.text.Split(' ');
                string   damageValue = splitText.First();
                string   damageWord  = splitText.Last();
                tt.text = damageValue + " gambling " + damageWord;
            }

            Player          player    = Main.player[Main.myPlayer];
            OrchidModPlayer modPlayer = player.GetModPlayer <OrchidModPlayer>();

            Item[] cards = modPlayer.gamblerCardsItem;
            int    count = OrchidModGamblerHelper.getNbGamblerCards(player, modPlayer);
            int    diff  = this.cardRequirement - count;

            int index = tooltips.FindIndex(ttip => ttip.mod.Equals("Terraria") && ttip.Name.Equals("Tooltip0"));

            if (index != -1)
            {
                int tagCount = this.gamblerCardSets.Count - 1;
                if (tagCount > -1)
                {
                    List <string> alreadyDone = new List <string>();
                    string        tags        = "";
                    foreach (string tag in this.gamblerCardSets)
                    {
                        if (!alreadyDone.Contains(tag))
                        {
                            tags += alreadyDone.Count > 0 ? ", " : "";
                            tags += tag;
                            tagCount--;
                            alreadyDone.Add(tag);
                        }
                    }
                    tags += alreadyDone.Count > 1 ? " sets" : " set";

                    tooltips.Insert(index, new TooltipLine(mod, "TagsTag", tags)
                    {
                        overrideColor = new Color(175, 255, 175)
                    });
                }
            }

            tooltips.Insert(1, new TooltipLine(mod, "CardsNeeded", "Requires " + this.cardRequirement + " cards (Deck : " + count + ")")
            {
                overrideColor = new Color(255, 200, 100)
            });

            if (OrchidModGamblerHelper.containsGamblerCard(item, player, modPlayer))
            {
                tooltips.Insert(1, new TooltipLine(mod, "UseTag", "Currently in your deck")
                {
                    overrideColor = new Color(255, 100, 100)
                });
            }
            else if (count == 20)
            {
                tooltips.Insert(1, new TooltipLine(mod, "UseTag", "Your deck is full")
                {
                    overrideColor = new Color(255, 100, 100)
                });
            }
            else if (count < this.cardRequirement)
            {
                tooltips.Insert(1, new TooltipLine(mod, "UseTag", "Requires " + diff + " more cards")
                {
                    overrideColor = new Color(255, 100, 100)
                });
            }
            else
            {
                tooltips.Insert(1, new TooltipLine(mod, "UseTag", "Use to add to your deck")
                {
                    overrideColor = new Color(255, 200, 100)
                });
            }

            Mod thoriumMod = OrchidMod.ThoriumMod;

            if (thoriumMod != null)
            {
                tooltips.Insert(1, new TooltipLine(mod, "ClassTag", "-Gambler Class-")
                {
                    overrideColor = new Color(255, 200, 0)
                });
            }

            tt = tooltips.FirstOrDefault(x => x.Name == "Speed" && x.mod == "Terraria");
            if (tt != null)
            {
                tooltips.Remove(tt);
            }

            tt = tooltips.FirstOrDefault(x => x.Name == "Consumable" && x.mod == "Terraria");
            if (tt != null)
            {
                tooltips.Remove(tt);
            }
        }