mirror of
https://github.com/1dot13/source.git
synced 2026-07-29 13:52:17 +02:00
Added missing from ModularizedTacticalAI :/
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6019 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#include "../include/AbstractPlanFactory.h"
|
||||
#include "../../Tactical/Soldier Control.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace AI
|
||||
{
|
||||
namespace tactical
|
||||
{
|
||||
AIInputData::AIInputData(Auditive , int noise_maker, int grid_no, int level, int volume, int type)
|
||||
: noise_maker_(noise_maker),
|
||||
grid_no_(grid_no),
|
||||
level_(level),
|
||||
volume_(volume),
|
||||
type_(type)
|
||||
{
|
||||
event_type_ = auditive_event;
|
||||
}
|
||||
|
||||
AIInputData::AIInputData(Visual, SOLDIERTYPE* opponent, int grid_no, int level, int caller1, int caller2)
|
||||
: opponent_(opponent),
|
||||
grid_no_(grid_no),
|
||||
level_(level),
|
||||
caller1_(caller1),
|
||||
caller2_(caller2)
|
||||
{
|
||||
event_type_ = visual_event;
|
||||
}
|
||||
|
||||
AIInputData::AIInputData()
|
||||
: event_type_(no_event)
|
||||
{
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const AIInputData& i)
|
||||
{
|
||||
if(i.event_type_ == AIInputData::no_event)
|
||||
return os<<"no_event";
|
||||
if(i.event_type_ == AIInputData::auditive_event)
|
||||
return os<<"sound: "<<i.noise_maker_<<" made a sound at "<<i.grid_no_<<", lvl "<<i.level_<<" vol "<<i.volume_<<" type "<<i.type_;
|
||||
if(i.event_type_ == AIInputData::visual_event)
|
||||
return os<<"visual: "<<(int)i.opponent_->ubID<<" was seen at "<<i.grid_no_<<", lvl "<<i.level_<<" caller1 "<<i.caller1_<<" caller2 "<<i.caller2_;
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* @file
|
||||
* @author feynman (bears-pit.com)
|
||||
*/
|
||||
|
||||
#include "../include/CrowPlan.h"
|
||||
#include "../../Tactical/Soldier Control.h" // defines SOLDIERTYPE
|
||||
#include "../../Tactical/Animation Control.h" // defines CROW_FLY
|
||||
#include "../../Tactical/Soldier Add.h" // FindGridNoFromSweetSpot()
|
||||
#include "../../TacticalAI/ai.h" // AI_ACTION_...
|
||||
#include "../../TacticalAI/AIInternals.h" // AIDEBUGMSG
|
||||
#include "../../Tactical/Rotting Corpses.h" // FindNearestRottingCorpse()
|
||||
#include "../../TileEngine/Isometric Utils.h" // TileIsOutOfBounds()
|
||||
|
||||
namespace AI
|
||||
{
|
||||
namespace tactical
|
||||
{
|
||||
CrowFlyAwayPlan::CrowFlyAwayPlan(SOLDIERTYPE* npc)
|
||||
: Plan(npc)
|
||||
{
|
||||
}
|
||||
|
||||
void CrowFlyAwayPlan::execute(PlanInputData& environment)
|
||||
{
|
||||
CrowsFlyAway( get_npc()->bTeam );
|
||||
}
|
||||
|
||||
CrowSeekCorpsePlan::CrowSeekCorpsePlan(SOLDIERTYPE* npc)
|
||||
: Plan(npc),
|
||||
corpse_grid_(FindNearestRottingCorpse(npc))
|
||||
{
|
||||
}
|
||||
|
||||
void CrowSeekCorpsePlan::execute(PlanInputData& environment)
|
||||
{
|
||||
get_npc()->aiData.bAction = AI_ACTION_NONE;
|
||||
if(TileIsOutOfBounds(corpse_grid_))
|
||||
return;
|
||||
// Walk to nearest corpse
|
||||
UINT8 unused;
|
||||
get_npc()->aiData.usActionData = FindGridNoFromSweetSpot( get_npc(), corpse_grid_, 4, &unused);
|
||||
if(TileIsOutOfBounds(get_npc()->aiData.usActionData))
|
||||
return;
|
||||
get_npc()->aiData.bAction = AI_ACTION_GET_CLOSER;
|
||||
}
|
||||
|
||||
bool CrowSeekCorpsePlan::done() const
|
||||
{
|
||||
return SpacesAway( get_npc()->sGridNo, corpse_grid_ ) < 2;
|
||||
}
|
||||
|
||||
int CrowSeekCorpsePlan::get_corpse_grid() const
|
||||
{
|
||||
return corpse_grid_;
|
||||
}
|
||||
|
||||
CrowPeckPlan::CrowPeckPlan(SOLDIERTYPE* npc, int corpse_grid)
|
||||
: Plan(npc), corpse_grid_(corpse_grid)
|
||||
{
|
||||
}
|
||||
|
||||
void CrowPeckPlan::execute(PlanInputData& environment)
|
||||
{
|
||||
get_npc()->aiData.bAction = AI_ACTION_NONE;
|
||||
INT16 sFacingDir;
|
||||
if (TileIsOutOfBounds(corpse_grid_))
|
||||
return;
|
||||
|
||||
// Change facing
|
||||
sFacingDir = GetDirectionFromGridNo( corpse_grid_, get_npc() );
|
||||
if ( sFacingDir != get_npc()->ubDirection )
|
||||
{
|
||||
get_npc()->aiData.usActionData = sFacingDir;
|
||||
get_npc()->aiData.bAction = AI_ACTION_CHANGE_FACING;
|
||||
return;
|
||||
}
|
||||
if (!environment.turn_based())
|
||||
{
|
||||
get_npc()->aiData.usActionData = 30000;
|
||||
get_npc()->aiData.bAction = AI_ACTION_WAIT;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace tactical
|
||||
} // namespace AI
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @file
|
||||
* @author feynman (bears-pit.com)
|
||||
*/
|
||||
|
||||
#include "../include/LegacyCreaturePlan.h"
|
||||
#include "../../Tactical/Soldier Control.h"
|
||||
|
||||
INT8 CreatureDecideAction( SOLDIERTYPE *pSoldier );
|
||||
|
||||
namespace AI
|
||||
{
|
||||
namespace tactical
|
||||
{
|
||||
LegacyCreaturePlan::LegacyCreaturePlan(SOLDIERTYPE* npc)
|
||||
: Plan(npc)
|
||||
{
|
||||
}
|
||||
|
||||
void LegacyCreaturePlan::execute(PlanInputData& environment)
|
||||
{
|
||||
get_npc()->aiData.bAction = CreatureDecideAction( get_npc() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @file
|
||||
* @author feynman (bears-pit.com)
|
||||
*/
|
||||
|
||||
#include "../include/LegacyZombiePlan.h"
|
||||
#include "../../Tactical/Soldier Control.h" // definition of SOLDIERTYPE
|
||||
|
||||
INT8 ZombieDecideAction( SOLDIERTYPE *pSoldier ); // defined in DecideAction.cpp
|
||||
|
||||
namespace AI
|
||||
{
|
||||
namespace tactical
|
||||
{
|
||||
LegacyZombiePlan::LegacyZombiePlan(SOLDIERTYPE* npc)
|
||||
: Plan(npc)
|
||||
{
|
||||
}
|
||||
|
||||
void LegacyZombiePlan::execute(PlanInputData& environment)
|
||||
{
|
||||
get_npc()->aiData.bAction = ZombieDecideAction(get_npc());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "../include/Plan.h"
|
||||
|
||||
#include "../../TacticalAI/ai.h"
|
||||
#include "../../TacticalAI/AIInternals.h" // ACTING_ON_SCHEDULE
|
||||
#include "../../TacticalAI/NPC.h" // NPCReachedDestination
|
||||
#include "../../Tactical/Animation Control.h" // defines ANIM_...
|
||||
#include "../../Tactical/Soldier Macros.h" // CREATURE_OR_BLOODCAT
|
||||
#include "../../Tactical/opplist.h" // EndMuzzleFlash
|
||||
#include "../../Tactical/Dialogue Control.h" // DialogueQueueIsEmpty
|
||||
#include "../../TileEngine/Isometric Utils.h" // defines NOWHERE
|
||||
#include "../../Utils/Debug Control.h" // LiveMessage
|
||||
#include "../../Utils/Font Control.h" // ScreenMsg about deadlock
|
||||
#include "../../Utils/message.h" // ditto
|
||||
#include "../../TileEngine/Render Fun.h" // defines InARoom
|
||||
#include "../../Strategic/quests.h" // IN_BROTHEL
|
||||
|
||||
// FIXME uagh, these need to go
|
||||
extern BOOLEAN gfUIInDeadlock;
|
||||
extern UINT8 gUIDeadlockedSoldier;
|
||||
|
||||
void HandleAITacticalTraversal(SOLDIERTYPE* pSoldier); // defined in TacticalAI/AIMain.cpp
|
||||
|
||||
namespace AI
|
||||
{
|
||||
namespace tactical
|
||||
{
|
||||
PlanInputData::PlanInputData(bool turn_based, const TacticalStatusType& tactical_status)
|
||||
: turn_based_(turn_based),
|
||||
tactical_status_(tactical_status)
|
||||
{
|
||||
}
|
||||
|
||||
Plan::Plan(SOLDIERTYPE* npc)
|
||||
: npc_(npc)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#include "../include/PlanList.h"
|
||||
#include "../../TacticalAI/AIInternals.h"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace AI
|
||||
{
|
||||
namespace tactical
|
||||
{
|
||||
PlanList::PlanList(SOLDIERTYPE* npc)
|
||||
: Plan(npc)
|
||||
{
|
||||
}
|
||||
|
||||
PlanList::~PlanList()
|
||||
{
|
||||
for(std::deque<Plan*>::iterator subplan_iter(subplans_.begin()); subplan_iter != subplans_.end(); ++subplan_iter)
|
||||
delete *subplan_iter;
|
||||
}
|
||||
|
||||
void PlanList::add_subplan(Plan* p)
|
||||
{
|
||||
if(!p)
|
||||
throw std::logic_error("No empty plans in PlanList allowed");
|
||||
subplans_.push_back(p);
|
||||
}
|
||||
|
||||
void PlanList::execute(PlanInputData& environment)
|
||||
{
|
||||
while(!subplans_.empty() && subplans_.front()->done())
|
||||
{
|
||||
delete subplans_.front();
|
||||
subplans_.pop_front();
|
||||
DEBUGAIMSG("Plan done, switching to next...");
|
||||
}
|
||||
if(subplans_.empty())
|
||||
return;
|
||||
subplans_.front()->execute(environment);
|
||||
}
|
||||
|
||||
bool PlanList::done() const
|
||||
{
|
||||
return subplans_.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user