Something like this would probably work:
1.move to food source (by pathfinding)
2.turn to face the source
3.set boolean variable "WaitingForFood" to true
4.Set timer "FoodWait" 2 seconds
1 On timer "FoodWait" if boolean "WaitingForFood" is true
4.create a piece of food sprite over npc and pin to it.
5.reduce food value remaining in food source
6.find path to home.
0.if timer "cooldown" = 0 - detect enemy
1.move to enemy and set Boolean "WaitingForFood" to false
2.turn to face the enemy
3.call attack function
4.Set timer "cooldown" for whatever seconds"