Presentation is loading. Please wait.

Presentation is loading. Please wait.

Individual NPC Behavior Daniel Phang & Sui Ying Teoh.

Similar presentations


Presentation on theme: "Individual NPC Behavior Daniel Phang & Sui Ying Teoh."— Presentation transcript:

1 Individual NPC Behavior Daniel Phang & Sui Ying Teoh

2 NPC - Non-Player Character Primary application of AI in games Any character not controlled by player o Mobs, Monsters, Enemies o Allies o Noncombat or neutral units o Environment animals Function to create an immersive gaming experience for the player

3 Overview NPC Behavior Coordinated Behavior Human-like NPCs Reputation Systems Animating NPCs

4 NPC Behavior

5 What is NPC Behavior? Actions NPCs perform (in-game behavior) o Movement o Environmental interactions o Combat o Responses to game events o Querying and storing information Later: animations o Movement: limb and body animation o Emotions: facial expressions, body language

6 NPC Requirements Believable actions Realistic behavior Fulfill function without impeding gameplay or other NPCs Minimize strain on system Make the game fun

7 AI for NPC Behavior Static NPCs are predictable, repetitive and harder to manage Complex autonomous NPCs make for interesting emergent behavior and replayable games NPC AI must be balanced and practical o NPC should not make the game too difficult o NPC AI needs to conserve system resources o Unrealistic behavior and cheating is acceptable if player does not notice

8 Scripted behaviors Predefined set of actions Good for linear environments, with predictable events Bad for open or dynamic environments, with unexpected events Half-Life 2 uses a lot of scripting

9 Scripts in Half-Life 2 (2:00)

10 Autonomous Behavior Goal-based NPCs are more complex o Emergent behavior based on desires, sensory input, and proximity to objects of interest o Good response to unexpected events o Human-like behavior: reading books, drinking water, opening doors, etc. Very flexible o Developers can create an open world o No need to script many individual characters NOLF2, Far Cry 2, Assassin's Creed: Brotherhood

11 Assassin's Creed: Brotherhood

12 Autonomous Behavior Simple implementation: Finite State Machines

13 Autonomous Behavior Complex NPCs are more chaotic o NOLF2: Guard leaves post to work in office Solution: Apply human concepts o Ownership o Dependency o Responsibility o Relevance o Priority o Consciousness o Expected state o Presence of others

14 Ownership "Is this object mine to use?" o A guard cannot use a microscope o A scientist cannot use a gun Assign ownership by grouping objects into sets belonging to specific NPCs What to do about public objects? o Group them into multiple overlapping sets o Use a world set o Don't group them at all

15 Dependency "Is there anything I need to do before using this object?" o NPCs use the sink after going to the toilet Use tightly coupled actions o Atomic, inseparable action of using toilet and sink o Less reusability in other situations Use dependency parameters: objects that reference others by ID Simple solution used in NOLF2 o Disable all objects but the sink after toilet is used, and enable all objects after sink is used

16 Responsibility "What is my purpose in life?" o Guards responsible for specific areas o Scientists never leave the lab Tagging objects with the character classes allowed to use it o Specific region tied to guards o Only scientists can use microscopes

17 Relevance "How will my actions affect the player's experience?" Modern games fit between a simulation and a drama NPCs should recognize their significance o Rabbits shouldn't be allowed to use dramatic music when being chased

18 Priority "What is most important right now?" Aggressive > Investigative > Relaxed o Investigating a dead body vs. being on guard o NPC defending himself vs. drinking coffee Behavior priorities should persist until behavior is completed o Highest priority goal controls behavior

19 State of Consciousness "Am I awake?" Unconscious NPCs have limited actions o Can snore or wake up o Should not be able to talk When checking bodies, NPCs should know whether the body is conscious or not

20 Expected State "Has anything changed?" Generalization of consciousness o Ally caught in bear trap, ally is wounded, etc. o Footprints on floor If object is not as expected the NPC o Investigates o Returns object to its default state Disturbance threshold o NPC responds when enough disturbances are registered

21 Presence of Others "How will this action affect other characters?" o NPCs programmed to switch off the light when they exit the room o What if there are other NPCs in the room? NPCs should coordinate with one another

22 Coordinated Behavior

23 NPCs need to be aware of each other too Messages NPCs need to send each other: o Split Up! o Get Out of My Way! o Get Down! o What's Going On? Use a blackboard to enable sharing of information among multiple NPCs o Easy but effective solution o Used in NOLF2

24 Split Up! NPCs crowd corridors and rooms Path reservation o Works best in combat scenarios o Reserve a path during planning o Path becomes more costly to other NPCs o Illusion of flanking and strategy Maximum Occupancy o Works best in investigative scenarios o First NPC to reach a room flags it as occupied o Additional NPCs approach room but do not enter o Illusion of watching the first NPC investigate Blackboard coordinates path information

25 Split Up!

26

27 Get Out of My Way! NPCs get in each other's line of fire 1.Is line of fire blocked? Yes 2.Is obstruction an ally? Yes 3.Request ally ducks. If ally busy 4.Step aside and commence firing. Kung Fu Attack emerges if used in close range melee attacks

28 Get Down! All NPCs exhibit the same behavior o All enemies go prone at the same time Blackboard coordinates actions o NPC posts AttackProne action o Blackboard counts down ProneTime o Other NPCs do not go prone as long as another NPC is prone

29 What's Going On? NPC is idle while ally is attacked NPC on patrol steps over dead body Apply the sensory trigger system used to detect enemies o Detect ally NPC's state o Take appropriate action

