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
CommunicatingAI Class Reference

this class is meant to be inherited by AI wishing to process comm messages More...

#include <comm_ai.h>

Inheritance diagram for CommunicatingAI:
Order Orders::FireAt Orders::AggressiveAI Orders::Ikarus

Public Member Functions

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...
 
virtual float getMood ()
 
UnitGetRandomUnit (float PlayerProbability, float TargetProbability)
 
void RandomInitiateCommunication (float PlayerProbability, float TargetProbability)
 
void TerminateContrabandSearch (bool foundcontraband)
 
void InitiateContrabandSearch (float PlayerProbability, float TargetProbability)
 
void UpdateContrabandSearch ()
 
 CommunicatingAI (int ttype, int stype, float mood=0, float anger=-666, float appeasement=666, float moodswingyness=666, float randomnessresponse=666)
 
virtual void ProcessCommMessage (class CommunicationMessage &c)
 processes a single message...generally called by the Messages() func More...
 
virtual void AdjustRelationTo (Unit *un, float factor)
 
virtual ~CommunicatingAI ()
 
virtual int selectCommunicationMessage (class CommunicationMessage &c, Unit *)
 
virtual int selectCommunicationMessageMood (CommunicationMessage &c, float mood)
 
- 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 Execute ()
 The function that gets called and executes all queued suborders. 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 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 std::string getOrderDescription ()
 
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 ()
 

Protected Member Functions

void GetMadAt (Unit *which, int howMad)
 
- Protected Member Functions inherited from Order
virtual ~Order ()
 
virtual void Destructor ()
 changes the local relation of this unit to another...may inform superiors about "good" or bad! behavior depending on the AI More...
 

Protected Attributes

float anger
 
float appease
 
float moodswingyness
 
float randomresponse
 
float mood
 
UnitContainer contraband_searchee
 
Vector SpeedAndCourse
 
int which_cargo_item
 
- 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
 

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 }
 

Detailed Description

this class is meant to be inherited by AI wishing to process comm messages

Definition at line 9 of file comm_ai.h.

Constructor & Destructor Documentation

CommunicatingAI::CommunicatingAI ( int  ttype,
int  stype,
float  mood = 0,
float  anger = -666,
float  appeasement = 666,
float  moodswingyness = 666,
float  randomnessresponse = 666 
)

Definition at line 16 of file comm_ai.cpp.

References appease, VegaConfig::getVariable(), XMLSupport::parse_float(), randomresponse, and vs_config.

22  : Order( ttype, stype )
23  , anger( anger )
24  , appease( appeas )
26  , randomresponse( randomresp )
27  , mood( mood )
28 {
29  if (appease > 665 && appease < 667) {
30  static float appeas = XMLSupport::parse_float( vs_config->getVariable( "AI", "EaseToAppease", ".5" ) );
31  this->appease = appeas;
32  }
33  if ( (anger > 665 && anger < 667) || (anger > -667 && anger < -665) ) {
34  static float ang = XMLSupport::parse_float( vs_config->getVariable( "AI", "EaseToAnger", "-.5" ) );
35  this->anger = ang;
36  }
37  if (moodswingyness > 665 && moodswingyness < 667) {
38  static float ang1 = XMLSupport::parse_float( vs_config->getVariable( "AI", "MoodSwingLevel", ".2" ) );
39  this->moodswingyness = ang1;
40  }
41  if (randomresp > 665 && moodswingyness < 667) {
42  static float ang2 = XMLSupport::parse_float( vs_config->getVariable( "AI", "RandomResponseRange", ".8" ) );
43  this->randomresponse = ang2;
44  }
45 }
CommunicatingAI::~CommunicatingAI ( )
virtual

Definition at line 435 of file comm_ai.cpp.

435 {}

Member Function Documentation

void CommunicatingAI::AdjustRelationTo ( Unit un,
float  factor 
)
virtual

Reimplemented from Order.

Definition at line 278 of file comm_ai.cpp.

