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