baseaiinterface.h

Go to the documentation of this file.
00001 
00005 /***************************************************************************
00006                           baseaiinterface.h  -  description
00007                              -------------------
00008     begin                : Tue Feb 17 2001
00009     copyright            : (C) 2001 by Martin Bickel
00010     email                : bickel@asc-hq.org
00011  ***************************************************************************/
00012 
00013 /***************************************************************************
00014  *                                                                         *
00015  *   This program is free software; you can redistribute it and/or modify  *
00016  *   it under the terms of the GNU General Public License as published by  *
00017  *   the Free Software Foundation; either version 2 of the License, or     *
00018  *   (at your option) any later version.                                   *
00019  *                                                                         *
00020  ***************************************************************************/
00021 
00022 
00023 #ifndef baseaiinterface_h_included
00024  #define baseaiinterface_h_included
00025 
00026 
00027  class Vehicle;
00028  class Building;
00029  class MapDisplayInterface;
00030  
00032 const int aiValueTypeNum = 8;
00033 
00039 class AiThreat {
00040        public:
00041          int threatTypes;
00042          int threat[aiValueTypeNum];
00043          void reset ( void );
00044          AiThreat ( void ) : threatTypes ( aiValueTypeNum ) { reset(); };
00045          AiThreat& operator+= ( const AiThreat& t ) {
00046             for ( int i = 0; i < threatTypes; i++ )
00047                threat[i] += t.threat[i];
00048             return *this;
00049          };
00050 
00051          void read ( tnstream& stream );
00052          void write ( tnstream& stream );
00053 };
00054 
00055 
00061 class AiValue {
00062 #ifdef karteneditor
00063  public:
00064 #endif
00065            int value;
00066            int addedValue;
00067         public:
00068            AiThreat threat;
00069            int valueType;
00070 
00071            void reset ( int _valueType ) { threat.reset(); value = 0; valueType = _valueType; addedValue = 0; };
00072            AiValue ( int _valueType ) { reset( _valueType ); };
00073            int getValue() { return value + addedValue; };
00074            void setValue ( int _value ) { value = _value; };
00075            void setAdditionalValue ( int _addedValue ) { addedValue = _addedValue; };
00076            void resetAdditionalValue (  ) { addedValue = 0; };
00077 
00078            void read ( tnstream& stream );
00079            void write ( tnstream& stream );
00080         };
00081 
00083 class AiParameter : public AiValue {
00084            Vehicle* unit;
00085         public:
00086            static const int taskNum = 8;
00087            static const int jobNum = 8;
00088            enum Task { tsk_nothing, tsk_tactics, tsk_tactwait, tsk_stratwait, tsk_wait, tsk_strategy, tsk_serviceRetreat, tsk_move };
00089            enum Job { job_undefined, job_fight, job_supply, job_conquer, job_build, job_recon, job_guard, job_script };
00090            typedef vector<AiParameter::Job> JobList;
00091 
00092            Task getTask ( ) { return task; };
00093            void setTask ( Task t ) { task = t; };
00094 
00095            Job getJob ( ) { if ( jobPos < jobs.size() ) return jobs[jobPos]; else return job_undefined; };
00096            void addJob ( Job j, bool front = false );
00097 
00098            void setNextJob();
00099            void restartJobs();
00100            void clearJobs();
00101            void setJob ( const JobList& jobs );
00102            void setJob ( Job j );
00103            bool hasJob ( Job j );
00104 
00105 
00106            int lastDamage;
00107            GameTime damageTime;
00108 
00109            MapCoordinate3D dest;
00110            int dest_nwid;
00111            int data;
00112            bool resetAfterJobCompletion;
00113 
00114            void reset ( Vehicle* _unit );
00115            void setNewHeight();
00116            void resetTask ( );
00117            AiParameter ( Vehicle* _unit );
00118 
00119            void read ( tnstream& stream );
00120            void write ( tnstream& stream );
00121         private:
00122            Task task;
00123            JobList jobs;
00124            int jobPos;
00125 };
00126 
00127 class BaseAI {
00128        public:
00129          virtual void run ( MapDisplayInterface* mapDisplay ) = 0;
00130          virtual bool isRunning ( void ) = 0;
00131          virtual VisibilityStates getVision ( void ) = 0;
00132          virtual void read ( tnstream& stream ) = 0;
00133          virtual void write ( tnstream& stream ) const = 0;
00134          virtual ~BaseAI () {};
00135       };
00136 
00137 
00138 
00139 #endif

Generated on Mon May 21 01:26:28 2012 for Advanced Strategic Command by  doxygen 1.5.1