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

Method doUpkeep

source/rooms/RoomPortal.cpp:209–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209void RoomPortal::doUpkeep()
210{
211 // Call the super class Room::doUpkeep() function to do any generic upkeep common to all rooms.
212 Room::doUpkeep();
213
214 if(mSpawnCreatureCountdown > 0)
215 {
216 --mSpawnCreatureCountdown;
217 return;
218 }
219 mSpawnCreatureCountdown = Random::Uint(ConfigManager::getSingleton().getRoomConfigUInt32("PortalCooldownSpawnMin"),
220 ConfigManager::getSingleton().getRoomConfigUInt32("PortalCooldownSpawnMax"));
221
222 if (mCoveredTiles.empty())
223 return;
224
225 // Rogue seat cannot spawn creatures through normal portal (they won't spawn
226 // anyway since there is no spawning list for rogue seat but no need to compute
227 // everything in this case)
228 if(getSeat()->isRogueSeat())
229 return;
230
231 if(getSeat()->getPlayer() == nullptr)
232 return;
233
234 if(getSeat()->getPlayer()->getHasLost())
235 return;
236
237 // Randomly choose to spawn a creature.
238 const double maxCreatures = getSeat()->getNumCreaturesFightersMax();
239 // Count how many creatures are controlled by this seat
240 double numCreatures = getSeat()->getNumCreaturesFighters();
241 if(numCreatures >= maxCreatures)
242 return;
243
244 spawnCreature();
245}
246
247void RoomPortal::spawnCreature()
248{

Callers

nothing calls this directly

Calls 7

UintFunction · 0.85
getRoomConfigUInt32Method · 0.80
isRogueSeatMethod · 0.80
getHasLostMethod · 0.80
getPlayerMethod · 0.45

Tested by

no test coverage detected