1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

1.blocked critical AI call

2.Yet another chapter of epic battle with creature banks
This commit is contained in:
DjWarmonger 2009-08-24 14:59:24 +00:00
parent 2c7d7f4094
commit 82ddb607e6
3 changed files with 35 additions and 38 deletions

View File

@ -177,12 +177,12 @@ float Priorities::getValue(const CGeniusAI::AIObjective & obj)
if(dynamic_cast<const CGTownInstance*>(hobj->object)->getOwner()==obj.AI->m_cb->getMyColor())//friendly town
{
stateFeatures[17] = dynamic_cast<const CGTownInstance*>(hobj->object)->getArmyStrength();
return objectNetworks[98][0].feedForward(stateFeatures);
return 0; // objectNetworks[98][0].feedForward(stateFeatures);
}
else
{
stateFeatures[17] = dynamic_cast<const CGTownInstance*>(hobj->object)->getArmyStrength();
return objectNetworks[98][1].feedForward(stateFeatures);
return 0; //objectNetworks[98][1].feedForward(stateFeatures);
}
break;
@ -197,7 +197,8 @@ float Priorities::getValue(const CGeniusAI::AIObjective & obj)
case 215://quest guard
return 0;
case 53: //various mines
return objectNetworks[53][hobj->object->subID].feedForward(stateFeatures);
return 0; //out of range crash
//objectNetworks[53][hobj->object->subID].feedForward(stateFeatures);
case 113://TODO: replace with value of skill for the hero
return 0;
case 103:case 58://TODO: replace with value of seeing x number of new tiles

View File

@ -1443,8 +1443,8 @@ void CGTownInstance::onHeroVisit(const CGHeroInstance * h) const
cb->setOwner(id, h->tempOwner);
}
}
for (std::vector<CGTownBuilding>::const_iterator i = bonusingBuildings.begin(); i != bonusingBuildings.end(); i++)
i->onHeroVisit (h);
for (std::vector<CGTownBuilding*>::const_iterator i = bonusingBuildings.begin(); i != bonusingBuildings.end(); i++)
(*i)->onHeroVisit (h);
cb->heroVisitCastle(id, h->id);
}
@ -1468,10 +1468,10 @@ void CGTownInstance::initObj()
switch (alignment)
{ //add new visitable objects
case 2: case 3: case 5: case 6:
bonusingBuildings.push_back(CTownBonus(23, this));
bonusingBuildings.push_back(new CTownBonus(23, this));
break;
case 7:
bonusingBuildings.push_back(CTownBonus(17, this));
bonusingBuildings.push_back(new CTownBonus(17, this));
break;
}
}
@ -3703,7 +3703,7 @@ void CBank::initObj()
case 16: //bank
index = subID; break;
case 24: //derelict ship
index = 8;
index = 8; break;
case 25: //utopia
index = 10; break;
case 84: //crypt
@ -3718,19 +3718,36 @@ void CBank::initObj()
}
void CBank::reset()
{
int val1 = ran()%100;
int chance = 0;
for (ui8 i = 0; i < VLC->objh->banksInfo[index].size(); i++)
{
// if (val1 < (chance += VLC->objh->banksInfo[index][i].chance))
// cb->setObjProperty (id, 13, i);
{
if (val1 < (chance += VLC->objh->banksInfo[index][i].chance))
bc = &VLC->objh->banksInfo[index][i];
}
artifacts.clear();
std::vector<CArtifact*> arts;
for (ui8 i = 1; i <= 4; i++)
{
// for (ui8 j = 1; j <= bc->artifacts[i]; j++)
// cb->setObjProperty (id, 18, i);
{
for (ui8 n = 1; n <= bc->artifacts[i - 1]; n++)
{
switch (i)
{
case 1:
cb->getAllowed (arts, CArtifact::ART_TREASURE);
break;
case 2:
cb->getAllowed (arts, CArtifact::ART_MINOR);
break;
case 3:
cb->getAllowed (arts, CArtifact::ART_MAJOR);
break;
case 4:
cb->getAllowed (arts, CArtifact::ART_RELIC);
break;
}
artifacts.push_back (arts[ran() % arts.size()]->id);
}
}
}
@ -3759,27 +3776,6 @@ void CBank::setPropertyDer (ui8 what, ui32 val)
case 16:
artifacts.clear();
break;
case 18: //Artifacts
{
std::vector<CArtifact*> arts;
switch (val)
{
case 1:
cb->getAllowed (arts, CArtifact::ART_TREASURE);
break;
case 2:
cb->getAllowed (arts, CArtifact::ART_MINOR);
break;
case 3:
cb->getAllowed (arts, CArtifact::ART_MAJOR);
break;
case 4:
cb->getAllowed (arts, CArtifact::ART_RELIC);
break;
}
artifacts.push_back (arts[ran() % arts.size()]->id);
}
break;
}
}
@ -3826,7 +3822,7 @@ void CBank::onHeroVisit (const CGHeroInstance * h) const
BlockingDialog bd (true, false);
bd.player = h->getOwner();
bd.soundID = soundBase::DANGER;
std::string desc = VLC->generaltexth->allTexts[banktext];
std::string desc = VLC->generaltexth->advobtxt[banktext];
boost::algorithm::replace_first (desc, "%s", VLC->generaltexth->names[ID]);
bd.text << desc;
cb->showBlockingDialog (&bd, boost::bind (&CBank::fightGuards, this, h, _1));

View File

@ -383,7 +383,7 @@ public:
ui32 identifier; //special identifier from h3m (only > RoE maps)
si32 alignment;
std::set<si32> forbiddenBuildings, builtBuildings;
std::vector<CGTownBuilding> bonusingBuildings;
std::vector<CGTownBuilding*> bonusingBuildings;
std::vector<ui32> possibleSpells, obligatorySpells;
std::vector<std::vector<ui32> > spells; //spells[level] -> vector of spells, first will be available in guild