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

       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_plan.cpp File Reference

AI planning functions. More...

#include <stdio.h>
#include <stdlib.h>
#include "stratagus.h"
#include "missile.h"
#include "unittype.h"
#include "unit_cache.h"
#include "map.h"
#include "pathfinder.h"
#include "actions.h"
#include "ai_local.h"
#include "player.h"

Go to the source code of this file.

Functions

static CUnitEnemyOnMapTile (const CUnit *source, int tx, int ty)
static void AiMarkWaterTransporter (const CUnit *unit, unsigned char *matrix)
static int AiFindTarget (const CUnit *unit, unsigned char *matrix, int *dx, int *dy, int *ds)
int AiPlanAttack (AiForce *force)
 < Plan the an attack
void AiSendExplorers (void)
 Enemy units in distance.


Detailed Description

AI planning functions.

Definition in file ai_plan.cpp.


Function Documentation

static int AiFindTarget ( const CUnit unit,
unsigned char *  matrix,
int *  dx,
int *  dy,
int *  ds 
) [static]

Find possible targets.

Parameters:
unit Attack.
matrix Water matrix.
dx Attack point X.
dy Attack point Y.
ds Attack state.
Returns:
True if target found.

Definition at line 218 of file ai_plan.cpp.

References _C_, CanMoveToMask(), DebugPrint, EnemyOnMapTile(), CMap::Info, Map, MapFieldAirUnit, MapFieldLandUnit, MapFieldSeaUnit, CMapInfo::MapHeight, CMapInfo::MapWidth, CUnitType::MovementMask, CUnit::Type, CUnit::X, CUnit::Y, and y.

Referenced by AiPlanAttack().

static void AiMarkWaterTransporter ( const CUnit unit,
unsigned char *  matrix 
) [static]

Mark all by transporter reachable water tiles.

Parameters:
unit Transporter
matrix Water matrix.
Note:
only works for water transporters!

Definition at line 115 of file ai_plan.cpp.

References CanMoveToMask(), DebugPrint, CMap::Info, Map, MapFieldAirUnit, MapFieldLandUnit, MapFieldSeaUnit, CMapInfo::MapHeight, CMapInfo::MapWidth, CUnitType::MovementMask, CUnit::Type, CUnit::X, CUnit::Y, and y.

Referenced by AiPlanAttack().

int AiPlanAttack ( AiForce force  ) 

< Plan the an attack

Plan an attack with a force. We know, that we must use a transporter.

Parameters:
force Pointer on the force.
Returns:
True if target found, false otherwise.
Todo:
Perfect planning. Only works for water transporter!
Todo:
transporter are more selective now (flag with unittypeland). We must manage it.

Definition at line 375 of file ai_plan.cpp.

References _C_, AiFindTarget(), AiMarkWaterTransporter(), AiPlayer, CUnitType::CanTransport, CreateMatrix(), DebugPrint, PlayerAi::Force, AiForce::GoalX, AiForce::GoalY, CPlayer::Index, int(), CUnit::IsIdle(), AiForce::MustTransport, PlayerAi::Player, CUnit::RefsIncrease(), AiForce::State, CPlayer::TotalNumUnits, CUnit::Type, UnitNumber, CPlayer::Units, AiForce::Units, CUnitType::UnitType, UnitTypeLand, and y.

Referenced by AiAttackWithForce().

void AiSendExplorers ( void   ) 

static CUnit* EnemyOnMapTile ( const CUnit source,
int  tx,
int  ty 
) [static]

Choose enemy on map tile.

Parameters:
source Unit which want to attack.
tx X position on map, tile-based.
ty Y position on map, tile-based.
Returns:
Returns ideal target on map tile.

Definition at line 65 of file ai_plan.cpp.

References CanTarget(), CPlayer::IsEnemy(), NoUnitP, CUnit::Orders, CUnit::Player, CUnitType::Priority, CUnit::Removed, CUnitCache::Select(), CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, UnitActionDie, UnitCache, UnitMax, CUnit::X, and CUnit::Y.

Referenced by AiFindTarget().


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