Skip to content
Slashscreen edited this page Apr 17, 2023 · 3 revisions

Introduction

Data

Flags

Schedule

Combat Info

The AI System

Modules

GOAP

Combat responses

Opinions and how the NPC determines its opinions

  • NPCs have a concept called opinions, which are a value from -100 to 100 reflecting what this NPC thinks of an entity, from -100 being mortal enemies to 100 being best of friends. 0 is a special value meaning no opinion at all, or "neutral". This system is almost entirely different from Creation Kit's combat response system.
  • This system is separate from Relationships, but will possibly be integrated more closely in the future.
  • The scale roughly follows this guideline:
100
 Allies / BFFs
80
 Friends
20
 Acquaintance
0 - NEUTRAL
 Acquaintance
-20
 Enemies
-80
 Nemesis
-100
  • This value is calculated by, essentially, taking the Covens this entity is a part of, gathering all non-neutral opinions of the other entity's Covens (defined in the Coven's "inter-faction relations" dictionary), tacking on the NPC's personal opinion of the entity (this can change during runtime), and averaging all of them together.
  • NPCs also have a flag determining if the average is weighted towards the covens' opinions or the personal opinions (or neither). This simulates an NPC being more loyal to the group or having their own personal opinion be more important than the group.
  • The opinion is always 0 for entities that aren't of a type that can pose a threat, like containers, or items. This is so NPCs don't try to fight a glass bottle lying on the floor, although that would admittedly be pretty funny. Entities are deemed a possible threat by having one of any components defined under NPCComponent.THREATENING_ENTITY_TYPES - By default, NPCComponent and PlayerComponent.
  • Here is code written in Ruby reflecting the algorithm, for those that learn easier by example than by words:
# get the weights of opinion categories, taking preferences into account
covens_weight = if favors_covens then 2 else 1
personal_weight = if favors_self then 2 else 1

opinions = get_coven_opinions.select{|x| not x == 0} # get all coven opinions that aren't 0, to total later
total_elements = coven_opinions.length * covens_weight # count up total coven elements, multiplied by covens weight

	# If the personal opinion is not neutral,  
unless personal_opinion == 0 then
	opinions << personal_opinions # add it to the opinions to total
	total_elements += 1 * personal_weight # add to total elements, taking the weight into account
end

opinion = (opinions.reduce(0) {|sum, num| sum + num}) / total_elements # sum all opinions, divide by opinion count with weights, return value

(Why Ruby? Because I like Ruby, and it's close enough to English to be a bit like functional pseudocode.)

The Opinion system is used for dialog and combat responses, but you can use it for whatever.

Clone this wiki locally