SetPhysical

Category: Objects / Status
Since engine version: 5.1 OC

Description

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

Syntax

bool SetPhysical(string physical, int value, int mode);

Parameters

physical:
Name of property to be changed.
value:
0-100000: new value for the property
mode:
[opt] Physical attribute change mode:
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.

Examples

func ControlUse(object eater)
{
  eater->SetPhysical("Energy", 10000000, PHYS_Temporary);
  eater->DoEnergy(1000);
  RemoveObject();
}
Steroids - The clonk gains a ridiculous amount of energy for this round on eating.
protected func FxJumpBoostStart(object trg, effect, int temporary)
{
  trg->SetPhysical("Jump", trg->GetPhysical("Jump", PHYS_Current) + 10000, PHYS_StackTemporary);
  return FX_OK;
}
		
protected func FxJumpBoostStop(object trg, effect, int reason, bool tmp)
{
  trg->ResetPhysical("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, 2003-06