Skip to content

Commit

Permalink
npc: remove hardcoded mutation modifiers to opinions and use JSON values
Browse files Browse the repository at this point in the history
let NPCs form opinions of players based on the total ugliness of all the
player's traits, not just select traits.  Replace hardcoded modifiers to
intimidate and persuade with the existing social_modifiers JSON
information.  Adjust the social modifiers for a few traits, including
moving the previous hardcoded values into JSON.
  • Loading branch information
mlangsdorf committed Jan 4, 2019
1 parent e25c28e commit 78bfc7a
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 77 deletions.
95 changes: 84 additions & 11 deletions data/json/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@
"valid" : false,
"cancels" : ["FLIMSY", "FLIMSY2", "FLIMSY3", "GLASSJAW"],
"changes_to" : ["TOUGH2"],
"social_modifiers" : {
"intimidate" : 2
},
"hp_modifier" : 0.2
},{
"type" : "mutation",
Expand All @@ -199,6 +202,9 @@
"cancels" : ["FLIMSY", "FLIMSY2", "FLIMSY3", "GLASSJAW"],
"prereqs" : ["TOUGH"],
"changes_to" : ["TOUGH3"],
"social_modifiers" : {
"intimidate" : 3
},
"hp_modifier" : 0.3
},{
"type" : "mutation",
Expand All @@ -209,6 +215,9 @@
"valid" : false,
"cancels" : ["FLIMSY", "FLIMSY2", "FLIMSY3", "GLASSJAW"],
"prereqs" : ["TOUGH2"],
"social_modifiers" : {
"intimidate" : 4
},
"hp_modifier" : 0.4
},{
"type" : "mutation",
Expand Down Expand Up @@ -297,6 +306,9 @@
"points" : 1,
"description" : "You've always felt that there is more to the world than we can see. Whether driven by religious beliefs or philosophical interest, you find great inspiration in studying holy texts and experiencing mystical things.",
"starting_trait" : true,
"social_modifiers" : {
"persuade" : 5
},
"valid" : false
},{
"type" : "mutation",
Expand Down Expand Up @@ -401,6 +413,9 @@
"name" : "Inconspicuous",
"points" : 1,
"description" : "While sleeping or staying still, it is less likely that monsters will wander close to you.",
"social_modifiers" : {
"lie" : 2
},
"valid" : false
},{
"type" : "mutation",
Expand Down Expand Up @@ -473,6 +488,9 @@
"description" : "You don't experience guilt like others do. Even when you know your actions are wrong, you just don't care.",
"starting_trait" : true,
"valid" : false,
"social_modifiers" : {
"intimidate" : 5
},
"cancels" : ["PACIFIST"],
"flags" : ["CANNIBAL"]
},{
Expand Down Expand Up @@ -644,6 +662,9 @@
"name" : "Asthmatic",
"points" : -4,
"description" : "You will occasionally need to use an inhaler, or else suffer severe physical limitations. However, you are guaranteed to start with an inhaler.",
"social_modifiers" : {
"intimidate" : -2
},
"starting_trait" : true,
"valid" : false
},{
Expand Down Expand Up @@ -810,6 +831,9 @@
"points" : -2,
"description" : "Your head can't take much abuse. Its maximum HP is 20% lower than usual.",
"starting_trait" : true,
"social_modifiers" : {
"intimidate" : -2
},
"category" : ["BIRD", "RAPTOR"],
"cancels" : ["TOUGH"]
},{
Expand All @@ -818,6 +842,9 @@
"name" : "Forgetful",
"points" : -3,
"description" : "You have a hard time remembering things. Your skills will erode slightly faster than usual, and you can remember less terrain.",
"social_modifiers" : {
"lie" : -5
},
"starting_trait" : true,
"category" : ["BEAST", "MEDICAL", "CHIMERA", "MOUSE", "INSECT"],
"cancels" : ["GOODMEMORY"]
Expand Down Expand Up @@ -952,6 +979,9 @@
"points" : -4,
"description" : "You don't like thinking about violence. Your combat skills advance much slower than usual, and you feel more guilt about killing.",
"starting_trait" : true,
"social_modifiers" : {
"intimidate" : -10
},
"valid" : false,
"cancels" : ["PSYCHOPATH", "PRED1", "PRED2", "PRED3", "PRED4"]
},{
Expand Down Expand Up @@ -1027,6 +1057,9 @@
"description" : "Your body can't take much abuse. Its maximum HP is 25% lower than usual and you heal slightly slower. Stacks with Glass Jaw.",
"starting_trait" : true,
"valid" : false,
"social_modifiers" : {
"intimidate" : -2
},
"cancels" : ["TOUGH", "TOUGH2", "TOUGH3"],
"category" : ["MOUSE"],
"changes_to" : ["FLIMSY2"],
Expand All @@ -1039,6 +1072,9 @@
"description" : "Your body breaks very easily. Its maximum HP is 50% lower than usual and you heal slower. Stacks with Glass Jaw.",
"starting_trait" : true,
"valid" : false,
"social_modifiers" : {
"intimidate" : -3
},
"cancels" : ["TOUGH", "TOUGH2", "TOUGH3"],
"prereqs" : ["FLIMSY"],
"changes_to" : ["FLIMSY3"],
Expand All @@ -1051,6 +1087,9 @@
"description" : "Your body is extremely fragile. Its maximum HP is 75% lower than usual and you heal much slower. Stacks with Glass Jaw.",
"starting_trait" : true,
"valid" : false,
"social_modifiers" : {
"intimidate" : -4
},
"cancels" : ["TOUGH", "TOUGH2", "TOUGH3"],
"prereqs" : ["FLIMSY2"],
"hp_modifier" : -0.75
Expand Down Expand Up @@ -1122,9 +1161,9 @@
"cancels" : ["BIRD_EYE", "LIZ_EYE", "FEL_EYE", "URSINE_EYE", "COMPOUND_EYES"],
"category" : ["ELFA"],
"social_modifiers" : {
"lie" : 10,
"persuade" : 20,
"intimidate" : 10
"lie" : 5,
"persuade" : 5,
"intimidate" : -5
}
},{
"type" : "mutation",
Expand Down Expand Up @@ -1157,6 +1196,10 @@
"visibility" : 2,
"ugliness" : 1,
"description" : "Your eyes have mutated, now having a slitted pupil and glittering in light, much like those of cats. This is visually striking, but it isn't helping you see at night.",
"social_modifiers" : {
"lie" : 2,
"persuade" : 2
},
"leads_to" : ["FEL_NV"],
"cancels" : ["ELFAEYES", "LIZ_EYE", "BIRD_EYE", "URSINE_EYE", "COMPOUND_EYES"],
"category" : ["FELINE", "BEAST"]
Expand Down Expand Up @@ -1209,6 +1252,10 @@
"visibility" : 2,
"ugliness" : 1,
"description" : "Your eyes have mutated, with a brilliant iris and slitted pupil similar to that of a lizard. This is visually striking, but doesn't seem to affect your vision.",
"social_modifiers" : {
"persuade" : -1,
"intimidate" : 1
},
"leads_to" : ["LIZ_IR"],
"cancels" : ["ELFAEYES", "FEL_EYE", "URSINE_EYE", "BIRD_EYE", "COMPOUND_EYES"],
"category" : ["LIZARD", "RAPTOR"]
Expand Down Expand Up @@ -2826,6 +2873,9 @@
"name" : "Resilient",
"points" : 2,
"description" : "You can survive injuries that would incapacitate humans: you get a 20% bonus to all hit points. Stacks with Tough, etc.",
"social_modifiers" : {
"intimidate" : 2
},
"prereqs" : ["LARGE_OK", "HUGE_OK", "STR_UP_3", "STR_UP_4", "MASOCHIST_MED"],
"threshreq" : ["THRESH_URSINE", "THRESH_CATTLE", "THRESH_CHIMERA", "THRESH_MEDICAL", "THRESH_LIZARD", "THRESH_BEAST"],
"cancels" : ["FLIMSY", "FLIMSY2", "FLIMSY3", "GLASSJAW"],
Expand All @@ -2838,6 +2888,9 @@
"name" : "Solidly Built",
"points" : 3,
"description" : "Not much scares you. You get a 30% bonus to all hit points. Stacks with Tough, etc.",
"social_modifiers" : {
"intimidate" : 3
},
"valid" : false,
"prereqs" : ["MUT_TOUGH"],
"threshreq" : ["THRESH_URSINE", "THRESH_CATTLE", "THRESH_CHIMERA", "THRESH_MEDICAL"],
Expand All @@ -2851,6 +2904,9 @@
"name" : "TAAANK",
"points" : 4,
"description" : "You can simply take the punishment from lesser beings and keep going. You get a 40% bonus to all hit points. Stacks with Tough, etc.",
"social_modifiers" : {
"intimidate" : 4
},
"valid" : false,
"prereqs" : ["MUT_TOUGH2"],
"threshreq" : ["THRESH_URSINE", "THRESH_CATTLE"],
Expand Down Expand Up @@ -2970,6 +3026,9 @@
"name" : "Hunter",
"points" : 3,
"description" : "Your brain has a lot more in common with predatory animal than a human, making it easier to control misplaced reactions to death of your prey. Additionally, combat skills, which you use to hunt, are easier to learn and maintain.",
"social_modifiers" : {
"intimidate" : 3
},
"purifiable" : false,
"prereqs" : ["CARNIVORE", "THRESH_URSINE"],
"prereqs2" : ["PRED1"],
Expand All @@ -2983,6 +3042,9 @@
"name" : "Predator",
"points" : 3,
"description" : "You consider yourself something other than human and no longer empathize with them. Combat skills are easy to learn and maintain, but your critical thinking, so characteristic to these creatures, suffers.",
"social_modifiers" : {
"intimidate" : 4
},
"valid" : false,
"purifiable" : false,
"prereqs" : ["CARNIVORE", "THRESH_URSINE"],
Expand All @@ -3001,6 +3063,9 @@
"name" : "Apex Predator",
"points" : 2,
"description" : "Your mind and brain have adapted to your new place in the world: as one on top the food chain. You can effortlessly master and maintain combat skills, but your critical thinking has atrophied further.",
"social_modifiers" : {
"intimidate" : 5
},
"valid" : false,
"purifiable" : false,
"prereqs" : ["CARNIVORE", "THRESH_URSINE"],
Expand All @@ -3017,6 +3082,11 @@
"name" : "Sapiovore",
"points" : 1,
"description" : "The hairless apes are as good eating as any other meat.",
"social_modifiers" : {
"persuade": -20,
"lie": -20,
"intimidate" : 6
},
"valid" : false,
"purifiable" : false,
"prereqs" : ["CARNIVORE"],
Expand Down Expand Up @@ -3808,8 +3878,8 @@
"category" : ["INSECT"],
"restricts_gear" : [ "TORSO" ],
"social_modifiers" : {
"lie" : 10,
"persuade" : 15,
"lie" : 15,
"persuade" : 5,
"intimidate" : -20
}
},{
Expand Down Expand Up @@ -4764,8 +4834,9 @@
"changes_to" : ["SNARL"],
"category" : ["RAT", "URSINE", "LUPINE"],
"social_modifiers" : {
"persuade" : -25,
"intimidate" : 15
"persuade" : -20,
"lie" : -10,
"intimidate" : 10
}
},{
"type" : "mutation",
Expand All @@ -4778,7 +4849,8 @@
"category" : ["BEAST", "CHIMERA", "FELINE", "LUPINE"],
"social_modifiers" : {
"persuade" : -60,
"intimidate" : 30
"lie" : -40,
"intimidate" : 20
}
},{
"type" : "mutation",
Expand All @@ -4789,8 +4861,9 @@
"description": "You hiss when speaking. Persuading NPCs will be more difficult, but threatening them will be easier.",
"category": ["LIZARD", "RAPTOR"],
"social_modifiers" : {
"persuade" : -25,
"intimidate" : 15
"persuade" : -20,
"lie" : -10,
"intimidate" : 10
}
},{
"type" : "mutation",
Expand Down Expand Up @@ -5399,7 +5472,7 @@
"category" : ["FISH"],
"threshreq" : ["THRESH_FISH"],
"social_modifiers" : {
"intimidate" : 15
"intimidate" : 5
},
"attacks" : {
"attack_text_u" : "You tear into %s with your teeth",
Expand Down
42 changes: 6 additions & 36 deletions src/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1067,28 +1067,16 @@ void npc::form_opinion( const player &u )
if( u.has_trait( trait_SAPIOVORE ) ) {
op_of_u.fear += 10; // Sapiovores = Scary
}

if( u.has_trait( trait_PRETTY ) ) {
op_of_u.fear += 1;
} else if( u.has_trait( trait_BEAUTIFUL ) ) {
op_of_u.fear += 2;
} else if( u.has_trait( trait_BEAUTIFUL2 ) ) {
op_of_u.fear += 3;
} else if( u.has_trait( trait_BEAUTIFUL3 ) ) {
op_of_u.fear += 4;
} else if( u.has_trait( trait_UGLY ) ) {
op_of_u.fear -= 1;
} else if( u.has_trait( trait_DEFORMED ) ) {
op_of_u.fear += 3;
} else if( u.has_trait( trait_DEFORMED2 ) ) {
if( u.has_trait( trait_TERRIFYING ) ) {
op_of_u.fear += 6;
} else if( u.has_trait( trait_DEFORMED3 ) ) {
op_of_u.fear += 9;
}

if( u.has_trait( trait_TERRIFYING ) ) {
op_of_u.fear += 6;
int u_ugly = 0;
for( trait_id &mut : u.get_mutations() ) {
u_ugly += mut.obj().ugliness;
}
op_of_u.fear += u_ugly / 2;
op_of_u.trust -= u_ugly / 3;

if( u.stim > 20 ) {
op_of_u.fear++;
Expand Down Expand Up @@ -1125,24 +1113,6 @@ void npc::form_opinion( const player &u )
op_of_u.trust -= 1;
}

if( u.has_trait( trait_PRETTY ) ) {
op_of_u.trust += 1;
} else if( u.has_trait( trait_BEAUTIFUL ) ) {
op_of_u.trust += 3;
} else if( u.has_trait( trait_BEAUTIFUL2 ) ) {
op_of_u.trust += 5;
} else if( u.has_trait( trait_BEAUTIFUL3 ) ) {
op_of_u.trust += 7;
} else if( u.has_trait( trait_UGLY ) ) {
op_of_u.trust -= 1;
} else if( u.has_trait( trait_DEFORMED ) ) {
op_of_u.trust -= 3;
} else if( u.has_trait( trait_DEFORMED2 ) ) {
op_of_u.trust -= 6;
} else if( u.has_trait( trait_DEFORMED3 ) ) {
op_of_u.trust -= 9;
}

if( op_of_u.trust > 0 ) {
// Trust is worth a lot right now
op_of_u.trust /= 2;
Expand Down
31 changes: 1 addition & 30 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3083,25 +3083,6 @@ int player::talk_skill() const

/** @EFFECT_SPEECH increases talking skill */
int ret = get_int() + get_per() + get_skill_level( skill_id( "speech" ) ) * 3;
if (has_trait( trait_SAPIOVORE )) {
ret -= 20; // Friendly conversation with your prey? unlikely
} else if (has_trait( trait_UGLY )) {
ret -= 3;
} else if (has_trait( trait_DEFORMED )) {
ret -= 6;
} else if (has_trait( trait_DEFORMED2 )) {
ret -= 12;
} else if (has_trait( trait_DEFORMED3 )) {
ret -= 18;
} else if (has_trait( trait_PRETTY )) {
ret += 1;
} else if (has_trait( trait_BEAUTIFUL )) {
ret += 2;
} else if (has_trait( trait_BEAUTIFUL2 )) {
ret += 4;
} else if (has_trait( trait_BEAUTIFUL3 )) {
ret += 6;
}
return ret;
}

Expand All @@ -3117,17 +3098,7 @@ int player::intimidation() const
weapon.damage_melee( DT_STAB ) >= 12 ) {
ret += 5;
}
if (has_trait( trait_SAPIOVORE )) {
ret += 5; // Scaring one's prey, on the other claw...
} else if (has_trait( trait_DEFORMED2 )) {
ret += 3;
} else if (has_trait( trait_DEFORMED3 )) {
ret += 6;
} else if (has_trait( trait_PRETTY )) {
ret -= 1;
} else if (has_trait( trait_BEAUTIFUL ) || has_trait( trait_BEAUTIFUL2 ) || has_trait( trait_BEAUTIFUL3 )) {
ret -= 4;
}

if (stim > 20) {
ret += 2;
}
Expand Down

0 comments on commit 78bfc7a

Please sign in to comment.