Point defenses fire at targets within range

This commit is contained in:
devZoGok
2023-11-26 10:54:06 +02:00
parent 760b986b18
commit ed932b7ac9
3 changed files with 11 additions and 6 deletions
@@ -46,9 +46,9 @@ units = {
health = {500, 600, 200, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500},
cost = {500, 600, 200, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500},
range = {15, 20, 45, 15, 14, 14, 13, 13, 12, 12, 15, 0, 25},
damage = {15, 20, 45, 15, 14, 14, 13, 13, 12, 12, 15, 100, 100},
rateOfFire = {50, 60, 80, 100, 100, 100, 100, 100, 0, 0, 0, 0, 100},
range = {15, 20, 45, 15, 14, 14, 13, 13, 12, 12, 15, 0, 40},
damage = {15, 120, 250, 15, 14, 14, 13, 13, 12, 12, 15, 100, 100},
rateOfFire = {50, 2000, 5000, 100, 100, 100, 100, 100, 0, 0, 0, 0, 100},
garrisonCapacity = {0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0},
unitCornerPoints = {
+8 -2
View File
@@ -9,11 +9,17 @@ namespace battleship{
void PointDefense::attack(Order order){
Unit *targUnit = order.targets[0].unit;
Vector3 targDir = ((targUnit ? targUnit->getPos() : order.targets[0].pos) - pos).norm();
Vector3 targDir = (targUnit ? targUnit->getPos() : order.targets[0].pos) - pos;
if(targDir.getLength() > range){
removeOrder(0);
return;
}
float angleToTarg = targDir.getAngleBetween(turretDir);
if(angleToTarg > .05)
rotateTurret(calculateRotation(targDir, angleToTarg, .1));
rotateTurret(calculateRotation(targDir.norm(), angleToTarg, .1));
else if(canFire())
fire();
-1
View File
@@ -24,7 +24,6 @@ using namespace gameBase;
using namespace std;
namespace battleship{
//TODO remove the player member field
Unit::Unit(Player *player, int id, Vector3 pos, Quaternion rot) : GameObject(GameObject::Type::UNIT, id, player, pos, rot){
this->id = id;
this->player = player;