References _Universe, UniverseUtil::adjustFGRelationModifier(), UniverseUtil::adjustRelationModifierInt(), Order::AdjustRelationTo(), Pilot::adjustSpecificRelationship(), anger, appease, Flightgroup::directive, Unit::faction, UnitUtil::getFactionRelation(), Unit::getFlightgroup(), Pilot::getRank(), mood, moodswingyness, Flightgroup::name, Network, Order::parent, Unit::pilot, Unit::Target(), Unit::TargetTurret(), and Universe::whichPlayerStarship().

279 {
280  if (Network)
281  return; //Server will handle this.
282 
283  Order::AdjustRelationTo( un, factor );
284  float newrel = parent->pilot->adjustSpecificRelationship( parent, un, factor, un->faction );
285 
286  {
287  int whichCp = _Universe->whichPlayerStarship( parent );
288  Flightgroup *toFg;
289  int toFaction;
290  float oRlyFactor = factor;
291  if (whichCp != -1) {
292  toFg = un->getFlightgroup();
293  toFaction = un->faction;
294  } else {
295  /* Instead use the Aggressor's cockpit? */
296  whichCp = _Universe->whichPlayerStarship( un );
297  toFg = parent->getFlightgroup();
298  toFaction = parent->faction;
299  }
300  if (whichCp != -1) {
301  if (toFg && un->faction != parent->faction)
302  oRlyFactor = factor*0.5;
303  if (toFg)
304  UniverseUtil::adjustFGRelationModifier( whichCp, toFg->name, oRlyFactor*parent->pilot->getRank() );
305  if (un->faction != parent->faction)
306  UniverseUtil::adjustRelationModifierInt( whichCp, toFaction, oRlyFactor*parent->pilot->getRank() );
307  }
308  }
309  if ( newrel < anger || (parent->Target() == NULL && newrel+UnitUtil::getFactionRelation( parent, un ) < 0) ) {
310  if ( parent->Target() == NULL
311  || (parent->getFlightgroup() == NULL || parent->getFlightgroup()->directive.find( "." ) == string::npos) ) {
312  parent->Target( un ); //he'll target you--even if he's friendly
313  parent->TargetTurret( un ); //he'll target you--even if he's friendly
314  } else if (newrel > appease) {
315  if (parent->Target() == un) {
316  if (parent->getFlightgroup() == NULL || parent->getFlightgroup()->directive.find( "." ) == string::npos) {
317  parent->Target( NULL );
318  parent->TargetTurret( NULL ); //he'll target you--even if he's friendly
319  }
320  }
321  }
322  }
323  mood += factor*moodswingyness;
324 }
void CommunicatingAI::Destroy ( )
virtual

The virutal function that unrefs all memory then calls Destruct () which takes care of unreffing this or calling delete on this.

Reimplemented from Order.

Definition at line 235 of file comm_ai.cpp.

References _Universe, Universe::AccessCockpit(), Order::Destroy(), Unit::faction, FactionUtil::GetConversation(), Pilot::getGender(), Cockpit::GetParent(), i, Universe::numPlayers(), Order::parent, Unit::pilot, Cockpit::SetStaticAnimation(), and FSM::StopAllSounds().

236 {
237  for (unsigned int i = 0; i < _Universe->numPlayers(); ++i) {
238  Unit *target = _Universe->AccessCockpit( i )->GetParent();
239  if (target) {
240  FSM *fsm = FactionUtil::GetConversation( this->parent->faction, target->faction );
241  if ( fsm->StopAllSounds( (unsigned char) ( parent->pilot->getGender() ) ) ) {
244  }
245  }
246  }
247  this->Order::Destroy();
248 }
void CommunicatingAI::GetMadAt ( Unit which,
int  howMad 
)
protected

Definition at line 159 of file comm_ai.cpp.

References Order::parent.

Referenced by TerminateContrabandSearch(), and UpdateContrabandSearch().

160 {
161  ::GetMadAt( un, parent, numHitsPerContrabandFail );
162 }
virtual float CommunicatingAI::getMood ( )
inlinevirtual

Reimplemented from Order.

Definition at line 24 of file comm_ai.h.

References mood.

25  {
26  return mood;
27  }
Unit * CommunicatingAI::GetRandomUnit ( float  PlayerProbability,
float  TargetProbability 
)

