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-21 20:49:58 +0000
committerStijn Buys <ingar@osirion.org>2012-11-21 20:49:58 +0000
commit5e4ef80dc29a69e1f5f185d1efab323af4a77292 (patch)
tree3f741a160a9f62d392ef0116df9f9925d55da557 /src/game/base/ship.cc
parent3dc60689b9327190eeecd42f6920299ef3e7b52c (diff)
Added get/set methods for the weapon-slot API.
Diffstat (limited to 'src/game/base/ship.cc')
-rw-r--r--src/game/base/ship.cc40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index dc039e4..7282fe1 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -88,9 +88,10 @@ Ship::Ship(core::Player *owner, const ShipModel *shipmodel) : core::EntityContro
for (core::Slots::iterator it = slots()->begin(); it != slots()->end(); it++) {
// default fire rate: 1 projectile / second
- (*it)->set_interval(1000);
- (*it)->set_lifespan(5000);
- (*it)->set_speed(5.0f);
+ (*it)->set_projectile_interval(1000);
+ (*it)->set_projectile_lifespan(5000);
+ (*it)->set_projectile_speed(5.0f);
+ (*it)->set_projectile_damage(10.0f);
}
}
@@ -442,6 +443,7 @@ void Ship::action (btScalar seconds)
entity_speed = Game::g_impulsespeed->value() * 0.01f;
body()->setLinearVelocity(math::to_btVector3(axis().forward() * entity_speed));
}
+ // FIXME set speed to 0 if below threshold
}
void Ship::collision(core::Entity *other)
@@ -867,27 +869,31 @@ void Ship::frame(const unsigned long elapsed)
EntityControlable::frame(elapsed);
+
+ // TODO move to core::
if (model() && slots() && (state() == core::Entity::Normal) && has_controlflag(core::EntityControlable::ControlFlagFire)) {
const float modelscale = radius() / model()->radius();
for (core::Slots::iterator it = slots()->begin(); it != slots()->end(); it++) {
// create projectiles
- if ((*it)->last_fired() + (*it)->interval() <= core::server()->timestamp()) {
- (*it)->set_last_fired(core::server()->timestamp());
- Projectile * projectile = new Projectile((*it)->lifespan());
- projectile->set_damage(10.0f);
- projectile->set_color(color());
- if (owner()) {
- projectile->set_ownerid(owner()->id());
+ if ((*it)->projectile_interval() > 0) {
+ if ((*it)->last_fired() + (*it)->projectile_interval() <= core::server()->timestamp()) {
+ (*it)->set_last_fired(core::server()->timestamp());
+ Projectile * projectile = new Projectile((*it)->projectile_lifespan());
+ projectile->set_damage((*it)->projectile_damage());
+ projectile->set_color(color());
+ 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->reset();
+ projectile->body()->setDamping(0.0f, 0.0f);
+ projectile->body()->setLinearVelocity(math::to_btVector3(projectile->axis().forward() * (*it)->projectile_speed()));
}
- projectile->set_zone(zone());
- projectile->set_axis(axis() * (*it)->axis());
- projectile->set_location(location() + (axis() * (*it)->location() * modelscale) + projectile->axis().forward() * projectile->radius());
-
- projectile->reset();
- projectile->body()->setDamping(0.0f, 0.0f);
- projectile->body()->setLinearVelocity(math::to_btVector3(projectile->axis().forward() * (*it)->speed()));
}
}
}