Flights are probably expensive because August is still part of the peak period of travel in Croatia. You might find flights significantly cheaper if you push the trip to the first or second week of September, into shoulder season.
If you want to include Slovenia, consider flying to Venice and taking a shuttle directly from the airport to Ljubljana (DRD or GoOpti, maybe even FlixBus these days). If you can't get a good flight home out of Dubrovnik, a round trip to/from Venice might work if you can find a budget flight (not every day so you need to schedule precisely) from Dubrovnik to Venice and perhaps spend a final night in Venice before flying home. Or open jaw (multi-city) into Venice, out of London, Paris, Amsterdam, or Frankfurt if you can get great flights and also find a direct flight the day before from Dubrovnik.
Try to include Plitvice Lakes National Park on your agenda. It's a beautiful (though touristy) park and doesn't require strenuous hiking to enjoy.