Definition at line 327 of file comm_ai.cpp.

References _Universe, Universe::AccessCockpit(), Universe::activeStarSystem(), StarSystem::collidemap, CollideArray::end(), findObjects(), Unit::GetComputerData(), Order::GetParent(), VegaConfig::getVariable(), CollideArray::lower_bound(), Magnitude(), Unit::Computer::RADARLIM::maxrange, Universe::numPlayers(), Order::parent, XMLSupport::parse_float(), Unit::Position(), QVector, Unit::Computer::radar, Collidable::radius, Collidable::ref, Unit::rSize(), Unit::Target(), VSRandom::uniformInc(), Collidable::CollideRef::unit, Unit::UNIT_ONLY, vs_config, and vsrandom.

Referenced by InitiateContrabandSearch(), and RandomInitiateCommunication().

328 {
329  if (vsrandom.uniformInc( 0, 1 ) < playaprob) {
330  Unit *playa = _Universe->AccessCockpit( rand()%_Universe->numPlayers() )->GetParent();
331  if (playa)
332  if ( ( playa->Position()-parent->Position() ).Magnitude()-parent->rSize()-playa->rSize() )
333  return playa;
334  }
335  if ( vsrandom.uniformInc( 0, 1 ) < targprob && parent->Target() )
336  return parent->Target();
337  //FIXME FOR TESTING ONLY
338  //return parent->Target();
340  vsrandom.uniformInc( -1, 1 ),
341  vsrandom.uniformInc( -1, 1 ) );
342  Collidable wherewrapper( 0, 0, where );
343 
344  //FIXME cm and unitRad below cause unused variable warnings because VS_ENABLE_COLLIDE_KEY is obviously not defined.
345  //Anybody knows if this ifdef serves an important purpose or can be removed?
347  static float unitRad =
348  XMLSupport::parse_float( vs_config->getVariable( "graphics", "hud", "radar_search_extra_radius", "1000" ) );
349  NearestUnitLocator unitLocator;
350 #ifdef VS_ENABLE_COLLIDE_KEY
351  CollideMap::iterator iter = cm->lower_bound( wherewrapper );
352  if (iter != cm->end() && (*iter)->radius > 0)
353  if ( (*iter)->ref.unit != parent )
354  return (*iter)->ref.unit;
356 
357  Unit *target = unitLocator.retval.unit;
358  if (target == NULL || target == parent)
359  target = parent->Target();
360 #else
361  Unit *target = parent->Target();
362 #endif
363  return target;
364 }
void CommunicatingAI::InitiateContrabandSearch ( float  PlayerProbability,
float  TargetProbability 
)

Definition at line 250 of file comm_ai.cpp.

References c, Order::Communicate(), contraband_searchee, Unit::faction, CommunicationMessage::fsm, Unit::getAIState(), Pilot::getCommFaces(), FactionUtil::GetContraband(), FSM::GetContrabandInitiateNode(), GetRandomUnit(), UnitContainer::GetUnit(), UnitUtil::getUnitSystemFile(), Unit::GetVelocity(), UnitUtil::isDockableUnit(), Unit::numCargo(), Order::parent, Unit::pilot, CommunicationMessage::SetCurrentState(), UnitContainer::SetUnit(), SpeedAndCourse, TerminateContrabandSearch(), v, and which_cargo_item.

251 {
252  Unit *u = GetRandomUnit( playaprob, targprob );
253  if (u) {
255  if (un) {
258  Unit *v;
259  if ( ( v = contraband_searchee.GetUnit() ) ) {
260  if (v == u)
261  return;
262  TerminateContrabandSearch( false );
263  }
266  unsigned char gender;
267  std::vector< Animation* > *comm_face = parent->pilot->getCommFaces( gender );
268  CommunicationMessage c( parent, u, comm_face, gender );
269  c.SetCurrentState( c.fsm->GetContrabandInitiateNode(), comm_face, gender );
270  if ( u->getAIState() )
271  u->getAIState()->Communicate( c );
272  which_cargo_item = 0;
273  }
274  }
275  }
276 }
void CommunicatingAI::ProcessCommMessage ( class CommunicationMessage c)
virtual

