mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
Point defenses fire at targets within range
This commit is contained in:
@@ -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
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user