SetPhysical

Category: Objects / Status
Since engine version: 4.6.5.0 CP (extended in 4.9.6.0 CR)

Description

Changes the physical properties of an object. With this, the values from the Physical section of the DefCore.txt can be permanently or temporarily adapted.

Syntax

bool SetPhysical (string szPhysical, int iValue, int iMode, object pObj);

Parameters

szPhysical:
Name of property to be changed
iValue:
0-100000: new value for the property
iMode:
[opt] Physical attribute change mode (symbolical constants since CR):
Constant Value Meaning
PHYS_Current 0 The physical attributes are changed in the current mode (temporary or permanent) of the object.
PHYS_Permanent 1 The physical attributes are changed in permanent mode. This modifies the info section of the associated crew object, which means that the changes will be written to the player file as well. Only player crew objects have a permanent info section.
PHYS_Temporary 2 The object will be set to temporary physical mode, and a temporary info section will be created if none exists already. Use ResetPhysical to reset temporary physicals to permanent mode.
PHYS_StackTemporary 3 Like PHYS_Temporary, but the previous physical-value will be backed up and can be restored by calling ResetPhysical. Since CR.

pObj:
[opt] Object the physicals of which you want to change. Can be 0 in local calls.

Examples

protected func Activate(pEater)
  {
  [$DescEatPill$]
  SetPhysical("Magic", 1000000, PHYS_Temporary, pEater);
  while(DoMagicEnergy(1, pEater)) ;
  return(RemoveObject());
  }
Script for a magic pill: the eating clonk will temporarily gain magic energy.
protected func FxJumpBoostStart(object trg, int num, int iTemp)
  {
  SetPhysical("Jump", GetPhysical("Jump", PHYS_Current, trg) + 10000, PHYS_StackTemporary, trg);
  return(FX_OK);
  }
		
protected func FxJumpBoostStop(object trg, int num, int reason, bool tmp)
  {
  ResetPhysical(trg, "Jump");
  return(FX_OK);
  }
Script of an effect named JumpBoost: If created on a Clonk, it can jump higher until the effect is deleted again. Using PHYS_StackTemporary and ResetPhysical in this manner ensures that multiple effects written in this style can be combined without causing unwanted behaviour when one effect wears off while another remains.
See also: DefCore.txt, [Physical], GetPhysical, ResetPhysical, TrainPhysical
Sven2, Juni 2003