1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +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 if(dynamic_cast<const CGTownInstance*>(hobj->object)->getOwner()==obj.AI->m_cb->getMyColor())//friendly town
{ {
stateFeatures[17] = dynamic_cast<const CGTownInstance*>(hobj->object)->getArmyStrength(); stateFeatures[17] = dynamic_cast<const CGTownInstance*>(hobj->object)->getArmyStrength();
return objectNetworks[98][0].feedForward(stateFeatures); return 0; // objectNetworks[98][0].feedForward(stateFeatures);
} }
else else
{ {
stateFeatures[17] = dynamic_cast<const CGTownInstance*>(hobj->object)->getArmyStrength(); stateFeatures[17] = dynamic_cast<const CGTownInstance*>(hobj->object)->getArmyStrength();
return objectNetworks[98][1].feedForward(stateFeatures); return 0; //objectNetworks[98][1].feedForward(stateFeatures);
} }
break; break;
@ -197,7 +197,8 @@ float Priorities::getValue(const CGeniusAI::AIObjective & obj)
case 215://quest guard case 215://quest guard
return 0; return 0;
case 53: //various mines 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 case 113://TODO: replace with value of skill for the hero
return 0; return 0;
case 103:case 58://TODO: replace with value of seeing x number of new tiles 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); cb->setOwner(id, h->tempOwner);
} }
} }
for (std::vector<CGTownBuilding>::const_iterator i = bonusingBuildings.begin(); i != bonusingBuildings.end(); i++) for (std::vector<CGTownBuilding*>::const_iterator i = bonusingBuildings.begin(); i != bonusingBuildings.end(); i++)
i->onHeroVisit (h); (*i)->onHeroVisit (h);
cb->heroVisitCastle(id, h->id); cb->heroVisitCastle(id, h->id);
} }
@ -1468,10 +1468,10 @@ void CGTownInstance::initObj()
switch (alignment) switch (alignment)
{ //add new visitable objects { //add new visitable objects
case 2: case 3: case 5: case 6: case 2: case 3: case 5: case 6:
bonusingBuildings.push_back(CTownBonus(23, this)); bonusingBuildings.push_back(new CTownBonus(23, this));
break; break;
case 7: case 7:
bonusingBuildings.push_back(CTownBonus(17, this)); bonusingBuildings.push_back(new CTownBonus(17, this));
break; break;
} }
} }
@ -3703,7 +3703,7 @@ void CBank::initObj()
case 16: //bank case 16: //bank
index = subID; break; index = subID; break;
case 24: //derelict ship case 24: //derelict ship
index = 8; index = 8; break;
case 25: //utopia case 25: //utopia
index = 10; break; index = 10; break;
case 84: //crypt case 84: //crypt
@ -3718,19 +3718,36 @@ void CBank::initObj()
} }
void CBank::reset() void CBank::reset()
{ {
int val1 = ran()%100; int val1 = ran()%100;
int chance = 0; int chance = 0;
for (ui8 i = 0; i < VLC->objh->banksInfo[index].size(); i++) for (ui8 i = 0; i < VLC->objh->banksInfo[index].size(); i++)
{ {
// if (val1 < (chance += VLC->objh->banksInfo[index][i].chance)) if (val1 < (chance += VLC->objh->banksInfo[index][i].chance))
// cb->setObjProperty (id, 13, i); bc = &VLC->objh->banksInfo[index][i];
} }
artifacts.clear(); artifacts.clear();
std::vector<CArtifact*> arts;
for (ui8 i = 1; i <= 4; i++) for (ui8 i = 1; i <= 4; i++)
{ {
// for (ui8 j = 1; j <= bc->artifacts[i]; j++) for (ui8 n = 1; n <= bc->artifacts[i - 1]; n++)
// cb->setObjProperty (id, 18, i); {
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: case 16:
artifacts.clear(); artifacts.clear();
break; 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); BlockingDialog bd (true, false);
bd.player = h->getOwner(); bd.player = h->getOwner();
bd.soundID = soundBase::DANGER; 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]); boost::algorithm::replace_first (desc, "%s", VLC->generaltexth->names[ID]);
bd.text << desc; bd.text << desc;
cb->showBlockingDialog (&bd, boost::bind (&CBank::fightGuards, this, h, _1)); 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) ui32 identifier; //special identifier from h3m (only > RoE maps)
si32 alignment; si32 alignment;
std::set<si32> forbiddenBuildings, builtBuildings; std::set<si32> forbiddenBuildings, builtBuildings;
std::vector<CGTownBuilding> bonusingBuildings; std::vector<CGTownBuilding*> bonusingBuildings;
std::vector<ui32> possibleSpells, obligatorySpells; std::vector<ui32> possibleSpells, obligatorySpells;
std::vector<std::vector<ui32> > spells; //spells[level] -> vector of spells, first will be available in guild std::vector<std::vector<ui32> > spells; //spells[level] -> vector of spells, first will be available in guild