_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

Public Member Functions | Friends | List of all members
COrder_Attack Class Reference

#include <action_attack.h>

Inheritance diagram for COrder_Attack:
COrder

Public Member Functions

 COrder_Attack (bool ground)
 
virtual COrder_AttackClone () const
 
virtual const Vec2i GetGoalPos () const
 
- Public Member Functions inherited from COrder
 COrder (int action)
 
virtual void Cancel (CUnit &unit)
 
virtual void UpdateUnitVariables (CUnit &unit) const
 
bool HasGoal () const
 
CUnitGetGoal () const
 
bool ParseGenericData (lua_State *l, int &j, const char *value)
 
virtual ~COrder ()
 Hash calculated to find sync failures. More...
 
virtual void FillSeenValues (CUnit &unit) const
 
virtual void AiUnitKilled (CUnit &unit)
 
void SetGoal (CUnit *const new_goal)
 
void ClearGoal ()
 

Friends

COrderCOrder::NewActionAttack (const CUnit &attacker, CUnit &target)
 
COrderCOrder::NewActionAttack (const CUnit &attacker, const Vec2i &dest)
 
COrderCOrder::NewActionAttackGround (const CUnit &attacker, const Vec2i &dest)
 

action_attack.cpp - The attack action.

virtual bool IsValid () const
 
virtual void Save (CFile &file, const CUnit &unit) const
 
virtual bool ParseSpecificData (lua_State *l, int &j, const char *value, const CUnit &unit)
 
virtual void Execute (CUnit &unit)
 
virtual void OnAnimationAttack (CUnit &unit)
 
virtual PixelPos Show (const CViewport &vp, const PixelPos &lastScreenPos) const
 
virtual void UpdatePathFinderData (PathFinderInput &input)
 
virtual bool OnAiHitUnit (CUnit &unit, CUnit *attacker, int)
 
bool IsWeakTargetSelected () const
 
bool IsAutoTargeting () const
 
bool IsMovingToAttackPos () const
 
bool IsAttackGroundOrWall () const
 
bool IsTargetTooClose (const CUnit &unit) const
 
CUnit *const BestTarget (const CUnit &unit, CUnit *const target1, CUnit *const target2) const
 
void OfferNewTarget (const CUnit &unit, CUnit *const target)
 

Additional Inherited Members

- Static Public Member Functions inherited from COrder
static COrderNewActionAttack (const CUnit &attacker, CUnit &target)
 
static COrderNewActionAttack (const CUnit &attacker, const Vec2i &dest)
 
static COrderNewActionAttackGround (const CUnit &attacker, const Vec2i &dest)
 
static COrderNewActionBoard (CUnit &unit)
 
static COrderNewActionBuild (const CUnit &builder, const Vec2i &pos, CUnitType &building)
 
static COrderNewActionBuilt (CUnit &builder, CUnit &unit)
 
static COrderNewActionDefend (CUnit &dest)
 
static COrderNewActionDie ()
 
static COrderNewActionExplore (const CUnit &unit)
 
static COrderNewActionFollow (CUnit &dest)
 
static COrderNewActionMove (const Vec2i &pos)
 
static COrderNewActionPatrol (const Vec2i &currentPos, const Vec2i &dest)
 
static COrderNewActionRepair (CUnit &unit, CUnit &target)
 
static COrderNewActionRepair (const Vec2i &pos)
 
static COrderNewActionResearch (CUnit &unit, CUpgrade &upgrade)
 
static COrderNewActionResource (CUnit &harvester, const Vec2i &pos)
 
static COrderNewActionResource (CUnit &harvester, CUnit &mine)
 
static COrderNewActionReturnGoods (CUnit &harvester, CUnit *depot)
 
static COrderNewActionSpellCast (const SpellType &spell, const Vec2i &pos, CUnit *target, bool isAutocast=false)
 
static COrderNewActionStandGround ()
 
static COrderNewActionStill ()
 
static COrderNewActionTrain (CUnit &trainer, CUnitType &type)
 
static COrderNewActionTransformInto (CUnitType &type)
 
static COrderNewActionUpgradeTo (CUnit &unit, CUnitType &type, bool instant=false)
 
