mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
implemented shells
This commit is contained in:
@@ -1,7 +1,21 @@
|
|||||||
ProjectileId = {CRUISE_MISSILE = 0, TORPEDO = 1}
|
ProjectileId = {SHELL = 0, CRUISE_MISSILE = 1, TORPEDO = 2}
|
||||||
ProjectileClass = {CRUISE_MISSILE = 0, TORPEDO = 1}
|
ProjectileClass = {SHELL = 0, CRUISE_MISSILE = 1, TORPEDO = 2}
|
||||||
|
G = 9.8
|
||||||
|
|
||||||
projectiles = {
|
projectiles = {
|
||||||
|
{
|
||||||
|
projectileClass = ProjectileClass.SHELL,
|
||||||
|
size = {x = 1, y = 1, z = 1},
|
||||||
|
speed = 5,
|
||||||
|
rotAngle = .1,
|
||||||
|
explosion = {damage = 100, radius = 20, sfx = PATH .. 'Sounds/SFX/Explosions/explosion02.ogg'},
|
||||||
|
directHitDamage = 200,
|
||||||
|
rayLength = 1,
|
||||||
|
name = "Shell",
|
||||||
|
basePath = PATH .. "Models/GameObjects/Projectiles/Shells/",
|
||||||
|
meshPath = "shell.xml",
|
||||||
|
albedoPath = 'shell.jpg'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
projectileClass = ProjectileClass.CRUISE_MISSILE,
|
projectileClass = ProjectileClass.CRUISE_MISSILE,
|
||||||
size = {x = 6, y = 13.5, z = 2.54},
|
size = {x = 6, y = 13.5, z = 2.54},
|
||||||
|
|||||||
@@ -160,11 +160,17 @@ units = {
|
|||||||
{
|
{
|
||||||
weapons = {
|
weapons = {
|
||||||
{
|
{
|
||||||
type = WeaponClass.HITSCAN,
|
type = WeaponClass.SHELL,
|
||||||
|
projectile = {id = ProjectileId.SHELL, pos = {x = 0.06, y = 5.82, z = 11.4}, rot = {w = 1, x = 0, y = 0, z = 0}},
|
||||||
rateOfFire = 1000,
|
rateOfFire = 1000,
|
||||||
damage = 200,
|
damage = 200,
|
||||||
maxRange = 25,
|
maxRange = 25,
|
||||||
fireFx = {
|
fireFx = {
|
||||||
|
{
|
||||||
|
vfx = false,
|
||||||
|
duration = 300,
|
||||||
|
path = PATH .. 'Sounds/Units/Tanks/attack.ogg',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
vfx = true,
|
vfx = true,
|
||||||
duration = 50,
|
duration = 50,
|
||||||
@@ -172,19 +178,14 @@ units = {
|
|||||||
path = PATH .. vfxPrefix .. 'muzzleFlash.xml',
|
path = PATH .. vfxPrefix .. 'muzzleFlash.xml',
|
||||||
color = {x = 1, y = 1, z = 0, a = 1},
|
color = {x = 1, y = 1, z = 0, a = 1},
|
||||||
},
|
},
|
||||||
parent = 'Turret',
|
parent = 'CannonBarrel',
|
||||||
pos = {x = 0.06, y = 5.82, z = 11.4},
|
pos = {x = 0.06, y = 5.82, z = 11.4},
|
||||||
rot = {w = 1, x = 0, y = 0, z = 0},
|
rot = {w = 1, x = 0, y = 0, z = 0},
|
||||||
--scale = .5
|
--scale = .5
|
||||||
},
|
|
||||||
{
|
|
||||||
vfx = false,
|
|
||||||
duration = 300,
|
|
||||||
path = PATH .. 'Sounds/Units/Tanks/attack.ogg',
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
landHitFx = {explosionVfx, explosionSfx},
|
--landHitFx = {explosionVfx, explosionSfx},
|
||||||
unitHitFx = {explosionVfx, explosionSfx}
|
--unitHitFx = {explosionVfx, explosionSfx}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
unitClass = UnitClass.TANK,
|
unitClass = UnitClass.TANK,
|
||||||
|
|||||||
+3
-2
@@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 2.9)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
set(GAME_NAME battleship)
|
set(GAME_NAME battleship)
|
||||||
project(${GAME_NAME})
|
project(${GAME_NAME})
|
||||||
@@ -10,6 +10,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDART 17)
|
set(CMAKE_CXX_STANDART 17)
|
||||||
|
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
|
||||||
set(CMAKE_BUILD_TYPE Debug)
|
set(CMAKE_BUILD_TYPE Debug)
|
||||||
set(BUILD_TESTS ON)
|
set(BUILD_TESTS ON)
|
||||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL FORCED)
|
set(BUILD_SHARED_LIBS OFF CACHE BOOL FORCED)
|
||||||
@@ -30,7 +31,7 @@ set(UTIL util.cpp binds.h)
|
|||||||
set(CONTROLLERS gameObjectFrameController.cpp cameraController.cpp)
|
set(CONTROLLERS gameObjectFrameController.cpp cameraController.cpp)
|
||||||
set(CONSOLE console.cpp abstractCommand.cpp addUnitCommand.cpp addResourceCommand.cpp addTechnologyCommand.cpp toggleDebugCommand.cpp)
|
set(CONSOLE console.cpp abstractCommand.cpp addUnitCommand.cpp addResourceCommand.cpp addTechnologyCommand.cpp toggleDebugCommand.cpp)
|
||||||
set(CORE gameManager.cpp game.cpp fxManager.cpp defConfigs.cpp ${CONSOLE} ${CONTROLLERS})
|
set(CORE gameManager.cpp game.cpp fxManager.cpp defConfigs.cpp ${CONSOLE} ${CONTROLLERS})
|
||||||
set(PROJECTILES projectile.cpp cruiseMissile.cpp)
|
set(PROJECTILES projectile.cpp cruiseMissile.cpp shell.cpp)
|
||||||
set(VEHICLES vehicle.cpp engineer.cpp resourceRover.cpp)
|
set(VEHICLES vehicle.cpp engineer.cpp resourceRover.cpp)
|
||||||
set(STRUCTURES structure.cpp factory.cpp pointDefense.cpp extractor.cpp researchStruct.cpp)
|
set(STRUCTURES structure.cpp factory.cpp pointDefense.cpp extractor.cpp researchStruct.cpp)
|
||||||
set(UNITS gameObjectFactory.cpp unit.cpp ${STRUCTURES} ${VEHICLES})
|
set(UNITS gameObjectFactory.cpp unit.cpp ${STRUCTURES} ${VEHICLES})
|
||||||
|
|||||||
+1
-1
@@ -204,7 +204,7 @@ namespace battleship{
|
|||||||
|
|
||||||
cursorState = (unloadFlag ? CursorState::UNLOAD : CursorState::LOAD);
|
cursorState = (unloadFlag ? CursorState::UNLOAD : CursorState::LOAD);
|
||||||
}
|
}
|
||||||
else if(gameObjUnit && !(ownGameObj || alliedGameObj))
|
else if(controlPressed || gameObjUnit && !(ownGameObj || alliedGameObj))
|
||||||
cursorState = CursorState::ATTACK;
|
cursorState = CursorState::ATTACK;
|
||||||
else
|
else
|
||||||
cursorState = CursorState::NORMAL;
|
cursorState = CursorState::NORMAL;
|
||||||
|
|||||||
+5
-12
@@ -47,19 +47,8 @@ namespace battleship{
|
|||||||
flightStage = FlightStage::DESCENT;
|
flightStage = FlightStage::DESCENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CruiseMissile::checkSurfaceCollision(){
|
|
||||||
Map *map = Map::getSingleton();
|
|
||||||
int cellId = map->getCellId(pos, false);
|
|
||||||
|
|
||||||
if((pos + dirVec * rayLength).y <= map->getCells()[cellId].pos.y){
|
|
||||||
Game::getSingleton()->explode(pos, explosionDamage, explosionRadius, explosionSfx);
|
|
||||||
remove = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CruiseMissile::update(){
|
void CruiseMissile::update(){
|
||||||
GameObject::update();
|
Projectile::update();
|
||||||
placeAt(pos + dirVec * speed);
|
|
||||||
|
|
||||||
switch(flightStage){
|
switch(flightStage){
|
||||||
case FlightStage::ASCENT:
|
case FlightStage::ASCENT:
|
||||||
@@ -73,6 +62,10 @@ namespace battleship{
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkCollision();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CruiseMissile::checkCollision(){
|
||||||
if(!remove && flightStage == FlightStage::DESCENT){
|
if(!remove && flightStage == FlightStage::DESCENT){
|
||||||
checkSurfaceCollision();
|
checkSurfaceCollision();
|
||||||
if(remove) return;
|
if(remove) return;
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ namespace battleship{
|
|||||||
|
|
||||||
void pitch(float, vb01::Vector3);
|
void pitch(float, vb01::Vector3);
|
||||||
void cruise();
|
void cruise();
|
||||||
void checkSurfaceCollision();
|
void checkCollision();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -45,8 +45,11 @@ namespace battleship{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GameObject::orientAt(Quaternion rotQuat){
|
void GameObject::orientAt(Quaternion rotQuat){
|
||||||
model->setOrientation(rotQuat);
|
|
||||||
rot = rotQuat;
|
rot = rotQuat;
|
||||||
|
model->setOrientation(rotQuat);
|
||||||
|
leftVec = model->getGlobalAxis(0);
|
||||||
|
upVec = model->getGlobalAxis(1);
|
||||||
|
dirVec = model->getGlobalAxis(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO remove neccessity to create a material for an invisible mesh
|
//TODO remove neccessity to create a material for an invisible mesh
|
||||||
|
|||||||
@@ -7,8 +7,9 @@
|
|||||||
#include "resourceDeposit.h"
|
#include "resourceDeposit.h"
|
||||||
#include "pointDefense.h"
|
#include "pointDefense.h"
|
||||||
#include "extractor.h"
|
#include "extractor.h"
|
||||||
#include "cruiseMissile.h"
|
|
||||||
#include "researchStruct.h"
|
#include "researchStruct.h"
|
||||||
|
#include "cruiseMissile.h"
|
||||||
|
#include "shell.h"
|
||||||
#include "defConfigs.h"
|
#include "defConfigs.h"
|
||||||
|
|
||||||
#include <solUtil.h>
|
#include <solUtil.h>
|
||||||
@@ -52,6 +53,8 @@ namespace battleship{
|
|||||||
int projectileClass = SOL_LUA_VIEW["projectiles"][id + 1]["projectileClass"];
|
int projectileClass = SOL_LUA_VIEW["projectiles"][id + 1]["projectileClass"];
|
||||||
|
|
||||||
switch((ProjectileClass)projectileClass){
|
switch((ProjectileClass)projectileClass){
|
||||||
|
case ProjectileClass::SHELL:
|
||||||
|
return new Shell(unit, id, pos, rot);
|
||||||
case ProjectileClass::CRUISE_MISSILE:
|
case ProjectileClass::CRUISE_MISSILE:
|
||||||
{
|
{
|
||||||
Order::Target target = unit->getOrder(0).targets[0];
|
Order::Target target = unit->getOrder(0).targets[0];
|
||||||
|
|||||||
+11
-7
@@ -73,12 +73,6 @@ namespace battleship{
|
|||||||
void Projectile::update() {
|
void Projectile::update() {
|
||||||
GameObject::update();
|
GameObject::update();
|
||||||
placeAt(pos + speed * dirVec);
|
placeAt(pos + speed * dirVec);
|
||||||
|
|
||||||
if(!remove){
|
|
||||||
checkSurfaceCollision();
|
|
||||||
if(remove) return;
|
|
||||||
checkUnitCollision();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Projectile::checkUnitCollision(){
|
void Projectile::checkUnitCollision(){
|
||||||
@@ -112,8 +106,18 @@ namespace battleship{
|
|||||||
Map *map = Map::getSingleton();
|
Map *map = Map::getSingleton();
|
||||||
int cellId = map->getCellId(pos, false);
|
int cellId = map->getCellId(pos, false);
|
||||||
|
|
||||||
if(map->getCells()[cellId].type == Map::Cell::LAND)
|
if((pos + dirVec * rayLength).y <= map->getCells()[cellId].pos.y){
|
||||||
|
Game::getSingleton()->explode(pos, explosionDamage, explosionRadius, explosionSfx);
|
||||||
remove = true;
|
remove = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Projectile::checkCollision(){
|
||||||
|
if(!remove){
|
||||||
|
checkSurfaceCollision();
|
||||||
|
if(remove) return;
|
||||||
|
checkUnitCollision();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Projectile::debug(){
|
void Projectile::debug(){
|
||||||
|
|||||||
+2
-2
@@ -12,7 +12,7 @@ namespace vb01{
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace battleship {
|
namespace battleship {
|
||||||
enum class ProjectileClass{CRUISE_MISSILE, TORPEDO};
|
enum class ProjectileClass{SHELL, CRUISE_MISSILE, TORPEDO};
|
||||||
class Unit;
|
class Unit;
|
||||||
|
|
||||||
class Projectile : public GameObject{
|
class Projectile : public GameObject{
|
||||||
@@ -24,11 +24,11 @@ namespace battleship {
|
|||||||
private:
|
private:
|
||||||
void initProperties();
|
void initProperties();
|
||||||
void initSound();
|
void initSound();
|
||||||
void checkCollision();
|
|
||||||
protected:
|
protected:
|
||||||
virtual void reinit();
|
virtual void reinit();
|
||||||
virtual void checkUnitCollision();
|
virtual void checkUnitCollision();
|
||||||
virtual void checkSurfaceCollision();
|
virtual void checkSurfaceCollision();
|
||||||
|
void checkCollision();
|
||||||
|
|
||||||
float speed, rayLength, explosionRadius, rotAngle;
|
float speed, rayLength, explosionRadius, rotAngle;
|
||||||
int directHitDamage, explosionDamage;
|
int directHitDamage, explosionDamage;
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#include "shell.h"
|
||||||
|
|
||||||
|
#include <solUtil.h>
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
namespace battleship{
|
||||||
|
using namespace std;
|
||||||
|
using namespace vb01;
|
||||||
|
using namespace gameBase;
|
||||||
|
|
||||||
|
Shell::Shell(Unit *un, int id, Vector3 pos, Quaternion rot) :
|
||||||
|
Projectile(un, id, pos, rot),
|
||||||
|
initTime(getTime())
|
||||||
|
{
|
||||||
|
initDir = dirVec;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Shell::update(){
|
||||||
|
float currTime = float(getTime() - initTime) / 1000;
|
||||||
|
|
||||||
|
if(currTime == 0) return;
|
||||||
|
|
||||||
|
const float G = generateView()["G"];
|
||||||
|
float angle = initDir.getAngleBetween(Vector3(initDir.x, 0, initDir.z).norm());
|
||||||
|
|
||||||
|
dirVec = (
|
||||||
|
pos +
|
||||||
|
speed * currTime * cos(angle) * Vector3(initDir.x, 0, initDir.z).norm() +
|
||||||
|
(currTime * speed * sin(angle) - G * currTime * currTime) * Vector3::VEC_J -
|
||||||
|
pos
|
||||||
|
).norm();
|
||||||
|
upVec = Quaternion(-PI / 2, leftVec) * dirVec;
|
||||||
|
model->lookAt(dirVec, upVec);
|
||||||
|
|
||||||
|
Projectile::update();
|
||||||
|
checkCollision();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#ifndef SHELL_H
|
||||||
|
#define SHELL_H
|
||||||
|
|
||||||
|
#include "projectile.h"
|
||||||
|
|
||||||
|
#include <util.h>
|
||||||
|
|
||||||
|
namespace battleship{
|
||||||
|
class Shell : public Projectile{
|
||||||
|
public:
|
||||||
|
Shell(Unit*, int, vb01::Vector3, vb01::Quaternion);
|
||||||
|
void update();
|
||||||
|
private:
|
||||||
|
vb01::s64 initTime;
|
||||||
|
vb01::Vector3 initDir;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -279,7 +279,7 @@ namespace battleship{
|
|||||||
Vector3 upVec = unit->getUpVec();
|
Vector3 upVec = unit->getUpVec();
|
||||||
Vector3 dirVec = unit->getDirVec();
|
Vector3 dirVec = unit->getDirVec();
|
||||||
Vector3 p = unit->getPos() + leftVec * projPos.x + upVec * projPos.y + dirVec * projPos.z;
|
Vector3 p = unit->getPos() + leftVec * projPos.x + upVec * projPos.y + dirVec * projPos.z;
|
||||||
Quaternion r = unit->getRot() * projRot;
|
Quaternion r = projRot * unit->getRot();
|
||||||
unit->getPlayer()->addProjectile(GameObjectFactory::createProjectile(unit, projId, p, r));
|
unit->getPlayer()->addProjectile(GameObjectFactory::createProjectile(unit, projId, p, r));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user