Exemple #1
0
        bool canHit(NPC npc)
        {
            if (!(NPCLoader.CanBeHitByProjectile(npc, projectile) ?? true))
            {
                return(false);
            }
            if (!(PlayerHooks.CanHitNPCWithProj(projectile, npc) ?? true))
            {
                return(false);
            }
            Player player = Main.player[projectile.owner];

            if (npc.friendly)
            {
                switch (npc.type)
                {
                case NPCID.Guide:
                    return(player.killGuide);

                case NPCID.Clothier:
                    return(player.killClothier);

                default:
                    return(false);
                }
            }
            return(true);
        }
        private bool hitAndAttachProjectile(NPC npc)
        {
            if (!npc.active || npc.immortal || npc.dontTakeDamage ||
                (npc.friendly && !(npc.type == NPCID.Guide && Main.player[projectile.owner].killGuide) && !(npc.type == NPCID.Clothier && Main.player[projectile.owner].killClothier))
                )
            {
                if (npc.type != NPCID.TargetDummy)
                {
                    return(false);
                }
            }
            bool?b = NPCLoader.CanBeHitByProjectile(npc, projectile);

            if (b.HasValue && !b.Value)
            {
                return(false);
            }
            b = ProjectileLoader.CanHitNPC(projectile, npc);
            if (b.HasValue && !b.Value)
            {
                return(false);
            }
            b = PlayerHooks.CanHitNPCWithProj(projectile, npc);
            if (b.HasValue && !b.Value)
            {
                return(false);
            }

            npcIndex = (short)npc.whoAmI;
            npc.GetGlobalNPC <FishGlobalNPC>(mod).isHooked++;
            if (Main.player[projectile.owner].GetModPlayer <FishPlayer>(mod).seals)
            {
                npc.GetGlobalNPC <FishGlobalNPC>(mod).isSealed++;
            }
            projectile.Center = npc.Center;
            updatePos         = false;

            if (Main.netMode != 0)
            {
                /*
                 * ModPacket pk = mod.GetPacket();
                 * pk.Write((byte)2);
                 * pk.Write((ushort)(projectile.whoAmI));
                 * pk.Write(npcIndex);
                 * pk.Write(projectile.ai[0]);
                 * pk.Send();*/
                NetMessage.SendData(27, -1, -1, null, projectile.whoAmI, 0f, 0f, 0f, 0, 0, 0);
            }

            /*  if(projectile.damage > 0)
             * {
             *    //Main.NewText("Entered npc " + npcIndex + " into bobber " + projectile.whoAmI + " from player " + projectile.owner + ";");
             *    damageNPC(npc);
             * }*/
            return(true);
        }