-
Notifications
You must be signed in to change notification settings - Fork 3
BehaviorManagers
Behavior managers control how behaviors operate when NPCs trigger them. They are responsible for loading the behaviors from the behaviors directory and the behaviors from the addons directory. They are also responsible for evaluating the sentence for behaviors that should run, evaluating the sentence for behaviors that should run before the sentence is spoken, evaluating the sentence for behaviors that should run after the sentence is spoken, getting a summary of all behaviors and what they do, getting a list of all behavior memories, rendering a behavior, and running behaviors that are triggered by the player.
Behavior managers are loaded at startup by the module loader. They are imported at startup, but only one is in use at any point. You can set which ones are being loaded in the interface config for the game you're playing, or you can override it in your config.json file. The config.json file is located in the Pantella repository directory.
Behavior managers are located in the ./src/behavior_managers/ directory.
The behavior manager class is responsible for loading the default behaviors and the addon behaviors. It is also responsible for evaluating the sentence for behaviors that should run, evaluating the sentence for behaviors that should run before the sentence is spoken, evaluating the sentence for behaviors that should run after the sentence is spoken, getting a summary of all behaviors and what they do, getting a list of all behavior memories, rendering a behavior, and running behaviors that are triggered by the player. The default_behavior_manager.py file is located in the ./src/behavior_managers/ directory and is what all behavior managers should inherit from. The behavior manager class has the following methods:
-
__init__(self,conversation_manager): Initializes the behavior manager. -
load_behaviors(self,behaviors_dir, addon_slug = None): Loads the behaviors from the behaviors directory and the behaviors from the addons directory. -
behavior_style: Returns a list of all behavior styles. -
behavior_keywords: Returns a list of all behavior keywords. -
evaluate(self, possible_word, next_author, sentence): Evaluates the keyword for behaviors that should run. -
pre_sentence_evaluate(self, next_author, sentence): Evaluates the sentence for behaviors that should run before the sentence is spoken. -
post_sentence_evaluate(self, next_author, sentence): Evaluates the sentence for behaviors that should run after the sentence is spoken. -
get_behavior_summary(self, character): Returns a summary of all behaviors and what they do. -
get_behavior_memories(self, character): Returns a list of all behavior memories. -
render_behavior(self, behavior): Renders a behavior. -
run_player_behaviors(self, sentence): Runs behaviors that are triggered by the player.
Initializes the behavior manager. It loads the default behaviors and the addon behaviors. When creating a new behavior manager, you should call the parent class's __init__ method to ensure that the default behaviors are loaded. The conversation_manager parameter is the conversation manager that the behavior manager is associated with.
Loads the behaviors from the behaviors directory and the behaviors from the addons directory. The behaviors_dir parameter is the directory where the behaviors are located. The addon_slug parameter is the slug of the addon that the behaviors are being loaded from. If addon_slug is None, the behaviors are loaded from the default behaviors directory. If addon_slug is not None, the behaviors are loaded from the addon's behaviors directory.
Returns a list of all behavior styles. The behavior styles are defined in the conversation manager's config file.
Returns a list of all behavior keywords. The behavior keywords are the keywords that trigger the behaviors.
Evaluates the keyword for behaviors that should run. The possible_word parameter is the word that is being evaluated. The next_author parameter is the author of the next sentence. The sentence parameter is the sentence that is being evaluated. The method returns a list of behaviors that were run.
Evaluates the sentence for behaviors that should run before the sentence is spoken. The next_author parameter is the author of the next sentence. The sentence parameter is the sentence that is being evaluated. The method returns the behavior that was run.
Evaluates the sentence for behaviors that should run after the sentence is spoken. The next_author parameter is the author of the next sentence. The sentence parameter is the sentence that is being evaluated. The method returns the behavior that was run.
Returns a summary of all behaviors and what they do. The character parameter is the character that the behaviors are associated with. The method returns a string that contains the summary of all behaviors.
Returns a list of all behavior memories. The character parameter is the character that the behaviors are associated with. The method returns a list of dictionaries that contain the behavior memories.
Renders a behavior. The behavior parameter is the behavior that is being rendered. The method returns a string that contains the rendered behavior.
Runs behaviors that are triggered by the player. The sentence parameter is the sentence that is being evaluated. The method runs the behaviors that are triggered by the player.
When creating a new behavior manager, you should inherit from the default behavior manager. This ensures that the default behaviors are loaded and that the behavior manager has access to the default behavior manager's methods. To inherit from the default behavior manager, you should create a new Python file in the
./src/behavior_managers/ directory and import the default behavior manager. You should then create a new class that inherits from the default behavior manager and implement any additional methods or properties that are required for your behavior manager.
print("Imported required libraries in custom_behavior_manager.py")
import src.behavior_managers.default_behavior_manager as default_behavior_manager
from src.logging import logging
logging.info("Imported required libraries in custom_behavior_manager.py")
valid_games = ["fallout4","skyrim","fallout4vr","skyrimvr"]
manager_slug = "custom_behavior_manager"
class BehaviorManager(default_behavior_manager.BehaviorManager):
def __init__(self, conversation_manager):
super().__init__(conversation_manager)
# Add custom initialization code here
# Add custom methods and properties here