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>2008-11-09 11:43:28 +0000
committerStijn Buys <ingar@osirion.org>2008-11-09 11:43:28 +0000
commit9d39702824e8fae5127e09fb5a05b521b48cd028 (patch)
treea56fdfc6e85a2405461be22bc80e43b33c8b8b48 /src/game
parent6cd1a38f1d3a0a45846d63a75475400372af1277 (diff)
docking menus
Diffstat (limited to 'src/game')
-rw-r--r--src/game/base/base.cc63
-rw-r--r--src/game/base/base.h1
2 files changed, 53 insertions, 11 deletions
diff --git a/src/game/base/base.cc b/src/game/base/base.cc
index 7fa5299..ce5eb1c 100644
--- a/src/game/base/base.cc
+++ b/src/game/base/base.cc
@@ -11,6 +11,7 @@
#include "auxiliary/functions.h"
#include "core/gameserver.h"
#include "core/parser.h"
+#include "core/descriptions.h"
#include "filesystem/filesystem.h"
#include "filesystem/inifile.h"
#include "base/base.h"
@@ -54,11 +55,13 @@ void Base::func_join(core::Player *player, std::string const &args)
ship->set_zone(player->zone());
player->set_control(ship);
-/*
core::Entity *dock = ship->zone()->default_view();
- ship->entity_location.assign(dock->location() + (dock->axis().forward() * dock->radius()*2.0f));
- ship->entity_axis.assign(dock->axis());
-*/
+ if (dock) {
+ ship->entity_location.assign(dock->location() + (dock->axis().forward() * ((ship->radius()+ dock->radius())*2.0f)));
+ ship->entity_axis.assign(dock->axis());
+ ship->set_eventstate(core::Entity::Docked);
+ player->set_view(dock);
+ }
player->sound("game/buy-ship");
std::string message("^B");
@@ -118,15 +121,19 @@ void Base::func_buy(core::Player *player, std::string const &args)
player->remove_asset(player->control());
}
+ core::Entity *dock = player->view();
Ship * ship = new Ship(player, shipmodel);
ship->set_zone(player->zone());
- if (player->view()) {
- core::Entity *dock = player->view();
- ship->entity_location.assign(dock->location() + (dock->axis().forward() * dock->radius()*2.0f));
+ player->set_control(ship);
+
+ if (dock) {
+ player->control()->location().assign(dock->location());
+ player->control()->set_eventstate(core::Entity::Docked);
ship->entity_axis.assign(dock->axis());
+ ship->entity_axis.change_direction(180.0f);
+ player->set_view(dock);
}
- player->set_control(ship);
core::server()->broadcast("^B" + player->name() + " ^Bpurchased " + aux::article(shipmodel->name()));
player->sound("game/buy-ship");
@@ -200,7 +207,7 @@ void Base::func_dock(core::Player *player,core::Entity *entity)
if (player->control()->eventstate() == core::Entity::Docked)
return;
- if (math::distance(entity->location(), player->control()->location()) > 2.0f * entity->radius()) {
+ if (math::distance(entity->location(), player->control()->location()) > 2.0f * (entity->radius() + player->control()->radius())) {
player->send("^B" + entity->name() + " is out of range!");
return;
}
@@ -226,12 +233,43 @@ void Base::func_launch(core::Player *player, std::string const &args)
assert(player->view()->zone() == player->control()->zone());
core::Entity *dock = player->view();
- player->control()->entity_location.assign(dock->location() + (dock->axis().forward() * dock->radius()*2.0f));
+ player->control()->entity_location.assign(dock->location() + (dock->axis().forward() * (player->control()->radius()+ dock->radius())*2.0f));
player->control()->entity_axis.assign(dock->axis());
player->control()->set_eventstate(core::Entity::Normal);
player->set_view(0);
}
+// instantaniously goto a specified entity within the zone
+void Base::func_goto(core::Player *player, const std::string &args)
+{
+ if (!args.size())
+ return;
+
+ if (!g_devel->value())
+ return;
+
+ if (!player->control())
+ return;
+
+ std::string label(args);
+ aux::to_label(label);
+
+ core::Zone *zone = player->control()->zone();
+ for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it ++) {
+ core::Entity *dock = (*it);
+ std::string str(dock->label());
+ aux::to_label(str);
+ if (str.find(label) != std::string::npos) {
+ player->control()->entity_location.assign(dock->location() + (dock->axis().forward() * (player->control()->radius()+dock->radius())*2.0f));
+ player->control()->entity_axis.assign(dock->axis());
+ player->control()->entity_axis.change_direction(180.0f);
+ player->control()->set_eventstate(core::Entity::Normal);
+ player->set_view(0);
+ return;
+ }
+ }
+}
+
/* -- class Base -------------------------------------------------- */
Base::Base() : core::Module("base", "Project::OSiRiON", true)
@@ -285,6 +323,9 @@ void Base::init()
func = core::Func::add("launch", Base::func_launch);
func->set_info("launch to space when docked");
+ func = core::Func::add("goto", Base::func_goto);
+ func->set_info("[string] goto to an entity within the zone");
+
func = core::Func::add("@dock", Base::func_dock);
func->set_info("dock with target object");
@@ -556,7 +597,7 @@ bool Base::load_zone(core::Zone *zone)
} else if (zoneini.got_key_bool("dock", b)) {
if (b) {
entity->set_flag(core::Entity::Dockable);
- //core::Parser::read_entity_menu(entity, "zones/" + zone->label() + "/" + entity->label());
+ core::Descriptions::load_entity_menus(entity, "zones/" + zone->label() + "/" + entity->label());
} else {
entity->unset_flag(core::Entity::Dockable);
}
diff --git a/src/game/base/base.h b/src/game/base/base.h
index 6979335..926060c 100644
--- a/src/game/base/base.h
+++ b/src/game/base/base.h
@@ -94,6 +94,7 @@ private:
static void func_impulse(core::Player *player, std::string const &args);
static void func_dock(core::Player *player,core::Entity *entity);
static void func_launch(core::Player *player, std::string const &args);
+ static void func_goto(core::Player *player, const std::string &args);
};
}