Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/base/spacemine.cc18
-rw-r--r--src/game/base/weapon.cc4
-rw-r--r--src/game/base/weapon.h12
3 files changed, 31 insertions, 3 deletions
diff --git a/src/game/base/spacemine.cc b/src/game/base/spacemine.cc
index 75fe8fa..fbbca51 100644
--- a/src/game/base/spacemine.cc
+++ b/src/game/base/spacemine.cc
@@ -37,8 +37,11 @@ SpaceMine::SpaceMine() : EntityDynamic()
}
}
*/
+ // FIXME should be loaded from the Weapon Info
set_shape(core::Entity::Sphere);
+ set_modelname("maps/static/cargopod001");
set_radius(0.10f);
+ spacemine_detonated_timestamp = 0;
// activate physics
set_mass(radius());
@@ -80,15 +83,28 @@ void SpaceMine::collision(core::Entity *other)
entity->body()->applyCentralImpulse(math::to_btVector3(explosion_direction * force ));
entity->body()->applyTorqueImpulse(math::to_btVector3(explosion_torque * force * 0.1f));
+
+ spacemine_detonated_timestamp = core::game()->time();
}
set_state(core::Entity::Destroyed);
- die();
+ // this method is a bullet callback, we can not reset() here
}
void SpaceMine::frame(const unsigned long elapsed)
{
EntityDynamic::frame(elapsed);
+
+ if (state() == core::Entity::Destroyed) {
+
+ if (body()) {
+ reset();
+ }
+
+ if (core::game()->time() - spacemine_detonated_timestamp > 5) {
+ die();
+ }
+ }
}
// main 'eject mine' function
diff --git a/src/game/base/weapon.cc b/src/game/base/weapon.cc
index 8eca691..7f816e2 100644
--- a/src/game/base/weapon.cc
+++ b/src/game/base/weapon.cc
@@ -152,14 +152,17 @@ bool Weapon::init()
if (weaponsini.got_section("mine")) {
weapon = new Weapon();
+ weapon->set_stackable(true);
count++;
} else if (weaponsini.got_section("cannon")) {
weapon = new Weapon();
+ weapon->set_stackable(false);
count++;
} else if (weaponsini.got_section("turret")) {
weapon = new Weapon();
+ weapon->set_stackable(false);
count++;
} else if (weaponsini.got_section()) {
@@ -190,6 +193,7 @@ Weapon::Weapon() : core::Info(weapon_infotype)
{
set_volume(1);
set_level(1);
+ set_stackable(false);
}
Weapon::~Weapon()
diff --git a/src/game/base/weapon.h b/src/game/base/weapon.h
index 4e99493..b263266 100644
--- a/src/game/base/weapon.h
+++ b/src/game/base/weapon.h
@@ -17,16 +17,22 @@ public:
Weapon();
~Weapon();
+ inline bool stackable() const {
+ return weapon_stackable;
+ }
+
inline int level() const {
return weapon_level;
}
+ inline void set_stackable(bool stackable) {
+ weapon_stackable = stackable;
+ }
+
inline void set_level(const int level) {
weapon_level = level;
}
-
-
/* --- static registry functions ---------------------------------- */
static Weapon *find(const std::string & label);
@@ -45,6 +51,8 @@ private:
static core::InfoType *weapon_infotype;
int weapon_level;
+
+ bool weapon_stackable;
};
} // namespace game