Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2013-10-13 18:29:00 +0000
committerStijn Buys <ingar@osirion.org>2013-10-13 18:29:00 +0000
commit6e140025aab2c57b400c54a06b811875c196cede (patch)
treed8cd92201243a9b8751a3cc135d9065b8e48648f /src/game
parentadc3d4dbff2361da2ba9a8e0e0207546d474e29a (diff)
Added initial NPC class, added 'wingmen' engine function.
Diffstat (limited to 'src/game')
-rw-r--r--src/game/base/Makefile.am2
-rw-r--r--src/game/base/game.cc42
-rw-r--r--src/game/base/game.h1
-rw-r--r--src/game/base/ship.cc37
-rw-r--r--src/game/base/ship.h2
5 files changed, 68 insertions, 16 deletions
diff --git a/src/game/base/Makefile.am b/src/game/base/Makefile.am
index 544cbb6..3d6840a 100644
--- a/src/game/base/Makefile.am
+++ b/src/game/base/Makefile.am
@@ -10,6 +10,7 @@ noinst_HEADERS = \
faction.h \
jumppoint.h \
navpoint.h \
+ npc.h \
planet.h \
racetrack.h \
savegame.h \
@@ -28,6 +29,7 @@ libbase_la_SOURCES = \
game.cc \
jumppoint.cc \
navpoint.cc \
+ npc.cc \
planet.cc \
racetrack.cc \
savegame.cc \
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index 2b605a4..aa7fd07 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -9,6 +9,8 @@
#include <iomanip>
#include <assert.h>
+#include "math/mathlib.h"
+#include "sys/sys.h"
#include "auxiliary/functions.h"
#include "core/gameserver.h"
#include "core/parser.h"
@@ -22,6 +24,7 @@
#include "base/faction.h"
#include "base/navpoint.h"
#include "base/jumppoint.h"
+#include "base/npc.h"
#include "base/planet.h"
#include "base/savegame.h"
#include "base/spacemine.h"
@@ -31,8 +34,6 @@
#include "base/star.h"
#include "base/template.h"
#include "base/weapon.h"
-#include "math/mathlib.h"
-#include "sys/sys.h"
namespace game
{
@@ -557,6 +558,34 @@ void Game::func_give(core::Player *player, const std::string &args)
}
}
+// cheats
+void Game::func_wingmen(core::Player *player, const std::string &args)
+{
+ if (!Game::g_devel->value()) {
+ player->send("Cheats disabled");
+ return;
+ }
+
+ if (!player->control()) {
+ player->send("^WYou need to join the game first!");
+ return;
+ }
+
+ if (player->control()->moduletype() != ship_enttype)
+ return;
+
+ Ship * ship = static_cast<Ship *>(player->control());
+
+ std::istringstream is(args);
+ std::string str;
+
+ is >> str;
+ aux::to_label(str);
+
+ if (str.compare("add") == 0) {
+ NPC::add_wingman(ship);
+ }
+}
void Game::func_specs(core::Player *player, const std::string &args)
{
@@ -1038,7 +1067,7 @@ void Game::func_drop(core::Player *player, const std::string &args)
spacemine->set_color(ship->color());
spacemine->set_owner_id(player->id());
spacemine->set_color_second(ship->color_second());
- spacemine->set_location(ship->location() + ship->axis().forward() * -1.0f * (ship->radius() + spacemine->radius()));
+ spacemine->set_location(ship->location() - ship->axis().forward() * (ship->radius() + spacemine->radius()));
spacemine->set_axis(ship->axis());
spacemine->set_zone(ship->zone());
@@ -1589,7 +1618,10 @@ Game::Game() : core::Module("Project::OSiRiON", true)
func->set_info("beam nearby cargo pods in");
func = core::Func::add("give", Game::func_give);
- func->set_info("cheat functions");
+ func->set_info("cheat function to get items and ships");
+
+ func = core::Func::add("wingmen", Game::func_wingmen);
+ func->set_info("cheat function for wingmen control");
func = core::Func::add("specs", Game::func_specs);
func->set_info("change your current ship's engine specifications");
@@ -1598,7 +1630,7 @@ Game::Game() : core::Module("Project::OSiRiON", true)
func->set_info("[string] activate or deactivate hyperspace jump drive");
func = core::Func::add("impulse", Game::func_impulse);
- func->set_info("activate are deactive kinetic impulse drive");
+ func->set_info("toggle kinetic impulse drive");
func = core::Func::add("launch", Game::func_launch);
func->set_info("launch to space when docked");
diff --git a/src/game/base/game.h b/src/game/base/game.h
index aab28bc..3872303 100644
--- a/src/game/base/game.h
+++ b/src/game/base/game.h
@@ -135,6 +135,7 @@ private:
static void func_mount(core::Player *player, const std::string &args);
static void func_unmount(core::Player *player, const std::string &args);
static void func_beam(core::Player *player, const std::string &args);
+ static void func_wingmen(core::Player *player, const std::string &args);
/* ---- target functions ----------------------------------- */
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 4a77706..6c5598e 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -25,8 +25,6 @@ using math::degrees180f;
namespace game
{
-const float MIN_DELTA = 0.000001f;
-
Ship::Ship(core::Player *owner, const ShipModel *shipmodel) : core::EntityControlable()
{
assert(shipmodel);
@@ -207,16 +205,22 @@ void Ship::func_jump(std::string const &args)
helpstr.append("^N|^B");
helpstr.append((*it).second->label());
}
- owner()->send("Usage: jump [^B" + helpstr + "^N]");
+ if (owner()) {
+ owner()->send("Usage: jump [^B" + helpstr + "^N]");
+ }
return;
}
if (jumptargetzone == zone()) {
- owner()->send("Already in the " + jumptargetzone->name());
+ if (owner()) {
+ owner()->send("Already in the " + jumptargetzone->name());
+ }
return;
}
- owner()->send("Jumping to the " + jumptargetzone->name());
+ if (owner()) {
+ owner()->send("Jumping to the " + jumptargetzone->name());
+ }
set_zone(jumptargetzone);
//ship_jumpdrive_timer = 0;
@@ -233,14 +237,18 @@ void Ship::func_jump(std::string const &args)
} else {
if (!jumpdrive() && !Game::g_devel->value()) {
- owner()->send("This ship is not equiped with a hyperspace drive!");
+ if (owner()) {
+ owner()->send("This ship is not equiped with a hyperspace drive!");
+ }
return;
} else if (entity_state == core::Entity::Jump) {
return;
} else if (entity_state == core::Entity::JumpInitiate) {
- owner()->send("Jump aborted, hyperspace drive deactivated");
+ if (owner()) {
+ owner()->send("Jump aborted, hyperspace drive deactivated");
+ }
ship_jumpdrive_timer = 0;
entity_timer = 0;
entity_state = core::Entity::Normal;
@@ -269,14 +277,20 @@ JumpPoint * Ship::find_closest_jumppoint()
if (jumppoint && jumppoint->target()) {
if (Game::g_jumppointrange->value() < d) {
- owner()->send("Jumppoint out of range!");
+ if (owner()) {
+ owner()->send("Jumppoint out of range!");
+ }
return 0;
} else {
- owner()->send("Jumping to the " + jumppoint->target()->zone()->name());
+ if (owner()) {
+ owner()->send("Jumping to the " + jumppoint->target()->zone()->name());
+ }
return jumppoint;
}
} else {
- owner()->send("No jumppoints found!");
+ if (owner()) {
+ owner()->send("No jumppoints found!");
+ }
return 0;
}
@@ -299,8 +313,9 @@ void Ship::explode()
entity_thrust = 0;
if (owner()) {
- if (owner()->control() == this)
+ if (owner()->control() == this) {
owner()->set_view(this);
+ }
}
};
diff --git a/src/game/base/ship.h b/src/game/base/ship.h
index 4e95f5d..1de208d 100644
--- a/src/game/base/ship.h
+++ b/src/game/base/ship.h
@@ -16,6 +16,8 @@
namespace game
{
+const float MIN_DELTA = 0.000001f;
+
/**
* @brief A ship in the game, controled by a player
* */