= Weapon = [[ArchivePage]] A Weapon is an advanced basic class for all the Weapons one can imagine: (Turrets, Rifles, Cannons, etc...) __Dependencies__: * [wiki:WorldEntity WorldEntity] * [wiki:Projectile Projectile] orxonox will support many types of weapons, and it will split them up into two main elements: 1. __Weapons(/GUNS)__: They are fixed modules coppled in some way with the Ship (static or dynamic) 2. __[wiki:Projectile Projectiles]__: They get emitted from Weapons/guns in the Direction and speed (and other initial values) given them by __[wiki:Weapon Weapon]__ As you can see ''[wiki:Weapon Weapon]'' and ''[wiki:Projectile Projectile]'' will be independant from each other, projectiles only get emitted by guns in a usefull manner. == idea == Each ship may have one or multiple weapons. Activation/Deactivation is handled over the !WeaponManager, that connects a !WeaponSystem to the ship. * '''types''': There are different types of guns: 1. __uni-directionals__: They shoot in a fixed direction 1. __Turrets__: Shoot in the direction of the Aim (either automatically or with the help of the Mouse/Joystick... 1. __Orbiters__: Cyrcling around the ship, these guns will fire in a special way * '''States''': Weapons will cycle through different states as represented here: [[br]] http://www.orxonox.net/additionals/Weapon.png [[br]] * '''Cycles''': As you can see, there are two main cycles: 1. The __Activation-Cycle__, where the Weapon gets round up and uninstalled 2. The __Shoot-Cycle__, where the Weapon fires and reloads. == Definition == {{{ #!cpp public: void requestAction(WeaponAction action); inline bool isActive() const; inline bool isChargeable() const; inline void setCapability(long capabilities); void setProjectileType(ClassID projectile); void prepareProjectiles(unsigned int count); Projectile* getProjectile(); void setEmissionPoint(const Vector& point); inline const Vector& getEmissionPoint() const; inline void setStateDuration(WeaponState state, float duration); float increaseEnergy(float energyToAdd); inline void setMaximumEnergy(float energyMax, float energyLoadedMax); void setActionSound(WeaponAction action, const char* soundFile); Animation3D* getAnimation(WeaponState state, PNode* node = NULL); Animation3D* copyAnimation(WeaponState from, WeaponState to); void tickW(float dt); bool check() const; void debug() const; protected: virtual void activate() {}; virtual void deactivate() {}; virtual void charge() {}; virtual void fire() {}; virtual void reload() {}; virtual void destroy() {}; }}} '''Description:''' 1. ''Public Functions'': * __requestAction__: A request to an action the weapon should take next (shooting reloading and so on) * __setCapability__: The capabilities this weapon has (direction, type of weapon (turret/directional))... * __setProjectileType__: The Type of Projectiles this Weapon should emit: (This automatically gets the !FastFactory for the requested Projectiles). * __getProjectile__: get a Projectile of the Requested type... then you can fire it :) * __setEmissionPoint__: Where the Projectile gets emitted from * __setStateDuration __: How long a Weapon rests in a given state before going to the next one (reloading takes 2 seconds, shooting .5 seconds). * __increaseEnergy__: add more energy to the Weapon * __setActionSound__: The Sound of an executed Action (eg. fire, activate, Reload...) * __getAnimation__: Returns a new Animation for a State. 2. ''Protected Functions'': These are functions you can extend, if you like to declare in some special Weapon stuff. like turning a weapon and so on. == Howto Create a Weapon == 1. Have a look at the Howto Process of -> [wiki:archive/WorldEntity WorldEntity]. 2. Define a Projectile 3. Define some Animations 4. Have a look at source:orxonox.OLD/trunk/src/world_entities/weapons/laser.h#HEAD or source:orxonox.OLD/trunk/src/world_entities/weapons/turret.h#HEAD for examples 5. Maybe define your own [wiki:Projectile Projectile]