TrainPhysical

Category: Objects / Status
Since engine version: 4.9.6.0 CR

Description

Increases the physical property of an object by the specified value. This function will train permanent physicals as well as temporary physicals. This function can be used e.g. to enhance magic capabilities after casting spells.

Syntax

bool TrainPhysical (string szPhysical, int iTrainBy, int iMaxTrain, object pObj);

Parameters

szPhysical:
Name of property to be changed
iTrainBy:
0-100000: added training value
iMaxTrain:
Maximum training value. In no case, the physical property of the clonk will be modified, even if its value is lower than the value specified here.
pObj:
[opt] Object the physicals of which you want to change. Can be 0 in local calls.

Example

// Globaler Aufruf, wenn ein Zauber erfolgreich war: Magie trainieren
global func OnClonkSucceededSpell(id idSpell, object pClonk)
  {
  if (!pClonk) if (!(pClonk = this())) return(_inherited(idSpell));
  // Zauberkraft trainieren (plus 1/10 des Zauberwerts)
  if (!ObjectCount(NMGE))
    {
    var iMaxTrain, idInfo;
    // Maximales Training bei Infoobjekten: Nach Ursprungsdefinition richten
    if (idInfo = GetObjectInfoCoreVal("id", "ObjectInfo", pClonk)) iMaxTrain = idInfo->~MaxMagicPhysical();
    // Infodefinition hat kein MaxMagicPhysical (d.h., kein Zauberclonk) oder kein Infoobjekt vorhanden:
    // Training wird eh nicht permanent gesichert; nach aktueller Definition richten
    if (!iMaxTrain) iMaxTrain = pClonk->~MaxMagicPhysical();
    // Trainieren
    TrainPhysical("Magic", Value(idSpell)/MCLK_ManaTrainRate, iMaxTrain, pClonk);
    }
  // Gegebenenfalls weitere Hooks erlauben
  return (_inherited(idSpell, pClonk));
  }
Example from System.c4g: improves the sorcerer's magic physical value after each successfull spell. It is ensured that the physical value will not surpass the maximum limit specified in MaxMagicPhysical() of the definition.
See also: DefCore.txt, [Physical], GetPhysical, ResetPhysical, SetPhysical
Sven2, Juni 2003