mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
technologies in posession improve unit abilities
This commit is contained in:
@@ -1,5 +1,19 @@
|
|||||||
AbilityType = {SPEED = 0}
|
AbilityType = {
|
||||||
|
SPEED = 0,
|
||||||
ablilities = {
|
HEALTH = 1,
|
||||||
{type = AbilityType.SPEED, ammount = .2, units = {UnitClass.WAR_MECH}}
|
LINE_OF_SIGHT = 1,
|
||||||
|
MAX_TURN_ANGLE = 2,
|
||||||
|
DIRECT_HIT_DAMAGE = 3,
|
||||||
|
EXPLOSION_RADIUS = 4,
|
||||||
|
EXPLOSION_DAMAGE = 5,
|
||||||
|
CAPACITY = 6,
|
||||||
|
LOAD_RATE = 7,
|
||||||
|
LOAD_SPEED = 8,
|
||||||
|
DRAW_RATE = 9,
|
||||||
|
DRAW_SPEED = 10,
|
||||||
|
HACK_RANGE = 11
|
||||||
|
}
|
||||||
|
|
||||||
|
abilities = {
|
||||||
|
{type = AbilityType.SPEED, gameObjType = 0, ammount = .4, gameObjIds = {UnitId.WAR_MECH}}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ technologies = {
|
|||||||
description = '',
|
description = '',
|
||||||
parents = {},
|
parents = {},
|
||||||
children = {},
|
children = {},
|
||||||
abilities = {},
|
abilities = {0},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id = TechnologyId.EFT,
|
id = TechnologyId.EFT,
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
#ifndef ABILITY_H
|
||||||
|
#define ABILITY_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace battleship{
|
||||||
|
struct Ability{
|
||||||
|
enum class Type{
|
||||||
|
SPEED,
|
||||||
|
HEALTH,
|
||||||
|
LINE_OF_SIGHT,
|
||||||
|
MAX_TURN_ANGLE,
|
||||||
|
DIRECT_HIT_DAMAGE,
|
||||||
|
EXPLOSION_RADIUS,
|
||||||
|
EXPLOSION_DAMAGE,
|
||||||
|
CAPACITY,
|
||||||
|
LOAD_RATE,
|
||||||
|
LOAD_SPEED,
|
||||||
|
DRAW_RATE,
|
||||||
|
DRAW_SPEED,
|
||||||
|
HACK_RANGE
|
||||||
|
};
|
||||||
|
|
||||||
|
Type type;
|
||||||
|
float ammount;
|
||||||
|
int gameObjType;
|
||||||
|
std::vector<int> gameObjIds;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -52,6 +52,7 @@ namespace battleship{
|
|||||||
"Scripts/aiAgent.lua",
|
"Scripts/aiAgent.lua",
|
||||||
"Scripts/Core/player.lua",
|
"Scripts/Core/player.lua",
|
||||||
"Scripts/Technologies/technologyData.lua",
|
"Scripts/Technologies/technologyData.lua",
|
||||||
|
"Scripts/Abilities/abilityData.lua",
|
||||||
};
|
};
|
||||||
|
|
||||||
const static Bind staticBinds[numAppStates][maxStaticBinds]{
|
const static Bind staticBinds[numAppStates][maxStaticBinds]{
|
||||||
|
|||||||
+3
-1
@@ -16,7 +16,9 @@ namespace battleship{
|
|||||||
using namespace gameBase;
|
using namespace gameBase;
|
||||||
|
|
||||||
Engineer::Engineer(Player *player, int id, Vector3 pos, Quaternion rot, Unit::State state) : Vehicle(player, id, pos, rot, state){
|
Engineer::Engineer(Player *player, int id, Vector3 pos, Quaternion rot, Unit::State state) : Vehicle(player, id, pos, rot, state){
|
||||||
hackRange = generateView()["units"][id + 1]["hackRange"];
|
Game *game = Game::getSingleton();
|
||||||
|
vector<int> currTechs = player->getTechnologies();
|
||||||
|
hackRange = generateView()["units"][id + 1]["hackRange"]; hackRange += game->calcAbilFromTech(Ability::Type::HACK_RANGE, currTechs, (int)GameObject::type, id);
|
||||||
|
|
||||||
Vector2 size = Vector2(lenHpBar, 10);
|
Vector2 size = Vector2(lenHpBar, 10);
|
||||||
hackStatusBackground = Unit::createBar(Vector2::VEC_ZERO, size, Vector4(0, 0, 0, 1));
|
hackStatusBackground = Unit::createBar(Vector2::VEC_ZERO, size, Vector4(0, 0, 0, 1));
|
||||||
|
|||||||
+10
-4
@@ -27,10 +27,6 @@ namespace battleship{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sol::table unitTable = generateView()["units"][id + 1];
|
|
||||||
drawRate = unitTable["drawRate"];
|
|
||||||
drawSpeed = unitTable["drawSpeed"];
|
|
||||||
|
|
||||||
Vector2 size = Vector2(lenHpBar, 10);
|
Vector2 size = Vector2(lenHpBar, 10);
|
||||||
ammountBackground = Unit::createBar(Vector2::VEC_ZERO, size, Vector4(0, 0, 0, 1));
|
ammountBackground = Unit::createBar(Vector2::VEC_ZERO, size, Vector4(0, 0, 0, 1));
|
||||||
ammountForeground = Unit::createBar(Vector2::VEC_ZERO, size, Vector4(0, 0, 1, 1));
|
ammountForeground = Unit::createBar(Vector2::VEC_ZERO, size, Vector4(0, 0, 1, 1));
|
||||||
@@ -41,6 +37,16 @@ namespace battleship{
|
|||||||
removeBar(ammountBackground);
|
removeBar(ammountBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Extractor::initProperties(){
|
||||||
|
Structure::initProperties();
|
||||||
|
Game *game = Game::getSingleton();
|
||||||
|
vector<int> currTechs = player->getTechnologies();
|
||||||
|
|
||||||
|
sol::table unitTable = generateView()["units"][id + 1];
|
||||||
|
drawRate = unitTable["drawRate"]; drawRate += game->calcAbilFromTech(Ability::Type::DRAW_RATE, currTechs, (int)GameObject::type, id);
|
||||||
|
drawSpeed = unitTable["drawSpeed"]; drawSpeed += game->calcAbilFromTech(Ability::Type::DRAW_SPEED, currTechs, (int)GameObject::type, id);
|
||||||
|
}
|
||||||
|
|
||||||
void Extractor::update(){
|
void Extractor::update(){
|
||||||
Structure::update();
|
Structure::update();
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ namespace battleship{
|
|||||||
bool canDraw(){return vb01::getTime() - lastDrawTime > drawRate;}
|
bool canDraw(){return vb01::getTime() - lastDrawTime > drawRate;}
|
||||||
inline ResourceDeposit* getDeposit(){return deposit;}
|
inline ResourceDeposit* getDeposit(){return deposit;}
|
||||||
private:
|
private:
|
||||||
|
void initProperties();
|
||||||
|
|
||||||
int drawSpeed, drawRate;
|
int drawSpeed, drawRate;
|
||||||
vb01::s64 lastDrawTime = 0;
|
vb01::s64 lastDrawTime = 0;
|
||||||
vb01::Node *ammountBackground = nullptr, *ammountForeground = nullptr;
|
vb01::Node *ammountBackground = nullptr, *ammountForeground = nullptr;
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
#include "concreteGuiManager.h"
|
#include "concreteGuiManager.h"
|
||||||
#include "defConfigs.h"
|
#include "defConfigs.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <assetManager.h>
|
#include <assetManager.h>
|
||||||
#include <particleEmitter.h>
|
#include <particleEmitter.h>
|
||||||
|
|
||||||
@@ -215,11 +217,11 @@ namespace battleship{
|
|||||||
unit->halt();
|
unit->halt();
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<int> Game::parseTechTable(int tid, string techKey, string numVarKey, string varKey){
|
vector<int> Game::parseTechTable(int tid, string key, string numVarKey, string varKey){
|
||||||
sol::state_view SOL_LUA_VIEW = generateView();
|
sol::state_view SOL_LUA_VIEW = generateView();
|
||||||
SOL_LUA_VIEW.script(numVarKey + " = #" + techKey + "[" + to_string(tid + 1) + "]." + varKey);
|
SOL_LUA_VIEW.script(numVarKey + " = #" + key + "[" + to_string(tid + 1) + "]." + varKey);
|
||||||
int numVar = SOL_LUA_VIEW[numVarKey];
|
int numVar = SOL_LUA_VIEW[numVarKey];
|
||||||
sol::table techTable = SOL_LUA_VIEW[techKey][tid + 1];
|
sol::table techTable = SOL_LUA_VIEW[key][tid + 1];
|
||||||
|
|
||||||
vector<int> varVec;
|
vector<int> varVec;
|
||||||
|
|
||||||
@@ -252,5 +254,36 @@ namespace battleship{
|
|||||||
|
|
||||||
technologies.push_back(t);
|
technologies.push_back(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
techKey = "abilities";
|
||||||
|
SOL_LUA_VIEW.script("numAbilities = #" + techKey);
|
||||||
|
int numAbilities = SOL_LUA_VIEW["numAbilities"];
|
||||||
|
|
||||||
|
for(int i = 0; i < numAbilities; i++){
|
||||||
|
sol::table techTable = SOL_LUA_VIEW[techKey][i + 1];
|
||||||
|
|
||||||
|
Ability ability;
|
||||||
|
ability.type = techTable["type"];
|
||||||
|
ability.ammount = techTable["ammount"];
|
||||||
|
ability.gameObjType = techTable["gameObjType"];
|
||||||
|
ability.gameObjIds = parseTechTable(i, techKey, "numGameObjIds", "gameObjIds");
|
||||||
|
abilities.push_back(ability);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float Game::calcAbilFromTech(Ability::Type type, vector<int> techResearch, int gameObjType, int unitId){
|
||||||
|
float ammount = 0;
|
||||||
|
|
||||||
|
for(int techId : techResearch)
|
||||||
|
for(int abilId : technologies[techId].abilities)
|
||||||
|
if(
|
||||||
|
abilities[abilId].type == type &&
|
||||||
|
abilities[abilId].gameObjType == gameObjType &&
|
||||||
|
find(abilities[abilId].gameObjIds.begin(), abilities[abilId].gameObjIds.end(), unitId) != abilities[abilId].gameObjIds.end()
|
||||||
|
){
|
||||||
|
ammount += abilities[abilId].ammount;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ammount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "fx.h"
|
#include "fx.h"
|
||||||
#include "technology.h"
|
#include "technology.h"
|
||||||
|
#include "ability.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -25,6 +26,7 @@ namespace battleship{
|
|||||||
void explode(vb01::Vector3, int, float, sf::Sound*);
|
void explode(vb01::Vector3, int, float, sf::Sound*);
|
||||||
void changeUnitPlayer(Unit*, Player*);
|
void changeUnitPlayer(Unit*, Player*);
|
||||||
void initTechnologies();
|
void initTechnologies();
|
||||||
|
float calcAbilFromTech(Ability::Type, std::vector<int>, int, int);
|
||||||
inline void addFx(Fx f){fx.push_back(f);}
|
inline void addFx(Fx f){fx.push_back(f);}
|
||||||
inline void addPlayer(Player *pl){players.push_back(pl);}
|
inline void addPlayer(Player *pl){players.push_back(pl);}
|
||||||
inline std::vector<Player*>& getPlayers(){return players;}
|
inline std::vector<Player*>& getPlayers(){return players;}
|
||||||
@@ -39,6 +41,7 @@ namespace battleship{
|
|||||||
bool paused = false, ended = false;
|
bool paused = false, ended = false;
|
||||||
std::vector<Fx> fx;
|
std::vector<Fx> fx;
|
||||||
std::vector<Technology> technologies;
|
std::vector<Technology> technologies;
|
||||||
|
std::vector<Ability> abilities;
|
||||||
std::vector<Player*> players;
|
std::vector<Player*> players;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-7
@@ -1,20 +1,21 @@
|
|||||||
#include <node.h>
|
#include <node.h>
|
||||||
#include <model.h>
|
#include <model.h>
|
||||||
#include <material.h>
|
#include <material.h>
|
||||||
#include <particleEmitter.h>
|
|
||||||
#include <quaternion.h>
|
|
||||||
#include <rayCaster.h>
|
#include <rayCaster.h>
|
||||||
|
#include <quaternion.h>
|
||||||
|
#include <particleEmitter.h>
|
||||||
|
|
||||||
#include <stateManager.h>
|
#include <stateManager.h>
|
||||||
|
|
||||||
|
#include "fx.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "unit.h"
|
#include "unit.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "player.h"
|
||||||
#include "projectile.h"
|
#include "projectile.h"
|
||||||
#include "resourceDeposit.h"
|
|
||||||
#include "defConfigs.h"
|
#include "defConfigs.h"
|
||||||
|
#include "resourceDeposit.h"
|
||||||
#include "inGameAppState.h"
|
#include "inGameAppState.h"
|
||||||
#include "fx.h"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vb01;
|
using namespace vb01;
|
||||||
@@ -51,14 +52,16 @@ namespace battleship{
|
|||||||
|
|
||||||
void Projectile::initProperties(){
|
void Projectile::initProperties(){
|
||||||
GameObject::initProperties();
|
GameObject::initProperties();
|
||||||
|
Game *game = Game::getSingleton();
|
||||||
|
vector<int> currTechs = player->getTechnologies();
|
||||||
|
|
||||||
sol::table projTable = generateView()[GameObject::getGameObjTableName()][id + 1];
|
sol::table projTable = generateView()[GameObject::getGameObjTableName()][id + 1];
|
||||||
rayLength = projTable["rayLength"];
|
rayLength = projTable["rayLength"];
|
||||||
directHitDamage = projTable["directHitDamage"];
|
directHitDamage = projTable["directHitDamage"]; directHitDamage += game->calcAbilFromTech(Ability::Type::DIRECT_HIT_DAMAGE, currTechs, (int)GameObject::type, id);
|
||||||
|
|
||||||
string explKey = "explosion";
|
string explKey = "explosion";
|
||||||
explosionDamage = projTable[explKey]["damage"];
|
explosionDamage = projTable[explKey]["damage"]; explosionDamage += game->calcAbilFromTech(Ability::Type::EXPLOSION_DAMAGE, currTechs, (int)GameObject::type, id);
|
||||||
explosionRadius = projTable[explKey]["radius"];
|
explosionRadius = projTable[explKey]["radius"]; explosionRadius += game->calcAbilFromTech(Ability::Type::EXPLOSION_RADIUS, currTechs, (int)GameObject::type, id);
|
||||||
speed = projTable["speed"];
|
speed = projTable["speed"];
|
||||||
rotAngle = projTable["rotAngle"].get_or(0.0);
|
rotAngle = projTable["rotAngle"].get_or(0.0);
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-5
@@ -1,6 +1,7 @@
|
|||||||
#include "resourceRover.h"
|
#include "resourceRover.h"
|
||||||
#include "resourceDeposit.h"
|
#include "resourceDeposit.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
#include "game.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "extractor.h"
|
#include "extractor.h"
|
||||||
#include "structure.h"
|
#include "structure.h"
|
||||||
@@ -14,11 +15,6 @@ namespace battleship{
|
|||||||
using namespace gameBase;
|
using namespace gameBase;
|
||||||
|
|
||||||
ResourceRover::ResourceRover(Player *player, int id, Vector3 pos, Quaternion rot, Unit::State state) : Vehicle(player, id, pos, rot, state) {
|
ResourceRover::ResourceRover(Player *player, int id, Vector3 pos, Quaternion rot, Unit::State state) : Vehicle(player, id, pos, rot, state) {
|
||||||
sol::table unitTable = generateView()["units"][id + 1];
|
|
||||||
capacity = unitTable["capacity"];
|
|
||||||
loadSpeed = unitTable["loadSpeed"];
|
|
||||||
loadRate = unitTable["loadRate"];
|
|
||||||
|
|
||||||
Vector2 size = Vector2(lenHpBar, 10);
|
Vector2 size = Vector2(lenHpBar, 10);
|
||||||
loadBackground = Unit::createBar(Vector2::VEC_ZERO, size, Vector4(0, 0, 0, 1));
|
loadBackground = Unit::createBar(Vector2::VEC_ZERO, size, Vector4(0, 0, 0, 1));
|
||||||
loadForeground = Unit::createBar(Vector2::VEC_ZERO, size, Vector4(1, 1, 0, 1));
|
loadForeground = Unit::createBar(Vector2::VEC_ZERO, size, Vector4(1, 1, 0, 1));
|
||||||
@@ -29,6 +25,17 @@ namespace battleship{
|
|||||||
removeBar(loadBackground);
|
removeBar(loadBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResourceRover::initProperties(){
|
||||||
|
Vehicle::initProperties();
|
||||||
|
Game *game = Game::getSingleton();
|
||||||
|
vector<int> currTechs = player->getTechnologies();
|
||||||
|
|
||||||
|
sol::table unitTable = generateView()["units"][id + 1];
|
||||||
|
capacity = unitTable["capacity"]; capacity += game->calcAbilFromTech(Ability::Type::CAPACITY, currTechs, (int)GameObject::type, id);
|
||||||
|
loadSpeed = unitTable["loadSpeed"]; loadSpeed += game->calcAbilFromTech(Ability::Type::LOAD_SPEED, currTechs, (int)GameObject::type, id);
|
||||||
|
loadRate = unitTable["loadRate"]; loadRate += game->calcAbilFromTech(Ability::Type::LOAD_RATE, currTechs, (int)GameObject::type, id);
|
||||||
|
}
|
||||||
|
|
||||||
void ResourceRover::supply(Order order){
|
void ResourceRover::supply(Order order){
|
||||||
float minDist = .5 * Map::getSingleton()->getCellSize().x;
|
float minDist = .5 * Map::getSingleton()->getCellSize().x;
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace battleship{
|
|||||||
~ResourceRover();
|
~ResourceRover();
|
||||||
void update();
|
void update();
|
||||||
private:
|
private:
|
||||||
|
void initProperties();
|
||||||
void supply(Order);
|
void supply(Order);
|
||||||
Unit* getClosestUnit(std::vector<Structure*>);
|
Unit* getClosestUnit(std::vector<Structure*>);
|
||||||
inline bool canLoad(){return vb01::getTime() - lastLoadTime > loadRate && load < capacity;}
|
inline bool canLoad(){return vb01::getTime() - lastLoadTime > loadRate && load < capacity;}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "activeGameState.h"
|
#include "activeGameState.h"
|
||||||
#include "defConfigs.h"
|
#include "defConfigs.h"
|
||||||
#include "pathfinder.h"
|
#include "pathfinder.h"
|
||||||
|
#include "ability.h"
|
||||||
|
|
||||||
using namespace glm;
|
using namespace glm;
|
||||||
using namespace vb01;
|
using namespace vb01;
|
||||||
@@ -126,12 +127,16 @@ namespace battleship{
|
|||||||
sol::state_view SOL_LUA_VIEW = generateView();
|
sol::state_view SOL_LUA_VIEW = generateView();
|
||||||
string objType = GameObject::getGameObjTableName();
|
string objType = GameObject::getGameObjTableName();
|
||||||
sol::table unitTable = SOL_LUA_VIEW[objType][id + 1];
|
sol::table unitTable = SOL_LUA_VIEW[objType][id + 1];
|
||||||
|
|
||||||
|
Game *game = Game::getSingleton();
|
||||||
|
vector<int> currTechs = player->getTechnologies();
|
||||||
|
|
||||||
string name = unitTable["name"];
|
string name = unitTable["name"];
|
||||||
health = unitTable["health"];
|
health = unitTable["health"]; health += game->calcAbilFromTech(Ability::Type::HEALTH, currTechs, (int)GameObject::type, id);
|
||||||
vehicle = unitTable["isVehicle"];
|
vehicle = unitTable["isVehicle"];
|
||||||
maxHealth = health;
|
maxHealth = health;
|
||||||
|
|
||||||
lineOfSight = unitTable["lineOfSight"];
|
lineOfSight = unitTable["lineOfSight"]; lineOfSight += game->calcAbilFromTech(Ability::Type::LINE_OF_SIGHT, currTechs, (int)GameObject::type, id);
|
||||||
unitClass = (UnitClass)unitTable["unitClass"];
|
unitClass = (UnitClass)unitTable["unitClass"];
|
||||||
type = (UnitType)unitTable["unitType"];
|
type = (UnitType)unitTable["unitType"];
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#include "vehicle.h"
|
#include "vehicle.h"
|
||||||
#include "pathfinder.h"
|
#include "pathfinder.h"
|
||||||
|
#include "player.h"
|
||||||
|
#include "game.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
|
||||||
using namespace gameBase;
|
using namespace gameBase;
|
||||||
@@ -83,9 +85,12 @@ namespace battleship{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Vehicle::initProperties(){
|
void Vehicle::initProperties(){
|
||||||
|
Game *game = Game::getSingleton();
|
||||||
|
vector<int> currTechs = player->getTechnologies();
|
||||||
|
|
||||||
sol::table unitTable = generateView()[GameObject::getGameObjTableName()][id + 1];
|
sol::table unitTable = generateView()[GameObject::getGameObjTableName()][id + 1];
|
||||||
maxTurnAngle = unitTable["maxTurnAngle"];
|
maxTurnAngle = unitTable["maxTurnAngle"]; maxTurnAngle += game->calcAbilFromTech(Ability::Type::MAX_TURN_ANGLE, currTechs, (int)GameObject::type, id);
|
||||||
speed = unitTable["speed"];
|
speed = unitTable["speed"]; speed += game->calcAbilFromTech(Ability::Type::SPEED, currTechs, (int)GameObject::type, id);
|
||||||
anglePrecision = unitTable["anglePrecision"];
|
anglePrecision = unitTable["anglePrecision"];
|
||||||
garrisonCategory = unitTable["garrisonCategory"];
|
garrisonCategory = unitTable["garrisonCategory"];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user