An alternative solution to break the hp/mp 9999 caps is to divide all damage and health points across the game (players and monsters alike) by a factor of 10, that way your 999 will be the equivalent of the original 9999, but with the theoretical possibility of reaching 9999 which would be equivalent to the original 99999.
Not sure if this is harder to implement, just wanted to provide a different point of view to it, just in case a direct solution to modify the actual hp/mp caps is not provided.