bool ResourceUnitFinder::MineIsUsable(const CUnit &mine) const { return mine.Type->BoolFlag[CANHARVEST_INDEX].value && mine.ResourcesHeld && (resinfo.HarvestFromOutside || mine.Player->Index == PlayerMax - 1 || mine.Player == worker.Player || (worker.IsAllied(mine) && mine.IsAllied(worker))); }
bool ResourceUnitFinder::MineIsUsable(const CUnit &mine) const { //Wyrmgus start // return mine.Type->BoolFlag[CANHARVEST_INDEX].value && mine.ResourcesHeld return (mine_on_top ? mine.Type->BoolFlag[CANHARVEST_INDEX].value : !mine.Type->BoolFlag[CANHARVEST_INDEX].value) && mine.ResourcesHeld //Wyrmgus end //Wyrmgus start && !mine.IsUnusable(false) // && (resinfo.HarvestFromOutside && (mine.Type->BoolFlag[HARVESTFROMOUTSIDE_INDEX].value //Wyrmgus end || mine.Player->Index == PlayerMax - 1 || mine.Player == worker.Player || (worker.IsAllied(mine) && mine.IsAllied(worker))); }
/** ** Check the condition. ** ** @param caster Pointer to caster unit. ** @param spell Pointer to the spell to cast. ** @param target Pointer to target unit, or 0 if it is a position spell. ** @param goalPos position, or {-1, -1} if it is a unit spell. ** @param condition Pointer to condition info. ** ** @return true if passed, false otherwise. */ static bool PassCondition(const CUnit &caster, const SpellType &spell, const CUnit *target, const Vec2i &/*goalPos*/, const ConditionInfo *condition) { if (caster.Variable[MANA_INDEX].Value < spell.ManaCost) { // Check caster mana. return false; } // check countdown timer if (caster.SpellCoolDownTimers[spell.Slot]) { // Check caster mana. return false; } // Check caster's resources if (caster.Player->CheckCosts(spell.Costs, false)) { return false; } if (spell.Target == TargetUnit) { // Casting a unit spell without a target. if ((!target) || target->IsAlive() == false) { return false; } } if (!condition) { // no condition, pass. return true; } for (unsigned int i = 0; i < UnitTypeVar.GetNumberVariable(); i++) { // for custom variables const CUnit *unit; if (!condition->Variable[i].Check) { continue; } unit = (condition->Variable[i].ConditionApplyOnCaster) ? &caster : target; // Spell should target location and have unit condition. if (unit == NULL) { continue; } if (condition->Variable[i].Enable != CONDITION_TRUE) { if ((condition->Variable[i].Enable == CONDITION_ONLY) ^ (unit->Variable[i].Enable)) { return false; } } // Value and Max if (condition->Variable[i].ExactValue != -1 && condition->Variable[i].ExactValue != unit->Variable[i].Value) { return false; } if (condition->Variable[i].ExceptValue != -1 && condition->Variable[i].ExceptValue == unit->Variable[i].Value) { return false; } if (condition->Variable[i].MinValue >= unit->Variable[i].Value) { return false; } if (condition->Variable[i].MaxValue != -1 && condition->Variable[i].MaxValue <= unit->Variable[i].Value) { return false; } if (condition->Variable[i].MinMax >= unit->Variable[i].Max) { return false; } if (!unit->Variable[i].Max) { continue; } // Percent if (condition->Variable[i].MinValuePercent * unit->Variable[i].Max >= 100 * unit->Variable[i].Value) { return false; } if (condition->Variable[i].MaxValuePercent * unit->Variable[i].Max <= 100 * unit->Variable[i].Value) { return false; } } if (!target) { return true; } if (!target->Type->CheckUserBoolFlags(condition->BoolFlag)) { return false; } if (condition->Alliance != CONDITION_TRUE) { if ((condition->Alliance == CONDITION_ONLY) ^ // own units could be not allied ? (caster.IsAllied(*target) || target->Player == caster.Player)) { return false; } } if (condition->Opponent != CONDITION_TRUE) { if ((condition->Opponent == CONDITION_ONLY) ^ (caster.IsEnemy(*target) && 1)) { return false; } } if (condition->TargetSelf != CONDITION_TRUE) { if ((condition->TargetSelf == CONDITION_ONLY) ^ (&caster == target)) { return false; } } return true; }