mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
freezers can create ice sheets
This commit is contained in:
@@ -275,9 +275,6 @@ units = {
|
||||
deathFx = {explosionVfx, explosionSfx},
|
||||
},
|
||||
{
|
||||
weapons = {
|
||||
{orderType = OrderType.ATTACK, rateOfFire = 2000, fireSfx = PATH .. 'Sounds/Units/WarMechs/fire.ogg', damage = 20, maxRange = 8},
|
||||
},
|
||||
buildableUnits = {
|
||||
{id = UnitId.LAND_FACTORY, buildable = true, trigger = 76},
|
||||
{id = UnitId.NAVAL_FACTORY, buildable = true, trigger = 78},
|
||||
@@ -848,7 +845,7 @@ units = {
|
||||
waterHitFx = {},
|
||||
}
|
||||
},
|
||||
--buildableUnits = {{id = UnitId.ICE_SHEET, buildable = true, trigger = 83}},
|
||||
buildableUnits = {{id = UnitId.ICE_SHEET, buildable = true, trigger = 83}},
|
||||
unitClass = UnitClass.FREEZER,
|
||||
unitType = UnitType.SEA_LEVEL,
|
||||
isVehicle = true,
|
||||
|
||||
@@ -82,12 +82,17 @@ function generateGui(unitId)
|
||||
mainUnit.unitClass == UnitClass.FORT
|
||||
)
|
||||
|
||||
isEng = (
|
||||
mainUnit.unitClass == UnitClass.ENGINEER or
|
||||
mainUnit.unitClass == UnitClass.FREEZER
|
||||
)
|
||||
|
||||
buttonData = {
|
||||
trigger = buildUnit.trigger,
|
||||
name = units[buildUnit.id + 1].name,
|
||||
buttonType = (mainUnit.isVehicle and ButtonType.BUILD or ButtonType.TRAIN),
|
||||
factoryId = (isFactory and unitId or nil),
|
||||
engineerId = (mainUnit.unitClass == UnitClass.ENGINEER and unitId or nil),
|
||||
engineerId = (isEng and unitId or nil),
|
||||
slotId = (ButtonType.BUILD and i - 1 or nil)
|
||||
}
|
||||
gui[#gui + 1] = generateButton(#gui, buttonData)
|
||||
|
||||
+1
-1
@@ -703,7 +703,7 @@ namespace battleship{
|
||||
else if(cursorState == CursorState::HACK){
|
||||
if(orderPossible) issueOrder(Order::TYPE::HACK, vector<Order::Target>{Order::Target((Unit*)gameObjHoveredOn)}, shiftPressed);
|
||||
}
|
||||
else if(selectedUnits[0]->getUnitClass() == UnitClass::ENGINEER && ufCtr->isPlacingOnSurface()){
|
||||
else if((selectedUnits[0]->getUnitClass() == UnitClass::ENGINEER || selectedUnits[0]->getUnitClass() == UnitClass::FREEZER) && ufCtr->isPlacingOnSurface()){
|
||||
castRayToTerrain();
|
||||
GameObjectFrame gmObjFr = ufCtr->getGameObjectFrame(0);
|
||||
|
||||
|
||||
+1
-29
@@ -50,40 +50,12 @@ namespace battleship{
|
||||
hackStatus = 0;
|
||||
}
|
||||
|
||||
void Engineer::build(Order order){
|
||||
if(pathPoints.empty()){
|
||||
if(!order.targets[0].unit)
|
||||
player->addUnit(order.targets[0].unit);
|
||||
else {
|
||||
Structure *structure = (Structure*)order.targets[0].unit;
|
||||
sol::table targTable = generateView()["units"][order.targets[0].unit->getId()];
|
||||
int costRate = (int)targTable["cost"] / 100, buildRate = (int)targTable["buildTime"] / 100;
|
||||
|
||||
if(structure->getBuildStatus() < 100 && player->getResource(ResourceType::REFINEDS) >= costRate && getTime() - lastIncrementTime > buildRate){
|
||||
structure->incrementBuildStatus();
|
||||
player->updateResource(ResourceType::REFINEDS, -costRate, true);
|
||||
lastIncrementTime = getTime();
|
||||
}
|
||||
else if(structure->getBuildStatus() >= 100){
|
||||
removeOrder(0);
|
||||
player->incStructuresBuilt();
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
navigate(0.5 * Map::getSingleton()->getCellSize().x);
|
||||
|
||||
if(type == UnitType::LAND)
|
||||
alignToSurface();
|
||||
}
|
||||
}
|
||||
|
||||
//TODO change unit colors after faction change
|
||||
void Engineer::hack(Order order){
|
||||
Unit *targUnit = order.targets[0].unit;
|
||||
bool withinRange = (targUnit->getPos().getDistanceFrom(pos) < hackRange);
|
||||
int hackRate = int(generateView()["units"][id + 1]["hackTime"]) / 100;
|
||||
bool canHack = (getTime() - lastIncrementTime > hackRate);
|
||||
bool canHack = (getTime() - lastHackTime > hackRate);
|
||||
|
||||
if(withinRange && canHack){
|
||||
hackStatus++;
|
||||
|
||||
+1
-2
@@ -20,10 +20,9 @@ namespace battleship{
|
||||
private:
|
||||
int hackStatus = 0;
|
||||
float hackRange;
|
||||
vb01::s64 lastIncrementTime = 0;
|
||||
vb01::s64 lastHackTime = 0;
|
||||
vb01::Node *hackStatusBackground = nullptr, *hackStatusForeground = nullptr;
|
||||
|
||||
void build(Order);
|
||||
void hack(Order);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@ namespace battleship{
|
||||
void IceSheet::update(){
|
||||
Structure::update();
|
||||
|
||||
if(buildStatus < 100)
|
||||
model->getChild(0)->setScale(.01 * buildStatus * Vector3::VEC_IJK);
|
||||
|
||||
for(Player *pl : Game::getSingleton()->getPlayers(true)){
|
||||
vector<Unit*> icebreakers = pl->getUnitsByClass(UnitClass::ICEBREAKER);
|
||||
|
||||
|
||||
+1
-1
@@ -17,9 +17,9 @@ namespace battleship{
|
||||
inline int getBuildStatus(){return buildStatus;}
|
||||
inline void incrementBuildStatus(){buildStatus++;}
|
||||
private:
|
||||
int buildStatus = 0;
|
||||
protected:
|
||||
vb01::Node *buildStatusBackground = nullptr, *buildStatusForeground = nullptr;
|
||||
int buildStatus = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -451,7 +451,7 @@ namespace battleship{
|
||||
case Order::TYPE::ATTACK:
|
||||
return !getWeaponsByOrder(Order::TYPE::ATTACK).empty();
|
||||
case Order::TYPE::BUILD:
|
||||
return unitClass == UnitClass::ENGINEER;
|
||||
return (unitClass == UnitClass::ENGINEER || unitClass == UnitClass::FREEZER);
|
||||
case Order::TYPE::PATROL:
|
||||
case Order::TYPE::MOVE:
|
||||
return vehicle;
|
||||
|
||||
+29
-1
@@ -7,9 +7,10 @@
|
||||
#include <model.h>
|
||||
#include <quaternion.h>
|
||||
|
||||
#include "pathfinder.h"
|
||||
#include "structure.h"
|
||||
#include "vehicle.h"
|
||||
#include "weapon.h"
|
||||
#include "pathfinder.h"
|
||||
#include "player.h"
|
||||
#include "game.h"
|
||||
#include "map.h"
|
||||
@@ -355,6 +356,33 @@ namespace battleship{
|
||||
}
|
||||
}
|
||||
|
||||
void Vehicle::build(Order order){
|
||||
if(pathPoints.empty()){
|
||||
if(!order.targets[0].unit)
|
||||
player->addUnit(order.targets[0].unit);
|
||||
else {
|
||||
Structure *structure = (Structure*)order.targets[0].unit;
|
||||
sol::table targTable = generateView()["units"][structure->getId()];
|
||||
int costRate = (int)targTable["cost"] / 100, buildRate = (int)targTable["buildTime"] / 100;
|
||||
|
||||
if(structure->getBuildStatus() < 100 && player->getResource(ResourceType::REFINEDS) >= costRate && getTime() - lastBuildTime > buildRate){
|
||||
structure->incrementBuildStatus();
|
||||
player->updateResource(ResourceType::REFINEDS, -costRate, true);
|
||||
lastBuildTime = getTime();
|
||||
}
|
||||
else if(structure->getBuildStatus() >= 100){
|
||||
removeOrder(0);
|
||||
player->incStructuresBuilt();
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
navigate(0.5 * Map::getSingleton()->getCellSize().x);
|
||||
|
||||
if(type == UnitType::LAND)
|
||||
alignToSurface();
|
||||
}
|
||||
}
|
||||
|
||||
void Vehicle::select(){
|
||||
if(!garrisonable)
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace battleship{
|
||||
float speed, maxTurnAngle, anglePrecision;
|
||||
vb01::Material *debugMat = nullptr;
|
||||
std::vector<vb01::Node*> debugPathPoints;
|
||||
vb01::s64 lastBuildTime = 0;
|
||||
|
||||
inline int getNextPatrolPointId(int numPoints) {return patrolPointId == numPoints - 1 ? 0 : patrolPointId + 1;}
|
||||
bool validateGarrisonOrder(Order);
|
||||
@@ -34,6 +35,7 @@ namespace battleship{
|
||||
void addPathpoint(vb01::Vector3);
|
||||
void removePathpoint(int = 0);
|
||||
void removeAllPathpoints();
|
||||
void build(Order);
|
||||
void select();
|
||||
void reinit();
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user