MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / doUpkeep

Method doUpkeep

source/rooms/RoomCrypt.cpp:193–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191}
192
193void RoomCrypt::doUpkeep()
194{
195 Room::doUpkeep();
196
197 if(mCoveredTiles.empty())
198 return;
199
200 // Each central active spot has a probability to spawn a spider
201 for(Tile* tile : mCentralActiveSpotTiles)
202 {
203 if(Random::Int(1, 10) > 1)
204 continue;
205
206 SmallSpiderEntity* spider = new SmallSpiderEntity(getGameMap(), getName(), 10);
207 Ogre::Vector3 pos(static_cast<Ogre::Real>(tile->getX()), static_cast<Ogre::Real>(tile->getY()), 0.0f);
208 spider->addToGameMap();
209 spider->createMesh();
210 spider->setPosition(pos);
211 }
212
213 // We increment rotting creatures counter
214 for(std::pair<Tile* const, std::pair<Creature*, int32_t> >& p : mRottingCreatures)
215 {
216 if((p.second.first == nullptr) || (p.second.second == -1))
217 continue;
218
219 ConfigManager& configManager = ConfigManager::getSingleton();
220
221 ++p.second.second;
222 if(p.second.second < configManager.getRoomConfigInt32("CryptRotNbTurns"))
223 continue;
224
225 // We add the rotten creature points to the room and release the active spot
226 double coef = 1.0 + static_cast<double>(mNumActiveSpots - mCentralActiveSpotTiles.size()) * configManager.getRoomConfigDouble("CryptBonusWallActiveSpot");
227 Creature* c = p.second.first;
228 mRottenPoints += static_cast<int32_t>(c->getMaxHp() * coef);
229
230 c->removeFromGameMap();
231 c->deleteYourself();
232 p.second.first = nullptr;
233 p.second.second = -1;
234
235 int32_t maxCreatures = configManager.getMaxCreaturesPerSeatAbsolute();
236 int32_t numCreatures = getGameMap()->getCreaturesBySeat(getSeat()).size();
237 int32_t cryptPointsForSpawn = configManager.getRoomConfigInt32("CryptPointsForSpawn");
238 if((numCreatures < maxCreatures) &&
239 (mRottenPoints >= cryptPointsForSpawn))
240 {
241 Tile* tileSpawn = p.first;
242 mRottenPoints -= cryptPointsForSpawn;
243 const std::string& className = configManager.getRoomConfigString("CryptSpawnClass");
244 const CreatureDefinition* classToSpawn = getGameMap()->getClassDescription(className);
245 if(classToSpawn == nullptr)
246 {
247 OD_LOG_ERR("className=" + className);
248 continue;
249 }
250

Callers

nothing calls this directly

Calls 15

IntFunction · 0.85
Vector3Class · 0.85
createMeshMethod · 0.80
getRoomConfigInt32Method · 0.80
getRoomConfigDoubleMethod · 0.80
getMaxHpMethod · 0.80
deleteYourselfMethod · 0.80
getCreaturesBySeatMethod · 0.80
getClassDescriptionMethod · 0.80
getIsHumanMethod · 0.80
getHasLostMethod · 0.80

Tested by

no test coverage detected