mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
Merge pull request #216 from devZoGok/imp-215-freezer-weapons
Imp 215 freezer weapons
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -71,7 +71,7 @@ UnitId = {
|
||||
ER_REFINERY = 54,
|
||||
ICE_SHEET = 55
|
||||
}
|
||||
WeaponClass = {FREEZE = 1}
|
||||
WeaponClass = {DAMAGE = 0, FREEZE = 1}
|
||||
UnitClass = {
|
||||
WAR_MECH = 0,
|
||||
TANK = 1,
|
||||
@@ -2287,8 +2287,12 @@ units = {
|
||||
type = WeaponClass.FREEZE,
|
||||
orderType = OrderType.ATTACK,
|
||||
rateOfFire = 100,
|
||||
maxRange = 10,
|
||||
maxRange = 30,
|
||||
damage = 0,
|
||||
nodes = {
|
||||
{name = 'turret', rotationSpeed = .05, vertical = false},
|
||||
{name = 'barrel', rotationSpeed = .05, angleConstraints = {min = -.523, max = .523}, vertical = true},
|
||||
},
|
||||
fireFx = {
|
||||
{
|
||||
vfx = false,
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ set(CORE gameManager.cpp game.cpp pathfinder.cpp environment.cpp fxManager.cpp d
|
||||
set(PROJECTILES projectile.cpp missile.cpp cruiseMissile.cpp shell.cpp)
|
||||
set(VEHICLES vehicle.cpp submarine.cpp engineer.cpp resourceRover.cpp freezer.cpp)
|
||||
set(STRUCTURES structure.cpp factory.cpp pointDefense.cpp extractor.cpp researchStruct.cpp iceSheet.cpp)
|
||||
set(WEAPONS weapon.cpp cryoGun.cpp)
|
||||
set(WEAPONS weapon.cpp)
|
||||
set(UNITS unit.cpp ${WEAPONS} ${STRUCTURES} ${VEHICLES})
|
||||
set(CONTENT map.cpp gameObject.cpp destructable.cpp gameObjectFrame.h gameObjectFactory.cpp resourceDeposit.cpp ${UNITS} ${PROJECTILES})
|
||||
|
||||
|
||||
+13
-2
@@ -719,7 +719,18 @@ 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 || selectedUnits[0]->getUnitClass() == UnitClass::FREEZER) && ufCtr->isPlacingOnSurface()){
|
||||
else if(ufCtr->isPlacingOnSurface()){
|
||||
Order::TYPE type;
|
||||
|
||||
switch(selectedUnits[0]->getUnitClass()){
|
||||
case UnitClass::ENGINEER:
|
||||
case UnitClass::FREEZER:
|
||||
type = Order::TYPE::BUILD;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
targets.clear();
|
||||
|
||||
for(int i = 0; i < ufCtr->getNumGameObjectFrames(); i++){
|
||||
@@ -728,7 +739,7 @@ namespace battleship{
|
||||
if(gmObjFr.status == GameObjectFrame::NOT_PLACEABLE) continue;
|
||||
|
||||
Unit *buildStruct = GameObjectFactory::createUnit(mainPlayer, gmObjFr.getId(), gmObjFr.getPos(), gmObjFr.getRot());
|
||||
issueOrder(Order::TYPE::BUILD, vector<Order::Target>{Order::Target(buildStruct, gmObjFr.getPos())}, shiftPressed);
|
||||
issueOrder(type, vector<Order::Target>{Order::Target(buildStruct, gmObjFr.getPos())}, shiftPressed);
|
||||
mainPlayer->addUnit(buildStruct);
|
||||
}
|
||||
|
||||
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
#include "cryoGun.h"
|
||||
#include "destructable.h"
|
||||
#include "unit.h"
|
||||
|
||||
namespace battleship{
|
||||
using namespace std;
|
||||
using namespace vb01;
|
||||
using namespace gameBase;
|
||||
|
||||
CryoGun::CryoGun(Unit *u, sol::table unitTable, int wid) : Weapon(u, unitTable, wid){}
|
||||
|
||||
void CryoGun::updateTarget(GameObject *target){
|
||||
if(canFreeze()){
|
||||
Destructable *destructTarg = target->getDestructable();
|
||||
destructTarg->setFreezeStatus(destructTarg->getFreezeStatus() + 1);
|
||||
lastFreezeTime = getTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
#ifndef CRYOGUN_H
|
||||
#define CRYOGUN_H
|
||||
|
||||
#include "weapon.h"
|
||||
|
||||
#include <util.h>
|
||||
|
||||
#include <solUtil.h>
|
||||
|
||||
namespace battleship{
|
||||
class Unit;
|
||||
|
||||
class CryoGun : public Weapon{
|
||||
public:
|
||||
CryoGun(Unit*, sol::table, int);
|
||||
private:
|
||||
vb01::s64 lastFreezeTime = 0;
|
||||
|
||||
void updateTarget(GameObject*);
|
||||
inline bool canFreeze(){return vb01::getTime() - lastFreezeTime > rateOfFire;}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+22
-1
@@ -1,8 +1,13 @@
|
||||
#include "freezer.h"
|
||||
#include "weapon.h"
|
||||
#include "structure.h"
|
||||
#include "destructable.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace battleship{
|
||||
using namespace vb01;
|
||||
using namespace std;
|
||||
|
||||
//TODO rename the class to a more generic name
|
||||
Freezer::Freezer(Player *player, int id, Vector3 pos, Quaternion rot, Unit::State state) : Vehicle(player, id, pos, rot, state){}
|
||||
@@ -12,7 +17,23 @@ namespace battleship{
|
||||
|
||||
Destructable *target = order.targets[0].unit->getDestructable();
|
||||
|
||||
if(target && target->getFreezeStatus() == 100)
|
||||
if(target && target->getFreezeStatus() >= 100)
|
||||
removeOrder(0);
|
||||
}
|
||||
|
||||
void Freezer::build(Order order){
|
||||
vector<Weapon*> weapons = getWeaponsByType((int)Weapon::Type::FREEZER);
|
||||
|
||||
if(weapons.empty()) return;
|
||||
|
||||
Unit *targ = (Unit*)order.targets[0].unit;
|
||||
|
||||
for(Weapon *w : weapons)
|
||||
w->trackTarget(targ->getPos());
|
||||
|
||||
Vehicle::build(order);
|
||||
|
||||
if(targ->getUnitClass() == UnitClass::ICE_SHEET && ((Structure*)targ)->getBuildStatus() >= 100)
|
||||
removeOrder(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace battleship{
|
||||
Freezer(Player*, int, vb01::Vector3, vb01::Quaternion, Unit::State);
|
||||
private:
|
||||
void attack(Order);
|
||||
void build(Order);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <ext.hpp>
|
||||
|
||||
#include "unit.h"
|
||||
#include "cryoGun.h"
|
||||
#include "weapon.h"
|
||||
#include "util.h"
|
||||
#include "game.h"
|
||||
@@ -142,14 +141,7 @@ namespace battleship{
|
||||
|
||||
if(wtOpt != sol::nullopt) wt = unitTable[tblName][i + 1]["type"];
|
||||
|
||||
switch((Weapon::Type)wt){
|
||||
case Weapon::Type::FREEZER:
|
||||
weapons.push_back(new CryoGun(this, unitTable, i));
|
||||
break;
|
||||
default:
|
||||
weapons.push_back(new Weapon(this, unitTable, i));
|
||||
break;
|
||||
}
|
||||
weapons.push_back(new Weapon(this, unitTable, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -428,6 +420,16 @@ namespace battleship{
|
||||
return weaps;
|
||||
}
|
||||
|
||||
vector<Weapon*> Unit::getWeaponsByType(int type){
|
||||
vector<Weapon*> weaps;
|
||||
|
||||
for(Weapon *w : weapons)
|
||||
if(w->getType() == (Weapon::Type)type)
|
||||
weaps.push_back(w);
|
||||
|
||||
return weaps;
|
||||
}
|
||||
|
||||
void Unit::receiveOrder(Order order, bool add) {
|
||||
if(!validateOrder(order)) return;
|
||||
|
||||
|
||||
@@ -196,6 +196,7 @@ namespace battleship{
|
||||
virtual void freeze(Order){}
|
||||
float calculateRotation(vb01::Vector3, float, float);
|
||||
std::vector<Weapon*> getWeaponsByOrder(Order::TYPE);
|
||||
std::vector<Weapon*> getWeaponsByType(int);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ namespace battleship{
|
||||
void addPathpoint(vb01::Vector3);
|
||||
void removePathpoint(int = 0);
|
||||
void removeAllPathpoints();
|
||||
void build(Order);
|
||||
void select();
|
||||
void reinit();
|
||||
protected:
|
||||
@@ -48,6 +47,7 @@ namespace battleship{
|
||||
void navigateToTarget(float);
|
||||
void preparePathpoints(Order&, vb01::Vector3, bool = false);
|
||||
virtual void attack(Order);
|
||||
virtual void build(Order);
|
||||
void garrison(Order);
|
||||
void patrol(Order);
|
||||
virtual void initProperties();
|
||||
|
||||
+21
-3
@@ -9,6 +9,7 @@
|
||||
#include "player.h"
|
||||
#include "fxManager.h"
|
||||
#include "destructable.h"
|
||||
#include "structure.h"
|
||||
#include "gameObjectFactory.h"
|
||||
#include "projectile.h"
|
||||
|
||||
@@ -28,6 +29,11 @@ namespace battleship{
|
||||
maxFireAngle = weaponTable["maxFireAngle"].get_or(.1);
|
||||
orderType = (Order::TYPE)weaponTable["orderType"];
|
||||
|
||||
sol::optional<float> typeOpt = unitTable["weapons"][wid + 1]["type"];
|
||||
|
||||
if(typeOpt != sol::nullopt)
|
||||
type = (Type)unitTable["weapons"][wid + 1]["type"];
|
||||
|
||||
initProjectileData(weaponTable);
|
||||
initNodes(weaponTable);
|
||||
|
||||
@@ -155,8 +161,7 @@ namespace battleship{
|
||||
aimedAtTarget = withinRange && withinAngle;
|
||||
}
|
||||
|
||||
if((Order::TYPE)ordTp == Order::TYPE::ATTACK && aimedAtTarget)
|
||||
fire(unit->getOrder(0));
|
||||
if(aimedAtTarget) fire(unit->getOrder(0));
|
||||
}
|
||||
else{
|
||||
Vector3 dir = (
|
||||
@@ -204,7 +209,20 @@ namespace battleship{
|
||||
}
|
||||
|
||||
void Weapon::updateTarget(GameObject *target){
|
||||
target->getDestructable()->takeDamage(damage);
|
||||
Destructable *destr = target->getDestructable();
|
||||
|
||||
switch(type){
|
||||
case Type::FREEZER:
|
||||
if(target->getType() == GameObject::Type::UNIT && ((Unit*)target)->getUnitClass() == UnitClass::ICE_SHEET)
|
||||
((Structure*)target)->incrementBuildStatus();
|
||||
else
|
||||
destr->setFreezeStatus(destr->getFreezeStatus() + 1);
|
||||
|
||||
break;
|
||||
default:
|
||||
destr->takeDamage(damage);
|
||||
break;
|
||||
}
|
||||
|
||||
if(target->getType() == GameObject::Type::UNIT)
|
||||
unit->getPlayer()->updateGameStats((Unit*)target);
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace battleship{
|
||||
|
||||
class Weapon{
|
||||
public:
|
||||
enum class Type{FREEZER = 1};
|
||||
enum class Type{DAMAGE = 0, FREEZER = 1};
|
||||
|
||||
struct Component{
|
||||
vb01::Node *node = nullptr;
|
||||
@@ -46,6 +46,7 @@ namespace battleship{
|
||||
inline int getMinRange(){return minRange;}
|
||||
inline int getMaxRange(){return maxRange;}
|
||||
inline Unit* getUnit(){return unit;}
|
||||
inline Type getType(){return type;}
|
||||
inline Order::TYPE getOrderType(){return orderType;}
|
||||
private:
|
||||
Unit *unit = nullptr;
|
||||
@@ -58,6 +59,7 @@ namespace battleship{
|
||||
vb01::Vector3 projPos, initUnitSpaceDir;
|
||||
vb01::Node *projPar = nullptr;
|
||||
static std::string LASER_FLAG;
|
||||
Type type = Type::DAMAGE;
|
||||
|
||||
void initProjectileData(sol::table);
|
||||
void initNodes(sol::table);
|
||||
|
||||
Reference in New Issue
Block a user