[I am assuming that you need a visa to enter South Africa, and aren't exempt based on your nationality.]
It is quite likely that you will be denied boarding by TAAG at Luanda. The reason is that as far as TAAG is concerned, you are flying to South Africa. They aren't supposed to fly people to South Africa that don't have the necessary paperwork, so if you aren't eligible for entry to South Africa, you're out.
If you can convince TAAG that you are indeed just transiting in Cape Town, you still can't take (checked-in) luggage. The reason is that you would indeed need to pass immigration, collect it, and recheck it. You also need to check how exactly South Africa's transit visa exemption policy is phrased (and interpreted) to see whether it covers self-transfer. Finally, depending how airports are set-up, there can be other obstructions to just staying airside while not formally having a connecting ticket.
Overall, self-connections via airports you don't have the paperwork for are a bad idea. You probably should either rebook your flights or get a visa for South Africa.