game: check if the active pc is killed in combat + update scenario name after

restoring a game...
This commit is contained in:
ALONSO Laurent
2022-01-18 09:33:26 +01:00
committed by Celtic Minstrel
parent 242fd65824
commit 5573e4eacd
6 changed files with 39 additions and 60 deletions

View File

@@ -2635,8 +2635,11 @@ void handle_death() {
fs::path file_to_load = nav_get_party();
if(!file_to_load.empty()) load_party(file_to_load, univ);
if(univ.party.is_alive()) {
if(overall_mode == MODE_STARTUP)
post_load(), finish_load_party();
if(overall_mode == MODE_STARTUP) {
post_load();
finish_load_party();
univ.file = file_to_load;
}
return;
}
}

View File

@@ -16,7 +16,6 @@
#include "boe.global.hpp"
#include "choicedlog.hpp"
extern void finish_load_party();
extern void end_startup();
extern void post_load();

View File

@@ -30,7 +30,7 @@ extern eGameMode overall_mode;
extern short which_combat_type;
extern eItemWinMode stat_window;
extern location center;
extern short combat_active_pc;
short combat_active_pc;
extern bool monsters_going,spell_forced;
extern bool flushingInput;
extern sf::RenderWindow mainPtr;
@@ -397,8 +397,16 @@ bool pc_combat_move(location destination) {
return false;
}
if(monst_hit == nullptr)
if(monst_hit == nullptr) {
short actual_pc=univ.cur_pc;
keep_going = check_special_terrain(destination,eSpecCtx::COMBAT_MOVE,univ.current_pc(),&check_f);
// check if current pc is still alive, has not change, ...
if (actual_pc!=univ.cur_pc ||
(univ.current_pc().main_status != eMainStatus::ALIVE && univ.current_pc().main_status != eMainStatus::SPLIT_ALIVE)) {
if(combat_active_pc == actual_pc) combat_active_pc = 6; // checkme: do we need also to check if actual_pc==univ.cur_pc
return true;
}
}
if(check_f)
forced = true;

View File

