Test now can work the enemy AI to prototype behavior.
This commit is contained in:
parent
db5a371766
commit
2815375836
6 changed files with 59 additions and 6 deletions
10
ai.cpp
10
ai.cpp
|
@ -93,8 +93,8 @@ namespace ai {
|
|||
auto& scripts = config["scripts"];
|
||||
for(auto& [script_name, action_names] : scripts.items()) {
|
||||
std::vector<Action> the_script;
|
||||
for(auto name : action_names) {
|
||||
|
||||
for(auto name : action_names) {
|
||||
check(AIMGR.actions.contains(name),
|
||||
fmt::format("ai::init(): script {} uses action {} that doesn't exist",
|
||||
(std::string)script_name, (std::string)name));
|
||||
|
@ -110,6 +110,12 @@ namespace ai {
|
|||
}
|
||||
}
|
||||
|
||||
void check_valid_action(std::string name, std::string msg) {
|
||||
dbc::check(AIMGR.actions.contains(name),
|
||||
fmt::format("{} tried to access action that doesn't exist {}",
|
||||
msg, name));
|
||||
}
|
||||
|
||||
State load_state(std::string state_name) {
|
||||
check(initialized, "you forgot to initialize the AI first.");
|
||||
check(AIMGR.states.contains(state_name), fmt::format(
|
||||
|
@ -158,8 +164,8 @@ namespace ai {
|
|||
return &AIMGR.profile;
|
||||
}
|
||||
|
||||
|
||||
bool EntityAI::wants_to(std::string name) {
|
||||
ai::check_valid_action(name, "EntityAI::wants_to");
|
||||
return plan.script[0].name == name;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue