Example #1
0
        public override void NPCLoot()
        {
            Entity target = npc.GetGlobalNPC <TarrHelper>().snaredTarget;

            if (target is NPC n)
            {
                TarrHelper th = n.GetGlobalNPC <TarrHelper>();
                th.grasped  = false;
                th.isSnared = false;
                th.drawArm  = false;
                th.armRot   = 0f;
                n.rotation  = 0f;
            }
            if (target is Player p)
            {
                p.GetModPlayer <SnareBoolean>().isSnared = false;
                if (!wet)
                {
                    p.GetModPlayer <SnareBoolean>().grasped = false;
                }
            }
            if (npc.ai[3] < 1 || wet)
            {
                Main.PlaySound(SoundID.NPCDeath12, npc.position);
                Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Gore1"), 1f);
                for (int a = 0; a < 2; a++)
                {
                    Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Gore2"), 1f);
                }
            }
        }
Example #2
0
 public override void NPCLoot()
 {
     if (target != null && target.active)
     {
         if (target is NPC tar)
         {
             TarrHelper th = tar.GetGlobalNPC <TarrHelper>();
             th.isSnared = false;
             th.grasped  = false;
         }
         if (target is Player pl)
         {
             SnareBoolean sb = pl.GetModPlayer <SnareBoolean>();
             sb.isSnared = false;
             sb.grasped  = false;
         }
     }
     Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Gore1"), 1f);
     for (int a = 0; a < 6; a++)
     {
         Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Gore2"), 1f);
     }
     Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Gore3"), 1f);
     Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Gore3"), 1f);
     Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Gore4"), 1f);
     Main.PlaySound(SoundLoader.customSoundType, npc.Center, mod.GetSoundSlot(SoundType.Custom, "Sounds/Custom/Tarr_Death"));
 }
Example #3
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;
                    }
                }
            }
        }
Example #4
0
        private void SnatchATarget()
        {
            List <Entity> targets = new List <Entity>();
            Vector2       min     = new Vector2(npc.position.X - 750, npc.position.Y - 750);
            Vector2       max     = new Vector2(npc.position.X + 750, npc.position.Y + 750);

            for (int a = 0; a < Main.npc.Length; a++)
            {
                if (InRange(min, max, 1, a) && Main.npc[a].type != NPCID.TargetDummy && Main.npc[a].type != ModContent.NPCType <TheTarr>() && Main.npc[a].type != ModContent.NPCType <Appendage>())
                {
                    targets.Add(Main.npc[a]);
                }
            }
            for (int a = 0; a < Main.player.Length; a++)
            {
                if (InRange(min, max, 2, a) && !HasSmite(Main.player[a]) && Main.player[a].active)
                {
                    targets.Add(Main.player[a]);
                }
            }
            if (targets.Count > 0)
            {
                catchTarget = true;
                try
                {
                    target = null;
                    int        appendage = NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, ModContent.NPCType <Appendage>());
                    TarrHelper th        = Main.npc[appendage].GetGlobalNPC <TarrHelper>();
                    th.parentTarr   = npc;
                    th.snaredTarget = Main.rand.Next(targets);
                    foreach (Entity e in targets)
                    {
                        if (e is Player p && IsRancher(p))
                        {
                            target = p;
                        }
                    }
                    Main.npc[appendage].rotation = th.snaredTarget.position.ToRotation();
                    appen = appendage;
                    Entity targ = Main.npc[appendage].GetGlobalNPC <TarrHelper>().snaredTarget;
                    if (targ is NPC tar)
                    {
                        tar.GetGlobalNPC <TarrHelper>().isSnared = true;
                    }
                    if (targ is Player pla)
                    {
                        pla.GetModPlayer <SnareBoolean>().isSnared = true;
                    }
                }
                catch (IndexOutOfRangeException)
                {
                    if (target is NPC)
                    {
                        NPC targetN = (NPC)Main.rand.Next(targets);
                        targetN.life = int.MinValue;
                    }
                    if (target is Player)
                    {
                        Player            targetP = (Player)Main.rand.Next(targets);
                        PlayerDeathReason dR      = new PlayerDeathReason
                        {
                            SourceCustomReason = $"{targetP.name} was in a sticky, and unavoidable situation..."
                        };
                        targetP.KillMe(dR, double.MaxValue, 0, false);
                    }
                }
            }
            //TODO: create Appendage NPC
        }