30 Human-like NPCs

31 Games such as RPG and FPS should improve behavior to be more human-like We can take into account several factors o Sensory o Memory o Personality o Emotions o Physiological Stressors

32 Sensory NPC's perception of its surroundings o Most important: touch, sight, hearing o Less important: smell, taste Touch o Detecting if NPC collided with something Sight o A vision cone based on distance o Affected by lighting and obstacles Hearing o Listening for player movements, other game events o Affected by proximity and environment

33 Sensory Smell o Dead corpses should emit a strong stench o Animals are more sensitive to smells Taste o Humans may like or dislike certain types of food

34 Sensory Games with stealth mechanics o Thief  Guards visually look for player  Guards react to corpses  Guards listen for environment noises & footsteps o Skyrim  Armor weight, movement speed and proximity affect movement noise  Attacking / casting spells / jumping increase noise o Assassin's Creed  Mostly visual

35 Stealth in Skyrim (1:04)

36 Memory, Personality, Emotions How NPCs interact with the player Memory o NPC learns from interactions o Short-term vs. long-term memory Personality o Happy, sarcastic, antagonistic, etc. o "Big Five": Extraversion, agreeableness, conscientiousness, neuroticism, openness Emotions o The mood of NPCs o Happy, sad, angry, etc.

37 Memory, Personality, Emotions Most useful for RPGs o NPCs remember decisions player makes o NPCs have vastly different personalities o NPCs react to player actions o Memorable dialogue In the (near) future: o More interactive dialogue, less scripted dialogue o Natural language processing, such as in Façade

38 Interactive NPCs in Façade (13:20)

39 Physiological Stressors Indicators of significant changes in the human body o Muscle fatigue o Pain o Health o Anxiety o Fear o Extreme temperatures o Chemicals o Hunger

40 Physiological Stressors Most games implement some stressors Sims series o Sims have hunger, energy, fun, social, hygiene levels S.T.A.L.K.E.R. o Radiation poisoning is cured by using med-packs, anti-radiation injections, or drinking vodka

41 Physiological Stressors in Sims (0:50)

42 Reputation Systems

43 Determines how NPCs react to the player Makes the game more believable o NPC does not smile and greet you even after you killed their entire village Varies gameplay o Different dialogue options o Different events o Different allies / resources o Different endings Can be NPC-specific / global / localized / event knowledge driven

44 NPC-Specific Reputation Player actions only affect specific NPCs Dragon Age II o Supporting blood mages  + Friendship with Merril  - Friendship with Fenris  Other blood mages still try to kill you o Decisions and responses to the Arishok  Earning his respect means you can fight him one- on-one  Qunari still try to kill you Town NPCs remain unaffected

45 DA2 Friendship with Merrill

46 DA2 Friendship Perks

47 DA2 Rivalry with Fenris

48 DA2 Rivalry Perks

49 Global Reputation System Player actions determine if 'Good' or 'Evil' All NPCs know what you are Fable III o Good - Angel wings, Positive responses o Bad - Bat wings, Negative responses o Neutral - Eagle wings Mass Effect 2 o Choose sides - Paragon / Renegade Problems o Not quite believable - NPCs appear to be psychic o Black and white morality - Not rewarding to be grey

50 Good Character in Fable III

51 Evil Character in Fable III

52 Reputation in Mass Effect 2

53 Grey Morality in Mass Effect 3 General Reputation

54 Localized Reputation System Player reputation only applies within a city or a guild More believable o City guards would have a central command center o Reasonable to assume all guards share same info Simpler solution o No need for event-based system Skyrim o Windhelm guards do not arrest you for crimes committed in Whiterun o Standing in Thieves Guild does not affect standing in Dark Brotherhood

55 Localized Reputation in Skyrim

56 Event Knowledge Reputation More realistic: your reputation changes only if NPC has knowledge of an event o NPC is within the area when an event occurs e.g. when an NPC dies or is attacked o NPC comes in contact with another NPC that knows of the event Reputation changes aren't instantaneous o Player can keep ahead of reputation by eliminating all witnesses of the event

57 Animating NPCs

58 Despite good NPC behavior, NPCs still seem artificial without smooth animations In the past: animations were limited to full- body, upper-body, or lower-body Now body parts should move independently How do we manage independent layers?

59 Animating NPCs Separate controllers for each body part o Overly complex o Could lead to too many interdependencies Better: layered animation system o Each layer is categorized by the body region it affects o Animations are prioritized by their importance

60 Animating NPCs Priorities should make sense o Idle animations have priority of 0 o Walks have priority of 5 o Attacks have priority of 10 o Reactions have priority of 20 o Deaths have priority of 100 Each category corresponds to specific body regions o If the category is upper-body, animation data should only be for bones from the waist up

61 Animating NPCs: Implementation Animation controller class o Standard Template Library (STL) map which stores animation instances, sorted by category o Animation instances reference a resource file o Core function PlayAnim()  Can animation be played? (based on category and priority)  Should other animations be stopped?  Animations played from general to more specific

62 Skyrim vs Oblivion NPC Animation (0:08) (1:46)

63 The Ideal NPC Moves naturally o Realistic movements o Express emotions Acts normally o Does what they are supposed to do o Behaves like a human being Responds appropriately o Knows if you are a friend or an enemy o Makes human mistakes


Download ppt "Individual NPC Behavior Daniel Phang & Sui Ying Teoh."

Similar presentations


Ads by Google