mirror of
https://github.com/glest/glest-source.git
synced 2025-02-25 12:12:25 +01:00
italien translation; Multiattack warnings ( with setting AttackWarnRange )
This commit is contained in:
parent
443096d0db
commit
43eb95f1b4
@ -1338,7 +1338,7 @@ void MenuStateCustomGame::render() {
|
|||||||
int mouse2dAnim = mainMenu->getMouse2dAnim();
|
int mouse2dAnim = mainMenu->getMouse2dAnim();
|
||||||
|
|
||||||
renderer.renderMouse2d(mouseX, mouseY, mouse2dAnim);
|
renderer.renderMouse2d(mouseX, mouseY, mouse2dAnim);
|
||||||
bool renderAll = (listBoxFogOfWar.getSelectedItemIndex() == 1);
|
bool renderAll = (listBoxFogOfWar.getSelectedItemIndex() == 2);
|
||||||
|
|
||||||
if(mapPreviewTexture == NULL) {
|
if(mapPreviewTexture == NULL) {
|
||||||
//printf("=================> Rendering map preview into a texture BEFORE (%p)\n", mapPreviewTexture);
|
//printf("=================> Rendering map preview into a texture BEFORE (%p)\n", mapPreviewTexture);
|
||||||
|
@ -53,7 +53,6 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +67,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;
|
attackWarnRange=Config::getInstance().getFloat("AttackWarnRange","50.0");
|
||||||
//UnitRangeCellsLookupItemCacheTimerCount = 0;
|
//UnitRangeCellsLookupItemCacheTimerCount = 0;
|
||||||
|
|
||||||
switch(this->game->getGameSettings()->getPathFinderType()) {
|
switch(this->game->getGameSettings()->getPathFinderType()) {
|
||||||
@ -89,6 +88,12 @@ UnitUpdater::~UnitUpdater() {
|
|||||||
|
|
||||||
delete pathFinder;
|
delete pathFinder;
|
||||||
pathFinder = NULL;
|
pathFinder = NULL;
|
||||||
|
|
||||||
|
while(attackWarnings.empty() == false) {
|
||||||
|
AttackWarningData* awd=attackWarnings.back();
|
||||||
|
attackWarnings.pop_back();
|
||||||
|
delete awd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== progress skills ====================
|
// ==================== progress skills ====================
|
||||||
@ -1782,12 +1787,63 @@ bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr,
|
|||||||
|
|
||||||
if(result && !(unit->isAlly(enemySeen)))
|
if(result && !(unit->isAlly(enemySeen)))
|
||||||
{
|
{
|
||||||
if(world->getFrameCount()-lastWarnFrameCount>100) //after 100 frames attack break we warn again
|
// find nearest Attack and cleanup old dates
|
||||||
{
|
AttackWarningData *nearest=NULL;
|
||||||
world->addAttackEffects(enemySeen);
|
float currentDistance;
|
||||||
SoundRenderer::getInstance().playFx(CoreData::getInstance().getAttentionSound());
|
float nearestDistance;
|
||||||
}
|
for(int i = attackWarnings.size()-1; i>-1; --i) {
|
||||||
lastWarnFrameCount=world->getFrameCount();
|
if(world->getFrameCount()-attackWarnings[i]->lastFrameCount>100) { //after 100 frames attack break we warn again
|
||||||
|
AttackWarningData *toDelete=attackWarnings[i];
|
||||||
|
attackWarnings.erase(attackWarnings.begin()+i);
|
||||||
|
delete toDelete; // old one
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
currentDistance=floor(floatCenter.dist(attackWarnings[i]->attackPosition)); // no need for streflops here!
|
||||||
|
if( nearest==NULL ){
|
||||||
|
nearest=attackWarnings[i];
|
||||||
|
nearestDistance=currentDistance;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
if( currentDistance< nearestDistance ){
|
||||||
|
nearest=attackWarnings[i];
|
||||||
|
nearestDistance=currentDistance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(nearest!=NULL)
|
||||||
|
{ // does it fit?
|
||||||
|
if(nearestDistance<attackWarnRange)
|
||||||
|
{// update entry with current values
|
||||||
|
nearest->lastFrameCount=world->getFrameCount();
|
||||||
|
nearest->attackPosition.x=enemySeen->getFloatCenteredPos().x;
|
||||||
|
nearest->attackPosition.y=enemySeen->getFloatCenteredPos().y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{//Must be a different Attack!
|
||||||
|
nearest=NULL; //set to null to force a new entry in next step
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// add new attack
|
||||||
|
if(nearest==NULL) // no else!
|
||||||
|
{
|
||||||
|
AttackWarningData* awd= new AttackWarningData();
|
||||||
|
awd->lastFrameCount=world->getFrameCount();
|
||||||
|
awd->attackPosition.x=enemySeen->getFloatCenteredPos().x;
|
||||||
|
awd->attackPosition.y=enemySeen->getFloatCenteredPos().y;
|
||||||
|
attackWarnings.push_back(awd);
|
||||||
|
SoundRenderer::getInstance().playFx(CoreData::getInstance().getAttentionSound());
|
||||||
|
world->addAttackEffects(enemySeen);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if(world->getFrameCount()-lastWarnFrameCount>100) //after 100 frames attack break we warn again
|
||||||
|
// {
|
||||||
|
// world->addAttackEffects(enemySeen);
|
||||||
|
// SoundRenderer::getInstance().playFx(CoreData::getInstance().getAttentionSound());
|
||||||
|
// }
|
||||||
|
// lastWarnFrameCount=world->getFrameCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,9 +49,16 @@ public:
|
|||||||
static time_t lastDebug;
|
static time_t lastDebug;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AttackWarningData {
|
||||||
|
public:
|
||||||
|
Vec2f attackPosition;
|
||||||
|
int lastFrameCount;
|
||||||
|
};
|
||||||
|
|
||||||
class UnitUpdater {
|
class UnitUpdater {
|
||||||
private:
|
private:
|
||||||
friend class ParticleDamager;
|
friend class ParticleDamager;
|
||||||
|
typedef vector<AttackWarningData*> AttackWarnings;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int maxResSearchRadius= 10;
|
static const int maxResSearchRadius= 10;
|
||||||
@ -70,7 +77,8 @@ private:
|
|||||||
RoutePlanner *routePlanner;
|
RoutePlanner *routePlanner;
|
||||||
Game *game;
|
Game *game;
|
||||||
RandomGen random;
|
RandomGen random;
|
||||||
int lastWarnFrameCount;
|
float attackWarnRange;
|
||||||
|
AttackWarnings attackWarnings;
|
||||||
|
|
||||||
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…
x
Reference in New Issue
Block a user