Ejemplo n.º 1
0
        public override void Update(NPC npc, ref int buffIndex)
        {
            NPCEdits modNPC = npc.GetGlobalNPC <NPCEdits>();

            modNPC.stunned   = true;
            modNPC.stunTimer = 60;
        }
Ejemplo n.º 2
0
        public void Check(NPC npc)
        {
            NPCEdits    modNPC    = npc.GetGlobalNPC <NPCEdits>();
            Player      player    = Main.player[modNPC.owner];
            PlayerEdits modPlayer = player.GetModPlayer <PlayerEdits>();

            if (IfHoverNPC(npc))
            {
                if (Main.mouseRight && Main.npcChatRelease)
                {
                    npc.life = 0;
                }
            }
            if (player.dead)
            {
                npc.life = 0;
            }
            if (npc.life <= 0)
            {
                modPlayer.usedMinionSlots -= modNPC.minionSlots;
                Main.player[modNPC.owner].numMinions--;
                Main.PlaySound(SoundID.NPCDeath1);
                npc.active = false;
            }
        }
Ejemplo n.º 3
0
        public override bool?CanHitNPC(NPC target)
        {
            NPCEdits modNPC    = npc.GetGlobalNPC <NPCEdits>();
            NPCEdits modTarget = target.GetGlobalNPC <NPCEdits>();

            if (modTarget.isMinion)
            {
                if (modNPC.owner < Main.maxPlayers && modNPC.owner == modTarget.owner)
                {
                    return(false);
                }
                if (modNPC.owner < Main.maxPlayers && !Main.player[modNPC.owner].hostile)
                {
                    return(false);
                }
                if (modNPC.owner < Main.maxPlayers && !Main.player[modTarget.owner].hostile)
                {
                    return(false);
                }
            }
            if (target.friendly)
            {
                return(false);
            }
            return(base.CanHitNPC(target));
        }
Ejemplo n.º 4
0
        public int Shoot(Vector2 velocity)
        {
            NPCEdits        modNPC        = npc.GetGlobalNPC <NPCEdits>();
            int             proj          = Projectile.NewProjectile(npc.position, velocity, modNPC.shoot, npc.damage, modNPC.knockback, modNPC.owner);
            ProjectileEdits modProjectile = Main.projectile[proj].GetGlobalProjectile <ProjectileEdits>();

            modProjectile.minionProjectile = true;
            modProjectile.minionOwner      = npc.whoAmI;
            return(proj);
        }
Ejemplo n.º 5
0
        public override bool?CanBeHitByItem(Player player, Item item)
        {
            NPCEdits modNPC = npc.GetGlobalNPC <NPCEdits>();

            if (Main.player[modNPC.owner] == player)
            {
                return(false);
            }
            if (!player.hostile)
            {
                return(false);
            }
            return(base.CanBeHitByItem(player, item));
        }
Ejemplo n.º 6
0
        public override bool CanHitPlayer(Player target, ref int cooldownSlot)
        {
            NPCEdits modNPC = npc.GetGlobalNPC <NPCEdits>();

            if (!target.hostile)
            {
                return(false);
            }
            if (modNPC.owner < Main.maxPlayers && modNPC.owner == target.whoAmI)
            {
                return(false);
            }
            return(base.CanHitPlayer(target, ref cooldownSlot));
        }
Ejemplo n.º 7
0
        public override void AI()
        {
            base.AI();
            NPCEdits modNPC = npc.GetGlobalNPC <NPCEdits>();
            Player   player = Main.player[modNPC.owner];

            Check(npc);
            //if (player.talkNPC == npc.whoAmI)
            //{
            //    PlayerEdits modPlayer = player.GetModPlayer<PlayerEdits>();
            //    modPlayer.usedMinionSlots -= modNPC.minionSlots;
            //    Main.player[modNPC.owner].numMinions--;
            //    npc.active = false;
            //}
            Behavior();
        }
Ejemplo n.º 8
0
        public override bool?CanBeHitByProjectile(Projectile projectile)
        {
            NPCEdits        modNPC        = npc.GetGlobalNPC <NPCEdits>();
            ProjectileEdits modProjectile = projectile.GetGlobalProjectile <ProjectileEdits>();

            if (projectile.owner < Main.maxPlayers && projectile.owner == modNPC.owner)
            {
                return(false);
            }
            if (modProjectile.minionProjectile && modProjectile.minionOwner == npc.whoAmI)
            {
                return(false);
            }
            if (modProjectile.minionProjectile && !Main.player[projectile.owner].hostile)
            {
                return(false);
            }
            return(base.CanBeHitByProjectile(projectile));
        }
