____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       A futuristic real-time strategy game.
          This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project. Distributed under the "GNU General Public License"

ai.h File Reference

The ai headerfile. More...

Go to the source code of this file.

Functions

void AiEachCycle (CPlayer *player)
 Called each game cycle.
void AiEachSecond (CPlayer *player)
 Called each second.
void InitAiModule (void)
 Init AI global structures.
void AiInit (CPlayer *player)
 Init AI for this player.
void CleanAi (void)
 Cleanup the AI module.
void FreeAi (void)
 Free the AI resources.
void SaveAi (CFile *file)
 Save the AI state.
void AiCclRegister (void)
 Register ccl features.
void AiHelpMe (const CUnit *attacker, CUnit *defender)
 < Called if AI unit is attacked
void AiUnitKilled (CUnit *unit)
 Called if AI needs more farms.
void AiNeedMoreSupply (const CUnit *unit, const CUnitType *what)
 Called if AI unit has completed work.
void AiWorkComplete (CUnit *unit, CUnit *what)
 Called if AI unit can't build.
void AiCanNotBuild (CUnit *unit, const CUnitType *what)
 Called if AI unit can't reach building place.
void AiCanNotReach (CUnit *unit, const CUnitType *what)
 Called if an AI unit can't move.
void AiCanNotMove (CUnit *unit)
 Called if AI unit has completed training.
void AiTrainingComplete (CUnit *unit, CUnit *what)

Variables

int AiSleepCycles
 Ai sleeps # cycles.


Detailed Description

The ai headerfile.

Definition in file ai.h.


Function Documentation

void AiCanNotBuild ( CUnit unit,
const CUnitType what 
)

Called if AI unit can't reach building place.

Called if building can't be build.

Parameters:
unit Pointer to unit what builds the building.
what Pointer to unit-type.

Definition at line 769 of file ai.cpp.

References _C_, CPlayer::Ai, AiReduceMadeInBuilt(), Assert, DebugPrint, CUnitType::Ident, CPlayer::Index, CUnit::Player, PlayerPerson, CPlayer::Type, CUnit::Type, UnitNumber, CUnit::X, and CUnit::Y.

Referenced by CheckCanBuild(), and StartBuilding().

void AiCanNotMove ( CUnit unit  ) 

Called if AI unit has completed training.

Called if a unit can't move. Try to move unit in the way

Parameters:
unit Pointer to unit what builds the building.

Definition at line 924 of file ai.cpp.

References CPlayer::Ai, AiMoveUnitInTheWay(), CUnit::Orders, PlaceReachable(), CUnit::Player, CUnit::Type, CUnitType::UnitType, and UnitTypeFly.

Referenced by DoActionMove().

void AiCanNotReach ( CUnit unit,
const CUnitType what 
)

Called if an AI unit can't move.

Called if building place can't be reached.

Parameters:
unit Pointer to unit what builds the building.
what Pointer to unit-type.

Definition at line 785 of file ai.cpp.

References CPlayer::Ai, AiReduceMadeInBuilt(), Assert, CUnit::Player, PlayerPerson, and CPlayer::Type.

Referenced by MoveToLocation().

void AiCclRegister ( void   ) 

void AiEachCycle ( CPlayer player  ) 

Called each game cycle.

This is called for each player, each game cycle.

Parameters:
player The player structure pointer.

Definition at line 996 of file ai.cpp.

References CPlayer::Ai, COrder::Goal, int(), AiTransportRequest::Order, CUnit::RefsDecrease(), PlayerAi::TransportRequests, and AiTransportRequest::Unit.

Referenced by PlayersEachCycle().

void AiEachSecond ( CPlayer player  ) 

Called each second.

This is called for each player each second.

Parameters:
player The player structure pointer.

Definition at line 1015 of file ai.cpp.

References CPlayer::Ai, AiCheckMagic(), AiCheckUnits(), AiExecuteScript(), AiForceManager(), AiResourceManager(), AiSendExplorers(), CYCLES_PER_SECOND, GameCycle, and PlayerAi::LastExplorationGameCycle.

Referenced by PlayersEachSecond().

void AiHelpMe ( const CUnit attacker,
CUnit defender 
)

< Called if AI unit is attacked

Called if AI unit is killed

Called if a Unit is Attacked

Parameters:
attacker Pointer to attacker unit.
defender Pointer to unit that is being attacked.

Definition at line 646 of file ai.cpp.

