Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

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  
00031 const int aiValueTypeNum = 8;
00032 
00038 class AiThreat {
00039        public:
00040          int threatTypes;
00041          int threat[aiValueTypeNum];
00042          void reset ( void );
00043          AiThreat ( void ) : threatTypes ( aiValueTypeNum ) { reset(); };
00044          AiThreat& operator+= ( const AiThreat& t ) {
00045             for ( int i = 0; i < threatTypes; i++ )
00046                threat[i] += t.threat[i];
00047             return *this;
00048          };
00049 
00050          void read ( tnstream& stream );
00051          void write ( tnstream& stream );
00052 };
00053 
00054 
00060 class AiValue {
00061 #ifdef karteneditor
00062  public:
00063 #endif
00064            int value;
00065            int addedValue;
00066         public:
00067            AiThreat threat;
00068            int valueType;
00069 
00070            void reset ( int _valueType ) { threat.reset(); value = 0; valueType = _valueType; addedValue = 0; };
00071            AiValue ( int _valueType ) { reset( _valueType ); };
00072            int getValue() { return value + addedValue; };
00073            void setValue ( int _value ) { value = _value; };
00074            void setAdditionalValue ( int _addedValue ) { addedValue = _addedValue; };
00075            void resetAdditionalValue (  ) { addedValue = 0; };
00076 
00077            void read ( tnstream& stream );
00078            void write ( tnstream& stream );
00079         };
00080 
00082 class AiParameter : public AiValue {
00083            Vehicle* unit;
00084         public:
00085            static const int taskNum = 8;
00086            static const int jobNum = 8;
00087            enum Task { tsk_nothing, tsk_tactics, tsk_tactwait, tsk_stratwait, tsk_wait, tsk_strategy, tsk_serviceRetreat, tsk_move };
00088            enum Job { job_undefined, job_fight, job_supply, job_conquer, job_build, job_recon, job_guard, job_script };
00089            typedef vector<AiParameter::Job> JobList;
00090 
00091            Task getTask ( ) { return task; };
00092            void setTask ( Task t ) { task = t; };
00093 
00094            Job getJob ( ) { if ( jobPos < jobs.size() ) return jobs[jobPos]; else return job_undefined; };
00095            void addJob ( Job j, bool front = false );
00096 
00097            void setNextJob();
00098            void restartJobs();
00099            void clearJobs();
00100            void setJob ( const JobList& jobs );
00101            void setJob ( Job j );
00102            bool hasJob ( Job j );
00103 
00104 
00105            int lastDamage;
00106            GameTime damageTime;
00107 
00108            MapCoordinate3D dest;
00109            int dest_nwid;
00110            int data;
00111            bool resetAfterJobCompletion;
00112 
00113            void reset ( Vehicle* _unit );
00114            void resetTask ( );
00115            AiParameter ( Vehicle* _unit );
00116 
00117            void read ( tnstream& stream );
00118            void write ( tnstream& stream );
00119         private:
00120            Task task;
00121            JobList jobs;
00122            int jobPos;
00123 };
00124 
00125 class BaseAI {
00126        public:
00127          virtual void run ( void ) = 0;
00128          virtual bool isRunning ( void ) = 0;
00129          virtual VisibilityStates getVision ( void ) = 0;
00130          virtual void read ( tnstream& stream ) = 0;
00131          virtual void write ( tnstream& stream ) const = 0;
00132          virtual ~BaseAI () {};
00133       };
00134 
00135 
00136 
00137 #endif

Generated on Tue Jun 24 01:27:35 2008 for Advanced Strategic Command by  doxygen 1.4.2