GetEnergy() offers exact energy value optionally (Bug #2043)

master
Mark 2018-12-20 08:40:04 +01:00
parent 11cfcdd910
commit 6351fe7a66
2 changed files with 21 additions and 3 deletions

View File

@ -7,7 +7,17 @@
<title>GetEnergy</title> <title>GetEnergy</title>
<category>Objects</category> <category>Objects</category>
<version>1.0 OC</version> <version>1.0 OC</version>
<syntax><rtype>int</rtype></syntax> <syntax>
<rtype>int</rtype>
<params>
<param>
<type>bool</type>
<name>exact</name>
<desc>If <code>true</code>, the exact energy value is returned.</desc>
<optional />
</param>
</params>
</syntax>
<desc>Returns the current energy value of an object. 100% representing the maximum physical value of 100,000</desc> <desc>Returns the current energy value of an object. 100% representing the maximum physical value of 100,000</desc>
<remark>For living beings, \"energy\" stands for health, in buildings it stands for electrical charge.</remark> <remark>For living beings, \"energy\" stands for health, in buildings it stands for electrical charge.</remark>
<related> <related>
@ -15,4 +25,5 @@
</related> </related>
</func> </func>
<author>jwk</author><date>2002-06</date> <author>jwk</author><date>2002-06</date>
<author>Marky</author><date>2018-12</date>
</funcs> </funcs>

View File

@ -558,9 +558,16 @@ static long FnGetPhase(C4Object *Obj)
return Obj->Action.Phase; return Obj->Action.Phase;
} }
static long FnGetEnergy(C4Object *Obj) static long FnGetEnergy(C4Object *Obj, bool fExact)
{ {
return 100*Obj->Energy/C4MaxPhysical; if (fExact)
{
return Obj->Energy;
}
else
{
return 100*Obj->Energy/C4MaxPhysical;
}
} }
static long FnGetBreath(C4Object *Obj) static long FnGetBreath(C4Object *Obj)