anchor.diff:      //(it could appear again, f.e. by script)
       fHome.ResourceDepleted := False;
   
  -  if TM.WorkPlan.IsIssued
  -    and ((TM.WorkPlan.Resource1 = wtNone) or (fHome.CheckResIn(TM.WorkPlan.Resource1) >= TM.WorkPlan.Count1))
  -    and ((TM.WorkPlan.Resource2 = wtNone) or (fHome.CheckResIn(TM.WorkPlan.Resource2) >= TM.WorkPlan.Count2))
  -    and (fHome.CheckResOut(TM.WorkPlan.Product1) < MAX_WARES_IN_HOUSE)
  -    and (fHome.CheckResOut(TM.WorkPlan.Product2) < MAX_WARES_IN_HOUSE) then
  -  begin
  -    //if gResHouses[fHome.HouseType].DoesOrders then
  -      //Take order to production
  -      //fHome.ResOrder[Res] := fHome.ResOrder[Res] - 1;
  -    Result := TM;
  -  end
  -  else
  -  begin
  -    TM.Free;
  -    Result := nil;
  -  end;
  +  // Verify the task can be done
  +  if not ( //todo: Invert negation here
  +  tm.WorkPlan.IsIssued
  +  and ((tm.WorkPlan.Resource1 = wtNone) or (fHome.CheckResIn(tm.WorkPlan.Resource1) >= tm.WorkPlan.Count1))
  +  and ((tm.WorkPlan.Resource2 = wtNone) or (fHome.CheckResIn(tm.WorkPlan.Resource2) >= tm.WorkPlan.Count2))
  +  and (fHome.CheckResOut(tm.WorkPlan.Product1) < MAX_WARES_IN_HOUSE)
  +  and (fHome.CheckResOut(tm.WorkPlan.Product2) < MAX_WARES_IN_HOUSE)
  +  ) then
  +    // If task can't be done - discard it
  +    FreeAndNil(fTask);
   end;
   
   
   { TKMUnitRecruit }
  -function TKMUnitRecruit.InitiateActivity: TKMUnitTask;
  +procedure TKMUnitRecruit.TaskGetWork;
   var
     enemy: TKMUnit;
   begin
  -  Result := nil;
  -
  -  //See if we are in a tower and have something to throw
  +  fTask := nil;
  +
  +  // See if we are in a tower and have something to throw
     if not (fHome is TKMHouseTower) or (fHome.CheckResIn(wtStone) <= 0) then
       Exit;
   
     enemy := gTerrain.UnitsHitTestWithinRad(fPositionRound, RANGE_WATCHTOWER_MIN, RANGE_WATCHTOWER_MAX, Owner, atEnemy, dirNA, not RANDOM_TARGETS);
   
  -  //Note: In actual game there might be two Towers nearby,
  -  //both throwing a stone into the same enemy. We should not
  -  //negate that fact, thats real-life situation.
  +  // Note: In actual game there might be two Towers nearby,
  +  // both throwing a stone into the same enemy. We should not
  +  // negate that fact, thats real-life situation.
   
     if enemy <> nil then
  -    Result := TKMTaskThrowRock.Create(Self, enemy);
  +    fTask := TKMTaskThrowRock.Create(Self, enemy);
   end;
   
   
  
positive.code: end;
  
  
  function TKMUnitCitizen.InitiateActivity: TKMUnitTask;
  var
    res: Integer;
    TM: TKMTaskMining;
  begin
    Result := nil;
  
    if not KMSamePoint(fPositionRound, fHome.Entrance) then
      raise ELocError.Create('Mining from wrong spot', fPositionRound);
  
    res := 1;
    //Check if House has production orders
    //Ask the house what order we should make
    if gResHouses[fHome.HouseType].DoesOrders then
    begin
      res := fHome.PickOrder;
  
negative.code:   private
      procedure CleanHousePointer(aFreeAndNilTask: Boolean = False);
    protected
      procedure TaskGetWork; virtual; abstract;
      function FindHome: Boolean;
      procedure ProceedHouseClosedForWorker;
    public
  