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

Method doUpkeep

source/entities/Creature.cpp:769–1024  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

767}
768
769void Creature::doUpkeep()
770{
771 // If the creature is in jail, we check if it is still standing on it (if not picked up). If
772 // not, it is free
773 if((mSeatPrison != nullptr) &&
774 getIsOnMap())
775 {
776 Tile* myTile = getPositionTile();
777 if(myTile == nullptr)
778 {
779 OD_LOG_ERR("name=" + getName() + ", position=" + Helper::toString(getPosition()));
780 return;
781 }
782
783 // We check if the creature is in containment
784 Room* roomPrison = myTile->getCoveringRoom();
785 if((roomPrison == nullptr) ||
786 (!roomPrison->isInContainment(*this)))
787 {
788 // it is not standing on a jail. It is free
789 mSeatPrison = nullptr;
790 mNeedFireRefresh = true;
791 }
792 }
793
794 // The creature may be killed while temporary KO
795 if((mKoTurnCounter != 0) && !isAlive())
796 mKoTurnCounter = 0;
797
798 // If the creature is KO to death or dead, we remove its particle effects
799 if(!mEntityParticleEffects.empty() &&
800 ((mKoTurnCounter < 0) || !isAlive()))
801 {
802 for(EntityParticleEffect* effect : mEntityParticleEffects)
803 {
804 delete effect;
805 }
806 mEntityParticleEffects.clear();
807 }
808
809 // We apply creature effects if any
810 for(auto it = mEntityParticleEffects.begin(); it != mEntityParticleEffects.end();)
811 {
812 CreatureParticuleEffect* effect = static_cast<CreatureParticuleEffect*>(*it);
813 if(effect->mEffect->upkeepEffect(*this))
814 {
815 ++it;
816 continue;
817 }
818
819 delete effect;
820 it = mEntityParticleEffects.erase(it);
821 }
822
823 // if creature is not on map (picked up or being carried), we do nothing
824 if(!getIsOnMap())
825 return;
826

Callers

nothing calls this directly

Calls 15

IntFunction · 0.85
getCoveringRoomMethod · 0.80
clearMethod · 0.80
upkeepEffectMethod · 0.80
getHpHealPerTurnMethod · 0.80
isRogueSeatMethod · 0.80
getNbTurnsFuriousMaxMethod · 0.80
getSeatRogueMethod · 0.80
getCooldownNbTurnsMethod · 0.80

Tested by

no test coverage detected