@@ -319,51 +319,51 @@ void draw_fields(location where){
return;
auto const fields=univ.town.fields[where.x][where.y];
if ((fields&~(unsigned long)SPECIAL_EXPLORED)==0) return;
if(univ.town.is_force_wall(fields))
if(fields & WALL_FORCE)
Draw_Some_Item(fields_gworld,calc_rect(0,1),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_fire_wall(fields))
if(fields & WALL_FIRE)
Draw_Some_Item(fields_gworld,calc_rect(1,1),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_antimagic(fields))
if(fields & FIELD_ANTIMAGIC)
Draw_Some_Item(fields_gworld,calc_rect(2,1),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_scloud(fields))
if(fields & CLOUD_STINK)
Draw_Some_Item(fields_gworld,calc_rect(3,1),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_ice_wall(fields))
if(fields & WALL_ICE)
Draw_Some_Item(fields_gworld,calc_rect(4,1),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_blade_wall(fields))
if(fields & WALL_BLADES)
Draw_Some_Item(fields_gworld,calc_rect(5,1),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_sleep_cloud(fields))
if(fields & CLOUD_SLEEP)
Draw_Some_Item(fields_gworld,calc_rect(6,1),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_block(fields))
if(fields & OBJECT_BLOCK)
Draw_Some_Item(fields_gworld,calc_rect(3,0),terrain_screen_gworld,where_draw,1,0);
if(!is_combat() && univ.town.is_spot(fields))
if(!is_combat() && (fields & SPECIAL_SPOT))
Draw_Some_Item(fields_gworld,calc_rect(4,0),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_web(fields))
if(fields & FIELD_WEB)
Draw_Some_Item(fields_gworld,calc_rect(5,0),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_crate(fields))
if(fields & OBJECT_CRATE)
Draw_Some_Item(fields_gworld,calc_rect(6,0),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_barrel(fields))
if(fields & OBJECT_BARREL)
Draw_Some_Item(fields_gworld,calc_rect(7,0),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_fire_barr(fields) || univ.town.is_force_barr(fields))
if(fields & (BARRIER_FIRE | BARRIER_FORCE))
Draw_Some_Item(*ResMgr::textures.get("teranim"),calc_rect(8+(anim_ticks%4),4),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_quickfire(fields))
if(fields & FIELD_QUICKFIRE)
Draw_Some_Item(fields_gworld,calc_rect(7,1),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_sm_blood(fields))
if(fields & SFX_SMALL_BLOOD)
Draw_Some_Item(fields_gworld,calc_rect(0,3),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_med_blood(fields))
if(fields & SFX_MEDIUM_BLOOD)
Draw_Some_Item(fields_gworld,calc_rect(1,3),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_lg_blood(fields))
if(fields & SFX_LARGE_BLOOD)
Draw_Some_Item(fields_gworld,calc_rect(2,3),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_sm_slime(fields))
if(fields & SFX_SMALL_SLIME)
Draw_Some_Item(fields_gworld,calc_rect(3,3),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_lg_slime(fields))
if(fields & SFX_LARGE_SLIME)
Draw_Some_Item(fields_gworld,calc_rect(4,3),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_ash(fields))
if(fields & SFX_ASH)
Draw_Some_Item(fields_gworld,calc_rect(5,3),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_bones(fields))
if(fields & SFX_BONES)
Draw_Some_Item(fields_gworld,calc_rect(6,3),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_rubble(fields))
if(fields & SFX_RUBBLE)
Draw_Some_Item(fields_gworld,calc_rect(7,3),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_force_cage(fields)) {
if(fields & BARRIER_CAGE) {
Draw_Some_Item(fields_gworld,calc_rect(1,0),terrain_screen_gworld,where_draw,1,0);
forcecage_locs.push_back(where_draw);
}

View File

@@ -93,7 +93,6 @@ location spell_targets[8];
/* Combat globals */
short which_combat_type;
location center;
short combat_active_pc;
effect_pat_type current_pat;
short missile_firer,current_monst_tactic;
short store_current_pc = 0;

View File

@@ -39,10 +39,6 @@ class cCurTown {
cTown* arena;
cTown*const record() const;
template<eFieldType Field> static bool test_field(unsigned long allFields)
{
return allFields & Field;
}
template<eFieldType Field> bool test_field(short x, short y) const
{
if(!record()->is_on_map(x,y)) return false;
@@ -72,33 +68,7 @@ public:
bool prep_talk(short which); // Prepare for loading specified speech, returning true if already loaded
void prep_arena(); // Set up for a combat arena
void place_preset_fields();
static bool is_explored(unsigned long allFields) { return test_field<SPECIAL_EXPLORED>(allFields); }
static bool is_force_wall(unsigned long allFields) { return test_field<WALL_FORCE>(allFields); }
static bool is_fire_wall(unsigned long allFields) { return test_field<WALL_FIRE>(allFields); }
static bool is_antimagic(unsigned long allFields) { return test_field<FIELD_ANTIMAGIC>(allFields); }
static bool is_scloud(unsigned long allFields) { return test_field<CLOUD_STINK>(allFields); } // stinking cloud
static bool is_ice_wall(unsigned long allFields) { return test_field<WALL_ICE>(allFields); }
static bool is_blade_wall(unsigned long allFields) { return test_field<WALL_BLADES>(allFields); }
static bool is_sleep_cloud(unsigned long allFields) { return test_field<CLOUD_SLEEP>(allFields); }
static bool is_block(unsigned long allFields) { return test_field<OBJECT_BLOCK>(allFields); } // currently unused
static bool is_spot(unsigned long allFields) { return test_field<SPECIAL_SPOT>(allFields); }
static bool is_web(unsigned long allFields) { return test_field<FIELD_WEB>(allFields); }
static bool is_crate(unsigned long allFields) { return test_field<OBJECT_CRATE>(allFields); }
static bool is_barrel(unsigned long allFields) { return test_field<OBJECT_BARREL>(allFields); }
static bool is_fire_barr(unsigned long allFields) { return test_field<BARRIER_FIRE>(allFields); }
static bool is_force_barr(unsigned long allFields) { return test_field<BARRIER_FORCE>(allFields); }
static bool is_quickfire(unsigned long allFields) { return test_field<FIELD_QUICKFIRE>(allFields); }
static bool is_sm_blood(unsigned long allFields) { return test_field<SFX_SMALL_BLOOD>(allFields); }
static bool is_med_blood(unsigned long allFields) { return test_field<SFX_MEDIUM_BLOOD>(allFields); }
static bool is_lg_blood(unsigned long allFields) { return test_field<SFX_LARGE_BLOOD>(allFields); }
static bool is_sm_slime(unsigned long allFields) { return test_field<SFX_SMALL_SLIME>(allFields); }
static bool is_lg_slime(unsigned long allFields) { return test_field<SFX_LARGE_SLIME>(allFields); }
static bool is_ash(unsigned long allFields) { return test_field<SFX_ASH>(allFields); }
static bool is_bones(unsigned long allFields) { return test_field<SFX_BONES>(allFields); }
static bool is_rubble(unsigned long allFields) { return test_field<SFX_RUBBLE>(allFields); }
static bool is_force_cage(unsigned long allFields) { return test_field<BARRIER_CAGE>(allFields); }
static bool is_road(unsigned long allFields) { return test_field<SPECIAL_ROAD>(allFields); }
bool is_explored(short x, short y) const { return test_field<SPECIAL_EXPLORED>(x,y); }
bool is_force_wall(short x, short y) const { return test_field<WALL_FORCE>(x,y); }
bool is_fire_wall(short x, short y) const { return test_field<WALL_FIRE>(x,y); }