void npc::form_opinion(player *u) { // FEAR if (u->weapon.is_gun()) { if (weapon.is_gun()) op_of_u.fear += 2; else op_of_u.fear += 4; } else if (u->weapon.type->melee_dam >= 12 || u->weapon.type->melee_cut >= 12) op_of_u.fear += 1; else if (u->weapon.type->id == 0) // Unarmed op_of_u.fear -= 3; if (u->str_max >= 16) op_of_u.fear += 2; else if (u->str_max >= 12) op_of_u.fear += 1; else if (u->str_max <= 5) op_of_u.fear -= 1; else if (u->str_max <= 3) op_of_u.fear -= 3; for (int i = 0; i < num_hp_parts; i++) { if (u->hp_cur[i] <= u->hp_max[i] / 2) op_of_u.fear--; if (hp_cur[i] <= hp_max[i] / 2) op_of_u.fear++; } if (u->has_trait(PF_DEFORMED2)) op_of_u.fear += 1; if (u->has_trait(PF_TERRIFYING)) op_of_u.fear += 2; if (u->stim > 20) op_of_u.fear++; if (u->has_disease(DI_DRUNK)) op_of_u.fear -= 2; // TRUST if (op_of_u.fear > 0) op_of_u.trust -= 3; else op_of_u.trust += 1; if (u->weapon.is_gun()) op_of_u.trust -= 2; else if (u->weapon.type->id == 0) op_of_u.trust += 2; if (u->has_disease(DI_HIGH)) op_of_u.trust -= 1; if (u->has_disease(DI_DRUNK)) op_of_u.trust -= 2; if (u->stim > 20 || u->stim < -20) op_of_u.trust -= 1; if (u->pkill > 30) op_of_u.trust -= 1; if (u->has_trait(PF_DEFORMED)) op_of_u.trust -= 1; if (u->has_trait(PF_DEFORMED2)) op_of_u.trust -= 3; // VALUE op_of_u.value = 0; for (int i = 0; i < num_hp_parts; i++) { if (hp_cur[i] < hp_max[i] * .8) op_of_u.value++; } decide_needs(); for (int i = 0; i < needs.size(); i++) { if (needs[i] == need_food || needs[i] == need_drink) op_of_u.value += 2; } if (op_of_u.fear < personality.bravery + 3 && op_of_u.fear - personality.aggression > -8 && op_of_u.trust > -4) attitude = NPCATT_TALK; else if (op_of_u.fear - 2 * personality.aggression - personality.bravery < -8) attitude = NPCATT_KILL; else attitude = NPCATT_FLEE; }
void npc::talk_to_u(game *g) { if (attitude == NPCATT_TALK) attitude = NPCATT_NULL; dialogue d; d.alpha = &g->u; d.beta = this; d.topic_stack.push_back(chatbin.first_topic); if (is_friend()) d.topic_stack.push_back(TALK_FRIEND); int most_difficult_mission = 0; for (int i = 0; i < chatbin.missions.size(); i++) { mission_type *type = g->find_mission_type(chatbin.missions[i]); if (type->urgent && type->difficulty > most_difficult_mission) { d.topic_stack.push_back(TALK_MISSION_DESCRIBE); chatbin.mission_selected = i; most_difficult_mission = type->difficulty; } } most_difficult_mission = 0; bool chosen_urgent = false; for (int i = 0; i < chatbin.missions_assigned.size(); i++) { mission_type *type = g->find_mission_type(chatbin.missions_assigned[i]); if ((type->urgent && !chosen_urgent) || (type->difficulty > most_difficult_mission && (type->urgent || !chosen_urgent) )) { chosen_urgent = type->urgent; d.topic_stack.push_back(TALK_MISSION_INQUIRE); chatbin.mission_selected = i; most_difficult_mission = type->difficulty; } } if (d.topic_stack.back() == TALK_NONE) { g->add_msg(_("%s says, \"Leave me alone.\""), name.c_str()); return; } moves -= 100; decide_needs(); d.win = newwin(25, 80, 0, 0); wborder(d.win, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX, LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX ); for (int i = 1; i < 24; i++) mvwputch(d.win, i, 41, c_ltgray, LINE_XOXO); mvwputch(d.win, 0, 41, c_ltgray, LINE_OXXX); mvwputch(d.win, 24, 41, c_ltgray, LINE_XXOX); mvwprintz(d.win, 1, 1, c_white, _("Dialogue with %s"), name.c_str()); mvwprintz(d.win, 1, 43, c_white, _("Your response:")); // Main dialogue loop do { talk_topic next = d.opt(d.topic_stack.back(), g); if (next == TALK_NONE) { int cat = topic_category(d.topic_stack.back()); do d.topic_stack.pop_back(); while (cat != -1 && topic_category(d.topic_stack.back()) == cat); } if (next == TALK_DONE || d.topic_stack.empty()) d.done = true; else if (next != TALK_NONE) d.topic_stack.push_back(next); } while (!d.done); delwin(d.win); g->refresh_all(); }