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)); }
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; }
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; } } }