now, filter_opponent usable for backstab abilities
This commit is contained in:
parent
845978dc9c
commit
00ef295c1b
2 changed files with 8 additions and 6 deletions
|
@ -23,6 +23,8 @@
|
||||||
#include "actions/vision.hpp"
|
#include "actions/vision.hpp"
|
||||||
|
|
||||||
#include "ai/lua/aspect_advancements.hpp"
|
#include "ai/lua/aspect_advancements.hpp"
|
||||||
|
#include "formula/callable_objects.hpp"
|
||||||
|
#include "formula/formula.hpp"
|
||||||
#include "game_config.hpp"
|
#include "game_config.hpp"
|
||||||
#include "game_data.hpp"
|
#include "game_data.hpp"
|
||||||
#include "game_events/pump.hpp"
|
#include "game_events/pump.hpp"
|
||||||
|
@ -1588,24 +1590,24 @@ bool unit::abilities_filter_matches(const config& cfg, bool attacker, int res) c
|
||||||
|
|
||||||
//functions for emulate weapon specials.
|
//functions for emulate weapon specials.
|
||||||
//filter opponent and affect self/opponent/both option.
|
//filter opponent and affect self/opponent/both option.
|
||||||
bool unit::ability_filter_fighter(const std::string& ability, const std::string& filter_attacker , const config& cfg, const map_location& loc) const
|
bool unit::ability_filter_fighter(const std::string& ability, const std::string& filter_attacker , const config& cfg, const map_location& loc, const unit& u2) const
|
||||||
{
|
{
|
||||||
const config &filter = cfg.child(filter_attacker);
|
const config &filter = cfg.child(filter_attacker);
|
||||||
if(!filter) {
|
if(!filter) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return unit_filter(vconfig(filter)).set_use_flat_tod(ability == "illuminates").matches(*this, loc);
|
return unit_filter(vconfig(filter)).set_use_flat_tod(ability == "illuminates").matches(*this, loc, u2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ability_apply_filter(const unit_map::const_iterator un, const unit_map::const_iterator up, const std::string& ability, const config& cfg, const map_location& loc, const map_location& opp_loc, bool attacker )
|
static bool ability_apply_filter(const unit_map::const_iterator un, const unit_map::const_iterator up, const std::string& ability, const config& cfg, const map_location& loc, const map_location& opp_loc, bool attacker )
|
||||||
{
|
{
|
||||||
if(!up->ability_filter_fighter(ability, "filter_opponent", cfg, opp_loc)){
|
if(!up->ability_filter_fighter(ability, "filter_opponent", cfg, opp_loc, *un)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if((attacker && !un->ability_filter_fighter(ability, "filter_attacker", cfg, loc)) || (!attacker && !up->ability_filter_fighter(ability, "filter_attacker", cfg, opp_loc))){
|
if((attacker && !un->ability_filter_fighter(ability, "filter_attacker", cfg, loc, *up)) || (!attacker && !up->ability_filter_fighter(ability, "filter_attacker", cfg, opp_loc, *un))){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if((!attacker && !un->ability_filter_fighter(ability, "filter_defender", cfg, loc)) || (attacker && !up->ability_filter_fighter(ability, "filter_defender", cfg, opp_loc))){
|
if((!attacker && !un->ability_filter_fighter(ability, "filter_defender", cfg, loc, *up)) || (attacker && !up->ability_filter_fighter(ability, "filter_defender", cfg, opp_loc, *un))){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1621,7 +1621,7 @@ public:
|
||||||
void remove_ability_by_id(const std::string& ability);
|
void remove_ability_by_id(const std::string& ability);
|
||||||
|
|
||||||
bool abilities_filter_matches(const config& cfg, bool attacker, int res) const;
|
bool abilities_filter_matches(const config& cfg, bool attacker, int res) const;
|
||||||
bool ability_filter_fighter(const std::string& ability, const std::string& filter_attacker , const config& cfg,const map_location& loc) const;
|
bool ability_filter_fighter(const std::string& ability, const std::string& filter_attacker , const config& cfg, const map_location& loc, const unit& u2) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue