Exemple #1
0
 void Shoot()
 {
     if (Helper2.GetNearestPlayer(npc) != -1)
     {
         npc.target = Helper2.GetNearestPlayer(npc);
         Vector2 velocity = Helper2.VelocityFPTP(npc.Center, Main.player[npc.target].Center, (Power) ? PowerLaserSpeed : NormalLaserSpeed);
         int     i        = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, ShootType, (Power) ? PowerLaserDamage : NormalLaserDamage, (Power) ? PowerLaserKB : NormalLaserKB);
         Main.projectile[i].tileCollide = false;
         Main.projectile[i].friendly    = false;
     }
 }
Exemple #2
0
 void Shoot()
 {
     npc.target = Helper2.GetNearestPlayer(npc);
     if (npc.target != -1)
     {
         Vector2 velocity   = Helper2.VelocityFPTP(npc.Center, Main.player[npc.target].Center, NormalBulletSpeed);
         int     spread     = 95;
         float   spreadMult = 0.075f;
         for (int l = 0; l < 2; l++)
         {
             velocity.X = velocity.X + (float)Main.rand.Next(-spread, spread + 1) * spreadMult;
             velocity.Y = velocity.Y + (float)Main.rand.Next(-spread, spread + 1) * spreadMult;
             int i = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, NormalShootType, NormalBulletDamage, NormalBulletKB);
             Main.projectile[i].hostile  = true;
             Main.projectile[i].friendly = false;
         }
     }
 }
Exemple #3
0
 void Shoot()
 {
     npc.target = Helper2.GetNearestPlayer(npc);
     if (npc.target != -1)
     {
         Vector2 velocity   = Helper2.VelocityFPTP(npc.Center, new Vector2(Main.player[npc.target].Center.X, Main.player[npc.target].Center.Y + 20), 0.0f);
         int     spread     = 65;
         float   spreadMult = 0.05f;
         for (int l = 0; l < 2; l++)
         {
             velocity.X = velocity.X + (float)Main.rand.Next(-spread, spread + 1) * spreadMult;
             velocity.Y = velocity.Y + (float)Main.rand.Next(-spread, spread + 1) * spreadMult;
             int i = Projectile.NewProjectile(npc.Center.X, npc.Center.Y + 20, velocity.X, velocity.Y, ShootType, PowerLaserDamage, PowerLaserKB);
             Main.projectile[i].hostile     = true;
             Main.projectile[i].friendly    = false;
             Main.projectile[i].tileCollide = false;
         }
     }
 }
