mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
using destination pos offsets for cargo ships
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
fx = {
|
||||||
|
}
|
||||||
@@ -392,7 +392,7 @@ units = {
|
|||||||
cost = 500,
|
cost = 500,
|
||||||
size = {x = 11.505, y = 10.3979, z = 17.1902},
|
size = {x = 11.505, y = 10.3979, z = 17.1902},
|
||||||
hitboxOffset = {x = 0, y = 5.46, z = .86},
|
hitboxOffset = {x = 0, y = 5.46, z = .86},
|
||||||
lineOfSight = 25,
|
lineOfSight = 75,
|
||||||
name = 'Tank',
|
name = 'Tank',
|
||||||
basePath = PATH .. vehiclePrefix .. 'Tanks/',
|
basePath = PATH .. vehiclePrefix .. 'Tanks/',
|
||||||
meshPath = 'acsTank.xml',
|
meshPath = 'acsTank.xml',
|
||||||
@@ -450,7 +450,7 @@ units = {
|
|||||||
cost = 500,
|
cost = 500,
|
||||||
size = {x = 13.6, y = 6.79, z = 21.8},
|
size = {x = 13.6, y = 6.79, z = 21.8},
|
||||||
hitboxOffset = {x = 0, y = 3.31, z = 0},
|
hitboxOffset = {x = 0, y = 3.31, z = 0},
|
||||||
lineOfSight = 25,
|
lineOfSight = 75,
|
||||||
name = 'Tank',
|
name = 'Tank',
|
||||||
basePath = PATH .. vehiclePrefix .. 'Tanks/',
|
basePath = PATH .. vehiclePrefix .. 'Tanks/',
|
||||||
meshPath = 'aincTank.xml',
|
meshPath = 'aincTank.xml',
|
||||||
@@ -511,7 +511,7 @@ units = {
|
|||||||
cost = 500,
|
cost = 500,
|
||||||
size = {x = 7.2, y = 10.3, z = 15},
|
size = {x = 7.2, y = 10.3, z = 15},
|
||||||
hitboxOffset = {x = 0, y = 5.27, z = .26},
|
hitboxOffset = {x = 0, y = 5.27, z = .26},
|
||||||
lineOfSight = 25,
|
lineOfSight = 75,
|
||||||
name = 'Tank',
|
name = 'Tank',
|
||||||
basePath = PATH .. vehiclePrefix .. 'Tanks/',
|
basePath = PATH .. vehiclePrefix .. 'Tanks/',
|
||||||
meshPath = 'erTank.xml',
|
meshPath = 'erTank.xml',
|
||||||
@@ -570,7 +570,7 @@ units = {
|
|||||||
cost = 500,
|
cost = 500,
|
||||||
size = {x = 9.99, y = 15.4, z = 14.},
|
size = {x = 9.99, y = 15.4, z = 14.},
|
||||||
hitboxOffset = {x = 0, y = 7.69, z = .71},
|
hitboxOffset = {x = 0, y = 7.69, z = .71},
|
||||||
lineOfSight = 30,
|
lineOfSight = 90,
|
||||||
name = 'Artillery',
|
name = 'Artillery',
|
||||||
basePath = PATH .. vehiclePrefix .. 'Artillery/',
|
basePath = PATH .. vehiclePrefix .. 'Artillery/',
|
||||||
meshPath = 'acsArtillery.xml',
|
meshPath = 'acsArtillery.xml',
|
||||||
@@ -628,7 +628,7 @@ units = {
|
|||||||
cost = 500,
|
cost = 500,
|
||||||
size = {x = 10.4, y = 14, z = 12.9},
|
size = {x = 10.4, y = 14, z = 12.9},
|
||||||
hitboxOffset = {x = 0, y = 7, z = 1.3},
|
hitboxOffset = {x = 0, y = 7, z = 1.3},
|
||||||
lineOfSight = 30,
|
lineOfSight = 90,
|
||||||
name = 'Artillery',
|
name = 'Artillery',
|
||||||
basePath = PATH .. vehiclePrefix .. 'Artillery/',
|
basePath = PATH .. vehiclePrefix .. 'Artillery/',
|
||||||
meshPath = 'aincArtillery.xml',
|
meshPath = 'aincArtillery.xml',
|
||||||
@@ -768,7 +768,7 @@ units = {
|
|||||||
cost = 500,
|
cost = 500,
|
||||||
size = {x = 4.95, y = 6.59, z = 4.11},
|
size = {x = 4.95, y = 6.59, z = 4.11},
|
||||||
hitboxOffset = {x = .178, y = 3.27, z = 0},
|
hitboxOffset = {x = .178, y = 3.27, z = 0},
|
||||||
lineOfSight = 150,
|
lineOfSight = 1500,
|
||||||
name = 'Engineer',
|
name = 'Engineer',
|
||||||
basePath = PATH .. vehiclePrefix .. 'Engineers/',
|
basePath = PATH .. vehiclePrefix .. 'Engineers/',
|
||||||
albedoPath = 'engineer.jpg',
|
albedoPath = 'engineer.jpg',
|
||||||
@@ -1221,8 +1221,8 @@ units = {
|
|||||||
meshPath = 'acsCargoShip.xml',
|
meshPath = 'acsCargoShip.xml',
|
||||||
albedoPath = 'cargoship.jpg',
|
albedoPath = 'cargoship.jpg',
|
||||||
selectionSfx = PATH .. 'Sounds/Units/Cargoships/selection.ogg',
|
selectionSfx = PATH .. 'Sounds/Units/Cargoships/selection.ogg',
|
||||||
speed = .3,
|
speed = .45,
|
||||||
destinationOffset = .1,
|
destinationOffset = 1.25,
|
||||||
anglePrecision = .1,
|
anglePrecision = .1,
|
||||||
maxTurnAngle = .1,
|
maxTurnAngle = .1,
|
||||||
garrisonCategory = 3,
|
garrisonCategory = 3,
|
||||||
@@ -1257,7 +1257,7 @@ units = {
|
|||||||
albedoPath = 'cargoship.jpg',
|
albedoPath = 'cargoship.jpg',
|
||||||
selectionSfx = PATH .. 'Sounds/Units/Cargoships/selection.ogg',
|
selectionSfx = PATH .. 'Sounds/Units/Cargoships/selection.ogg',
|
||||||
speed = .3,
|
speed = .3,
|
||||||
destinationOffset = .1,
|
destinationOffset = 1.25,
|
||||||
anglePrecision = .1,
|
anglePrecision = .1,
|
||||||
maxTurnAngle = .1,
|
maxTurnAngle = .1,
|
||||||
garrisonCategory = 3,
|
garrisonCategory = 3,
|
||||||
@@ -1291,8 +1291,8 @@ units = {
|
|||||||
meshPath = 'erCargoShip.xml',
|
meshPath = 'erCargoShip.xml',
|
||||||
albedoPath = 'cargoship.jpg',
|
albedoPath = 'cargoship.jpg',
|
||||||
selectionSfx = PATH .. 'Sounds/Units/Cargoships/selection.ogg',
|
selectionSfx = PATH .. 'Sounds/Units/Cargoships/selection.ogg',
|
||||||
speed = .3,
|
speed = .45,
|
||||||
destinationOffset = .1,
|
destinationOffset = 1.25,
|
||||||
anglePrecision = .1,
|
anglePrecision = .1,
|
||||||
maxTurnAngle = .1,
|
maxTurnAngle = .1,
|
||||||
garrisonCategory = 3,
|
garrisonCategory = 3,
|
||||||
|
|||||||
+3
-12
@@ -112,16 +112,7 @@ namespace battleship{
|
|||||||
nearestExtractor = (Extractor*)getClosestUnit(extractors);
|
nearestExtractor = (Extractor*)getClosestUnit(extractors);
|
||||||
nearestRefinery = getClosestUnit(refineries);
|
nearestRefinery = getClosestUnit(refineries);
|
||||||
|
|
||||||
auto closeEnough = [](GameObject *obj, Vector3 pos){
|
if(nearestExtractor && closeEnough(nearestExtractor, pos, destinationOffset)){
|
||||||
Vector3 neVec = pos - obj->getPos();
|
|
||||||
float angle = obj->getDirVec().getAngleBetween(neVec.norm());
|
|
||||||
|
|
||||||
if(angle > PI / 2) angle = PI - angle;
|
|
||||||
|
|
||||||
return cos(angle) * neVec.getLength() < .5 * obj->getLength();
|
|
||||||
};
|
|
||||||
|
|
||||||
if(nearestExtractor && closeEnough(nearestExtractor, pos)){
|
|
||||||
ResourceDeposit *deposit = nearestExtractor->getDeposit();
|
ResourceDeposit *deposit = nearestExtractor->getDeposit();
|
||||||
|
|
||||||
if(canLoad() && deposit->getAmmount() > 0){
|
if(canLoad() && deposit->getAmmount() > 0){
|
||||||
@@ -144,7 +135,7 @@ namespace battleship{
|
|||||||
else removeOrder(0);
|
else removeOrder(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nearestRefinery && closeEnough(nearestRefinery, pos)){
|
if(nearestRefinery && closeEnough(nearestRefinery, pos, destinationOffset)){
|
||||||
if(canUnload((int)ResourceType::REFINEDS)){
|
if(canUnload((int)ResourceType::REFINEDS)){
|
||||||
cargo[(int)ResourceType::REFINEDS] -= loadSpeed;
|
cargo[(int)ResourceType::REFINEDS] -= loadSpeed;
|
||||||
player->updateResource(ResourceType::REFINEDS, loadSpeed, true);
|
player->updateResource(ResourceType::REFINEDS, loadSpeed, true);
|
||||||
@@ -158,7 +149,7 @@ namespace battleship{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ResourceRover::handleResources(Order order){
|
void ResourceRover::handleResources(Order order){
|
||||||
if(!pathPoints.empty()) navigate(.01);
|
if(!pathPoints.empty()) navigate(destinationOffset);
|
||||||
else if(order.type == Order::TYPE::SUPPLY)
|
else if(order.type == Order::TYPE::SUPPLY)
|
||||||
collectRefineds(order);
|
collectRefineds(order);
|
||||||
else
|
else
|
||||||
|
|||||||
+19
-8
@@ -57,10 +57,8 @@ namespace battleship{
|
|||||||
|
|
||||||
removeAllPathpoints();
|
removeAllPathpoints();
|
||||||
|
|
||||||
if(!orders[0].targets[0].unit)
|
Vector3 targPos = (orders[0].targets[0].unit ? orders[0].targets[0].unit->getPos() : orders[0].targets[0].pos);
|
||||||
preparePathpoints(orders[0], orders[0].targets[0].pos);
|
preparePathpoints(orders[0], targPos);
|
||||||
else if(orders[0].type == Order::TYPE::BUILD)
|
|
||||||
preparePathpoints(orders[0], orders[0].targets[0].unit->getPos());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Vehicle::validateGarrisonOrder(Order order){
|
bool Vehicle::validateGarrisonOrder(Order order){
|
||||||
@@ -105,6 +103,7 @@ namespace battleship{
|
|||||||
maxTurnAngle = unitTable["maxTurnAngle"]; maxTurnAngle += game->calcAbilFromTech(Ability::Type::MAX_TURN_ANGLE, currTechs, (int)GameObject::type, id);
|
maxTurnAngle = unitTable["maxTurnAngle"]; maxTurnAngle += game->calcAbilFromTech(Ability::Type::MAX_TURN_ANGLE, currTechs, (int)GameObject::type, id);
|
||||||
speed = unitTable["speed"]; speed += game->calcAbilFromTech(Ability::Type::SPEED, currTechs, (int)GameObject::type, id);
|
speed = unitTable["speed"]; speed += game->calcAbilFromTech(Ability::Type::SPEED, currTechs, (int)GameObject::type, id);
|
||||||
anglePrecision = unitTable["anglePrecision"];
|
anglePrecision = unitTable["anglePrecision"];
|
||||||
|
destinationOffset = unitTable["destinationOffset"];
|
||||||
garrisonCategory = unitTable["garrisonCategory"];
|
garrisonCategory = unitTable["garrisonCategory"];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,8 +343,9 @@ namespace battleship{
|
|||||||
Unit *blockingUnit = cells[dest].blockedBy;
|
Unit *blockingUnit = cells[dest].blockedBy;
|
||||||
bool garrisonOrder = (order.type == Order::TYPE::GARRISON);
|
bool garrisonOrder = (order.type == Order::TYPE::GARRISON);
|
||||||
bool buildOrder = (order.type == Order::TYPE::BUILD);
|
bool buildOrder = (order.type == Order::TYPE::BUILD);
|
||||||
|
bool resourceOrder = (order.type == Order::TYPE::LOAD || order.type == Order::TYPE::UNLOAD || order.type == Order::TYPE::SUPPLY);
|
||||||
|
|
||||||
if(blockingUnit && blockingUnit != this && !buildOrder && (!garrisonOrder || (garrisonOrder && blockingUnit != (Unit*)targObj))){
|
if(blockingUnit && blockingUnit != this && !resourceOrder && !buildOrder && (!garrisonOrder || (garrisonOrder && blockingUnit != (Unit*)targObj))){
|
||||||
vector<int> surrCellIds = map->getSurroundingCells(cells[dest].pos, 1);
|
vector<int> surrCellIds = map->getSurroundingCells(cells[dest].pos, 1);
|
||||||
int altDest = -1;
|
int altDest = -1;
|
||||||
|
|
||||||
@@ -496,8 +496,10 @@ namespace battleship{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Vehicle::build(Order order){
|
void Vehicle::build(Order order){
|
||||||
if(pathPoints.empty()){
|
Structure *structure = (Structure*)order.targets[0].unit;
|
||||||
Structure *structure = (Structure*)order.targets[0].unit;
|
float offset = .5 * Map::getSingleton()->getCellSize().x;
|
||||||
|
|
||||||
|
if(pathPoints.empty() && closeEnough(structure, pos, offset)){
|
||||||
sol::table targTable = generateView()["units"][structure->getId()];
|
sol::table targTable = generateView()["units"][structure->getId()];
|
||||||
int costRate = (int)targTable["cost"] / 100, buildRate = (int)targTable["buildTime"] / 100;
|
int costRate = (int)targTable["cost"] / 100, buildRate = (int)targTable["buildTime"] / 100;
|
||||||
|
|
||||||
@@ -511,11 +513,20 @@ namespace battleship{
|
|||||||
player->incStructuresBuilt();
|
player->incStructuresBuilt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else navigate(0.5 * Map::getSingleton()->getCellSize().x);
|
else navigate(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vehicle::select(){
|
void Vehicle::select(){
|
||||||
if(!garrisonable)
|
if(!garrisonable)
|
||||||
Unit::select();
|
Unit::select();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Vehicle::closeEnough(GameObject *obj, Vector3 pos, float eps){
|
||||||
|
Vector3 neVec = pos - obj->getPos();
|
||||||
|
float angle = obj->getDirVec().getAngleBetween(neVec.norm());
|
||||||
|
|
||||||
|
if(angle > PI / 2) angle = PI - angle;
|
||||||
|
|
||||||
|
return cos(angle) * neVec.getLength() < .5 * obj->getLength() + eps;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ namespace battleship{
|
|||||||
protected:
|
protected:
|
||||||
std::vector<vb01::Vector3> pathPoints;
|
std::vector<vb01::Vector3> pathPoints;
|
||||||
bool pursuingTarget = false;
|
bool pursuingTarget = false;
|
||||||
|
float destinationOffset;
|
||||||
|
|
||||||
void arrivedAtPathpoint(bool, float = 0);
|
void arrivedAtPathpoint(bool, float = 0);
|
||||||
void moveByTerrainQuads(vb01::Vector3, float);
|
void moveByTerrainQuads(vb01::Vector3, float);
|
||||||
@@ -53,6 +54,7 @@ namespace battleship{
|
|||||||
void garrison(Order);
|
void garrison(Order);
|
||||||
void patrol(Order);
|
void patrol(Order);
|
||||||
virtual void initProperties();
|
virtual void initProperties();
|
||||||
|
bool closeEnough(GameObject *obj, vb01::Vector3 pos, float = 0);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user