Well logically thinking it's quite simple to program
class Rules
{
boolean dropGoalAvailable;
void dropGoal()
{
if( play == scrum or free kick)
{
dropGoalAvailable = false
}
else
{
dropGoalAvailable = true
insert into AI commands list (or something)
}
}
You aren't allowed a drop goal from a free kick, or a scrum taken in lieu of that free kick, but you can take one from any other scrum (for a knock on, forward pass, not straight into a line-out etc) including one taken in lieu of a penalty kick.
So AIUI firstly, your code is going to have to distinguish between
1 a scrum ordered by the referee for an infringement (DG = allowed),
2 a scrum chosen by the player after being awarded a penalty (DG = allowed)
3 a scrum chosen by the player after being awarded a free kick (DG = not allowed)
and then for option 3, DG continues to = not allowed until such time as the ball is touched by an opposing player or the ball carrier is tackled. This could mean that several passes and kicks might ensue after the scrum, and the DG would still be not allowed,
e.g. scrum half passes to 10, who passes to 12, inside pass to 15, who is tackled
but not brought to ground, and he offloads back to 13, who fires a long pass out to 10 waiting in the pocket, who has a drop kick at goal, but it would be disallowed, because no opponent touched the ball, and no ball carrier was tackled and brought to ground.
Now this might be an unlikely scenario, but the game should to allow for something like this.