1. Copy and paste the entire function from Blizzard's code into your addon file.
2. Add a "local" keyword in front of the function definition so it only exists in your file, not everywhere. "function DoStuff(x)" --> "local function DoStuff(x)"
3. Change each instance of the function names I mentioned where they're called from inside the function.
4.
Set a new OnEvent handler on the CombatText frame, passing it your modified function.
You can use
this tool to generate an addon package for your code if you're not sure how to write a TOC file and set up your folder structure.