fixed ability to fire cruise missiles

This commit is contained in:
devZoGok
2025-05-31 20:14:48 +03:00
parent 72134c1bc4
commit 692c917296
4 changed files with 5 additions and 13 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ namespace battleship{
using namespace std;
using namespace vb01;
CruiseMissile::CruiseMissile(Unit *unit, Vector3 tp, Vector3 pos, Quaternion rot) : Projectile(unit, 0, pos, rot), targetPoint(tp), flightStage(FlightStage::ASCENT){
CruiseMissile::CruiseMissile(Unit *unit, int id, Vector3 tp, Vector3 pos, Quaternion rot) : Projectile(unit, id, pos, rot), targetPoint(tp), flightStage(FlightStage::ASCENT){
Vector3 unitDir = unit->getDirVec();
Vector3 leftDir = unit->getLeftVec();
Vector3 targDir = (Vector3(targetPoint.x, pos.y, targetPoint.z) - pos).norm();
+1 -1
View File
@@ -6,7 +6,7 @@
namespace battleship{
class CruiseMissile : public Projectile{
public:
CruiseMissile(Unit*, vb01::Vector3, vb01::Vector3, vb01::Quaternion);
CruiseMissile(Unit*, int, vb01::Vector3, vb01::Vector3, vb01::Quaternion);
void update();
private:
enum class FlightStage{ASCENT, CRUISE, DESCENT};
+1 -1
View File
@@ -60,7 +60,7 @@ namespace battleship{
case ProjectileClass::SHELL:
return new Shell(unit, id, pos, rot);
case ProjectileClass::CRUISE_MISSILE:
return new CruiseMissile(unit, targetPos, pos, rot);
return new CruiseMissile(unit, id, targetPos, pos, rot);
case ProjectileClass::MISSILE:
return new Missile(unit, id, targetPos, pos, rot);
default:
+2 -10
View File
@@ -566,15 +566,7 @@ namespace battleship{
}
void Unit::launch(Order order){
for(Weapon *weapon : weapons){
Vector3 targPos = Vector3(order.targets[0].pos.x, pos.y, order.targets[0].pos.z);
if(weapon->getProjectileId() == 0 && weapon->getMinRange() < targPos.getDistanceFrom(pos)){
weapon->fire(order);
break;
}
}
getWeaponsByOrder(Order::TYPE::LAUNCH)[0]->fire(order);
removeOrder(0);
}
@@ -796,7 +788,7 @@ namespace battleship{
if(w->getOrderType() == type)
weaps.push_back(w);
return weapons;
return weaps;
}
void Unit::receiveOrder(Order order, bool add) {