summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/assets.cpp3
-rw-r--r--src/game/decos.cpp37
-rw-r--r--src/game/game.cpp10
-rw-r--r--src/game/game.hpp11
-rw-r--r--src/game/unit_soldier.cpp6
5 files changed, 54 insertions, 13 deletions
diff --git a/src/game/assets.cpp b/src/game/assets.cpp
index 59cf89a..e8ad153 100644
--- a/src/game/assets.cpp
+++ b/src/game/assets.cpp
@@ -89,8 +89,11 @@ void load(void)
fx.explosion_sound.volume = 3.0f;
deco.stone.load("assets/deco/stone_", 1);
+ deco.stone_cracked.load("assets/deco/stone_cracked_", 1);
deco.eyething.load("assets/deco/eyething_", 2);
+ deco.eyething_dead.load("assets/deco/eyething_dead_", 2);
deco.spike.load("assets/deco/spike_", 1);
+ deco.spike_broken.load("assets/deco/spike_broken_", 1);
deco.spike_small.load("assets/deco/spike_small_", 1);
deco.wart.load("assets/deco/wart_", 1);
diff --git a/src/game/decos.cpp b/src/game/decos.cpp
index ebd8bb8..bbb1cee 100644
--- a/src/game/decos.cpp
+++ b/src/game/decos.cpp
@@ -32,6 +32,11 @@ static const struct {
{-0.4f, -0.4f}, {+0.4f, +0.4f}, 0.0
},
{
+ &assets::deco.stone_cracked,
+ {-0.4f, +0.1f}, {+0.4f, +0.4f}, CF_SOLID,
+ {-0.4f, -0.4f}, {+0.4f, +0.4f}, 0.0
+ },
+ {
&assets::deco.stone,
{-0.2f, +0.1f}, {+0.2f, +0.2f}, 0,
{-0.2f, -0.2f}, {+0.2f, +0.2f}, 0.0
@@ -42,11 +47,21 @@ static const struct {
{-0.4f, -1.2f}, {+0.4f, +0.4f}, 0.3
},
{
+ &assets::deco.eyething_dead,
+ {-0.4f, -0.4f}, {+0.4f, +0.4f}, 0,
+ {-0.4f, -1.2f}, {+0.4f, +0.4f}, 0.3
+ },
+ {
&assets::deco.spike,
{-0.4f, -0.4f}, {+0.4f, +0.4f}, CF_SOLID,
{-0.4f, -1.2f}, {+0.4f, +0.4f}, 0.0
},
{
+ &assets::deco.spike_broken,
+ {-0.4f, -0.4f}, {+0.4f, +0.4f}, 0,
+ {-0.4f, -1.2f}, {+0.4f, +0.4f}, 0.0
+ },
+ {
&assets::deco.spike_small,
{-0.2f, +0.1f}, {+0.2f, +0.2f}, 0,
{-0.2f, -0.6f}, {+0.2f, +0.2f}, 0.0
@@ -75,4 +90,26 @@ void deco_t::render_to(render::state_t *render)
decos[type].texture, render_bounds, sf::Color::White);
}
+void deco_t::damage(int points, unit_t *attacker)
+{
+ switch (type) {
+ case DECO_STONE:
+ type = DECO_STONE_CRACKED;
+ break;
+
+ case DECO_EYETHING:
+ type = DECO_EYETHING_DEAD;
+ break;
+
+ case DECO_SPIKE:
+ type = DECO_SPIKE_BROKEN;
+ break;
+
+ default:
+ break;
+ }
+
+ cmodel.cflags = decos[type].cflags;
+}
+
} // namespace game
diff --git a/src/game/game.cpp b/src/game/game.cpp
index bf9ec97..6e73811 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -397,7 +397,7 @@ void state_t::explosion(v2f_t x)
for (size_t i = 0; i < 30; i++) {
v2f_t end;
world::trace_t trace;
- unit_t *unit;
+ entity_t *ent;
int damage;
end = x + prng.unit_vec2() * 6.0f;
@@ -411,13 +411,9 @@ void state_t::explosion(v2f_t x)
if (trace.ent->type != ET_UNIT)
continue;
- unit = dynamic_cast<unit_t*>(trace.ent);
-
- if (unit->dead)
- continue;
-
+ ent = dynamic_cast<unit_t*>(trace.ent);
damage = pow(1 - trace.frac, 2.0f) * 40.0f;
- unit->damage(damage, nullptr);
+ ent->damage(damage, nullptr);
}
}
diff --git a/src/game/game.hpp b/src/game/game.hpp
index 8a6d2ba..a173b7e 100644
--- a/src/game/game.hpp
+++ b/src/game/game.hpp
@@ -88,8 +88,9 @@ namespace game {
} fx_assets_t;
typedef struct {
- render::animated_texture_t stone, eyething;
- render::animated_texture_t spike, spike_small;
+ render::animated_texture_t stone, stone_cracked;
+ render::animated_texture_t eyething, eyething_dead;
+ render::animated_texture_t spike, spike_broken, spike_small;
render::animated_texture_t wart;
} deco_assets_t;
@@ -152,6 +153,7 @@ namespace game {
void wake(void);
void sleep(void);
+ virtual void damage(int points, unit_t *attacker) = 0;
virtual void on_think(void) = 0;
virtual void on_spawn(void) = 0;
virtual void on_wake(void) = 0;
@@ -317,6 +319,7 @@ namespace game {
void on_think(void);
void on_spawn(void) {};
void on_wake(void) {};
+ void damage(int points, unit_t *attacker) {};
void render_late_to(render::state_t *render) {};
};
@@ -386,9 +389,12 @@ namespace game {
typedef enum {
DECO_STONE,
+ DECO_STONE_CRACKED,
DECO_STONE_SMALL,
DECO_EYETHING,
+ DECO_EYETHING_DEAD,
DECO_SPIKE,
+ DECO_SPIKE_BROKEN,
DECO_SPIKE_SMALL,
DECO_WART
} deco_type_t;
@@ -406,5 +412,6 @@ namespace game {
void on_think(void) {};
void on_spawn(void) {};
void on_wake(void) {};
+ void damage(int points, unit_t *attacker);
};
};
diff --git a/src/game/unit_soldier.cpp b/src/game/unit_soldier.cpp
index c6ed4dd..433f88d 100644
--- a/src/game/unit_soldier.cpp
+++ b/src/game/unit_soldier.cpp
@@ -107,10 +107,8 @@ void unit_soldier_t::shoot(v2f_t aim)
assets::soldier.fire.play_3d(x);
if (trace.hit && trace.ent) {
- if (trace.ent->type == ET_UNIT) {
- unit_t *unit = dynamic_cast<unit_t*>(trace.ent);
- unit->damage(3, this);
- }
+ entity_t *ent = dynamic_cast<entity_t*>(trace.ent);
+ ent->damage(3, this);
}
}