diff options
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/assets.cpp | 3 | ||||
| -rw-r--r-- | src/game/game.hpp | 5 | ||||
| -rw-r--r-- | src/game/unit_nest.cpp | 13 | ||||
| -rw-r--r-- | src/game/unit_soldier.cpp | 37 | ||||
| -rw-r--r-- | src/game/unit_spider.cpp | 19 | ||||
| -rw-r--r-- | src/game/units.cpp | 7 | 
6 files changed, 61 insertions, 23 deletions
diff --git a/src/game/assets.cpp b/src/game/assets.cpp index 0ec83c2..f92aae0 100644 --- a/src/game/assets.cpp +++ b/src/game/assets.cpp @@ -49,7 +49,6 @@ void load(void)  	soldier.pain.load("assets/units/soldier/pain.ogg");  	soldier.death.load("assets/units/soldier/death1.ogg");  	soldier.death.load("assets/units/soldier/death2.ogg"); -	soldier.gib_sound.load("assets/units/soldier/gibbing.ogg");  	soldier.step_stone.load("assets/units/soldier/step_stone_1.ogg");  	soldier.step_stone.load("assets/units/soldier/step_stone_2.ogg"); @@ -85,6 +84,8 @@ void load(void)  	fx.blood.load("assets/units/blood_", 4);  	fx.flash.load("assets/units/flash_", 1); +	fx.gibbing.load("assets/fx/gibbing.ogg"); +	fx.corpse_hit.load("assets/fx/corpse_hit.ogg");  	fx.explosion.load("assets/fx/explosion_", 7);  	fx.explosion_sound.load("assets/fx/explosion.ogg");  	fx.explosion_sound.volume = 12.0f; diff --git a/src/game/game.hpp b/src/game/game.hpp index c6d4b53..6d6e773 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -67,7 +67,7 @@ namespace game {  			render::animated_texture_t rocket;  			render::animated_texture_t avatar; -			audio::sound_t fire, step_stone, step_dirt, pain, death, gib_sound; +			audio::sound_t fire, step_stone, step_dirt, pain, death;  		} soldier_assets_t;  		typedef struct { @@ -89,6 +89,7 @@ namespace game {  		typedef struct {  			render::animated_texture_t blood, flash, explosion, ricochet, water_splash; +			audio::sound_t gibbing, corpse_hit;  			audio::sound_t explosion_sound, ricochet_sound, water_splash_sound;  		} fx_assets_t; @@ -259,6 +260,8 @@ namespace game {  		void render_to(render::state_t *render);  		void render_late_to(render::state_t *render); +		bool gibbed = false; +  		void on_think(void);  		void on_spawn(void) {};   		void on_wake(void) {}; diff --git a/src/game/unit_nest.cpp b/src/game/unit_nest.cpp index a52574a..fe4a077 100644 --- a/src/game/unit_nest.cpp +++ b/src/game/unit_nest.cpp @@ -81,6 +81,19 @@ void unit_nest_t::on_spawn(void)  void unit_nest_t::on_damage(unit_t *attacker)  { +	if (health < -30) { +		assets::fx.gibbing.play_3d(x); +		game->deletion_list.insert(this); +		return; +	} + +	if (health <= 0) { +		if (!dead) +			assets::fx.corpse_hit.play_3d(x); + +		return; +	} +  	if (attacker)  		game->hivemind_alert(x, 12.0f, true, attacker->x);  	else diff --git a/src/game/unit_soldier.cpp b/src/game/unit_soldier.cpp index 0ffe19f..e41278e 100644 --- a/src/game/unit_soldier.cpp +++ b/src/game/unit_soldier.cpp @@ -211,19 +211,36 @@ void unit_soldier_t::on_think(void)  void unit_soldier_t::on_damage(unit_t *attacker)  { -	assets::soldier.pain.play_3d(x); -} +	if (health < -30) { +		assets::fx.gibbing.play_3d(x); +		game->deletion_list.insert(this); +		return; +	} else if (health < -10) { +		render_size[0] = v2f_t(-0.5f, -1.2f); +		render_size[1] = v2f_t(+0.5f, +0.3f); -void unit_soldier_t::on_death(void) -{ -	if (health >= -10) { +		if (!gibbed) +			assets::fx.gibbing.play_3d(x); +		else +			assets::fx.corpse_hit.play_3d(x); + +		place(world, x); +		gibbed = true; +	} else if (health <= 0) {  		render_size[0] = v2f_t(-0.75f, -0.5f);  		render_size[1] = v2f_t(+0.75f, +0.5f); -		assets::soldier.death.play_3d(x); -	} else { -		assets::soldier.gib_sound.play_3d(x); -	} +		if (!dead) +			assets::soldier.death.play_3d(x); +		else +			assets::fx.corpse_hit.play_3d(x); + +		place(world, x); +	} else +		assets::soldier.pain.play_3d(x); +} +void unit_soldier_t::on_death(void) +{  	render_layer = render::LAYER_FLAT;  	cmodel.cflags = CF_BACKGROUND;  	place(world, x); @@ -278,7 +295,7 @@ void unit_soldier_t::render_to(render::state_t *render)  	} else {  		float phase = clamp<float>((game->now - death_time) * 5, 0, 0.9); -		if (health < -10) +		if (gibbed)  			render->render(phase, &assets::soldier.gibbing, render_bounds);  		else  			render->render(phase, &assets::soldier.dead, render_bounds); diff --git a/src/game/unit_spider.cpp b/src/game/unit_spider.cpp index 2838a8b..c6f5755 100644 --- a/src/game/unit_spider.cpp +++ b/src/game/unit_spider.cpp @@ -101,6 +101,19 @@ void unit_spider_t::on_think(void)  void unit_spider_t::on_damage(unit_t *attacker)  { +	if (health < -5) { +		assets::fx.gibbing.play_3d(x); +		game->deletion_list.insert(this); +		return; +	} + +	if (health <= 0) { +		if (!dead) +			assets::fx.corpse_hit.play_3d(x); + +		return; +	} +  	assets::spider.sounds.play_3d(x);  	if (attacker) @@ -113,12 +126,6 @@ void unit_spider_t::on_death(void)  {  	game->hivemind_alert(x, 16.0f, false, v2f_t(0, 0)); -	if (health < -5) { -		assets::soldier.gib_sound.play_3d(x); -		game->deletion_list.insert(this); -		return; -	} -  	render_layer = render::LAYER_FLAT;  	cmodel.cflags = CF_BACKGROUND;  	assets::spider.sounds.play_3d(x); diff --git a/src/game/units.cpp b/src/game/units.cpp index f1ee45e..c4bc8de 100644 --- a/src/game/units.cpp +++ b/src/game/units.cpp @@ -191,12 +191,9 @@ void unit_t::damage(int points, unit_t *attacker)  	bool alien;  	health -= points; -	if (health <= 0) +	on_damage(attacker); +	if (health <= 0 && !dead)  		die(attacker); -	else { -		wake(); -		on_damage(attacker); -	}  	switch (type) {  	case UNIT_SOLDIER:  | 