References _C_, CPlayer::Ai, AI_MAX_ATTACKING_FORCES, AiAttackWithForceAt(), AiForce::Attacking, CUnitType::CanAttack, DebugPrint, AiForce::Defending, PlayerAi::Force, CUnitType::Ident, CPlayer::Index, int(), CUnit::Player, CUnit::Type, UnitNumber, AiForce::Units, CUnitType::UnitType, UnitTypeFly, CUnit::X, and CUnit::Y.

Referenced by HitUnit().

void AiInit ( CPlayer player  ) 

Init AI for this player.

Setup all at start.

Parameters:
player The player structure pointer.

Definition at line 423 of file ai.cpp.

References _C_, CPlayer::Ai, CPlayer::AiName, PlayerAi::AiType, AiTypes, CAiType::Class, DebugPrint, Exit(), CPlayer::Index, int(), PlayerAi::Player, CAiType::Script, and PlayerAi::Script.

Referenced by HandleCheats(), and PlayersInitAi().

void AiNeedMoreSupply ( const CUnit unit,
const CUnitType what 
)

Called if AI unit has completed work.

Called if the AI needs more farms.

Parameters:
unit Point to unit.
what Pointer to unit-type.

Definition at line 964 of file ai.cpp.

References CPlayer::Ai, Assert, PlayerAi::NeedSupply, CUnit::Player, PlayerPerson, and CPlayer::Type.

Referenced by HandleActionTrain().

void AiTrainingComplete ( CUnit unit,
CUnit what 
)

Called if training of a unit is completed.

Parameters:
unit Pointer to unit making.
what Pointer to new ready trained unit.

Definition at line 976 of file ai.cpp.

References _C_, CPlayer::Ai, AiAssignToForce(), AiCleanForces(), AiRemoveFromBuilt(), Assert, DebugPrint, CUnitType::Ident, CPlayer::Index, CUnit::Player, PlayerPerson, CPlayer::Type, CUnit::Type, UnitNumber, CUnit::X, and CUnit::Y.

Referenced by HandleActionTrain().

void AiUnitKilled ( CUnit unit  ) 

Called if AI needs more farms.

Called if a unit is killed.

Parameters:
unit Pointer to unit.

Definition at line 708 of file ai.cpp.

References _C_, CPlayer::Ai, AiReduceMadeInBuilt(), Assert, DebugPrint, CUnitType::Ident, CPlayer::Index, CUnit::Orders, CUnit::Player, PlayerPerson, CPlayer::Type, CUnit::Type, UnitActionAttack, UnitActionBuild, UnitActionBuilt, UnitActionMove, UnitActionStill, and UnitNumber.

Referenced by UnitLost().

void AiWorkComplete ( CUnit unit,
CUnit what 
)

Called if AI unit can't build.

Called if work complete (Buildings).

Parameters:
unit Pointer to unit that builds the building.
what Pointer to unit building that was built.

Definition at line 748 of file ai.cpp.

References _C_, CPlayer::Ai, AiRemoveFromBuilt(), Assert, DebugPrint, CUnitType::Ident, CPlayer::Index, CUnit::Player, PlayerPerson, CPlayer::Type, CUnit::Type, UnitNumber, CUnit::X, and CUnit::Y.

Referenced by HandleActionBuilt().

void CleanAi ( void   ) 

Cleanup the AI module.

Cleanup the AI in order to enable to restart a game.

Definition at line 486 of file ai.cpp.

References CPlayer::Ai, PlayerMax, and Players.

Referenced by CleanGame(), and FreeAi().

void FreeAi ( void   ) 

Free the AI resources.

Free all AI resources.

Definition at line 500 of file ai.cpp.

References AiResetUnitTypeEquiv(), AiTypes, AiHelper::Build, CleanAi(), AiHelper::Equiv, int(), AiHelper::Repair, AiHelper::Train, and AiHelper::UnitLimit.

Referenced by CleanModules().

void InitAiModule ( void   ) 

Init AI global structures.

Initialize global structures of the AI

Definition at line 477 of file ai.cpp.

References AiResetUnitTypeEquiv().

Referenced by InitModules(), and main().

void SaveAi ( CFile file  ) 

Save the AI state.

Save state of AI to file.

Parameters:
file Output file.

Definition at line 409 of file ai.cpp.

References DebugPrint, CFile::printf(), and SaveAiPlayers().

Referenced by SaveGame().


Variable Documentation

Ai sleeps # cycles.

Definition at line 152 of file ai.cpp.

Referenced by CclAiGetSleepCycles(), and main().


Generated on Sat Feb 21 00:28:15 2009 for Bos Wars by  doxygen 1.5.6