alarmsound when enemy units are seen ( will be improved soon )
This commit is contained in:
parent
6a99e2db8e
commit
886bd3b37e
|
@ -67,12 +67,12 @@ enum Queueability {
|
||||||
|
|
||||||
class CommandType: public RequirableType {
|
class CommandType: public RequirableType {
|
||||||
protected:
|
protected:
|
||||||
CommandClass commandTypeClass;
|
|
||||||
Clicks clicks;
|
Clicks clicks;
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const int invalidId= -1;
|
static const int invalidId= -1;
|
||||||
|
CommandClass commandTypeClass;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CommandType() {
|
CommandType() {
|
||||||
|
|
|
@ -53,6 +53,7 @@ UnitUpdater::UnitUpdater() {
|
||||||
this->scriptManager= NULL;
|
this->scriptManager= NULL;
|
||||||
this->routePlanner = NULL;
|
this->routePlanner = NULL;
|
||||||
this->pathFinder = NULL;
|
this->pathFinder = NULL;
|
||||||
|
lastWarnFrameCount=0;
|
||||||
//UnitRangeCellsLookupItemCacheTimerCount = 0;
|
//UnitRangeCellsLookupItemCacheTimerCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +68,7 @@ void UnitUpdater::init(Game *game){
|
||||||
this->scriptManager= game->getScriptManager();
|
this->scriptManager= game->getScriptManager();
|
||||||
this->routePlanner = NULL;
|
this->routePlanner = NULL;
|
||||||
this->pathFinder = NULL;
|
this->pathFinder = NULL;
|
||||||
|
lastWarnFrameCount=0;
|
||||||
//UnitRangeCellsLookupItemCacheTimerCount = 0;
|
//UnitRangeCellsLookupItemCacheTimerCount = 0;
|
||||||
|
|
||||||
switch(this->game->getGameSettings()->getPathFinderType()) {
|
switch(this->game->getGameSettings()->getPathFinderType()) {
|
||||||
|
@ -180,6 +182,12 @@ void UnitUpdater::updateUnitCommand(Unit *unit) {
|
||||||
|
|
||||||
//if unit has command process it
|
//if unit has command process it
|
||||||
if(unit->anyCommand()) {
|
if(unit->anyCommand()) {
|
||||||
|
CommandClass cc=unit->getCurrCommand()->getCommandType()->commandTypeClass;
|
||||||
|
if(unit->isOperative() && (!(cc==ccStop || cc==ccAttack)) )
|
||||||
|
{//stop and attack already check for themselves
|
||||||
|
Unit *sighted;
|
||||||
|
attackerOnSight(unit, &sighted);
|
||||||
|
}
|
||||||
unit->getCurrCommand()->getCommandType()->update(this, unit);
|
unit->getCurrCommand()->getCommandType()->update(this, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,6 +202,12 @@ void UnitUpdater::updateUnitCommand(Unit *unit) {
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
unit->giveCommand(new Command(unit->getType()->getFirstCtOfClass(ccStop)));
|
unit->giveCommand(new Command(unit->getType()->getFirstCtOfClass(ccStop)));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// buidings have no stop skill but hav to check for attackers too.
|
||||||
|
Unit *sighted;
|
||||||
|
attackerOnSight(unit, &sighted);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
@ -1692,7 +1706,7 @@ void UnitUpdater::findEnemiesForCell(const AttackSkillType *ast, Cell *cell, con
|
||||||
bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr,
|
bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr,
|
||||||
const AttackSkillType *ast){
|
const AttackSkillType *ast){
|
||||||
vector<Unit*> enemies;
|
vector<Unit*> enemies;
|
||||||
|
bool result=false;
|
||||||
//we check command target
|
//we check command target
|
||||||
const Unit *commandTarget = NULL;
|
const Unit *commandTarget = NULL;
|
||||||
if(unit->anyCommand()) {
|
if(unit->anyCommand()) {
|
||||||
|
@ -1743,18 +1757,30 @@ bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr,
|
||||||
if(enemies[i]->getType()->hasSkillClass(scAttack)) {
|
if(enemies[i]->getType()->hasSkillClass(scAttack)) {
|
||||||
*rangedPtr= enemies[i];
|
*rangedPtr= enemies[i];
|
||||||
|
|
||||||
return true;
|
result=true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//any enemy
|
//any enemy
|
||||||
if(enemies.size() > 0) {
|
if(!result && (enemies.size() > 0)) {
|
||||||
*rangedPtr= enemies.front();
|
*rangedPtr= enemies.front();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
if(result)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(world->getFrameCount()-lastWarnFrameCount>80) //after 100 frames attack break we warn again
|
||||||
|
{
|
||||||
|
SoundRenderer::getInstance().playFx(CoreData::getInstance().getAttentionSound());
|
||||||
|
}
|
||||||
|
lastWarnFrameCount=world->getFrameCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
|
@ -70,6 +70,7 @@ private:
|
||||||
RoutePlanner *routePlanner;
|
RoutePlanner *routePlanner;
|
||||||
Game *game;
|
Game *game;
|
||||||
RandomGen random;
|
RandomGen random;
|
||||||
|
int lastWarnFrameCount;
|
||||||
|
|
||||||
std::map<Vec2i, std::map<int, std::map<int, UnitRangeCellsLookupItem > > > UnitRangeCellsLookupItemCache;
|
std::map<Vec2i, std::map<int, std::map<int, UnitRangeCellsLookupItem > > > UnitRangeCellsLookupItemCache;
|
||||||
//std::map<int,ExploredCellsLookupKey> ExploredCellsLookupItemCacheTimer;
|
//std::map<int,ExploredCellsLookupKey> ExploredCellsLookupItemCacheTimer;
|
||||||
|
|
Loading…
Reference in New Issue