#include "OrxoBloxCanon.h" #include "core/CoreIncludes.h" #include "graphics/Model.h" #include "weaponsystem/Weapon.h" #include "weaponsystem/WeaponPack.h" #include "weaponsystem/WeaponSystem.h" #include "weapons/projectiles/BallProjectile.h" #include "weapons/MuzzleFlash.h" namespace orxonox { RegisterClass(OrxoBloxCanon); OrxoBloxCanon::OrxoBloxCanon(Context* context) : HsW01(context) { RegisterObject(OrxoBloxCanon); } OrxoBloxCanon::~OrxoBloxCanon() { } void OrxoBloxCanon::shot() { assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() ); // Create the projectile. Projectile* projectile = new BallProjectile(this->getContext()); Model* model = new Model(projectile->getContext()); model->setMeshSource(mesh_); model->setCastShadows(false); projectile->attach(model); model->setScale(5); //get position and orientation of the ship to know in which direction the projectile needs to fire off Pawn* player = this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn(); projectile->setOrientation(player->getOrientation()); projectile->setPosition(player->getPosition()); //Velocity & position of the projectile must be y = 0 since the game takes place in the x-z plane Vector3 muzzle2D = player->getOrientation()* WorldEntity::FRONT ; muzzle2D.y = 0; projectile->setVelocity(muzzle2D * this->speed_); projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); projectile->setDamage(this->getDamage()); projectile->setShieldDamage(this->getShieldDamage()); projectile->setHealthDamage(this->getHealthDamage()); // Display the muzzle flash. this->HsW01::muzzleflash(); } }