Skip to content

Commit

Permalink
# finished act 2
Browse files Browse the repository at this point in the history
+ new enemy Type
# only health, energy and energy regen can be upgraded
+ act 3
  • Loading branch information
Thanduriel committed Nov 4, 2018
1 parent 909acde commit 05100f5
Show file tree
Hide file tree
Showing 29 changed files with 277 additions and 54 deletions.
1 change: 1 addition & 0 deletions credits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ https://www.turbosquid.com/3d-models/fighter-1-3ds-free/526437
https://www.turbosquid.com/3d-models/ready-games-real-time-max-free/644656
https://www.turbosquid.com/3d-models/free-max-model-space/588767
https://www.turbosquid.com/3d-models/free-spaceship-fighter-3d-model/727670
https://free3d.com/3d-model/sci-fi-fighter-ship-v1--548422.html

sounds
explosion01 - https://freesound.org/people/Quaker540/sounds/245372/
Expand Down
Binary file added models/advanced_ship2.wim
Binary file not shown.
Binary file added models/advanced_ship2bm.wii
Binary file not shown.
10 changes: 6 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ AccForward [W] - temporarly accelerate
AccBackward [S]
AdjustTargetAcc[Shift] - hold in combination with AccForward/AccBackward
to change the target speed that will be held
Thrust[A/D] - make a quick jump left or right
Brake[Tab] - Set the target speed to zero
Fire[LeftMouse] - fires weapons in the first group targeting the ray of the cursor
FireOther[RightMouse] - fires weapons in the second group
Expand All @@ -43,7 +44,8 @@ RollCCW[E]
Inventory [I] - opens/closes the inventory
SwitchTactical[Space] - once unlocked switches to the tactical targeting
mode that allows usage of special weapons
LockTarget[R] - locks on a ship closest to the center of the screen
LockTarget[R] - locks on a ship closest to the center of the screen
CycleTarget[T] - in tactical: jump with the camera to the locked ship
Pause[P] - opens the pause menu

MECHANICS ##############################
Expand All @@ -61,10 +63,10 @@ of the screen is visible.

rocket launchers
One type of weapon fires homing and accelerating missiles.
The target is always the last ship that was focused in the center of the screen.
The target is always the locked ship, marked by a red indicator.
When something is in the focus the two arrows go outwards.



