Affinity

Affinity is a companion gameplay mechanic in Fallout 4. Companions can develop personal connections to your character and some may ask for your help with quests of their own. Each companion has a distinct personality and values, actions or dialogue that please one companion may displease another.

Raising the affinity value grants additional dialogue into their history or the possibility of romance. Reaching maximum affinity with a companion will unlock a special perk. The affinity value is a hidden statistic, meaning its not possible to check your progress without console commands.

Scale
Typically, all companions begin at an affinity value of 0. If the affinity value reaches a certain positive level, they will "admire" you and often reveal new dialogue. Raising their affinity to the maximum value of 1000 will result in them "idolizing" you, at which point you are granted their companion perk.

Lowering the affinity into a negative value far enough will displease the companion, and they will issue a single warning to you, asking you to change your ways. If the affinity value drops further, they will become angry and refuse to travel with you. This decision is permanent.

For most companions, new dialogue will be triggered when the affinity value reaches 250, 500, 750 and 1000.

Reactions
There are four different reactions a companion can have towards your actions/dialogue that will affect their affinity value:

There is a romance affinity level with the humanoid companions, once you reach the highest affinity you have a choice to "flirt", then be "romantic". It requires a high charisma to succeed, but if you do succeed, that companion becomes a love interest. Sleeping in a bed with them nearby will also grant the Lover's Embrace perk.

Companion romances are not mutually exclusive; if a new companion is romanced, previously romanced partners will still confer the benefits of the Lover's Embrace. (However, some romanced partners will "dislike" flirting in their presence.)

A companion's reaction to most actions have a cooldown period, meaning it is not possible to perform the same action several times in a row to gain/lose affinity. For example, modifying several weapons in a row will only trigger one instance of approval from Paladin Danse. One (albeit time consuming) exploit around the cooldown is to save and reload after a companion's reaction. Reloading the game resets the cooldown and the action can be performed again to gain additional approval.

For a full list of what pleases or displeases a companion, see the respective companion page.

Affinity can be also increased by asking a companion to follow. The increase depends on the current affinity level and will be lower with higher affinity values. The formula for the increase is 40 - 0,033 x affinity value. The increase by choosing a companion only applies if a quest has been completed since the companion was last chosen.

Companion perks
Those perks are acquired by reaching the maximum level of affinity with a companion. The perks obtained this way are permanently obtained, whether you keep travelling with the associated companion or not.

Exploits
This process can be repeated indefinitely to increase the companions affinity towards you.
 * Cait, Deacon, MacCready, and Piper's affinity can be raised by using a safe that has a terminal attached to it, opening the safe then using the terminal to lock it again.
 * Safes can be found in:
 * Sanctuary (unless scrapped)
 * Fiddler's Green Trailer Estates
 * Medford Memorial Hospital (advanced)
 * Back Street Apparel (advanced 1st floor)
 * Hubris Comics (Grognak's axe case)
 * Greenetech Genetics (Expert 7th floor)
 * Super-Duper Mart (advanced)
 * Cait and Hancock's affinity can be raised by removing all clothing and fast-traveling among safe locations with them as companions.
 * Codsworth, Danse and X6-88's affinity can be raised by attaching and "detaching" a mod to any armor, creating the "none" mod costs nothing at an armor bench and then you can just swap between them.
 * Codsworth, Danse, Preston and X6-88's affinity can be raised by attaching and "detaching" a mod to any weapon, after creating the "none" attachment, it can be attached and swapped between any other attachment for free.
 * MacCready's affinity can be raised by repeatedly placing an item in a owned container and then retrieving it. A good location for this is in the hotel in Goodneighbor since you can shut the door behind you and start the process.
 * Danse and X6-88's affinity can be raised by getting into Power Armor. Be aware that Strong's affinity will be lowered if he is in the same Settlement when getting into the Power Armor.
 * Strong's affinity can be raised by using the Cannibal perk.