Refactoring the context-based combat PR v2

This is a duplicate of #7125.