Ejemplo n.º 9
0
        public override void SetDefaults()
        {
            base.SetDefaults();
            NPCEdits modNPC = npc.GetGlobalNPC <NPCEdits>();

            npc.width                    = 32;
            npc.height                   = 32;
            npc.lifeMax                  = 300;
            npc.life                     = 300;
            modNPC.inertia               = 30f;
            modNPC.shootSpeed            = 10f;
            modNPC.idleAccel             = 10f;
            modNPC.spacingMult           = 1f;
            modNPC.viewDist              = 300f; //minion view Distance
            modNPC.chaseDist             = 200f; //how far the minion can go
            modNPC.chaseAccel            = 20f;
            modNPC.shootCool             = 80f;  //how fast the minion can shoot
            modNPC.shoot                 = ProjectileID.ImpFireball;
            Main.npcFrameCount[npc.type] = 8;
        }
Ejemplo n.º 10
0
        public bool IfHoverNPC(NPC npc)
        {
            NPCEdits modNPC = npc.GetGlobalNPC <NPCEdits>();

            if (!Main.player[Main.myPlayer].dead && Main.myPlayer == modNPC.owner)
            {
                Rectangle rectangle = new Rectangle((int)((float)Main.mouseX + Main.screenPosition.X), (int)((float)Main.mouseY + Main.screenPosition.Y), 1, 1);
                bool      flag5;
                bool      flag4;
                if (npc.active)
                {
                    flag5 = rectangle.Intersects(npc.getRect());
                    flag4 = (flag5 || (Main.SmartInteractShowingGenuine && Main.SmartInteractNPC == npc.whoAmI));
                    if (flag4)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 11
0
        public override void SetDefaults()
        {
            base.SetDefaults();
            NPCEdits modNPC = npc.GetGlobalNPC <NPCEdits>();

            npc.width          = 32;
            npc.height         = 32;
            npc.lifeMax        = 100;
            npc.life           = npc.lifeMax;
            npc.friendlyRegen  = 100;
            npc.HitSound       = SoundID.NPCHit1;
            npc.noTileCollide  = false;
            npc.noGravity      = true;
            modNPC.isMinion    = true;
            modNPC.inertia     = 30f;
            modNPC.idleAccel   = 10f;
            modNPC.spacingMult = 1f;
            modNPC.viewDist    = 300f;
            modNPC.chaseDist   = 200f;
            modNPC.chaseAccel  = 20f;
        }
Ejemplo n.º 12
0
        public override void Behavior()
        {
            NPCEdits    modNPC    = npc.GetGlobalNPC <NPCEdits>();
            Player      player    = Main.player[modNPC.owner];
            PlayerEdits modPlayer = player.GetModPlayer <PlayerEdits>();
            float       spacing   = (float)npc.width * modNPC.spacingMult;

            for (int k = 0; k < 1000; k++)
            {
                Projectile otherProj = Main.projectile[k];
                if (k != npc.whoAmI && otherProj.active && otherProj.owner == modNPC.owner && otherProj.type == npc.type && System.Math.Abs(npc.position.X - otherProj.position.X) + System.Math.Abs(npc.position.Y - otherProj.position.Y) < spacing)
                {
                    if (npc.position.X < Main.projectile[k].position.X)
                    {
                        npc.velocity.X -= modNPC.idleAccel;
                    }
                    else
                    {
                        npc.velocity.X += modNPC.idleAccel;
                    }
                    if (npc.position.Y < Main.projectile[k].position.Y)
                    {
                        npc.velocity.Y -= modNPC.idleAccel;
                    }
                    else
                    {
                        npc.velocity.Y += modNPC.idleAccel;
                    }
                }
            }
            Vector2 targetPos  = npc.position;
            float   targetDist = modNPC.viewDist;
            bool    target     = false;

            npc.noTileCollide = false;
            for (int k = 0; k < 200; k++)
            {
                NPC othernpc = Main.npc[k];
                if (othernpc.CanBeChasedBy(this, false))
                {
                    float distance = Vector2.Distance(othernpc.Center, npc.Center);
                    if ((distance < targetDist || !target) && Collision.CanHitLine(npc.position, npc.width, npc.height, othernpc.position, othernpc.width, othernpc.height))
                    {
                        targetDist = distance;
                        targetPos  = othernpc.Center;
                        target     = true;
                    }
                }
            }
            if (Vector2.Distance(player.Center, npc.Center) > (target ? 1000f : 500f))
            {
                npc.ai[0]     = 1f;
                npc.netUpdate = true;
            }
            if (npc.ai[0] == 1f)
            {
                npc.noTileCollide = true;
            }
            if (target && npc.ai[0] == 0f)
            {
                Vector2 direction = targetPos - npc.Center;
                if (direction.Length() > modNPC.chaseDist)
                {
                    direction.Normalize();
                    npc.velocity = (npc.velocity * modNPC.inertia + direction * modNPC.chaseAccel) / (modNPC.inertia + 1);
                }
                else
                {
                    npc.velocity *= (float)Math.Pow(0.97, 40.0 / modNPC.inertia);
                }
            }
            else
            {
                if (!Collision.CanHitLine(npc.Center, 1, 1, player.Center, 1, 1))
                {
                    npc.ai[0] = 1f;
                }
                float speed = 6f;
                if (npc.ai[0] == 1f)
                {
                    speed = 15f;
                }
                Vector2 center    = npc.Center;
                Vector2 direction = player.Center - center;
                npc.ai[1]     = 3600f;
                npc.netUpdate = true;
                int num = 1;
                for (int k = 0; k < npc.whoAmI; k++)
                {
                    if (Main.npc[k].active && Main.npc[k].GetGlobalNPC <NPCEdits>().owner == modNPC.owner && Main.npc[k].type == npc.type)
                    {
                        num++;
                    }
                }
                direction.X -= (float)((10 + num * 40) * player.direction);
                direction.Y -= 70f;
                float distanceTo = direction.Length();
                if (distanceTo > 200f && speed < modNPC.chaseAccel)
                {
                    speed = modNPC.chaseAccel;
                }
                if (distanceTo < 100f && npc.ai[0] == 1f && !Collision.SolidCollision(npc.position, npc.width, npc.height))
                {
                    npc.ai[0]     = 0f;
                    npc.netUpdate = true;
                }
                if (distanceTo > 2000f)
                {
                    npc.Center = player.Center;
                }
                if (distanceTo > 48f)
                {
                    direction.Normalize();
                    direction *= speed;
                    float temp = modNPC.inertia / 2f;
                    npc.velocity = (npc.velocity * temp + direction) / (temp + 1);
                }
                else
                {
                    npc.direction = Main.player[modNPC.owner].direction;
                    npc.velocity *= (float)Math.Pow(0.9, 40.0 / modNPC.inertia);
                }
            }
            npc.rotation = npc.velocity.X * 0.05f;
            CreateDust();
            if (npc.velocity.X > 0f)
            {
                npc.spriteDirection = (npc.direction = 1);
            }
            else if (npc.velocity.X < 0f)
            {
                npc.spriteDirection = (npc.direction = -1);
            }
            if (npc.ai[1] > 0f)
            {
                npc.ai[1] += 1f;
                if (Main.rand.Next(3) == 0)
                {
                    npc.ai[1] += 1f;
                }
            }
            if (npc.ai[1] > modNPC.shootCool)
            {
                npc.ai[1]     = 0f;
                npc.netUpdate = true;
            }
            if (npc.ai[0] == 0f)
            {
                if (target == true)
                {
                    if ((targetPos - npc.Center).X > 0f)
                    {
                        npc.spriteDirection = (npc.direction = 1);
                    }
                    else if ((targetPos - npc.Center).X < 0f)
                    {
                        npc.spriteDirection = (npc.direction = -1);
                    }
                    if (npc.ai[1] == 0f)
                    {
                        npc.ai[1] = 1f;
                        if (Main.myPlayer == modNPC.owner)
                        {
                            Vector2 shootVel = targetPos - npc.Center;
                            if (shootVel == Vector2.Zero)
                            {
                                shootVel = new Vector2(0f, 1f);
                            }
                            shootVel.Normalize();
                            shootVel *= modNPC.shootSpeed;
                            int proj = Shoot(shootVel);
                            Main.projectile[proj].timeLeft  = 300;
                            Main.projectile[proj].netUpdate = true;
                            npc.netUpdate = true;
                        }
                    }
                }
            }
        }