navi homePPSaboutscreenshotsdownloaddevelopmentforum


This is an archived page!
This page is very old and the content is not up to date.
Not everything (if any) which is written here will be in the final game!

A Weapon is an advanced basic class for all the Weapons one can imagine: (Turrets, Rifles, Cannons, etc…)


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. 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.


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
    2. Turrets: Shoot in the direction of the Aim (either automatically or with the help of the Mouse/Joystick…
    3. Orbiters: Cyrcling around the ship, these guns will fire in a special way
  • States: Weapons will cycle through different states as represented here:
  • 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.


    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;

    virtual void activate() {};
    virtual void deactivate() {};
    virtual void charge() {};
    virtual void fire() {};
    virtual void reload() {};
    virtual void destroy() {};


  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 → 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 Projectile
Last modified 3 years ago Last modified on Apr 15, 2017, 3:56:27 PM