[+] Added "corpse" check for autocast spells (no more blizzard on corpses)
This commit is contained in:
parent
8c0c15db03
commit
7a2afec8db
3 changed files with 24 additions and 1 deletions
|
@ -174,7 +174,7 @@ public:
|
|||
#define ACP_NOVALUE -1
|
||||
#define ACP_DISTANCE -2
|
||||
AutoCastInfo() : Range(0), MinRange(0), PriorytyVar(ACP_NOVALUE), ReverseSort(false), Condition(NULL),
|
||||
Combat(0), Attacker(0), PositionAutoCast(NULL) {};
|
||||
Combat(0), Attacker(0), Corpse(0), PositionAutoCast(NULL) {};
|
||||
~AutoCastInfo()
|
||||
{
|
||||
delete Condition;
|
||||
|
@ -193,6 +193,7 @@ public:
|
|||
/// Combat mode is when there are hostile non-coward units around
|
||||
int Combat; /// If it should be casted in combat
|
||||
int Attacker; /// If it should be casted on unit which attacks
|
||||
int Corpse; /// If it should be casted on corpses
|
||||
|
||||
// Position autocast callback
|
||||
LuaCallback *PositionAutoCast;
|
||||
|
|
|
@ -249,6 +249,8 @@ static void CclSpellAutocast(lua_State *l, AutoCastInfo *autocast)
|
|||
autocast->Combat = Ccl2Condition(l, LuaToString(l, -1, j + 1));
|
||||
} else if (!strcmp(value, "attacker")) {
|
||||
autocast->Attacker = Ccl2Condition(l, LuaToString(l, -1, j + 1));
|
||||
} else if (!strcmp(value, "corpse")) {
|
||||
autocast->Corpse = Ccl2Condition(l, LuaToString(l, -1, j + 1));
|
||||
} else if (!strcmp(value, "priority")) {
|
||||
lua_rawgeti(l, -1, j + 1);
|
||||
if (!lua_istable(l, -1) || lua_rawlen(l, -1) != 2) {
|
||||
|
|
|
@ -299,6 +299,16 @@ static Target *SelectTargetUnitsOfAutoCast(CUnit &caster, const SpellType &spell
|
|||
if (autocast->PositionAutoCast && table.empty() == false) {
|
||||
size_t count = 0;
|
||||
for (size_t i = 0; i != table.size(); ++i) {
|
||||
// Check for corpse
|
||||
if (autocast->Corpse == CONDITION_ONLY) {
|
||||
if (table[i]->CurrentAction() != UnitActionDie) {
|
||||
continue;
|
||||
}
|
||||
} else if (autocast->Corpse == CONDITION_FALSE) {
|
||||
if (table[i]->CurrentAction() == UnitActionDie) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (PassCondition(caster, spell, table[i], pos, spell.Condition)
|
||||
&& PassCondition(caster, spell, table[i], pos, autocast->Condition)) {
|
||||
table[count++] = table[i];
|
||||
|
@ -343,6 +353,16 @@ static Target *SelectTargetUnitsOfAutoCast(CUnit &caster, const SpellType &spell
|
|||
continue;
|
||||
}
|
||||
}
|
||||
// Check for corpse
|
||||
if (autocast->Corpse == CONDITION_ONLY) {
|
||||
if (table[i]->CurrentAction() != UnitActionDie) {
|
||||
continue;
|
||||
}
|
||||
} else if (autocast->Corpse == CONDITION_FALSE) {
|
||||
if (table[i]->CurrentAction() == UnitActionDie) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (PassCondition(caster, spell, table[i], pos, spell.Condition)
|
||||
&& PassCondition(caster, spell, table[i], pos, autocast->Condition)) {
|
||||
table[n++] = table[i];
|
||||
|
|
Loading…
Reference in a new issue