1 #ifndef BTANKS_BASE_AI_H__ 2 #define BTANKS_BASE_AI_H__ 3 4 /* Battle Tanks Game 5 * Copyright (C) 2006-2009 Battle Tanks team 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 */ 21 22 /* 23 * Additional rights can be granted beyond the GNU General Public License 24 * on the terms provided in the Exception. If you modify this file, 25 * you may extend this exception to your version of the file, 26 * but you are not obligated to do so. If you do not wish to provide this 27 * exception without modification, you must delete this exception statement 28 * from your version and license this file solely under the GPL without exception. 29 */ 30 31 #include "export_btanks.h" 32 #include "object.h" 33 #include "traits.h" 34 #include <string> 35 #include <set> 36 #include "alarm.h" 37 #include "synchronizable.h" 38 39 namespace ai { 40 class BTANKSAPI Buratino : public ai::Synchronizable { 41 public: 42 Buratino(); 43 virtual ~Buratino(); 44 45 virtual void calculate(Object *obj, const float dt); 46 virtual void on_spawn(const Object *obj); 47 48 virtual const std::string getWeapon(const int idx) const = 0; 49 virtual const int getWeaponAmount(const int idx) const = 0; 50 static const std::string convertName(const std::string &name); 51 52 const bool active() const; 53 const float getWeaponRange(const Object *object) const; 54 55 static const float getFirePower(const Object *o, ai::Traits &traits); 56 57 protected: 58 virtual void calculateCloseCombat(Object *obj, const Object *target, const float range, const bool dumb); 59 void processPF(Object *object); 60 61 void addEnemyClass(const std::string &classname); 62 void addBonusName(const std::string &rname); 63 const bool isEnemy(const Object *o) const; 64 65 const bool checkTarget(const Object *obj, const Object * target, const std::string &weapon) const; 66 const Object * findTarget(const Object *src, const std::set<std::string> &enemies, const std::set<std::string> &bonuses, ai::Traits &traits, const std::set<int> &skip_objects) const; 67 68 private: 69 70 Alarm _reaction_time, _refresh_path; 71 ai::Traits _traits; 72 std::set<std::string> _enemies, _bonuses; 73 std::set<int> _skip_objects; 74 int _target_id; 75 v2<float> _target_position; 76 bool _enemy; 77 78 int _pf_slice; 79 int _target_dir; 80 }; 81 } 82 83 #endif 84 85