This seems pretty simple, actually. Dedicate a switch to this, and then under "Battle_Action_AttacksPriority", locate "if needRearranging". There is a section within it that says "elsif @priorityTrickRoom", which simply needs to be edited.
Only briefly tested, but I believe this should work, as...