Exemple #4
0
        public override void AI()
        {
            npc.position += npc.velocity * 1.7f;
            if (Main.rand.Next(500) == 0 && Main.expertMode)
            {
                for (int i = 0; i < 50; i++)
                {
                    int dust = Dust.NewDust(npc.position, npc.width, npc.height, 5);
                    Main.dust[dust].scale     = 1.5f;
                    Main.dust[dust].noGravity = true;
                    Main.dust[dust].velocity *= 0f;
                    Main.dust[dust].velocity *= 0f;
                }
                npc.position.X = (Main.player[npc.target].position.X - 250) + Main.rand.Next(500);
                npc.position.Y = (Main.player[npc.target].position.Y - 250) + Main.rand.Next(500);
            }

            if (Main.rand.Next(500) == 0 && !Main.expertMode)
            {
                npc.TargetClosest(true);
                Vector2 vector142 = new Vector2(npc.Center.X, npc.Center.Y);
                float   num1243   = Main.player[npc.target].Center.X - vector142.X;
                float   num1244   = Main.player[npc.target].Center.Y - vector142.Y;
                float   num1245   = (float)Math.Sqrt((double)(num1243 * num1243 + num1244 * num1244));
                if (npc.ai[1] == 0f)
                {
                    if (Main.netMode != 1)
                    {
                        npc.localAI[1] += 1f;
                        if (npc.localAI[1] >= (float)(120 + Main.rand.Next(200)))
                        {
                            npc.localAI[1] = 0f;
                            npc.TargetClosest(true);
                            int num1249 = 0;
                            int num1250;
                            int num1251;
                            while (true)
                            {
                                num1249++;
                                num1250  = (int)Main.player[npc.target].Center.X / 16;
                                num1251  = (int)Main.player[npc.target].Center.Y / 16;
                                num1250 += Main.rand.Next(-50, 51);
                                num1251 += Main.rand.Next(-50, 51);
                                if (!WorldGen.SolidTile(num1250, num1251) && Collision.CanHit(new Vector2((float)(num1250 * 16), (float)(num1251 * 16)), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
                                {
                                    break;
                                }
                                if (num1249 > 100)
                                {
                                    //return;
                                }
                            }
                            npc.ai[1]     = 1f;
                            npc.ai[2]     = (float)num1250;
                            npc.ai[3]     = (float)num1251;
                            npc.netUpdate = true;
                            //return;
                        }
                    }
                }
                else if (npc.ai[1] == 1f)
                {
                    npc.alpha += 3;
                    if (npc.alpha >= 255)
                    {
                        npc.alpha      = 255;
                        npc.position.X = npc.ai[2] * 16f - (float)(npc.width / 2);
                        npc.position.Y = npc.ai[3] * 16f - (float)(npc.height / 2);
                        npc.ai[1]      = 2f;
                        //return;
                    }
                }
                else if (npc.ai[1] == 2f)
                {
                    npc.alpha -= 3;
                    if (npc.alpha <= 0)
                    {
                        npc.alpha = 0;
                        npc.ai[1] = 0f;
                        //return;
                    }
                }
            }

            if (Main.rand.Next(2500) == 0)
            {
                NPC.NewNPC((int)npc.position.X - 150, (int)npc.position.Y - 50, 420);
                NPC.NewNPC((int)npc.position.X + 150, (int)npc.position.Y - 50, 420);
            }

            if (npc.target != -1 && !RunAway)
            {
                if (!Main.player[npc.target].active)
                {
                    if (Helper2.GetNearestAlivePlayer(npc) == -1)
                    {
                        RunAway = true;
                    }
                    else
                    {
                        if (Main.player[Helper2.GetNearestAlivePlayer(npc)].Distance(npc.Center) > 2500f)
                        {
                            RunAway = true;
                        }
                        else
                        {
                            npc.target = Helper2.GetNearestAlivePlayer(npc);
                        }
                    }
                }
            }
            if (Main.dayTime || RunAway || npc.localAI[3] == 1)
            {
                npc.localAI[3] = 1;
                if (Main.npc[(int)npc.ai[2]].type == mod.NPCType("SoulofTrust") && Main.npc[(int)npc.ai[2]].active == true)
                {
                    Main.npc[(int)npc.ai[2]].localAI[3] = 1;
                }
                if (Main.npc[(int)npc.ai[3]].type == mod.NPCType("SoulofTruth") && Main.npc[(int)npc.ai[3]].active == true)
                {
                    Main.npc[(int)npc.ai[3]].localAI[3] = 1;
                }
                npc.life    += 11;
                npc.aiStyle  = 0;
                npc.rotation = 0;
                npc.velocity = Helper2.VelocityFPTP(npc.Center, new Vector2(npc.Center.X, npc.Center.Y - 4815162342), 30.0f);
                CreateDust();
                return;
            }
            if (StateFlag)
            {
                if (
                    !((Main.npc[(int)npc.ai[2]].type == mod.NPCType("SoulofTrust") && Main.npc[(int)npc.ai[2]].active == true)) ||
                    !((Main.npc[(int)npc.ai[3]].type == mod.NPCType("SoulofTruth") && Main.npc[(int)npc.ai[3]].active == true))
                    )
                {
                    StateFlag = false;
                    OnlyPower = true;
                }
            }
            if (OnlyPower)
            {
                SetStage(true);
            }
            else
            {
                SetStage(Main.player[Helper2.GetNearestPlayer(npc)].Distance(npc.Center) <= DistantionToPower);
            }
            SetRotation();
            CreateDust();
            TimeToShoot--;
            if (TimeToShoot <= 0)
            {
                TimeToShoot = (Power) ? PowerShootRate : NormalShootRate;
                Shoot();
            }
        }
Exemple #5
0
        public override void AI()
        {
            npc.position += npc.velocity * 1.7f;
            if (Main.rand.Next(500) == 0 && Main.expertMode)
            {
                for (int i = 0; i < 50; i++)
                {
                    int dust = Dust.NewDust(npc.position, npc.width, npc.height, 6);
                    Main.dust[dust].scale     = 1.5f;
                    Main.dust[dust].noGravity = true;
                    Main.dust[dust].velocity *= 0f;
                    Main.dust[dust].velocity *= 0f;
                }
                npc.position.X = (Main.player[npc.target].position.X - 250) + Main.rand.Next(500);
                npc.position.Y = (Main.player[npc.target].position.Y - 250) + Main.rand.Next(500);
            }

            if (Main.rand.Next(500) == 0 && !Main.expertMode)
            {
                npc.TargetClosest(true);
                Vector2 vector142 = new Vector2(npc.Center.X, npc.Center.Y);
                float   num1243   = Main.player[npc.target].Center.X - vector142.X;
                float   num1244   = Main.player[npc.target].Center.Y - vector142.Y;
                float   num1245   = (float)Math.Sqrt((double)(num1243 * num1243 + num1244 * num1244));
                if (npc.ai[1] == 0f)
                {
                    if (Main.netMode != 1)
                    {
                        npc.localAI[1] += 1f;
                        if (npc.localAI[1] >= (float)(120 + Main.rand.Next(200)))
                        {
                            npc.localAI[1] = 0f;
                            npc.TargetClosest(true);
                            int num1249 = 0;
                            int num1250;
                            int num1251;
                            while (true)
                            {
                                num1249++;
                                num1250  = (int)Main.player[npc.target].Center.X / 16;
                                num1251  = (int)Main.player[npc.target].Center.Y / 16;
                                num1250 += Main.rand.Next(-50, 51);
                                num1251 += Main.rand.Next(-50, 51);
                                if (!WorldGen.SolidTile(num1250, num1251) && Collision.CanHit(new Vector2((float)(num1250 * 16), (float)(num1251 * 16)), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
                                {
                                    break;
                                }
                                if (num1249 > 100)
                                {
                                    //return;
                                }
                            }
                            npc.ai[1]     = 1f;
                            npc.ai[2]     = (float)num1250;
                            npc.ai[3]     = (float)num1251;
                            npc.netUpdate = true;
                            //return;
                        }
                    }
                }
                else if (npc.ai[1] == 1f)
                {
                    npc.alpha += 3;
                    if (npc.alpha >= 255)
                    {
                        npc.alpha      = 255;
                        npc.position.X = npc.ai[2] * 16f - (float)(npc.width / 2);
                        npc.position.Y = npc.ai[3] * 16f - (float)(npc.height / 2);
                        npc.ai[1]      = 2f;
                        //return;
                    }
                }
                else if (npc.ai[1] == 2f)
                {
                    npc.alpha -= 3;
                    if (npc.alpha <= 0)
                    {
                        npc.alpha = 0;
                        npc.ai[1] = 0f;
                        //return;
                    }
                }
            }

            if (NPC.AnyNPCs(mod.NPCType("SoulofHope")) || NPC.AnyNPCs(mod.NPCType("SoulofTrust")))
            {
                npc.dontTakeDamage = true;
            }
            if (NPC.AnyNPCs(mod.NPCType("SoulofHope")) || NPC.AnyNPCs(mod.NPCType("SoulofTrust")))
            {
                npc.dontTakeDamage = false;
            }

            if (Main.expertMode && Main.rand.Next(4500) == 0)
            {
                NPC.NewNPC((int)npc.position.X - 100, (int)npc.position.Y - 50, 418);
                NPC.NewNPC((int)npc.position.X + 100, (int)npc.position.Y - 50, 418);
            }

            if (Main.rand.Next(2) == 0)
            {
                int num706 = Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 200, npc.color, 0.5f);
                Main.dust[num706].velocity *= 0.6f;
            }


            if (npc.target != -1 && !RunAway)                                                             //если(пнс.цель не варно -1 И не убегать)
            {
                if (!Main.player[npc.target].active)                                                      //если (не мой.игрок[нпс.цель].активный)
                {
                    if (Helper2.GetNearestAlivePlayer(npc) == -1)                                         //если (Помощьник.ПолучитьКоординатыИгрока(нпс) присвоить -1)
                    {
                        RunAway = true;                                                                   //Убегает = да
                    }
                    else                                                                                  //или
                    {
                        if (Main.player[Helper2.GetNearestAlivePlayer(npc)].Distance(npc.Center) > 2500f) //если(Мой.игрок[Помощьник.ПолучитьКоординатыИгрока(нпс)].Дистанция(нпс.Центр) больше 2500фунтов)
                        {
                            RunAway = true;                                                               //Убегает = да
                        }
                        else                                                                              //или...
                        {
                            npc.target = Helper2.GetNearestAlivePlayer(npc);                              //нпс.цель равно Помощьник.ПолучитьКоординатыИгрока(нпс)
                        }
                    }
                }
            }
            if (Main.dayTime || RunAway || npc.localAI[3] == 1)                                                               //если(Мой.День или Убегать или нпс.местный ИИ 3 к 1)
            {
                npc.localAI[3] = 1;                                                                                           //нпс.местный ИИ[3] равен 3
                if (Main.npc[(int)npc.ai[2]].type == mod.NPCType("SoulofHope") && Main.npc[(int)npc.ai[2]].active == true)    //если(Мой.нпс[(значение)нпс.ИИ[2]].тип равен мод.НПС Тип("МОБ") и Мой.нпс[(значение)нпс.ИИ[2]].активен равен да)
                {
                    Main.npc[(int)npc.ai[2]].localAI[3] = 1;                                                                  //Мой.нпс[(значение)нпс.ИИ[2]].местный ИИ[3] варно 1
                }
                if (Main.npc[(int)npc.ai[3]].type == mod.NPCType("SoulofTruth") && Main.npc[(int)npc.ai[3]].active == true)   //если(Мой.нпс[(значение)нпс.ИИ[2]].тип равен мод.НПС Тип("МОБ") и Мой.нпс[(значение)нпс.ИИ[2]].активен равен да)
                {
                    Main.npc[(int)npc.ai[3]].localAI[3] = 1;                                                                  //Мой.нпс[(значение)нпс.ИИ[2]].местный ИИ[3] варно 1
                }
                npc.life    += 11;                                                                                            //нпс.жизнь прибавить
                npc.aiStyle  = 0;                                                                                             //нпс.ИИ Стиль - 0
                npc.rotation = 0;
                npc.velocity = Helper2.VelocityFPTP(npc.Center, new Vector2(npc.Center.X, npc.Center.Y - 4815162342), 30.0f); //нпс.поворот = Помощьник.ПоворотФПТП(нпс.Центр, новый Вектор2(нпс.Центр.X, нпс.Центр.Y - 4815162342))
                CreateDust();
                return;
            }
            if (StateFlag)
            {
                if (
                    !((Main.npc[(int)npc.ai[2]].type == mod.NPCType("SoulofHope") && Main.npc[(int)npc.ai[2]].active == true)) ||
                    !((Main.npc[(int)npc.ai[3]].type == mod.NPCType("SoulofTruth") && Main.npc[(int)npc.ai[3]].active == true))
                    )
                {
                    StateFlag = false;
                    OnlyPower = true;
                }
            }
            if (OnlyPower)
            {
                SetStage(true);
            }
            else
            {
                CurrentPower += Step;
                if (CurrentPower <= 0 || CurrentPower >= PowerTime)
                {
                    Step *= -1;
                    SetStage(!Power);
                }
            }
            SetRotation();
            CreateDust();
            TimeToShoot--;
            if (TimeToShoot <= 0 && !Power)
            {
                TimeToShoot = NormalShootRate;
                Shoot();
                return;
            }
            if (TimeToShoot <= 0 && Power)
            {
                TimeToShoot = PowerShootRate;
                npc.target  = Helper2.GetNearestPlayer(npc);
                if (npc.target != -1)
                {
                    for (int a = 0; a < 5; a++)
                    {
                        Vector2 velocity   = Helper2.VelocityFPTP(npc.Center, Main.player[npc.target].Center, PowerBulletSpeed);
                        int     spread     = 65;
                        float   spreadMult = 0.05f;
                        velocity.X = velocity.X + (float)Main.rand.Next(-spread, spread + 1) * spreadMult;
                        velocity.Y = velocity.Y + (float)Main.rand.Next(-spread, spread + 1) * spreadMult;
                        int i = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, PowerShootType, PowerBulletDamage, PowerBulletKB);
                        Main.projectile[i].hostile  = true;
                        Main.projectile[i].friendly = true;
                    }
                }
                return;
            }
        }