- observers now hear sounds from units of all team units in visible quad
This commit is contained in:
parent
07f56669b7
commit
505abbd1ec
|
@ -39,7 +39,7 @@ namespace Glest{ namespace Game{
|
||||||
|
|
||||||
const int PathFinder::maxFreeSearchRadius = 10;
|
const int PathFinder::maxFreeSearchRadius = 10;
|
||||||
//const int PathFinder::pathFindNodesMax= 400;
|
//const int PathFinder::pathFindNodesMax= 400;
|
||||||
int PathFinder::pathFindNodesMax = 500;
|
int PathFinder::pathFindNodesMax = 350;
|
||||||
const int PathFinder::pathFindRefresh = 10;
|
const int PathFinder::pathFindRefresh = 10;
|
||||||
const int PathFinder::pathFindBailoutRadius = 20;
|
const int PathFinder::pathFindBailoutRadius = 20;
|
||||||
|
|
||||||
|
@ -393,6 +393,9 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
throw runtime_error("map == NULL");
|
throw runtime_error("map == NULL");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool showConsoleDebugInfo = Config::getInstance().getBool("EnablePathfinderDistanceOutput","false");
|
||||||
|
const bool tryLastPathCache = Config::getInstance().getBool("EnablePathfinderCache","false");
|
||||||
|
|
||||||
UnitPathInterface *path= unit->getPath();
|
UnitPathInterface *path= unit->getPath();
|
||||||
|
|
||||||
factions[unit->getFactionIndex()].nodePoolCount= 0;
|
factions[unit->getFactionIndex()].nodePoolCount= 0;
|
||||||
|
@ -439,9 +442,13 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
if(i < pathFindRefresh) {
|
if(i < pathFindRefresh) {
|
||||||
path->add(nodePos);
|
path->add(nodePos);
|
||||||
}
|
}
|
||||||
else {
|
else if(tryLastPathCache == false) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(tryLastPathCache == true && basicPathFinder) {
|
||||||
|
basicPathFinder->addToLastPathCache(nodePos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return factions[unit->getFactionIndex()].precachedTravelState[unit->getId()];
|
return factions[unit->getFactionIndex()].precachedTravelState[unit->getId()];
|
||||||
}
|
}
|
||||||
|
@ -474,10 +481,9 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled == true && chrono.getMillis() > 4) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled == true && chrono.getMillis() > 4) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
|
|
||||||
// Check the previous path find cache for the unit to see if its good to
|
// Check the previous path find cache for the unit to see if its good to
|
||||||
// use
|
// use
|
||||||
const bool showConsoleDebugInfo = Config::getInstance().getBool("EnablePathfinderDistanceOutput","false");
|
|
||||||
const bool tryLastPathCache = Config::getInstance().getBool("EnablePathfinderCache","false");
|
|
||||||
if((showConsoleDebugInfo || tryLastPathCache) && dist > 60) {
|
if((showConsoleDebugInfo || tryLastPathCache) && dist > 60) {
|
||||||
if(showConsoleDebugInfo) printf("Distance from [%d - %s] to destination is %.2f tryLastPathCache = %d\n",unit->getId(),unit->getFullName().c_str(), dist,tryLastPathCache);
|
if(showConsoleDebugInfo) printf("Distance from [%d - %s] to destination is %.2f tryLastPathCache = %d\n",unit->getId(),unit->getFullName().c_str(), dist,tryLastPathCache);
|
||||||
|
|
||||||
|
@ -501,17 +507,25 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled == true && chrono.getMillis() > 4) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled == true && chrono.getMillis() > 4) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
//store path
|
//store path
|
||||||
|
if(frameIndex < 0) {
|
||||||
basicPathFinder->clear();
|
basicPathFinder->clear();
|
||||||
|
}
|
||||||
|
|
||||||
int pathCount=0;
|
int pathCount=0;
|
||||||
for(int k=i+1; k <= j; k++) {
|
for(int k=i+1; k <= j; k++) {
|
||||||
if(k >= cachedPath.size()) {
|
if(k >= cachedPath.size()) {
|
||||||
throw runtime_error("k >= cachedPath.size() k = " + intToStr(k) + " cachedPath.size() = " + intToStr(cachedPath.size()));
|
throw runtime_error("k >= cachedPath.size() k = " + intToStr(k) + " cachedPath.size() = " + intToStr(cachedPath.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(frameIndex >= 0) {
|
||||||
|
factions[unit->getFactionIndex()].precachedPath[unit->getId()].push_back(cachedPath[k]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
if(pathCount < pathFindRefresh) {
|
if(pathCount < pathFindRefresh) {
|
||||||
basicPathFinder->add(cachedPath[k]);
|
basicPathFinder->add(cachedPath[k]);
|
||||||
}
|
}
|
||||||
basicPathFinder->addToLastPathCache(cachedPath[k]);
|
basicPathFinder->addToLastPathCache(cachedPath[k]);
|
||||||
|
}
|
||||||
pathCount++;
|
pathCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,7 +562,9 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled == true && chrono.getMillis() > 4) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled == true && chrono.getMillis() > 4) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
//store path
|
//store path
|
||||||
|
if(frameIndex < 0) {
|
||||||
basicPathFinder->clear();
|
basicPathFinder->clear();
|
||||||
|
}
|
||||||
|
|
||||||
int pathCount=0;
|
int pathCount=0;
|
||||||
for(int k=i+1; k < cachedPath.size(); k++) {
|
for(int k=i+1; k < cachedPath.size(); k++) {
|
||||||
|
@ -556,10 +572,15 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
throw runtime_error("#2 k >= cachedPath.size() k = " + intToStr(k) + " cachedPath.size() = " + intToStr(cachedPath.size()));
|
throw runtime_error("#2 k >= cachedPath.size() k = " + intToStr(k) + " cachedPath.size() = " + intToStr(cachedPath.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(frameIndex >= 0) {
|
||||||
|
factions[unit->getFactionIndex()].precachedPath[unit->getId()].push_back(cachedPath[k]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
if(pathCount < pathFindRefresh) {
|
if(pathCount < pathFindRefresh) {
|
||||||
basicPathFinder->add(cachedPath[k]);
|
basicPathFinder->add(cachedPath[k]);
|
||||||
}
|
}
|
||||||
basicPathFinder->addToLastPathCache(cachedPath[k]);
|
basicPathFinder->addToLastPathCache(cachedPath[k]);
|
||||||
|
}
|
||||||
pathCount++;
|
pathCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -600,7 +621,6 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//path find algorithm
|
//path find algorithm
|
||||||
|
|
||||||
//a) push starting pos into openNodes
|
//a) push starting pos into openNodes
|
||||||
|
|
|
@ -656,7 +656,8 @@ void Faction::applyCostsOnInterval(const ResourceType *rtApply) {
|
||||||
scriptManager->onUnitDied(unit);
|
scriptManager->onUnitDied(unit);
|
||||||
}
|
}
|
||||||
StaticSound *sound= unit->getType()->getFirstStOfClass(scDie)->getSound();
|
StaticSound *sound= unit->getType()->getFirstStOfClass(scDie)->getSound();
|
||||||
if(sound != NULL && thisFaction) {
|
if(sound != NULL &&
|
||||||
|
(thisFaction == true || (world->getThisTeamIndex() == GameConstants::maxPlayers -1 + fpt_Observer))) {
|
||||||
SoundRenderer::getInstance().playFx(sound);
|
SoundRenderer::getInstance().playFx(sound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1032,12 +1032,18 @@ void Unit::kill() {
|
||||||
|
|
||||||
//clear commands
|
//clear commands
|
||||||
clearCommands();
|
clearCommands();
|
||||||
|
|
||||||
|
UnitUpdater *unitUpdater = game->getWorld()->getUnitUpdater();
|
||||||
|
unitUpdater->clearUnitPrecache(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::undertake() {
|
void Unit::undertake() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to undertake unit id = %d [%s] [%s]\n",
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to undertake unit id = %d [%s] [%s]\n",
|
||||||
__FILE__,__FUNCTION__,__LINE__,this->id, this->getFullName().c_str(),this->getDesc().c_str());
|
__FILE__,__FUNCTION__,__LINE__,this->id, this->getFullName().c_str(),this->getDesc().c_str());
|
||||||
|
|
||||||
|
UnitUpdater *unitUpdater = game->getWorld()->getUnitUpdater();
|
||||||
|
unitUpdater->clearUnitPrecache(this);
|
||||||
|
|
||||||
livingUnits.erase(id);
|
livingUnits.erase(id);
|
||||||
livingUnitsp.erase(this);
|
livingUnitsp.erase(this);
|
||||||
faction->removeUnit(this);
|
faction->removeUnit(this);
|
||||||
|
@ -1287,7 +1293,9 @@ void Unit::tick() {
|
||||||
game->getScriptManager()->onUnitDied(this);
|
game->getScriptManager()->onUnitDied(this);
|
||||||
}
|
}
|
||||||
StaticSound *sound= this->getType()->getFirstStOfClass(scDie)->getSound();
|
StaticSound *sound= this->getType()->getFirstStOfClass(scDie)->getSound();
|
||||||
if(sound != NULL && this->getFactionIndex() == Unit::game->getWorld()->getThisFactionIndex()) {
|
if(sound != NULL &&
|
||||||
|
(this->getFactionIndex() == Unit::game->getWorld()->getThisFactionIndex() ||
|
||||||
|
(game->getWorld()->getThisTeamIndex() == GameConstants::maxPlayers -1 + fpt_Observer))) {
|
||||||
SoundRenderer::getInstance().playFx(sound);
|
SoundRenderer::getInstance().playFx(sound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,10 +115,11 @@ void UnitUpdater::updateUnit(Unit *unit) {
|
||||||
|
|
||||||
//play skill sound
|
//play skill sound
|
||||||
const SkillType *currSkill= unit->getCurrSkill();
|
const SkillType *currSkill= unit->getCurrSkill();
|
||||||
if(currSkill->getSound()!=NULL) {
|
if(currSkill->getSound() != NULL) {
|
||||||
float soundStartTime= currSkill->getSoundStartTime();
|
float soundStartTime= currSkill->getSoundStartTime();
|
||||||
if(soundStartTime>=unit->getLastAnimProgress() && soundStartTime<unit->getAnimProgress()) {
|
if(soundStartTime >= unit->getLastAnimProgress() && soundStartTime < unit->getAnimProgress()) {
|
||||||
if(map->getSurfaceCell(Map::toSurfCoords(unit->getPos()))->isVisible(world->getThisTeamIndex())) {
|
if(map->getSurfaceCell(Map::toSurfCoords(unit->getPos()))->isVisible(world->getThisTeamIndex()) ||
|
||||||
|
(game->getWorld()->getThisTeamIndex() == GameConstants::maxPlayers -1 + fpt_Observer)) {
|
||||||
soundRenderer.playFx(currSkill->getSound(), unit->getCurrVector(), gameCamera->getPos());
|
soundRenderer.playFx(currSkill->getSound(), unit->getCurrVector(), gameCamera->getPos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -665,7 +666,8 @@ void UnitUpdater::updateBuild(Unit *unit, int frameIndex) {
|
||||||
command->setUnit(builtUnit);
|
command->setUnit(builtUnit);
|
||||||
|
|
||||||
//play start sound
|
//play start sound
|
||||||
if(unit->getFactionIndex() == world->getThisFactionIndex()) {
|
if(unit->getFactionIndex() == world->getThisFactionIndex() ||
|
||||||
|
(game->getWorld()->getThisTeamIndex() == GameConstants::maxPlayers -1 + fpt_Observer)) {
|
||||||
SoundRenderer::getInstance().playFx(
|
SoundRenderer::getInstance().playFx(
|
||||||
bct->getStartSound(),
|
bct->getStartSound(),
|
||||||
unit->getCurrVector(),
|
unit->getCurrVector(),
|
||||||
|
@ -736,7 +738,8 @@ void UnitUpdater::updateBuild(Unit *unit, int frameIndex) {
|
||||||
|
|
||||||
builtUnit->born();
|
builtUnit->born();
|
||||||
scriptManager->onUnitCreated(builtUnit);
|
scriptManager->onUnitCreated(builtUnit);
|
||||||
if(unit->getFactionIndex() == world->getThisFactionIndex()) {
|
if(unit->getFactionIndex() == world->getThisFactionIndex() ||
|
||||||
|
(game->getWorld()->getThisTeamIndex() == GameConstants::maxPlayers -1 + fpt_Observer)) {
|
||||||
SoundRenderer::getInstance().playFx(
|
SoundRenderer::getInstance().playFx(
|
||||||
bct->getBuiltSound(),
|
bct->getBuiltSound(),
|
||||||
unit->getCurrVector(),
|
unit->getCurrVector(),
|
||||||
|
@ -2078,7 +2081,7 @@ void ParticleDamager::update(ParticleSystem *particleSystem) {
|
||||||
|
|
||||||
//play sound
|
//play sound
|
||||||
StaticSound *projSound= ast->getProjSound();
|
StaticSound *projSound= ast->getProjSound();
|
||||||
if(particleSystem->getVisible() && projSound!=NULL){
|
if(particleSystem->getVisible() && projSound != NULL) {
|
||||||
SoundRenderer::getInstance().playFx(projSound, attacker->getCurrVector(), gameCamera->getPos());
|
SoundRenderer::getInstance().playFx(projSound, attacker->getCurrVector(), gameCamera->getPos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,6 +112,8 @@ public:
|
||||||
void updateUpgrade(Unit *unit, int frameIndex);
|
void updateUpgrade(Unit *unit, int frameIndex);
|
||||||
void updateMorph(Unit *unit, int frameIndex);
|
void updateMorph(Unit *unit, int frameIndex);
|
||||||
|
|
||||||
|
void clearUnitPrecache(Unit *unit);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//attack
|
//attack
|
||||||
void hit(Unit *attacker);
|
void hit(Unit *attacker);
|
||||||
|
@ -132,8 +134,6 @@ private:
|
||||||
void SwapActiveCommandState(Unit *unit, CommandStateType commandStateType,
|
void SwapActiveCommandState(Unit *unit, CommandStateType commandStateType,
|
||||||
const CommandType *commandType,
|
const CommandType *commandType,
|
||||||
int originalValue,int newValue);
|
int originalValue,int newValue);
|
||||||
|
|
||||||
void clearUnitPrecache(Unit *unit);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
Loading…
Reference in New Issue