diff --git a/source/glest_game/ai/path_finder.cpp b/source/glest_game/ai/path_finder.cpp index 1c2657b5..b6fd9b64 100644 --- a/source/glest_game/ai/path_finder.cpp +++ b/source/glest_game/ai/path_finder.cpp @@ -41,7 +41,7 @@ const int PathFinder::maxFreeSearchRadius = 10; //const int PathFinder::pathFindNodesMax= 400; int PathFinder::pathFindNodesAbsoluteMax = 900; -int PathFinder::pathFindNodesMax = 2000; +int PathFinder::pathFindNodesMax = 1500; const int PathFinder::pathFindRefresh = 10; const int PathFinder::pathFindBailoutRadius = 20; const int PathFinder::pathFindExtendRefreshForNodeCount = 25; @@ -288,7 +288,8 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu if(canUnitMove) { //printf("$$$$ Unit BAILOUT(1) ASTAR ATTEMPT for [%d - %s] newFinalPos = [%s]\n",unit->getId(),unit->getFullName().c_str(),newFinalPos.getString().c_str()); - ts= aStar(unit, newFinalPos, true, frameIndex); + int maxBailoutNodeCount = (PathFinder::pathFindBailoutRadius * 2); + ts= aStar(unit, newFinalPos, true, frameIndex, maxBailoutNodeCount); } } } @@ -308,7 +309,8 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu if(canUnitMove) { //printf("$$$$ Unit BAILOUT(1) ASTAR ATTEMPT for [%d - %s] newFinalPos = [%s]\n",unit->getId(),unit->getFullName().c_str(),newFinalPos.getString().c_str()); - ts= aStar(unit, newFinalPos, true, frameIndex); + int maxBailoutNodeCount = (PathFinder::pathFindBailoutRadius * 2); + ts= aStar(unit, newFinalPos, true, frameIndex, maxBailoutNodeCount); } } } diff --git a/source/glest_game/facilities/game_util.cpp b/source/glest_game/facilities/game_util.cpp index 2d176530..1cc9616e 100644 --- a/source/glest_game/facilities/game_util.cpp +++ b/source/glest_game/facilities/game_util.cpp @@ -27,7 +27,7 @@ using namespace Shared::Platform; namespace Glest { namespace Game { const string mailString = "contact@megaglest.org"; -const string glestVersionString = "v3.5.2"; +const string glestVersionString = "v3.5.3-dev"; #if defined(SVNVERSION) const string SVN_Rev = string("Rev: ") + string(SVNVERSION); #elif defined(SVNVERSIONHEADER) diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index 779797ca..c29c538a 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -483,16 +483,42 @@ void UnitUpdater::updateAttack(Unit *unit, int frameIndex) { else { //if unit arrives destPos order has ended switch (tsValue){ - case tsMoving: - unit->setCurrSkill(act->getMoveSkillType()); - break; - case tsBlocked: - if(unit->getPath()->isBlocked()){ + case tsMoving: + unit->setCurrSkill(act->getMoveSkillType()); + + { + std::pair beingAttacked = unitBeingAttacked(unit); + if(beingAttacked.first == true) { + Unit *enemy = beingAttacked.second; + const AttackCommandType *act_forenemy = unit->getType()->getFirstAttackCommand(enemy->getCurrField()); + if(act_forenemy != NULL) { + if(unit->getEp() >= act_forenemy->getAttackSkillType()->getEpCost()) { + unit->setCurrSkill(act_forenemy->getAttackSkillType()); + unit->setTarget(enemy); + } + //aiInterface->giveCommand(i, act_forenemy, beingAttacked.second->getPos()); + } + else { + const AttackStoppedCommandType *asct_forenemy = unit->getType()->getFirstAttackStoppedCommand(enemy->getCurrField()); + if(asct_forenemy != NULL) { + //aiInterface->giveCommand(i, asct_forenemy, beingAttacked.second->getCenteredPos()); + if(unit->getEp() >= asct_forenemy->getAttackSkillType()->getEpCost()) { + unit->setCurrSkill(asct_forenemy->getAttackSkillType()); + unit->setTarget(enemy); + } + } + } + } + } + + break; + case tsBlocked: + if(unit->getPath()->isBlocked()){ + unit->finishCommand(); + } + break; + default: unit->finishCommand(); - } - break; - default: - unit->finishCommand(); } } }