PC Andrew Harper paid the “ultimate price for his bravery” when he was killed, a court hears.