コード例 #1
0
ファイル: ArmedGNPC.cs プロジェクト: DarthHA/NPCAttacker
        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;
                }
            }
        }