processes a single message...generally called by the Messages() func

Reimplemented from Order.

Definition at line 408 of file comm_ai.cpp.

References b, Order::Communicate(), FSM::Node::edges, Unit::faction, CommunicationMessage::fsm, Unit::getAIState(), Pilot::getCommFaces(), FactionUtil::GetConversation(), CommunicationMessage::getCurrentState(), UnitContainer::GetUnit(), UnitUtil::getUnitSystemFile(), isDockedAtAll(), Order::messagequeue, Order::parent, Unit::pilot, Order::ProcessCommMessage(), selectCommunicationMessage(), and CommunicationMessage::sender.

409 {
410  if ( messagequeue.back()->curstate < messagequeue.back()->fsm->GetUnDockNode() ) {
412  FSM *tmpfsm = c.fsm;
413  Unit *targ = c.sender.GetUnit();
414  if ( targ && UnitUtil::getUnitSystemFile( targ ) == UnitUtil::getUnitSystemFile( parent ) && !isDockedAtAll( targ ) ) {
416  FSM::Node *n = c.getCurrentState();
417  if (n) {
418  if ( n->edges.size() ) {
419  Unit *un = c.sender.GetUnit();
420  if (un) {
421  int b = selectCommunicationMessage( c, un );
422  Order *o = un->getAIState();
423  unsigned char gender;
424  std::vector< Animation* > *comm_face = parent->pilot->getCommFaces( gender );
425  if (o)
426  o->Communicate( CommunicationMessage( parent, un, c, b, comm_face, gender ) );
427  }
428  }
429  }
430  c.fsm = tmpfsm;
431  }
432  }
433 }
void CommunicatingAI::RandomInitiateCommunication ( float  PlayerProbability,
float  TargetProbability 
)

Definition at line 366 of file comm_ai.cpp.

References Unit::faction, Pilot::getCommFaces(), Unit::GetComputerData(), FactionUtil::GetConversation(), FSM::getDefaultState(), UnitUtil::getDistance(), UnitUtil::getFlightgroupName(), GetRandomUnit(), Unit::getRelation(), UnitUtil::getUnitSystemFile(), i, isDockedAtAll(), Unit::Computer::RADARLIM::maxrange, Order::messagequeue, Order::parent, Unit::pilot, and Unit::Computer::radar.

367 {
368  Unit *target = GetRandomUnit( playaprob, targprob );
369  if (target != NULL) {
371  && UnitUtil::getFlightgroupName( parent ) != "Base" && !isDockedAtAll( target )
372  && UnitUtil::getDistance( parent, target ) <= target->GetComputerData().radar.maxrange) {
373  //warning--odd hack they can talk to you if you can sense them--it's like SETI@home
374  for (std::list< CommunicationMessage* >::iterator i = messagequeue.begin(); i != messagequeue.end(); i++) {
375  Unit *un = (*i)->sender.GetUnit();
376  if (un == target)
377  return;
378  }
379  //ok we're good to put a default msg in the queue as a fake message;
380  FSM *fsm = FactionUtil::GetConversation( target->faction, this->parent->faction );
381  int state = fsm->getDefaultState( parent->getRelation( target ) );
382  unsigned char gender;
383  std::vector< Animation* > *comm_face = parent->pilot->getCommFaces( gender );
384  messagequeue.push_back( new CommunicationMessage( target, this->parent, state, state, comm_face, gender ) );
385  }
386  }
387 }
int CommunicatingAI::selectCommunicationMessage ( class CommunicationMessage c,
Unit un 
)
virtual

Definition at line 389 of file comm_ai.cpp.

References FSM::Node::edges, Pilot::getAnger(), CommunicationMessage::getCurrentState(), UnitUtil::getFactionRelation(), VegaConfig::getVariable(), mood, Order::parent, XMLSupport::parse_float(), Unit::pilot, selectCommunicationMessageMood(), and vs_config.

Referenced by ProcessCommMessage().

390 {
391  if (0 && mood == 0) {
392  FSM::Node *n = c.getCurrentState();
393  if (n)
394  return rand()%n->edges.size();
395  else
396  return 0;
397  } else {
398  static float moodmul = XMLSupport::parse_float( vs_config->getVariable( "AI", "MoodAffectsRespose", "0" ) );
399  static float angermul = XMLSupport::parse_float( vs_config->getVariable( "AI", "AngerAffectsRespose", "1" ) );
400  static float staticrelmul =
401  XMLSupport::parse_float( vs_config->getVariable( "AI", "StaticRelationshipAffectsResponse", "1" ) );
402  return selectCommunicationMessageMood( c, moodmul*mood+angermul*parent->pilot->getAnger( parent,
403  un )+staticrelmul
405  }
406 }
int CommunicatingAI::selectCommunicationMessageMood ( CommunicationMessage c,
float  mood 
)
virtual

Definition at line 68 of file comm_ai.cpp.

References CommunicationMessage::curstate, CommunicationMessage::fsm, FSM::getCommMessageMood(), FSM::getDefaultState(), Pilot::GetEffectiveRelationship(), FSM::GetUnDockNode(), UnitContainer::GetUnit(), MatchingMood(), Order::parent, Unit::pilot, randomresponse, CommunicationMessage::sender, and Unit::Target().

Referenced by selectCommunicationMessage().

69 {
70  Unit *targ = c.sender.GetUnit();
71  float relationship = 0;
72  if (targ) {
73  relationship = parent->pilot->GetEffectiveRelationship( parent, targ );
74  if (targ == parent->Target() && relationship > -1.0)
75  relationship = -1.0;
76  mood += (1-randomresponse)*relationship;
77  }
78  //breaks stuff
79  if ( ( c.curstate >= c.fsm->GetUnDockNode() ) || !MatchingMood( c, mood, randomresponse, relationship ) )
80  c.curstate = c.fsm->getDefaultState( relationship ); //hijack the current state
81  return c.fsm->getCommMessageMood( c.curstate, mood, randomresponse, relationship );
82 }
void CommunicatingAI::TerminateContrabandSearch ( bool  foundcontraband)

Definition at line 137 of file comm_ai.cpp.

References AllUnitsCloseAndEngage(), c, Order::Communicate(), contraband_searchee, Unit::faction, CommunicationMessage::fsm, Unit::getAIState(), Pilot::getCommFaces(), FSM::GetContrabandDetectedNode(), FSM::GetContrabandUnDetectedNode(), GetMadAt(), UnitContainer::GetUnit(), Order::parent, Unit::pilot, CommunicationMessage::SetCurrentState(), and UnitContainer::SetUnit().

Referenced by InitiateContrabandSearch(), and UpdateContrabandSearch().

138 {
139  //reports success or failure
140  Unit *un;
141  unsigned char gender;
142  std::vector< Animation* > *comm_face = parent->pilot->getCommFaces( gender );
143  if ( ( un = contraband_searchee.GetUnit() ) ) {
144  CommunicationMessage c( parent, un, comm_face, gender );
145  if (contraband_detected) {
146  c.SetCurrentState( c.fsm->GetContrabandDetectedNode(), comm_face, gender );
147  GetMadAt( un, 0 );
149  } else {
150  c.SetCurrentState( c.fsm->GetContrabandUnDetectedNode(), comm_face, gender );
151  }
152  Order *o = un->getAIState();
153  if (o)
154  o->Communicate( c );
155  }
157 }
void CommunicatingAI::UpdateContrabandSearch ( )

Definition at line 176 of file comm_ai.cpp.

References c, Order::Communicate(), Cargo::content, contraband_searchee, Unit::CourseDeviation(), Unit::faction, CommunicationMessage::fsm, Unit::getAIState(), Unit::GetCargo(), Pilot::getCommFaces(), FactionUtil::GetContraband(), FSM::GetContrabandWobblyNode(), Unit::getHiddenCargoVolume(), GetMadAt(), Unit::GetManifest(), UnitContainer::GetUnit(), VegaConfig::getVariable(), Unit::GetVelocity(), i, InList(), max(), Unit::numCargo(), Order::parent, XMLSupport::parse_bool(), XMLSupport::parse_float(), XMLSupport::parse_int(), Unit::pilot, Cargo::quantity, CommunicationMessage::SetCurrentState(), SpeedAndCourse, TerminateContrabandSearch(), vs_config, and which_cargo_item.

177 {
178  static unsigned int contraband_search_batch_update =
179  XMLSupport::parse_int( vs_config->getVariable( "AI", "num_contraband_scans_per_search", "10" ) );
180  for (unsigned int rep = 0; rep < contraband_search_batch_update; ++rep) {
182  if ( u && (u->faction != parent->faction) ) {
183  //don't scan your buddies
184  if ( which_cargo_item < (int) u->numCargo() ) {
185  if (u->GetCargo( which_cargo_item ).quantity > 0) {
186  int which_carg_item_bak = which_cargo_item;
187  std::string item = u->GetManifest( which_cargo_item++, parent, SpeedAndCourse );
188  static bool use_hidden_cargo_space =
189  XMLSupport::parse_bool( vs_config->getVariable( "physics", "use_hidden_cargo_space", "true" ) );
190  static float speed_course_change =
191  XMLSupport::parse_float( vs_config->getVariable( "AI", "PercentageSpeedChangeToStopSearch", "1" ) );
192  if (u->CourseDeviation( SpeedAndCourse, u->GetVelocity() ) > speed_course_change) {
193  unsigned char gender;
194  std::vector< Animation* > *comm_face = parent->pilot->getCommFaces( gender );
195  CommunicationMessage c( parent, u, comm_face, gender );
196  c.SetCurrentState( c.fsm->GetContrabandWobblyNode(), comm_face, gender );
197  Order *o;
198  if ( ( o = u->getAIState() ) )
199  o->Communicate( c );
200  GetMadAt( u, 1 );
202  }
203  float HiddenTotal = use_hidden_cargo_space ? ( u->getHiddenCargoVolume() ) : (0);
204  Unit *contrabandlist = FactionUtil::GetContraband( parent->faction );
205  if (InList( item, contrabandlist ) > 0) {
206  //inlist now returns an integer so that we can do this at all...
207  if (HiddenTotal == 0 || u->GetCargo( which_carg_item_bak ).quantity > HiddenTotal) {
208  TerminateContrabandSearch( true ); //BUCO this is where we want to check against free hidden cargo space.
209  } else {
210  unsigned int max = u->numCargo();
211  unsigned int quantity = 0;
212  for (unsigned int i = 0; i < max; ++i)
213  if (InList( u->GetCargo( i ).content, contrabandlist ) > 0) {
214  quantity += u->GetCargo( i ).quantity;
215  if (quantity > HiddenTotal) {
217  break;
218  }
219  }
220  }
221  }
222  } else {
223  TerminateContrabandSearch( false );
224  }
225  }
226  }
227  }
228 }

Member Data Documentation

float CommunicatingAI::anger
protected

Definition at line 12 of file comm_ai.h.

Referenced by AdjustRelationTo().

float CommunicatingAI::appease
protected

Definition at line 13 of file comm_ai.h.

Referenced by AdjustRelationTo(), and CommunicatingAI().

UnitContainer CommunicatingAI::contraband_searchee
protected
float CommunicatingAI::mood
protected

Definition at line 16 of file comm_ai.h.

Referenced by AdjustRelationTo(), getMood(), and selectCommunicationMessage().

float CommunicatingAI::moodswingyness
protected

Definition at line 14 of file comm_ai.h.

Referenced by AdjustRelationTo().

float CommunicatingAI::randomresponse
protected

Definition at line 15 of file comm_ai.h.

Referenced by CommunicatingAI(), and selectCommunicationMessageMood().

Vector CommunicatingAI::SpeedAndCourse
protected

Definition at line 18 of file comm_ai.h.

Referenced by InitiateContrabandSearch(), and UpdateContrabandSearch().

int CommunicatingAI::which_cargo_item
protected

Definition at line 19 of file comm_ai.h.

Referenced by InitiateContrabandSearch(), and UpdateContrabandSearch().


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