mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
EMPs jam units
This commit is contained in:
@@ -20,6 +20,7 @@ explosionSfx = {
|
|||||||
path = PATH .. 'Sounds/SFX/Explosions/explosion02.ogg',
|
path = PATH .. 'Sounds/SFX/Explosions/explosion02.ogg',
|
||||||
duration = 2500
|
duration = 2500
|
||||||
}
|
}
|
||||||
|
Detonation = {EXPLOSION = 0, EMP = 1, CRYO = 2}
|
||||||
|
|
||||||
projectiles = {
|
projectiles = {
|
||||||
{
|
{
|
||||||
@@ -27,7 +28,7 @@ projectiles = {
|
|||||||
size = {x = 1, y = 1, z = 1},
|
size = {x = 1, y = 1, z = 1},
|
||||||
speed = 5,
|
speed = 5,
|
||||||
rotAngle = .1,
|
rotAngle = .1,
|
||||||
explosion = {damage = 100, radius = 20, fx = {explosionVfx, explosionSfx}},
|
explosion = {detonation = Detonation.EXPLOSION, damage = 100, radius = 20, fx = {explosionVfx, explosionSfx}},
|
||||||
directHitDamage = 200,
|
directHitDamage = 200,
|
||||||
rayLength = 1,
|
rayLength = 1,
|
||||||
name = "Shell",
|
name = "Shell",
|
||||||
@@ -40,7 +41,7 @@ projectiles = {
|
|||||||
size = {x = 1, y = 1, z = 1},
|
size = {x = 1, y = 1, z = 1},
|
||||||
speed = 5,
|
speed = 5,
|
||||||
rotAngle = .1,
|
rotAngle = .1,
|
||||||
explosion = {damage = 0, radius = 20, fx = {explosionVfx, explosionSfx}},
|
explosion = {detonation = Detonation.EMP, damage = 0, radius = 20, fx = {explosionVfx, explosionSfx}},
|
||||||
directHitDamage = 0,
|
directHitDamage = 0,
|
||||||
rayLength = 1,
|
rayLength = 1,
|
||||||
name = "Shell",
|
name = "Shell",
|
||||||
@@ -53,7 +54,7 @@ projectiles = {
|
|||||||
size = {x = 6, y = 13.5, z = 2.54},
|
size = {x = 6, y = 13.5, z = 2.54},
|
||||||
speed = .5,
|
speed = .5,
|
||||||
rotAngle = .1,
|
rotAngle = .1,
|
||||||
explosion = {damage = 100, radius = 20, fx = {explosionVfx, explosionSfx}},
|
explosion = {detonation = Detonation.EXPLOSION, damage = 100, radius = 20, fx = {explosionVfx, explosionSfx}},
|
||||||
directHitDamage = 450,
|
directHitDamage = 450,
|
||||||
rayLength = 6,
|
rayLength = 6,
|
||||||
name = "Cruise missile",
|
name = "Cruise missile",
|
||||||
@@ -66,7 +67,7 @@ projectiles = {
|
|||||||
size = {x = 3, y = 7., z = 1.27},
|
size = {x = 3, y = 7., z = 1.27},
|
||||||
speed = .5,
|
speed = .5,
|
||||||
rotAngle = .1,
|
rotAngle = .1,
|
||||||
explosion = {damage = 70, radius = 12, fx = {explosionVfx, explosionSfx}},
|
explosion = {detonation = Detonation.EXPLOSION, damage = 70, radius = 12, fx = {explosionVfx, explosionSfx}},
|
||||||
directHitDamage = 250,
|
directHitDamage = 250,
|
||||||
rayLength = 3,
|
rayLength = 3,
|
||||||
name = "Missile",
|
name = "Missile",
|
||||||
@@ -78,7 +79,7 @@ projectiles = {
|
|||||||
projectileClass = ProjectileClass.TORPEDO,
|
projectileClass = ProjectileClass.TORPEDO,
|
||||||
size = {x = 1, y = 6, z = 1},
|
size = {x = 1, y = 6, z = 1},
|
||||||
speed = .06,
|
speed = .06,
|
||||||
explosion = {damage = 20, radius = 3, fx = {explosionVfx, explosionSfx}},
|
explosion = {detonation = Detonation.EXPLOSION, damage = 20, radius = 3, fx = {explosionVfx, explosionSfx}},
|
||||||
directHitDamage = 450,
|
directHitDamage = 450,
|
||||||
rayLength = 3.5,
|
rayLength = 3.5,
|
||||||
name = "Torpedo",
|
name = "Torpedo",
|
||||||
|
|||||||
+20
-38
@@ -1,6 +1,7 @@
|
|||||||
#include "environment.h"
|
#include "environment.h"
|
||||||
#include "fxManager.h"
|
#include "fxManager.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
#include "unit.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
|
||||||
#include <root.h>
|
#include <root.h>
|
||||||
@@ -9,8 +10,6 @@
|
|||||||
#include <texture.h>
|
#include <texture.h>
|
||||||
#include <particleEmitter.h>
|
#include <particleEmitter.h>
|
||||||
|
|
||||||
#include <SFML/Audio.hpp>
|
|
||||||
|
|
||||||
namespace battleship{
|
namespace battleship{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vb01;
|
using namespace vb01;
|
||||||
@@ -24,44 +23,27 @@ namespace battleship{
|
|||||||
return environment;
|
return environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Environment::explode(Vector3 pos, int damage, float radius, sf::Sound *explosionSfx){
|
//TODO use the pos argument from the fx
|
||||||
if(!(damage == 0 || radius == 0))
|
void Environment::explode(FxManager::Fx *fx, Detonation det, Vector3 pos, int damage, float radius){
|
||||||
for(Player *pl : Game::getSingleton()->getPlayers()){
|
FxManager::getSingleton()->addFx(fx);
|
||||||
for(Unit *un : pl->getUnits()){
|
|
||||||
float distance = un->getPos().getDistanceFrom(pos);
|
|
||||||
|
|
||||||
if(distance < radius)
|
if(radius == 0) return;
|
||||||
un->takeDamage(int(damage * (1.f - distance / radius)));
|
|
||||||
|
for(Player *pl : Game::getSingleton()->getPlayers()){
|
||||||
|
for(Unit *un : pl->getUnits()){
|
||||||
|
float distance = un->getPos().getDistanceFrom(pos);
|
||||||
|
|
||||||
|
if(distance < radius){
|
||||||
|
switch(det){
|
||||||
|
case Detonation::EXPLOSION:
|
||||||
|
un->takeDamage(int(damage * (1.f - distance / radius)));
|
||||||
|
break;
|
||||||
|
case Detonation::EMP:
|
||||||
|
un->setCondition(Unit::Condition::EM_JAMMED);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Root *root = Root::getSingleton();
|
|
||||||
|
|
||||||
const int numFrames = 1;
|
|
||||||
string p[numFrames];
|
|
||||||
|
|
||||||
for(int i = 0; i < numFrames; i++)
|
|
||||||
p[i] = GameManager::getSingleton()->getPath() + "Textures/Explosion/explosion07.png";
|
|
||||||
|
|
||||||
Texture *tex = new Texture(p, numFrames, false);
|
|
||||||
|
|
||||||
Material *mat = new Material(root->getLibPath() + "particle");
|
|
||||||
mat->addTexUniform("tex", tex, true);
|
|
||||||
|
|
||||||
ParticleEmitter *pe = new ParticleEmitter(1);
|
|
||||||
pe->setMaterial(mat);
|
|
||||||
pe->setLowLife(3);
|
|
||||||
pe->setHighLife(3);
|
|
||||||
pe->setSize(10 * Vector2::VEC_IJ);
|
|
||||||
pe->setSpeed(0);
|
|
||||||
|
|
||||||
Node *node = new Node(pos + Vector3(0, 2, 0));
|
|
||||||
node->attachParticleEmitter(pe);
|
|
||||||
node->lookAt(Vector3::VEC_J, Vector3::VEC_K);
|
|
||||||
root->getRootNode()->attachChild(node);
|
|
||||||
|
|
||||||
typedef FxManager::Fx Fx;
|
|
||||||
typedef FxManager::Fx::Component Component;
|
|
||||||
FxManager::getSingleton()->addFx(new Fx(vector<Component>{Component((void*)node, true, 50), Component((void*)explosionSfx, false, 2500)}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -3,15 +3,15 @@
|
|||||||
|
|
||||||
#include <vector.h>
|
#include <vector.h>
|
||||||
|
|
||||||
namespace sf{
|
#include "fxManager.h"
|
||||||
class Sound;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace battleship{
|
namespace battleship{
|
||||||
class Environment{
|
class Environment{
|
||||||
public:
|
public:
|
||||||
|
enum class Detonation{EXPLOSION, EMP, CRYO};
|
||||||
|
|
||||||
static Environment* getSingleton();
|
static Environment* getSingleton();
|
||||||
static void explode(vb01::Vector3, int, float, sf::Sound*);
|
static void explode(FxManager::Fx*, Detonation, vb01::Vector3, int = 0, float = 0);
|
||||||
private:
|
private:
|
||||||
Environment(){}
|
Environment(){}
|
||||||
};
|
};
|
||||||
|
|||||||
+15
-17
@@ -69,6 +69,16 @@ namespace battleship{
|
|||||||
placeAt(pos + speed * dirVec);
|
placeAt(pos + speed * dirVec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Projectile::detonate(Unit *target){
|
||||||
|
if(target) target->takeDamage(directHitDamage);
|
||||||
|
|
||||||
|
sol::table tbl = generateView()[getGameObjTableName()][id + 1]["explosion"];
|
||||||
|
FxManager::Fx *fx = FxManager::getSingleton()->initFx(tbl["fx"], model, false, pos);
|
||||||
|
Environment::explode(fx, (Environment::Detonation)tbl["detonation"], pos, tbl["damage"], tbl["radius"]);
|
||||||
|
|
||||||
|
remove = true;
|
||||||
|
}
|
||||||
|
|
||||||
void Projectile::checkUnitCollision(){
|
void Projectile::checkUnitCollision(){
|
||||||
vector<Player*> players = Game::getSingleton()->getPlayers(true);
|
vector<Player*> players = Game::getSingleton()->getPlayers(true);
|
||||||
vector<Unit*> targetUnits;
|
vector<Unit*> targetUnits;
|
||||||
@@ -86,30 +96,18 @@ namespace battleship{
|
|||||||
|
|
||||||
vector<RayCaster::CollisionResult> results = RayCaster::cast(pos, dirVec, targetNodes, rayLength);
|
vector<RayCaster::CollisionResult> results = RayCaster::cast(pos, dirVec, targetNodes, rayLength);
|
||||||
|
|
||||||
if(!results.empty()){
|
if(!results.empty())
|
||||||
for(int i = 0; i < targetNodes.size(); i++)
|
for(int i = 0; i < targetNodes.size(); i++)
|
||||||
if(targetNodes[i]->getMesh(0) == results[0].mesh){
|
if(targetNodes[i]->getMesh(0) == results[0].mesh)
|
||||||
FxManager *fxManager = FxManager::getSingleton();
|
detonate(targetUnits[i]);
|
||||||
FxManager::Fx *explosionFx = fxManager->initFx(generateView()[getGameObjTableName()][id + 1]["explosion"]["fx"], model, false, pos);
|
|
||||||
explosionFx->toggleComponents(true);
|
|
||||||
fxManager->addFx(explosionFx);
|
|
||||||
targetUnits[i]->takeDamage(directHitDamage);
|
|
||||||
remove = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Projectile::checkSurfaceCollision(){
|
void Projectile::checkSurfaceCollision(){
|
||||||
Map *map = Map::getSingleton();
|
Map *map = Map::getSingleton();
|
||||||
int cellId = map->getCellId(pos, false);
|
int cellId = map->getCellId(pos, false);
|
||||||
|
|
||||||
if((pos + dirVec * rayLength).y <= map->getCells()[cellId].pos.y){
|
if((pos + dirVec * rayLength).y <= map->getCells()[cellId].pos.y)
|
||||||
FxManager *fxManager = FxManager::getSingleton();
|
detonate();
|
||||||
FxManager::Fx *explosionFx = fxManager->initFx(generateView()[getGameObjTableName()][id + 1]["explosion"]["fx"], model, false, pos);
|
|
||||||
explosionFx->toggleComponents(true);
|
|
||||||
fxManager->addFx(explosionFx);
|
|
||||||
remove = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Projectile::checkCollision(){
|
void Projectile::checkCollision(){
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ namespace battleship {
|
|||||||
virtual void debug();
|
virtual void debug();
|
||||||
private:
|
private:
|
||||||
void initProperties();
|
void initProperties();
|
||||||
|
void detonate(Unit *u = nullptr);
|
||||||
protected:
|
protected:
|
||||||
virtual void reinit();
|
virtual void reinit();
|
||||||
virtual void checkUnitCollision();
|
virtual void checkUnitCollision();
|
||||||
|
|||||||
@@ -325,10 +325,9 @@ namespace battleship{
|
|||||||
displayUnitStats(slot.foreground, slot.background, (int)((bool)slot.vehicle), (int)true, renderSelectables, slot.offset);
|
displayUnitStats(slot.foreground, slot.background, (int)((bool)slot.vehicle), (int)true, renderSelectables, slot.offset);
|
||||||
|
|
||||||
if (health <= DEATH_HP){
|
if (health <= DEATH_HP){
|
||||||
FxManager *fxManager = FxManager::getSingleton();
|
sol::table tbl = generateView()[getGameObjTableName()][id + 1]["deathFx"];
|
||||||
FxManager::Fx *deathFx = fxManager->initFx(generateView()[getGameObjTableName()][id + 1]["deathFx"], model, false, pos);
|
FxManager::Fx *fx = FxManager::getSingleton()->initFx(tbl, model, false, pos);
|
||||||
deathFx->toggleComponents(true);
|
Environment::explode(fx, Environment::Detonation::EXPLOSION, pos);
|
||||||
fxManager->addFx(deathFx);
|
|
||||||
remove = true;
|
remove = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -142,6 +142,11 @@ namespace battleship{
|
|||||||
inline void setFreezeStatus(int fs){this->freezeStatus = std::clamp(fs, 0, 100);}
|
inline void setFreezeStatus(int fs){this->freezeStatus = std::clamp(fs, 0, 100);}
|
||||||
inline int getFreezeStatus(){return freezeStatus;}
|
inline int getFreezeStatus(){return freezeStatus;}
|
||||||
inline Condition getCondition(){return condition;}
|
inline Condition getCondition(){return condition;}
|
||||||
|
inline void setCondition(Condition cond){
|
||||||
|
this->condition = cond;
|
||||||
|
|
||||||
|
if(cond == Condition::EM_JAMMED) lastJamTime = vb01::getTime();
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
void renderOrderLine(bool);
|
void renderOrderLine(bool);
|
||||||
void updateScreenCoordinates();
|
void updateScreenCoordinates();
|
||||||
|
|||||||
Reference in New Issue
Block a user