Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-11-25 21:29:39 +0000
committerStijn Buys <ingar@osirion.org>2012-11-25 21:29:39 +0000
commit71503d65f1099d9f34010de98d377f8f2f5e474e (patch)
tree0e54c6dd9b80e9de86742185853b1c6d796ee2c8 /src/game/base/ship.cc
parent159716799ed0aebb3c30ca156a7c253030ab09b1 (diff)
Removed game::Projectile, added initial support for ship health.
Diffstat (limited to 'src/game/base/ship.cc')
-rw-r--r--src/game/base/ship.cc41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index fc01b5c..f874fa3 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -13,10 +13,11 @@
#include "core/gameserver.h"
#include "core/entity.h"
+#include "core/entityprojectile.h"
#include "base/game.h"
#include "base/ship.h"
-#include "base/projectile.h"
+
#include "base/spacemine.h"
using math::degrees360f;
@@ -530,10 +531,10 @@ void Ship::collision(core::Entity *other)
}
}
- } else if (other->moduletype() == projectile_enttype) {
+ } else if (other->type() == core::Entity::Projectile) {
// hit by projectile
- game::EntityProjectile *projectile = static_cast<EntityProjectile *>(other);
+ core::EntityProjectile *projectile = static_cast<core::EntityProjectile *>(other);
if (projectile->state() != core::Entity::Destroyed) {
ship_armor -= projectile->damage();
}
@@ -762,6 +763,9 @@ void Ship::frame(const unsigned long elapsed)
entity_thrust = 0;
entity_controlflags = 0;
}
+
+ // current health
+ entity_health = armor() * 100.0f / maxarmor();
/* -- SNAPPY ------------------------------------------ */
@@ -880,24 +884,31 @@ void Ship::frame(const unsigned long elapsed)
const float modelscale = radius() / model()->radius();
for (core::Slots::iterator it = slots()->begin(); it != slots()->end(); it++) {
+ core::Slot *slot = (*it);
+
// create projectiles
- if ( ((*it)->projectile_interval() > 0) && ((*it)->has_flag(core::Slot::Mounted)) && ((*it)->has_flag(core::Slot::Active))) {
- if ((*it)->last_fired() + (*it)->projectile_interval() <= core::server()->timestamp()) {
- (*it)->set_last_fired(core::server()->timestamp());
- EntityProjectile * projectile = new EntityProjectile((*it)->projectile_lifespan());
- projectile->set_damage((*it)->projectile_damage());
+ if (slot->has_flag(core::Slot::Mounted) && slot->item() && (slot->item()->info()->type() == Weapon::infotype())) {
+
+ const Weapon *weapon = static_cast<const Weapon *>(slot->item()->info());
+ if ((weapon->subtype() == Weapon::Cannon) && (weapon->projectile_interval() > 0) && (slot->last_fired() + weapon->projectile_interval() <= core::server()->timestamp())) {
+ slot->set_last_fired(core::server()->timestamp());
+
+ core::EntityProjectile *projectile = new core::EntityProjectile();
+
+ projectile->set_damage(weapon->damage());
+ projectile->set_lifespan(weapon->projectile_lifespan());
+ projectile->set_projectile_modelname(weapon->projectile_modelname());
projectile->set_color(color());
+ projectile->set_color_second(color_second());
+ projectile->set_zone(zone());
+ projectile->set_axis(axis() * slot->axis());
+ projectile->set_location(location() + (axis() * slot->location() * modelscale) + projectile->axis().forward() * projectile->radius());
if (owner()) {
projectile->set_ownerid(owner()->id());
}
- projectile->set_zone(zone());
- projectile->set_axis(axis() * (*it)->axis());
- projectile->set_location(location() + (axis() * (*it)->location() * modelscale) + projectile->axis().forward() * projectile->radius());
- projectile->set_modelname("maps/projectiles/" + (*it)->projectile_modelname());
-
+ projectile->set_speed(weapon->projectile_speed());
projectile->reset();
- projectile->body()->setDamping(0.0f, 0.0f);
- projectile->body()->setLinearVelocity(math::to_btVector3(projectile->axis().forward() * (*it)->projectile_speed()));
+
}
}
}