/* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Author: * Gani Aliguzhinov * Co-authors: * ... * */ #ifndef _ActionpointController_H__ #define _ActionpointController_H__ #include "controllers/FightingController.h" #include "tools/Timer.h" #include "tools/interfaces/Tickable.h" #include "../modules/pickup/PickupSpawner.h" #include #include namespace orxonox { /** @brief ActionpointController is a state machine with states: 1) NONE 2) FLY: fly towards a point 3) FIGHT: fight enemies that are in attackRange_ (see FightingController) 4) PROTECT: follow this->protect_ 5) FIGHTALL: fight all enemies on the map 6) ATTACK: fight a specific spaceship This controller always executes an action that is in the back of the vector being used. After current this->action_ is completed, next action becomes the top action (one that will be returned by someVector.back()), and current action either will be removed (if not looping), or moved to the top (if looping). Every second action(), which is once in two seconds, this searches the area for enemies that are in attack range, if finds anyone, pushes Action::FIGHT to the stack. That makes spaceship fight enemies inside of a sphere, and when all enemies in range are dead, Action::FIGHT is removed from the stack, and spaceship resumes doing whatever action was being executed before. In XML one has to attack Actionpoints in order to achieve any complex behaviour, but in Controller all actionpoints are effectively being stored in an array of type Point::Value. @note ActionpointController will not work, if there is no MasterController in the level! All the demos are in a file called AITest.oxw. In the menu look for New AI Testing Level. */ enum class Action { NONE, FLY, FIGHT, PROTECT, FIGHTALL, ATTACK }; struct Point { Action action; std::string name; Vector3 position; bool inLoop; }; class _OrxonoxExport ActionpointController : public FightingController, public Tickable { public: ActionpointController(Context* context); virtual ~ActionpointController(); virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; /** @brief tick is called every tick by Game (?). In tick ship flies and fires. */ virtual void tick(float dt) override; /** @brief XML method, example XML usage: