Version 1 (modified by landauf, 17 years ago) (diff) |
---|
Weapon
A Weapon is an advanced basic class for all the Weapons one can imagine: (Turrets, Rifles, Cannons, etc…)
Dependencies:
orxonox will support many types of weapons, and it will split them up into two main elements:
- Weapons(/GUNS): They are fixed modules coppled in some way with the Ship (static or dynamic)
- Projectiles: They get emitted from Weapons/guns in the Direction and speed (and other initial values) given them by Weapon
As you can see Weapon and 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:
- uni-directionals: They shoot in a fixed direction
- Turrets: Shoot in the direction of the Aim (either automatically or with the help of the Mouse/Joystick…
- Orbiters: Cyrcling around the ship, these guns will fire in a special way
- States: Weapons will cycle through different states as represented here:
http://www.orxonox.net/additionals/Weapon.png
- Cycles: As you can see, there are two main cycles:
- The Activation-Cycle, where the Weapon gets round up and uninstalled
- The Shoot-Cycle, where the Weapon fires and reloads.
Definition
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:
- 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.
- 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
- Have a look at the Howto Process of → WorldEntity.
- Define a Projectile
- Define some Animations
- Have a look at source:/trunk/src/world_entities/weapons/laser.h#HEAD or source:/trunk/src/world_entities/weapons/turret.h#HEAD for examples
- Maybe define your own Projectile