Exemplo n.º 1
0
        public override void TownNPCAttackSwing(NPC npc, ref int itemWidth, ref int itemHeight)
        {
            if (!SomeUtils.BuffNPC())
            {
                return;
            }
            if (Weapon.IsAir)
            {
                return;
            }

            itemWidth  = Weapon.width;
            itemHeight = Weapon.height;
            if (Weapon.shoot != ProjectileID.None)
            {
                if (!MeleeAttacked)
                {
                    MeleeAttacked = true;

                    bool    ShouldShoot = true;
                    int     shoot       = Weapon.shoot;
                    int     dmg         = Main.LocalPlayer.GetWeaponDamage(Weapon);
                    float   Kb          = Main.LocalPlayer.GetWeaponKnockback(Weapon, Weapon.knockBack);
                    Vector2 Pos         = npc.Center;
                    Vector2 Speed;
                    if (SomeUtils.AttackMode())
                    {
                        Speed = Vector2.Normalize(Main.MouseWorld - npc.Center) * Weapon.shootSpeed;
                    }
                    else
                    {
                        Speed = new Vector2(1, 0) * npc.direction * Weapon.shootSpeed;
                    }
                    if (Weapon.modItem != null)
                    {
                        ShouldShoot = Weapon.modItem.Shoot(Main.LocalPlayer, ref Pos, ref Speed.X, ref Speed.Y, ref shoot, ref dmg, ref Kb);
                    }
                    if (ShouldShoot)
                    {
                        if (VanillaItemProjFix.TransFormProj(Weapon.type) != -1)
                        {
                            shoot = VanillaItemProjFix.TransFormProj(Weapon.type);
                        }
                        int protmp = Projectile.NewProjectile(Pos, Speed, shoot, dmg, Kb, Main.myPlayer);
                        Main.projectile[protmp].npcProj              = true;
                        Main.projectile[protmp].noDropItem           = true;
                        Main.projectile[protmp].usesLocalNPCImmunity = true;
                        if (Main.projectile[protmp].localNPCHitCooldown > 10)
                        {
                            Main.projectile[protmp].localNPCHitCooldown = 10;
                        }
                    }
                    if (Weapon.UseSound != null)
                    {
                        Main.PlaySound(Weapon.UseSound, npc.Center);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override void TownNPCAttackProj(NPC npc, ref int projType, ref int attackDelay)
        {
            if (!SomeUtils.BuffNPC())
            {
                return;
            }
            if (Weapon.IsAir)
            {
                return;
            }
            if (npc.type == NPCID.Nurse)
            {
                return;
            }
            attackDelay = 1;

            if (NPCID.Sets.AttackType[npc.type] == 0 || NPCID.Sets.AttackType[npc.type] == 2)
            {
                int shoot = Weapon.shoot;
                if (npc.localAI[3] == 0)
                {
                    if (Weapon.modItem != null)
                    {
                        int     dmg = Main.LocalPlayer.GetWeaponDamage(Weapon);
                        Vector2 Pos = npc.Center;
                        Vector2 Speed;
                        if (NPCTargetForSpecialUse != -1)
                        {
                            Speed = Vector2.Normalize(Main.npc[NPCTargetForSpecialUse].Center - npc.Center) * Weapon.shootSpeed;
                        }
                        else
                        {
                            Speed = new Vector2(npc.direction, 0) * Weapon.shootSpeed;
                        }
                        float Kb = Weapon.knockBack;
                        if (Weapon.modItem.Shoot(Main.LocalPlayer, ref Pos, ref Speed.X, ref Speed.Y, ref shoot, ref dmg, ref Kb))
                        {
                            projType = shoot;
                        }
                        else
                        {
                            projType = 0;
                        }
                    }
                    else
                    {
                        projType = shoot;
                        if (VanillaItemProjFix.TransFormProj(Weapon.type) != -1)
                        {
                            projType = VanillaItemProjFix.TransFormProj(Weapon.type);
                        }
                    }
                }
                else
                {
                    projType = 0;
                }
            }
            else if (NPCID.Sets.AttackType[npc.type] == 1)                  //大头射手
            {
                if (!SomeUtils.HasAmmo(Weapon))
                {
                    projType = 0;
                    return;
                }
                if (npc.localAI[3] == 0)
                {
                    if (Weapon.modItem != null)
                    {
                        int shoot;
                        if (SomeUtils.ItsAmmoShootProj(Weapon) > 0)
                        {
                            shoot = SomeUtils.PickAmmo(Weapon);
                        }
                        else
                        {
                            shoot = Weapon.shoot;
                        }

                        int     dmg = Main.LocalPlayer.GetWeaponDamage(Weapon);
                        Vector2 Pos = npc.Center;
                        Vector2 Speed;
                        if (NPCTargetForSpecialUse != -1)
                        {
                            Speed = Vector2.Normalize(Main.npc[NPCTargetForSpecialUse].Center - npc.Center) * Weapon.shootSpeed;
                        }
                        else
                        {
                            Speed = new Vector2(npc.direction, 0) * Weapon.shootSpeed;
                        }
                        float Kb = Weapon.knockBack;
                        if (Weapon.modItem.Shoot(Main.LocalPlayer, ref Pos, ref Speed.X, ref Speed.Y, ref shoot, ref dmg, ref Kb))
                        {
                            projType = shoot;
                        }
                        else
                        {
                            projType = 0;
                        }
                    }
                    else
                    {
                        if (SomeUtils.ItsAmmoShootProj(Weapon) > 0)
                        {
                            bool ForceChange = false;
                            if (Weapon.useAmmo == AmmoID.Bullet || Weapon.useAmmo == AmmoID.Arrow || Weapon.useAmmo == AmmoID.Dart || Weapon.useAmmo == AmmoID.NailFriendly)
                            {
                                if (VanillaItemProjFix.IsUseSpecialProj[Weapon.type] != 0)
                                {
                                    ForceChange = true;
                                }
                            }
                            if (ForceChange)
                            {
                                projType = VanillaItemProjFix.IsUseSpecialProj[Weapon.type];
                            }
                            else
                            {
                                projType = SomeUtils.PickAmmo(Weapon);
                            }
                        }
                        else
                        {
                            projType = Weapon.shoot;
                            if (Weapon.type == ItemID.Toxikarp)
                            {
                                projType = ProjectileID.ToxicBubble;
                            }
                            if (Weapon.type == ItemID.Harpoon)
                            {
                                projType = ProjectileID.Harpoon;
                            }
                        }
                        if (VanillaItemProjFix.TransFormProj(Weapon.type) != -1)
                        {
                            projType = VanillaItemProjFix.TransFormProj(Weapon.type);
                        }
                    }
                }
                else
                {
                    projType = 0;
                }
            }
        }