False Alibi

Enchantment (Compulsion) [mind-affecting]
Level: Artificer * 3, Bard * 3, Cleric */Oracle * 3, Inquisitor * 3
Components: V, S, M (emerald dust worth 100 gp)
Casting Time: 1 round
Range: close (25 ft. + 5 ft./2 levels)
Target: one living creature
Duration: permanent; see text
Saving Throw: Will negates
Spell Resistance: yes
  This spell functions similarly to modify memory, except you can modify the target's memory only in a specific way. In response to a triggering condition you determine, up to the last 5 minutes of the target's memory are eliminated and replaced with a memory of your choosing (or no memory at all). For example, you could cast this on an assassin, set it to trigger when he completes his kill, and replace his memory of the murder with the memory of him discovering the body and picking up the murder weapon. You can cast this spell multiple times on the same target, even with the same trigger, affecting different memories. A single casting of false alibi affects a creature only until the specified condition has been triggered; once a condition has been triggered and the target's memory altered, that condition no longer triggers this spell unless the victim is subject to another casting of false alibi that specifies the same trigger.