GetValue
Category: Objects
/ Status
Since engine version: 4.6.5.0 CP
(extended in 4.9.1.0 GWE)
Description
Determines the value of an object. With idDef specified, the standard value of the original object definition is returned, otherwise the current value of the specified object (pObj) or the calling object if pObj is 0.
An object's value is determined as follows: with pObj specified it is first checked whether the CalcValue function is defined in the object's script and if so, it is evaluated. Otherwise, the definition value is used (see below). The resulting value is then reduced according to the object's completion.
Dead animals or clonks always have value 0.
The definition value is determined as follows: if the function CalcDefValue is defined in the definition script, it is evaluated. Otherwise, the value overload from Scenario.txt is used, if present. Otherwise, the standard value from DefCore is used.
Syntax
int GetValue
(object pObj, id idDef, object pBase, int iForPlayer);
Parameters
- pObj:
[opt]
Object of which to request a value. 0 if a local call or if idDef is specified.
- idDef:
[opt]
If specified: the definition of which to request the standard value. Otherwise the given object is evaluated.
- pBase:
[opt]
Home base in which to buy. If the CalcValue function is defined in pObj, the return value of CalcValue is used.
- iForPlayer:
[opt]
Player to whom the value applies. If the CalcValue function is defined in pObj, the return value of CalcValue is used in this case also.
Remark
The two parameters pBase and iForPlayer are designed for use in special trading in individual scenarios and are only processed by CalcValue/CalcDefValue calls.
Example
var iValue=GetValue();
while (iValue-->0) CreateContents(ROCK);
RemoveObject(0, 1);
Object script: the object creates as many rocks as it is worth and then self-destructs (expelling the rocks).
Sven2, März 2003