italien translation; Multiattack warnings ( with setting AttackWarnRange )

This commit is contained in:
Titus Tscharntke 2010-12-21 15:55:37 +00:00
parent 443096d0db
commit 43eb95f1b4
3 changed files with 74 additions and 10 deletions

View File

@ -1338,7 +1338,7 @@ void MenuStateCustomGame::render() {
int mouse2dAnim = mainMenu->getMouse2dAnim();
renderer.renderMouse2d(mouseX, mouseY, mouse2dAnim);
bool renderAll = (listBoxFogOfWar.getSelectedItemIndex() == 1);
bool renderAll = (listBoxFogOfWar.getSelectedItemIndex() == 2);
if(mapPreviewTexture == NULL) {
//printf("=================> Rendering map preview into a texture BEFORE (%p)\n", mapPreviewTexture);

View File

@ -53,7 +53,6 @@ UnitUpdater::UnitUpdater() {
this->scriptManager= NULL;
this->routePlanner = NULL;
this->pathFinder = NULL;
lastWarnFrameCount=0;
//UnitRangeCellsLookupItemCacheTimerCount = 0;
}
@ -68,7 +67,7 @@ void UnitUpdater::init(Game *game){
this->scriptManager= game->getScriptManager();
this->routePlanner = NULL;
this->pathFinder = NULL;
lastWarnFrameCount=0;
attackWarnRange=Config::getInstance().getFloat("AttackWarnRange","50.0");
//UnitRangeCellsLookupItemCacheTimerCount = 0;
switch(this->game->getGameSettings()->getPathFinderType()) {
@ -89,6 +88,12 @@ UnitUpdater::~UnitUpdater() {
delete pathFinder;
pathFinder = NULL;
while(attackWarnings.empty() == false) {
AttackWarningData* awd=attackWarnings.back();
attackWarnings.pop_back();
delete awd;
}
}
// ==================== progress skills ====================
@ -1782,12 +1787,63 @@ bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr,
if(result && !(unit->isAlly(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();
// find nearest Attack and cleanup old dates
AttackWarningData *nearest=NULL;
float currentDistance;
float nearestDistance;
for(int i = attackWarnings.size()-1; i>-1; --i) {
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();
}

View File

@ -49,9 +49,16 @@ public:
static time_t lastDebug;
};
class AttackWarningData {
public:
Vec2f attackPosition;
int lastFrameCount;
};
class UnitUpdater {
private:
friend class ParticleDamager;
typedef vector<AttackWarningData*> AttackWarnings;
private:
static const int maxResSearchRadius= 10;
@ -70,7 +77,8 @@ private:
RoutePlanner *routePlanner;
Game *game;
RandomGen random;
int lastWarnFrameCount;
float attackWarnRange;
AttackWarnings attackWarnings;
std::map<Vec2i, std::map<int, std::map<int, UnitRangeCellsLookupItem > > > UnitRangeCellsLookupItemCache;
//std::map<int,ExploredCellsLookupKey> ExploredCellsLookupItemCacheTimer;