Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Orders::FaceTargetITTS Class Reference

#include <navigation.h>

Inheritance diagram for Orders::FaceTargetITTS:
Orders::ChangeHeading Order Orders::FacePerpendicular Orders::LoopAround Orders::LoopAroundAgro Orders::TurretAI

Public Member Functions

 FaceTargetITTS (bool fini=false, int accuracy=3)
 
virtual void Execute ()
 The function that gets called and executes all queued suborders. More...
 
virtual string getOrderDescription ()
 
virtual ~FaceTargetITTS ()
 
- Public Member Functions inherited from Orders::ChangeHeading
 ChangeHeading (const QVector &final_heading, int switchback, float turning_speed=1, bool term=false)
 takes in the destination target, and the ammount of accuracy (how many times it should miss destination and come back) should be used More...
 
void SetDest (const QVector &)
 
virtual ~ChangeHeading ()
 
- Public Member Functions inherited from Order
virtual void ChooseTarget ()
 this function calls the destructor (needs to be overridden for python; More...
 
virtual bool PursueTarget (Unit *, bool isleader)
 
void ClearMessages ()
 clears the messasges of this order More...
 
 Order ()
 The default constructor setting everything to NULL and no dependency on order. More...
 
 Order (int type, int subtype)
 The constructor that specifies what order dependencies this order has. More...
 
virtual void Destroy ()
 The virutal function that unrefs all memory then calls Destruct () which takes care of unreffing this or calling delete on this. More...
 
OrderqueryType (unsigned int type)
 returns a pointer to the first order that may be bitwised ored with that type More...
 
OrderqueryAny (unsigned int type)
 returns a pointer to the first order that may be bitwise ored with any type More...
 
void eraseType (unsigned int type)
 Erases all orders that bitwise OR with that type. More...
 
bool AttachOrder (Unit *targets)
 Attaches a group of targets to this order (used for strategery-type games) More...
 
bool AttachOrder (QVector target)
 Attaches a navigation point to this order. More...
 
bool AttachSelfOrder (Unit *targets)
 Attaches a group (form up) to this order. More...
 
OrderEnqueueOrder (Order *ord)
 Enqueues another order that will be executed (in parallel perhaps) when next void Execute() is called. More...
 
OrderReplaceOrder (Order *ord)
 Replaces the first order of that type in the order queue. More...
 
bool Done ()
 
int getType ()
 
int getSubType ()
 
virtual void SetParent (Unit *parent1)
 Sets the parent of this Unit. Any virtual functions must call this one. More...
 
UnitGetParent () const
 
virtual void Communicate (const class CommunicationMessage &c)
 Sends a communication message from the Unit (encapulated in c) to this unit. More...
 
virtual void ProcessCommMessage (class CommunicationMessage &c)
 processes a single message...generally called by the Messages() func More...
 
virtual void ProcessCommunicationMessages (float CommRepsonseTime, bool RemoveMessageProcessed)
 responds (or does not) to certain messages in the message queue More...
 
OrderfindOrder (Order *ord)
 return pointer to order or NULL if not found More...
 
void eraseOrder (Order *ord)
 erase that order from the list More...
 
OrderEnqueueOrderFirst (Order *ord)
 enqueue order as first order More...
 
virtual olist_tgetOrderList ()
 returns the orderlist (NULL for orders that haven't got any) More...
 
virtual void AdjustRelationTo (Unit *un, float factor)
 
OrderfindOrderList ()
 searches the suborders recursively for the first order that has an orderlist More...
 
std::string createFullOrderDescription (int level=0)
 
void setActionString (std::string astring)
 
std::string getActionString ()
 
virtual float getMood ()
 

Additional Inherited Members

- Public Types inherited from Order
enum  ORDERTYPES {
  MOVEMENT =1, FACING =2, WEAPON =4, CLOAKING =8,
  ALLTYPES =(1|2|4|8)
}
 The varieties of order types MOVEMENT,FACING, and WEAPON orders may not be mutually executed (lest one engine goes left, the other right) More...
 
enum  SUBORDERTYPES { SLOCATION =1, STARGET =2, SSELF =4 }
 
- Protected Member Functions inherited from Orders::ChangeHeading
void ResetDone ()
 
- Protected Attributes inherited from Order
Unitparent
 The unit this order is attached to. More...
 
unsigned int type
 The bit code (from ORDERTYPES) that this order is (for parallel execution) More...
 
unsigned int subtype
 
bool done
 Whether or not this order is done. More...
 
UnitContainer group
 If this order applies to a group of units (as in form up with this group) More...
 
QVector targetlocation
 If this order applies to a physical location in world space. More...
 
std::vector< Order * > suborders
 The queue of suborders that will be executed in parallel according to bit code. More...
 
std::list< class
CommunicationMessage * > 
messagequeue
 a bunch of communications that have not been answered CommunicationMessages are actually containing reference to a nice Finite State Machine that can allow a player to have a reasonable conversation with an AI More...
 
std::string actionstring
 

Detailed Description

This class analyzes a Unit's position and adjusts ChangeHeading to face that target's ITTS indicator for best firing solution

Definition at line 160 of file navigation.h.

Constructor & Destructor Documentation

FaceTargetITTS::FaceTargetITTS ( bool  fini = false,
int  accuracy = 3 
)

Definition at line 370 of file navigation.cpp.

References game_data_t::difficulty, Order::FACING, float, g_game, VegaConfig::getVariable(), XMLSupport::parse_bool(), Order::STARGET, Order::subtype, Order::type, and vs_config.

370  : ChangeHeading( QVector( 0, 0, 1 ), accuracy )
371  , finish( fini )
372 {
373  type = FACING;
374  subtype = STARGET;
375  speed = float(.00001);
376  useitts = true;
377  static bool alwaysuseitts = XMLSupport::parse_bool( vs_config->getVariable( "AI", "always_use_itts", "false" ) );
378  if (!alwaysuseitts)
379  if (rand() >= g_game.difficulty*RAND_MAX)
380  useitts = false;
381 }
FaceTargetITTS::~FaceTargetITTS ( )
virtual

Definition at line 382 of file navigation.cpp.

References VSFileSystem::vs_fprintf().

383 {
384 #ifdef ORDERDEBUG
385  VSFileSystem::vs_fprintf( stderr, "fti%x", this );
386  fflush( stderr );
387 #endif
388 }

Member Function Documentation

void FaceTargetITTS::Execute ( )
virtual

The function that gets called and executes all queued suborders.

Reimplemented from Orders::ChangeHeading.

Reimplemented in Orders::FacePerpendicular, Orders::LoopAroundAgro, Orders::LoopAround, and Orders::TurretAI.

Definition at line 390 of file navigation.cpp.

References Unit::cumulative_velocity, Order::done, Orders::ChangeHeading::Execute(), Unit::getAverageGunSpeed(), Unit::Position(), Unit::PositionITTS(), Orders::ChangeHeading::ResetDone(), Orders::ChangeHeading::SetDest(), and Unit::Target().

Referenced by Orders::TurretAI::Execute(), Orders::LoopAround::Execute(), Orders::LoopAroundAgro::Execute(), and Orders::FacePerpendicular::Execute().

391 {
392  Unit *target = parent->Target();
393  if (target == NULL) {
394  done = finish;
395  return;
396  }
397  if ( speed == float(.00001) ) {
398  float mrange;
399  float range;
400  parent->getAverageGunSpeed( speed, range, mrange );
401  if ( speed == float(.00001) )
402  speed = FLT_MAX;
403  }
404  SetDest( useitts ? target->PositionITTS( parent->Position(), parent->cumulative_velocity, speed, false ) : target->Position() );
406  if (!finish)
407  ResetDone();
408 }
virtual string Orders::FaceTargetITTS::getOrderDescription ( )
inlinevirtual

Reimplemented from Orders::ChangeHeading.

Definition at line 168 of file navigation.h.

169  {
170  return "faceitts";
171  }

The documentation for this class was generated from the following files: