diff options
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/assets.cpp | 2 | ||||
| -rw-r--r-- | src/game/game.cpp | 2 | ||||
| -rw-r--r-- | src/game/game.hpp | 8 | ||||
| -rw-r--r-- | src/game/units.cpp | 23 | 
4 files changed, 20 insertions, 15 deletions
diff --git a/src/game/assets.cpp b/src/game/assets.cpp index 2a91a96..1034f92 100644 --- a/src/game/assets.cpp +++ b/src/game/assets.cpp @@ -17,7 +17,7 @@ void load(void)  	alien.walking.load("assets/units/alien/walking", 2, 2, 2);  	world::register_tile(TILE_DIRT, 0); -	world::register_tile(TILE_WALL, CF_SOLID | CF_HUMAN); +	world::register_tile(TILE_WALL, CF_SOLID);  	render::register_tile(TILE_DIRT, "assets/tiles/dirt.png");  	render::register_tile(TILE_WALL, "assets/tiles/wall.png");  } diff --git a/src/game/game.cpp b/src/game/game.cpp index 836b304..826f9e5 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -75,7 +75,7 @@ void state_t::command(v2f_t x)  		if (unit->dead)  			continue; -		if (!unit->start_moving(snap)) +		if (!unit->start_moving(snap, CF_SOLID))  			unit->say(text::get(text::SAY_NO_PATH));  		else  			unit->say(text::get(text::SAY_MOVING)); diff --git a/src/game/game.hpp b/src/game/game.hpp index 55e3c45..fdb2348 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -12,9 +12,9 @@ namespace game {  	};  	enum { -		CF_NONE  = 0, -		CF_SOLID = 1, -		CF_HUMAN = 2 +		CF_SOLID      = 1, +		CF_BODY       = 2, +		CF_BODY_SMALL = 4  	};  	extern size_t selection_cookie; @@ -79,7 +79,7 @@ namespace game {  		void place(world::world_t *world_, v2f_t x_);  		bool keep_moving(double speed); -		bool start_moving(v2f_t dst); +		bool start_moving(v2f_t dst, world::cflags_t cflags);  		bool awake = false;  		double wake_time = -INFINITY; diff --git a/src/game/units.cpp b/src/game/units.cpp index 5efab65..672e73f 100644 --- a/src/game/units.cpp +++ b/src/game/units.cpp @@ -139,8 +139,10 @@ bool unit_t::keep_moving(double speed)  	return rv;  } -bool unit_t::start_moving(v2f_t dst) +bool unit_t::start_moving(v2f_t dst, world::cflags_t cflags)  { +	world::cmodel_t rep; +  	if (!world) {  		printf("unit_t::start_moving: entity is not linked\n");  		return false; @@ -149,7 +151,10 @@ bool unit_t::start_moving(v2f_t dst)  	move.dst = dst;  	move.path.clear(); -	if (!world->find_path(x, move.dst, &cmodel, this, &move.path)) { +	rep.cflags = cflags; +	rep.bounds = cmodel.bounds; + +	if (!world->find_path(x, move.dst, &rep, this, &move.path)) {  		move.moving = false;  		return false;  	} @@ -166,7 +171,7 @@ void unit_t::damage(int points, unit_t *attacker)  {  	health -= points;  	if (health < 0) { -		game->interface->print(name + ": " + text::get(text::UNIT_DEATH) + "."); +		game->interface->print(name + " " + text::get(text::UNIT_DEATH) + ".");  		dead = true;  		death_time = game->now;  		cflags = 0; @@ -208,7 +213,7 @@ void unit_t::try_attack(unit_t *target)  human_t::human_t(game::state_t *game) : unit_t(game, UNIT_HUMAN)  { -	cflags = CF_HUMAN; +	cflags = CF_BODY;  	health = max_health = 20;  	size[0] = v2f_t(-0.4f, -0.4f);  	size[1] = v2f_t(+0.4f, +0.4f); @@ -271,7 +276,7 @@ void human_t::render_to(render::state_t *render)  alien_t::alien_t(game::state_t *game) : unit_t(game, UNIT_ALIEN)  { -	cflags = CF_SOLID; +	cflags = CF_BODY_SMALL;  	health = max_health = 4;  	size[0] = v2f_t(-0.2f, -0.2f);  	size[1] = v2f_t(+0.2f, +0.2f); @@ -282,7 +287,7 @@ alien_t::alien_t(game::state_t *game) : unit_t(game, UNIT_ALIEN)  void alien_t::wake(unit_t *by_whom)  { -	start_moving(by_whom->x); +	start_moving(by_whom->x, CF_SOLID);  	next_targetting = game->now + 0.4;  } @@ -351,10 +356,10 @@ void alien_t::think(void)  	if (game->now > next_targetting) {  		unit_t *target; -		target = find_target(world, x, 5.0f, UNIT_HUMAN); +		target = find_target(world, x, 10.0f, UNIT_HUMAN);  		if (target) { -			attack(target, 0.75f); -			start_moving(target->x); +			attack(target, 1.0f); +			start_moving(target->x, CF_SOLID);  		}  		next_targetting = game->now + 0.2;  | 
