Added per-unit haloing, including haloes for Mage of Light
This commit is contained in:
parent
431c713d20
commit
bc61faf13e
10 changed files with 59 additions and 13 deletions
|
@ -13,7 +13,6 @@ image=Morning.png
|
|||
lawful_bonus=25
|
||||
red=-20
|
||||
green=-20
|
||||
mask=terrain/mage_light_halo.png
|
||||
[/illuminated_time]
|
||||
#enddef
|
||||
|
||||
|
@ -62,7 +61,6 @@ image=Afternoon.png
|
|||
lawful_bonus=25
|
||||
green=-20
|
||||
blue=-20
|
||||
mask=terrain/mage_light_halo.png
|
||||
[/illuminated_time]
|
||||
#enddef
|
||||
|
||||
|
@ -83,7 +81,6 @@ image=Dusk.png
|
|||
red=-40
|
||||
green=-40
|
||||
blue=-10
|
||||
mask=terrain/mage_light_halo.png
|
||||
[/illuminated_time]
|
||||
#enddef
|
||||
|
||||
|
@ -104,7 +101,6 @@ image=Dusk.png
|
|||
red=-40
|
||||
green=-40
|
||||
blue=-10
|
||||
mask=terrain/mage_light_halo.png
|
||||
[/illuminated_time]
|
||||
#enddef
|
||||
|
||||
|
@ -119,6 +115,5 @@ lawful_bonus=-25
|
|||
id=underground
|
||||
name=Underground
|
||||
image=UndergroundIllum.png
|
||||
mask=terrain/mage_light_halo.png
|
||||
[/illuminated_time]
|
||||
#enddef
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
name=Mage of Light
|
||||
race=human
|
||||
image=white-cleric.png
|
||||
halo=white-cleric-aura.png
|
||||
ability=illuminates,cures
|
||||
hitpoints=42
|
||||
movement_type=smallfoot
|
||||
|
|
Binary file not shown.
BIN
images/white-cleric-aura.png
Normal file
BIN
images/white-cleric-aura.png
Normal file
Binary file not shown.
|
@ -552,7 +552,10 @@ void ai::do_move()
|
|||
|
||||
//recruitment phase and leader movement phase
|
||||
if(leader != units_.end()) {
|
||||
move_leader_to_keep(enemy_dstsrc);
|
||||
if(!passive_leader) {
|
||||
move_leader_to_keep(enemy_dstsrc);
|
||||
}
|
||||
|
||||
do_recruitment();
|
||||
|
||||
if(!passive_leader) {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "font.hpp"
|
||||
#include "game.hpp"
|
||||
#include "game_config.hpp"
|
||||
#include "halo.hpp"
|
||||
#include "hotkeys.hpp"
|
||||
#include "image.hpp"
|
||||
#include "language.hpp"
|
||||
|
@ -1021,6 +1022,28 @@ gamemap::TERRAIN display::get_terrain_on(int palx, int paly, int x, int y)
|
|||
return terrains[index];
|
||||
}
|
||||
|
||||
void display::draw_halo_on_tile(int x, int y)
|
||||
{
|
||||
const gamemap::location loc(x,y);
|
||||
int xpos = get_location_x(loc);
|
||||
int ypos = get_location_y(loc);
|
||||
|
||||
const halo_map::iterator halo_it = haloes_.find(loc);
|
||||
|
||||
//see if there is a unit on this tile
|
||||
const unit_map::const_iterator it = units_.find(gamemap::location(x,y));
|
||||
|
||||
if(halo_it != haloes_.end() && it == units_.end()) {
|
||||
halo::remove(halo_it->second);
|
||||
haloes_.erase(halo_it);
|
||||
} else if(halo_it == haloes_.end() && it != units_.end()) {
|
||||
const std::string& halo = it->second.type().image_halo();
|
||||
if(halo.empty() == false) {
|
||||
haloes_.insert(std::pair<gamemap::location,int>(loc,halo::add(xpos+hex_width()/2,ypos+hex_size()/2,halo)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void display::draw_unit_on_tile(int x, int y, SDL_Surface* unit_image_override,
|
||||
double highlight_ratio, Uint32 blend_with)
|
||||
{
|
||||
|
@ -1031,6 +1054,13 @@ void display::draw_unit_on_tile(int x, int y, SDL_Surface* unit_image_override,
|
|||
int xpos = get_location_x(loc);
|
||||
int ypos = get_location_y(loc);
|
||||
|
||||
//see if there is a unit on this tile
|
||||
const unit_map::const_iterator it = units_.find(loc);
|
||||
|
||||
if(it == units_.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_Rect clip_rect = map_area();
|
||||
|
||||
if(xpos > clip_rect.x + clip_rect.w || ypos > clip_rect.y + clip_rect.h ||
|
||||
|
@ -1053,12 +1083,6 @@ void display::draw_unit_on_tile(int x, int y, SDL_Surface* unit_image_override,
|
|||
|
||||
const std::string* energy_file = NULL;
|
||||
|
||||
//see if there is a unit on this tile
|
||||
const unit_map::const_iterator it = units_.find(gamemap::location(x,y));
|
||||
if(it == units_.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const unit& u = it->second;
|
||||
|
||||
if(loc != hiddenUnit_ || !hideEnergy_) {
|
||||
|
@ -1287,6 +1311,8 @@ void display::draw_tile(int x, int y, SDL_Surface* unit_image, double alpha, Uin
|
|||
{
|
||||
if(updatesLocked_)
|
||||
return;
|
||||
|
||||
draw_halo_on_tile(x,y);
|
||||
|
||||
const gamemap::location loc(x,y);
|
||||
int xpos = int(get_location_x(loc));
|
||||
|
|
|
@ -176,6 +176,8 @@ private:
|
|||
void draw_unit_on_tile(int x, int y, SDL_Surface* unit_image=NULL,
|
||||
double alpha=1.0, Uint32 blend_to=0);
|
||||
|
||||
void draw_halo_on_tile(int x, int y);
|
||||
|
||||
enum ADJACENT_TERRAIN_TYPE { ADJACENT_BACKGROUND, ADJACENT_FOREGROUND };
|
||||
void draw_tile_adjacent(int x, int y, image::TYPE image_type, ADJACENT_TERRAIN_TYPE type);
|
||||
|
||||
|
@ -455,6 +457,9 @@ private:
|
|||
//then we will use these two masks on top of all hexes when we blit
|
||||
shared_sdl_surface tod_hex_mask1, tod_hex_mask2;
|
||||
|
||||
typedef std::map<gamemap::location,int> halo_map;
|
||||
halo_map haloes_;
|
||||
|
||||
//for debug mode
|
||||
static std::map<gamemap::location,double> debugHighlights_;
|
||||
|
||||
|
|
|
@ -46,6 +46,8 @@ void move_unit_between(display& disp, const gamemap& map, const gamemap::locatio
|
|||
|
||||
int skips = 0;
|
||||
|
||||
const std::string& halo = u.type().image_halo();
|
||||
|
||||
for(int i = 0; i < nsteps; ++i) {
|
||||
events::pump();
|
||||
|
||||
|
@ -108,8 +110,16 @@ void move_unit_between(display& disp, const gamemap& map, const gamemap::locatio
|
|||
const int height_adjust = src_height_adjust + (dst_height_adjust-src_height_adjust)*(i/nsteps);
|
||||
const double submerge = src_submerge + (dst_submerge-src_submerge)*(i/nsteps);
|
||||
|
||||
const int xpos = static_cast<int>(xloc);
|
||||
const int ypos = static_cast<int>(yloc) - height_adjust;
|
||||
|
||||
disp.draw(false);
|
||||
disp.draw_unit((int)xloc,(int)yloc - height_adjust,image,false,1.0,0,submerge);
|
||||
disp.draw_unit(xpos,ypos,image,false,1.0,0,submerge);
|
||||
|
||||
util::scoped_resource<int,halo::remover> halo_effect(0);
|
||||
if(halo.empty() == false) {
|
||||
halo_effect.assign(halo::add(xpos+disp.hex_width()/2,ypos+disp.hex_size()/2,halo));
|
||||
}
|
||||
|
||||
const int new_ticks = SDL_GetTicks();
|
||||
const int wait_time = time_between_frames - (new_ticks - ticks);
|
||||
|
|
|
@ -585,6 +585,11 @@ const std::string& unit_type::image() const
|
|||
return cfg_["image"];
|
||||
}
|
||||
|
||||
const std::string& unit_type::image_halo() const
|
||||
{
|
||||
return cfg_["halo"];
|
||||
}
|
||||
|
||||
const std::string& unit_type::image_moving() const
|
||||
{
|
||||
const std::string& res = cfg_["image_moving"];
|
||||
|
|
|
@ -157,6 +157,7 @@ public:
|
|||
std::string id() const;
|
||||
const std::string& name() const;
|
||||
const std::string& image() const;
|
||||
const std::string& image_halo() const;
|
||||
const std::string& image_moving() const;
|
||||
const std::string& image_profile() const;
|
||||
const std::string& image_fighting(attack_type::RANGE range) const;
|
||||
|
|
Loading…
Add table
Reference in a new issue