Ejemplo n.º 1
0
        public override void UpdateInventory(Player player)
        {
            IncPlayer ic = Main.player[Main.myPlayer].GetModPlayer <IncPlayer>();

            if (Press(1))
            {
                for (int a = 0; a < Main.npc.Length; a++)
                {
                    NPC n = Main.npc[a];
                    if (n != null && n.active && (!n.friendly || !n.townNPC))
                    {
                        if (n.type != NPCID.TargetDummy)
                        {
                            if (n.type == ModContent.NPCType <TheTarr>())
                            {
                                n.wet = true;
                            }
                            n.life = int.MinValue;
                            n.HitEffect();
                            n.checkDead();
                            if (Main.netMode == NetmodeID.Server)
                            {
                                NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, a, 0f, 0f, 0f, 0);
                            }
                        }
                    }
                }
            }
            if (Press(2))
            {
                ic.magicCursor = !ic.magicCursor;
                Terraria.Audio.LegacySoundStyle type = ic.magicCursor ? SoundID.Item103 : SoundID.Item104;
                Main.PlaySound(type, player.position);
                int dustType = ic.magicCursor ? DustID.AncientLight : DustID.ApprenticeStorm;
                for (int i = 0; i < 15; i++)
                {
                    Vector2 position = player.Center + Vector2.UnitX.RotatedBy(MathHelper.ToRadians(360f / 15 * i));
                    Dust    dust     = Dust.NewDustPerfect(position, dustType);
                    dust.noGravity = true;
                    dust.velocity  = Vector2.Normalize(dust.position - player.Center) * 4;
                    dust.fadeIn    = 1f;
                }
            }

            bool Press(int type)
            {
                if (type == 1)
                {
                    return(CastledsContent.SpecialHotkey.JustPressed && player.HeldItem == item);
                }
                if (type == 2)
                {
                    return(CastledsContent.SpecialHotkey.JustPressed && player.HeldItem != item);
                }
                return(false);
            }
        }
Ejemplo n.º 2
0
        public bool HasSmite(Player player)
        {
            IncPlayer inc = player.GetModPlayer <IncPlayer>();

            if (inc.godMode)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 3
0
 public override bool CheckDead(NPC npc)
 {
     foreach (Player p in Main.player)
     {
         if (p.active)
         {
             IncPlayer inc = p.GetModPlayer <IncPlayer>();
             if (inc.magicCursor)
             {
                 inc.nTar = false;
             }
         }
     }
     manipulate = false;
     if (manipulate)
     {
         return(true);
     }
     return(base.CheckDead(npc));
 }
Ejemplo n.º 4
0
        public override void UpdateEquips(ref bool wallSpeedBuff, ref bool tileSpeedBuff, ref bool tileRangeBuff)
        {
            bool HasTablet()
            {
                foreach (Item i in player.inventory)
                {
                    if (i.type == ModContent.ItemType <Incinerator>())
                    {
                        return(true);
                    }
                }
                return(false);
            }

            godMode = HasTablet();
            if (godMode)
            {
                if (ModContent.GetInstance <ClientConfig>().tabletUI)
                {
                    CastledsContent.instance.TabletState.SetState(CastledsContent.instance.tabletUI);
                }
                for (int a = 0; a < BuffLoader.BuffCount; a++)
                {
                    if (Main.debuff[a])
                    {
                        player.buffImmune[a] = true;
                    }
                }
                player.statLife = player.statLifeMax2;
                player.statMana = player.statManaMax2;
                player.breath   = player.breathMax;
                player.wingTime = player.wingTimeMax;
            }
            else
            {
                CastledsContent.instance.TabletState.SetState(null);
            }
            if (magicCursor)
            {
                foreach (NPC n in Main.npc)
                {
                    if (n.active && !pTar)
                    {
                        IncNPC inc = n.GetGlobalNPC <IncNPC>();
                        if (inc.InRangeOfCursor(n) && Main.mouseLeft)
                        {
                            inc.manipulate = true;
                            nTar           = true;
                        }
                        if (inc.manipulate && Main.mouseLeft)
                        {
                            Vector2 position = new Vector2(Main.MouseWorld.X - (n.width / 2), Main.MouseWorld.Y - (n.height / 2));
                            n.velocity = new Vector2(0f, 0f);
                            n.position = position;
                            if (Main.mouseRight)
                            {
                                inc.Damaged(n);
                            }
                        }
                        if (!Main.mouseLeft && inc.manipulate)
                        {
                            nTar           = false;
                            inc.manipulate = false;
                        }
                    }
                }
                foreach (Player p in Main.player)
                {
                    if (p.active && !p.dead && !nTar)
                    {
                        IncPlayer inc = p.GetModPlayer <IncPlayer>();
                        if (inc.InRangeOfCursor(p) && Main.mouseLeft)
                        {
                            inc.manipulate = true;
                            pTar           = true;
                        }
                        if (inc.manipulate && Main.mouseLeft)
                        {
                            SnareBoolean sb       = p.GetModPlayer <SnareBoolean>();
                            Vector2      position = new Vector2(Main.MouseWorld.X - (p.width / 2), Main.MouseWorld.Y - (p.height / 2));
                            p.velocity = new Vector2(0f, 0f);
                            p.position = position;
                            if (Main.mouseRight)
                            {
                                inc.Damaged(p);
                            }
                        }
                        if (!Main.mouseLeft && inc.manipulate)
                        {
                            pTar           = false;
                            inc.manipulate = false;
                        }
                    }
                }
                foreach (Item i in Main.item)
                {
                    if (i.active)
                    {
                        IncItem inc = i.GetGlobalItem <IncItem>();
                        if (inc.InRangeOfCursor(i) && Main.mouseLeft)
                        {
                            inc.manipulate = true;
                        }
                        if (inc.manipulate && Main.mouseLeft)
                        {
                            Vector2 position = new Vector2(Main.MouseWorld.X - (i.width / 2), Main.MouseWorld.Y - (i.height / 2));
                            i.velocity = new Vector2(0f, 0f);
                            i.position = position;
                            if (Main.mouseRight && !inc.smiteImmune)
                            {
                                i.SetDefaults(ItemID.None);
                            }
                        }
                        if (!Main.mouseLeft && inc.manipulate)
                        {
                            inc.manipulate = false;
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public override void AI()
        {
            Entity target = npc.GetGlobalNPC <TarrHelper>().snaredTarget;
            NPC    tarr   = npc.GetGlobalNPC <TarrHelper>().parentTarr;

            bool Manipulation()
            {
                if (target is Player p)
                {
                    IncPlayer inc = p.GetModPlayer <IncPlayer>();
                    if (inc.pTar || inc.nTar)
                    {
                        return(true);
                    }
                }
                return(false);
            }

            if (tarr != null && tarr.active)
            {
                npc.life = npc.lifeMax;
            }
            else
            {
                npc.life = int.MinValue;
                npc.checkDead();
            }
            if (npc.HasBuff(BuffID.Wet))
            {
                npc.ai[3] = 30f;
                wet       = true;
                npc.life  = int.MinValue;
                npc.checkDead();
            }
            if (!npc.active)
            {
                if (target is Player)
                {
                    Player pt = (Player)npc.GetGlobalNPC <TarrHelper>().snaredTarget;
                    pt.GetModPlayer <SnareBoolean>().isSnared = false;
                    pt.GetModPlayer <SnareBoolean>().grasped  = false;
                }
                if (target is NPC n)
                {
                    n.GetGlobalNPC <TarrHelper>().drawArm = false;
                    n.GetGlobalNPC <TarrHelper>().armRot  = 0f;
                    n.rotation = 0f;
                }
            }
            if (gripTarget)
            {
                if (target == null || !target.active)
                {
                    if (tarr == null || !tarr.active)
                    {
                        npc.life = int.MinValue;
                        npc.checkDead();
                    }
                    else
                    {
                        npc.ai[3] = 69f;
                    }
                }

                target.position = new Vector2(npc.Center.X - (target.width / 2), npc.Center.Y - (target.height / 2));
                target.velocity = new Vector2(0f, 0f);
                npc.velocity.X *= 0.98f;
                npc.velocity.Y *= 0.98f;
                if (target is NPC n)
                {
                    n.GetGlobalNPC <TarrHelper>().drawArm = true;
                    n.rotation = npc.position.ToRotation();
                    n.GetGlobalNPC <TarrHelper>().armRot = n.rotation;
                    n.frame = new Rectangle(0, 0, n.frame.Width, n.frame.Height);
                }
                if (target is Player p)
                {
                    bool extra  = p.inventory[p.selectedItem].useStyle != 0 && Main.mouseLeft;
                    bool extra2 = p.inventory[p.selectedItem].useStyle != 0 && p.altFunctionUse > 0 && Main.mouseRight;
                    p.GetModPlayer <SnareBoolean>().grasped = true;
                    p.tileInteractionHappened = false;
                    if (!p.GetModPlayer <SnareBoolean>().useGrasp&& !extra && !extra2)
                    {
                        p.bodyFrame.Y = 0;
                    }
                    p.ItemCheck(0);
                    if (p.position.X < 650)
                    {
                        p.position.X = 650;
                    }
                    if (p.position.X > 100000)
                    {
                        p.position.X = 100000;
                    }
                    if (p.position.Y < 650)
                    {
                        p.position.Y = 650;
                    }
                    if (p.position.Y > 28000)
                    {
                        p.position.Y = 28000;
                    }
                }
                Vector2 vector8 = new Vector2(npc.position.X + (npc.width * 0.5f), npc.position.Y + (npc.height * 0.5f));
                {
                    float rotation = (float)Math.Atan2((vector8.Y) - (tarr.position.Y + (tarr.height * 0.5f)), (vector8.X) - (tarr.position.X + (tarr.width * 0.5f)));
                    npc.velocity.X = (float)(Math.Cos(rotation) * moveMult) * -1;
                    npc.velocity.Y = (float)(Math.Sin(rotation) * moveMult) * -1;
                }
                if (NextToParentTarr())
                {
                    if (target is NPC a)
                    {
                        NPC        npcTarget = (NPC)npc.GetGlobalNPC <TarrHelper>().snaredTarget;
                        TarrHelper th        = npcTarget.GetGlobalNPC <TarrHelper>();
                        th.grasped = true;
                        if (a.active)
                        {
                            Main.PlaySound(SoundLoader.customSoundType, npc.Center, mod.GetSoundSlot(SoundType.Custom, "Sounds/Custom/Tarr_Bite"));
                            Main.PlaySound(SoundLoader.customSoundType, npc.Center, mod.GetSoundSlot(SoundType.Custom, "Sounds/Custom/Tarr_Consume"));
                        }
                        th.Consumed(npcTarget);
                        npc.ai[3] = 21f;
                        a.GetGlobalNPC <TarrHelper>().drawArm = false;
                        a.GetGlobalNPC <TarrHelper>().armRot  = 0f;
                        npcTarget.rotation = 0f;
                    }
                    if (target is Player b)
                    {
                        Player        pt       = (Player)npc.GetGlobalNPC <TarrHelper>().snaredTarget;
                        List <string> messages = new List <string>()
                        {
                            "was eaten without the crust.",
                            "turned into a terrarian chicken nugget.",
                            "is currently approaching the intestines...",
                            "didn't know how to wrangle, and ended up mangled.",
                            "forgot to bring some water.",
                            "came too close to the exhibit",
                            "isn't a god."
                        };
                        if (pt.name == "Beatrix LeBeau" && !pt.Male)
                        {
                            messages.Add("was knocked out.");
                        }
                        if (!b.dead)
                        {
                            Main.PlaySound(SoundLoader.customSoundType, npc.Center, mod.GetSoundSlot(SoundType.Custom, "Sounds/Custom/Tarr_Bite"));
                            Main.PlaySound(SoundLoader.customSoundType, npc.Center, mod.GetSoundSlot(SoundType.Custom, "Sounds/Custom/Tarr_Consume"));
                        }
                        PlayerDeathReason dR = new PlayerDeathReason
                        {
                            SourceCustomReason = $"{pt.name} {Main.rand.Next(messages)}"
                        };
                        pt.KillMe(dR, double.MaxValue, 0, false);
                        npc.ai[3] = 21f;
                        pt.GetModPlayer <SnareBoolean>().isSnared = false;
                        pt.GetModPlayer <SnareBoolean>().grasped  = false;
                    }
                }
                if (!Manipulation() && moveMult <= 35)
                {
                    moveMult *= 1.01f;
                }
            }
            if (!gripTarget)
            {
                if (target == null || !target.active)
                {
                    if (tarr == null || !tarr.active)
                    {
                        npc.life = int.MinValue;
                        npc.checkDead();
                    }
                    else
                    {
                        npc.ai[3] = 69f;
                    }
                }
                else
                {
                    npc.velocity.X *= 0.98f;
                    npc.velocity.Y *= 0.98f;
                    Vector2 vector8 = new Vector2(npc.position.X + (npc.width * 0.5f), npc.position.Y + (npc.height * 0.5f));
                    {
                        float rotation = (float)Math.Atan2((vector8.Y) - (target.position.Y + (target.height * 0.5f)), (vector8.X) - (target.position.X + (target.width * 0.5f)));
                        npc.velocity.X = (float)(Math.Cos(rotation) * moveMult) * -1;
                        npc.velocity.Y = (float)(Math.Sin(rotation) * moveMult) * -1;
                    }
                    if (NextToTarget())
                    {
                        Main.PlaySound(SoundLoader.customSoundType, npc.Center, mod.GetSoundSlot(SoundType.Custom, "Sounds/Custom/Tarr_Grab"));
                        moveMult   = 1f;
                        gripTarget = true;
                    }
                    if (moveMult <= 50)
                    {
                        moveMult *= 1.025f;
                    }
                }
            }
        }