made minimap display fog and units
This commit is contained in:
parent
910afee07d
commit
c38a116833
8 changed files with 91 additions and 21 deletions
|
@ -192,14 +192,49 @@ Defeat
|
|||
|
||||
[command]
|
||||
[message]
|
||||
id=choice15
|
||||
description=Delfador
|
||||
message="We have a choice to make. To the north past the Orcs are the snow plains. To the south, beyond the armies of the Walking Dead is the Swamp of Dread."
|
||||
id=choice15a
|
||||
description=Kalenz
|
||||
message="I can tell where we are. By the river that is known as Longlier to men, but as Arkan-thoria in my people's ancient tongue. The home of my people lies to the East of here."
|
||||
[/message]
|
||||
[message]
|
||||
id=choice16
|
||||
id=choice15b
|
||||
description=Konrad
|
||||
message="Then perhaps we should head East, along the river, and seek refuge and rest there for a time?"
|
||||
[/message]
|
||||
[message]
|
||||
id=choice15c
|
||||
description=Kalenz
|
||||
message="We certainly must go either north or south, for we must get out of this valley. Then we will be able to seek refuge in the ancient home of the North Elves."
|
||||
message="We should indeed seek refuge there, my lord, but not by going East along the river. Its name means 'The River of Bones'. Great and evil creatures lurk along its banks. Its waters are not fit to drink, and it passes over the Cliffs of Thoria. No man or elf has passed over the Cliffs and survived for a millenia! No, prince, we must choose another way."
|
||||
[/message]
|
||||
[message]
|
||||
id=choice15d
|
||||
description=Konrad
|
||||
message="Then which way should we go, Kalenz?"
|
||||
[/message]
|
||||
[message]
|
||||
id=choice15e
|
||||
description=Kalenz
|
||||
message="There are two paths we can take which avoid the river. We can travel North, through the ancient home of my people and then veer East, to where they now live, or we can go to the South, and pass through the Swamps, before turning to the East, and finally to the North. We would have to cross the river one more time if we choose that route, but I know a safe place we can cross at."
|
||||
[/message]
|
||||
[message]
|
||||
id=choice15f
|
||||
description=Konrad
|
||||
message="And will you come with us to seek refuge with the North Elves, princess?"
|
||||
[/message]
|
||||
[message]
|
||||
id=choice15g
|
||||
description=Li'sar
|
||||
message="If the Elves will promise me refuge and safe passage, then I will go."
|
||||
[/message]
|
||||
[message]
|
||||
id=choice15h
|
||||
description=Kalenz
|
||||
message="That we will, princess. Even thought you are the daughter of the Queen, who is our enemy, we shall not harm you on this encounter, for you have helped us."
|
||||
[/message]
|
||||
[message]
|
||||
id=choice15
|
||||
description=Delfador
|
||||
message="So, we have a choice to make. To the north past the Orcs are the ancient snow plains of the Elves. To the south, beyond the armies of the Walking Dead are the dreaded swamps."
|
||||
[/message]
|
||||
[/command]
|
||||
[/event]
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
#macro which will let you go {GOLD x y z} to set
|
||||
#the gold depending on easy/medium/hard - x/y/z
|
||||
|
||||
#define GOLD ON_EASY ON_MEDIUM ON_HARD
|
||||
#define GOLD ON_EASY ON_NORMAL ON_HARD
|
||||
#ifdef EASY
|
||||
gold={ON_EASY}
|
||||
#endif
|
||||
|
||||
#ifdef MEDIUM
|
||||
gold={ON_MEDIUM}
|
||||
#ifdef NORMAL
|
||||
gold={ON_NORMAL}
|
||||
#endif
|
||||
|
||||
#ifdef HARD
|
||||
|
@ -17,13 +17,13 @@ gold={ON_HARD}
|
|||
#endif
|
||||
#enddef
|
||||
|
||||
#define INCOME ON_EASY ON_MEDIUM ON_HARD
|
||||
#define INCOME ON_EASY ON_NORMAL ON_HARD
|
||||
#ifdef EASY
|
||||
income={ON_EASY}
|
||||
#endif
|
||||
|
||||
#ifdef MEDIUM
|
||||
income={ON_MEDIUM}
|
||||
#ifdef NORMAL
|
||||
income={ON_NORMAL}
|
||||
#endif
|
||||
|
||||
#ifdef HARD
|
||||
|
|
|
@ -218,7 +218,7 @@ std::pair<location,location> choose_move(
|
|||
for(std::vector<target>::iterator tg = targets.begin(); tg != targets.end(); ++tg) {
|
||||
assert(map.on_board(tg->loc));
|
||||
const paths::route cur_route = a_star_search(u->first,tg->loc,
|
||||
minimum(tg->value/best_rating,100.0),cost_calc);
|
||||
minimum(tg->value/best_rating,500.0),cost_calc);
|
||||
const double rating = tg->value/cur_route.move_left;
|
||||
std::cerr << tg->value << "/" << cur_route.move_left << " = " << rating << "\n";
|
||||
if(best_target == targets.end() || rating > best_rating) {
|
||||
|
|
|
@ -1632,7 +1632,7 @@ void display::blit_surface(int x, int y, SDL_Surface* surface)
|
|||
SDL_Surface* display::getMinimap(int w, int h)
|
||||
{
|
||||
if(minimap_ == NULL)
|
||||
minimap_ = image::getMinimap(w,h,map_,team_valid() ? &teams_[currentTeam_] : NULL);
|
||||
minimap_ = image::getMinimap(w,h,map_,team_valid() ? &teams_[currentTeam_] : NULL, &units_);
|
||||
|
||||
sdl_add_ref(minimap_);
|
||||
return minimap_;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "game_config.hpp"
|
||||
#include "image.hpp"
|
||||
#include "display.hpp"
|
||||
#include "font.hpp"
|
||||
#include "sdl_utils.hpp"
|
||||
#include "team.hpp"
|
||||
#include "util.hpp"
|
||||
|
@ -284,7 +285,7 @@ SDL_Surface* get_image_dim(const std::string& filename, size_t x, size_t y)
|
|||
return surf;
|
||||
}
|
||||
|
||||
SDL_Surface* getMinimap(int w, int h, const gamemap& map, const team* tm)
|
||||
SDL_Surface* getMinimap(int w, int h, const gamemap& map, const team* tm, const unit_map* units)
|
||||
{
|
||||
SDL_Surface* minimap = NULL;
|
||||
if(minimap == NULL) {
|
||||
|
@ -306,9 +307,14 @@ SDL_Surface* getMinimap(int w, int h, const gamemap& map, const team* tm)
|
|||
SDL_Rect minirect = {0,0,scale,scale};
|
||||
for(int y = 0; y != map.y(); ++y) {
|
||||
for(int x = 0; x != map.x(); ++x) {
|
||||
|
||||
SDL_Surface* surf = NULL;
|
||||
scoped_sdl_surface scoped_surface(NULL);
|
||||
|
||||
if(map.on_board(gamemap::location(x,y))) {
|
||||
const gamemap::location loc(x,y);
|
||||
if(map.on_board(loc)) {
|
||||
const bool shrouded = tm != NULL && tm->shrouded(x,y);
|
||||
const bool fogged = tm != NULL && tm->fogged(x,y);
|
||||
const gamemap::TERRAIN terrain = shrouded ? gamemap::VOID_TERRAIN : map[x][y];
|
||||
cache_map::iterator i = cache.find(terrain);
|
||||
|
||||
|
@ -321,14 +327,34 @@ SDL_Surface* getMinimap(int w, int h, const gamemap& map, const team* tm)
|
|||
continue;
|
||||
}
|
||||
|
||||
SDL_Surface* const minitile = scale_surface(tile,scale,scale);
|
||||
i = cache.insert(cache_map::value_type(terrain,minitile)).first;
|
||||
surf = scale_surface(tile,scale,scale);
|
||||
|
||||
if(units != NULL && !fogged) {
|
||||
const unit_map::const_iterator u = units->find(loc);
|
||||
if(u != units->end()) {
|
||||
const SDL_Color& colour = font::get_side_colour(u->second.side());
|
||||
SDL_Rect rect = {0,0,surf->w,surf->h};
|
||||
const short col = SDL_MapRGB(surf->format,colour.r,colour.g,colour.b);
|
||||
SDL_FillRect(surf,&rect,col);
|
||||
}
|
||||
|
||||
//we're not caching the surface, so make sure
|
||||
//that it gets freed after use
|
||||
scoped_surface.assign(surf);
|
||||
} else if(fogged) {
|
||||
adjust_surface_colour(surf,-50,-50,-50);
|
||||
scoped_surface.assign(surf);
|
||||
} else {
|
||||
i = cache.insert(cache_map::value_type(terrain,surf)).first;
|
||||
}
|
||||
} else {
|
||||
surf = i->second;
|
||||
}
|
||||
|
||||
assert(i != cache.end());
|
||||
assert(surf != NULL);
|
||||
|
||||
SDL_Rect maprect = {x*scale,y*scale,0,0};
|
||||
SDL_BlitSurface(i->second, &minirect, minimap, &maprect);
|
||||
SDL_BlitSurface(surf, &minirect, minimap, &maprect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define IMAGE_HPP_INCLUDED
|
||||
|
||||
#include "map.hpp"
|
||||
#include "unit.hpp"
|
||||
|
||||
#include "SDL.h"
|
||||
#include <string>
|
||||
|
@ -62,7 +63,7 @@ namespace image {
|
|||
SDL_Surface* get_image_dim(const std::string& filename, size_t x, size_t y);
|
||||
|
||||
//the surface returned must be freed by the user
|
||||
SDL_Surface* getMinimap(int w, int h, const gamemap& map_, const team* tm=NULL);
|
||||
SDL_Surface* getMinimap(int w, int h, const gamemap& map_, const team* tm=NULL, const unit_map* units=NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -159,7 +159,13 @@ LEVEL_RESULT play_level(game_data& gameinfo, config& game_config,
|
|||
}
|
||||
}
|
||||
|
||||
const gamemap::location& start_pos = map.starting_position(new_unit.side());
|
||||
//see if the side specifies its location. Otherwise start it at the map-given
|
||||
//starting position
|
||||
const std::string& has_loc = (**ui)["x"];
|
||||
gamemap::location start_pos(**ui);
|
||||
|
||||
if(has_loc.empty())
|
||||
start_pos = map.starting_position(new_unit.side());
|
||||
|
||||
if(!start_pos.valid() && new_unit.side() == 1) {
|
||||
throw gamestatus::load_game_failed("No starting position for side 1");
|
||||
|
|
|
@ -845,6 +845,8 @@ void turn_info::undo()
|
|||
gui_.set_route(NULL);
|
||||
|
||||
recorder.undo();
|
||||
|
||||
clear_shroud(gui_,map_,gameinfo_,units_,teams_,team_num_-1);
|
||||
}
|
||||
|
||||
void turn_info::redo()
|
||||
|
|
Loading…
Add table
Reference in a new issue