If you are having trouble or just want to mess around press F5 to generate weapons
out of thin air!
With cheats enabled in the config you can use F5 and F6 to generate some
random weapons and shields!
24 changes: 21 additions & 3 deletions ships.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,36 @@
"MinSpeed" : -5.0,
"AngularSpeed" : 0.5
},
"Corvette": {
"Mesh": "advanced_ship2",
"BoundingMesh": "advanced_ship2bm",
"WeaponSockets": ["LeftTurret", "RightTurret"],
"DriveSockets" : ["LeftDrive", "RightDrive"],
"Lights" : [],
"BaseHealth" : 250.0,
"Mass" : 2000.0,
"Energy" : 14.0,
"EnergyRecharge" : 3.25,
"Shield" : 40.0,
"ShieldRecharge" : 6.5,
"ShieldDelay" : 7.0,
"Thrust" : 42000.0,
"MaxSpeed" : 120.0,
"MinSpeed" : -15.0,
"AngularSpeed" : 2.5
},
"BattleShip": {
"Mesh": "battleship",
"BoundingMesh": "battleshipbm",
"WeaponSockets": ["LeftTurret", "RightTurret", "CenterTurret", "LeftTurrentBank", "LeftFrontTurret", "RightFrontTurret", "RightSideTurret"],
"DriveSockets" : ["LeftDrive", "RightDrive", "OuterLeftDrive", "OuterRightDrive", "InnerLeftDrive", "InnerRightDrive"],
"Lights" : [],
"BaseHealth" : 300.0,
"BaseHealth" : 800.0,
"Mass" : 10000.0,
"Energy" : 100.0,
"EnergyRecharge" : 7.25,
"Shield" : 40.0,
"ShieldRecharge" : 1.5,
"Shield" : 200.0,
"ShieldRecharge" : 8.5,
"ShieldDelay" : 12.0,
"Thrust" : 14000.0,
"MaxSpeed" : 45.0,
Expand Down
2 changes: 1 addition & 1 deletion src/control/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace Control
{
using namespace ei;
Vec3 forward = normalize(GetShip().GetRotationMatrix() * Vec3(0.0f, 0.0f, 1.0f));
Ray& ray = Ray(GetShip().GetPosition() + forward * 10.0f, forward);
Ray& ray = Ray(GetShip().GetPosition() + forward * 25.0f, forward);
Game::Actor* hitObj = s_sceneGraph->RayCast(ray, m_minDistance);
if (hitObj && hitObj != &**m_target)
GetShip().SetTargetAngularVelocity(GetShip().GetRotationMatrix() * Vec3(1.0f, 0.0f, 0.0f));
Expand Down
2 changes: 1 addition & 1 deletion src/control/kamikazecontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace Control
Vec3 delta = target->GetPosition() - GetShip().GetPosition();
Vec3 forward = GetShip().GetRotationMatrix() * Vec3(0.0f, 0.0f, 1.0f);

if (dot(delta, forward) > 0.0f)
if (lensq(delta) < 500.f*500.f && dot(delta, forward) > 0.0f)
{
float angle = acosf(clamp(dot(normalize(delta), forward), -1.0f, 1.0f));
if (angle < ei::PI / 4.0f)
Expand Down
37 changes: 21 additions & 16 deletions src/control/playercontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace Control
using namespace ei;

bool PlayerController::HAS_AIM_ASSIST;
bool PlayerController::ENABLE_CHEASTS = false;

const float TACTICALCAM_DIST = 52.f;
const float TACTICALCAM_ANGLE = PI / 3.2f;
Expand Down Expand Up @@ -158,25 +159,29 @@ namespace Control
if (InputManager::IsVirtualKey(_key, VirtualKey::BRAKE))
m_targetSpeed = 0.f;

if (InputManager::IsVirtualKey(_key, VirtualKey::LOCK_TARGET))
m_lookForTarget = true;

// test stuff
if (_key == GLFW_KEY_F5)
if (ENABLE_CHEASTS)
{
// static uint32_t count = 2;
// ++count;
Generators::WeaponGenerator gen;
Game::Weapon* w = gen.Generate(10.f, 4.f);
Game::FactoryActor::GetThreadLocalInstance().Add(*w);
m_ship.GetInventory().Add(*w);
}
else if (_key == GLFW_KEY_F6)
{
Generators::ShieldGenerator gen;
Game::Shield* w = gen.Generate(10.f, 4.f);
Game::FactoryActor::GetThreadLocalInstance().Add(*w);
m_ship.GetInventory().Add(*w);
if (_key == GLFW_KEY_F5)
{
// static uint32_t count = 2;
// ++count;
Generators::WeaponGenerator gen;
Game::Weapon* w = gen.Generate(11.f, 4.f);
Game::FactoryActor::GetThreadLocalInstance().Add(*w);
m_ship.GetInventory().Add(*w);
}
else if (_key == GLFW_KEY_F6)
{
Generators::ShieldGenerator gen;
Game::Shield* w = gen.Generate(11.f, 4.f);
Game::FactoryActor::GetThreadLocalInstance().Add(*w);
m_ship.GetInventory().Add(*w);
}
}
else if (InputManager::IsVirtualKey(_key, VirtualKey::LOCK_TARGET))
m_lookForTarget = true;
}

void PlayerController::KeyDown(int _key, int _modifiers)
Expand Down
1 change: 1 addition & 0 deletions src/control/playercontroller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace Control

void SetFocus(Game::Ship* _actor);
static bool HAS_AIM_ASSIST;
static bool ENABLE_CHEASTS;
private:
enum struct TargetingMode
{
Expand Down
10 changes: 8 additions & 2 deletions src/control/turtlecontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,15 @@ namespace Control

GetShip().SetTargetAngularVelocity(Vec3(0.0f, 0.0f, 0.0f));
Vec3 delta = target->GetPosition() - GetShip().GetPosition();
if (len(delta) < m_minDistance)
const float dist = len(delta);
if (dist < m_minDistance)
GetShip().SetSpeed(-10.0f);
else if (len(delta) > m_maxDistance)
else if (dist > 1000.f)
{
RotateTowards(Vec3(0.f));
GetShip().SetSpeed(30.f);
}
else if (dist > m_maxDistance)
GetShip().SetSpeed(10.0f);
else
GetShip().SetSpeed(0.0f);
Expand Down
6 changes: 3 additions & 3 deletions src/control/waspcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ namespace Control
{
m_target = _target;
m_minDistance = 75.0f;
m_maxDistance = 250.0f;
m_maxDistance = _ship.GetMaxSpeed() * 4.5f;
m_maxFollowTime = 5.0f;
m_evasionTime = 5.0f;
GetShip().SetSpeed(50.0f);
GetShip().SetSpeed(120.0f);
// GetShip().SetAngularAcceleration(2.0f);
GetShip().SetWeaponTarget(**_target);
m_hud.AddIndicator(this->GetShip(), _name);
Expand Down Expand Up @@ -115,7 +115,7 @@ namespace Control
Vec3 delta = target->GetPosition() - GetShip().GetPosition();
Vec3 forward = GetShip().GetRotationMatrix() * Vec3(0.0f, 0.0f, 1.0f);

if (dot(delta, forward) > 0.0f)
if (lensq(delta) < 500.f*500.f && dot(delta, forward) > 0.0f)
{
float angle = acosf(clamp(dot(normalize(delta), forward), -1.0f, 1.0f));
if (angle < ei::PI / 4.0f)
Expand Down
2 changes: 2 additions & 0 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Wimp_s::Wimp_s()
// load other properties
auto& cgame = m_config["Game"];
Control::PlayerController::HAS_AIM_ASSIST = cgame["AimAssist"s];
Control::PlayerController::ENABLE_CHEASTS = cgame["Cheats"s];
SetTargetFPS(cgraphic["TargetFPS"s].Get(144.f));

m_gameStates.emplace_back(new GameStates::MainMenuState());
Expand Down Expand Up @@ -208,6 +209,7 @@ void Wimp_s::BuildDefaultConfig()

auto& cgame = m_config[std::string("Game")];
cgame["AimAssist"s] = false;
cgame["Cheats"s] = false;

auto& csound = m_config["Sound"];
csound["MasterVolume"s] = 1.0;
Expand Down
4 changes: 2 additions & 2 deletions src/gameplay/elements/ship.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ namespace Game
{
// npcs can have items equipped that are not in there inventory
for (auto& socket : m_weaponSockets)
if (Weapon* w = static_cast<Weapon*>(socket.GetAttached()); w && m_inventory.Find(*w))
if (Weapon* w = static_cast<Weapon*>(socket.GetAttached()); w && !m_inventory.Find(*w))
w->Destroy();
if (m_shieldItem && !m_inventory.Find(*m_shieldItem)) m_shieldItem->Destroy();
// leave items behind
Expand Down Expand Up @@ -152,7 +152,7 @@ namespace Game
m_shield -= dmgAbsorbed;

const float finalDamage = remainingDmg * (_type == DamageType::Physical ? 1.5f : 1.f);
if (m_controller) m_controller->OnDamageTaken(finalDamage, _source, _type);
if (m_controller) m_controller->OnDamageTaken(_amount, _source, _type);
return finalDamage;
}

Expand Down
1 change: 0 additions & 1 deletion src/gameplay/events/01_intro/act01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ namespace Acts {
Model& planet = *new Model("planet", PLANET_POSITION, ei::qidentity());
planet.SetAngularVelocity(Vec3(0.01f, 0.00f, 0.01f));
m_sceneGraph.Add(planet);
_player.SetSpecialMove(*new Game::BlackHoleGenerator(30.f));

// --- events --------------------------------------- //
auto AfinishAct = CREATE_ACTION
Expand Down
74 changes: 68 additions & 6 deletions src/gameplay/events/02_delivery/act02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,105 @@
#include "gamestates/huds/mainhud.hpp"
#include "control/waspcontroller.hpp"
#include "control/turtlecontroller.hpp"
#include "gameplay/elements/shipsystems/specialmove.hpp"

namespace Game {
namespace Acts {

using namespace Utils;
using namespace ei;
using namespace Generators;

const Vec3 PLAYER_SPAWN = Vec3(0.f);
const Vec3 MEETING_POSITION = Vec3(100.f, 600.f, 3000.f);
const Vec3 PLANET_POSITION = Vec3(1000.f, 3138.f, 15000.f);
const Vec3 ASTEROID_FIELD_POSITION = Vec3(1800.f, 2400.f, 4000.f);
const Vec3 ESCAPE_POSITION = ASTEROID_FIELD_POSITION + Vec3(10.f, 370.f, 140.f);


Act02::Act02(SceneGraph& _sceneGraph, Ship& _player, GameStates::MainHud& _hud)
: Map(_sceneGraph, _player, _hud),
m_finishDescription("You won! There is nothing left to do.")
m_finishDescription("You won! There is nothing left to do."),
m_asteroids(ASTEROID_FIELD_POSITION, 400.f, 0x7c23e)
{
SetupPlayer(_player, PLAYER_SPAWN);
Actor::ConstHandle playerHandle = _player.GetHandle();

m_sceneGraph.Add(*new Sun(Vec3(-3457.f, -1500.f, 20000.f), 3300.f));
Graphic::LightSystem::SetDominantLight(ei::normalize(Vec3(-3457.f, -1500.f, 20000.f) - PLAYER_SPAWN));
Ship& boss = CreateShip("BattleShip", MEETING_POSITION, 7, 13.f);
Ship& boss = CreateShip("BattleShip", MEETING_POSITION, 7, 16.f);
Actor::Handle bossHandle = boss.GetHandle();

/* Model& largeAsteroid1 = *new Model("asteroid03", ASTEROID_FIELD_POSITION, ei::qidentity(), 10000.f);
m_sceneGraph.Add(largeAsteroid1);
Model& largeAsteroid2 = *new Model("asteroid03", ASTEROID_FIELD_POSITION - Vec3(100.f, 50.f, 13.f), g_random.Rotation(), 10000.f);
m_sceneGraph.Add(largeAsteroid2);
Model& largeAsteroid3 = *new Model("asteroid03", ASTEROID_FIELD_POSITION + Vec3(10.f, 150.f, 20.f), g_random.Rotation(), 10000.f);
m_sceneGraph.Add(largeAsteroid3);*/
m_asteroids.Generate(1400, { });

// background
Model& planet = *new Model("planet", PLANET_POSITION, ei::qidentity(), 10000.f, "planet1");
planet.SetAngularVelocity(Vec3(0.01f, 0.02f, 0.0f));
m_sceneGraph.Add(planet);

_hud.SetMessageAnimation(true);
_player.SetSpecialMove(*new Game::BlackHoleGenerator(30.f));
// events in reverse order of execution
auto AfinishAct = CREATE_ACTION
{
FinishMap(Level::Act03);
};

auto AleaveSystem = CREATE_ACTION
{
CREATE_OBJECTIVE5(Conditions::IsClose, AfinishAct, "leave the system",
_player, ESCAPE_POSITION, 50.f);
};

auto Anothing = CREATE_ACTION
{};

auto AlastAttack = CREATE_ACTION
{
const Vec3 playerPos = _player.GetPosition();
const Vec3 playerLeft = _player.GetRotationMatrix() * Vec3(-1.f, 0.f, 0.f);
Vec3 spawnPos = playerPos + playerLeft * m_randomGen.Uniform(80.f, 100.f);
CreateAsaultForce(std::vector<ShipType>{Dart, Fighter, Drone}, spawnPos, _player, 14, 14.0f, 1.5f);

Ship& ship = CreateShip("Corvette", playerPos - playerLeft * 155.f, 2, 16.f, 2.f, Drop::All);
CreateController<Control::WaspController>(ship, _player.GetHandle(), _hud, "Corvette");
CREATE_OBJECTIVE4(Conditions::OnDestroy, AleaveSystem, "destroy the pursuers",
std::vector<Actor::ConstHandle>({ ship.GetHandle() }), 1);
};

auto Aescape = CREATE_ACTION
{
CreateController<Control::TurtleController>(static_cast<Ship&>(**bossHandle), playerHandle, _hud, "BattleShip");
_player.SetEnergy(0.f);
CREATE_OBJECTIVE5(Conditions::IsClose, AlastAttack, "escape into the asteroid field",
_player, ASTEROID_FIELD_POSITION, 300.f);
ev->SetPosition(ESCAPE_POSITION);
_hud.AddIndicator(*ev, "asteroid field", Color8U(1.f, 1.f, 0.f));

// auto& timer = *new Event<Conditions::Timer>(AlastAttack, "", 15.f);
};

auto Aaction = CREATE_ACTION
{
_hud.AddObjective(m_finishDescription);
};

auto AturnAround = CREATE_ACTION
{
CreateController<Control::TurtleController>(static_cast<Ship&>(**bossHandle), playerHandle, _hud, "BattleShip");

CREATE_OBJECTIVE4(Conditions::OnDestroy, Aaction, "destroy the battleship",
std::vector<Actor::ConstHandle>({ bossHandle }), 1);
/* CREATE_OBJECTIVE4(Conditions::OnDestroy, Aaction, "destroy the battleship",
std::vector<Actor::ConstHandle>({ bossHandle }), 1);*/
_hud.ShowMessage("[Daymon Battleship] There you are. I trust that you didn't run into any trouble.");
_hud.ShowMessage("[Doomwhisper] Nothing unusual. Once i've received the payment the object is yours and you'll never hear from me again.");
auto& aggroTimer = *new Event<Conditions::Timer>(Aescape, "", 14.f);
m_sceneGraph.Add(aggroTimer);
_hud.ShowMessage("[Daymon Battleship] I'm afraid that there has been a change of plan. It involves eliminating risks.");
};

auto& ev = *new Event<Conditions::IsClose>(AturnAround, "reach the rendezvous coordinates", _player, MEETING_POSITION, 250.f);
Expand All @@ -59,12 +119,14 @@ namespace Acts {
const Vec3 playerPos = _player.GetPosition();
const Vec3 playerLeft = _player.GetRotationMatrix() * Vec3(-1.f, 0.f, 0.f);
Vec3 spawnPos = playerPos + playerLeft * m_randomGen.Uniform(80.f, 100.f);
CreateAsaultForce(std::vector<ShipType>{Dart, Fighter}, spawnPos, _player, 12, 11.5f, 1.5f);
CreateAsaultForce(std::vector<ShipType>{Dart, Fighter}, spawnPos, _player, 12, 13.5f, 1.5f);
};

auto& pirateTrigger = *new Event<Conditions::IsClose>(pirateAttack2, "", _player, MEETING_POSITION, 1000.f);
m_sceneGraph.Add(pirateTrigger);

/**/

auto pirateAttack = CREATE_ACTION
{
const Vec3 playerPos = _player.GetPosition();
Expand Down
2 changes: 2 additions & 0 deletions src/gameplay/events/02_delivery/act02.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "../event.hpp"
#include "../helpers.hpp"
#include "generators/asteroidfield.hpp"

namespace GameStates {
class MainHud;
Expand All @@ -18,6 +19,7 @@ namespace Game {

private:
BaseEvent m_finishDescription;
Generators::AsteroidField m_asteroids;
};
}
}
Loading

0 comments on commit 05100f5

Please sign in to comment.