undamage=DamageThing(thing, damage, flags, damager);
undamage: This is the amount of damage that was not applied to the thing.
damage: This is the amout of health to subtract from the thing. This becomes the first parameter of the damaged message.
flags: This is the Damage Flag for the damage. This tells the exe and the damaged message the type of the damage. This flag becomes the second parameter of the damaged message.
damager: This is the thing that caused the damage. This thing becomes the source of the damaged message. Remember that the damager is most often a projectile or explosion and not a player.
Aside from the class and capture cogs, the 0x10 Inventory Flag will make the local player's damaged message run in an items.dat cog.