well supposing you want it to do it when you fire the NPC do it like this
NPC Code:
if (weaponfired) {
disabledefmovement;
}
if (keydown(4)) {
whatever it does;
}
just put in the keydown 4 bit a thing to check the player still has ammo or whatever it uses