static COrderNewActionUnload (const Vec2i &pos, CUnit *what)
 
- Public Attributes inherited from COrder
const unsigned char Action
 
bool Finished
 global action More...
 
bool Instant
 true when order is finish More...
 
- Protected Member Functions inherited from COrder
void UpdatePathFinderData_NotCalled (PathFinderInput &input)
 

Constructor & Destructor Documentation

◆ COrder_Attack()

COrder_Attack::COrder_Attack ( bool  ground)
inlineexplicit

Member Function Documentation

◆ BestTarget()

CUnit *const COrder_Attack::BestTarget ( const CUnit unit,
CUnit *const  target1,
CUnit *const  target2 
) const

◆ Clone()

virtual COrder_Attack* COrder_Attack::Clone ( ) const
inlinevirtual

Implements COrder.

◆ Execute()

void COrder_Attack::Execute ( CUnit unit)
virtual

Unit attacks!

if (SubAction & AUTO_TARGETING) is true the goal is a weak goal. This means the unit AI (little AI) could choose a new better goal.

Todo:
Lets do some tries to reach the target. If target place is not reachable, choose better goal to reduce the pathfinder load.
Parameters
unitUnit, for that the attack is handled.

Implements COrder.

◆ GetGoalPos()

virtual const Vec2i COrder_Attack::GetGoalPos ( ) const
inlinevirtual

Get goal position

Reimplemented from COrder.

◆ IsAttackGroundOrWall()

bool COrder_Attack::IsAttackGroundOrWall ( ) const

FIXME: Check if need to add this: (goal && goal->Type && goal->Type->BoolFlag[WALL_INDEX].value)

◆ IsAutoTargeting()

bool COrder_Attack::IsAutoTargeting ( ) const

◆ IsMovingToAttackPos()

bool COrder_Attack::IsMovingToAttackPos ( ) const

◆ IsTargetTooClose()

bool COrder_Attack::IsTargetTooClose ( const CUnit unit) const

Check if current target is closer to unit more than MinAttackRange

Parameters
unitUnit that is attacking and moving

Calculate distance to goal or map tile if attack ground/wall

◆ IsValid()

bool COrder_Attack::IsValid ( ) const
virtual

Implements COrder.

◆ IsWeakTargetSelected()

bool COrder_Attack::IsWeakTargetSelected ( ) const

◆ OfferNewTarget()

void COrder_Attack::OfferNewTarget ( const CUnit unit,
CUnit *const  target 
)

Try to change goal from outside, when in the auto attack mode

@param unit
Parameters
targetTarget that offered as the new current goal

if attacker cant't move (stand_ground, building, in a bunker or transport)

◆ OnAiHitUnit()

bool COrder_Attack::OnAiHitUnit ( CUnit unit,
CUnit attacker,
int   
)
virtual

Reimplemented from COrder.

◆ OnAnimationAttack()

void COrder_Attack::OnAnimationAttack ( CUnit unit)
virtual

Call when animation step is "attack"

Reimplemented from COrder.

◆ ParseSpecificData()

bool COrder_Attack::ParseSpecificData ( lua_State *  l,
int &  j,
const char *  value,
const CUnit unit 
)
virtual

Implements COrder.

◆ Save()

void COrder_Attack::Save ( CFile file,
const CUnit unit 
) const
virtual

Implements COrder.

◆ Show()

PixelPos COrder_Attack::Show ( const CViewport vp,
const PixelPos lastScreenPos 
) const
virtual

Implements COrder.

◆ UpdatePathFinderData()

void COrder_Attack::UpdatePathFinderData ( PathFinderInput input)
virtual

Implements COrder.

Friends And Related Function Documentation

◆ COrder::NewActionAttack [1/2]

COrder* COrder::NewActionAttack ( const CUnit attacker,
const Vec2i dest 
)
friend

◆ COrder::NewActionAttack [2/2]

COrder* COrder::NewActionAttack ( const CUnit attacker,
CUnit target 
)
friend

◆ COrder::NewActionAttackGround

COrder* COrder::NewActionAttackGround ( const CUnit attacker,
const Vec2i dest 
)
friend

The documentation for this class was generated from the following files:
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.