"And Cornelius waited for them, having called together his kinsmen and special friends. And it came to pass, that when Peter was come in, Cornelius came to meet him...
"And Peter opening his mouth, said: In very deed I perceive, that God is not a respecter of persons. But in every nation, he that feareth him, and worketh justice, is acceptable to him. God sent the word to the children of Israel, preaching peace by Jesus Christ: (he is Lord of all.) You know the word which hath been published through all Judea: for it began from Galilee, after the baptism which John preached, Jesus of Nazareth: how God anointed him with the Holy Ghost, and with power, who went about doing good, and healing all that were oppressed by the devil, for God was with him. And we are witnesses of all things that he did in the land of the Jews and in Jerusalem, whom they killed, hanging him upon a tree. Him God raised up the third day, and gave him to be made manifest, Not to all the people, but to witnesses preordained by God, even to us, who did eat and drink with him after he arose again from the dead; And he commanded us to preach to the people, and to testify that it is he who was appointed by God, to be judge of the living and of the dead. To him all the prophets give testimony, that by his name all receive remission of sins, who believe in him.
Cornelius was worshiping in a false religion, undeniably. But he was good willed enough that God was pleased to bring him into the true faith. His reception of the Holy Ghost prior to baptism was not an indwelling, but rather the grace of the Holy Ghost acting externally upon him, enabling him to confess the truth that Jesus is God.
1 Corinthians 12:3: "And no man can say the Lord Jesus, but by the Holy Ghost."
His prayers and alms did not merit this grace, but rather impetrated this favour from the bountiful mercy of God. It is important to note the distinction between the concept of merit and that of impetration, and it is summed up succinctly by St. Thomas:
St. Thomas Aquinas, Summa, Prima Secunda Partis, Q. 114, Article 9, Reply to Objection 1: "We impetrate in prayer things that we do not merit, since God hears sinners who beseech the pardon of their sins, which they do not merit, as appears from Augustine on John 11:31, "Now we know that God doth not hear sinners," otherwise it would have been useless for the publican to say: "O God, be merciful to me a sinner," Luke 18:13. So too may we impetrate of God in prayer the grace of perseverance either for ourselves or for others, although it does not fall under merit."
Naturally, it would be essential that a person who is outside of the Catholic Church, if he wished to impetrate anything at all from God, would have to ask for his own conversion to the truth, with a humble heart, if he would expect to get anything of value from God. He may be obstinately and stubbornly convinced that his sect is true, but yet remain good willed - as long as he has not yet been exposed to the sound arguments and proofs that show his sect to be false, whereupon his obstinacy (if he were good willed) would be then melted away.
This is one reason why it is important for Christians to have soundness of doctrine, steadfastness of faith and courage in proclaiming Jesus, without any admixture of error. As St. Peter says: "But sanctify the Lord Christ in your hearts, being ready always to satisfy every one that asketh you a reason of that hope which is in you." (1st. St. Peter 3:15)
Cornelius being a Gentile, he neither worshiped the true God, nor even knew who He is, yet knew enough to give alms and to pray. Let us assume for the sake of discussion that he had been approached by followers of another false religion who offered arguments to him that there was no God at all, or perhaps that Jupiter is god. Such arguments cannot be sound, since they are arguments for a falsehood. Cornelius, if he had flatly refused to accept their arguments would appear by any observer to be obstinate or stubborn in his false beliefs - and until St. Peter visited him with sound arguments and truth, he never had any reason to abandon any part of those beliefs.
Does this mean that Cornelius was able to please God?
If God is pleased with someone, then that someone is His friend (is God pleased by his enemies? God forbid!). If he dies while pleasing Him, he will assuredly go to Heaven. So it cannot be said that Cornelius was yet pleasing to God or that he was friends with God, since he did not yet fulfill the necessary confession of Christ and receive baptism, even though he may have been invincibly ignorant.
St. John 14:6: "Jesus saith to him: I am the way, and the truth, and the life. No man cometh to the Father, but by me.'
St. John 3:5: "Jesus answered: Amen, amen I say to thee, unless a man be born again of water and the Holy Ghost, he cannot enter into the kingdom of God."
So how is it then, that the angel said to him: "Thy prayers and thy alms are ascended for a memorial in the sight of God."?
It is not because Cornelius' prayers and alms were either pleasing to God in themselves or meritorious, but rather that God, in giving him the prevenient grace to earnestly desire the truth, also gave the grace to perform such actions as would benefit him spiritually ONCE HE CONVERTED, forming in him a good habit. Since Cornelius responded to this grace and made petitions to God, he was able to impetrate his own conversion from darkness, where he could never please God, into the light of the Gospel, and the Faith of Jesus Christ. God accepted Cornelius, then, because Cornelius accepted God's grace.
It is not altogether forbidden for good willed non-Catholics to pray or offer sacrifices to God, even if they do not yet know Him, so long as they are doing so for the purpose of obtaining the truth and contrition for their sins, and ready to accept correction for any false notions they may have about Him when the truth is made manifest.
Remember that in receiving what he prayed for, Cornelius did not effect a change in God's will or action, but God simply put into effect what He had eternally foreknown in view of Cornelius' humility. It is by God's mercy that He not only gave Cornelius this grace, but that He deigned to answer his prayers, by sending St. Peter and freely offering the gift of faith by his words and sanctifying grace through baptism.
Romans 10:17: "Faith then cometh by hearing; and hearing by the word of Christ."
Pope Julius III, Council of Trent, Session 14, Chapter 1: "[...] Peter, the prince of the apostles, recommending penitence to sinners who were about to be initiated by baptism, said; Do penance, and be baptized every one you."
The prayers and penance performed by a good willed person before he has entered the true faith, while they do not merit eternal rewards, nevertheless may pertain to the prevenient grace of God and help to establish and strengthen the dispositions necessary for a soul to enter into justification.
This is consistent with the Council of Trent's definitions on justification:
Pope Paul III, Council of Trent, Session 6, Chapter 5, ex cathedra: "[...] the beginning of the said Justification is to be derived from the prevenient grace of God, through Jesus Christ, that is to say, from His vocation, whereby, without any merits existing on their parts, they are called; that so they, who by sins were alienated from God, may be disposed through His quickening and assisting grace, to convert themselves to their own justification, by freely assenting to and co-operating with that said grace"
Pope Paul III, Council of Trent, Session 6, Chapter 8, ex cathedra: "And whereas the Apostle saith, that man is justified by faith and freely, those words are to be understood in that sense which the perpetual consent of the Catholic Church hath held and expressed; to wit, that we are therefore said to be justified by faith, because faith is the beginning of human salvation, the foundation, and the root of all Justification; without which it is impossible to please God, and to come unto the fellowship of His sons: but we are therefore said to be justified freely, because that none of those things which precede justification - whether faith or works - merit the grace itself of justification."
God gives those who do not worship Him, but who truly desire to know Him in truth, the grace to ask for what they ought to ask for. Although they are of themselves incapable of addressing their petitions to Him whom they know not, in the gratuity of His mercy he grants their supplication unto them if they are sincere. So while a man must choose to cooperate with the free gift of God's grace, it is the grace itself that disposes him to make such a choice.
St. John 15:5: "[W]ithout Me you can do nothing"
What Must You Do To Get to Heaven?