mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +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,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
|
||||
|
||||
Reference in New Issue
Block a user