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

Method computeCreatureOverlayHealthValue

source/entities/Creature.cpp:2875–2906  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2873}
2874
2875void Creature::computeCreatureOverlayHealthValue()
2876{
2877 if(!getIsOnServerMap())
2878 return;
2879
2880 uint32_t value = 0;
2881 double hp = getHP();
2882 // Note that we make a special case for hp = 0 to avoid errors due to roundness
2883 if(hp <= 0)
2884 {
2885 value = NB_OVERLAY_HEALTH_VALUES - 1;
2886 }
2887 else
2888 {
2889 uint32_t nbSteps = NB_OVERLAY_HEALTH_VALUES - 2;
2890 double healthStep = getMaxHp() / static_cast<double>(nbSteps);
2891 double tmpHealth = getMaxHp();
2892 for(value = 0; value < nbSteps; ++value)
2893 {
2894 if(hp >= tmpHealth)
2895 break;
2896
2897 tmpHealth -= healthStep;
2898 }
2899 }
2900
2901 if(mOverlayHealthValue != value)
2902 {
2903 mOverlayHealthValue = value;
2904 mNeedFireRefresh = true;
2905 }
2906}
2907
2908void Creature::computeCreatureOverlayMoodValue()
2909{

Callers 2

handleSleepMethod · 0.80
handleEatChickenMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected