| 767 | } |
| 768 | |
| 769 | void 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 |
nothing calls this directly
no test coverage detected