Category: Objects
/ Status
Since engine version: 1.0 OC
GetValue
Description
Determines the value of an object. If called as a definition call (e.g.
An object's value is determined as follows: with
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.
Rock->GetValue();
), the standard value of the original object definition is returned, otherwise the current value of the calling object.An object's value is determined as follows: with
base
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 base, int for_player);
Parameters
- base:
- [opt] Home base in which to buy. If the CalcValue function is defined in this object, the return value of CalcValue is used.
- for_player:
- [opt] Player to whom the value applies. If the CalcValue function is defined in this object, the return value of CalcValue is used in this case also.
Remark
The two parameters base and for_player are designed for use in special trading in individual scenarios and are only processed by CalcValue/CalcDefValue calls.
Example
var value = GetValue(); while (value-- > 0) CreateContents(Rock); RemoveObject(true);
Object script: the object creates as many rocks as it is worth and then self-destructs (expelling the rocks).