added support for different colour depths
This commit is contained in:
parent
6e08e47951
commit
866ad17423
12 changed files with 84 additions and 40 deletions
|
@ -51,14 +51,27 @@ Defeat:
|
||||||
description=Agadla
|
description=Agadla
|
||||||
side=2
|
side=2
|
||||||
canrecruit=1
|
canrecruit=1
|
||||||
#ifdef HARD
|
recruit=Orcish Warrior,Orcish Assassin,Orcish Crossbow
|
||||||
recruit=Orcish Warrior,Orcish Assassin,Orcish Crossbow,Goblin Knight
|
|
||||||
#else
|
|
||||||
recruit=Orcish Warrior,Orcish Assassin,Orcish Crossbow,Wolf Rider
|
|
||||||
#endif
|
|
||||||
|
|
||||||
{GOLD 160 240 300}
|
{GOLD 120 200 300}
|
||||||
team_name=orcs
|
team_name=orcs
|
||||||
|
|
||||||
|
[ai]
|
||||||
|
recruitment_pattern=fighter,fighter,archer
|
||||||
|
leader_value=10.0
|
||||||
|
aggression=0.0
|
||||||
|
caution=1.0
|
||||||
|
[/ai]
|
||||||
|
|
||||||
|
[ai]
|
||||||
|
time_of_day=dusk
|
||||||
|
aggression=0.6
|
||||||
|
[/ai]
|
||||||
|
[ai]
|
||||||
|
time_of_day=first_watch,second_watch
|
||||||
|
aggression=0.7
|
||||||
|
caution=0.25
|
||||||
|
[/ai]
|
||||||
[/side]
|
[/side]
|
||||||
|
|
||||||
[side]
|
[side]
|
||||||
|
@ -67,18 +80,28 @@ Defeat:
|
||||||
side=3
|
side=3
|
||||||
canrecruit=1
|
canrecruit=1
|
||||||
|
|
||||||
#ifdef HARD
|
recruit=Skeleton Archer,Skeleton
|
||||||
recruit=Vampire Bat,Wraith,Skeleton Archer,Skeleton
|
|
||||||
#else
|
|
||||||
recruit=Vampire Bat,Ghost,Skeleton Archer,Skeleton
|
|
||||||
#endif
|
|
||||||
|
|
||||||
{GOLD 140 200 300}
|
{GOLD 140 200 300}
|
||||||
{INCOME 4 12 20}
|
|
||||||
|
|
||||||
team_name=orcs
|
team_name=orcs
|
||||||
|
|
||||||
|
[ai]
|
||||||
|
recruitment_pattern=fighter,fighter,archer
|
||||||
|
leader_value=10.0
|
||||||
|
[/ai]
|
||||||
|
|
||||||
|
[ai]
|
||||||
|
time_of_day=dusk,first_watch,second_watch
|
||||||
|
aggression=1.0
|
||||||
|
grouping=no
|
||||||
|
[/ai]
|
||||||
[/side]
|
[/side]
|
||||||
|
|
||||||
|
#start the orcs/undead with most of the villages on the map
|
||||||
|
{STARTING_VILLAGES 2 20}
|
||||||
|
{STARTING_VILLAGES 3 10}
|
||||||
|
|
||||||
[event]
|
[event]
|
||||||
name=start
|
name=start
|
||||||
[role]
|
[role]
|
||||||
|
|
|
@ -1173,7 +1173,7 @@ void calculate_healing(display& disp, const gamestatus& status, const gamemap& m
|
||||||
}
|
}
|
||||||
|
|
||||||
while(h->second > 0) {
|
while(h->second > 0) {
|
||||||
const Uint16 heal_colour = disp.rgb(0,0,200);
|
const Uint32 heal_colour = disp.rgb(0,0,200);
|
||||||
u.heal(1);
|
u.heal(1);
|
||||||
|
|
||||||
if(show_healing) {
|
if(show_healing) {
|
||||||
|
@ -1191,7 +1191,7 @@ void calculate_healing(display& disp, const gamestatus& status, const gamemap& m
|
||||||
}
|
}
|
||||||
|
|
||||||
while(h->second < 0) {
|
while(h->second < 0) {
|
||||||
const Uint16 damage_colour = disp.rgb(200,0,0);
|
const Uint32 damage_colour = disp.rgb(200,0,0);
|
||||||
u.gets_hit(1);
|
u.gets_hit(1);
|
||||||
|
|
||||||
if(show_healing) {
|
if(show_healing) {
|
||||||
|
|
17
src/ai.cpp
17
src/ai.cpp
|
@ -376,6 +376,23 @@ gamemap::location ai::move_unit(location from, location to, std::map<location,pa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ai::attack_close(const gamemap::location& loc) const
|
||||||
|
{
|
||||||
|
for(std::set<location>::const_iterator i = attacks_.begin(); i != attacks_.end(); ++i) {
|
||||||
|
if(distance_between(*i,loc) < 4) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ai::attack_enemy(const location& attacking_unit, const location& target, int weapon)
|
||||||
|
{
|
||||||
|
attacks_.insert(attacking_unit);
|
||||||
|
ai_interface::attack_enemy(attacking_unit,target,weapon);
|
||||||
|
}
|
||||||
|
|
||||||
void ai_interface::calculate_possible_moves(std::map<location,paths>& res, move_map& srcdst, move_map& dstsrc, bool enemy, bool assume_full_movement, const std::set<gamemap::location>* remove_destinations)
|
void ai_interface::calculate_possible_moves(std::map<location,paths>& res, move_map& srcdst, move_map& dstsrc, bool enemy, bool assume_full_movement, const std::set<gamemap::location>* remove_destinations)
|
||||||
{
|
{
|
||||||
for(std::map<gamemap::location,unit>::iterator un_it = info_.units.begin(); un_it != info_.units.end(); ++un_it) {
|
for(std::map<gamemap::location,unit>::iterator un_it = info_.units.begin(); un_it != info_.units.end(); ++un_it) {
|
||||||
|
|
|
@ -326,6 +326,9 @@ public:
|
||||||
|
|
||||||
bool leader_can_reach_keep() const;
|
bool leader_can_reach_keep() const;
|
||||||
|
|
||||||
|
//function which will return true iff there has been another attack this turn 'close' to this one
|
||||||
|
bool attack_close(const location& loc) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
mutable std::map<location,defensive_position> defensive_position_cache_;
|
mutable std::map<location,defensive_position> defensive_position_cache_;
|
||||||
|
@ -367,6 +370,11 @@ protected:
|
||||||
//moving, it will first attempt recruitment.
|
//moving, it will first attempt recruitment.
|
||||||
location move_unit(location from, location to, std::map<location,paths>& possible_moves);
|
location move_unit(location from, location to, std::map<location,paths>& possible_moves);
|
||||||
|
|
||||||
|
//our own version of 'attack_enemy'. We record all attacks to support group attacking
|
||||||
|
void attack_enemy(const location& attacking_unit, const location& target, int weapon);
|
||||||
|
|
||||||
|
std::set<location> attacks_;
|
||||||
|
|
||||||
//sees if it's possible for a unit to move 'from' -> 'via' -> 'to' all in one turn
|
//sees if it's possible for a unit to move 'from' -> 'via' -> 'to' all in one turn
|
||||||
bool multistep_move_possible(location from, location to, location via, std::map<location,paths>& possible_moves);
|
bool multistep_move_possible(location from, location to, location via, std::map<location,paths>& possible_moves);
|
||||||
|
|
||||||
|
|
|
@ -546,9 +546,9 @@ double ai::attack_analysis::rating(double aggression, ai& ai_obj) const
|
||||||
//prefer to attack already damaged targets
|
//prefer to attack already damaged targets
|
||||||
value += ((target_starting_damage/3 + avg_damage_inflicted) - (1.0-aggression)*avg_damage_taken)/10.0;
|
value += ((target_starting_damage/3 + avg_damage_inflicted) - (1.0-aggression)*avg_damage_taken)/10.0;
|
||||||
|
|
||||||
//sanity check: if we're putting ourselves at major risk, and have no chance to kill
|
//sanity check: if we're putting ourselves at major risk, and have no chance to kill, and we're not
|
||||||
//then don't do it
|
//aiding our allies who are also attacking, then don't do it
|
||||||
if(vulnerability > 50.0 && vulnerability > support*5.0 && chance_to_kill < 0.02) {
|
if(vulnerability > 50.0 && vulnerability > support*2.0 && chance_to_kill < 0.02 && aggression < 0.75 && !ai_obj.attack_close(target)) {
|
||||||
return -1.0;
|
return -1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -933,7 +933,7 @@ void display::draw_minimap(int x, int y, int w, int h)
|
||||||
|
|
||||||
const int side = u->second.side();
|
const int side = u->second.side();
|
||||||
const SDL_Color& col = font::get_side_colour(side);
|
const SDL_Color& col = font::get_side_colour(side);
|
||||||
const Uint16 mapped_col = SDL_MapRGB(video().getSurface()->format,col.r,col.g,col.b);
|
const Uint32 mapped_col = SDL_MapRGB(video().getSurface()->format,col.r,col.g,col.b);
|
||||||
SDL_Rect rect = {x + (u->first.x*w)/map_.x(),
|
SDL_Rect rect = {x + (u->first.x*w)/map_.x(),
|
||||||
y + (u->first.y*h)/map_.y(),
|
y + (u->first.y*h)/map_.y(),
|
||||||
w/map_.x(), h/map_.y() };
|
w/map_.x(), h/map_.y() };
|
||||||
|
@ -949,7 +949,7 @@ void display::draw_minimap(int x, int y, int w, int h)
|
||||||
const int wbox = static_cast<int>(xscaling*map_area().w/(zoom_*0.75) - xscaling);
|
const int wbox = static_cast<int>(xscaling*map_area().w/(zoom_*0.75) - xscaling);
|
||||||
const int hbox = static_cast<int>(yscaling*map_area().h/zoom_ - yscaling);
|
const int hbox = static_cast<int>(yscaling*map_area().h/zoom_ - yscaling);
|
||||||
|
|
||||||
const Uint16 boxcolour = Uint16(SDL_MapRGB(surface->format,0xFF,0xFF,0xFF));
|
const Uint32 boxcolour = SDL_MapRGB(surface->format,0xFF,0xFF,0xFF);
|
||||||
SDL_Surface* const screen = screen_.getSurface();
|
SDL_Surface* const screen = screen_.getSurface();
|
||||||
|
|
||||||
gui::draw_rectangle(x+xbox,y+ybox,wbox,hbox,boxcolour,screen);
|
gui::draw_rectangle(x+xbox,y+ybox,wbox,hbox,boxcolour,screen);
|
||||||
|
@ -1271,7 +1271,7 @@ void display::draw_bar(const std::string& image, int xpos, int ypos, size_t heig
|
||||||
|
|
||||||
if(unfilled < height && alpha >= 0.3) {
|
if(unfilled < height && alpha >= 0.3) {
|
||||||
SDL_Rect filled_area = {xpos+bar_loc.x,ypos+bar_loc.y+unfilled,bar_loc.w,height-unfilled};
|
SDL_Rect filled_area = {xpos+bar_loc.x,ypos+bar_loc.y+unfilled,bar_loc.w,height-unfilled};
|
||||||
const Uint16 colour = SDL_MapRGB(video().getSurface()->format,col.r,col.g,col.b);
|
const Uint32 colour = SDL_MapRGB(video().getSurface()->format,col.r,col.g,col.b);
|
||||||
SDL_FillRect(video().getSurface(),&filled_area,colour);
|
SDL_FillRect(video().getSurface(),&filled_area,colour);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1148,7 +1148,7 @@ void map_editor::update_l_button_palette() {
|
||||||
const int draw_w = minimum<int>(r.w + 2, gui_.screen_area().w);
|
const int draw_w = minimum<int>(r.w + 2, gui_.screen_area().w);
|
||||||
const int draw_h = minimum<int>(r.h + 2, gui_.screen_area().h);
|
const int draw_h = minimum<int>(r.h + 2, gui_.screen_area().h);
|
||||||
const SDL_Rect draw_rect = {draw_x, draw_y, draw_w, draw_h};
|
const SDL_Rect draw_rect = {draw_x, draw_y, draw_w, draw_h};
|
||||||
Uint16 color;
|
Uint32 color;
|
||||||
if ((*it).items().back() == get_action_name(l_button_func_)) {
|
if ((*it).items().back() == get_action_name(l_button_func_)) {
|
||||||
color = 0xF000;
|
color = 0xF000;
|
||||||
}
|
}
|
||||||
|
|
17
src/game.cpp
17
src/game.cpp
|
@ -383,7 +383,7 @@ int play_game(int argc, char** argv)
|
||||||
std::pair<int,int> resolution = preferences::resolution();
|
std::pair<int,int> resolution = preferences::resolution();
|
||||||
|
|
||||||
std::cerr << "checking mode possible...\n";
|
std::cerr << "checking mode possible...\n";
|
||||||
const int bpp = video.modePossible(resolution.first,resolution.second,16,video_flags);
|
int bpp = video.modePossible(resolution.first,resolution.second,16,video_flags);
|
||||||
|
|
||||||
std::cerr << bpp << "\n";
|
std::cerr << bpp << "\n";
|
||||||
|
|
||||||
|
@ -397,7 +397,7 @@ int play_game(int argc, char** argv)
|
||||||
resolution.first = 1024;
|
resolution.first = 1024;
|
||||||
resolution.second = 768;
|
resolution.second = 768;
|
||||||
|
|
||||||
int bpp = video.modePossible(resolution.first,resolution.second,16,video_flags);
|
bpp = video.modePossible(resolution.first,resolution.second,16,video_flags);
|
||||||
|
|
||||||
if(bpp == 0) {
|
if(bpp == 0) {
|
||||||
//Attempt 1024x768.
|
//Attempt 1024x768.
|
||||||
|
@ -429,17 +429,12 @@ int play_game(int argc, char** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bpp != 16) {
|
std::cerr << "setting mode to " << resolution.first << "x" << resolution.second << "x" << bpp << "\n";
|
||||||
std::cerr << "Video mode must be emulated; the game may run slowly. "
|
const int res = video.setMode(resolution.first,resolution.second,bpp,video_flags);
|
||||||
<< "For best results, run the program on a 16 bpp display\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cerr << "setting mode to " << resolution.first << "x" << resolution.second << "\n";
|
|
||||||
const int res = video.setMode(resolution.first,resolution.second,16,video_flags);
|
|
||||||
video.setBpp(bpp);
|
video.setBpp(bpp);
|
||||||
if(res != 16) {
|
if(res == 0) {
|
||||||
std::cerr << "required video mode, " << resolution.first << "x"
|
std::cerr << "required video mode, " << resolution.first << "x"
|
||||||
<< resolution.second << "x16 is not supported\n";
|
<< resolution.second << "x" << bpp << " is not supported\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,8 +96,9 @@ void set_fullscreen(bool ison)
|
||||||
CVideo& video = disp->video();
|
CVideo& video = disp->video();
|
||||||
if(video.isFullScreen() != ison) {
|
if(video.isFullScreen() != ison) {
|
||||||
const int flags = ison ? FULL_SCREEN : 0;
|
const int flags = ison ? FULL_SCREEN : 0;
|
||||||
if(video.modePossible(res.first,res.second,16,flags)) {
|
const int bpp = video.modePossible(res.first,res.second,16,flags);
|
||||||
video.setMode(res.first,res.second,16,flags);
|
if(bpp > 0) {
|
||||||
|
video.setMode(res.first,res.second,bpp,flags);
|
||||||
disp->redraw_everything();
|
disp->redraw_everything();
|
||||||
} else if(video.modePossible(1024,768,16,flags)) {
|
} else if(video.modePossible(1024,768,16,flags)) {
|
||||||
set_resolution(std::pair<int,int>(1024,768));
|
set_resolution(std::pair<int,int>(1024,768));
|
||||||
|
@ -141,9 +142,9 @@ void set_resolution(const std::pair<int,int>& resolution)
|
||||||
if(disp != NULL) {
|
if(disp != NULL) {
|
||||||
CVideo& video = disp->video();
|
CVideo& video = disp->video();
|
||||||
const int flags = fullscreen() ? FULL_SCREEN : 0;
|
const int flags = fullscreen() ? FULL_SCREEN : 0;
|
||||||
if(video.modePossible(res.first,res.second,16,flags)) {
|
const int bpp = video.modePossible(res.first,res.second,16,flags);
|
||||||
|
if(bpp != 0) {
|
||||||
video.setMode(res.first,res.second,16,flags);
|
video.setMode(res.first,res.second,bpp,flags);
|
||||||
disp->redraw_everything();
|
disp->redraw_everything();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -228,7 +228,7 @@ void draw_dialog(int x, int y, int w, int h, display& disp, const std::string& t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_rectangle(int x, int y, int w, int h, Uint16 colour,SDL_Surface* target)
|
void draw_rectangle(int x, int y, int w, int h, Uint32 colour,SDL_Surface* target)
|
||||||
{
|
{
|
||||||
if(x < 0 || y < 0 || x+w >= target->w || y+h >= target->h) {
|
if(x < 0 || y < 0 || x+w >= target->w || y+h >= target->h) {
|
||||||
std::cerr << "Rectangle has illegal co-ordinates: " << x << "," << y
|
std::cerr << "Rectangle has illegal co-ordinates: " << x << "," << y
|
||||||
|
|
|
@ -50,7 +50,7 @@ void draw_dialog_frame(int x, int y, int w, int h, display& disp, const std::str
|
||||||
|
|
||||||
void draw_dialog_background(int x, int y, int w, int h, display& disp, const std::string& dialog_style);
|
void draw_dialog_background(int x, int y, int w, int h, display& disp, const std::string& dialog_style);
|
||||||
|
|
||||||
void draw_rectangle(int x, int y, int w, int h, Uint16 colour, SDL_Surface* tg);
|
void draw_rectangle(int x, int y, int w, int h, Uint32 colour, SDL_Surface* tg);
|
||||||
|
|
||||||
void draw_solid_tinted_rectangle(int x, int y, int w, int h,
|
void draw_solid_tinted_rectangle(int x, int y, int w, int h,
|
||||||
int r, int g, int b,
|
int r, int g, int b,
|
||||||
|
|
|
@ -111,7 +111,7 @@ void textbox::draw()
|
||||||
src.w = src.x + w > loc.x + loc.w ? loc.x + loc.w - src.x : w;
|
src.w = src.x + w > loc.x + loc.w ? loc.x + loc.w - src.x : w;
|
||||||
src.h = loc.h;
|
src.h = loc.h;
|
||||||
|
|
||||||
Uint16 colour = Uint16(SDL_MapRGB(disp().video().getSurface()->format, 160, 0, 0));
|
Uint32 colour = SDL_MapRGB(disp().video().getSurface()->format, 160, 0, 0);
|
||||||
fill_rect_alpha(src,colour,140,disp().video().getSurface());
|
fill_rect_alpha(src,colour,140,disp().video().getSurface());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue