/* * 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: * Fabian 'x3n' Landau * Co-authors: * ... * */ #ifndef _CommonController_H__ #define _CommonController_H__ #include "controllers/Controller.h" #include "worldentities/ControllableEntity.h" #include "worldentities/pawns/Pawn.h" #include "util/Math.h" #include "tools/Timer.h" #include "tools/interfaces/Tickable.h" #include #include #include "worldentities/Actionpoint.h" #include "worldentities/pawns/SpaceShip.h" namespace orxonox { namespace FormationMode { enum Value { FINGER4, DIAMOND, WALL }; } namespace Rank { enum Value { NONE, SECTIONLEADER, DIVISIONLEADER, WINGMAN }; } namespace Action { enum Value { NONE, FLY, FIGHT, PROTECT, FIGHTALL, ATTACK }; } struct Point { Action::Value action; std::string name; Vector3 position; bool inLoop; } ; class _OrxonoxExport CommonController : public Controller, public Tickable { public: static const float hardcoded_projectile_speed = 750; static const float ACTION_INTERVAL = 1.0f; CommonController(Context* context); virtual ~CommonController(); virtual void tick(float dt); //----[XML methods]---- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); void setFormationModeXML(std::string val); std::string getFormationModeXML(); void setFormationMode(FormationMode::Value val); FormationMode::Value getFormationMode() const; void setRank(Rank::Value val); Rank::Value getRank() const; void addActionpoint(WorldEntity* waypoint); WorldEntity* getActionpoint(unsigned int index) const; //----[/XML methods]---- //----[Interaction with other Controllers]---- virtual bool setWingman(CommonController* wingman); virtual bool hasWingman(); bool hasTarget(); ControllableEntity* getTarget(); Action::Value getAction (); std::string getActionName(); void setAction (Action::Value action); void setAction (Action::Value action, ControllableEntity* target); void setAction (Action::Value action, const Vector3& target); void setAction (Action::Value action, const Vector3& target, const Quaternion& orient ); //----[/Interaction with other Controllers]---- //----[Helper methods]---- float randomInRange(float a, float b); static float distance(ControllableEntity* entity1, ControllableEntity* entity2); static bool sameTeam (ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gt); static bool isLooking( ControllableEntity* entityThatLooks, ControllableEntity* entityBeingLookedAt, float angle ) ; static std::string getName( Pawn* entity ) ; float squaredDistanceToTarget() const; bool isLookingAtTarget(float angle); //----[/Helper methods]---- virtual void stayNearProtect(); virtual void action(); // protect_; //----[/protect information]---- //----[who-to-kill information]---- WeakPtr target_; bool bHasPositionOfTarget_; Vector3 positionOfTarget_; bool bHasOrientationOfTarget_; Quaternion orientationOfTarget_; //----[/who-to-kill information]---- //----[Actionpoint information]---- std::vector > actionpoints_; float squaredaccuracy_; std::vector parsedActionpoints_; std::vector loopActionpoints_; //----[/Actionpoint information]---- //----[Actionpoint methods]---- void executeActionpoint(); void nextActionpoint(); void fillLoop(); void fillLoopReversed(); void moveBackToTop(); //----[Actionpoint methods]---- //----["Private" variables]---- FormationMode::Value formationMode_; Rank::Value rank_; std::string protectName_; std::string targetName_; Action::Value action_; int attackRange_; bool bLookAtTarget_; bool bShooting_; int maneuverCounter_; int tolerance_; bool bFirstTick_; bool bInLoop_; bool bLoop_; //----[/"Private" variables]---- virtual void takeActionpoints (std::vector vector, std::vector loop, bool b); }; } #endif /* _CommonController_H__ */