Further refinement of new ModularizedTacticalAI architecture; added plans for Crows

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6017 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
feynman
2013-04-18 20:02:54 +00:00
parent 52cb4ff424
commit 26383d83a8
22 changed files with 451 additions and 490 deletions
@@ -4,21 +4,49 @@
*/
#include "../include/LegacyAIPlanFactory.h"
#include "../include/LegacyAIPlan.h"
#include "../include/LegacyCreaturePlan.h"
#include "../include/LegacyZombiePlan.h"
#include "../include/CrowPlan.h"
#include "../include/PlanList.h"
#include "../../TacticalAI/AIInternals.h" // DEBUGAIMSG
#include "../../Tactical/Soldier Control.h" // For SOLDIERTYPE definition
#include "../../Tactical/Animation Data.h" // For the definition of, wait for it... BLOODCAT!
#include <stdio.h>
namespace AI
{
namespace tactical
{
Plan* LegacyAIPlanFactory::create_plan(const AIInputData& input)
Plan* LegacyAIPlanFactory::create_plan(SOLDIERTYPE* npc, const AIInputData& input)
{
return new LegacyAIPlan();
DEBUGAIMSG("Planning for "<<(int)npc->ubID);
if((npc->flags.uiStatusFlags & SOLDIER_MONSTER) || npc->ubBodyType == BLOODCAT )
return new LegacyCreaturePlan(npc);
if(npc->ubBodyType == CROW)
{
PlanList* find_supper = new PlanList(npc);
CrowSeekCorpsePlan* seek_corpse = new CrowSeekCorpsePlan(npc);
CrowPeckPlan* peck = new CrowPeckPlan(npc, seek_corpse->get_corpse_grid());
find_supper->add_subplan(seek_corpse);
find_supper->add_subplan(peck);
return find_supper;
}
#ifdef ENABLE_ZOMBIES
if(npc->IsZombie())
return new LegacyZombiePlan(npc);
#endif
return new LegacyAIPlan(npc); // no special plan for other cases yet, return default legacy AI wrapper
}
void LegacyAIPlanFactory::update_plan(const AIInputData& input, Plan* plan_to_change)
void LegacyAIPlanFactory::update_plan(SOLDIERTYPE* npc, const AIInputData& input)
{
// TODO: currently, everything is handled in the LegacyAIPlan. The goal is to modularize the AI, so that in
// the end, the LegacyAIPlan is split into so many "new" AI Plan subclasses, that every case is covered.
// Then the behavior of the old AI would be implemented here.
DEBUGAIMSG("Update called for "<<(int)npc->ubID<<" event: "<<input);
if(!npc->ai_masterplan_)
npc->ai_masterplan_ = create_plan(npc, input);
}
}
}